[435065] | 1 | /*
|
---|
| 2 | * VerletForceIntegration.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Feb 23, 2011
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef VERLETFORCEINTEGRATION_HPP_
|
---|
| 9 | #define VERLETFORCEINTEGRATION_HPP_
|
---|
| 10 |
|
---|
| 11 | // include config.h
|
---|
| 12 | #ifdef HAVE_CONFIG_H
|
---|
| 13 | #include <config.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
[6f0841] | 16 | #include "Atom/atom.hpp"
|
---|
| 17 | #include "Atom/AtomSet.hpp"
|
---|
[435065] | 18 | #include "CodePatterns/Assert.hpp"
|
---|
| 19 | #include "CodePatterns/Info.hpp"
|
---|
| 20 | #include "CodePatterns/Log.hpp"
|
---|
| 21 | #include "CodePatterns/Verbose.hpp"
|
---|
[51cdfd] | 22 | #include "Dynamics/AtomicForceManipulator.hpp"
|
---|
[a9b86d] | 23 | #include "Fragmentation/ForceMatrix.hpp"
|
---|
[255829] | 24 | #include "Helpers/helpers.hpp"
|
---|
[4882d5] | 25 | #include "Helpers/defs.hpp"
|
---|
[435065] | 26 | #include "LinearAlgebra/Vector.hpp"
|
---|
[ab26c3] | 27 | #include "Thermostats/ThermoStatContainer.hpp"
|
---|
[4882d5] | 28 | #include "Thermostats/Thermostat.hpp"
|
---|
[435065] | 29 | #include "World.hpp"
|
---|
| 30 |
|
---|
| 31 | template <class T>
|
---|
[51cdfd] | 32 | class VerletForceIntegration : public AtomicForceManipulator<T>
|
---|
[435065] | 33 | {
|
---|
| 34 | public:
|
---|
[4882d5] | 35 | /** Constructor of class VerletForceIntegration.
|
---|
| 36 | *
|
---|
| 37 | * \param _atoms set of atoms to integrate
|
---|
| 38 | * \param _Deltat time step width in atomic units
|
---|
| 39 | * \param _IsAngstroem whether length units are in angstroem or bohr radii
|
---|
| 40 | */
|
---|
| 41 | VerletForceIntegration(AtomSetMixin<T> &_atoms, double _Deltat, bool _IsAngstroem) :
|
---|
[51cdfd] | 42 | AtomicForceManipulator<T>(_atoms, _Deltat, _IsAngstroem)
|
---|
[435065] | 43 | {}
|
---|
[4882d5] | 44 | /** Destructor of class VerletForceIntegration.
|
---|
| 45 | *
|
---|
| 46 | */
|
---|
[435065] | 47 | ~VerletForceIntegration()
|
---|
| 48 | {}
|
---|
| 49 |
|
---|
[4882d5] | 50 | /** Performs Verlet integration.
|
---|
[bcb593] | 51 | *
|
---|
| 52 | * We assume that forces have just been calculated. Then, we perform the velocity
|
---|
| 53 | * and the position calculation for \f$ t + \Delta t \f$, such that forces may be
|
---|
| 54 | * again calculated with respect to the new position.
|
---|
| 55 | *
|
---|
[4882d5] | 56 | * \param NextStep current time step (i.e. \f$ t + \Delta t \f$ in the sense of the velocity verlet)
|
---|
| 57 | * \param offset offset in matrix file to the first force component
|
---|
| 58 | * \param DoConstrainedMD whether a constrained MD shall be done
|
---|
| 59 | * \param FixedCenterOfMass whether forces and velocities are correct to have fixed center of mass
|
---|
| 60 | * \todo This is not yet checked if it is correctly working with DoConstrainedMD set >0.
|
---|
| 61 | */
|
---|
[1e45f1f] | 62 | void operator()(const int NextStep, const size_t offset, const int DoConstrainedMD, const bool FixedCenterOfMass)
|
---|
[4882d5] | 63 | {
|
---|
| 64 | Info FunctionInfo(__func__);
|
---|
| 65 |
|
---|
| 66 | // make sum of forces equal zero
|
---|
| 67 | if (FixedCenterOfMass)
|
---|
[51cdfd] | 68 | AtomicForceManipulator<T>::correctForceMatrixForFixedCenterOfMass(offset,NextStep-1);
|
---|
[4882d5] | 69 |
|
---|
[435065] | 70 | // solve a constrained potential if we are meant to
|
---|
[51cdfd] | 71 | // if (DoConstrainedMD)
|
---|
| 72 | // performConstraintMinimization(DoConstrainedMD,NextStep-1);
|
---|
[bcb593] | 73 |
|
---|
| 74 | if (NextStep > 0) {
|
---|
[51cdfd] | 75 | for(typename AtomSetMixin<T>::iterator iter = AtomicForceManipulator<T>::atoms.begin();
|
---|
| 76 | iter != AtomicForceManipulator<T>::atoms.end(); ++iter) {
|
---|
[bcb593] | 77 | //std::cout << "Id of atom is " << (*iter)->getId() << std::endl;
|
---|
[51cdfd] | 78 | (*iter)->VelocityVerletUpdateU(
|
---|
| 79 | (*iter)->getId(),
|
---|
| 80 | NextStep-1,
|
---|
| 81 | AtomicForceManipulator<T>::Deltat,
|
---|
| 82 | AtomicForceManipulator<T>::IsAngstroem);
|
---|
[bcb593] | 83 | }
|
---|
| 84 |
|
---|
| 85 | // make sum of velocities equal zero
|
---|
| 86 | if (FixedCenterOfMass)
|
---|
[51cdfd] | 87 | AtomicForceManipulator<T>::correctVelocitiesForFixedCenterOfMass(NextStep-1);
|
---|
[bcb593] | 88 |
|
---|
| 89 | // thermostat
|
---|
[51cdfd] | 90 | AtomicForceManipulator<T>::performThermostatControl(NextStep-1);
|
---|
[435065] | 91 | }
|
---|
| 92 |
|
---|
| 93 | //std::cout << "Force before velocity verlet, " << Force << std::endl;
|
---|
| 94 | // and perform Verlet integration for each atom with position, velocity and force vector
|
---|
| 95 | // check size of vectors
|
---|
[51cdfd] | 96 | for(typename AtomSetMixin<T>::iterator iter = AtomicForceManipulator<T>::atoms.begin();
|
---|
| 97 | iter != AtomicForceManipulator<T>::atoms.end(); ++iter) {
|
---|
[435065] | 98 | //std::cout << "Id of atom is " << (*iter)->getId() << std::endl;
|
---|
[51cdfd] | 99 | (*iter)->VelocityVerletUpdateX(
|
---|
| 100 | (*iter)->getId(),
|
---|
| 101 | NextStep,
|
---|
| 102 | AtomicForceManipulator<T>::Deltat,
|
---|
| 103 | AtomicForceManipulator<T>::IsAngstroem);
|
---|
[435065] | 104 | }
|
---|
[4882d5] | 105 | }
|
---|
[435065] | 106 | };
|
---|
| 107 |
|
---|
| 108 | #endif /* VERLETFORCEINTEGRATION_HPP_ */
|
---|