Changeset 4cbca0 for src/Parser
- Timestamp:
- Feb 7, 2011, 10:45:43 AM (14 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:
- 1a6bda, 311da7b
- Parents:
- 963321a
- git-author:
- Frederik Heber <heber@…> (02/04/11 14:03:06)
- git-committer:
- Frederik Heber <heber@…> (02/07/11 10:45:43)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/MpqcParser.cpp
r963321a r4cbca0 55 55 void MpqcParser::load(istream *file) 56 56 { 57 bool GeometryFollows = false; 57 bool MpqcSection = false; 58 bool MoleculeSection = false; 59 bool GeometrySection = false; 60 bool BasisSection = false; 61 bool AuxBasisSection = false; 58 62 char line[MAXSTRINGSIZE]; 59 63 typedef boost::tokenizer<boost::char_separator<char> > tokenizer; 60 64 boost::char_separator<char> sep("[]"); 65 boost::char_separator<char> angularsep("<>"); 66 boost::char_separator<char> equalitysep("="); 61 67 boost::char_separator<char> whitesep(" \t"); 62 68 ConvertTo<double> toDouble; … … 64 70 molecule *newmol = World::getInstance().createMolecule(); 65 71 newmol->ActiveFlag = true; 72 // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include 73 World::getInstance().getMolecules()->insert(newmol); 66 74 while (file->good()) { 67 75 file->getline(line, MAXSTRINGSIZE-1); 68 76 std::string linestring(line); 69 77 if ((linestring.find("atoms geometry") == string::npos) && (linestring.find("}") != string::npos)) { 70 GeometryFollows = false; 71 } 72 if (GeometryFollows) { // we have an atom 73 tokenizer tokens(linestring, sep); 74 // if (tokens.size() != 2) 75 // throw MpqcParseException; 78 GeometrySection = false; 79 } 80 if ((linestring.find(")") != string::npos)) { // ends a section which do not overlap 81 MpqcSection = false; 82 MoleculeSection = false; 83 BasisSection = false; 84 AuxBasisSection = false; 85 } 86 if (MoleculeSection) { 87 if (GeometrySection) { // we have an atom 88 tokenizer tokens(linestring, sep); 89 // if (tokens.size() != 2) 90 // throw MpqcParseException; 91 tokenizer::iterator tok_iter = tokens.begin(); 92 std::stringstream whitespacefilter(*tok_iter++); 93 std::string element; 94 whitespacefilter >> element; 95 std::string vector = *tok_iter; 96 tokenizer vectorcomponents(vector, whitesep); 97 Vector X; 98 // if (vectorcomponents.size() != NDIM) 99 // throw MpqcParseException; 100 tok_iter = vectorcomponents.begin(); 101 for (int i=0; i<NDIM; ++i) { 102 X[i] = toDouble(*tok_iter++); 103 } 104 // create atom 105 atom *newAtom = World::getInstance().createAtom(); 106 newAtom->setType(World::getInstance().getPeriode()->FindElement(element)); 107 newAtom->setPosition(X); 108 newmol->AddAtom(newAtom); 109 DoLog(1) && (Log() << Verbose(1) << "Adding atom " << *newAtom << std::endl); 110 } 111 } 112 if (MpqcSection) { 113 tokenizer tokens(linestring, equalitysep); 76 114 tokenizer::iterator tok_iter = tokens.begin(); 77 115 std::stringstream whitespacefilter(*tok_iter++); 78 std::string element; 79 whitespacefilter >> element; 80 std::string vector = *tok_iter; 81 tokenizer vectorcomponents(vector, whitesep); 82 Vector X; 83 // if (vectorcomponents.size() != NDIM) 84 // throw MpqcParseException; 85 tok_iter = vectorcomponents.begin(); 86 for (int i=0; i<NDIM; ++i) { 87 X[i] = toDouble(*tok_iter++); 88 } 89 // create atom 90 atom *newAtom = World::getInstance().createAtom(); 91 newAtom->setType(World::getInstance().getPeriode()->FindElement(element)); 92 newAtom->setPosition(X); 93 newmol->AddAtom(newAtom); 94 DoLog(1) && (Log() << Verbose(1) << "Adding atom " << *newAtom << std::endl); 116 std::string key(*tok_iter++); 117 if (params.haveParam(key)) { 118 std::stringstream linestream(linestring); 119 linestream >> params; 120 } else if (linestring.find("mole<") != string::npos) { // get theory 121 tokenizer tokens(linestring, angularsep); 122 tokenizer::iterator tok_iter = tokens.begin(); 123 std::string value(*(++tok_iter)); 124 std::stringstream linestream("theory = "+value); 125 linestream >> params; 126 } else if (linestring.find("integrals<") != string::npos) { // get theory 127 tokenizer tokens(linestring, angularsep); 128 tokenizer::iterator tok_iter = tokens.begin(); 129 std::string value(*(++tok_iter)); 130 std::stringstream linestream("integration = "+value); 131 linestream >> params; 132 } 133 } 134 if (BasisSection) { 135 tokenizer tokens(linestring, equalitysep); 136 tokenizer::iterator tok_iter = tokens.begin(); 137 std::string key(*tok_iter++); 138 std::string value(*tok_iter); 139 // TODO: use exception instead of ASSERT 140 ASSERT(tok_iter == tokens.end(), 141 "MpqcParser::load() - more than (key = value) on line "+linestring+"."); 142 if (key == "name") { 143 std::stringstream linestream("basis = "+value); 144 linestream >> params; 145 } 146 } 147 if (AuxBasisSection) { 148 tokenizer tokens(linestring, equalitysep); 149 tokenizer::iterator tok_iter = tokens.begin(); 150 std::string key(*tok_iter++); 151 std::string value(*tok_iter); 152 // TODO: use exception instead of ASSERT 153 ASSERT(tok_iter == tokens.end(), 154 "MpqcParser::load() - more than (key = value) on line "+linestring+"."); 155 if (key == "name") { 156 std::stringstream linestream("aux_basis = "+value); 157 linestream >> params; 158 } 95 159 } 96 160 // set some scan flags 161 if (linestring.find("mpqc:") != string::npos) { 162 MpqcSection = true; 163 } 164 if (linestring.find("molecule<Molecule>:") != string::npos) { 165 MoleculeSection = true; 166 } 97 167 if (linestring.find("atoms geometry") != string::npos) { 98 GeometryFollows = true; 168 GeometrySection = true; 169 } 170 if ((linestring.find("basis<GaussianBasisSet>:") != string::npos) && ((linestring.find("abasis<") == string::npos))) { 171 BasisSection = true; 172 } 173 if (linestring.find("abasis<") != string::npos) { 174 AuxBasisSection = true; 99 175 } 100 176 }
Note:
See TracChangeset
for help on using the changeset viewer.