Changeset 056e70 for src/atom_atominfo.cpp
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.