8 #include "NvtIntegrator.h" 9 #include <ddMd/simulation/Simulation.h> 10 #include <ddMd/storage/AtomStorage.h> 11 #include <ddMd/storage/AtomIterator.h> 12 #include <ddMd/communicate/Exchanger.h> 13 #include <ddMd/potentials/pair/PairPotential.h> 14 #include <simp/ensembles/EnergyEnsemble.h> 15 #include <util/space/Vector.h> 16 #include <util/mpi/MpiLoader.h> 17 #include <util/misc/Timer.h> 48 UTIL_THROW(
"Simulation energy ensemble is not isothermal");
63 read<double>(in,
"dt", dt_);
64 read<double>(in,
"tauT", tauT_);
79 loadParameter<double>(ar,
"dt", dt_);
80 loadParameter<double>(ar,
"tauT", tauT_);
128 double dtHalf = 0.5*dt_;
133 prefactors_[i] = dtHalf/mass;
141 if (
domain().isMaster()) {
145 xiDot_ = (T_kinetic_/T_target_ -1.0)*nuT_*nuT_;
158 double dtHalf = 0.5*dt_;
164 factor = exp(-dtHalf*(xi_ + xiDot_*dtHalf));
168 for ( ; atomIter.
notEnd(); ++atomIter) {
169 atomIter->velocity() *= factor;
170 prefactor = prefactors_[atomIter->typeId()];
171 dv.
multiply(atomIter->force(), prefactor);
172 atomIter->velocity() += dv;
173 dr.
multiply(atomIter->velocity(), dt_);
174 atomIter->position() += dr;
182 double dtHalf = 0.5*dt_;
187 factor = exp(-dtHalf*(xi_ + xiDot_*dtHalf));
191 for ( ; atomIter.
notEnd(); ++atomIter) {
192 prefactor = prefactors_[atomIter->typeId()];
193 dv.
multiply(atomIter->force(), prefactor);
194 atomIter->velocity() += dv;
195 atomIter->velocity() *=factor;
203 if (
domain().isMaster()) {
204 xi_ += xiDot_*dtHalf;
206 xiDot_ = (T_kinetic_/T_target_ - 1.0)*nuT_*nuT_;
207 xi_ += xiDot_*dtHalf;
void loadParameters(Serializable::IArchive &ar)
Load saveInterval and saveFileName from restart archive.
~NvtIntegrator()
Destructor.
Signal & velocitySignal()
Signal to indicate change in atomic velocities.
A Vector is a Cartesian vector.
void readParameters(std::istream &in)
Read required parameters.
int nAtomTotal() const
Get total number of atoms on all processors.
double kineticEnergy()
Return precomputed total kinetic energy.
Vector & multiply(const Vector &v, double s)
Multiply a vector v by a scalar s.
void readParameters(std::istream &in)
Read saveInterval and saveFileName.
void setIsSetup()
Mark the integrator as having been setup at least once.
double mass() const
Get the mass.
File containing preprocessor macros for error handling.
Parallel domain decomposition (DD) MD simulation.
Classes used by all simpatico molecular simulations.
Main object for a domain-decomposition MD simulation.
AtomType & atomType(int i)
Get an AtomType descriptor by reference.
Saving / output archive for binary ostream.
virtual void integrateStep2()
Execute secodn step of two-step integrator.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
void setupAtoms()
Setup state of atoms just before integration.
void bcast(MPI::Intracomm &comm, T &data, int root)
Broadcast a single T value.
void setup()
Setup state just before integration.
bool isIsothermal() const
Is this an Isothermal ensemble?
virtual void initDynamicalState()
Initialize internal dynamical state variables to default value.
void notify(const T &t)
Notify all observers.
bool notEnd() const
Is the current pointer not at the end of the PArray?
Utility classes for scientific computation.
void load(Data &value)
Load and broadcast a single Data value.
Domain & domain()
Get the Domain.
bool isAllocated() const
Return true if the DArray has been allocated, false otherwise.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
bool isSetup() const
Has the setup() method been called at least once previously?
AtomStorage & atomStorage()
Get the AtomStorage.
void save(Serializable::OArchive &ar)
Save saveInterval and saveFileName from restart archive.
void computeNAtomTotal(MPI::Intracomm &communicator)
Compute the total number of local atoms on all processors.
Simulation & simulation()
Get the parent simulation.
int nAtomType()
Get maximum number of atom types.
Saving archive for binary istream.
NvtIntegrator(Simulation &simulation)
Constructor.
Provides methods for MPI-aware loading of data from input archive.
A two-step velocity-Verlet style integrator.
void setClassName(const char *className)
Set class name string.
int nAtomType()
Get maximum number of atom types.
virtual void integrateStep1()
Execute first step of two-step integrator.
int capacity() const
Return allocated size.
void allocate(int capacity)
Allocate the underlying C array.
double temperature() const
Return the temperature.
void computeKineticEnergy()
Compute total kinetic energy.
Iterator for all atoms owned by an AtomStorage.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
virtual void clear()
Set integrator to initial state and clears all statistics.
void begin(AtomIterator &iterator)
Set iterator to beginning of the set of atoms.
EnergyEnsemble & energyEnsemble()
Get the EnergyEnsemble by reference.