1 #ifndef DDMD_EXTERNAL_POTENTIAL_IMPL_H 2 #define DDMD_EXTERNAL_POTENTIAL_IMPL_H 11 #include <ddMd/potentials/external/ExternalPotential.h> 32 template <
class Interaction>
70 virtual void setNAtomType(
int nAtomType);
77 virtual void readParameters(std::istream& in);
105 virtual double externalEnergy(
const Vector& position,
int typeId)
const;
114 virtual void getExternalForce(
const Vector& position,
int typeId,
123 void set(std::string name,
double value)
124 { interactionPtr_->set(name, value); }
131 double get(std::string name)
const 132 {
return interactionPtr_->get(name); }
137 virtual std::string interactionClassName()
const;
142 Interaction& interaction();
147 const Interaction& interaction()
const;
156 virtual void computeForces();
164 virtual void computeEnergy(MPI::Intracomm& communicator);
166 virtual void computeEnergy();
176 Interaction* interactionPtr_;
186 double computeForces(
bool needForce,
bool needEnergy);
192 #include <ddMd/simulation/Simulation.h> 193 #include <ddMd/storage/AtomStorage.h> 194 #include <ddMd/storage/AtomIterator.h> 196 #include <util/space/Dimension.h> 197 #include <util/space/Vector.h> 205 using namespace Util;
210 template <
class Interaction>
214 isInitialized_(false)
216 interactionPtr_ =
new Interaction;
224 template <
class Interaction>
228 isInitialized_(false)
229 { interactionPtr_ =
new Interaction; }
234 template <
class Interaction>
237 if (interactionPtr_) {
238 delete interactionPtr_;
247 template <
class Interaction>
258 template <
class Interaction>
265 template <
class Interaction>
269 bool nextIndent =
false;
272 isInitialized_ =
true;
278 template <
class Interaction>
282 bool nextIndent =
false;
285 isInitialized_ =
true;
291 template <
class Interaction>
298 template <
class Interaction>
307 template <
class Interaction>
310 int typeId,
Vector& force)
const 311 {
interaction().getForce(position, typeId, force); }
316 template <
class Interaction>
323 template <
class Interaction>
326 assert(interactionPtr_);
327 return *interactionPtr_;
333 template <
class Interaction>
336 assert(interactionPtr_);
337 return *interactionPtr_;
343 template <
class Interaction>
350 template <
class Interaction>
358 double localEnergy = 0;
370 template <
class Interaction>
380 for ( ; iter.
notEnd(); ++iter) {
381 type = iter->typeId();
384 interactionPtr_->energy(iter->position(), type);
387 interactionPtr_->getForce(iter->position(), type, f);
A Vector is a Cartesian vector.
Boundary & boundary()
Get the Boundary by reference.
Implementation template for a ExternalPotential.
Interaction & interaction()
Return external interaction by reference.
An orthorhombic periodic unit cell.
Calculates external forces and energies for a parent Simulation.
virtual void getExternalForce(const Vector &position, int typeId, Vector &force) const
Computes external force on one atom.
File containing preprocessor macros for error handling.
virtual double externalEnergy(const Vector &position, int typeId) const
Returns external potential energy of a single atom.
Parallel domain decomposition (DD) MD simulation.
Main object for a domain-decomposition MD simulation.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from archive and initialize, for restart.
Saving / output archive for binary ostream.
bool notEnd() const
Is the current pointer not at the end of the PArray?
Utility classes for scientific computation.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive, for restart.
A container for all the atoms and ghost atoms on this processor.
double energy() const
Return the total potential, from all processors.
Saving archive for binary istream.
virtual void setNAtomType(int nAtomType)
Set the maximum number of atom types.
void addParamComposite(ParamComposite &child, bool next=true)
Add a child ParamComposite object to the format array.
AtomStorage & storage()
Get the AtomStorage by reference.
void reduceEnergy(double localEnergy, MPI::Intracomm &communicator)
Add local energies from all processors, set energy on master.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
int nAtomType()
Get maximum number of atom types.
virtual void associate(Boundary &boundary, AtomStorage &storage)
Associate with related objects.
ExternalPotentialImpl()
Default constructor (for unit testing).
Boundary & boundary()
Get the Boundary by reference.
virtual void computeForces()
Calculate external forces for all atoms in this Simulation.
Iterator for all atoms owned by an AtomStorage.
void setEnergy(double energy)
Set a value for the total energy.
virtual std::string interactionClassName() const
Return external interaction class name (e.g., "LamellarOrderingExternal").
void begin(AtomIterator &iterator)
Set iterator to beginning of the set of atoms.
virtual ~ExternalPotentialImpl()
Destructor.
virtual void readParameters(std::istream &in)
Read external potential interaction.
virtual void computeEnergy(MPI::Intracomm &communicator)
Compute the total external energy for all processors.