1 #ifndef MCMD_LINK_POTENTIAL_IMPL_H 2 #define MCMD_LINK_POTENTIAL_IMPL_H 11 #include <mcMd/potentials/bond/BondPotential.h> 12 #include <mcMd/simulation/SystemInterface.h> 13 #include <mcMd/links/LinkMaster.h> 38 template <
class Interaction>
66 virtual void readParameters(std::istream& in);
74 virtual double energy(
double rsq,
int bondTypeId)
const;
79 virtual double forceOverR(
double rsq,
int bondTypeId)
const;
85 double randomBondLength(
Random* random,
double beta,
int bondTypeId)
95 void set(std::string name,
int type,
double value)
96 { interactionPtr_->set(name, type, value); }
104 double get(std::string name,
int type)
const 105 {
return interactionPtr_->get(name, type); }
110 virtual std::string interactionClassName()
const;
122 virtual double atomEnergy(
const Atom& atom)
const;
127 virtual void addForces();
132 virtual void computeEnergy();
137 virtual void computeStress();
144 Interaction& interaction();
149 const Interaction& interaction()
const;
154 Interaction* interactionPtr_;
163 template <
typename T>
164 void computeStressImpl(T& stress)
const;
170 #include <mcMd/simulation/System.h> 171 #include <mcMd/simulation/Simulation.h> 172 #include <mcMd/simulation/stress.h> 173 #include <mcMd/links/Link.h> 175 #include <simp/species/Species.h> 176 #include <simp/boundary/Boundary.h> 178 #include <util/space/Dimension.h> 179 #include <util/space/Vector.h> 180 #include <util/space/Tensor.h> 181 #include <util/accumulators/setToZero.h> 188 using namespace Util;
189 using namespace Simp;
194 template <
class Interaction>
199 linkMasterPtr_(&system.linkMaster()),
203 interactionPtr_ =
new Interaction();
209 template <
class Interaction>
215 linkMasterPtr_(&other.
system().linkMaster()),
222 template <
class Interaction>
229 template <
class Interaction>
235 bool nextIndent =
false;
244 template <
class Interaction>
252 template <
class Interaction>
255 {
return interaction().forceOverR(rsq, iBondType); }
260 template <
class Interaction>
double 263 {
return interaction().randomBondLength(random, beta, bondTypeId); }
268 template <
class Interaction>
279 nLink = linkSetPtr->
size();
280 for (iLink = 0; iLink < nLink; ++iLink) {
281 linkPtr = &((*linkSetPtr)[iLink]);
293 template <
class Interaction>
302 nLink = linkMasterPtr_->
nLink();
303 for (iLink = 0; iLink < nLink; ++iLink) {
304 linkPtr = &linkMasterPtr_->
link(iLink);
305 atom0Ptr = &(linkPtr->
atom0());
306 atom1Ptr = &(linkPtr->
atom1());
310 atom0Ptr->
force() += force;
311 atom1Ptr->
force() -= force;
318 template <
class Interaction>
325 nLink = linkMasterPtr_->
nLink();
326 for (iLink = 0; iLink < nLink; ++iLink) {
327 linkPtr = &(linkMasterPtr_->
link(iLink));
338 template <
class Interaction>
339 template <
typename T>
351 nLink = linkMasterPtr_->
nLink();
352 for (iLink = 0; iLink < nLink; ++iLink) {
353 linkPtr = &linkMasterPtr_->
link(iLink);
358 incrementPairStress(force, dr, stress);
363 normalizeStress(stress);
369 template <
class Interaction>
373 computeStressImpl(stress);
379 template <
class Interaction>
381 {
return *interactionPtr_; }
383 template <
class Interaction>
385 {
return *interactionPtr_; }
390 template <
class Interaction>
int nLink() const
Get the total number of active Links.
A Vector is a Cartesian vector.
virtual void addForces()
Compute and increment link forces for all atoms.
virtual void computeEnergy()
Calculate and store pair energy for this System.
An interface to a System.
virtual ~LinkPotentialImpl()
Destructor.
double distanceSq(const Vector &r1, const Vector &r2) const
Return square distance between positions r1 and r2.
virtual void readParameters(std::istream &in)
Read potential energy.
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.
Interaction & interaction()
Return bond interaction by reference.
int size() const
Return logical size of this array.
A set of interacting Molecules enclosed by a Boundary.
A Link represents a crosslink between two Atoms.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
A Tensor represents a Cartesian tensor.
virtual void computeStress()
Compute and store the total nonbonded pressure.
virtual std::string interactionClassName() const
Return pair interaction class name (e.g., "HarmonicBond").
virtual double forceOverR(double rsq, int bondTypeId) const
Return force / separation for a single pair.
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.
Manages all Link objects in a System.
virtual double randomBondLength(Random *random, double beta, int bondTypeId) const
Return force / separation for a single pair.
int typeId() const
Get the typeId for this Link.
virtual double atomEnergy(const Atom &atom) const
Calculate the link potential energy for one Atom.
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.
const Atom & atom1() const
Get Atom1 connected to a Link.
void setClassName(const char *className)
Set class name string.
Boundary & boundary() const
Get the Boundary by reference.
Abstract Bond Potential class.
Link & link(int id) const
Return an active link by an internal set index.
Statically allocated array of pointers to an unordered set.
const Vector & position() const
Get the position Vector by const reference.
const AtomLinkSet & atomLinkSet(const Atom &atom) const
Return a set of links associated with an Atom by const reference.
const Atom & atom0() const
Get Atom0 connected to a Link.
System & system() const
Get the parent System by reference.
Template implementation of an BondPotential for links.
LinkPotentialImpl(System &system)
Constructor.
double energy()
Return the energy contribution, compute if necessary.