| 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| 4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
|---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /*
|
|---|
| 9 | * atom_atominfo.cpp
|
|---|
| 10 | *
|
|---|
| 11 | * Created on: Oct 19, 2009
|
|---|
| 12 | * Author: heber
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | // include config.h
|
|---|
| 16 | #ifdef HAVE_CONFIG_H
|
|---|
| 17 | #include <config.h>
|
|---|
| 18 | #endif
|
|---|
| 19 |
|
|---|
| 20 | #include "CodePatterns/MemDebug.hpp"
|
|---|
| 21 |
|
|---|
| 22 | #include "CodePatterns/Log.hpp"
|
|---|
| 23 | #include "CodePatterns/Verbose.hpp"
|
|---|
| 24 | #include "config.hpp"
|
|---|
| 25 | #include "element.hpp"
|
|---|
| 26 | #include "parser.hpp"
|
|---|
| 27 | #include "periodentafel.hpp"
|
|---|
| 28 | #include "World.hpp"
|
|---|
| 29 | #include "atom_atominfo.hpp"
|
|---|
| 30 |
|
|---|
| 31 | /** Constructor of class AtomInfo.
|
|---|
| 32 | */
|
|---|
| 33 | AtomInfo::AtomInfo() :
|
|---|
| 34 | AtomicElement(NULL),
|
|---|
| 35 | FixedIon(false)
|
|---|
| 36 | {
|
|---|
| 37 | AtomicPosition.reserve(1);
|
|---|
| 38 | AtomicPosition.push_back(zeroVec);
|
|---|
| 39 | AtomicVelocity.reserve(1);
|
|---|
| 40 | AtomicVelocity.push_back(zeroVec);
|
|---|
| 41 | AtomicForce.reserve(1);
|
|---|
| 42 | AtomicForce.push_back(zeroVec);
|
|---|
| 43 | };
|
|---|
| 44 |
|
|---|
| 45 | /** Copy constructor of class AtomInfo.
|
|---|
| 46 | */
|
|---|
| 47 | AtomInfo::AtomInfo(const AtomInfo &_atom) :
|
|---|
| 48 | AtomicPosition(_atom.AtomicPosition),
|
|---|
| 49 | AtomicElement(_atom.AtomicElement),
|
|---|
| 50 | FixedIon(false)
|
|---|
| 51 | {
|
|---|
| 52 | AtomicVelocity.reserve(1);
|
|---|
| 53 | AtomicVelocity.push_back(zeroVec);
|
|---|
| 54 | AtomicForce.reserve(1);
|
|---|
| 55 | AtomicForce.push_back(zeroVec);
|
|---|
| 56 | };
|
|---|
| 57 |
|
|---|
| 58 | AtomInfo::AtomInfo(const VectorInterface &_v) :
|
|---|
| 59 | AtomicElement(NULL),
|
|---|
| 60 | FixedIon(false)
|
|---|
| 61 | {
|
|---|
| 62 | AtomicPosition[0] = _v.getPosition();
|
|---|
| 63 | AtomicVelocity.reserve(1);
|
|---|
| 64 | AtomicVelocity.push_back(zeroVec);
|
|---|
| 65 | AtomicForce.reserve(1);
|
|---|
| 66 | AtomicForce.push_back(zeroVec);
|
|---|
| 67 | };
|
|---|
| 68 |
|
|---|
| 69 | /** Destructor of class AtomInfo.
|
|---|
| 70 | */
|
|---|
| 71 | AtomInfo::~AtomInfo()
|
|---|
| 72 | {
|
|---|
| 73 | };
|
|---|
| 74 |
|
|---|
| 75 | const element *AtomInfo::getType() const
|
|---|
| 76 | {
|
|---|
| 77 | return AtomicElement;
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | const double& AtomInfo::operator[](size_t i) const
|
|---|
| 81 | {
|
|---|
| 82 | ASSERT(AtomicPosition.size() > 0,
|
|---|
| 83 | "AtomInfo::operator[]() - Access out of range.");
|
|---|
| 84 | return AtomicPosition[0][i];
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | const double& AtomInfo::at(size_t i) const
|
|---|
| 88 | {
|
|---|
| 89 | ASSERT(AtomicPosition.size() > 0,
|
|---|
| 90 | "AtomInfo::at() - Access out of range.");
|
|---|
| 91 | return AtomicPosition[0].at(i);
|
|---|
| 92 | }
|
|---|
| 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 |
|
|---|
| 101 | void AtomInfo::set(size_t i, const double value)
|
|---|
| 102 | {
|
|---|
| 103 | ASSERT(AtomicPosition.size() > 0,
|
|---|
| 104 | "AtomInfo::set() - Access out of range.");
|
|---|
| 105 | AtomicPosition[0].at(i) = value;
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | const Vector& AtomInfo::getPosition() const
|
|---|
| 109 | {
|
|---|
| 110 | ASSERT(AtomicPosition.size() > 0,
|
|---|
| 111 | "AtomInfo::getPosition() - Access out of range.");
|
|---|
| 112 | return AtomicPosition[0];
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | const Vector& AtomInfo::getPositionAtStep(const int _step) const
|
|---|
| 116 | {
|
|---|
| 117 | ASSERT(_step < AtomicPosition.size(),
|
|---|
| 118 | "AtomInfo::getPositionAtStep() - Access out of range.");
|
|---|
| 119 | return AtomicPosition[_step];
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | void AtomInfo::setType(const element* _type) {
|
|---|
| 123 | AtomicElement = _type;
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | void AtomInfo::setType(const int Z) {
|
|---|
| 127 | const element *elem = World::getInstance().getPeriode()->FindElement(Z);
|
|---|
| 128 | setType(elem);
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 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.");
|
|---|
| 147 | return AtomicVelocity[0];
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | const Vector& AtomInfo::getAtomicVelocityAtStep(const int _step) const
|
|---|
| 151 | {
|
|---|
| 152 | ASSERT(_step < AtomicVelocity.size(),
|
|---|
| 153 | "AtomInfo::getAtomicVelocity() - Access out of range.");
|
|---|
| 154 | return AtomicVelocity[_step];
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | void AtomInfo::setAtomicVelocity(const Vector &_newvelocity)
|
|---|
| 158 | {
|
|---|
| 159 | ASSERT(0 < AtomicVelocity.size(),
|
|---|
| 160 | "AtomInfo::setAtomicVelocity() - Access out of range.");
|
|---|
| 161 | AtomicVelocity[0] = _newvelocity;
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | void AtomInfo::setAtomicVelocityAtStep(const int _step, const Vector &_newvelocity)
|
|---|
| 165 | {
|
|---|
| 166 | ASSERT(_step <= AtomicVelocity.size(),
|
|---|
| 167 | "AtomInfo::setAtomicVelocityAtStep() - Access out of range.");
|
|---|
| 168 | if(_step < (int)AtomicVelocity.size()) {
|
|---|
| 169 | AtomicVelocity[_step] = _newvelocity;
|
|---|
| 170 | } else if (_step == (int)AtomicVelocity.size()) {
|
|---|
| 171 | AtomicVelocity.push_back(_newvelocity);
|
|---|
| 172 | }
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | const Vector& AtomInfo::getAtomicForce() const
|
|---|
| 176 | {
|
|---|
| 177 | ASSERT(0 < AtomicForce.size(),
|
|---|
| 178 | "AtomInfo::getAtomicForce() - Access out of range.");
|
|---|
| 179 | return AtomicForce[0];
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | const Vector& AtomInfo::getAtomicForceAtStep(const int _step) const
|
|---|
| 183 | {
|
|---|
| 184 | ASSERT(_step < AtomicForce.size(),
|
|---|
| 185 | "AtomInfo::getAtomicForce() - Access out of range.");
|
|---|
| 186 | return AtomicForce[_step];
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | void AtomInfo::setAtomicForce(const Vector &_newforce)
|
|---|
| 190 | {
|
|---|
| 191 | ASSERT(0 < AtomicForce.size(),
|
|---|
| 192 | "AtomInfo::setAtomicForce() - Access out of range.");
|
|---|
| 193 | AtomicForce[0] = _newforce;
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | void AtomInfo::setAtomicForceAtStep(const int _step, const Vector &_newforce)
|
|---|
| 197 | {
|
|---|
| 198 | const int size = AtomicForce.size();
|
|---|
| 199 | ASSERT(_step <= size,
|
|---|
| 200 | "AtomInfo::setAtomicForce() - Access out of range.");
|
|---|
| 201 | if(_step < size) {
|
|---|
| 202 | AtomicForce[_step] = _newforce;
|
|---|
| 203 | } else if (_step == size) {
|
|---|
| 204 | AtomicForce.push_back(_newforce);
|
|---|
| 205 | }
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | bool AtomInfo::getFixedIon() const
|
|---|
| 209 | {
|
|---|
| 210 | return FixedIon;
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | void AtomInfo::setFixedIon(const bool _fixedion)
|
|---|
| 214 | {
|
|---|
| 215 | FixedIon = _fixedion;
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | void AtomInfo::setPosition(const Vector& _vector)
|
|---|
| 219 | {
|
|---|
| 220 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 221 | "AtomInfo::setPosition() - Access out of range.");
|
|---|
| 222 | AtomicPosition[0] = _vector;
|
|---|
| 223 | //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl;
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | void AtomInfo::setPositionAtStep(int _step, const Vector& _vector)
|
|---|
| 227 | {
|
|---|
| 228 | ASSERT(_step <= AtomicPosition.size(),
|
|---|
| 229 | "AtomInfo::setPosition() - Access out of range.");
|
|---|
| 230 | if(_step < (int)AtomicPosition.size()) {
|
|---|
| 231 | AtomicPosition[_step] = _vector;
|
|---|
| 232 | } else if (_step == (int)AtomicPosition.size()) {
|
|---|
| 233 | AtomicPosition.push_back(_vector);
|
|---|
| 234 | }
|
|---|
| 235 | //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl;
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | const VectorInterface& AtomInfo::operator+=(const Vector& b)
|
|---|
| 239 | {
|
|---|
| 240 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 241 | "AtomInfo::operator+=() - Access out of range.");
|
|---|
| 242 | AtomicPosition[0] += b;
|
|---|
| 243 | return *this;
|
|---|
| 244 | }
|
|---|
| 245 |
|
|---|
| 246 | const VectorInterface& AtomInfo::operator-=(const Vector& b)
|
|---|
| 247 | {
|
|---|
| 248 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 249 | "AtomInfo::operator-=() - Access out of range.");
|
|---|
| 250 | AtomicPosition[0] -= b;
|
|---|
| 251 | return *this;
|
|---|
| 252 | }
|
|---|
| 253 |
|
|---|
| 254 | Vector const AtomInfo::operator+(const Vector& b) const
|
|---|
| 255 | {
|
|---|
| 256 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 257 | "AtomInfo::operator+() - Access out of range.");
|
|---|
| 258 | Vector a(AtomicPosition[0]);
|
|---|
| 259 | a += b;
|
|---|
| 260 | return a;
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | Vector const AtomInfo::operator-(const Vector& b) const
|
|---|
| 264 | {
|
|---|
| 265 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 266 | "AtomInfo::operator-() - Access out of range.");
|
|---|
| 267 | Vector a(AtomicPosition[0]);
|
|---|
| 268 | a -= b;
|
|---|
| 269 | return a;
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 | double AtomInfo::distance(const Vector &point) const
|
|---|
| 273 | {
|
|---|
| 274 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 275 | "AtomInfo::distance() - Access out of range.");
|
|---|
| 276 | return AtomicPosition[0].distance(point);
|
|---|
| 277 | }
|
|---|
| 278 |
|
|---|
| 279 | double AtomInfo::DistanceSquared(const Vector &y) const
|
|---|
| 280 | {
|
|---|
| 281 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 282 | "AtomInfo::DistanceSquared() - Access out of range.");
|
|---|
| 283 | return AtomicPosition[0].DistanceSquared(y);
|
|---|
| 284 | }
|
|---|
| 285 |
|
|---|
| 286 | double AtomInfo::distance(const VectorInterface &_atom) const
|
|---|
| 287 | {
|
|---|
| 288 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 289 | "AtomInfo::distance() - Access out of range.");
|
|---|
| 290 | return _atom.distance(AtomicPosition[0]);
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 | double AtomInfo::DistanceSquared(const VectorInterface &_atom) const
|
|---|
| 294 | {
|
|---|
| 295 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 296 | "AtomInfo::DistanceSquared() - Access out of range.");
|
|---|
| 297 | return _atom.DistanceSquared(AtomicPosition[0]);
|
|---|
| 298 | }
|
|---|
| 299 |
|
|---|
| 300 | VectorInterface &AtomInfo::operator=(const Vector& _vector)
|
|---|
| 301 | {
|
|---|
| 302 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 303 | "AtomInfo::operator=() - Access out of range.");
|
|---|
| 304 | AtomicPosition[0] = _vector;
|
|---|
| 305 | return *this;
|
|---|
| 306 | }
|
|---|
| 307 |
|
|---|
| 308 | void AtomInfo::ScaleAll(const double *factor)
|
|---|
| 309 | {
|
|---|
| 310 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 311 | "AtomInfo::ScaleAll() - Access out of range.");
|
|---|
| 312 | AtomicPosition[0].ScaleAll(factor);
|
|---|
| 313 | }
|
|---|
| 314 |
|
|---|
| 315 | void AtomInfo::ScaleAll(const Vector &factor)
|
|---|
| 316 | {
|
|---|
| 317 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 318 | "AtomInfo::ScaleAll() - Access out of range.");
|
|---|
| 319 | AtomicPosition[0].ScaleAll(factor);
|
|---|
| 320 | }
|
|---|
| 321 |
|
|---|
| 322 | void AtomInfo::Scale(const double factor)
|
|---|
| 323 | {
|
|---|
| 324 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 325 | "AtomInfo::Scale() - Access out of range.");
|
|---|
| 326 | AtomicPosition[0].Scale(factor);
|
|---|
| 327 | }
|
|---|
| 328 |
|
|---|
| 329 | void AtomInfo::Zero()
|
|---|
| 330 | {
|
|---|
| 331 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 332 | "AtomInfo::Zero() - Access out of range.");
|
|---|
| 333 | AtomicPosition[0].Zero();
|
|---|
| 334 | }
|
|---|
| 335 |
|
|---|
| 336 | void AtomInfo::One(const double one)
|
|---|
| 337 | {
|
|---|
| 338 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 339 | "AtomInfo::One() - Access out of range.");
|
|---|
| 340 | AtomicPosition[0].One(one);
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 | void AtomInfo::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors)
|
|---|
| 344 | {
|
|---|
| 345 | ASSERT(0 < AtomicPosition.size(),
|
|---|
| 346 | "AtomInfo::LinearCombinationOfVectors() - Access out of range.");
|
|---|
| 347 | AtomicPosition[0].LinearCombinationOfVectors(x1,x2,x3,factors);
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 | /**
|
|---|
| 351 | * returns the kinetic energy of this atom at a given time step
|
|---|
| 352 | */
|
|---|
| 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];
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | /** Extends the trajectory STL vector to the new size.
|
|---|
| 366 | * Does nothing if \a MaxSteps is smaller than current size.
|
|---|
| 367 | * \param MaxSteps
|
|---|
| 368 | */
|
|---|
| 369 | void AtomInfo::ResizeTrajectory(size_t MaxSteps)
|
|---|
| 370 | {
|
|---|
| 371 | if (AtomicPosition.size() <= (unsigned int)(MaxSteps)) {
|
|---|
| 372 | DoLog(0) && (Log() << Verbose(0) << "Increasing size for trajectory array from " << AtomicPosition.size() << " to " << (MaxSteps+1) << "." << endl);
|
|---|
| 373 | AtomicPosition.resize(MaxSteps+1, zeroVec);
|
|---|
| 374 | AtomicVelocity.resize(MaxSteps+1, zeroVec);
|
|---|
| 375 | AtomicForce.resize(MaxSteps+1, zeroVec);
|
|---|
| 376 | }
|
|---|
| 377 | };
|
|---|
| 378 |
|
|---|
| 379 | size_t AtomInfo::getTrajectorySize() const
|
|---|
| 380 | {
|
|---|
| 381 | return AtomicPosition.size();
|
|---|
| 382 | }
|
|---|
| 383 |
|
|---|
| 384 | double AtomInfo::getMass() const{
|
|---|
| 385 | return AtomicElement->getMass();
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 | /** Copies a given trajectory step \a src onto another \a dest
|
|---|
| 389 | * \param dest index of destination step
|
|---|
| 390 | * \param src index of source step
|
|---|
| 391 | */
|
|---|
| 392 | void AtomInfo::CopyStepOnStep(int dest, int src)
|
|---|
| 393 | {
|
|---|
| 394 | if (dest == src) // self assignment check
|
|---|
| 395 | return;
|
|---|
| 396 |
|
|---|
| 397 | ASSERT(dest < AtomicPosition.size(),
|
|---|
| 398 | "AtomInfo::CopyStepOnStep() - destination outside of current trajectory array.");
|
|---|
| 399 | ASSERT(src < AtomicPosition.size(),
|
|---|
| 400 | "AtomInfo::CopyStepOnStep() - source outside of current trajectory array.");
|
|---|
| 401 | for (int n=NDIM;n--;) {
|
|---|
| 402 | AtomicPosition.at(dest)[n] = AtomicPosition.at(src)[n];
|
|---|
| 403 | AtomicVelocity.at(dest)[n] = AtomicVelocity.at(src)[n];
|
|---|
| 404 | AtomicForce.at(dest)[n] = AtomicForce.at(src)[n];
|
|---|
| 405 | }
|
|---|
| 406 | };
|
|---|
| 407 |
|
|---|
| 408 | /** Performs a velocity verlet update of the trajectory.
|
|---|
| 409 | * Parameters are according to those in configuration class.
|
|---|
| 410 | * \param NextStep index of sequential step to set
|
|---|
| 411 | * \param *configuration pointer to configuration with parameters
|
|---|
| 412 | * \param *Force matrix with forces
|
|---|
| 413 | */
|
|---|
| 414 | void AtomInfo::VelocityVerletUpdate(int nr, int NextStep, config *configuration, ForceMatrix *Force, const size_t offset)
|
|---|
| 415 | {
|
|---|
| 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 |
|
|---|
| 429 | // Update U
|
|---|
| 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);
|
|---|
| 439 | };
|
|---|
| 440 |
|
|---|
| 441 | const AtomInfo& operator*=(AtomInfo& a, const double m)
|
|---|
| 442 | {
|
|---|
| 443 | a.Scale(m);
|
|---|
| 444 | return a;
|
|---|
| 445 | }
|
|---|
| 446 |
|
|---|
| 447 | AtomInfo const operator*(const AtomInfo& a, const double m)
|
|---|
| 448 | {
|
|---|
| 449 | AtomInfo copy(a);
|
|---|
| 450 | copy *= m;
|
|---|
| 451 | return copy;
|
|---|
| 452 | }
|
|---|
| 453 |
|
|---|
| 454 | AtomInfo const operator*(const double m, const AtomInfo& a)
|
|---|
| 455 | {
|
|---|
| 456 | AtomInfo copy(a);
|
|---|
| 457 | copy *= m;
|
|---|
| 458 | return copy;
|
|---|
| 459 | }
|
|---|
| 460 |
|
|---|
| 461 | std::ostream & AtomInfo::operator << (std::ostream &ost) const
|
|---|
| 462 | {
|
|---|
| 463 | return (ost << getPosition());
|
|---|
| 464 | }
|
|---|
| 465 |
|
|---|
| 466 | std::ostream & operator << (std::ostream &ost, const AtomInfo &a)
|
|---|
| 467 | {
|
|---|
| 468 | ost << a;
|
|---|
| 469 | return ost;
|
|---|
| 470 | }
|
|---|
| 471 |
|
|---|