- Timestamp:
- Jul 8, 2013, 2:22:01 PM (12 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:
- a953c4
- Parents:
- bbc422
- git-author:
- Frederik Heber <heber@…> (06/26/13 18:37:57)
- git-committer:
- Frederik Heber <heber@…> (07/08/13 14:22:01)
- Location:
- src/Potentials
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Potentials/SerializablePotential.cpp
rbbc422 r5f0c60 113 113 typedef boost::tokenizer<boost::char_separator<char> > tokenizer; 114 114 boost::char_separator<char> pairsep(",\t ;"); 115 boost::char_separator<char> keyvaluesep("=");116 115 std::string remainderstring(linestring.substr(colonpos+1)); 117 // {118 // std::stringstream remainderstream119 // remainderstream >> std::ws >> remainderstring;120 // }121 116 tokenizer tokens(remainderstring, pairsep); //skip colon 122 117 … … 128 123 tok_iter != tokens.end(); ++tok_iter) { 129 124 const std::string &keyvalue = *tok_iter; 130 tokenizer keyvaluetoken(keyvalue, keyvaluesep);131 tokenizer::iterator keyvalue_iter = keyvaluetoken.begin();132 const std::string &key = *keyvalue_iter;125 const size_t equalitypos = keyvalue.find("="); 126 const std::string key = keyvalue.substr(0,equalitypos); 127 const std::string value = keyvalue.substr(equalitypos+1); 133 128 134 129 /// parse the particle_types 135 const size_t pos = key.find("particle_type"); 130 const std::string typetoken("particle_type"); 131 const size_t pos = key.find(typetoken); 136 132 if (pos != std::string::npos) { 137 133 // split of type and convert rest to index 138 const size_t index = ConvertToIndex(key.substr(pos, std::string::npos)); 134 const size_t indexpos = pos+typetoken.length(); 135 const std::string &indexstring = key.substr(indexpos); 136 const size_t index = ConvertToIndex(indexstring); 137 if(index == 0) 138 throw SerializablePotentialMissingValueException() << SerializablePotentialKey(key); 139 139 // and set the type 140 if ( ++keyvalue_iter == keyvaluetoken.end())140 if (equalitypos == std::string::npos) 141 141 throw SerializablePotentialMissingValueException() << SerializablePotentialKey(key); 142 const std::string &value = *keyvalue_iter; 143 setParticleType(index, ConvertToParticleType(value)); 142 setParticleType(index-1, ConvertToParticleType(value)); 144 143 } else { 145 144 const size_t index = getParameterIndex(key); 146 145 // parse the coefficients 147 146 if (index != (size_t)-1) { 148 if ( ++keyvalue_iter == keyvaluetoken.end())147 if (equalitypos == std::string::npos) 149 148 throw SerializablePotentialMissingValueException() << SerializablePotentialKey(key); 150 const std::string &value = *keyvalue_iter;151 149 params[index] = ConvertToValue(value); 152 150 } else { -
src/Potentials/SerializablePotential.hpp
rbbc422 r5f0c60 141 141 void setParticleType(const size_t index, const ParticleType_t& _designation) 142 142 { 143 const_cast<ParticleTypes_t &>(ParticleTypes).resize(index); 143 if (ParticleTypes.size() <= index) 144 const_cast<ParticleTypes_t &>(ParticleTypes).resize(index+1); 144 145 const_cast<ParticleTypes_t &>(ParticleTypes)[index] = _designation; 145 146 }
Note:
See TracChangeset
for help on using the changeset viewer.