8 #include "NvtLangevinIntegrator.h" 9 #include <mcMd/mdSimulation/MdSystem.h> 10 #include <mcMd/simulation/Simulation.h> 11 #include <mcMd/potentials/pair/MdPairPotential.h> 12 #include <simp/boundary/Boundary.h> 13 #include <simp/ensembles/EnergyEnsemble.h> 14 #include <mcMd/chemistry/Molecule.h> 15 #include <mcMd/chemistry/Atom.h> 16 #include <util/space/Vector.h> 17 #include <util/archives/Serializable_includes.h> 48 read<double>(in,
"dt",
dt_);
49 read<double>(in,
"gamma", gamma_);
61 loadParameter<double>(ar,
"dt",
dt_);
88 UTIL_THROW(
"Energy ensemble is not isothermal");
90 double cv = (exp(-
dt_*gamma_) - 1.0)/
dt_;
92 double d = 2.0/(1.0 + exp(-
dt_*gamma_));
93 double cr = 12.0*temp*d*(1.0 - exp(-2.0*
dt_*gamma_))/(
dt_*
dt_);
97 int nAtomType = prefactors_.
capacity();
98 for (
int i = 0; i < nAtomType; ++i) {
100 prefactors_[i] = 0.5*dt_/mass;
102 cr_[i] = sqrt(mass*cr);
131 int iSpecies, nSpecies, typeId;
138 for (iSpecies=0; iSpecies < nSpecies; ++iSpecies) {
140 for ( ; molIter.
notEnd(); ++molIter) {
141 molIter->begin(atomIter);
142 for ( ; atomIter.
notEnd(); ++atomIter) {
143 typeId = atomIter->typeId();
146 dv.
multiply(atomIter->force(), prefactors_[typeId]);
147 atomIter->velocity() += dv;
151 atomIter->position() += dr;
158 for (iSpecies=0; iSpecies < nSpecies; ++iSpecies) {
160 for ( ; molIter.
notEnd(); ++molIter) {
161 for (ia=0; ia < molIter->nAtom(); ++ia) {
162 atomPtr = &molIter->atom(ia);
163 typeId = atomPtr->
typeId();
180 if (!
system().pairPotential().isPairListCurrent()) {
192 for (iSpecies=0; iSpecies < nSpecies; ++iSpecies) {
194 for ( ; molIter.
notEnd(); ++molIter) {
195 molIter->begin(atomIter);
196 for ( ; atomIter.
notEnd(); ++atomIter) {
197 typeId = atomIter->typeId();
200 df.
multiply(atomIter->velocity(), cv_[typeId]);
203 df[j] += (random.
uniform() - 0.5)*cr;
205 atomIter->force() += df;
208 dv.
multiply(atomIter->force(), prefactors_[typeId]);
209 atomIter->velocity() += dv;
214 for (iSpecies=0; iSpecies < nSpecies; ++iSpecies) {
216 for ( ; molIter.
notEnd(); ++molIter) {
217 for (ia=0; ia < molIter->nAtom(); ++ia) {
218 atomPtr = &molIter->atom(ia);
219 typeId = atomPtr->
typeId();
225 df[j] += (random.
uniform() - 0.5)*cr;
227 atomPtr->
force() += df;
virtual void save(Serializable::OArchive &ar)
Save the internal state to an archive.
const int Dimension
Dimensionality of space.
virtual void setup()
Setup private variables before main loop.
A Vector is a Cartesian vector.
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.
Vector & velocity()
Get atomic velocity Vector by reference.
bool notEnd() const
Is the current pointer not at the end of the array?
Signal & positionSignal()
Signal to indicate change in atomic positions.
Vector & force()
Get atomic force Vector by reference.
Vector & multiply(const Vector &v, double s)
Multiply a vector v by a scalar s.
EnergyEnsemble & energyEnsemble() const
Get the EnergyEnsemble by reference.
virtual void loadParameters(Serializable::IArchive &ar)
Load the internal state to an archive.
Classes used by all simpatico molecular simulations.
Simulation & simulation()
Get parent Simulation by reference.
virtual ~NvtLangevinIntegrator()
Destructor.
double uniform()
Return a random floating point number x, uniformly distributed in the range 0 <= x < 1...
Abstract base for molecular dynamics integrators.
virtual void step()
Take a complete NVE MD integration step.
Saving / output archive for binary ostream.
MdPairPotential & pairPotential() const
Return MdPairPotential by reference.
NvtLangevinIntegrator(MdSystem &system)
Constructor.
A statistical ensemble for energy.
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.
int typeId() const
Get type index for this Atom.
bool isIsothermal() const
Is this an Isothermal ensemble?
MdSystem & system()
Get parent MdSystem by reference.
void notify(const T &t)
Notify all observers.
A point particle within a Molecule.
bool notEnd() const
Is the current pointer not at the end of the PArray?
Utility classes for scientific computation.
Forward iterator for an Array or a C array.
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.
int capacity() const
Return allocated size.
void allocate(int capacity)
Allocate the underlying C array.
double temperature() const
Return the temperature.
const Vector & position() const
Get the position Vector by const reference.
int nAtomType() const
Get the number of atom types.
Random & random()
Get the random number generator by reference.
virtual void readParameters(std::istream &in)
Read parameters from file and initialize this MdSystem.