1 #ifndef MCMD_MD_PAIR_POTENTIAL_IMPL_H 2 #define MCMD_MD_PAIR_POTENTIAL_IMPL_H 11 #include <mcMd/potentials/pair/MdPairPotential.h> 12 #include <mcMd/potentials/pair/McPairPotentialImpl.h> 13 #include <mcMd/simulation/stress.h> 14 #include <util/space/Tensor.h> 15 #include <util/misc/Setable.h> 35 template <
class Interaction>
77 virtual void readParameters(std::istream& in);
105 double energy(
double rsq,
int iAtomType,
int jAtomType)
const;
116 double forceOverR(
double rsq,
int iAtomType,
int jAtomType)
const;
121 virtual double maxPairCutoff()
const;
131 void set(std::string name,
int i,
int j,
double value)
132 { interactionPtr_->set(name, i, j, value); }
142 double get(std::string name,
int i,
int j)
const 143 {
return interactionPtr_->get(name, i, j); }
148 virtual std::string interactionClassName()
const;
162 virtual void addForces();
169 virtual void computeEnergy();
174 virtual void computeStress();
180 Interaction& interaction()
const 181 {
return *interactionPtr_; }
186 template <
typename T>
187 void computeStressImpl(T& stress);
191 Interaction* interactionPtr_;
199 #include <mcMd/simulation/System.h> 200 #include <mcMd/simulation/Simulation.h> 201 #include <mcMd/simulation/stress.h> 202 #include <mcMd/neighbor/PairIterator.h> 203 #include <simp/boundary/Boundary.h> 204 #include <util/space/Dimension.h> 205 #include <util/space/Vector.h> 206 #include <util/accumulators/setToZero.h> 213 using namespace Util;
214 using namespace Simp;
219 template <
class Interaction>
224 { interactionPtr_ =
new Interaction; }
229 template <
class Interaction>
233 interactionPtr_(&other.interaction()),
240 template <
class Interaction>
243 if (interactionPtr_ && !isCopy_) {
244 delete interactionPtr_;
249 template <
class Interaction>
254 interaction().setNAtomType(
simulation().nAtomType());
255 bool nextIndent =
false;
257 interaction().readParameters(in);
262 double cutoff = interaction().maxPairCutoff();
269 template <
class Interaction>
275 interaction().setNAtomType(
simulation().nAtomType());
276 bool nextIndent =
false;
278 interaction().loadParameters(ar);
286 template <
class Interaction>
291 interaction().save(ar);
299 template <
class Interaction>
double 301 int iAtomType,
int jAtomType)
const 302 {
return interaction().energy(rsq, iAtomType, jAtomType); }
307 template <
class Interaction>
double 309 int iAtomType,
int jAtomType)
const 311 if (rsq < interaction().cutoffSq(iAtomType, jAtomType)) {
312 return interaction().forceOverR(rsq, iAtomType, jAtomType);
321 template <
class Interaction>
323 {
return interaction().maxPairCutoff(); }
328 template <
class Interaction>
330 {
return interaction().className(); }
335 template <
class Interaction>
352 iter.
getPair(atom0Ptr, atom1Ptr);
356 type0 = atom0Ptr->
typeId();
357 type1 = atom1Ptr->
typeId();
358 if (rsq < interaction().cutoffSq(type0, type1)) {
359 force *= interaction().forceOverR(rsq, type0, type1);
360 atom0Ptr->
force() += force;
361 atom1Ptr->
force() -= force;
370 template <
class Interaction>
385 iter.
getPair(atom0Ptr, atom1Ptr);
388 energy += interaction().
399 template <
class Interaction>
400 template <
typename T>
421 iter.
getPair(atom0Ptr, atom1Ptr);
424 type0 = atom0Ptr->
typeId();
425 type1 = atom1Ptr->
typeId();
426 if (rsq < interaction().cutoffSq(type0, type1)) {
428 force *= interaction().forceOverR(rsq, type0, type1);
429 incrementPairStress(force, dr, stress);
435 normalizeStress(stress);
441 template <
class Interaction>
445 computeStressImpl(stress);
void initialize(int atomIdEnd, double potentialCutoff)
Allocate memory and initialize.
A Vector is a Cartesian vector.
virtual double forceOverR(double rsq, int iAtomType, int jAtomType) const
Return force / separation for a single pair.
virtual void addForces()
Calculate non-bonded pair forces for all atoms in this System.
virtual double maxPairCutoff() const
Return maximum cutoff.
Vector & force()
Get atomic force Vector by reference.
double volume() const
Return unit cell volume.
void set(const T &value)
Set the value and mark as set.
virtual void computeEnergy()
Calculate and store pair energy for this System.
Implementation template for an MdPairPotential.
void loadParamComposite(Serializable::IArchive &ar, ParamComposite &child, bool next=true)
Add and load a required child ParamComposite.
A set of interacting Molecules enclosed by a Boundary.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
MdPairPotentialImpl(System &system)
Constructor.
A Tensor represents a Cartesian tensor.
void getPair(Atom *&atom1Ptr, Atom *&atom2Ptr) const
Get pointers for current pair of Atoms.
Saving / output archive for binary ostream.
virtual ~MdPairPotentialImpl()
Destructor.
Implementation template for an McPairPotential.
int typeId() const
Get type index for this Atom.
Simulation & simulation() const
Get the parent Simulation by reference.
void setToZero(int &value)
Set an int variable to zero.
A point particle within a Molecule.
Utility classes for scientific computation.
virtual std::string interactionClassName() const
Return pair interaction class name (e.g., "LJPair").
Iterator for pairs in a PairList.
virtual void readParameters(std::istream &in)
Read pair potential interaction and pair list blocks.
void begin(PairIterator &iterator) const
Initialize a PairIterator.
PairList pairList_
Verlet neighbor pair list for nonbonded interactions.
An PairPotential for MD simulation.
bool isPairListCurrent()
Return true if PairList is current, false if obsolete.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
Saving archive for binary istream.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
void buildPairList()
Build the internal PairList.
void addParamComposite(ParamComposite &child, bool next=true)
Add a child ParamComposite object to the format array.
virtual void computeStress()
Compute and store the total nonbonded pressure.
Boundary & boundary() const
Get the Boundary by reference.
bool notEnd() const
Return true if not at end of PairList.
void readParamComposite(std::istream &in, ParamComposite &child, bool next=true)
Add and read a required child ParamComposite.
const Vector & position() const
Get the position Vector by const reference.
System & system() const
Get the parent System by reference.
double energy()
Return the energy contribution, compute if necessary.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.