Changes in / [c7fe90:5c8807]
- Files:
-
- 18 added
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/userguide/userguide.xml
rc7fe90 r5c8807 955 955 domain.</para> 956 956 </section> 957 958 <section xml:id='atoms.mirror-atoms'> 959 <title xml:id='atoms.mirror-atoms.title'>Mirroring atoms</title> 960 961 <para>Present (and selected) atoms can be mirrored with respect to 962 a certain plane. You have to specify the normal vector of the plane 963 and the offset with respect to the origin as follows</para> 964 965 <programlisting> 966 ... --mirror-atoms "1,0,0" \ 967 --plane-offset 10.1 \ 968 --periodic 0 969 </programlisting> 970 </section> 957 971 958 972 <section xml:id='atoms.translate-to-origin'> … … 2133 2147 a fragment of order 1, e.g. a single hydrogen atom.</para> 2134 2148 </note> 2149 </section> 2150 2151 <section xml:id='potentials.fit-compound-potential'> 2152 <title xml:id='potentials.fit-compound-potential.title'>Fitting 2153 many empirical potentials simultaneously</title> 2154 2135 2155 2136 2156 <para>Another way is using a file containing a specific set of … … 2138 2158 2139 2159 <programlisting> 2140 ... --fit- potential \2160 ... --fit-compound-potential \ 2141 2161 --fragment-charges 8 1 1 \ 2142 2162 --potential-file water.potentials \ … … 2160 2180 type of analysis.</para> 2161 2181 2162 <para>Note that you can combine the two ways, i.e. start with the 2163 first but give an empty potential file. The resulting parameters are 2164 stored in this way. Fit other potentials and give different file 2165 names for each. Eventually, you have to combine the file in a text 2166 editor at the moment.</para> 2182 <para>Note that you can combine the two ways, i.e. start with a 2183 fit-potential call but give an empty potential file. The resulting 2184 parameters are stored in it. Fit other potentials and give different 2185 file names for each in turn. Eventually, you have to combine the file 2186 in a text editor at the moment. And perform a fit-compound-potential 2187 with this file.</para> 2188 </section> 2189 2190 2191 <section xml:id='potentials.parse-potential'> 2192 <title xml:id='potentials.parse-potential.title'>Parsing an 2193 empirical potentials file</title> 2194 2195 <para>Responsible for the compound potential is every potential 2196 function whose signature matches with the designated fragment-charges 2197 and who is currently known to an internal instance called the 2198 PotentialRegistry.</para> 2199 2200 <para>More potentials can be registered (fit-potential will also 2201 register the potential it fits) by parsing them from a file.</para> 2202 2203 <programlisting> 2204 ... --parse-potentials water.potentials 2205 </programlisting> 2206 2207 <note>Currently, only <productname>TREMOLO</productname> potential 2208 files are understood and can be parsed.</note> 2209 </section> 2210 2211 <section xml:id='potentials.save-potential'> 2212 <title xml:id='potentials.save-potential.title'>Saving an 2213 empirical potentials file</title> 2214 2215 <para>The opposite to parse-potentials is save-potentials that writes 2216 every potential currently known to the PotentialRegistry to the given 2217 file along with the currently fitted parameters</para> 2218 2219 <programlisting> 2220 ... --save-potentials water.potentials 2221 </programlisting> 2222 2223 <note>Again, only the <productname>TREMOLO</productname> potential 2224 format is understood currently and is written.</note> 2167 2225 </section> 2168 2226 -
src/Actions/GlobalListOfActions.hpp
rc7fe90 r5c8807 32 32 (AtomAdd) \ 33 33 (AtomChangeElement) \ 34 (AtomMirror) \ 34 35 (AtomRemove) \ 35 36 (AtomRotateAroundOriginByAngle) \ … … 85 86 (PotentialFitParticleCharges) \ 86 87 (PotentialParseHomologies) \ 88 (PotentialParsePotentials) \ 87 89 (PotentialSaveHomologies) \ 90 (PotentialSavePotentials) \ 88 91 (ParserParseTremoloPotentials) \ 89 92 (ParserSaveSelectedAtomsAsExtTypes) \ … … 150 153 #define GLOBALLISTOFACTIONS_LEVMAR \ 151 154 BOOST_PP_SEQ_PUSH_BACK( \ 152 GLOBALLISTOFACTIONS_initial, \ 153 PotentialFitPotential \ 155 BOOST_PP_SEQ_PUSH_BACK( \ 156 GLOBALLISTOFACTIONS_initial, \ 157 PotentialFitPotential \ 158 ), \ 159 PotentialFitCompoundPotential \ 154 160 ) 155 161 #else -
src/Actions/Makefile.am
rc7fe90 r5c8807 147 147 Actions/AtomAction/AddAction.cpp \ 148 148 Actions/AtomAction/ChangeElementAction.cpp \ 149 Actions/AtomAction/MirrorAction.cpp \ 149 150 Actions/AtomAction/RemoveAction.cpp \ 150 151 Actions/AtomAction/RotateAroundOriginByAngleAction.cpp \ … … 155 156 Actions/AtomAction/AddAction.hpp \ 156 157 Actions/AtomAction/ChangeElementAction.hpp \ 158 Actions/AtomAction/MirrorAction.hpp \ 157 159 Actions/AtomAction/RemoveAction.hpp \ 158 160 Actions/AtomAction/RotateAroundOriginByAngleAction.hpp \ … … 163 165 Actions/AtomAction/AddAction.def \ 164 166 Actions/AtomAction/ChangeElementAction.def \ 167 Actions/AtomAction/MirrorAction.def \ 165 168 Actions/AtomAction/RemoveAction.def \ 166 169 Actions/AtomAction/RotateAroundOriginByAngleAction.def \ … … 357 360 Actions/PotentialAction/FitParticleChargesAction.cpp \ 358 361 Actions/PotentialAction/ParseHomologiesAction.cpp \ 359 Actions/PotentialAction/SaveHomologiesAction.cpp 362 Actions/PotentialAction/ParsePotentialsAction.cpp \ 363 Actions/PotentialAction/SaveHomologiesAction.cpp \ 364 Actions/PotentialAction/SavePotentialsAction.cpp 360 365 POTENTIALACTIONHEADER = \ 361 366 Actions/PotentialAction/FitParticleChargesAction.hpp \ 362 367 Actions/PotentialAction/ParseHomologiesAction.hpp \ 363 Actions/PotentialAction/SaveHomologiesAction.hpp 368 Actions/PotentialAction/ParsePotentialsAction.hpp \ 369 Actions/PotentialAction/SaveHomologiesAction.hpp \ 370 Actions/PotentialAction/SavePotentialsAction.hpp 364 371 POTENTIALACTIONDEFS = \ 365 372 Actions/PotentialAction/FitParticleChargesAction.def \ 366 373 Actions/PotentialAction/ParseHomologiesAction.def \ 367 Actions/PotentialAction/SaveHomologiesAction.def 374 Actions/PotentialAction/ParsePotentialsAction.def \ 375 Actions/PotentialAction/SaveHomologiesAction.def \ 376 Actions/PotentialAction/SavePotentialsAction.def 368 377 369 378 if CONDLEVMAR 370 379 POTENTIALACTIONSOURCE += \ 380 Actions/PotentialAction/FitCompoundPotentialAction.cpp \ 371 381 Actions/PotentialAction/FitPotentialAction.cpp 372 382 POTENTIALACTIONHEADER += \ 383 Actions/PotentialAction/FitCompoundPotentialAction.hpp \ 373 384 Actions/PotentialAction/FitPotentialAction.hpp 374 385 POTENTIALACTIONDEFS += \ 386 Actions/PotentialAction/FitCompoundPotentialAction.def \ 375 387 Actions/PotentialAction/FitPotentialAction.def 376 388 endif -
src/Actions/MoleculeAction/ForceAnnealingAction.cpp
rc7fe90 r5c8807 79 79 ++iter) { 80 80 atom * const Walker = iter->second; 81 Walker->UpdateSteps();82 81 Walker->setPositionAtStep(CurrentStep+1, 83 82 Walker->getPositionAtStep(CurrentStep)); -
src/Actions/MoleculeAction/VerletIntegrationAction.cpp
rc7fe90 r5c8807 56 56 using namespace MoleCuilder; 57 57 58 enum {58 enum VectorIndexType { 59 59 PositionIndex=0, 60 60 VelocityIndex=1, 61 61 ForceIndex=2, 62 62 MAXINDEX 63 } VectorIndexType;63 }; 64 64 65 65 // and construct the stuff … … 134 134 135 135 // remove current step for all modified atoms 136 removeLastStep(getIdsFromAtomicInfo(state->UndoInfo) );136 removeLastStep(getIdsFromAtomicInfo(state->UndoInfo), CurrentStep); 137 137 138 138 // and set back the old step (forces have been changed) … … 151 151 152 152 // set stored new state 153 addNewStep(state->UndoInfo); 153 size_t CurrentStep = WorldTime::getInstance().getTime()+1; 154 addNewStep(state->UndoInfo, CurrentStep); 154 155 155 156 // add a new time step 156 size_t CurrentStep = WorldTime::getInstance().getTime(); 157 World::getInstance().setTime(CurrentStep+1); 157 World::getInstance().setTime(CurrentStep); 158 158 159 159 // and set positions of the new step -
src/Actions/PotentialAction/FitPotentialAction.cpp
rc7fe90 r5c8807 55 55 #include "Fragmentation/Homology/HomologyGraph.hpp" 56 56 #include "Fragmentation/Summation/SetValues/Fragment.hpp" 57 #include "FunctionApproximation/Extractors.hpp" 58 #include "FunctionApproximation/FunctionApproximation.hpp" 59 #include "FunctionApproximation/FunctionModel.hpp" 60 #include "FunctionApproximation/TrainingData.hpp" 61 #include "FunctionApproximation/writeDistanceEnergyTable.hpp" 62 #include "Potentials/CompoundPotential.hpp" 63 #include "Potentials/Exceptions.hpp" 64 #include "Potentials/PotentialDeserializer.hpp" 57 #include "Potentials/EmpiricalPotential.hpp" 65 58 #include "Potentials/PotentialFactory.hpp" 66 59 #include "Potentials/PotentialRegistry.hpp" 67 60 #include "Potentials/PotentialSerializer.hpp" 61 #include "Potentials/PotentialTrainer.hpp" 68 62 #include "Potentials/SerializablePotential.hpp" 63 #include "World.hpp" 69 64 70 65 using namespace MoleCuilder; … … 75 70 /** =========== define the function ====================== */ 76 71 77 HomologyGraph getFirstGraphwithSpecifiedElements(78 const HomologyContainer &homologies,79 const SerializablePotential::ParticleTypes_t &types)80 {81 ASSERT( !types.empty(),82 "getFirstGraphwithSpecifiedElements() - charges is empty?");83 // create charges84 Fragment::charges_t charges;85 charges.resize(types.size());86 std::transform(types.begin(), types.end(),87 charges.begin(), boost::lambda::_1);88 // convert into count map89 Extractors::elementcounts_t counts_per_charge =90 Extractors::_detail::getElementCounts(charges);91 ASSERT( !counts_per_charge.empty(),92 "getFirstGraphwithSpecifiedElements() - charge counts are empty?");93 LOG(2, "DEBUG: counts_per_charge is " << counts_per_charge << ".");94 // we want to check each (unique) key only once95 for (HomologyContainer::const_key_iterator iter = homologies.key_begin();96 iter != homologies.key_end(); iter = homologies.getNextKey(iter)) {97 // check if every element has the right number of counts98 Extractors::elementcounts_t::const_iterator countiter = counts_per_charge.begin();99 for (; countiter != counts_per_charge.end(); ++countiter)100 if (!(*iter).hasTimesAtomicNumber(101 static_cast<size_t>(countiter->first),102 static_cast<size_t>(countiter->second))103 )104 break;105 if( countiter == counts_per_charge.end())106 return *iter;107 }108 return HomologyGraph();109 }110 111 SerializablePotential::ParticleTypes_t getNumbersFromElements(112 const std::vector<const element *> &fragment)113 {114 SerializablePotential::ParticleTypes_t fragmentnumbers;115 std::transform(fragment.begin(), fragment.end(), std::back_inserter(fragmentnumbers),116 boost::bind(&element::getAtomicNumber, _1));117 return fragmentnumbers;118 }119 120 121 72 ActionState::ptr PotentialFitPotentialAction::performCall() { 122 73 // fragment specifies the homology fragment to use 123 74 SerializablePotential::ParticleTypes_t fragmentnumbers = 124 getNumbersFromElements(params.fragment.get());75 PotentialTrainer::getNumbersFromElements(params.fragment.get()); 125 76 126 77 // either charges and a potential is specified or a file 127 if (boost::filesystem::exists(params.potential_file.get())) { 128 std::ifstream returnstream(params.potential_file.get().string().c_str()); 129 if (returnstream.good()) { 130 try { 131 PotentialDeserializer deserialize(returnstream); 132 deserialize(); 133 } catch (SerializablePotentialMissingValueException &e) { 134 if (const std::string *key = boost::get_error_info<SerializablePotentialKey>(e)) 135 STATUS("Missing value when parsing information for potential "+*key+"."); 136 else 137 STATUS("Missing value parsing information for potential with unknown key."); 138 return Action::failure; 139 } catch (SerializablePotentialIllegalKeyException &e) { 140 if (const std::string *key = boost::get_error_info<SerializablePotentialKey>(e)) 141 STATUS("Illegal key parsing information for potential "+*key+"."); 142 else 143 STATUS("Illegal key parsing information for potential with unknown key."); 144 return Action::failure; 145 } 146 } else { 147 STATUS("Failed to parse from "+params.potential_file.get().string()+"."); 148 return Action::failure; 78 if (params.charges.get().empty()) { 79 STATUS("No charges given!"); 80 return Action::failure; 81 } else { 82 // charges specify the potential type 83 SerializablePotential::ParticleTypes_t chargenumbers = 84 PotentialTrainer::getNumbersFromElements(params.charges.get()); 85 86 LOG(0, "STATUS: I'm training now a " << params.potentialtype.get() 87 << " potential on charges " << chargenumbers << " on data from World's homologies."); 88 89 // register desired potential and an additional constant one 90 { 91 EmpiricalPotential *potential = 92 PotentialFactory::getInstance().createInstance( 93 params.potentialtype.get(), 94 chargenumbers); 95 // check whether such a potential already exists 96 const std::string potential_name = potential->getName(); 97 if (PotentialRegistry::getInstance().isPresentByName(potential_name)) { 98 delete potential; 99 potential = PotentialRegistry::getInstance().getByName(potential_name); 100 } else 101 PotentialRegistry::getInstance().registerInstance(potential); 149 102 } 150 returnstream.close(); 151 152 LOG(0, "STATUS: I'm training now a set of potentials parsed from " 153 << params.potential_file.get().string() << " on a fragment " 154 << fragmentnumbers << " on data from World's homologies."); 155 156 } else { 157 if (params.charges.get().empty()) { 158 STATUS("Neither charges nor potential file given!"); 159 return Action::failure; 160 } else { 161 // charges specify the potential type 162 SerializablePotential::ParticleTypes_t chargenumbers = 163 getNumbersFromElements(params.charges.get()); 164 165 LOG(0, "STATUS: I'm training now a " << params.potentialtype.get() 166 << " potential on charges " << chargenumbers << " on data from World's homologies."); 167 168 // register desired potential and an additional constant one 169 { 170 EmpiricalPotential *potential = 171 PotentialFactory::getInstance().createInstance( 172 params.potentialtype.get(), 173 chargenumbers); 174 // check whether such a potential already exists 175 const std::string potential_name = potential->getName(); 176 if (PotentialRegistry::getInstance().isPresentByName(potential_name)) { 177 delete potential; 178 potential = PotentialRegistry::getInstance().getByName(potential_name); 179 } else 180 PotentialRegistry::getInstance().registerInstance(potential); 181 } 182 { 183 EmpiricalPotential *constant = 184 PotentialFactory::getInstance().createInstance( 185 std::string("constant"), 186 SerializablePotential::ParticleTypes_t()); 187 // check whether such a potential already exists 188 const std::string constant_name = constant->getName(); 189 if (PotentialRegistry::getInstance().isPresentByName(constant_name)) { 190 delete constant; 191 constant = PotentialRegistry::getInstance().getByName(constant_name); 192 } else 193 PotentialRegistry::getInstance().registerInstance(constant); 194 } 103 { 104 EmpiricalPotential *constant = 105 PotentialFactory::getInstance().createInstance( 106 std::string("constant"), 107 SerializablePotential::ParticleTypes_t()); 108 // check whether such a potential already exists 109 const std::string constant_name = constant->getName(); 110 if (PotentialRegistry::getInstance().isPresentByName(constant_name)) { 111 delete constant; 112 constant = PotentialRegistry::getInstance().getByName(constant_name); 113 } else 114 PotentialRegistry::getInstance().registerInstance(constant); 195 115 } 196 116 } 197 117 198 118 // parse homologies into container 199 HomologyContainer &homologies = World::getInstance().getHomologies();119 const HomologyContainer &homologies = World::getInstance().getHomologies(); 200 120 201 121 // first we try to look into the HomologyContainer … … 211 131 212 132 // then we ought to pick the right HomologyGraph ... 213 const HomologyGraph graph = getFirstGraphwithSpecifiedElements(homologies,fragmentnumbers); 133 const HomologyGraph graph = 134 PotentialTrainer::getFirstGraphwithSpecifiedElements(homologies,fragmentnumbers); 214 135 if (graph != HomologyGraph()) { 215 136 LOG(1, "First representative graph containing fragment " … … 220 141 } 221 142 222 // fit potential 223 FunctionModel *model = new CompoundPotential(graph); 224 ASSERT( model != NULL, 225 "PotentialFitPotentialAction::performCall() - model is NULL."); 226 227 /******************** TRAINING ********************/ 228 // fit potential 229 FunctionModel::parameters_t bestparams(model->getParameterDimension(), 0.); 230 { 231 // Afterwards we go through all of this type and gather the distance and the energy value 232 TrainingData data(model->getSpecificFilter()); 233 data(homologies.getHomologousGraphs(graph)); 234 235 // print distances and energies if desired for debugging 236 if (!data.getTrainingInputs().empty()) { 237 // print which distance is which 238 size_t counter=1; 239 if (DoLog(3)) { 240 const FunctionModel::arguments_t &inputs = data.getAllArguments()[0]; 241 for (FunctionModel::arguments_t::const_iterator iter = inputs.begin(); 242 iter != inputs.end(); ++iter) { 243 const argument_t &arg = *iter; 244 LOG(3, "DEBUG: distance " << counter++ << " is between (#" 245 << arg.indices.first << "c" << arg.types.first << "," 246 << arg.indices.second << "c" << arg.types.second << ")."); 247 } 248 } 249 250 // print table 251 if (params.training_file.get().string().empty()) { 252 LOG(3, "DEBUG: I gathered the following training data:\n" << 253 _detail::writeDistanceEnergyTable(data.getDistanceEnergyTable())); 254 } else { 255 std::ofstream trainingstream(params.training_file.get().string().c_str()); 256 if (trainingstream.good()) { 257 LOG(3, "DEBUG: Writing training data to file " << 258 params.training_file.get().string() << "."); 259 trainingstream << _detail::writeDistanceEnergyTable(data.getDistanceEnergyTable()); 260 } 261 trainingstream.close(); 262 } 263 } 264 265 if ((params.threshold.get() < 1) && (params.best_of_howmany.isSet())) 266 ELOG(2, "threshold parameter always overrules max_runs, both are specified."); 267 // now perform the function approximation by optimizing the model function 268 FunctionApproximation approximator(data, *model); 269 if (model->isBoxConstraint() && approximator.checkParameterDerivatives()) { 270 double l2error = std::numeric_limits<double>::max(); 271 // seed with current time 272 srand((unsigned)time(0)); 273 unsigned int runs=0; 274 // threshold overrules max_runs 275 const double threshold = params.threshold.get(); 276 const unsigned int max_runs = (threshold >= 1.) ? 277 (params.best_of_howmany.isSet() ? params.best_of_howmany.get() : 1) : 0; 278 LOG(1, "INFO: Maximum runs is " << max_runs << " and threshold set to " << threshold << "."); 279 do { 280 // generate new random initial parameter values 281 model->setParametersToRandomInitialValues(data); 282 LOG(1, "INFO: Initial parameters of run " << runs << " are " 283 << model->getParameters() << "."); 284 approximator(FunctionApproximation::ParameterDerivative); 285 LOG(1, "INFO: Final parameters of run " << runs << " are " 286 << model->getParameters() << "."); 287 const double new_l2error = data.getL2Error(*model); 288 if (new_l2error < l2error) { 289 // store currently best parameters 290 l2error = new_l2error; 291 bestparams = model->getParameters(); 292 LOG(1, "STATUS: New fit from run " << runs 293 << " has better error of " << l2error << "."); 294 } 295 } while (( ++runs < max_runs) || (l2error > threshold)); 296 // reset parameters from best fit 297 model->setParameters(bestparams); 298 LOG(1, "INFO: Best parameters with L2 error of " 299 << l2error << " are " << model->getParameters() << "."); 300 } else { 301 STATUS("No required parameter derivatives for a box constraint minimization known."); 302 return Action::failure; 303 } 304 305 // create a map of each fragment with error. 306 HomologyContainer::range_t fragmentrange = homologies.getHomologousGraphs(graph); 307 TrainingData::L2ErrorConfigurationIndexMap_t WorseFragmentMap = 308 data.getWorstFragmentMap(*model, fragmentrange); 309 LOG(0, "RESULT: WorstFragmentMap " << WorseFragmentMap << "."); 310 311 // print fitted potentials 312 std::stringstream potentials; 313 PotentialSerializer serialize(potentials); 314 serialize(); 315 LOG(1, "STATUS: Resulting parameters are " << std::endl << potentials.str()); 316 std::ofstream returnstream(params.potential_file.get().string().c_str()); 317 if (returnstream.good()) { 318 returnstream << potentials.str(); 319 } 143 // training 144 PotentialTrainer trainer; 145 const bool status = trainer( 146 homologies, 147 graph, 148 params.training_file.get(), 149 params.threshold.get(), 150 params.best_of_howmany.get()); 151 if (!status) { 152 STATUS("No required parameter derivatives for a box constraint minimization known."); 153 return Action::failure; 320 154 } 321 delete model;322 155 323 156 return Action::success; -
src/Actions/PotentialAction/FitPotentialAction.def
rc7fe90 r5c8807 18 18 #include "Parameters/Validators/Specific/ElementValidator.hpp" 19 19 #include "Parameters/Validators/Specific/EmptyStringValidator.hpp" 20 #include "Parameters/Validators/Specific/FileSuffixValidator.hpp"21 #include "Parameters/Validators/Specific/FilePresentValidator.hpp"22 20 #include "Parameters/Validators/Specific/PotentialTypeValidator.hpp" 23 21 … … 25 23 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 26 24 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 27 #define paramtypes (boost::filesystem::path)(std::string)( boost::filesystem::path)(std::vector<const element *>)(std::vector<const element *>)(unsigned int)(double)28 #define paramtokens ("training-file")("potential-type")("potential- file")("potential-charges")("fragment-charges")("take-best-of")("set-threshold")29 #define paramdescriptions ("optional file to write training data to")("potential type to fit")(" optional potential file specifying multiple potentials to fit")("charges specifying the potential")("charges specifying the fragment")("take the best among this many approximations")("Require L2 error to be smaller than threshold, overrides number of attempts")30 #define paramdefaults (PARAM_DEFAULT(""))(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)( NOPARAM_DEFAULT)(PARAM_DEFAULT(3))(PARAM_DEFAULT(1.))31 #define paramreferences (training_file)(potentialtype)( potential_file)(charges)(fragment)(best_of_howmany)(threshold)25 #define paramtypes (boost::filesystem::path)(std::string)(std::vector<const element *>)(std::vector<const element *>)(unsigned int)(double) 26 #define paramtokens ("training-file")("potential-type")("potential-charges")("fragment-charges")("take-best-of")("set-threshold") 27 #define paramdescriptions ("optional file to write training data to")("potential type to fit")("charges specifying the potential")("charges specifying the fragment")("take the best among this many approximations")("Require L2 error to be smaller than threshold, overrides number of attempts") 28 #define paramdefaults (PARAM_DEFAULT(""))(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(PARAM_DEFAULT(3))(PARAM_DEFAULT(1.)) 29 #define paramreferences (training_file)(potentialtype)(charges)(fragment)(best_of_howmany)(threshold) 32 30 #define paramvalids \ 33 31 (DummyValidator<boost::filesystem::path>()) \ 34 (EmptyStringValidator() || PotentialTypeValidator()) \ 35 (!FilePresentValidator() || FileSuffixValidator("potentials")) \ 32 (PotentialTypeValidator()) \ 36 33 (STLVectorValidator< std::vector<const element *> >(0,99, ElementValidator())) \ 37 34 (STLVectorValidator< std::vector<const element *> >(1,99, ElementValidator())) \ -
src/Actions/SelectionAction/Atoms/AtomByIdAction.cpp
rc7fe90 r5c8807 93 93 break; 94 94 default: 95 ASSERT(0, "SelectionAtomByIdAction::performCall() - this must not happen.");95 STATUS("No atoms have been selected."); 96 96 return Action::failure; 97 97 break; -
src/Actions/SelectionAction/Atoms/NotAtomByIdAction.cpp
rc7fe90 r5c8807 93 93 break; 94 94 default: 95 ASSERT(0, "SelectionAtomByIdAction::performCall() - this must not happen.");95 STATUS("No atoms have been selected."); 96 96 return Action::failure; 97 97 break; -
src/Actions/UndoRedoHelpers.cpp
rc7fe90 r5c8807 181 181 } 182 182 183 void MoleCuilder::removeLastStep(const std::vector<atomId_t> &_atoms )183 void MoleCuilder::removeLastStep(const std::vector<atomId_t> &_atoms, const unsigned int _step) 184 184 { 185 185 for (size_t i=0; i<_atoms.size(); ++i) { 186 186 atom * const _atom = World::getInstance().getAtom(AtomById(_atoms[i])); 187 _atom->removeStep s();188 } 189 } 190 191 void MoleCuilder::addNewStep(const std::vector<AtomicInfo> &_movedatoms )187 _atom->removeStep(_step); 188 } 189 } 190 191 void MoleCuilder::addNewStep(const std::vector<AtomicInfo> &_movedatoms, const unsigned int _step) 192 192 { 193 193 for(size_t i=0; i< _movedatoms.size(); ++i) { 194 194 atom * const _atom = World::getInstance().getAtom(AtomById(_movedatoms[i].getId())); 195 _atom->UpdateStep s();196 } 197 } 198 199 void MoleCuilder::addNewStep(const std::vector<atomId_t> &_ids )195 _atom->UpdateStep(_step); 196 } 197 } 198 199 void MoleCuilder::addNewStep(const std::vector<atomId_t> &_ids, const unsigned int _step) 200 200 { 201 201 for(size_t i=0; i< _ids.size(); ++i) { 202 202 atom * const _atom = World::getInstance().getAtom(AtomById(_ids[i])); 203 _atom->UpdateStep s();203 _atom->UpdateStep(_step); 204 204 } 205 205 } -
src/Actions/UndoRedoHelpers.hpp
rc7fe90 r5c8807 107 107 * 108 108 * @param movedatoms atoms whose last step in time to remove 109 * @param _step which trajectory to remove 109 110 */ 110 void removeLastStep(const std::vector<atomId_t> &movedatoms );111 void removeLastStep(const std::vector<atomId_t> &movedatoms, const unsigned int _step); 111 112 112 113 /** Adds another time step to all \a movedatoms. … … 115 116 * 116 117 * @param _ids atoms whose last step in time to remove 118 * @param _step which trajectory to insert/assign 117 119 */ 118 void addNewStep(const std::vector<atomId_t> &_ids );120 void addNewStep(const std::vector<atomId_t> &_ids, const unsigned int _step); 119 121 120 122 /** Adds another time step to all \a movedatoms. … … 124 126 * 125 127 * @param _movedatoms atoms whose last step in time to remove 128 * @param _step which trajectory to insert/assign 126 129 */ 127 void addNewStep(const std::vector<AtomicInfo> &_movedatoms );130 void addNewStep(const std::vector<AtomicInfo> &_movedatoms, const unsigned int _step); 128 131 129 132 /** Helper function to extract id information from vector of AtomicInfo. -
src/Atom/TesselPoint.cpp
rc7fe90 r5c8807 52 52 {}; 53 53 54 void TesselPoint::UpdateStep s()54 void TesselPoint::UpdateStep(const unsigned int _step) 55 55 { 56 ASSERT(0, "TesselPoint::UpdateStep s() should never be called, TesselPoints don't have trajectories.");57 AtomInfo::AppendTrajectoryStep( );56 ASSERT(0, "TesselPoint::UpdateStep() should never be called, TesselPoints don't have trajectories."); 57 AtomInfo::AppendTrajectoryStep(_step); 58 58 }; 59 59 60 void TesselPoint::removeStep s()60 void TesselPoint::removeStep(const unsigned int _step) 61 61 { 62 ASSERT(0, "TesselPoint::removeStep s() should never be called, TesselPoints don't have trajectories.");63 AtomInfo::removeTrajectoryStep( );62 ASSERT(0, "TesselPoint::removeStep() should never be called, TesselPoints don't have trajectories."); 63 AtomInfo::removeTrajectoryStep(_step); 64 64 }; 65 65 -
src/Atom/TesselPoint.hpp
rc7fe90 r5c8807 37 37 * 38 38 */ 39 virtual void UpdateStep s();39 virtual void UpdateStep(const unsigned int _step); 40 40 41 41 /** Pops the last step in all trajectory vectors. … … 45 45 * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses. 46 46 */ 47 virtual void removeStep s();47 virtual void removeStep(const unsigned int _step); 48 48 49 49 /** Getter for this. -
src/Atom/atom.cpp
rc7fe90 r5c8807 69 69 mol(0) 70 70 { 71 AtomicPosition = pointer->AtomicPosition; // copy trajectory of coordination72 AtomicVelocity = pointer->AtomicVelocity; // copy trajectory of velocity73 AtomicForce = pointer->AtomicForce;74 71 // sign on to global atom change tracker 75 72 AtomObserver::getInstance().AtomInserted(this); … … 93 90 94 91 95 void atom::UpdateStep s()96 { 97 LOG(4,"atom::UpdateStep s() called.");92 void atom::UpdateStep(const unsigned int _step) 93 { 94 LOG(4,"atom::UpdateStep() called."); 98 95 // append to position, velocity and force vector 99 AtomInfo::AppendTrajectoryStep( );96 AtomInfo::AppendTrajectoryStep(WorldTime::getTime()+1); 100 97 // append to ListOfBonds vector 101 BondedParticleInfo::AppendTrajectoryStep( );102 } 103 104 void atom::removeStep s()105 { 106 LOG(4,"atom::removeStep s() called.");98 BondedParticleInfo::AppendTrajectoryStep(WorldTime::getTime()+1); 99 } 100 101 void atom::removeStep(const unsigned int _step) 102 { 103 LOG(4,"atom::removeStep() called."); 107 104 // append to position, velocity and force vector 108 AtomInfo::removeTrajectoryStep( );105 AtomInfo::removeTrajectoryStep(_step); 109 106 // append to ListOfBonds vector 110 BondedParticleInfo::removeTrajectoryStep( );107 BondedParticleInfo::removeTrajectoryStep(_step); 111 108 } 112 109 … … 313 310 atom* NewAtom(atomId_t _id){ 314 311 atom * res = new atom(); 315 // extent trajectory to current time step316 const size_t CurrentTime = WorldTime::getTime();317 for (size_t step = res->getTrajectorySize(); step <= CurrentTime; ++step)318 res->UpdateSteps();319 312 res->setId(_id); 320 313 return res; -
src/Atom/atom.hpp
rc7fe90 r5c8807 65 65 * real functions, \sa AppendTrajectoryStep(), by all necessary subclasses. 66 66 */ 67 virtual void UpdateStep s();67 virtual void UpdateStep(const unsigned int _step); 68 68 69 69 /** Pops the last step in all trajectory vectors. … … 73 73 * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses. 74 74 */ 75 virtual void removeStep s();75 virtual void removeStep(const unsigned int _step); 76 76 77 77 /** Output of a single atom with given numbering. -
src/Atom/atom_atominfo.cpp
rc7fe90 r5c8807 3 3 * Description: creates and alters molecular systems 4 4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved. 5 * Copyright (C) 2014 Frederik Heber. All rights reserved. 5 6 * 6 7 * … … 55 56 charge(0.) 56 57 { 57 AtomicPosition.reserve(1); 58 AtomicPosition.push_back(zeroVec); 59 AtomicVelocity.reserve(1); 60 AtomicVelocity.push_back(zeroVec); 61 AtomicForce.reserve(1); 62 AtomicForce.push_back(zeroVec); 63 64 }; 58 AtomicPosition.insert( std::make_pair(0, zeroVec) ); 59 AtomicVelocity.insert( std::make_pair(0, zeroVec) ); 60 AtomicForce.insert( std::make_pair(0, zeroVec) ); 61 } 65 62 66 63 /** Copy constructor of class AtomInfo. … … 68 65 AtomInfo::AtomInfo(const AtomInfo &_atom) : 69 66 AtomicPosition(_atom.AtomicPosition), 67 AtomicVelocity(_atom.AtomicVelocity), 68 AtomicForce(_atom.AtomicForce), 70 69 AtomicElement(_atom.AtomicElement), 71 70 FixedIon(_atom.FixedIon), 72 71 charge(_atom.charge) 73 72 { 74 AtomicVelocity.reserve(1); 75 AtomicVelocity.push_back(zeroVec); 76 AtomicForce.reserve(1); 77 AtomicForce.push_back(zeroVec); 78 }; 73 } 79 74 80 75 AtomInfo::AtomInfo(const VectorInterface &_v) : … … 83 78 charge(0.) 84 79 { 85 if (AtomicPosition.size() < 1) 86 AtomicPosition.resize(1); 87 AtomicPosition[0] = _v.getPosition(); 88 AtomicVelocity.reserve(1); 89 AtomicVelocity.push_back(zeroVec); 90 AtomicForce.reserve(1); 91 AtomicForce.push_back(zeroVec); 80 AtomicPosition.insert( std::make_pair(0, _v.getPosition()) ); 81 AtomicVelocity.insert( std::make_pair(0, zeroVec) ); 82 AtomicForce.insert( std::make_pair(0, zeroVec) ); 92 83 }; 93 84 … … 98 89 }; 99 90 100 void AtomInfo::AppendTrajectoryStep() 101 { 102 NOTIFY(TrajectoryChanged); 103 AtomicPosition.push_back(zeroVec); 104 AtomicVelocity.push_back(zeroVec); 105 AtomicForce.push_back(zeroVec); 91 void AtomInfo::AppendTrajectoryStep(const unsigned int _step) 92 { 93 if (WorldTime::getTime() == _step) 94 NOTIFY(TrajectoryChanged); 95 AtomicPosition.insert( std::make_pair(_step, zeroVec) ); 96 AtomicVelocity.insert( std::make_pair(_step, zeroVec) ); 97 AtomicForce.insert( std::make_pair(_step, zeroVec) ); 106 98 LOG(5,"AtomInfo::AppendTrajectoryStep() called, size is (" 107 99 << AtomicPosition.size() << "," … … 110 102 } 111 103 112 void AtomInfo::removeTrajectoryStep() 113 { 114 NOTIFY(TrajectoryChanged); 115 AtomicPosition.pop_back(); 116 AtomicVelocity.pop_back(); 117 AtomicForce.pop_back(); 104 void AtomInfo::removeTrajectoryStep(const unsigned int _step) 105 { 106 if (WorldTime::getTime() == _step) 107 NOTIFY(TrajectoryChanged); 108 AtomicPosition.erase(_step); 109 AtomicVelocity.erase(_step); 110 AtomicForce.erase(_step); 118 111 LOG(5,"AtomInfo::removeTrajectoryStep() called, size is (" 119 112 << AtomicPosition.size() << "," … … 141 134 const double& AtomInfo::operator[](size_t i) const 142 135 { 143 ASSERT(AtomicPosition.size() > WorldTime::getTime(), 144 "AtomInfo::operator[]() - Access out of range: " 145 +toString(WorldTime::getTime()) 146 +" not in [0,"+toString(AtomicPosition.size())+")."); 147 return AtomicPosition[WorldTime::getTime()][i]; 136 return atStep(i, WorldTime::getTime()); 148 137 } 149 138 150 139 const double& AtomInfo::at(size_t i) const 151 140 { 152 ASSERT(AtomicPosition.size() > WorldTime::getTime(), 153 "AtomInfo::at() - Access out of range: " 154 +toString(WorldTime::getTime()) 155 +" not in [0,"+toString(AtomicPosition.size())+")."); 156 return AtomicPosition[WorldTime::getTime()].at(i); 141 return atStep(i, WorldTime::getTime()); 157 142 } 158 143 159 144 const double& AtomInfo::atStep(size_t i, unsigned int _step) const 160 145 { 161 ASSERT( AtomicPosition.size() > _step,162 "AtomInfo:: atStep() - Access out of range: "163 +toString(_step)164 +" not in [0,"+toString(AtomicPosition.size())+").");165 return AtomicPosition[_step].at(i);146 ASSERT(!AtomicPosition.empty(), 147 "AtomInfo::operator[]() - AtomicPosition is empty."); 148 VectorTrajectory_t::const_iterator iter = 149 AtomicPosition.lower_bound(_step); 150 return iter->second[i]; 166 151 } 167 152 … … 170 155 OBSERVE; 171 156 NOTIFY(AtomObservable::PositionChanged); 172 ASSERT(AtomicPosition.size() > WorldTime::getTime(), 173 "AtomInfo::set() - Access out of range: " 174 +toString(WorldTime::getTime()) 175 +" not in [0,"+toString(AtomicPosition.size())+")."); 176 AtomicPosition[WorldTime::getTime()].at(i) = value; 157 VectorTrajectory_t::iterator iter = AtomicPosition.find(WorldTime::getTime()); 158 if (iter != AtomicPosition.end()) { 159 iter->second[i] = value; 160 } else { 161 Vector newPos; 162 newPos[i] = value; 163 #ifndef NDEBUG 164 std::pair<VectorTrajectory_t::iterator, bool> inserter = 165 #endif 166 AtomicPosition.insert( std::make_pair(WorldTime::getTime(), newPos) ); 167 ASSERT( inserter.second, 168 "AtomInfo::set() - time step "+toString(WorldTime::getTime()) 169 +" present after all?"); 170 } 171 } 172 173 /** Helps to determine whether the current step really exists or getPosition() has just 174 * delivered the one closest to it in the past. 175 * 176 * \param _step step to check 177 * \param true - step exists, false - step does not exist, getPosition() delivers closest 178 */ 179 bool AtomInfo::isStepPresent(const unsigned int _step) const 180 { 181 VectorTrajectory_t::const_iterator iter = 182 AtomicPosition.find(_step); 183 return iter != AtomicPosition.end(); 177 184 } 178 185 179 186 const Vector& AtomInfo::getPosition() const 180 187 { 181 ASSERT(AtomicPosition.size() > WorldTime::getTime(), 182 "AtomInfo::getPosition() - Access out of range: " 183 +toString(WorldTime::getTime()) 184 +" not in [0,"+toString(AtomicPosition.size())+")."); 185 return AtomicPosition[WorldTime::getTime()]; 188 return getPositionAtStep(WorldTime::getTime()); 186 189 } 187 190 188 191 const Vector& AtomInfo::getPositionAtStep(const unsigned int _step) const 189 192 { 190 ASSERT( _step < AtomicPosition.size(),191 "AtomInfo:: getPositionAtStep() - Access out of range: "192 +toString(_step)193 +" not in [0,"+toString(AtomicPosition.size())+").");194 return AtomicPosition[_step];193 ASSERT(!AtomicPosition.empty(), 194 "AtomInfo::operator[]() - AtomicPosition is empty."); 195 VectorTrajectory_t::const_iterator iter = 196 AtomicPosition.lower_bound(_step); 197 return iter->second; 195 198 } 196 199 … … 207 210 { 208 211 const element *elem = World::getInstance().getPeriode()->FindElement(Z); 209 if (elem != NULL) { 210 OBSERVE; 211 NOTIFY(AtomObservable::ElementChanged); 212 AtomicElement = Z; 213 } 214 } 215 216 //Vector& AtomInfo::getAtomicVelocity() 217 //{ 218 // return AtomicVelocity[0]; 219 //} 220 221 //Vector& AtomInfo::getAtomicVelocity(const int _step) 222 //{ 223 // ASSERT(_step < AtomicVelocity.size(), 224 // "AtomInfo::getAtomicVelocity() - Access out of range."); 225 // return AtomicVelocity[_step]; 226 //} 212 setType(elem); 213 } 227 214 228 215 const Vector& AtomInfo::getAtomicVelocity() const 229 216 { 230 ASSERT(AtomicVelocity.size() > 0, 231 "AtomInfo::getAtomicVelocity() - Access out of range: " 232 +toString(WorldTime::getTime()) 233 +" not in [0,"+toString(AtomicPosition.size())+")."); 234 return AtomicVelocity[WorldTime::getTime()]; 217 return getAtomicVelocityAtStep(WorldTime::getTime()); 235 218 } 236 219 237 220 const Vector& AtomInfo::getAtomicVelocityAtStep(const unsigned int _step) const 238 221 { 239 ASSERT(_step < AtomicVelocity.size(), 240 "AtomInfo::getAtomicVelocity() - Access out of range: " 241 +toString(_step) 242 +" not in [0,"+toString(AtomicPosition.size())+")."); 243 return AtomicVelocity[_step]; 222 ASSERT(!AtomicVelocity.empty(), 223 "AtomInfo::operator[]() - AtomicVelocity is empty."); 224 VectorTrajectory_t::const_iterator iter = 225 AtomicVelocity.lower_bound(_step); 226 // special, we only interpolate between present time steps not into the future 227 if (_step > AtomicVelocity.begin()->first) 228 return zeroVec; 229 else 230 return iter->second; 244 231 } 245 232 246 233 void AtomInfo::setAtomicVelocity(const Vector &_newvelocity) 247 234 { 235 setAtomicVelocityAtStep(WorldTime::getTime(), _newvelocity); 236 } 237 238 void AtomInfo::setAtomicVelocityAtStep(const unsigned int _step, const Vector &_newvelocity) 239 { 248 240 OBSERVE; 249 NOTIFY(AtomObservable::VelocityChanged); 250 ASSERT(WorldTime::getTime() < AtomicVelocity.size(), 251 "AtomInfo::setAtomicVelocity() - Access out of range: " 252 +toString(WorldTime::getTime()) 253 +" not in [0,"+toString(AtomicPosition.size())+")."); 254 AtomicVelocity[WorldTime::getTime()] = _newvelocity; 255 } 256 257 void AtomInfo::setAtomicVelocityAtStep(const unsigned int _step, const Vector &_newvelocity) 258 { 259 OBSERVE; 241 VectorTrajectory_t::iterator iter = AtomicVelocity.find(_step); 242 if (iter != AtomicVelocity.end()) { 243 iter->second = _newvelocity; 244 } else { 245 #ifndef NDEBUG 246 std::pair<VectorTrajectory_t::iterator, bool> inserter = 247 #endif 248 AtomicVelocity.insert( std::make_pair(_step, _newvelocity) ); 249 ASSERT( inserter.second, 250 "AtomInfo::set() - time step "+toString(_step) 251 +" present after all?"); 252 } 260 253 if (WorldTime::getTime() == _step) 261 254 NOTIFY(AtomObservable::VelocityChanged); 262 const unsigned int size = AtomicVelocity.size();263 ASSERT(_step <= size,264 "AtomInfo::setAtomicVelocityAtStep() - Access out of range: "265 +toString(_step)266 +" not in [0,"+toString(size)+"].");267 if(_step < size) {268 AtomicVelocity[_step] = _newvelocity;269 } else if (_step == size) {270 UpdateSteps();271 AtomicVelocity[_step] = _newvelocity;272 }273 255 } 274 256 275 257 const Vector& AtomInfo::getAtomicForce() const 276 258 { 277 ASSERT(WorldTime::getTime() < AtomicForce.size(), 278 "AtomInfo::getAtomicForce() - Access out of range: " 279 +toString(WorldTime::getTime()) 280 +" not in [0,"+toString(AtomicPosition.size())+")."); 281 return AtomicForce[WorldTime::getTime()]; 259 return getAtomicForceAtStep(WorldTime::getTime()); 282 260 } 283 261 284 262 const Vector& AtomInfo::getAtomicForceAtStep(const unsigned int _step) const 285 263 { 286 ASSERT(_step < AtomicForce.size(), 287 "AtomInfo::getAtomicForce() - Access out of range: " 288 +toString(_step) 289 +" not in [0,"+toString(AtomicPosition.size())+")."); 290 return AtomicForce[_step]; 264 ASSERT(!AtomicForce.empty(), 265 "AtomInfo::operator[]() - AtomicForce is empty."); 266 VectorTrajectory_t::const_iterator iter = 267 AtomicForce.lower_bound(_step); 268 // special, we only interpolate between present time steps not into the future 269 if (_step > AtomicForce.begin()->first) 270 return zeroVec; 271 else 272 return iter->second; 291 273 } 292 274 293 275 void AtomInfo::setAtomicForce(const Vector &_newforce) 294 276 { 277 setAtomicForceAtStep(WorldTime::getTime(), _newforce); 278 } 279 280 void AtomInfo::setAtomicForceAtStep(const unsigned int _step, const Vector &_newforce) 281 { 295 282 OBSERVE; 296 NOTIFY(AtomObservable::ForceChanged); 297 ASSERT(WorldTime::getTime() < AtomicForce.size(), 298 "AtomInfo::setAtomicForce() - Access out of range: " 299 +toString(WorldTime::getTime()) 300 +" not in [0,"+toString(AtomicPosition.size())+")."); 301 AtomicForce[WorldTime::getTime()] = _newforce; 302 } 303 304 void AtomInfo::setAtomicForceAtStep(const unsigned int _step, const Vector &_newforce) 305 { 306 OBSERVE; 283 VectorTrajectory_t::iterator iter = AtomicForce.find(_step); 284 if (iter != AtomicForce.end()) { 285 iter->second = _newforce; 286 } else { 287 #ifndef NDEBUG 288 std::pair<VectorTrajectory_t::iterator, bool> inserter = 289 #endif 290 AtomicForce.insert( std::make_pair(_step, _newforce) ); 291 ASSERT( inserter.second, 292 "AtomInfo::set() - time step "+toString(_step) 293 +" present after all?"); 294 } 307 295 if (WorldTime::getTime() == _step) 308 296 NOTIFY(AtomObservable::ForceChanged); 309 const unsigned int size = AtomicForce.size();310 ASSERT(_step <= size,311 "AtomInfo::setAtomicForce() - Access out of range: "312 +toString(_step)313 +" not in [0,"+toString(AtomicPosition.size())+"].");314 if(_step < size) {315 AtomicForce[_step] = _newforce;316 } else if (_step == size) {317 UpdateSteps();318 AtomicForce[_step] = _newforce;319 }320 297 } 321 298 … … 334 311 void AtomInfo::setPosition(const Vector& _vector) 335 312 { 313 setPositionAtStep(WorldTime::getTime(), _vector); 314 } 315 316 void AtomInfo::setPositionAtStep(unsigned int _step, const Vector& _vector) 317 { 336 318 OBSERVE; 337 NOTIFY(AtomObservable::PositionChanged);338 ASSERT(WorldTime::getTime() < AtomicPosition.size(),339 "AtomInfo::setPosition() - Access out of range: "340 +toString(WorldTime::getTime())341 +" not in [0,"+toString(AtomicPosition.size())+")."); 342 AtomicPosition[WorldTime::getTime()] = _vector;343 //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl; 344 } 345 346 void AtomInfo::setPositionAtStep(unsigned int _step, const Vector& _vector)347 { 348 OBSERVE;319 VectorTrajectory_t::iterator iter = AtomicPosition.find(_step); 320 if (iter != AtomicPosition.end()) { 321 iter->second = _vector; 322 } else { 323 #ifndef NDEBUG 324 std::pair<VectorTrajectory_t::iterator, bool> inserter = 325 #endif 326 AtomicPosition.insert( std::make_pair(_step, _vector) ); 327 ASSERT( inserter.second, 328 "AtomInfo::set() - time step "+toString(_step) 329 +" present after all?"); 330 } 349 331 if (WorldTime::getTime() == _step) 350 332 NOTIFY(AtomObservable::PositionChanged); 351 const unsigned int size = AtomicPosition.size();352 ASSERT(_step <= size,353 "AtomInfo::setPosition() - Access out of range: "354 +toString(_step)355 +" not in [0,"+toString(size)+"].");356 if(_step < size) {357 AtomicPosition[_step] = _vector;358 } else if (_step == size) {359 UpdateSteps();360 AtomicPosition[_step] = _vector;361 }362 //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl;363 333 } 364 334 365 335 const VectorInterface& AtomInfo::operator+=(const Vector& b) 366 336 { 367 OBSERVE; 368 NOTIFY(AtomObservable::PositionChanged); 369 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 370 "AtomInfo::operator+=() - Access out of range: " 371 +toString(WorldTime::getTime()) 372 +" not in [0,"+toString(AtomicPosition.size())+")."); 373 AtomicPosition[WorldTime::getTime()] += b; 337 setPosition(getPosition()+b); 374 338 return *this; 375 339 } … … 377 341 const VectorInterface& AtomInfo::operator-=(const Vector& b) 378 342 { 379 OBSERVE; 380 NOTIFY(AtomObservable::PositionChanged); 381 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 382 "AtomInfo::operator-=() - Access out of range: " 383 +toString(WorldTime::getTime()) 384 +" not in [0,"+toString(AtomicPosition.size())+")."); 385 AtomicPosition[WorldTime::getTime()] -= b; 343 setPosition(getPosition()-b); 386 344 return *this; 387 345 } … … 389 347 Vector const AtomInfo::operator+(const Vector& b) const 390 348 { 391 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 392 "AtomInfo::operator+() - Access out of range: " 393 +toString(WorldTime::getTime()) 394 +" not in [0,"+toString(AtomicPosition.size())+")."); 395 Vector a(AtomicPosition[WorldTime::getTime()]); 349 Vector a(getPosition()); 396 350 a += b; 397 351 return a; … … 400 354 Vector const AtomInfo::operator-(const Vector& b) const 401 355 { 402 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 403 "AtomInfo::operator-() - Access out of range: " 404 +toString(WorldTime::getTime()) 405 +" not in [0,"+toString(AtomicPosition.size())+")."); 406 Vector a(AtomicPosition[WorldTime::getTime()]); 356 Vector a(getPosition()); 407 357 a -= b; 408 358 return a; … … 411 361 double AtomInfo::distance(const Vector &point) const 412 362 { 413 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 414 "AtomInfo::distance() - Access out of range: " 415 +toString(WorldTime::getTime()) 416 +" not in [0,"+toString(AtomicPosition.size())+")."); 417 return AtomicPosition[WorldTime::getTime()].distance(point); 363 return getPosition().distance(point); 418 364 } 419 365 420 366 double AtomInfo::DistanceSquared(const Vector &y) const 421 367 { 422 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 423 "AtomInfo::DistanceSquared() - Access out of range: " 424 +toString(WorldTime::getTime()) 425 +" not in [0,"+toString(AtomicPosition.size())+")."); 426 return AtomicPosition[WorldTime::getTime()].DistanceSquared(y); 368 return getPosition().DistanceSquared(y); 427 369 } 428 370 429 371 double AtomInfo::distance(const VectorInterface &_atom) const 430 372 { 431 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 432 "AtomInfo::distance() - Access out of range: " 433 +toString(WorldTime::getTime()) 434 +" not in [0,"+toString(AtomicPosition.size())+")."); 435 return _atom.distance(AtomicPosition[WorldTime::getTime()]); 373 return _atom.distance(getPosition()); 436 374 } 437 375 438 376 double AtomInfo::DistanceSquared(const VectorInterface &_atom) const 439 377 { 440 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 441 "AtomInfo::DistanceSquared() - Access out of range: " 442 +toString(WorldTime::getTime()) 443 +" not in [0,"+toString(AtomicPosition.size())+")."); 444 return _atom.DistanceSquared(AtomicPosition[WorldTime::getTime()]); 378 return _atom.DistanceSquared(getPosition()); 445 379 } 446 380 447 381 VectorInterface &AtomInfo::operator=(const Vector& _vector) 448 382 { 449 OBSERVE; 450 NOTIFY(AtomObservable::PositionChanged); 451 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 452 "AtomInfo::operator=() - Access out of range: " 453 +toString(WorldTime::getTime()) 454 +" not in [0,"+toString(AtomicPosition.size())+")."); 455 AtomicPosition[WorldTime::getTime()] = _vector; 383 setPosition(_vector); 456 384 return *this; 457 385 } … … 459 387 void AtomInfo::ScaleAll(const double *factor) 460 388 { 461 OBSERVE; 462 NOTIFY(AtomObservable::PositionChanged); 463 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 464 "AtomInfo::ScaleAll() - Access out of range: " 465 +toString(WorldTime::getTime()) 466 +" not in [0,"+toString(AtomicPosition.size())+")."); 467 AtomicPosition[WorldTime::getTime()].ScaleAll(factor); 389 Vector temp(getPosition()); 390 temp.ScaleAll(factor); 391 setPosition(temp); 468 392 } 469 393 470 394 void AtomInfo::ScaleAll(const Vector &factor) 471 395 { 472 OBSERVE; 473 NOTIFY(AtomObservable::PositionChanged); 474 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 475 "AtomInfo::ScaleAll() - Access out of range: " 476 +toString(WorldTime::getTime()) 477 +" not in [0,"+toString(AtomicPosition.size())+")."); 478 AtomicPosition[WorldTime::getTime()].ScaleAll(factor); 396 Vector temp(getPosition()); 397 temp.ScaleAll(factor); 398 setPosition(temp); 479 399 } 480 400 481 401 void AtomInfo::Scale(const double factor) 482 402 { 483 OBSERVE; 484 NOTIFY(AtomObservable::PositionChanged); 485 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 486 "AtomInfo::Scale() - Access out of range: " 487 +toString(WorldTime::getTime()) 488 +" not in [0,"+toString(AtomicPosition.size())+")."); 489 AtomicPosition[WorldTime::getTime()].Scale(factor); 403 Vector temp(getPosition()); 404 temp.Scale(factor); 405 setPosition(temp); 490 406 } 491 407 492 408 void AtomInfo::Zero() 493 409 { 494 OBSERVE; 495 NOTIFY(AtomObservable::PositionChanged); 496 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 497 "AtomInfo::Zero() - Access out of range: " 498 +toString(WorldTime::getTime()) 499 +" not in [0,"+toString(AtomicPosition.size())+")."); 500 AtomicPosition[WorldTime::getTime()].Zero(); 410 setPosition(zeroVec); 501 411 } 502 412 503 413 void AtomInfo::One(const double one) 504 414 { 505 OBSERVE; 506 NOTIFY(AtomObservable::PositionChanged); 507 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 508 "AtomInfo::One() - Access out of range: " 509 +toString(WorldTime::getTime()) 510 +" not in [0,"+toString(AtomicPosition.size())+")."); 511 AtomicPosition[WorldTime::getTime()].One(one); 415 setPosition(Vector(one,one,one)); 512 416 } 513 417 514 418 void AtomInfo::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors) 515 419 { 516 OBSERVE; 517 NOTIFY(AtomObservable::PositionChanged); 518 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 519 "AtomInfo::LinearCombinationOfVectors() - Access out of range: " 520 +toString(WorldTime::getTime()) 521 +" not in [0,"+toString(AtomicPosition.size())+")."); 522 AtomicPosition[WorldTime::getTime()].LinearCombinationOfVectors(x1,x2,x3,factors); 420 Vector newPos; 421 newPos.LinearCombinationOfVectors(x1,x2,x3,factors); 422 setPosition(newPos); 523 423 } 524 424 … … 528 428 double AtomInfo::getKineticEnergy(const unsigned int _step) const 529 429 { 530 ASSERT(_step < AtomicPosition.size(), 531 "AtomInfo::getKineticEnergy() - Access out of range: " 532 +toString(WorldTime::getTime()) 533 +" not in [0,"+toString(AtomicPosition.size())+")."); 534 return getMass() * AtomicVelocity[_step].NormSquared(); 430 return getMass() * getAtomicVelocityAtStep(_step).NormSquared(); 535 431 } 536 432 537 433 Vector AtomInfo::getMomentum(const unsigned int _step) const 538 434 { 539 ASSERT(_step < AtomicPosition.size(), 540 "AtomInfo::getMomentum() - Access out of range: " 541 +toString(WorldTime::getTime()) 542 +" not in [0,"+toString(AtomicPosition.size())+")."); 543 return getMass()*AtomicVelocity[_step]; 544 } 545 546 /** Extends the trajectory STL vector to the new size. 547 * Does nothing if \a MaxSteps is smaller than current size. 435 return getMass() * getAtomicVelocityAtStep(_step); 436 } 437 438 /** Decrease the trajectory if given \a MaxSteps is smaller. 439 * Does nothing if \a MaxSteps is larger than current size. 440 * 548 441 * \param MaxSteps 549 442 */ 550 443 void AtomInfo::ResizeTrajectory(size_t MaxSteps) 551 444 { 552 for (;AtomicPosition.size() <= (unsigned int)(MaxSteps);) 553 UpdateSteps(); 445 // mind the reverse ordering due to std::greater, latest time steps are at beginning 446 VectorTrajectory_t::iterator positer = AtomicPosition.lower_bound(MaxSteps); 447 if (positer != AtomicPosition.begin()) { 448 if (positer->first == MaxSteps) 449 --positer; 450 AtomicPosition.erase(AtomicPosition.begin(), positer); 451 } 452 VectorTrajectory_t::iterator veliter = AtomicVelocity.lower_bound(MaxSteps); 453 if (veliter != AtomicVelocity.begin()) { 454 if (veliter->first == MaxSteps) 455 --veliter; 456 AtomicVelocity.erase(AtomicVelocity.begin(), veliter); 457 } 458 VectorTrajectory_t::iterator forceiter = AtomicForce.lower_bound(MaxSteps); 459 if (forceiter != AtomicForce.begin()) { 460 if (forceiter->first == MaxSteps) 461 --forceiter; 462 AtomicForce.erase(AtomicForce.begin(), forceiter); 463 } 554 464 } 555 465 556 466 size_t AtomInfo::getTrajectorySize() const 557 467 { 558 return AtomicPosition.size(); 468 // mind greater comp for map here: first element is latest in time steps! 469 return AtomicPosition.begin()->first+1; 559 470 } 560 471 … … 562 473 { 563 474 return getType()->getMass(); 475 } 476 477 /** Helper function to either insert or assign, depending on the element being 478 * present already. 479 * 480 * \param _trajectory vector of Vectors to assign 481 * \param dest step to insert/assign to 482 * \param _newvalue new Vector value 483 */ 484 void assignTrajectoryElement( 485 std::map<unsigned int, Vector, std::greater<unsigned int> > &_trajectory, 486 const unsigned int dest, 487 const Vector &_newvalue) 488 { 489 std::pair<std::map<unsigned int, Vector, std::greater<unsigned int> >::iterator, bool> inserter = 490 _trajectory.insert( std::make_pair(dest, _newvalue) ); 491 if (!inserter.second) 492 inserter.first->second = _newvalue; 564 493 } 565 494 … … 579 508 } 580 509 581 ASSERT(dest < AtomicPosition.size(), 582 "AtomInfo::CopyStepOnStep() - destination outside of current trajectory array: " 583 +toString(dest) 584 +" not in [0,"+toString(AtomicPosition.size())+")."); 585 ASSERT(src < AtomicPosition.size(), 586 "AtomInfo::CopyStepOnStep() - source outside of current trajectory array: " 587 +toString(src) 588 +" not in [0,"+toString(AtomicPosition.size())+")."); 589 for (int n=NDIM;n--;) { 590 AtomicPosition.at(dest)[n] = AtomicPosition.at(src)[n]; 591 AtomicVelocity.at(dest)[n] = AtomicVelocity.at(src)[n]; 592 AtomicForce.at(dest)[n] = AtomicForce.at(src)[n]; 593 } 510 VectorTrajectory_t::iterator positer = AtomicPosition.find(src); 511 ASSERT( positer != AtomicPosition.end(), 512 "AtomInfo::CopyStepOnStep() - step " 513 +toString(src)+" to copy from not present in AtomicPosition."); 514 VectorTrajectory_t::iterator veliter = AtomicVelocity.find(src); 515 ASSERT( veliter != AtomicVelocity.end(), 516 "AtomInfo::CopyStepOnStep() - step " 517 +toString(src)+" to copy from not present in AtomicVelocity."); 518 VectorTrajectory_t::iterator forceiter = AtomicForce.find(src); 519 ASSERT( forceiter != AtomicForce.end(), 520 "AtomInfo::CopyStepOnStep() - step " 521 +toString(src)+" to copy from not present in AtomicForce."); 522 assignTrajectoryElement(AtomicPosition, dest, positer->second); 523 assignTrajectoryElement(AtomicVelocity, dest, veliter->second); 524 assignTrajectoryElement(AtomicForce, dest, forceiter->second); 594 525 }; 595 526 … … 656 587 }; 657 588 658 //const AtomInfo& operator*=(AtomInfo& a, const double m)659 //{660 // a.Scale(m);661 // return a;662 //}663 //664 //AtomInfo const operator*(const AtomInfo& a, const double m)665 //{666 // AtomInfo copy(a);667 // copy *= m;668 // return copy;669 //}670 //671 //AtomInfo const operator*(const double m, const AtomInfo& a)672 //{673 // AtomInfo copy(a);674 // copy *= m;675 // return copy;676 //}677 678 589 std::ostream & AtomInfo::operator << (std::ostream &ost) const 679 590 { -
src/Atom/atom_atominfo.hpp
rc7fe90 r5c8807 56 56 * real functions, \sa AppendTrajectoryStep(), by all necessary subclasses. 57 57 */ 58 virtual void UpdateStep s()=0;58 virtual void UpdateStep(const unsigned int _step)=0; 59 59 60 60 /** Pops the last step in all trajectory vectors. … … 64 64 * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses. 65 65 */ 66 virtual void removeStep s()=0;66 virtual void removeStep(const unsigned int _step)=0; 67 67 68 68 /** DEPRECATED: Getter for element indicated by AtomicElement. … … 276 276 277 277 // operations for trajectories 278 bool isStepPresent(const unsigned int _step) const; 278 279 void ResizeTrajectory(size_t MaxSteps); 279 280 size_t getTrajectorySize() const; … … 297 298 * vectors. 298 299 */ 299 void AppendTrajectoryStep( );300 void AppendTrajectoryStep(const unsigned int _step); 300 301 301 302 /** Function used by this and inheriting classes to decrease the trajectory 302 303 * vectors by one. 303 304 */ 304 void removeTrajectoryStep( );305 void removeTrajectoryStep(const unsigned int _step); 305 306 306 307 // make these protected only such that deriving atom class still has full 307 308 // access needed for clone and alike 308 std::vector<Vector> AtomicPosition; //!< coordinate vector of atom, giving last position within cell 309 std::vector<Vector> AtomicVelocity; //!< velocity vector of atom, giving last velocity within cell 310 std::vector<Vector> AtomicForce; //!< Force vector of atom, giving last force within cell 309 310 //!> typedef for a vector of Vectors with inverse sorting to make lower_bound return present or last past step 311 typedef std::map<unsigned int, Vector, std::greater<unsigned int> > VectorTrajectory_t; 312 VectorTrajectory_t AtomicPosition; //!< coordinate vector of atom, giving last position within cell 313 VectorTrajectory_t AtomicVelocity; //!< velocity vector of atom, giving last velocity within cell 314 VectorTrajectory_t AtomicForce; //!< Force vector of atom, giving last force within cell 311 315 312 316 private: -
src/Atom/atom_bondedparticle.cpp
rc7fe90 r5c8807 52 52 BondedParticle::BondedParticle() 53 53 { 54 ListOfBonds. push_back(BondList());54 ListOfBonds.insert( std::make_pair(0, emptyList) ); 55 55 }; 56 56 … … 59 59 BondedParticle::~BondedParticle() 60 60 { 61 removeAllBonds(); 61 for(BondTrajectory_t::iterator iter = ListOfBonds.begin(); !ListOfBonds.empty(); 62 iter = ListOfBonds.begin()) { 63 removeAllBonds(iter->first); 64 ListOfBonds.erase(iter); 65 } 62 66 }; 63 67 … … 220 224 } 221 225 222 /** Removes all bonds in all timestepsand their instances, too.226 /** Removes all bonds in current timestep and their instances, too. 223 227 * 224 228 */ 225 229 void BondedParticle::removeAllBonds() 226 230 { 227 for (size_t index = 0; index < ListOfBonds.size(); ++index) 228 removeAllBonds(index); 231 removeAllBonds(WorldTime::getTime()); 229 232 } 230 233 … … 236 239 { 237 240 //LOG(3,"INFO: Clearing all bonds of " << *this << ": " << ListOfBonds[_step]); 238 for (BondList::iterator iter = (ListOfBonds[_step]).begin(); 239 !(ListOfBonds[_step]).empty(); 240 iter = (ListOfBonds[_step]).begin()) { 241 //LOG(3,"INFO: Clearing bond (" << *iter << ") " << *(*iter) << " of list " << &ListOfBonds); 242 atom * const Other = (*iter)->GetOtherAtom(this); 243 ASSERT( Other != NULL, 244 "BondedParticle::removeAllBonds() - cannot find bond partner for " 245 +toString(**iter)+"."); 246 Other->UnregisterBond(_step, *iter); 247 UnregisterBond(_step, *iter); 248 } 241 BondTrajectory_t::iterator listiter = ListOfBonds.find(_step); 242 if (listiter != ListOfBonds.end()) 243 for (BondList::iterator iter = listiter->second.begin(); 244 !listiter->second.empty(); 245 iter = listiter->second.begin()) { 246 //LOG(3,"INFO: Clearing bond (" << *iter << ") " << *(*iter) << " of list " << &ListOfBonds); 247 atom * const Other = (*iter)->GetOtherAtom(this); 248 ASSERT( Other != NULL, 249 "BondedParticle::removeAllBonds() - cannot find bond partner for " 250 +toString(**iter)+"."); 251 Other->UnregisterBond(_step, *iter); 252 UnregisterBond(_step, *iter); 253 } 249 254 } 250 255 … … 260 265 if (Binder->Contains(this)) { 261 266 //LOG(3,"INFO: Registering bond "<< *Binder << " with atom " << *this << " at step " << _step); 262 if (ListOfBonds.size() <= _step) 263 ListOfBonds.resize(_step+1); 264 ListOfBonds[_step].push_back(Binder); 267 std::pair< BondTrajectory_t::iterator, bool> inserter = 268 ListOfBonds.insert( std::make_pair( _step, BondList(1, Binder)) ); 269 if (!inserter.second) 270 inserter.first->second.push_back(Binder); 265 271 if (WorldTime::getTime() == _step) 266 272 NOTIFY(AtomObservable::BondsAdded); … … 290 296 OBSERVE; 291 297 //LOG(0,"INFO: Unregistering bond "<< *Binder << " from list " << &ListOfBonds << " of atom " << *this << " at step " << step); 298 BondTrajectory_t::iterator listiter = ListOfBonds.find(_step); 299 if (listiter != ListOfBonds.end()) { 292 300 #ifndef NDEBUG 293 BondList::const_iterator iter =294 std::find(ListOfBonds[_step].begin(), ListOfBonds[_step].end(), Binder);295 ASSERT( iter != ListOfBonds[_step].end(),296 "BondedParticle::UnregisterBond() - "+toString(*Binder)+" not contained at "297 +toString(_step));301 BondList::const_iterator iter = 302 std::find(listiter->second.begin(), listiter->second.end(), Binder); 303 ASSERT( iter != listiter->second.end(), 304 "BondedParticle::UnregisterBond() - "+toString(*Binder)+" not contained at " 305 +toString(_step)); 298 306 #endif 299 Binder->removeAtom(this); 300 ListOfBonds[_step].remove(Binder); 301 if (WorldTime::getTime() == _step) 302 NOTIFY(AtomObservable::BondsRemoved); 303 status = true; 307 Binder->removeAtom(this); 308 listiter->second.remove(Binder); 309 if (WorldTime::getTime() == _step) 310 NOTIFY(AtomObservable::BondsRemoved); 311 status = true; 312 } 304 313 } else { 305 314 ELOG(1, *Binder << " does not contain " << *this << "."); … … 328 337 { 329 338 int step = -1; 330 int tempstep = 0; 331 for(std::vector<BondList>::const_iterator iter = ListOfBonds.begin(); 332 iter != ListOfBonds.end(); 333 ++iter,++tempstep) { 334 for (BondList::const_iterator bonditer = iter->begin(); 335 bonditer != iter->end(); 339 for(BondTrajectory_t::const_iterator listiter = ListOfBonds.begin(); 340 listiter != ListOfBonds.end(); 341 ++listiter) { 342 for (BondList::const_iterator bonditer = listiter->second.begin(); 343 bonditer != listiter->second.end(); 336 344 ++bonditer) { 337 345 if ((*bonditer) == Binder) { 338 step = tempstep;346 step = listiter->first; 339 347 break; 340 348 } -
src/Atom/atom_bondedparticleinfo.cpp
rc7fe90 r5c8807 57 57 {} 58 58 59 void BondedParticleInfo::AppendTrajectoryStep( )59 void BondedParticleInfo::AppendTrajectoryStep(const unsigned int _step) 60 60 { 61 ListOfBonds. push_back(BondList());61 ListOfBonds.insert( std::make_pair(_step, emptyList) ); 62 62 LOG(5,"BondedParticleInfo::AppendTrajectoryStep() called, size is " << ListOfBonds.size()); 63 63 } 64 64 65 void BondedParticleInfo::removeTrajectoryStep( )65 void BondedParticleInfo::removeTrajectoryStep(const unsigned int _step) 66 66 { 67 ListOfBonds. pop_back();67 ListOfBonds.erase(_step); 68 68 LOG(5,"BondedParticleInfo::removeTrajectoryStep() called, size is " << ListOfBonds.size()); 69 69 } … … 71 71 const BondList& BondedParticleInfo::getListOfBonds() const 72 72 { 73 if(WorldTime::getTime() < ListOfBonds.size()) 74 return ListOfBonds[WorldTime::getTime()]; 75 else 76 return emptyList; 73 return getListOfBondsAtStep(WorldTime::getTime()); 77 74 } 78 79 //BondList& BondedParticleInfo::getListOfBonds()80 //{81 // // todo: here we actually need a container on whose destruction notifiy is emitted, i.e.82 // // similar or simply an ObservedContainer.83 // OBSERVE;84 // NOTIFY(AtomObservable::BondsAdded);85 // const unsigned int size = ListOfBonds.size();86 // ASSERT(WorldTime::getTime() <= size,87 // "BondedParticleInfo::getBondsAtStep() - Access out of range: "88 // +toString(WorldTime::getTime())89 // +" not in [0,"+toString(size)+"].");90 // if (WorldTime::getTime() == size) {91 // UpdateSteps();92 // }93 // return ListOfBonds[WorldTime::getTime()];94 //}95 75 96 76 const BondList& BondedParticleInfo::getListOfBondsAtStep(unsigned int _step) const 97 77 { 98 if(_step < ListOfBonds.size()) 99 return ListOfBonds[_step]; 100 else 101 return emptyList; 78 BondTrajectory_t::const_iterator iter = 79 ListOfBonds.find(_step); 80 if (iter != ListOfBonds.end()) 81 return iter->second; 82 return emptyList; 102 83 } 103 104 //BondList& BondedParticleInfo::getListOfBondsAtStep(unsigned int _step)105 //{106 // const unsigned int size = ListOfBonds.size();107 // ASSERT(_step <= size,108 // "BondedParticleInfo::getBondsAtStep() - Access out of range: "109 // +toString(_step)110 // +" not in [0,"+toString(size)+"].");111 // if (_step == size) {112 // UpdateSteps();113 // }114 // return ListOfBonds[_step];115 //} -
src/Atom/atom_bondedparticleinfo.hpp
rc7fe90 r5c8807 49 49 * real functions, \sa AppendTrajectoryStep(), by all necessary subclasses. 50 50 */ 51 virtual void UpdateSteps()=0; 51 virtual void UpdateStep(const unsigned int _step)=0; 52 53 /** Pops the last step in all trajectory vectors. 54 * 55 * This allows to decrease all trajectories contained in different classes 56 * by one consistently. This is implemented by the topmost class which calls 57 * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses. 58 */ 59 virtual void removeStep(const unsigned int _step)=0; 52 60 53 61 /** Const accessor to ListOfBonds of WorldTime::CurrentTime. … … 87 95 * vector. 88 96 */ 89 void AppendTrajectoryStep( );97 void AppendTrajectoryStep(const unsigned int _step); 90 98 91 99 /** Function used by this and inheriting classes to reduce the ListOfBonds 92 100 * vector by one. 93 101 */ 94 void removeTrajectoryStep( );102 void removeTrajectoryStep(const unsigned int _step); 95 103 96 std::vector<BondList> ListOfBonds; //!< list of all bonds 104 typedef std::map<unsigned int, BondList> BondTrajectory_t; 105 BondTrajectory_t ListOfBonds; //!< list of all bonds 97 106 static BondList emptyList; //!< empty list to return when step is not present 98 107 }; -
src/Atom/unittests/AtomObserverUnitTest.cpp
rc7fe90 r5c8807 130 130 void AtomObserverTest::AtomElementTest() 131 131 { 132 atoms[0]->setType(1); 132 CPPUNIT_ASSERT( atoms[0]->getType()->getAtomicNumber() != 2 ); 133 atoms[0]->setType(2); 133 134 134 135 // check for update -
src/Fragmentation/Exporters/HydrogenPool.cpp
rc7fe90 r5c8807 103 103 const size_t CurrentTime = WorldTime::getTime(); 104 104 for (size_t step = _atom->getTrajectorySize(); step <= CurrentTime; ++step) 105 _atom->UpdateStep s();105 _atom->UpdateStep(step); 106 106 } 107 107 -
src/LinkedCell/unittests/stubs/TesselPointStub.cpp
rc7fe90 r5c8807 43 43 virtual ~TesselPoint(); 44 44 45 virtual void UpdateStep s();45 virtual void UpdateStep(const unsigned int _step); 46 46 47 47 TesselPoint * getTesselPoint(); … … 54 54 {} 55 55 56 void TesselPoint::UpdateStep s()56 void TesselPoint::UpdateStep(const unsigned int _step) 57 57 {} 58 58 -
src/Potentials/Makefile.am
rc7fe90 r5c8807 53 53 Potentials/Specifics/PotentialTypes.def \ 54 54 Potentials/Specifics/PotentialTypes.undef 55 56 if CONDLEVMAR 57 POTENTIALSHEADER += \ 58 Potentials/PotentialTrainer.hpp 59 POTENTIALSSOURCE = \ 60 Potentials/PotentialTrainer.cpp 61 endif 55 62 56 63 # add here headers for real potentials (i.e. the PotentialFactory should instantiate) -
src/World.cpp
rc7fe90 r5c8807 234 234 if (_step != WorldTime::getTime()) { 235 235 const unsigned int oldstep = WorldTime::getTime(); 236 // set new time 236 237 // 1. copy bond graph (such not each addBond causes GUI update) 238 if (!areBondsPresent(_step)) { 239 // AtomComposite Set = getAllAtoms(); 240 // BG->cleanAdjacencyList(Set); 241 copyBondgraph(oldstep, _step); 242 } 243 244 // 2. set new time 237 245 WorldTime::getInstance().setTime(_step); 246 238 247 // TODO: removed when BondGraph creates the adjacency 239 // 1. remove all of World's molecules248 // 3. remove all of World's molecules 240 249 for (MoleculeIterator iter = getMoleculeIter(); 241 250 getMoleculeIter() != moleculeEnd(); … … 244 253 destroyMolecule(*iter); 245 254 } 246 // 2. copy bond graph 247 if (!areBondsPresent(_step)) { 248 // AtomComposite Set = getAllAtoms(); 249 // BG->cleanAdjacencyList(Set); 250 copyBondgraph(oldstep, _step); 251 } 252 253 // 3. scan for connected subgraphs => molecules 255 256 // 4. scan for connected subgraphs => molecules 254 257 DepthFirstSearchAnalysis DFS; 255 258 DFS(); -
src/molecule_geometry.cpp
rc7fe90 r5c8807 295 295 void molecule::Scale(const double *factor) 296 296 { 297 for (iterator iter = begin(); iter != end(); ++iter) {298 for (size_t j=0;j<(*iter)->getTrajectorySize();j++) {299 Vector temp = (*iter)->getPositionAtStep(j);300 temp.ScaleAll(factor);301 (*iter)->setPositionAtStep(j,temp);302 }303 }297 for (iterator iter = begin(); iter != end(); ++iter) 298 for (size_t j=0;j<(*iter)->getTrajectorySize();j++) 299 if ((*iter)->isStepPresent(j)) { 300 Vector temp = (*iter)->getPositionAtStep(j); 301 temp.ScaleAll(factor); 302 (*iter)->setPositionAtStep(j,temp); 303 } 304 304 }; 305 305 … … 309 309 void molecule::Translate(const Vector &trans) 310 310 { 311 getAtomSet().translate(trans); 311 for (iterator iter = begin(); iter != end(); ++iter) 312 for (size_t j=0;j<(*iter)->getTrajectorySize();j++) 313 if ((*iter)->isStepPresent(j)) 314 (*iter)->setPositionAtStep(j, (*iter)->getPositionAtStep(j) + (trans)); 312 315 }; 313 316 -
tests/Python/AllActions/options.dat
rc7fe90 r5c8807 99 99 mesh-size "10,10,10" 100 100 min-distance "1." 101 mirror-atoms "1.,1.,1." 101 102 molecule-by-id "0" 102 103 near-field-cells "3" … … 124 125 output-types "xyz mpqc" 125 126 parse-homologies "homology.dat" 127 parse-potentials "water.potentials" 126 128 parse-tremolo-potentials "argon.potentials" 127 129 parse-tremolo-potentials "tensid.potentials" … … 129 131 parser-parameters "psi3" 130 132 periodic "0" 133 plane-offset "5." 131 134 position "0 0 0" 132 135 position "0 0 1" … … 161 164 save-bonds "test.bond" 162 165 save-homologies "homology.dat" 166 save-potentials "water.potentials" 163 167 save-selected-atoms "testsave.xyz" 164 168 save-selected-atoms-as-exttypes "test.exttypes" -
tests/regression/Atoms/testsuite-atoms.at
rc7fe90 r5c8807 41 41 # translate to origin 42 42 m4_include([Atoms/TranslationToOrigin/testsuite-atoms-translation-to-origin.at]) 43 44 # mirror atoms 45 m4_include([Atoms/Mirror/testsuite-atoms-mirror.at]) -
tests/regression/Makefile.am
rc7fe90 r5c8807 35 35 $(srcdir)/Atoms/Add/testsuite-atoms-add.at \ 36 36 $(srcdir)/Atoms/ChangeElement/testsuite-atoms-change-element.at \ 37 $(srcdir)/Atoms/Mirror/testsuite-atoms-mirror.at \ 37 38 $(srcdir)/Atoms/Remove/testsuite-atoms-remove.at \ 38 39 $(srcdir)/Atoms/RemoveCuboid/testsuite-atoms-remove-cuboid.at \ -
tests/regression/Potential/FitPotential/testsuite-potential-fit-potential.at
rc7fe90 r5c8807 26 26 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0) 27 27 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore]) 28 AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "morse" --potential-charges 8 1 --fragment-charges 1 8 1 --set-threshold 1e-6], 0, [stdout], [ignore]) 28 AT_CHECK([../../molecuilder \ 29 --parse-homologies $file \ 30 --set-random-number-engine "lagged_fibonacci607" \ 31 --random-number-engine-parameters "seed=1;" \ 32 --set-random-number-distribution "uniform_real" \ 33 --random-number-distribution-parameters "min=0;max=1;" \ 34 --fit-potential \ 35 --potential-type "morse" \ 36 --potential-charges 8 1 \ 37 --fragment-charges 1 8 1 \ 38 --set-threshold 1e-6 \ 39 --save-potentials length.potentials], 0, [stdout], [ignore]) 29 40 # check that L_2 error is below 1e-6 30 41 AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 1e-6) exit 1}'], 0, [ignore], [ignore]) 31 42 # check parameters to printed precision 32 AT_CHECK([grep "morse:.*particle_type1=8,.*particle_type2=1,.*spring_constant=1.27.*,.*equilibrium_distance=1.78.*,.*dissociation_energy=0.19.*;" stdout], 0, [ignore], [ignore])43 AT_CHECK([grep "morse:.*particle_type1=8,.*particle_type2=1,.*spring_constant=1.27.*,.*equilibrium_distance=1.78.*,.*dissociation_energy=0.19.*;" length.potentials], 0, [ignore], [ignore]) 33 44 34 45 AT_CLEANUP … … 41 52 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0) 42 53 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore]) 43 AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "harmonic_bond" --potential-charges 8 1 --fragment-charges 1 8 1 --set-threshold 1e-6], 0, [stdout], [ignore]) 54 AT_CHECK([../../molecuilder \ 55 --parse-homologies $file \ 56 --set-random-number-engine "lagged_fibonacci607" \ 57 --random-number-engine-parameters "seed=1;" \ 58 --set-random-number-distribution "uniform_real" \ 59 --random-number-distribution-parameters "min=0;max=1;" \ 60 --fit-potential \ 61 --potential-type "harmonic_bond" \ 62 --potential-charges 8 1 \ 63 --fragment-charges 1 8 1 \ 64 --set-threshold 1e-6 \ 65 --save-potentials harmonic.potentials], 0, [stdout], [ignore]) 44 66 # check that L_2 error is below 1e-6 45 67 AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 1e-6) exit 1}'], 0, [ignore], [ignore]) 46 68 # check parameters to printed precision 47 AT_CHECK([grep "harmonic_bond:.*particle_type1=8,.*particle_type2=1,.*spring_constant=0.29.*,.*equilibrium_distance=1.8.*;" stdout], 0, [ignore], [ignore])69 AT_CHECK([grep "harmonic_bond:.*particle_type1=8,.*particle_type2=1,.*spring_constant=0.29.*,.*equilibrium_distance=1.8.*;" harmonic.potentials], 0, [ignore], [ignore]) 48 70 49 71 AT_CLEANUP … … 56 78 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0) 57 79 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore]) 58 AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "harmonic_angle" --potential-charges 1 8 1 --fragment-charges 1 8 1 --set-threshold 1e-6], 0, [stdout], [ignore]) 80 AT_CHECK([../../molecuilder \ 81 --parse-homologies $file \ 82 --set-random-number-engine "lagged_fibonacci607" \ 83 --random-number-engine-parameters "seed=1;" \ 84 --set-random-number-distribution "uniform_real" \ 85 --random-number-distribution-parameters "min=0;max=1;" \ 86 --fit-potential \ 87 --potential-type "harmonic_angle" \ 88 --potential-charges 1 8 1 \ 89 --fragment-charges 1 8 1 \ 90 --set-threshold 1e-6 \ 91 --save-potentials angle.potentials], 0, [stdout], [ignore]) 59 92 # check that L_2 error is below 1e-6 60 93 AT_CHECK([grep "||e||_2:" stdout | awk '{if ($7 > 1e-6) exit 1}'], 0, [ignore], [ignore]) 61 94 # check parameters to printed precision 62 AT_CHECK([grep "harmonic_angle:.*particle_type1=1,.*particle_type2=8,.*particle_type3=1,.*spring_constant=0.10.*,.*equilibrium_distance=-0.27.*;" stdout], 0, [ignore], [ignore])95 AT_CHECK([grep "harmonic_angle:.*particle_type1=1,.*particle_type2=8,.*particle_type3=1,.*spring_constant=0.10.*,.*equilibrium_distance=-0.27.*;" angle.potentials], 0, [ignore], [ignore]) 63 96 64 97 AT_CLEANUP … … 71 104 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0) 72 105 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore]) 73 AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "torsion" --potential-charges 6 6 6 6 --fragment-charges 6 6 6 6 1 1 1 1 1 1 1 1 1 1 --set-threshold 2e-10], 0, [stdout], [ignore]) 106 AT_CHECK([../../molecuilder \ 107 --parse-homologies $file \ 108 --set-random-number-engine "lagged_fibonacci607" \ 109 --random-number-engine-parameters "seed=1;" \ 110 --set-random-number-distribution "uniform_real" \ 111 --random-number-distribution-parameters "min=0;max=1;" \ 112 --fit-potential \ 113 --potential-type "torsion" \ 114 --potential-charges 6 6 6 6 \ 115 --fragment-charges 6 6 6 6 1 1 1 1 1 1 1 1 1 1 \ 116 --set-threshold 2e-10 \ 117 --save-potentials torsion.potentials], 0, [stdout], [ignore]) 74 118 # check that L_2 error is below 9e-12 ... just 2e-10 otherwise test takes tooo long 75 119 AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 2e-10) exit 1}'], 0, [ignore], [ignore]) 76 AT_CHECK([grep "torsion:.*particle_type1=6,.*particle_type2=6,.*particle_type3=6,.*particle_type4=6,.*spring_constant=.*,.*equilibrium_distance=.*;" stdout], 0, [ignore], [ignore])77 #AT_CHECK([grep "torsion:.*particle_type1=6,.*particle_type2=6,.*particle_type3=6,.*particle_type4=6,.*spring_constant=0.001.*,.*equilibrium_distance=0.99.*;" stdout], 0, [ignore], [ignore])120 AT_CHECK([grep "torsion:.*particle_type1=6,.*particle_type2=6,.*particle_type3=6,.*particle_type4=6,.*spring_constant=.*,.*equilibrium_distance=.*;" torsion.potentials], 0, [ignore], [ignore]) 121 #AT_CHECK([grep "torsion:.*particle_type1=6,.*particle_type2=6,.*particle_type3=6,.*particle_type4=6,.*spring_constant=0.001.*,.*equilibrium_distance=0.99.*;" torsion.potentials], 0, [ignore], [ignore]) 78 122 79 123 AT_CLEANUP … … 86 130 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0) 87 131 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore]) 88 AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "improper" --potential-charges 1 7 1 1 --fragment-charges 7 1 1 1 --set-threshold 3e-4], 0, [stdout], [ignore]) 132 AT_CHECK([../../molecuilder \ 133 --parse-homologies $file \ 134 --set-random-number-engine "lagged_fibonacci607" \ 135 --random-number-engine-parameters "seed=1;" \ 136 --set-random-number-distribution "uniform_real" \ 137 --random-number-distribution-parameters "min=0;max=1;" \ 138 --fit-potential \ 139 --potential-type "improper" \ 140 --potential-charges 1 7 1 1 \ 141 --fragment-charges 7 1 1 1 \ 142 --set-threshold 3e-4 \ 143 --save-potentials improper.potentials], 0, [stdout], [ignore]) 89 144 # check that L_2 error is below 3e-4 90 145 AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 3e-4) exit 1}'], 0, [ignore], [ignore]) 91 146 # check parameters to printed precision 92 AT_CHECK([grep "improper:.*particle_type1=1,.*particle_type2=7,.*particle_type3=1,.*particle_type4=1,.*spring_constant=.*,.*equilibrium_distance=.*;" stdout], 0, [ignore], [ignore])93 #AT_CHECK([grep "improper:.*particle_type1=1,.*particle_type2=7,.*particle_type3=1,.*particle_type4=1,.*spring_constant=1.02.*,.*equilibrium_distance=0.85.*;" stdout], 0, [ignore], [ignore])147 AT_CHECK([grep "improper:.*particle_type1=1,.*particle_type2=7,.*particle_type3=1,.*particle_type4=1,.*spring_constant=.*,.*equilibrium_distance=.*;" improper.potentials], 0, [ignore], [ignore]) 148 #AT_CHECK([grep "improper:.*particle_type1=1,.*particle_type2=7,.*particle_type3=1,.*particle_type4=1,.*spring_constant=1.02.*,.*equilibrium_distance=0.85.*;" improper.potentials], 0, [ignore], [ignore]) 94 149 95 150 AT_CLEANUP … … 102 157 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0) 103 158 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore]) 104 AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=5;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "lennardjones" --potential-charges 18 18 --fragment-charges 18 18 --set-threshold 7e-9], 0, [stdout], [ignore]) 159 AT_CHECK([../../molecuilder \ 160 --parse-homologies $file \ 161 --set-random-number-engine "lagged_fibonacci607" \ 162 --random-number-engine-parameters "seed=5;" \ 163 --set-random-number-distribution "uniform_real" \ 164 --random-number-distribution-parameters "min=0;max=1;" \ 165 --fit-potential \ 166 --potential-type "lennardjones" \ 167 --potential-charges 18 18 \ 168 --fragment-charges 18 18 \ 169 --set-threshold 7e-9 \ 170 --save-potentials lj.potentials], 0, [stdout], [ignore]) 105 171 # check that L_2 error is below 7e-11 ... just 7e-9 otherwise test takes too long 106 172 AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 7e-9) exit 1}'], 0, [ignore], [ignore]) 107 173 # check parameters to printed precision 108 AT_CHECK([grep "lennardjones:.*particle_type1=18,.*particle_type2=18,.*epsilon=.*,.*sigma=.*;" stdout], 0, [ignore], [ignore])109 #AT_CHECK([grep "lennardjones:.*particle_type1=18,.*particle_type2=18,.*epsilon=1.*e-05,.*sigma=8.2.*;" stdout], 0, [ignore], [ignore])174 AT_CHECK([grep "lennardjones:.*particle_type1=18,.*particle_type2=18,.*epsilon=.*,.*sigma=.*;" lj.potentials], 0, [ignore], [ignore]) 175 #AT_CHECK([grep "lennardjones:.*particle_type1=18,.*particle_type2=18,.*epsilon=1.*e-05,.*sigma=8.2.*;" lj.potentials], 0, [ignore], [ignore]) 110 176 111 177 AT_CLEANUP
Note:
See TracChangeset
for help on using the changeset viewer.