Changeset a275b3
- Timestamp:
- Apr 3, 2012, 7:58:43 AM (13 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, 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_BoundInBox_CenterInBox_MoleculeActions, 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, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, 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:
- ccb487
- Parents:
- d9005c1
- git-author:
- Frederik Heber <heber@…> (03/12/12 15:11:36)
- git-committer:
- Frederik Heber <heber@…> (04/03/12 07:58:43)
- Location:
- src/Parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TremoloParser.cpp
rd9005c1 ra275b3 437 437 ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!"); 438 438 LOG(4, "INFO: Parsing key " << keyName << " with next token " << *tok_iter); 439 std::string element(knownTypes[(*tok_iter)]); 439 std::string element; 440 try { 441 element = knownTypes.getType(*tok_iter); 442 } catch(IllegalParserKeyException) { 443 // clean up 444 World::getInstance().destroyAtom(newAtom); 445 // give an error 446 ELOG(0, "TremoloParser: I do not understand the element token " << *tok_iter << "."); 447 } 440 448 // put type name into container for later use 441 449 atomInfo->set(currentField, *tok_iter); … … 612 620 } 613 621 614 /** Creates knownTypes as the identity, e.g. H -> H, He -> He, ... .615 *616 */617 void FormatParser< tremolo >::createKnownTypesByIdentity()618 {619 // remove old mapping620 knownTypes.clear();621 // make knownTypes the identity mapping622 const periodentafel *periode = World::getInstance().getPeriode();623 for (periodentafel::const_iterator iter = periode->begin();624 iter != periode->end();625 ++iter) {626 knownTypes.insert( make_pair(iter->second->getSymbol(), iter->second->getSymbol()) );627 }628 }629 630 /** Parses a .potentials file and creates from it the knownTypes file.631 *632 * @param file input stream of .potentials file633 */634 void FormatParser< tremolo >::parseKnownTypes(std::istream &file)635 {636 const periodentafel *periode = World::getInstance().getPeriode();637 // remove old mapping638 knownTypes.clear();639 640 // LOG(3, "INFO: additionalAtomData contains: " << additionalAtomData);641 642 // parse in file643 typedef boost::tokenizer<boost::char_separator<char> >644 tokenizer;645 boost::char_separator<char> tokensep(":\t ,;");646 boost::char_separator<char> equalitysep("\t =");647 std::string line;648 while (file.good()) {649 std::getline( file, line );650 LOG(4, "INFO: full line of parameters is '" << line << "'");651 if (line.find("particle:") != string::npos) {652 LOG(3, "INFO: found line '" << line << "' containing keyword 'particle:'.");653 tokenizer tokens(line, tokensep);654 ASSERT(tokens.begin() != tokens.end(),655 "FormatParser< tremolo >::parseKnownTypes() - line with 'particle:' but no particles separated by comma.");656 // look for particle_type657 std::string particle_type("NULL");658 std::string element_type("NULL");659 for (tokenizer::iterator tok_iter = tokens.begin();660 tok_iter != tokens.end();661 ++tok_iter) {662 if ((*tok_iter).find("particle_type") != string::npos) {663 LOG(3, "INFO: found token '" << *tok_iter << "' containing keyword 'particle_type'.");664 tokenizer token((*tok_iter), equalitysep);665 ASSERT(token.begin() != token.end(),666 "FormatParser< tremolo >::parseKnownTypes() - could not split particle_type by equality sign");667 tokenizer::iterator particle_iter = token.begin();668 particle_iter++;669 particle_type = *particle_iter;670 }671 if ((*tok_iter).find("element_name") != string::npos) {672 LOG(3, "INFO: found token '" << *tok_iter << "' containing keyword 'element_name'.");673 tokenizer token((*tok_iter), equalitysep);674 ASSERT(token.begin() != token.end(),675 "FormatParser< tremolo >::parseKnownTypes() - could not split particle_type by equality sign");676 tokenizer::iterator element_iter = token.begin();677 element_iter++;678 element_type = *element_iter;679 }680 }681 if ((particle_type != "NULL") && (element_type != "NULL")) {682 if (periode->FindElement(element_type) != NULL) {683 LOG(1, "INFO: Added Type " << particle_type << " as reference to element " << element_type << ".");684 knownTypes.insert( make_pair (particle_type, element_type) );685 } else {686 ELOG(1, "INFO: Either Type " << particle_type << " or " << element_type << " could not be recognized." );687 }688 } else {689 ELOG(3, "Line does not contain both 'particle_type' and 'element_name' as keys." );690 }691 }692 }693 694 } -
src/Parser/TremoloParser.hpp
rd9005c1 ra275b3 22 22 #include "ParserTypes.hpp" 23 23 24 #include "TremoloParser_ElementKeys.hpp" 24 25 #include "TremoloKey.hpp" 25 26 #include "TremoloAtomInfoContainer.hpp" … … 51 52 void save(std::ostream* file, const std::vector<atom *> &atoms); 52 53 void setFieldsForSave(std::string atomDataLine); 54 void setAtomData(const std::string &atomdata_string); 53 55 54 void parseKnownTypes(std::istream &file); 55 void createKnownTypesByIdentity(); 56 void setAtomData(const std::string &atomdata_string); 56 private: 57 /** 58 * Map to associate element keys with the respective elements. 59 */ 60 struct ElementKeys knownTypes; 61 62 public: 63 64 void parseKnownTypes(std::istream &file) 65 { 66 knownTypes.parseKnownTypes(file); 67 } 68 void createKnownTypesByIdentity() 69 { 70 knownTypes.createKnownTypesByIdentity(); 71 } 57 72 58 73 protected: … … 72 87 void writeNeighbors(std::ostream* file, int numberOfNeighbors, atom* currentAtom); 73 88 void saveLine(std::ostream* file, atom* currentAtom); 74 75 /**76 * Map to associate the elements with stuff in "type", e.g. OC2 -> O.77 */78 std::map<std::string, std::string> knownTypes;79 89 80 90 /**
Note:
See TracChangeset
for help on using the changeset viewer.