8 #include "NvtNhIntegrator.h" 9 #include <mcMd/mdSimulation/MdSystem.h> 10 #include <mcMd/simulation/Simulation.h> 11 #include <mcMd/potentials/pair/MdPairPotential.h> 12 #include <mcMd/chemistry/Molecule.h> 13 #include <mcMd/chemistry/Atom.h> 14 #include <simp/ensembles/EnergyEnsemble.h> 15 #include <simp/boundary/Boundary.h> 16 #include <util/space/Vector.h> 17 #include <util/archives/Serializable_includes.h> 43 UTIL_THROW(
"System energy ensemble is not isothermal");
48 T_kinetic_ = T_target_;
64 read<double>(in,
"dt",
dt_);
65 read<double>(in,
"tauT", tauT_);
68 T_kinetic_ = T_target_;
84 loadParameter<double>(ar,
"dt",
dt_);
85 loadParameter<double>(ar,
"tauT", tauT_);
117 xiDot_ = (T_kinetic_/T_target_ -1.0)*nuT_*nuT_;
121 for (
int i = 0; i < nAtomType; ++i) {
123 prefactors_[i] = dtHalf/mass;
141 double dtHalf = 0.5*
dt_;
145 int iSpecies, nSpecies;
152 factor = exp(-dtHalf*(xi_ + xiDot_*dtHalf));
155 for (iSpecies = 0; iSpecies < nSpecies; ++iSpecies) {
157 for ( ; molIter.
notEnd(); ++molIter) {
159 molIter->begin(atomIter);
160 for ( ; atomIter.
notEnd(); ++atomIter) {
162 atomIter->velocity() *= factor;
164 prefactor = prefactors_[atomIter->typeId()];
165 dv.
multiply(atomIter->force(), prefactor);
168 atomIter->velocity() += dv;
171 atomIter->position() += dr;
181 xi_ += xiDot_*dtHalf;
185 if (!
system().pairPotential().isPairListCurrent()) {
193 for (iSpecies=0; iSpecies < nSpecies; ++iSpecies) {
195 for ( ; molIter.
notEnd(); ++molIter) {
196 for (molIter->begin(atomIter); atomIter.
notEnd(); ++atomIter) {
197 prefactor = prefactors_[atomIter->typeId()];
198 dv.
multiply(atomIter->force(), prefactor);
199 atomIter->velocity() += dv;
200 atomIter->velocity() *=factor;
208 xiDot_ = (T_kinetic_/T_target_ -1.0)*nuT_*nuT_;
209 xi_ += xiDot_*dtHalf;
A Vector is a Cartesian vector.
virtual ~NvtNhIntegrator()
Destructor.
void calculateForces()
Compute all forces in this System.
void begin(int speciesId, MoleculeIterator &iterator)
Initialize an iterator for molecules of one species in this System.
int nAtom() const
Return the total number of atoms in this System.
NvtNhIntegrator(MdSystem &system)
Constructor.
bool notEnd() const
Is the current pointer not at the end of the array?
Signal & positionSignal()
Signal to indicate change in atomic positions.
Vector & multiply(const Vector &v, double s)
Multiply a vector v by a scalar s.
virtual void save(Serializable::OArchive &ar)
Save the internal state to an archive.
EnergyEnsemble & energyEnsemble() const
Get the EnergyEnsemble by reference.
Classes used by all simpatico molecular simulations.
Simulation & simulation()
Get parent Simulation by reference.
Abstract base for molecular dynamics integrators.
Saving / output archive for binary ostream.
MdPairPotential & pairPotential() const
Return MdPairPotential by reference.
const AtomType & atomType(int i) const
Get a single AtomType object by const reference.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
bool isIsothermal() const
Is this an Isothermal ensemble?
MdSystem & system()
Get parent MdSystem by reference.
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.
bool isAllocated() const
Return true if the DArray has been allocated, false otherwise.
Forward iterator for an Array or a C array.
double kineticEnergy() const
Compute and return total kinetic energy.
Forward iterator for a PArray.
double dt_
Integrator time step.
Signal & velocitySignal()
Signal to indicate change in atomic velocities.
Saving archive for binary istream.
double mass() const
Get the mass.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
int nSpecies() const
Get the number of Species in this Simulation.
void buildPairList()
Build the internal PairList.
void setClassName(const char *className)
Set class name string.
A System for Molecular Dynamics simulation.
void allocate(int capacity)
Allocate the underlying C array.
virtual void setup()
Setup auxiliary parameters of integrator, just before main loop.
double temperature() const
Return the temperature.
int nAtomType() const
Get the number of atom types.
virtual void readParameters(std::istream &in)
Read parameters from file and initialize.
virtual void step()
Take a complete NVT MD integration step.
virtual void loadParameters(Serializable::IArchive &ar)
Load the internal state to an archive.