1 #ifndef MCMD_MC_PAIR_INTERACTION_IMPL_H 2 #define MCMD_MC_PAIR_INTERACTION_IMPL_H 11 #include <mcMd/potentials/pair/McPairPotential.h> 32 template <
class Interaction>
56 virtual void readParameters(std::istream& in);
78 virtual double energy(
double rsq,
int iAtomType,
int jAtomType)
const;
83 virtual double forceOverR(
double rsq,
int iAtomType,
int jAtomType)
const;
88 virtual double maxPairCutoff()
const;
98 void set(std::string name,
int i,
int j,
double value)
99 { interaction_.set(name, i, j, value); }
108 double get(std::string name,
int i,
int j)
const 109 {
return interaction_.get(name, i, j); }
114 virtual std::string interactionClassName()
const;
119 Interaction& interaction();
124 const Interaction& interaction()
const;
136 double atomEnergy(
const Atom& atom)
const;
144 double moleculeEnergy(
const Molecule& molecule)
const;
151 virtual void computeEnergy();
158 virtual void computeStress();
167 Interaction interaction_;
177 template <
typename T>
178 void computeStressImpl(T& stress);
184 #include <mcMd/simulation/System.h> 185 #include <mcMd/simulation/Simulation.h> 186 #include <mcMd/simulation/stress.h> 187 #include <mcMd/neighbor/PairIterator.h> 188 #include <simp/boundary/Boundary.h> 190 #include <util/space/Dimension.h> 191 #include <util/space/Vector.h> 192 #include <util/space/Tensor.h> 193 #include <util/accumulators/setToZero.h> 200 using namespace Util;
201 using namespace Simp;
206 template <
class Interaction>
214 template <
class Interaction>
221 template <
class Interaction>
227 bool nextIndent =
false;
238 template <
class Interaction>
245 bool nextIndent =
false;
256 template <
class Interaction>
265 template <
class Interaction>
269 {
return interaction().energy(rsq, iAtomType, jAtomType); }
274 template <
class Interaction>
279 if (rsq <
interaction().cutoffSq(iAtomType, jAtomType)) {
280 return interaction().forceOverR(rsq, iAtomType, jAtomType);
289 template <
class Interaction>
296 template <
class Interaction>
302 int j, jId, nNeighbor;
311 for (j = 0; j < nNeighbor; ++j) {
313 jId = jAtomPtr->
id();
333 template <
class Interaction>
336 const Atom* iAtomPtr;
337 const Atom* jAtomPtr;
340 int i, iId, j, jId, nNeighbor;
343 for (i = 0; i < molecule.
nAtom(); ++i) {
344 iAtomPtr = &molecule.
atom(i);
345 iId = iAtomPtr->
id();
352 for (j = 0; j < nNeighbor; ++j) {
354 jId = jAtomPtr->
id();
379 template <
class Interaction>
382 Atom *iAtomPtr, *jAtomPtr;
385 int nNeighbor, nInCell;
386 int i, j, iId, jId, ic;
397 for (i = 0; i < nInCell; ++i) {
399 iId = iAtomPtr->
id();
402 for (j = 0; j < nNeighbor; ++j) {
404 jId = jAtomPtr->
id();
433 template <
class Interaction>
434 template <
typename T>
440 const Atom *atom0Ptr, *atom1Ptr;
441 int nNeighbor, nInCell, ia, ja, type0, type1;
453 for (ia = 0; ia < nInCell; ++ia) {
455 type0 = atom0Ptr->
typeId();
458 for (ja = 0; ja < nNeighbor; ++ja) {
460 type1 = atom1Ptr->
typeId();
463 if (atom1Ptr->
id() > atom0Ptr->
id()) {
471 force *=
interaction().forceOverR(rsq, type0, type1);
472 incrementPairStress(force, dr, stress);
487 normalizeStress(stress);
493 template <
class Interaction>
497 computeStressImpl(stress);
505 template <
class Interaction>
507 {
return interaction_; }
512 template <
class Interaction>
514 {
return interaction_; }
519 template <
class Interaction>
Molecule & molecule() const
Get the parent Molecule by reference.
A Vector is a Cartesian vector.
virtual void readParameters(std::istream &in)
Reads the pair potential Interaction blocks.
void getNeighbors(const Vector &pos, NeighborArray &neighbors) const
Fill a NeighborArray with pointers to atoms near a specified position.
double atomEnergy(const Atom &atom) const
Calculate the nonbonded pair energy for one Atom.
double distanceSq(const Vector &r1, const Vector &r2) const
Return square distance between positions r1 and r2.
virtual double maxPairCutoff() const
Return maximum cutoff.
double volume() const
Return unit cell volume.
void set(const T &value)
Set the value and mark as set.
A PairPotential for MC simulations (abstract).
Mask & mask()
Get the associated Mask by reference.
A set of interacting Molecules enclosed by a Boundary.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
A Tensor represents a Cartesian tensor.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
CellList::NeighborArray neighbors_
Array to hold neighbors returned by a CellList.
Saving / output archive for binary ostream.
CellList cellList_
Cell list for atom positions.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
bool isMasked(const Atom &atom) const
True if the atom is in the masked set for the target Atom.
virtual double forceOverR(double rsq, int iAtomType, int jAtomType) const
Return force / separation for a single pair.
Implementation template for an McPairPotential.
int typeId() const
Get type index for this Atom.
void getCellNeighbors(int ic, NeighborArray &neighbors, int &nInCell) const
Fill an array with pointers to atoms in a cell and neighboring cells.
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.
int id() const
Get global index for this Atom within the Simulation.
Interaction & interaction()
Return reference to underlying pair interaction.
int totCells() const
Get total number of cells in this CellList.
virtual ~McPairPotentialImpl()
Destructor.
virtual void computeStress()
Compute and store total short-range pair stress.
virtual std::string interactionClassName() const
Return pair interaction class name (e.g., "LJPair").
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
void addParamComposite(ParamComposite &child, bool next=true)
Add a child ParamComposite object to the format array.
double moleculeEnergy(const Molecule &molecule) const
Calculate the nonbonded pair energy for an entire Molecule.
const Atom & atom(int localId) const
Get a specific Atom in this Molecule.
Boundary & boundary() const
Get the Boundary by reference.
virtual void computeEnergy()
Compute and store nonbonded pair energy of this System.
void setAtomCapacity(int atomCapacity)
Set atom capacity.
A physical molecule (a set of covalently bonded Atoms).
const Vector & position() const
Get the position Vector by const reference.
int size() const
Return logical size of this array (i.e., number of elements).
int nAtom() const
Get the number of Atoms in this Molecule.
double energy()
Return the energy contribution, compute if necessary.