1 #ifndef MCMD_EXTERNAL_POTENTIAL_IMPL_H 2 #define MCMD_EXTERNAL_POTENTIAL_IMPL_H 11 #include <mcMd/potentials/external/ExternalPotential.h> 12 #include <mcMd/simulation/SystemInterface.h> 34 template <
class Interaction>
63 virtual void readParameters(std::istream& in);
89 virtual double energy(
const Vector& position,
int typeId)
const;
98 virtual void getForce(
const Vector& position,
int typeId,
Vector& force)
const;
103 virtual std::string interactionClassName()
const;
117 void computeEnergy();
124 double atomEnergy(
const Atom& atom)
const;
131 Interaction& interaction();
136 const Interaction& interaction()
const;
140 Interaction* interactionPtr_;
144 template <
typename T>
145 void computeStressImpl(T& stress)
const;
151 #include <mcMd/simulation/System.h> 152 #include <mcMd/simulation/Simulation.h> 154 #include <simp/species/Species.h> 155 #include <simp/boundary/Boundary.h> 157 #include <util/space/Dimension.h> 158 #include <util/space/Vector.h> 165 using namespace Util;
166 using namespace Simp;
171 template <
class Interaction>
177 { interactionPtr_ =
new Interaction(); }
182 template <
class Interaction>
194 template <
class Interaction>
201 template <
class Interaction>
208 bool nextIndent =
false;
217 template <
class Interaction>
224 bool nextIndent =
false;
233 template <
class Interaction>
245 template <
class Interaction>
254 template <
class Interaction>
256 int typeId,
Vector& force)
const 257 {
interaction().getForce(position, typeId, force); }
262 template <
class Interaction>
269 for (
begin(iSpec, molIter); molIter.
notEnd(); ++molIter) {
270 for (molIter->begin(atomIter); atomIter.
notEnd(); ++atomIter) {
272 atomIter->typeId(), force);
273 atomIter->force() += force;
282 template <
class Interaction>
289 for (
begin(iSpec, molIter); molIter.
notEnd(); ++molIter) {
290 for (molIter->begin(atomIter); atomIter.
notEnd(); ++atomIter) {
291 energy +=
interaction().energy(atomIter->position(),
303 template <
class Interaction>
309 template <
class Interaction>
311 {
return *interactionPtr_; }
313 template <
class Interaction>
315 {
return *interactionPtr_; }
320 template <
class Interaction>
A Vector is a Cartesian vector.
ExternalPotentialImpl(System &system)
Constructor.
An interface to a System.
bool notEnd() const
Is the current pointer not at the end of the array?
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
void set(const T &value)
Set the value and mark as set.
virtual ~ExternalPotentialImpl()
Destructor.
A set of interacting Molecules enclosed by a Boundary.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
Forward iterator for a PArray.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
virtual void getForce(const Vector &position, int typeId, Vector &force) const
Returns force caused by the external potential.
Forward const iterator for an Array or a C array.
virtual std::string interactionClassName() const
Return external interaction class name (e.g., "LamellarOrderingExternal").
Saving / output archive for binary ostream.
double atomEnergy(const Atom &atom) const
Calculate the external energy for one Atom.
Abstract External Potential class.
int typeId() const
Get type index for this Atom.
Interaction & interaction()
Return external interaction by reference.
Simulation & simulation() const
Get the parent Simulation by reference.
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.
virtual void readParameters(std::istream &in)
Read param for external potential.
Forward iterator for an Array or a C array.
Forward iterator for a PArray.
void addForces()
Add external force of an Atom to the total force acting on it.
bool notEnd() const
Is the current pointer not at the end of the array?
void begin(int speciesId, System::MoleculeIterator &iterator)
Initialize an iterator for molecules of one species in this SystemInterface.
Saving archive for binary istream.
Template implementation of ExternalPotential.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
int nSpecies() const
Get the number of Species in this Simulation.
void addParamComposite(ParamComposite &child, bool next=true)
Add a child ParamComposite object to the format array.
Boundary & boundary() const
Get the Boundary by reference.
const Vector & position() const
Get the position Vector by const reference.
bool notEnd() const
Is this not the end of the array?
System & system() const
Get the parent System by reference.
void computeEnergy()
Compute and store total external energy of this System.
double energy()
Return the energy contribution, compute if necessary.