Changeset 740f9f for src


Ignore:
Timestamp:
May 18, 2016, 10:03:03 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
2fe4a5
Parents:
045228
git-author:
Frederik Heber <heber@…> (03/16/16 10:20:02)
git-committer:
Frederik Heber <heber@…> (05/18/16 22:03:03)
Message:

TremoloParser::readAtomDataLine() uses ParticleRegistry and Periodentafel for looking up elements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TremoloParser.cpp

    r045228 r740f9f  
    5050#include "Element/periodentafel.hpp"
    5151#include "LinearAlgebra/RealSpaceMatrix.hpp"
     52#include "Potentials/Particles/ParticleRegistry.hpp"
    5253#include "molecule.hpp"
    5354#include "World.hpp"
     
    702703  ConvertTo<int> toInt;
    703704  Vector tempVector;
     705  const ParticleRegistry& registry = ParticleRegistry::getConstInstance();
     706  const periodentafel& periode = *World::getInstance().getPeriode();
    704707
    705708  // setup tokenizer, splitting up white-spaced entries
     
    753756        ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");
    754757        LOG(4, "INFO: Parsing key " << keyName << " with next token " << word);
    755         std::string element;
    756         try {
    757           element = knownTypes.getType(word);
    758         } catch(IllegalParserKeyException) {
    759           // clean up
    760           World::getInstance().destroyAtom(newAtom);
    761           // give an error
    762           ELOG(0, "TremoloParser: I do not understand the element token " << word << ".");
    763           return;
     758        std::string elementname;
     759        const element * elem = NULL;
     760        if (!registry.isPresentByName(word)) {
     761          std::string lowercase_word(word);
     762          std::transform(word.begin()+1, word.end(), lowercase_word.begin()+1, ::tolower);
     763          elem = periode.FindElement(lowercase_word);
     764          if (elem == NULL) {
     765            // clean up
     766            World::getInstance().destroyAtom(newAtom);
     767            // give an error
     768            ELOG(0, "TremoloParser: tokens " << word << "/" << lowercase_word
     769                << " is unknown to neither ParticleRegistry nor Periodentafel.");
     770            return;
     771          } else {
     772            elementname = elem->getSymbol();
     773          }
     774        } else {
     775          const Particle * const p = registry.getByName(word);
     776          elementname = p->getElement();
     777          elem = periode.FindElement(elementname);
    764778        }
    765779        // put type name into container for later use
    766780        atomInfo->set(currentField, word);
    767         LOG(4, "INFO: Parsing element " << (word) << " as " << element << " according to KnownTypes.");
     781        LOG(4, "INFO: Parsing element " << (word) << " as " << elementname << " according to KnownTypes.");
    768782        tok_iter++;
    769         newAtom->setType(World::getInstance().getPeriode()->FindElement(element));
     783        newAtom->setType(elem);
    770784        ASSERT(newAtom->getType(), "Type was not set for this atom");
    771785        break;
Note: See TracChangeset for help on using the changeset viewer.