Changeset 056e70
- Timestamp:
- Feb 24, 2011, 5:56:03 PM (14 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 6b020f
- Parents:
- 6625c3
- Location:
- src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AtomSet.hpp
r6625c3 r056e70 127 127 inline void AtomSetMixin<Set>::addVelocityAtStep(const Vector velocity, unsigned int step){ 128 128 BOOST_FOREACH(AtomInfo *atom,*this){ 129 atom-> getAtomicVelocity(step) += velocity;129 atom->setAtomicVelocityAtStep(step, atom->getAtomicVelocityAtStep(step)+velocity); 130 130 } 131 131 } -
src/Parser/TremoloParser.cpp
r6625c3 r056e70 313 313 ConvertTo<double> toDouble; 314 314 ConvertTo<int> toInt; 315 Vector tempVector; 315 316 316 317 // setup tokenizer, splitting up white-spaced entries … … 327 328 currentField = knownKeys[keyName]; 328 329 const string word = *tok_iter; 329 //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with remaining data " << word << std::endl);330 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with remaining data " << word << std::endl); 330 331 switch (currentField) { 331 332 case TremoloKey::x : … … 333 334 for (int i=0;i<NDIM;i++) { 334 335 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for x["+toString(i)+"]!"); 335 //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);336 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 336 337 newAtom->set(i, toDouble(*tok_iter)); 337 338 tok_iter++; … … 342 343 for (int i=0;i<NDIM;i++) { 343 344 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for u["+toString(i)+"]!"); 344 //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);345 newAtom->getAtomicVelocity()[i] = toDouble(*tok_iter);345 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 346 tempVector[i] = toDouble(*tok_iter); 346 347 tok_iter++; 347 348 } 349 newAtom->setAtomicVelocity(tempVector); 348 350 break; 349 351 case TremoloKey::Type : 350 352 { 351 353 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!"); 352 DoLog( 1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);354 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 353 355 std::string element(knownTypes[(*tok_iter)]); 354 356 // put type name into container for later use 355 357 atomInfo->set(currentField, *tok_iter); 356 DoLog( 1) && (Log() << Verbose(1) << "INFO: Parsing element " << (*tok_iter) << " as " << element << " according to KnownTypes." << std::endl);358 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing element " << (*tok_iter) << " as " << element << " according to KnownTypes." << std::endl); 357 359 tok_iter++; 358 360 newAtom->setType(World::getInstance().getPeriode()->FindElement(element)); … … 362 364 case TremoloKey::Id : 363 365 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!"); 364 //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);366 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 365 367 atomIdMap[toInt(*tok_iter)] = newAtom->getId(); 366 368 tok_iter++; … … 369 371 for (int i=0;i<atoi(it->substr(it->find("=") + 1, 1).c_str());i++) { 370 372 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!"); 371 //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);373 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 372 374 lineStream << *tok_iter << "\t"; 373 375 tok_iter++; … … 378 380 default : 379 381 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!"); 380 //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);382 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 381 383 atomInfo->set(currentField, *tok_iter); 382 384 tok_iter++; … … 403 405 // 0 is used to fill empty neighbor positions in the tremolo file. 404 406 if (neighborId > 0) { 405 // DoLog(1) && (Log() << Verbose(1)406 //<< "Atom with global id " << atomId407 //<< " has neighbour with serial " << neighborId408 //<< std::endl);407 DoLog(4) && (Log() << Verbose(4) 408 << "Atom with global id " << atomId 409 << " has neighbour with serial " << neighborId 410 << std::endl); 409 411 additionalAtomData[atomId].neighbors.push_back(neighborId); 410 412 } -
src/Thermostats/Berendsen.cpp
r6625c3 r056e70 63 63 double ScaleTempFactor = getContainer().TargetTemp/ActualTemp; 64 64 for(ForwardIterator iter=begin;iter!=end;++iter){ 65 Vector &U = (*iter)->getAtomicVelocity(step);65 Vector U = (*iter)->getAtomicVelocityAtStep(step); 66 66 if ((*iter)->getFixedIon() == 0) { // even FixedIon moves, only not by other's forces 67 67 U *= sqrt(1+(World::getInstance().getConfig()->Deltat/TempFrequency)*(ScaleTempFactor-1)); 68 68 ekin += 0.5*(*iter)->getType()->getMass() * U.NormSquared(); 69 69 } 70 (*iter)->setAtomicVelocityAtStep(step, U); 70 71 } 71 72 return ekin; -
src/Thermostats/GaussianThermostat.cpp
r6625c3 r056e70 70 70 double ekin =0; 71 71 for(ForwardIterator iter=begin;iter!=end;++iter){ 72 Vector &U = (*iter)->getAtomicVelocity(step);72 Vector U = (*iter)->getAtomicVelocityAtStep(step); 73 73 if ((*iter)->getFixedIon() == 0) {// even FixedIon moves, only not by other's forces 74 74 U += World::getInstance().getConfig()->Deltat * G_over_E * U; 75 75 ekin += (*iter)->getType()->getMass() * U.NormSquared(); 76 76 } 77 (*iter)->setAtomicVelocityAtStep(step, U); 77 78 } 78 79 return ekin; … … 84 85 G=0; 85 86 for(ForwardIterator iter=begin;iter!=end;++iter){ 86 const Vector &U = (*iter)->getAtomicVelocity (step);87 const Vector &F = (*iter)->getAtomicForce (step);87 const Vector &U = (*iter)->getAtomicVelocityAtStep(step); 88 const Vector &F = (*iter)->getAtomicForceAtStep(step); 88 89 if ((*iter)->getFixedIon() == 0){ // even FixedIon moves, only not by other's forces 89 90 G += U.ScalarProduct(F); -
src/Thermostats/Langevin.cpp
r6625c3 r056e70 89 89 rng_distribution = new boost::normal_distribution<>(0,sigma); 90 90 boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > rng(*rng_engine, *rng_distribution); 91 Vector &U = (*iter)->getAtomicVelocity(step);91 Vector U = (*iter)->getAtomicVelocityAtStep(step); 92 92 if ((*iter)->getFixedIon() == 0) { // even FixedIon moves, only not by other's forces 93 93 // throw a dice to determine whether it gets hit by a heat bath particle … … 102 102 ekin += 0.5*(*iter)->getType()->getMass() * U.NormSquared(); 103 103 } 104 (*iter)->setAtomicVelocityAtStep(step, U); 104 105 delete rng_distribution; 105 106 rng_distribution = NULL; -
src/Thermostats/NoseHoover.cpp
r6625c3 r056e70 68 68 double ekin =0; 69 69 for(ForwardIterator iter=begin;iter!=end;++iter){ 70 Vector &U = (*iter)->getAtomicVelocity(step);70 Vector U = (*iter)->getAtomicVelocityAtStep(step); 71 71 if ((*iter)->getFixedIon() == 0) { // even FixedIon moves, only not by other's forces 72 72 U += World::getInstance().getConfig()->Deltat/(*iter)->getType()->getMass() * (alpha * (U * (*iter)->getType()->getMass())); 73 73 ekin += (0.5*(*iter)->getType()->getMass()) * U.NormSquared(); 74 74 } 75 (*iter)->setAtomicVelocityAtStep(step, U); 75 76 } 76 77 return ekin; … … 82 83 count=0; 83 84 for(ForwardIterator iter = begin;iter!=end;++iter){ 84 const Vector &U = (*iter)->getAtomicVelocity (step);85 const Vector &U = (*iter)->getAtomicVelocityAtStep(step); 85 86 if ((*iter)->getFixedIon() == 0) { // even FixedIon moves, only not by other's forces 86 87 delta_alpha += U.NormSquared()*(*iter)->getType()->getMass(); -
src/Thermostats/Woodcock.cpp
r6625c3 r056e70 67 67 double ekin; 68 68 for (ForwardIterator iter = begin; iter!=end;++iter){ 69 Vector &U = (*iter)->getAtomicVelocity(step);69 Vector U = (*iter)->getAtomicVelocityAtStep(step); 70 70 if ((*iter)->getFixedIon() == 0){ // even FixedIon moves, only not by other's forces 71 71 U *= ScaleTempFactor; 72 72 ekin += 0.5*(*iter)->getType()->getMass() * U.NormSquared(); 73 73 } 74 (*iter)->setAtomicVelocityAtStep(step, U); 74 75 } 75 76 } -
src/atom.cpp
r6625c3 r056e70 218 218 ASSERT(elementLookup.there.find(elemental)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration"); 219 219 *out << "Ion_Type" << elementLookup.there.find(elemental)->second << "_" << AtomNo[getType()->getAtomicNumber()] << "\t" << fixed << setprecision(9) << showpoint; 220 *out << getPosition (step)[0] << "\t" << getPosition(step)[1] << "\t" << getPosition(step)[2];220 *out << getPositionAtStep(step)[0] << "\t" << getPositionAtStep(step)[1] << "\t" << getPositionAtStep(step)[2]; 221 221 *out << "\t" << (int)(getFixedIon()); 222 if (getAtomicVelocity (step).Norm() > MYEPSILON)223 *out << "\t" << scientific << setprecision(6) << getAtomicVelocity (step)[0] << "\t" << getAtomicVelocity(step)[1] << "\t" << getAtomicVelocity(step)[2] << "\t";224 if (getAtomicForce (step).Norm() > MYEPSILON)225 *out << "\t" << scientific << setprecision(6) << getAtomicForce (step)[0] << "\t" << getAtomicForce(step)[1] << "\t" << getAtomicForce(step)[2] << "\t";222 if (getAtomicVelocityAtStep(step).Norm() > MYEPSILON) 223 *out << "\t" << scientific << setprecision(6) << getAtomicVelocityAtStep(step)[0] << "\t" << getAtomicVelocityAtStep(step)[1] << "\t" << getAtomicVelocityAtStep(step)[2] << "\t"; 224 if (getAtomicForceAtStep(step).Norm() > MYEPSILON) 225 *out << "\t" << scientific << setprecision(6) << getAtomicForceAtStep(step)[0] << "\t" << getAtomicForceAtStep(step)[1] << "\t" << getAtomicForceAtStep(step)[2] << "\t"; 226 226 *out << "\t# Number in molecule " << nr << endl; 227 227 return true; … … 239 239 if (out != NULL) { 240 240 *out << getType()->getSymbol() << "\t"; 241 *out << getPosition (step)[0] << "\t";242 *out << getPosition (step)[1] << "\t";243 *out << getPosition (step)[2] << endl;241 *out << getPositionAtStep(step)[0] << "\t"; 242 *out << getPositionAtStep(step)[1] << "\t"; 243 *out << getPositionAtStep(step)[2] << endl; 244 244 return true; 245 245 } else -
src/atom_atominfo.cpp
r6625c3 r056e70 80 80 const double& AtomInfo::operator[](size_t i) const 81 81 { 82 ASSERT(AtomicPosition.size() > 0, 83 "AtomInfo::operator[]() - Access out of range."); 82 84 return AtomicPosition[0][i]; 83 85 } … … 85 87 const double& AtomInfo::at(size_t i) const 86 88 { 89 ASSERT(AtomicPosition.size() > 0, 90 "AtomInfo::at() - Access out of range."); 87 91 return AtomicPosition[0].at(i); 88 92 } 89 93 94 const double& AtomInfo::atStep(size_t i, int _step) const 95 { 96 ASSERT(AtomicPosition.size() > _step, 97 "AtomInfo::atStep() - Access out of range."); 98 return AtomicPosition[_step].at(i); 99 } 100 90 101 void AtomInfo::set(size_t i, const double value) 91 102 { 103 ASSERT(AtomicPosition.size() > 0, 104 "AtomInfo::set() - Access out of range."); 92 105 AtomicPosition[0].at(i) = value; 93 106 } … … 95 108 const Vector& AtomInfo::getPosition() const 96 109 { 110 ASSERT(AtomicPosition.size() > 0, 111 "AtomInfo::getPosition() - Access out of range."); 97 112 return AtomicPosition[0]; 98 113 } 99 114 100 const Vector& AtomInfo::getPosition (const int _step) const115 const Vector& AtomInfo::getPositionAtStep(const int _step) const 101 116 { 102 117 ASSERT(_step < AtomicPosition.size(), 103 "AtomInfo::getPosition () - Access out of range.");118 "AtomInfo::getPositionAtStep() - Access out of range."); 104 119 return AtomicPosition[_step]; 105 120 } … … 114 129 } 115 130 116 Vector& AtomInfo::getAtomicVelocity() 117 { 131 //Vector& AtomInfo::getAtomicVelocity() 132 //{ 133 // return AtomicVelocity[0]; 134 //} 135 136 //Vector& AtomInfo::getAtomicVelocity(const int _step) 137 //{ 138 // ASSERT(_step < AtomicVelocity.size(), 139 // "AtomInfo::getAtomicVelocity() - Access out of range."); 140 // return AtomicVelocity[_step]; 141 //} 142 143 const Vector& AtomInfo::getAtomicVelocity() const 144 { 145 ASSERT(AtomicVelocity.size() > 0, 146 "AtomInfo::getAtomicVelocity() - Access out of range."); 118 147 return AtomicVelocity[0]; 119 148 } 120 149 121 Vector& AtomInfo::getAtomicVelocity(const int _step) 150 const Vector& AtomInfo::getAtomicVelocityAtStep(const int _step) const 122 151 { 123 152 ASSERT(_step < AtomicVelocity.size(), … … 126 155 } 127 156 128 const Vector& AtomInfo::getAtomicVelocity() const129 {130 return AtomicVelocity[0];131 }132 133 const Vector& AtomInfo::getAtomicVelocity(const int _step) const134 {135 ASSERT(_step < AtomicVelocity.size(),136 "AtomInfo::getAtomicVelocity() - Access out of range.");137 return AtomicVelocity[_step];138 }139 140 157 void AtomInfo::setAtomicVelocity(const Vector &_newvelocity) 141 158 { 159 ASSERT(0 < AtomicVelocity.size(), 160 "AtomInfo::setAtomicVelocity() - Access out of range."); 142 161 AtomicVelocity[0] = _newvelocity; 143 162 } 144 163 145 void AtomInfo::setAtomicVelocity (const int _step, const Vector &_newvelocity)164 void AtomInfo::setAtomicVelocityAtStep(const int _step, const Vector &_newvelocity) 146 165 { 147 166 ASSERT(_step <= AtomicVelocity.size(), 148 "AtomInfo::setAtomicVelocity () - Access out of range.");167 "AtomInfo::setAtomicVelocityAtStep() - Access out of range."); 149 168 if(_step < (int)AtomicVelocity.size()) { 150 169 AtomicVelocity[_step] = _newvelocity; … … 156 175 const Vector& AtomInfo::getAtomicForce() const 157 176 { 177 ASSERT(0 < AtomicForce.size(), 178 "AtomInfo::getAtomicForce() - Access out of range."); 158 179 return AtomicForce[0]; 159 180 } 160 181 161 const Vector& AtomInfo::getAtomicForce (const int _step) const182 const Vector& AtomInfo::getAtomicForceAtStep(const int _step) const 162 183 { 163 184 ASSERT(_step < AtomicForce.size(), … … 168 189 void AtomInfo::setAtomicForce(const Vector &_newforce) 169 190 { 191 ASSERT(0 < AtomicForce.size(), 192 "AtomInfo::setAtomicForce() - Access out of range."); 170 193 AtomicForce[0] = _newforce; 171 194 } 172 195 173 void AtomInfo::setAtomicForce(const int _step, const Vector &_newforce) 174 { 175 ASSERT(_step <= AtomicForce.size(), 196 void AtomInfo::setAtomicForceAtStep(const int _step, const Vector &_newforce) 197 { 198 const int size = AtomicForce.size(); 199 ASSERT(_step <= size, 176 200 "AtomInfo::setAtomicForce() - Access out of range."); 177 if(_step < (int)AtomicForce.size()) {201 if(_step < size) { 178 202 AtomicForce[_step] = _newforce; 179 } else if (_step == (int)AtomicForce.size()) {203 } else if (_step == size) { 180 204 AtomicForce.push_back(_newforce); 181 205 } … … 194 218 void AtomInfo::setPosition(const Vector& _vector) 195 219 { 220 ASSERT(0 < AtomicPosition.size(), 221 "AtomInfo::setPosition() - Access out of range."); 196 222 AtomicPosition[0] = _vector; 197 223 //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl; 198 224 } 199 225 200 void AtomInfo::setPosition (int _step, const Vector& _vector)226 void AtomInfo::setPositionAtStep(int _step, const Vector& _vector) 201 227 { 202 228 ASSERT(_step <= AtomicPosition.size(), … … 212 238 const VectorInterface& AtomInfo::operator+=(const Vector& b) 213 239 { 240 ASSERT(0 < AtomicPosition.size(), 241 "AtomInfo::operator+=() - Access out of range."); 214 242 AtomicPosition[0] += b; 215 243 return *this; … … 218 246 const VectorInterface& AtomInfo::operator-=(const Vector& b) 219 247 { 248 ASSERT(0 < AtomicPosition.size(), 249 "AtomInfo::operator-=() - Access out of range."); 220 250 AtomicPosition[0] -= b; 221 251 return *this; … … 224 254 Vector const AtomInfo::operator+(const Vector& b) const 225 255 { 256 ASSERT(0 < AtomicPosition.size(), 257 "AtomInfo::operator+() - Access out of range."); 226 258 Vector a(AtomicPosition[0]); 227 259 a += b; … … 231 263 Vector const AtomInfo::operator-(const Vector& b) const 232 264 { 265 ASSERT(0 < AtomicPosition.size(), 266 "AtomInfo::operator-() - Access out of range."); 233 267 Vector a(AtomicPosition[0]); 234 268 a -= b; … … 238 272 double AtomInfo::distance(const Vector &point) const 239 273 { 274 ASSERT(0 < AtomicPosition.size(), 275 "AtomInfo::distance() - Access out of range."); 240 276 return AtomicPosition[0].distance(point); 241 277 } … … 243 279 double AtomInfo::DistanceSquared(const Vector &y) const 244 280 { 281 ASSERT(0 < AtomicPosition.size(), 282 "AtomInfo::DistanceSquared() - Access out of range."); 245 283 return AtomicPosition[0].DistanceSquared(y); 246 284 } … … 248 286 double AtomInfo::distance(const VectorInterface &_atom) const 249 287 { 288 ASSERT(0 < AtomicPosition.size(), 289 "AtomInfo::distance() - Access out of range."); 250 290 return _atom.distance(AtomicPosition[0]); 251 291 } … … 253 293 double AtomInfo::DistanceSquared(const VectorInterface &_atom) const 254 294 { 295 ASSERT(0 < AtomicPosition.size(), 296 "AtomInfo::DistanceSquared() - Access out of range."); 255 297 return _atom.DistanceSquared(AtomicPosition[0]); 256 298 } … … 258 300 VectorInterface &AtomInfo::operator=(const Vector& _vector) 259 301 { 302 ASSERT(0 < AtomicPosition.size(), 303 "AtomInfo::operator=() - Access out of range."); 260 304 AtomicPosition[0] = _vector; 261 305 return *this; … … 264 308 void AtomInfo::ScaleAll(const double *factor) 265 309 { 310 ASSERT(0 < AtomicPosition.size(), 311 "AtomInfo::ScaleAll() - Access out of range."); 266 312 AtomicPosition[0].ScaleAll(factor); 267 313 } … … 269 315 void AtomInfo::ScaleAll(const Vector &factor) 270 316 { 317 ASSERT(0 < AtomicPosition.size(), 318 "AtomInfo::ScaleAll() - Access out of range."); 271 319 AtomicPosition[0].ScaleAll(factor); 272 320 } … … 274 322 void AtomInfo::Scale(const double factor) 275 323 { 324 ASSERT(0 < AtomicPosition.size(), 325 "AtomInfo::Scale() - Access out of range."); 276 326 AtomicPosition[0].Scale(factor); 277 327 } … … 279 329 void AtomInfo::Zero() 280 330 { 331 ASSERT(0 < AtomicPosition.size(), 332 "AtomInfo::Zero() - Access out of range."); 281 333 AtomicPosition[0].Zero(); 282 334 } … … 284 336 void AtomInfo::One(const double one) 285 337 { 338 ASSERT(0 < AtomicPosition.size(), 339 "AtomInfo::One() - Access out of range."); 286 340 AtomicPosition[0].One(one); 287 341 } … … 289 343 void AtomInfo::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors) 290 344 { 345 ASSERT(0 < AtomicPosition.size(), 346 "AtomInfo::LinearCombinationOfVectors() - Access out of range."); 291 347 AtomicPosition[0].LinearCombinationOfVectors(x1,x2,x3,factors); 292 348 } … … 295 351 * returns the kinetic energy of this atom at a given time step 296 352 */ 297 double AtomInfo::getKineticEnergy(unsigned int step) const{ 298 return getMass() * AtomicVelocity[step].NormSquared(); 299 } 300 301 Vector AtomInfo::getMomentum(unsigned int step) const{ 302 return getMass()*AtomicVelocity[step]; 353 double AtomInfo::getKineticEnergy(unsigned int _step) const{ 354 ASSERT(_step < AtomicPosition.size(), 355 "AtomInfo::getKineticEnergy() - Access out of range."); 356 return getMass() * AtomicVelocity[_step].NormSquared(); 357 } 358 359 Vector AtomInfo::getMomentum(unsigned int _step) const{ 360 ASSERT(_step < AtomicPosition.size(), 361 "AtomInfo::getMomentum() - Access out of range."); 362 return getMass()*AtomicVelocity[_step]; 303 363 } 304 364 … … 354 414 void AtomInfo::VelocityVerletUpdate(int nr, int NextStep, config *configuration, ForceMatrix *Force, const size_t offset) 355 415 { 356 //a = configuration.Deltat*0.5/walker->type->mass; // (F+F_old)/2m = a and thus: v = (F+F_old)/2m * t = (F + F_old) * a 357 if ((int)AtomicPosition.size() <= NextStep) 358 ResizeTrajectory(NextStep+10); 359 for (int d=0; d<NDIM; d++) { 360 AtomicForce.at(NextStep)[d] = -Force->Matrix[0][nr][d+offset]*(configuration->GetIsAngstroem() ? AtomicLengthToAngstroem : 1.); 361 AtomicPosition.at(NextStep)[d] = AtomicPosition.at(NextStep-1)[d]; 362 AtomicPosition.at(NextStep)[d] += configuration->Deltat*(AtomicVelocity.at(NextStep-1)[d]); // s(t) = s(0) + v * deltat + 1/2 a * deltat^2 363 AtomicPosition.at(NextStep)[d] += 0.5*configuration->Deltat*configuration->Deltat*(AtomicForce.at(NextStep)[d]/getMass()); // F = m * a and s = 364 } 416 // update force 417 // (F+F_old)/2m = a and thus: v = (F+F_old)/2m * t = (F + F_old) * a 418 Vector tempVector; 419 for (int d=0; d<NDIM; d++) 420 tempVector[d] = -Force->Matrix[0][nr][d+offset]*(configuration->GetIsAngstroem() ? AtomicLengthToAngstroem : 1.); 421 setAtomicForceAtStep(NextStep, tempVector); 422 423 // update position 424 tempVector = getPositionAtStep(NextStep-1); 425 tempVector += configuration->Deltat*(getAtomicVelocityAtStep(NextStep-1)); // s(t) = s(0) + v * deltat + 1/2 a * deltat^2 426 tempVector += 0.5*configuration->Deltat*configuration->Deltat*(getAtomicForceAtStep(NextStep))*(1./getMass()); // F = m * a and s = 427 setPositionAtStep(NextStep, tempVector); 428 365 429 // Update U 366 for (int d=0; d<NDIM; d++) { 367 AtomicVelocity.at(NextStep)[d] = AtomicVelocity.at(NextStep-1)[d]; 368 AtomicVelocity.at(NextStep)[d] += configuration->Deltat * (AtomicForce.at(NextStep)[d]+AtomicForce.at(NextStep-1)[d]/getMass()); // v = F/m * t 369 } 370 // Update R (and F) 371 // out << "Integrated position&velocity of step " << (NextStep) << ": ("; 372 // for (int d=0;d<NDIM;d++) 373 // out << AtomicPosition.at(NextStep).x[d] << " "; // next step 374 // out << ")\t("; 375 // for (int d=0;d<NDIM;d++) 376 // Log() << Verbose(0) << AtomicVelocity.at(NextStep).x[d] << " "; // next step 377 // out << ")" << endl; 430 tempVector = getAtomicVelocityAtStep(NextStep-1); 431 tempVector += configuration->Deltat * (getAtomicForceAtStep(NextStep)+getAtomicForceAtStep(NextStep-1))*(1./getMass()); // v = F/m * t 432 setAtomicVelocityAtStep(NextStep, tempVector); 433 434 // some info for debugging 435 DoLog(2) && (Log() << Verbose(2) 436 << "Integrated position&velocity of step " << (NextStep) << ": (" 437 << getPositionAtStep(NextStep) << ")\t(" 438 << getAtomicVelocityAtStep(NextStep) << ")" << std::endl); 378 439 }; 379 440 -
src/atom_atominfo.hpp
r6625c3 r056e70 64 64 * @return constant reference to AtomicVelocity 65 65 */ 66 Vector& getAtomicVelocity();67 /** Getter for AtomicVelocity. 68 * 69 * @param _step time step to return 70 * @return constant reference to AtomicVelocity 71 */ 72 Vector& getAtomicVelocity(const int _step);66 // Vector& getAtomicVelocity(); 67 /** Getter for AtomicVelocity. 68 * 69 * @param _step time step to return 70 * @return constant reference to AtomicVelocity 71 */ 72 // Vector& getAtomicVelocity(const int _step); 73 73 /** Getter for AtomicVelocity. 74 74 * … … 83 83 * @return constant reference to AtomicVelocity 84 84 */ 85 const Vector& getAtomicVelocity (const int _step) const;85 const Vector& getAtomicVelocityAtStep(const int _step) const; 86 86 /** Setter for AtomicVelocity. 87 87 * … … 96 96 * @param _newvelocity new velocity to set 97 97 */ 98 void setAtomicVelocity (const int _step, const Vector &_newvelocity);98 void setAtomicVelocityAtStep(const int _step, const Vector &_newvelocity); 99 99 100 100 /** Getter for AtomicForce. … … 110 110 * @return constant reference to AtomicForce 111 111 */ 112 const Vector& getAtomicForce (const int _step) const;112 const Vector& getAtomicForceAtStep(const int _step) const; 113 113 /** Setter for AtomicForce. 114 114 * … … 123 123 * @param _newvelocity new force vector to set 124 124 */ 125 void setAtomicForce (const int _step, const Vector &_newforce);125 void setAtomicForceAtStep(const int _step, const Vector &_newforce); 126 126 127 127 /** Getter for FixedIon. … … 165 165 * @return atomic position at time step _step 166 166 */ 167 const Vector& atStep(size_t i, int _step) const;167 const double& atStep(size_t i, int _step) const; 168 168 /** Setter for AtomicPosition. 169 169 * … … 193 193 * @return atomic position at time step _step 194 194 */ 195 const Vector& getPosition (int _step) const;195 const Vector& getPositionAtStep(int _step) const; 196 196 197 197 // Assignment operator … … 208 208 * @param _vector new position to set for time step _step 209 209 */ 210 void setPosition (int _step, const Vector& _vector);210 void setPositionAtStep(int _step, const Vector& _vector); 211 211 class VectorInterface &operator=(const Vector& _vector); 212 212 -
src/config.cpp
r6625c3 r056e70 530 530 if (!status) 531 531 break; 532 neues->setFixedIon(_fixedion);533 neues->setPosition(position);534 532 535 533 // check size of vectors … … 540 538 neues->ResizeTrajectory(repetition+1); 541 539 } 540 neues->setFixedIon(_fixedion); 541 neues->setPositionAtStep(repetition,position); 542 542 543 543 // parse velocities if present … … 549 549 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &tempVector[2], 1,optional)) 550 550 tempVector[2] = 0.; 551 neues->setAtomicVelocity (repetition, tempVector);551 neues->setAtomicVelocityAtStep(repetition, tempVector); 552 552 553 553 // parse forces if present … … 559 559 if(!ParseForParameter(verbose,FileBuffer, keyword, 1, 10, 1, double_type, &tempVector[2], 1,optional)) 560 560 tempVector[2] = 0.; 561 neues->setAtomicForce (repetition, tempVector);561 neues->setAtomicForceAtStep(repetition, tempVector); 562 562 563 563 // Log() << Verbose(0) << "Parsed position of step " << (repetition) << ": ("; -
src/molecule.cpp
r6625c3 r056e70 618 618 Walker->setType(1); 619 619 } 620 if (Walker->getTrajectorySize() <= (unsigned int)MDSteps) { 621 Walker->ResizeTrajectory(MDSteps+10); 622 } 620 623 621 Walker->setPosition(Vector(x)); 624 Walker->setPosition (MDSteps-1, Vector(x));625 Walker->setAtomicVelocity (MDSteps-1, zeroVec);626 Walker->setAtomicForce (MDSteps-1, zeroVec);622 Walker->setPositionAtStep(MDSteps-1, Vector(x)); 623 Walker->setAtomicVelocityAtStep(MDSteps-1, zeroVec); 624 Walker->setAtomicForceAtStep(MDSteps-1, zeroVec); 627 625 AddAtom(Walker); // add to molecule 628 626 delete(item); -
src/molecule_dynamics.cpp
r6625c3 r056e70 60 60 // determine normalized trajectories direction vector (n1, n2) 61 61 Sprinter = Params.PermutationMap[Walker->nr]; // find first target point 62 trajectory1 = Sprinter->getPosition (Params.endstep) - Walker->getPosition(Params.startstep);62 trajectory1 = Sprinter->getPositionAtStep(Params.endstep) - Walker->getPositionAtStep(Params.startstep); 63 63 trajectory1.Normalize(); 64 64 Norm1 = trajectory1.Norm(); 65 65 Sprinter = Params.PermutationMap[(*iter)->nr]; // find second target point 66 trajectory2 = Sprinter->getPosition (Params.endstep) - (*iter)->getPosition(Params.startstep);66 trajectory2 = Sprinter->getPositionAtStep(Params.endstep) - (*iter)->getPositionAtStep(Params.startstep); 67 67 trajectory2.Normalize(); 68 68 Norm2 = trajectory1.Norm(); 69 69 // check whether either is zero() 70 70 if ((Norm1 < MYEPSILON) && (Norm2 < MYEPSILON)) { 71 tmp = Walker->getPosition (Params.startstep).distance((*iter)->getPosition(Params.startstep));71 tmp = Walker->getPositionAtStep(Params.startstep).distance((*iter)->getPositionAtStep(Params.startstep)); 72 72 } else if (Norm1 < MYEPSILON) { 73 73 Sprinter = Params.PermutationMap[Walker->nr]; // find first target point 74 trajectory1 = Sprinter->getPosition (Params.endstep) - (*iter)->getPosition(Params.startstep);74 trajectory1 = Sprinter->getPositionAtStep(Params.endstep) - (*iter)->getPositionAtStep(Params.startstep); 75 75 trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything 76 76 trajectory1 -= trajectory2; // project the part in norm direction away … … 78 78 } else if (Norm2 < MYEPSILON) { 79 79 Sprinter = Params.PermutationMap[(*iter)->nr]; // find second target point 80 trajectory2 = Sprinter->getPosition (Params.endstep) - Walker->getPosition(Params.startstep); // copy second offset80 trajectory2 = Sprinter->getPositionAtStep(Params.endstep) - Walker->getPositionAtStep(Params.startstep); // copy second offset 81 81 trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything 82 82 trajectory2 -= trajectory1; // project the part in norm direction away … … 87 87 // Log() << Verbose(0) << " and "; 88 88 // Log() << Verbose(0) << trajectory2; 89 tmp = Walker->getPosition (Params.startstep).distance((*iter)->getPosition(Params.startstep));89 tmp = Walker->getPositionAtStep(Params.startstep).distance((*iter)->getPositionAtStep(Params.startstep)); 90 90 // Log() << Verbose(0) << " with distance " << tmp << "." << endl; 91 91 } else { // determine distance by finding minimum distance … … 106 106 gsl_matrix_set(A, 1, i, trajectory2[i]); 107 107 gsl_matrix_set(A, 2, i, normal[i]); 108 gsl_vector_set(x,i, (Walker->getPosition (Params.startstep)[i] - (*iter)->getPosition(Params.startstep)[i]));108 gsl_vector_set(x,i, (Walker->getPositionAtStep(Params.startstep)[i] - (*iter)->getPositionAtStep(Params.startstep)[i])); 109 109 } 110 110 // solve the linear system by Householder transformations … … 117 117 trajectory2.Scale(gsl_vector_get(x,1)); 118 118 normal.Scale(gsl_vector_get(x,2)); 119 TestVector = (*iter)->getPosition (Params.startstep) + trajectory2 + normal120 - (Walker->getPosition (Params.startstep) + trajectory1);119 TestVector = (*iter)->getPositionAtStep(Params.startstep) + trajectory2 + normal 120 - (Walker->getPositionAtStep(Params.startstep) + trajectory1); 121 121 if (TestVector.Norm() < MYEPSILON) { 122 122 // Log() << Verbose(2) << "Test: ok.\tDistance of " << tmp << " is correct." << endl; … … 183 183 // first term: distance to target 184 184 Runner = Params.PermutationMap[(*iter)->nr]; // find target point 185 tmp = ((*iter)->getPosition (Params.startstep).distance(Runner->getPosition(Params.endstep)));185 tmp = ((*iter)->getPositionAtStep(Params.startstep).distance(Runner->getPositionAtStep(Params.endstep))); 186 186 tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem; 187 187 result += Params.PenaltyConstants[0] * tmp; … … 239 239 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 240 240 for (molecule::const_iterator runner = mol->begin(); runner != mol->end(); ++runner) { 241 Params.DistanceList[(*iter)->nr]->insert( DistancePair((*iter)->getPosition (Params.startstep).distance((*runner)->getPosition(Params.endstep)), (*runner)) );241 Params.DistanceList[(*iter)->nr]->insert( DistancePair((*iter)->getPositionAtStep(Params.startstep).distance((*runner)->getPositionAtStep(Params.endstep)), (*runner)) ); 242 242 } 243 243 } … … 489 489 // set forces 490 490 for (int i=NDIM;i++;) 491 Force->Matrix[0][_atom->nr][5+i] += 2.*constant*sqrt(_atom->getPosition (startstep).distance(Sprinter->getPosition(endstep)));491 Force->Matrix[0][_atom->nr][5+i] += 2.*constant*sqrt(_atom->getPositionAtStep(startstep).distance(Sprinter->getPositionAtStep(endstep))); 492 492 } 493 493 DoLog(1) && (Log() << Verbose(1) << "done." << endl); … … 540 540 Sprinter = mol->AddCopyAtom((*iter)); 541 541 // add to Trajectories 542 Vector temp = (*iter)->getPosition (startstep) + (PermutationMap[(*iter)->nr]->getPosition(endstep) - (*iter)->getPosition(startstep))*((double)step/(double)MaxSteps);542 Vector temp = (*iter)->getPositionAtStep(startstep) + (PermutationMap[(*iter)->nr]->getPositionAtStep(endstep) - (*iter)->getPositionAtStep(startstep))*((double)step/(double)MaxSteps); 543 543 Sprinter->setPosition(temp); 544 (*iter)->setAtomicVelocity (step, zeroVec);545 (*iter)->setAtomicForce (step, zeroVec);544 (*iter)->setAtomicVelocityAtStep(step, zeroVec); 545 (*iter)->setAtomicForceAtStep(step, zeroVec); 546 546 //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl; 547 547 } -
src/molecule_geometry.cpp
r6625c3 r056e70 317 317 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 318 318 for (size_t j=0;j<(*iter)->getTrajectorySize();j++) { 319 Vector temp = (*iter)->getPosition (j);319 Vector temp = (*iter)->getPositionAtStep(j); 320 320 temp.ScaleAll(*factor); 321 (*iter)->setPosition (j,temp);321 (*iter)->setPositionAtStep(j,temp); 322 322 } 323 323 } … … 331 331 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 332 332 for (size_t j=0;j<(*iter)->getTrajectorySize();j++) { 333 Vector temp = (*iter)->getPosition(j); 334 temp += (*trans); 335 (*iter)->setPosition(j, temp); 333 (*iter)->setPositionAtStep(j, (*iter)->getPositionAtStep(j) + (*trans)); 336 334 } 337 335 } … … 445 443 for (int j=0;j<MDSteps;j++) { 446 444 Vector temp; 447 temp[0] = cos(alpha) * (*iter)->getPosition (j)[0] + sin(alpha) * (*iter)->getPosition(j)[2];448 temp[2] = -sin(alpha) * (*iter)->getPosition (j)[0] + cos(alpha) * (*iter)->getPosition(j)[2];449 (*iter)->setPosition (j,temp);445 temp[0] = cos(alpha) * (*iter)->getPositionAtStep(j)[0] + sin(alpha) * (*iter)->getPositionAtStep(j)[2]; 446 temp[2] = -sin(alpha) * (*iter)->getPositionAtStep(j)[0] + cos(alpha) * (*iter)->getPositionAtStep(j)[2]; 447 (*iter)->setPositionAtStep(j,temp); 450 448 } 451 449 } … … 465 463 for (int j=0;j<MDSteps;j++) { 466 464 Vector temp; 467 temp[1] = cos(alpha) * (*iter)->getPosition (j)[1] + sin(alpha) * (*iter)->getPosition(j)[2];468 temp[2] = -sin(alpha) * (*iter)->getPosition (j)[1] + cos(alpha) * (*iter)->getPosition(j)[2];469 (*iter)->setPosition (j,temp);465 temp[1] = cos(alpha) * (*iter)->getPositionAtStep(j)[1] + sin(alpha) * (*iter)->getPositionAtStep(j)[2]; 466 temp[2] = -sin(alpha) * (*iter)->getPositionAtStep(j)[1] + cos(alpha) * (*iter)->getPositionAtStep(j)[2]; 467 (*iter)->setPositionAtStep(j,temp); 470 468 } 471 469 }
Note:
See TracChangeset
for help on using the changeset viewer.