- Timestamp:
- Feb 27, 2013, 12:43:29 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:
- da2d5c
- Parents:
- dbcc47
- git-author:
- Frederik Heber <heber@…> (12/18/12 12:39:10)
- git-committer:
- Frederik Heber <heber@…> (02/27/13 12:43:29)
- Location:
- src/Potentials
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Potentials/SerializablePotential.cpp
rdbcc47 r3d2559 51 51 std::ostream& operator<<(std::ostream &ost, const SerializablePotential &potential) 52 52 { 53 potential.stream_to(ost); 54 return ost; 55 } 56 57 void SerializablePotential::stream_to(std::ostream &ost) const 58 { 53 59 // check stream 54 60 if (ost.bad()) … … 56 62 57 63 /// print parameter key 58 ost << potential.getToken() << ":";64 ost << getToken() << ":"; 59 65 /// print associated particles 60 const SerializablePotential::ParticleTypes_t &types = potential.getParticleTypes();66 const SerializablePotential::ParticleTypes_t &types = getParticleTypes(); 61 67 for (size_t index=0; index < types.size(); ++index) { 62 68 ost << "\tparticle_type" << index+1 << "=" << types[index]; … … 64 70 } 65 71 /// print coefficients 66 const SerializablePotential::ParameterNames_t ¶mNames = potential.getParameterNames();67 const SerializablePotential::parameters_t ¶ms = potential.getParameters();72 const SerializablePotential::ParameterNames_t ¶mNames = getParameterNames(); 73 const SerializablePotential::parameters_t ¶ms = getParameters(); 68 74 SerializablePotential::ParameterNames_t::const_iterator nameiter = paramNames.begin(); 69 75 SerializablePotential::parameters_t::const_iterator valueiter = params.begin(); … … 76 82 /// print terminating semi-colon 77 83 ost << ";"; 78 return ost;79 84 } 80 85 81 86 std::istream& operator>>(std::istream &ist, SerializablePotential &potential) 87 { 88 potential.stream_from(ist); 89 return ist; 90 } 91 92 void SerializablePotential::stream_from(std::istream &ist) 82 93 { 83 94 // check stream … … 86 97 87 98 // create copy of current parameters, hence line may contain not all required 88 SerializablePotential::parameters_t params( potential.getParameters());99 SerializablePotential::parameters_t params(getParameters()); 89 100 90 101 // read in full line … … 95 106 const size_t colonpos = linestring.find(":"); 96 107 if ((strBegin == std::string::npos) || (colonpos == std::string::npos) || 97 (linestring.substr(strBegin, colonpos-1) != potential.getToken()))108 (linestring.substr(strBegin, colonpos-1) != getToken())) 98 109 throw SerializablePotentialMissingValueException() 99 << SerializablePotentialKey( potential.getName());110 << SerializablePotentialKey(getName()); 100 111 101 112 // tokenize by "," … … 130 141 throw SerializablePotentialMissingValueException() << SerializablePotentialKey(key); 131 142 const std::string &value = *keyvalue_iter; 132 potential.setParticleType(index, ConvertToParticleType(value));143 setParticleType(index, ConvertToParticleType(value)); 133 144 } else { 134 const size_t index = potential.getParameterIndex(key);145 const size_t index = getParameterIndex(key); 135 146 // parse the coefficients 136 147 if (index != (size_t)-1) { … … 146 157 147 158 /// set the new paremeters 148 potential.setParameters(params); 149 return ist; 159 setParameters(params); 150 160 } 151 161 -
src/Potentials/SerializablePotential.hpp
rdbcc47 r3d2559 37 37 class SerializablePotential 38 38 { 39 //!> grant operator access to private functions40 friend std::ostream& operator<<(std::ostream &ost, const SerializablePotential &potential);41 //!> grant operator access to private functions42 friend std::istream& operator>>(std::istream &ost, SerializablePotential &potential);43 44 39 public: 45 40 //!> typedef for particle designation … … 113 108 const size_t getParameterIndex(const std::string &_name) const; 114 109 110 /** Print parameters to given stream \a ost. 111 * 112 * These are virtual functions to allow for overriding and hence 113 * changing the default behavior. 114 * 115 * @param ost stream to print to 116 */ 117 virtual void stream_to(std::ostream &ost) const; 118 119 /** Parse parameters from given stream \a ist. 120 * 121 * These are virtual functions to allow for overriding and hence 122 * changing the default behavior. 123 * 124 * @param ist stream to parse from 125 */ 126 virtual void stream_from(std::istream &ist); 127 115 128 protected: 116 129 -
src/Potentials/Specifics/SaturationPotential.cpp
rdbcc47 r3d2559 174 174 params[angle_equilibrium_distance] = angle_params[PairPotential_Angle::equilibrium_distance]; 175 175 return params; 176 } 177 178 void SaturationPotential::stream_to(std::ostream &ost) const 179 { 180 morse.stream_to(ost); 181 ost << std::endl; 182 angle.stream_to(ost); 183 } 184 185 void SaturationPotential::stream_from(std::istream &ist) 186 { 187 morse.stream_from(ist); 188 ist >> ws; 189 angle.stream_from(ist); 176 190 } 177 191 … … 379 393 "SaturationPotential::symmetrizeTypes() - failed to generate three types for angle."); 380 394 return types; 381 }382 383 std::ostream& operator<<(std::ostream &ost, const SaturationPotential &potential)384 {385 ost << potential.morse;386 ost << potential.angle;387 return ost;388 }389 390 std::istream& operator>>(std::istream &ist, SaturationPotential &potential)391 {392 ist >> potential.morse;393 ist >> potential.angle;394 return ist;395 395 } 396 396 -
src/Potentials/Specifics/SaturationPotential.hpp
rdbcc47 r3d2559 128 128 { return ParameterNames; } 129 129 130 /** Print parameters for both Morse and Angle potential. 131 * 132 * We override default parameter printing of SeralizablePotential 133 * to print both parameters 134 * 135 * @param ost stream to print to 136 */ 137 virtual void stream_to(std::ostream &ost) const; 138 139 /** Parse parameters for both Morse and Angle potential. 140 * 141 * We override default parameter parsing of SeralizablePotential 142 * to parse both parameters 143 * 144 * @param ist stream to parse from 145 */ 146 virtual void stream_from(std::istream &ist); 147 130 148 /** States whether lower and upper boundaries should be used to constraint 131 149 * the parameter search for this function model. … … 198 216 }; 199 217 200 /** Output operations stores .potentials line containing these parameters201 * coefficients and designations.202 *203 * \note We have to overrride this function in order to print both potentials204 * separately.205 *206 * \param ost output stream to print to207 * \param potential potential whose coefficients to print208 * \return output stream for concatenation209 */210 std::ostream& operator<<(std::ostream &ost, const SaturationPotential &potential);211 212 /** Input operation parses coefficients from a given line of a .potentials213 * file.214 *215 * \note We have to override this function in order to parse both potentials216 * separately.217 *218 * \param ist input stream to parse from219 * \param potential potential to set220 * \return input stream for concatenation221 */222 std::istream& operator>>(std::istream &ist, SaturationPotential &potential);223 218 224 219 #endif /* SATURATIONPOTENTIAL_HPP_ */
Note:
See TracChangeset
for help on using the changeset viewer.