Simpatico  v1.10
List of all members | Public Member Functions | Protected Member Functions
DdMd::Simulation Class Reference

Detailed Description

Main object for a domain-decomposition MD simulation.

A DdMd::Simulation contains and coordinates all the components of a parallel MD simulation.

Most member functions of this class should be called simultaneously on all processors. This should be assumed to be the case unless the documentation says otherwise. Member functions that should only be called on the master processor of the communicator associated with a spatial grid decomposition (i.e.,the communicator associated with the Domain member) are identified explicitly as such.

Definition at line 84 of file ddMd/simulation/Simulation.h.

#include <Simulation.h>

Inheritance diagram for DdMd::Simulation:
Util::ParamComposite Util::ParamComponent Util::Serializable Util::MpiFileIo

Public Member Functions

 Simulation (MPI::Intracomm &communicator=MPI::COMM_WORLD)
 Constructor. More...
 
 ~Simulation ()
 Destructor. More...
 
void outputOptions (std::ostream &out) const
 Output a list of options enabled & disabled during compilation. More...
 
bool isValid ()
 Return true if this Simulation is valid, or throw an Exception. More...
 
Initialization
void setOptions (int argc, char *const *argv)
 Process command line options. More...
 
virtual void readParam ()
 Read parameters from default parameter file. More...
 
virtual void readParam (std::istream &in)
 Read parameters. More...
 
virtual void readParameters (std::istream &in)
 Read body of the parameter block, allocate memory and initialize. More...
 
void setReverseUpdateFlag (bool reverseUpdateFlag)
 Set flag to identify if reverse communication is enabled. More...
 
Serialization (Restart files)
void load (const std::string &filename)
 Load internal state from a restart file. More...
 
virtual void loadParameters (Serializable::IArchive &ar)
 Load parameters from a restart archive. More...
 
void save (const std::string &filename)
 Save state to a restart file. More...
 
virtual void save (Serializable::OArchive &ar)
 Save internal state to restart archive. More...
 
Run Time Actions
void readCommands ()
 Read and execute commands from the default command file. More...
 
void readCommands (std::istream &in)
 Read and execute commands from a specific command file. More...
 
void setBoltzmannVelocities (double temperature)
 Set random velocities chosen from a Boltzmann distribution. More...
 
Vector removeDriftVelocity ()
 Subtract system center of mass velocity from atom velocities. More...
 
void zeroForces ()
 Set forces for all atoms to zero. More...
 
Config File IO
void readConfig (const std::string &filename)
 Read configuration file on master and distribute atoms. More...
 
void writeConfig (const std::string &filename)
 Write configuration file. More...
 
Factory< ConfigIo > & configIoFactory ()
 Get the configuration file reader/writer factory by reference. More...
 
void setConfigIo (std::string &classname)
 Create a new configuration file reader/writer. More...
 
Force, energy and stress calculators
void computeForces ()
 Compute forces for all local atoms. More...
 
void computeForcesAndVirial ()
 Compute forces for all local atoms and virial stress. More...
 
void computeKineticEnergy ()
 Compute total kinetic energy. More...
 
double kineticEnergy ()
 Return precomputed total kinetic energy. More...
 
void unsetKineticEnergy ()
 Mark kinetic energy as unknown. More...
 
void computePotentialEnergies ()
 Calculate and store total potential energy on all processors. More...
 
double potentialEnergy () const
 Return sum of precomputed total potential energies. More...
 
void unsetPotentialEnergies ()
 Mark all potential energies as unknown. More...
 
void computePairEnergies ()
 Compute pair energies for each pair of atom types. More...
 
DMatrix< double > pairEnergies () const
 Return precomputed pair energies. More...
 
void computeKineticStress ()
 Calculate and store kinetic stress. More...
 
Tensor kineticStress () const
 Return total kinetic stress. More...
 
double kineticPressure () const
 Return total kinetic pressure. More...
 
void unsetKineticStress ()
 Mark kinetic stress as unknown. More...
 
void computeVirialStress ()
 Calculate and store all virial stress contributions. More...
 
Tensor virialStress () const
 Return total virial stress. More...
 
double virialPressure () const
 Return total virial pressure. More...
 
void unsetVirialStress ()
 Mark all virial stress contributions as unknown. More...
 
Potential Energy Classes (Objects, Style Strings and Factories)
const PairPotentialpairPotential () const
 Get the PairPotential by const reference. More...
 
PairPotentialpairPotential ()
 Get the PairPotential by reference. More...
 
std::string pairStyle () const
 Return nonbonded pair style string. More...
 
Factory< PairPotential > & pairFactory ()
 Get the Factory<PairPotential> by reference. More...
 
const BondPotentialbondPotential () const
 Get the PairPotential by const reference. More...
 
BondPotentialbondPotential ()
 Get the PairPotential by reference. More...
 
std::string bondStyle () const
 Return covalent bond style string. More...
 
Factory< BondPotential > & bondFactory ()
 Get the Factory<BondPotential> by reference. More...
 
const AnglePotentialanglePotential () const
 Get the AnglePotential by const reference. More...
 
AnglePotentialanglePotential ()
 Get the AnglePotential by reference. More...
 
std::string angleStyle () const
 Return angle potential style string. More...
 
Factory< AnglePotential > & angleFactory ()
 Get the AngleFactory by reference. More...
 
const DihedralPotentialdihedralPotential () const
 Get the DihedralPotential by const reference. More...
 
DihedralPotentialdihedralPotential ()
 Get the DihedralPotential by reference. More...
 
std::string dihedralStyle () const
 Return dihedral potential style string. More...
 
Factory< DihedralPotential > & dihedralFactory ()
 Get the associated Dihedral Factory by reference. More...
 
const ExternalPotentialexternalPotential () const
 Get the ExternalPotential by reference. More...
 
ExternalPotentialexternalPotential ()
 Get the ExternalPotential by reference. More...
 
std::string externalStyle () const
 Return external potential style string. More...
 
Factory< ExternalPotential > & externalFactory ()
 Get the associated External Factory by reference. More...
 
Atom and Group Containers
AtomStorageatomStorage ()
 Get the AtomStorage by reference. More...
 
BondStoragebondStorage ()
 Get the BondStorage by reference. More...
 
AngleStorageangleStorage ()
 Get the AngleStorage by reference. More...
 
DihedralStoragedihedralStorage ()
 Get the DihedralStorage by reference. More...
 
Miscellaneous Accessors (return members by reference)
Domaindomain ()
 Get the Domain by reference. More...
 
Boundaryboundary ()
 Get the Boundary by reference. More...
 
AtomTypeatomType (int i)
 Get an AtomType descriptor by reference. More...
 
Integratorintegrator ()
 Get the Integrator by reference. More...
 
EnergyEnsembleenergyEnsemble ()
 Get the EnergyEnsemble by reference. More...
 
BoundaryEnsembleboundaryEnsemble ()
 Get the BoundaryEnsemble by reference. More...
 
FileMasterfileMaster ()
 Get the associated FileMaster by reference. More...
 
Randomrandom ()
 Get the Random number generator by reference. More...
 
Exchangerexchanger ()
 Get the Exchanger by reference. More...
 
Bufferbuffer ()
 Get the Buffer by reference. More...
 
ModifierManagermodifierManager ()
 Return the ModifierManager by reference. More...
 
AnalyzerManageranalyzerManager ()
 Return the AnalyzerManager by reference. More...
 
Factory< Integrator > & integratorFactory ()
 Get the Integrator factory by reference. More...
 
Accessors (return by value)
int nAtomType ()
 Get maximum number of atom types. More...
 
int nBondType ()
 Get maximum number of bond types. More...
 
int nAngleType ()
 Get maximum number of angle types. More...
 
int nDihedralType ()
 Get maximum number of dihedral types. More...
 
bool hasExternal ()
 Does this simulation have an external potential? More...
 
MaskPolicy maskedPairPolicy () const
 Return the value of the mask policy (MaskNone or MaskBonded). More...
 
bool reverseUpdateFlag () const
 Is reverse communication enabled? More...
 
Signals
SignalmodifySignal ()
 Signal to force unsetting of quantities that depend on x, v, or f. More...
 
SignalpositionSignal ()
 Signal to indicate change in atomic positions. More...
 
SignalvelocitySignal ()
 Signal to indicate change in atomic velocities. More...
 
SignalexchangeSignal ()
 Signal to indicate exchange of atoms and groups. More...
 
- Public Member Functions inherited from Util::ParamComposite
 ParamComposite ()
 Constructor. More...
 
 ParamComposite (const ParamComposite &other)
 Copy constructor. More...
 
 ParamComposite (int capacity)
 Constructor. More...
 
virtual ~ParamComposite ()
 Virtual destructor. More...
 
void resetParam ()
 Resets ParamComposite to its empty state. More...
 
virtual void readParamOptional (std::istream &in)
 Read optional parameter file block. More...
 
virtual void writeParam (std::ostream &out)
 Write all parameters to an output stream. More...
 
virtual void load (Serializable::IArchive &ar)
 Load all parameters from an input archive. More...
 
virtual void loadOptional (Serializable::IArchive &ar)
 Load an optional ParamComposite. More...
 
void saveOptional (Serializable::OArchive &ar)
 Saves isActive flag, and then calls save() iff isActive is true. More...
 
void readParamComposite (std::istream &in, ParamComposite &child, bool next=true)
 Add and read a required child ParamComposite. More...
 
void readParamCompositeOptional (std::istream &in, ParamComposite &child, bool next=true)
 Add and attempt to read an optional child ParamComposite. More...
 
template<typename Type >
ScalarParam< Type > & read (std::istream &in, const char *label, Type &value)
 Add and read a new required ScalarParam < Type > object. More...
 
template<typename Type >
ScalarParam< Type > & readOptional (std::istream &in, const char *label, Type &value)
 Add and read a new optional ScalarParam < Type > object. More...
 
template<typename Type >
CArrayParam< Type > & readCArray (std::istream &in, const char *label, Type *value, int n)
 Add and read a required C array parameter. More...
 
template<typename Type >
CArrayParam< Type > & readOptionalCArray (std::istream &in, const char *label, Type *value, int n)
 Add and read an optional C array parameter. More...
 
template<typename Type >
DArrayParam< Type > & readDArray (std::istream &in, const char *label, DArray< Type > &array, int n)
 Add and read a required DArray < Type > parameter. More...
 
template<typename Type >
DArrayParam< Type > & readOptionalDArray (std::istream &in, const char *label, DArray< Type > &array, int n)
 Add and read an optional DArray < Type > parameter. More...
 
template<typename Type , int N>
FArrayParam< Type, N > & readFArray (std::istream &in, const char *label, FArray< Type, N > &array)
 Add and read a required FArray < Type, N > array parameter. More...
 
template<typename Type , int N>
FArrayParam< Type, N > & readOptionalFArray (std::istream &in, const char *label, FArray< Type, N > &array)
 Add and read an optional FArray < Type, N > array parameter. More...
 
template<typename Type >
CArray2DParam< Type > & readCArray2D (std::istream &in, const char *label, Type *value, int m, int n, int np)
 Add and read a required CArray2DParam < Type > 2D C-array. More...
 
template<typename Type >
CArray2DParam< Type > & readOptionalCArray2D (std::istream &in, const char *label, Type *value, int m, int n, int np)
 Add and read an optional CArray2DParam < Type > 2D C-array parameter. More...
 
template<typename Type >
DMatrixParam< Type > & readDMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int m, int n)
 Add and read a required DMatrix < Type > matrix parameter. More...
 
template<typename Type >
DMatrixParam< Type > & readOptionalDMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int m, int n)
 Add and read an optional DMatrix < Type > matrix parameter. More...
 
template<typename Type >
DSymmMatrixParam< Type > & readDSymmMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int n)
 Add and read a required symmetrix DMatrix. More...
 
template<typename Type >
DSymmMatrixParam< Type > & readOptionalDSymmMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int n)
 Add and read an optional DMatrix matrix parameter. More...
 
BeginreadBegin (std::istream &in, const char *label, bool isRequired=true)
 Add and read a class label and opening bracket. More...
 
EndreadEnd (std::istream &in)
 Add and read the closing bracket. More...
 
BlankreadBlank (std::istream &in)
 Add and read a new Blank object, representing a blank line. More...
 
void loadParamComposite (Serializable::IArchive &ar, ParamComposite &child, bool next=true)
 Add and load a required child ParamComposite. More...
 
void loadParamCompositeOptional (Serializable::IArchive &ar, ParamComposite &child, bool next=true)
 Add and load an optional child ParamComposite if isActive. More...
 
template<typename Type >
ScalarParam< Type > & loadParameter (Serializable::IArchive &ar, const char *label, Type &value, bool isRequired)
 Add and load a new ScalarParam < Type > object. More...
 
template<typename Type >
ScalarParam< Type > & loadParameter (Serializable::IArchive &ar, const char *label, Type &value)
 Add and load new required ScalarParam < Type > object. More...
 
template<typename Type >
CArrayParam< Type > & loadCArray (Serializable::IArchive &ar, const char *label, Type *value, int n, bool isRequired)
 Add a C array parameter and load its elements. More...
 
template<typename Type >
CArrayParam< Type > & loadCArray (Serializable::IArchive &ar, const char *label, Type *value, int n)
 Add and load a required CArrayParam< Type > array parameter. More...
 
template<typename Type >
DArrayParam< Type > & loadDArray (Serializable::IArchive &ar, const char *label, DArray< Type > &array, int n, bool isRequired)
 Add an load a DArray < Type > array parameter. More...
 
template<typename Type >
DArrayParam< Type > & loadDArray (Serializable::IArchive &ar, const char *label, DArray< Type > &array, int n)
 Add and load a required DArray< Type > array parameter. More...
 
template<typename Type , int N>
FArrayParam< Type, N > & loadFArray (Serializable::IArchive &ar, const char *label, FArray< Type, N > &array, bool isRequired)
 Add and load an FArray < Type, N > fixed-size array parameter. More...
 
template<typename Type , int N>
FArrayParam< Type, N > & loadFArray (Serializable::IArchive &ar, const char *label, FArray< Type, N > &array)
 Add and load a required FArray < Type > array parameter. More...
 
template<typename Type >
CArray2DParam< Type > & loadCArray2D (Serializable::IArchive &ar, const char *label, Type *value, int m, int n, int np, bool isRequired)
 Add and load a CArray2DParam < Type > C 2D array parameter. More...
 
template<typename Type >
CArray2DParam< Type > & loadCArray2D (Serializable::IArchive &ar, const char *label, Type *value, int m, int n, int np)
 Add and load a required < Type > matrix parameter. More...
 
template<typename Type >
DMatrixParam< Type > & loadDMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int m, int n, bool isRequired)
 Add and load a DMatrixParam < Type > matrix parameter. More...
 
template<typename Type >
DMatrixParam< Type > & loadDMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int m, int n)
 Add and load a required DMatrixParam < Type > matrix parameter. More...
 
template<typename Type >
DSymmMatrixParam< Type > & loadDSymmMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int n, bool isRequired)
 Add and load a symmetric DSymmMatrixParam < Type > matrix parameter. More...
 
template<typename Type >
DSymmMatrixParam< Type > & loadDSymmMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int n)
 Add and load a required DSymmMatrixParam < Type > matrix parameter. More...
 
void addParamComposite (ParamComposite &child, bool next=true)
 Add a child ParamComposite object to the format array. More...
 
BeginaddBegin (const char *label)
 Add a Begin object representing a class name and bracket. More...
 
EndaddEnd ()
 Add a closing bracket. More...
 
BlankaddBlank ()
 Create and add a new Blank object, representing a blank line. More...
 
std::string className () const
 Get class name string. More...
 
bool isRequired () const
 Is this ParamComposite required in the input file? More...
 
bool isActive () const
 Is this parameter active? More...
 
- Public Member Functions inherited from Util::ParamComponent
virtual ~ParamComponent ()
 Destructor. More...
 
void setIndent (const ParamComponent &parent, bool next=true)
 Set indent level. More...
 
std::string indent () const
 Return indent string for this object (string of spaces). More...
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 Serialize this ParamComponent as a string. More...
 
- Public Member Functions inherited from Util::Serializable
virtual ~Serializable ()
 Destructor. More...
 
- Public Member Functions inherited from Util::MpiFileIo
 MpiFileIo ()
 Constructor. More...
 
 MpiFileIo (const MpiFileIo &other)
 Copy constructor. More...
 
bool isIoProcessor () const
 Can this processor do file I/O ? More...
 
void setIoCommunicator (MPI::Intracomm &communicator)
 Set the communicator. More...
 
void clearCommunicator ()
 Clear (nullify) the communicator. More...
 
bool hasIoCommunicator () const
 Does this object have an associated MPI communicator? More...
 
MPI::Intracomm & ioCommunicator () const
 Get the MPI communicator by reference. More...
 

Protected Member Functions

void readFileMaster (std::istream &in)
 Read the FileMaster. More...
 
void loadFileMaster (Serializable::IArchive &ar)
 Load FileMaster from an archive. More...
 
void saveFileMaster (Serializable::OArchive &ar)
 Save FileMaster to archive. More...
 
void readPotentialStyles (std::istream &in)
 Read potential styles and maskedPairPolicy. More...
 
void loadPotentialStyles (Serializable::IArchive &ar)
 Load potential styles. More...
 
void savePotentialStyles (Serializable::OArchive &ar)
 Save potential styles to archive. More...
 
void readEnsembles (std::istream &in)
 Read energy and boundary ensembles. More...
 
void loadEnsembles (Serializable::IArchive &ar)
 Load energy and boundary ensembles from an input archive. More...
 
void saveEnsembles (Serializable::OArchive &ar)
 Save energy and boundary ensembles to archive. More...
 
- Protected Member Functions inherited from Util::ParamComposite
void setClassName (const char *className)
 Set class name string. More...
 
void setIsRequired (bool isRequired)
 Set or unset the isActive flag. More...
 
void setIsActive (bool isActive)
 Set or unset the isActive flag. More...
 
void setParent (ParamComponent &param, bool next=true)
 Set this to the parent of a child component. More...
 
void addComponent (ParamComponent &param, bool isLeaf=true)
 Add a new ParamComponent object to the format array. More...
 
template<typename Type >
ScalarParam< Type > & add (std::istream &in, const char *label, Type &value, bool isRequired=true)
 Add a new required ScalarParam < Type > object. More...
 
template<typename Type >
CArrayParam< Type > & addCArray (std::istream &in, const char *label, Type *value, int n, bool isRequired=true)
 Add (but do not read) a required C array parameter. More...
 
template<typename Type >
DArrayParam< Type > & addDArray (std::istream &in, const char *label, DArray< Type > &array, int n, bool isRequired=true)
 Add (but do not read) a DArray < Type > parameter. More...
 
template<typename Type , int N>
FArrayParam< Type, N > & addFArray (std::istream &in, const char *label, FArray< Type, N > &array, bool isRequired=true)
 Add (but do not read) a FArray < Type, N > array parameter. More...
 
template<typename Type >
CArray2DParam< Type > & addCArray2D (std::istream &in, const char *label, Type *value, int m, int n, int np, bool isRequired=true)
 Add (but do not read) a CArray2DParam < Type > 2D C-array. More...
 
template<typename Type >
DMatrixParam< Type > & addDMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int m, int n, bool isRequired=true)
 Add and read a required DMatrix < Type > matrix parameter. More...
 
- Protected Member Functions inherited from Util::ParamComponent
 ParamComponent ()
 Constructor. More...
 
 ParamComponent (const ParamComponent &other)
 Copy constructor. More...
 

Additional Inherited Members

- Public Types inherited from Util::Serializable
typedef BinaryFileOArchive OArchive
 Type of output archive used by save method. More...
 
typedef BinaryFileIArchive IArchive
 Type of input archive used by load method. More...
 
- Static Public Member Functions inherited from Util::ParamComponent
static void initStatic ()
 Initialize static echo member to false. More...
 
static void setEcho (bool echo=true)
 Enable or disable echoing for all subclasses of ParamComponent. More...
 
static bool echo ()
 Get echo parameter. More...
 

Constructor & Destructor Documentation

DdMd::Simulation::Simulation ( MPI::Intracomm &  communicator = MPI::COMM_WORLD)

Constructor.

Parameters
communicatorMPI communicator for MD processors.

Definition at line 79 of file ddMd/simulation/Simulation.cpp.

References Util::Vector::commitMpiType(), Util::IntVector::commitMpiType(), Util::initStatic(), DdMd::AtomType::initStatic(), and UTIL_THROW.

DdMd::Simulation::~Simulation ( )

Destructor.

Definition at line 217 of file ddMd/simulation/Simulation.cpp.

Member Function Documentation

void DdMd::Simulation::setOptions ( int  argc,
char *const *  argv 
)

Process command line options.

Options:

-e Enable echoing of the parameter file to the log file as it is read.

-s nSystem [int] Enable multi system simulation, using different groups of processors for different systems. Integer argument nSystem is the number of systems. The rank of the communicator passed to the constructor must be an integer multiple of nSystem.

-p filename [string] Specifies the name of a parameter file. If not specified here, the parameter file for a single-system simulation may be read from standard input by default.

-r filename [string] Restarts a simulation from a checkpoint file. The name of the checkpoint file is restartFilename + ".rst", i..e., it is obtained by adding a suffix ".rst" to the filename argument. Also sets the default command file name to filename + ".cmd".

-c filename [string] Specifies the name of a command file. If not specified here, the command file name may be specified in the FileMaster block of the parameter file.

The -p (parameter file) and -r (restart) options are incompatible: A simulation may either be initialized from a parameter file or a restart file, but not both. A command file is required in both cases.

This function is passed two arguments that should contain the command line arguments that were passed to the main program:

Parameters
argcnumber of command line arguments
argvC-array of C-string argument strings

Definition at line 300 of file ddMd/simulation/Simulation.cpp.

References Util::Log::file(), Util::ParamComponent::setEcho(), Util::Log::setFile(), and UTIL_THROW.

void DdMd::Simulation::readParam ( )
virtual

Read parameters from default parameter file.

See comment about restarting in readParam(std::istream&)

Definition at line 468 of file ddMd/simulation/Simulation.cpp.

void DdMd::Simulation::readParam ( std::istream &  in)
virtual

Read parameters.

This version includes the opening and closing blocks. Does nothing and returns if load() was called previously.

Reimplemented from Util::ParamComposite.

Definition at line 444 of file ddMd/simulation/Simulation.cpp.

void DdMd::Simulation::readParameters ( std::istream &  in)
virtual

Read body of the parameter block, allocate memory and initialize.

This function is called by the readParam() methods, which simply add code to read opening and closing brackets.

Reimplemented from Util::ParamComposite.

Definition at line 479 of file ddMd/simulation/Simulation.cpp.

References DdMd::Atom::setHasAtomContext(), unsetKineticEnergy(), unsetKineticStress(), DdMd::GroupStorage< 2 >::unsetNTotal(), DdMd::GroupStorage< 3 >::unsetNTotal(), DdMd::GroupStorage< 4 >::unsetNTotal(), unsetPotentialEnergies(), unsetVirialStress(), and UTIL_THROW.

void DdMd::Simulation::setReverseUpdateFlag ( bool  reverseUpdateFlag)

Set flag to identify if reverse communication is enabled.

Reverse communication is off by default. It is used in communication patterns in which forces involving several atoms (nonbonded pairs or covalent groups) are calculated on one processor and the forces on particles that are not owned by that processor are then communicated to the processor that owns each particle. The default mode is for such forces to be calculated independently on each processor that owns one or more atoms in a group, to avoid the extra "reverse" communication step.

Parameters
reverseUpdateFlagtrue if reverse communication is enabled.

Definition at line 1460 of file ddMd/simulation/Simulation.cpp.

void DdMd::Simulation::load ( const std::string &  filename)

Load internal state from a restart file.

Call on all processors. This function opens an archive file with a name given by concatentaing filename + ".rst" on the ioProcessor, calls load(Serializable::OArchive& ), and closes the file. It also sets the default command file name to filename + ".cmd".

Parameters
filenamebase filename (add suffixes ".rst" and ".cmd")

Definition at line 866 of file ddMd/simulation/Simulation.cpp.

References Util::BinaryFileIArchive::file(), and UTIL_THROW.

void DdMd::Simulation::loadParameters ( Serializable::IArchive ar)
virtual

Load parameters from a restart archive.

Call on all processors, but loads from archive only on ioProcessor. This function loads both parameter information and the system configuration.

Do not call this directly. Instead call load(const std::string&) or load(Serializable::IArchive& ).

Parameters
arinput archive (open for reading on ioProcessor).

Reimplemented from Util::ParamComposite.

Definition at line 668 of file ddMd/simulation/Simulation.cpp.

References DdMd::Atom::setHasAtomContext(), unsetKineticEnergy(), unsetKineticStress(), DdMd::GroupStorage< 2 >::unsetNTotal(), DdMd::GroupStorage< 3 >::unsetNTotal(), DdMd::GroupStorage< 4 >::unsetNTotal(), unsetPotentialEnergies(), unsetVirialStress(), and UTIL_THROW.

void DdMd::Simulation::save ( const std::string &  filename)

Save state to a restart file.

Call on all processors. Only writes from communicator ioProcessor. This function opens an archive file with a name given by filename

Definition at line 974 of file ddMd/simulation/Simulation.cpp.

References Util::BinaryFileOArchive::file().

Referenced by DdMd::TwoStepIntegrator::run().

void DdMd::Simulation::save ( Serializable::OArchive ar)
virtual

Save internal state to restart archive.

Used to implement save(std::string).

Reimplemented from Util::ParamComposite.

Definition at line 893 of file ddMd/simulation/Simulation.cpp.

References Util::Parameter::saveOptional().

void DdMd::Simulation::readCommands ( )

Read and execute commands from the default command file.

This function calls readCommands(std::istream&) internally. The current default command file is defined by the FileMaster. The file name for the default file may be specified as a command line option (option -c) or in the parameter file.

Definition at line 1449 of file ddMd/simulation/Simulation.cpp.

References UTIL_THROW.

void DdMd::Simulation::readCommands ( std::istream &  in)

Read and execute commands from a specific command file.

Precondition
Simulation is initialized, by call to (read|load)Parameters.
AtomStorage coordinates are scaled / generalized (not Cartesian)
Parameters
incommand file

Definition at line 1172 of file ddMd/simulation/Simulation.cpp.

References Util::Log::file(), Util::getNextLine(), Util::Memory::max(), and UTIL_THROW.

void DdMd::Simulation::setBoltzmannVelocities ( double  temperature)

Set random velocities chosen from a Boltzmann distribution.

Parameters
temperatureabsolute temperature kT, in energy units.

Definition at line 1471 of file ddMd/simulation/Simulation.cpp.

References Util::Dimension, and Util::PArrayIterator< Data >::notEnd().

Vector DdMd::Simulation::removeDriftVelocity ( )

Subtract system center of mass velocity from atom velocities.

Call on all processors. Does all-reduce internally.

Returns
drift velocity of system before subtraction.

Definition at line 1494 of file ddMd/simulation/Simulation.cpp.

References Util::Dimension, and Util::PArrayIterator< Data >::notEnd().

void DdMd::Simulation::zeroForces ( )

Set forces for all atoms to zero.

Definition at line 1544 of file ddMd/simulation/Simulation.cpp.

Referenced by DdMd::Integrator::computeForces(), and DdMd::Integrator::computeForcesAndVirial().

void DdMd::Simulation::readConfig ( const std::string &  filename)

Read configuration file on master and distribute atoms.

Upon return, all processors should have all atoms and groups, and a full set of ghost atoms, but values for the atomic forces are undefined.

Precondition
AtomStorage is set for scaled / generalized coordinates
Postcondition
AtomStorage is set for scaled / generalized coordinates
Parameters
filenamename of input configuration file

Definition at line 2057 of file ddMd/simulation/Simulation.cpp.

void DdMd::Simulation::writeConfig ( const std::string &  filename)

Write configuration file.

Precondition
AtomStorage coordinates are generalized / scaled
Parameters
filenamename of output configuration file

Definition at line 2073 of file ddMd/simulation/Simulation.cpp.

Referenced by DdMd::ConfigWriter::sample().

Factory< ConfigIo > & DdMd::Simulation::configIoFactory ( )

Get the configuration file reader/writer factory by reference.

Definition at line 2202 of file ddMd/simulation/Simulation.cpp.

void DdMd::Simulation::setConfigIo ( std::string &  classname)

Create a new configuration file reader/writer.

This method creates a new instance of the specified subclass of ConfigIo, and retains a pointer to the new object.

Parameters
classnamename of desired ConfigIo subclass

Definition at line 2214 of file ddMd/simulation/Simulation.cpp.

References Util::Bit::clear(), DdMd::Atom::hasAtomContext(), Util::PArrayIterator< Data >::notEnd(), Util::Bit::set(), and UTIL_THROW.

void DdMd::Simulation::computeForces ( )

Compute forces for all local atoms.

Upon return, forces are correct for all local atoms. Values of the forces on ghost atoms are generally undefined.

This method zeros all forces, adds forces from all potential energies, and carries out reverse communication if required (i.e., if reverseUpdateFlag is true).

Definition at line 1550 of file ddMd/simulation/Simulation.cpp.

Referenced by DdMd::Integrator::setupAtoms().

void DdMd::Simulation::computeForcesAndVirial ( )

Compute forces for all local atoms and virial stress.

Upon return, forces are correct for all local atoms and virial stress values are set for all Potential objects. Values of the forces on ghost atoms are undefined.

This functions zeros all forces, adds forces from all potential energies, and carries out reverse communication if required (i.e., if reverseUpdateFlag is true). It also calculates and sets each virial stress contribution.

Definition at line 1584 of file ddMd/simulation/Simulation.cpp.

Referenced by DdMd::Integrator::setupAtoms().

void DdMd::Simulation::computeKineticEnergy ( )
double DdMd::Simulation::kineticEnergy ( )
void DdMd::Simulation::unsetKineticEnergy ( )

Mark kinetic energy as unknown.

Definition at line 1664 of file ddMd/simulation/Simulation.cpp.

Referenced by loadParameters(), and readParameters().

void DdMd::Simulation::computePotentialEnergies ( )

Calculate and store total potential energy on all processors.

Reduce operation: Must be called on all nodes.

Definition at line 1749 of file ddMd/simulation/Simulation.cpp.

Referenced by DdMd::NphIntegrator::integrateStep2(), DdMd::NptIntegrator::integrateStep2(), DdMd::ExternalEnergyAverage::sample(), DdMd::LogEnergy::sample(), DdMd::OutputEnergy::sample(), and DdMd::EnergyAnalyzer::sample().

double DdMd::Simulation::potentialEnergy ( ) const

Return sum of precomputed total potential energies.

Call only on master processor, after computePotentialEnergies. Calls the energy() methods of each of the potential classes.

Returns
total potential energy (only correct on master node).

Definition at line 1817 of file ddMd/simulation/Simulation.cpp.

Referenced by DdMd::NphIntegrator::integrateStep2(), and DdMd::NptIntegrator::integrateStep2().

void DdMd::Simulation::unsetPotentialEnergies ( )

Mark all potential energies as unknown.

Definition at line 1847 of file ddMd/simulation/Simulation.cpp.

Referenced by loadParameters(), and readParameters().

void DdMd::Simulation::computePairEnergies ( )

Compute pair energies for each pair of atom types.

Reduce operation: Must be called on all nodes.

Definition at line 1978 of file ddMd/simulation/Simulation.cpp.

Referenced by DdMd::PairEnergyAverage::sample(), and DdMd::OutputPairEnergies::sample().

DMatrix< double > DdMd::Simulation::pairEnergies ( ) const

Return precomputed pair energies.

Call only on master processor, after computePairEnergies.

Returns
total pair energies (only correct on master node).

Definition at line 1991 of file ddMd/simulation/Simulation.cpp.

References Util::DMatrix< Data >::allocate().

Referenced by DdMd::PairEnergyAverage::sample(), and DdMd::OutputPairEnergies::sample().

void DdMd::Simulation::computeKineticStress ( )
Tensor DdMd::Simulation::kineticStress ( ) const
double DdMd::Simulation::kineticPressure ( ) const

Return total kinetic pressure.

Call only on master processor, after computeKineticStress.

Returns
total kinetic pressure only correct on master node).

Definition at line 1727 of file ddMd/simulation/Simulation.cpp.

References Util::Dimension.

Referenced by DdMd::OutputPressure::sample(), and DdMd::PressureAnalyzer::value().

void DdMd::Simulation::unsetKineticStress ( )

Mark kinetic stress as unknown.

Definition at line 1740 of file ddMd/simulation/Simulation.cpp.

Referenced by loadParameters(), and readParameters().

void DdMd::Simulation::computeVirialStress ( )
Tensor DdMd::Simulation::virialStress ( ) const

Return total virial stress.

Call only on master processor, after computeVirialStress. This method calls the stress() method of each potential class (pair, bond, etc.) and adds and returns the sum.

Returns
total virial stress (only correct on master node).

Definition at line 1925 of file ddMd/simulation/Simulation.cpp.

References Util::Tensor::zero().

Referenced by DdMd::StressAutoCorrelation::data(), DdMd::NphIntegrator::integrateStep1(), DdMd::NptIntegrator::integrateStep1(), DdMd::NphIntegrator::integrateStep2(), DdMd::NptIntegrator::integrateStep2(), DdMd::VirialStressTensor::sample(), DdMd::VirialStressTensorAverage::sample(), DdMd::OutputStressTensor::sample(), DdMd::StressAutoCorr::sample(), DdMd::VirialStressAnalyzer::value(), and DdMd::StressAnalyzer::value().

double DdMd::Simulation::virialPressure ( ) const

Return total virial pressure.

Call only on master processor, after computeVirialStress. Similar to virialStress, but returns average of diagonal elements.

Returns
total virial pressure (only correct on master node).

Definition at line 1951 of file ddMd/simulation/Simulation.cpp.

Referenced by DdMd::OutputPressure::sample(), and DdMd::PressureAnalyzer::value().

void DdMd::Simulation::unsetVirialStress ( )

Mark all virial stress contributions as unknown.

This method calls unsetStress for each potential energy.

Definition at line 2002 of file ddMd/simulation/Simulation.cpp.

References DdMd::Atom::hasAtomContext().

Referenced by loadParameters(), and readParameters().

const PairPotential & DdMd::Simulation::pairPotential ( ) const
inline
PairPotential & DdMd::Simulation::pairPotential ( )
inline

Get the PairPotential by reference.

Definition at line 1116 of file ddMd/simulation/Simulation.h.

std::string DdMd::Simulation::pairStyle ( ) const

Return nonbonded pair style string.

Definition at line 2102 of file ddMd/simulation/Simulation.cpp.

Factory< PairPotential > & DdMd::Simulation::pairFactory ( )

Get the Factory<PairPotential> by reference.

Definition at line 2090 of file ddMd/simulation/Simulation.cpp.

const BondPotential & DdMd::Simulation::bondPotential ( ) const
inline
BondPotential & DdMd::Simulation::bondPotential ( )
inline

Get the PairPotential by reference.

Definition at line 1129 of file ddMd/simulation/Simulation.h.

std::string DdMd::Simulation::bondStyle ( ) const

Return covalent bond style string.

Definition at line 2121 of file ddMd/simulation/Simulation.cpp.

Factory< BondPotential > & DdMd::Simulation::bondFactory ( )

Get the Factory<BondPotential> by reference.

Definition at line 2109 of file ddMd/simulation/Simulation.cpp.

const AnglePotential & DdMd::Simulation::anglePotential ( ) const
inline
AnglePotential & DdMd::Simulation::anglePotential ( )
inline

Get the AnglePotential by reference.

Definition at line 1143 of file ddMd/simulation/Simulation.h.

std::string DdMd::Simulation::angleStyle ( ) const

Return angle potential style string.

Definition at line 2141 of file ddMd/simulation/Simulation.cpp.

Factory< AnglePotential > & DdMd::Simulation::angleFactory ( )

Get the AngleFactory by reference.

Definition at line 2129 of file ddMd/simulation/Simulation.cpp.

const DihedralPotential & DdMd::Simulation::dihedralPotential ( ) const
inline
DihedralPotential & DdMd::Simulation::dihedralPotential ( )
inline

Get the DihedralPotential by reference.

Definition at line 1157 of file ddMd/simulation/Simulation.h.

std::string DdMd::Simulation::dihedralStyle ( ) const

Return dihedral potential style string.

Definition at line 2161 of file ddMd/simulation/Simulation.cpp.

Factory< DihedralPotential > & DdMd::Simulation::dihedralFactory ( )

Get the associated Dihedral Factory by reference.

Definition at line 2149 of file ddMd/simulation/Simulation.cpp.

const ExternalPotential & DdMd::Simulation::externalPotential ( ) const
inline
ExternalPotential & DdMd::Simulation::externalPotential ( )
inline

Get the ExternalPotential by reference.

Definition at line 1171 of file ddMd/simulation/Simulation.h.

std::string DdMd::Simulation::externalStyle ( ) const

Return external potential style string.

Definition at line 2181 of file ddMd/simulation/Simulation.cpp.

Factory< ExternalPotential > & DdMd::Simulation::externalFactory ( )

Get the associated External Factory by reference.

Definition at line 2169 of file ddMd/simulation/Simulation.cpp.

AtomStorage & DdMd::Simulation::atomStorage ( )
inline
BondStorage & DdMd::Simulation::bondStorage ( )
inline
AngleStorage & DdMd::Simulation::angleStorage ( )
inline

Get the AngleStorage by reference.

Definition at line 1095 of file ddMd/simulation/Simulation.h.

Referenced by DdMd::ConfigIo::ConfigIo(), and DdMd::TrajectoryWriter::TrajectoryWriter().

DihedralStorage & DdMd::Simulation::dihedralStorage ( )
inline
Domain & DdMd::Simulation::domain ( )
inline

Get the Domain by reference.

Definition at line 1083 of file ddMd/simulation/Simulation.h.

Referenced by DdMd::EnergyAnalyzer::clear(), DdMd::ExternalEnergyAnalyzer::compute(), DdMd::PairEnergyAnalyzer::compute(), DdMd::BondTensorAutoCorr::computeData(), DdMd::ConfigIo::ConfigIo(), DdMd::NphIntegrator::integrateStep1(), DdMd::NptIntegrator::integrateStep1(), DdMd::NphIntegrator::integrateStep2(), DdMd::NptIntegrator::integrateStep2(), DdMd::ExternalEnergyAverage::loadParameters(), DdMd::PairEnergyAverage::loadParameters(), DdMd::VirialStressTensorAverage::loadParameters(), DdMd::AverageAnalyzer::loadParameters(), DdMd::TensorAverageAnalyzer::loadParameters(), DdMd::SymmTensorAverageAnalyzer::loadParameters(), DdMd::EnergyAnalyzer::output(), DdMd::ExternalEnergyAverage::readParameters(), DdMd::PairEnergyAverage::readParameters(), DdMd::StressAutoCorr::readParameters(), DdMd::AutoCorrAnalyzer< Data, Product >::readParameters(), DdMd::AverageAnalyzer::readParameters(), DdMd::SymmTensorAverageAnalyzer::readParameters(), DdMd::TensorAverageAnalyzer::readParameters(), DdMd::OutputPairEnergies::sample(), DdMd::VirialStressTensorAverage::sample(), DdMd::LogEnergy::sample(), DdMd::OutputStressTensor::sample(), DdMd::OutputEnergy::sample(), DdMd::OutputTemperature::sample(), DdMd::OutputBoxdim::sample(), DdMd::OutputPressure::sample(), DdMd::StressAutoCorr::sample(), DdMd::EnergyAnalyzer::sample(), DdMd::OrderParamNucleation::sample(), DdMd::StructureFactor::sample(), DdMd::VanHove::sample(), and DdMd::TrajectoryWriter::TrajectoryWriter().

Boundary & DdMd::Simulation::boundary ( )
inline
AtomType & DdMd::Simulation::atomType ( int  i)
inline

Get an AtomType descriptor by reference.

Get an AtomType descriptor for a specific type by reference.

Parameters
iindex of desired atom type.

Definition at line 1255 of file ddMd/simulation/Simulation.h.

Referenced by DdMd::NptIntegrator::integrateStep2(), DdMd::NvtIntegrator::setup(), DdMd::NveIntegrator::setup(), DdMd::NphIntegrator::setup(), DdMd::NptIntegrator::setup(), and DdMd::NvtLangevinIntegrator::setup().

Integrator & DdMd::Simulation::integrator ( )
inline

Get the Integrator by reference.

Get the MD integrator by reference.

Definition at line 1179 of file ddMd/simulation/Simulation.h.

EnergyEnsemble & DdMd::Simulation::energyEnsemble ( )
inline
BoundaryEnsemble & DdMd::Simulation::boundaryEnsemble ( )
inline
FileMaster & DdMd::Simulation::fileMaster ( )
inline

Get the associated FileMaster by reference.

Get the FileMaster by reference.

Definition at line 1204 of file ddMd/simulation/Simulation.h.

Referenced by DdMd::OutputStressTensor::loadParameters(), DdMd::OutputEnergy::loadParameters(), DdMd::OutputTemperature::loadParameters(), DdMd::OutputPressure::loadParameters(), DdMd::VirialStressTensor::loadParameters(), DdMd::OutputPairEnergies::loadParameters(), DdMd::VirialStressTensorAverage::loadParameters(), DdMd::ExternalEnergyAverage::output(), DdMd::PairEnergyAverage::output(), DdMd::StressAutoCorr::output(), DdMd::AutoCorrAnalyzer< Data, Product >::output(), DdMd::AverageAnalyzer::output(), DdMd::EnergyAnalyzer::output(), DdMd::SymmTensorAverageAnalyzer::output(), DdMd::TensorAverageAnalyzer::output(), DdMd::OrderParamNucleation::output(), DdMd::StructureFactorGrid::output(), DdMd::StructureFactor::output(), DdMd::VanHove::output(), DdMd::OutputStressTensor::readParameters(), DdMd::OutputBoxdim::readParameters(), DdMd::OutputTemperature::readParameters(), DdMd::OutputEnergy::readParameters(), DdMd::VirialStressTensor::readParameters(), DdMd::OutputPairEnergies::readParameters(), DdMd::OutputPressure::readParameters(), DdMd::VirialStressTensorAverage::readParameters(), DdMd::StructureFactorGrid::sample(), DdMd::StructureFactor::sample(), DdMd::OutputStressTensor::setup(), DdMd::OutputBoxdim::setup(), DdMd::OutputTemperature::setup(), DdMd::OutputEnergy::setup(), DdMd::OutputPressure::setup(), DdMd::TrajectoryWriter::setup(), DdMd::AverageAnalyzer::setup(), DdMd::EnergyAnalyzer::setup(), DdMd::TensorAverageAnalyzer::setup(), and DdMd::SymmTensorAverageAnalyzer::setup().

Random & DdMd::Simulation::random ( )
inline

Get the Random number generator by reference.

Get the Random RNG by reference.

Definition at line 1186 of file ddMd/simulation/Simulation.h.

Referenced by DdMd::NvtLangevinIntegrator::integrateStep2().

Exchanger & DdMd::Simulation::exchanger ( )
inline

Get the Exchanger by reference.

Definition at line 1104 of file ddMd/simulation/Simulation.h.

Referenced by DdMd::Integrator::clear().

Buffer & DdMd::Simulation::buffer ( )
inline

Get the Buffer by reference.

Definition at line 1107 of file ddMd/simulation/Simulation.h.

Referenced by DdMd::Integrator::clear(), and DdMd::ConfigIo::ConfigIo().

ModifierManager & DdMd::Simulation::modifierManager ( )
inline

Return the ModifierManager by reference.

Get the ModifierManager by reference.

Definition at line 1212 of file ddMd/simulation/Simulation.h.

Referenced by DdMd::TwoStepIntegrator::run().

AnalyzerManager & DdMd::Simulation::analyzerManager ( )
inline

Return the AnalyzerManager by reference.

Get the AnalyzerManager by reference.

Definition at line 1220 of file ddMd/simulation/Simulation.h.

Referenced by DdMd::Integrator::clear(), and DdMd::TwoStepIntegrator::run().

Factory< Integrator > & DdMd::Simulation::integratorFactory ( )

Get the Integrator factory by reference.

Definition at line 2190 of file ddMd/simulation/Simulation.cpp.

int DdMd::Simulation::nAtomType ( )
inline
int DdMd::Simulation::nBondType ( )
inline
int DdMd::Simulation::nAngleType ( )
inline
int DdMd::Simulation::nDihedralType ( )
inline
bool DdMd::Simulation::hasExternal ( )
inline
MaskPolicy DdMd::Simulation::maskedPairPolicy ( ) const
inline

Return the value of the mask policy (MaskNone or MaskBonded).

Get the masked pair policy.

Definition at line 1259 of file ddMd/simulation/Simulation.h.

bool DdMd::Simulation::reverseUpdateFlag ( ) const
inline

Is reverse communication enabled?

Get the reverse update flag.

Definition at line 1263 of file ddMd/simulation/Simulation.h.

Signal & DdMd::Simulation::modifySignal ( )
inline

Signal to force unsetting of quantities that depend on x, v, or f.

Signal to force unsetting of all computed quantities.

Definition at line 1269 of file ddMd/simulation/Simulation.h.

Referenced by DdMd::TwoStepIntegrator::run().

Signal & DdMd::Simulation::positionSignal ( )
inline

Signal to indicate change in atomic positions.

Definition at line 1273 of file ddMd/simulation/Simulation.h.

Signal & DdMd::Simulation::velocitySignal ( )
inline
Signal & DdMd::Simulation::exchangeSignal ( )
inline

Signal to indicate exchange of atoms and groups.

Signal to indicate exchange of atom ownership.

Definition at line 1281 of file ddMd/simulation/Simulation.h.

Referenced by DdMd::TwoStepIntegrator::run().

void DdMd::Simulation::outputOptions ( std::ostream &  out) const

Output a list of options enabled & disabled during compilation.

Parameters
outoutput stream

Definition at line 2286 of file ddMd/simulation/Simulation.cpp.

bool DdMd::Simulation::isValid ( )

Return true if this Simulation is valid, or throw an Exception.

Definition at line 2338 of file ddMd/simulation/Simulation.cpp.

References Util::bcast().

Referenced by DdMd::TwoStepIntegrator::run().

void DdMd::Simulation::readFileMaster ( std::istream &  in)
protected

Read the FileMaster.

Parameters
ininput parameter stream

Definition at line 1019 of file ddMd/simulation/Simulation.cpp.

void DdMd::Simulation::loadFileMaster ( Serializable::IArchive ar)
protected

Load FileMaster from an archive.

Parameters
arinput/loading archive

Definition at line 1029 of file ddMd/simulation/Simulation.cpp.

void DdMd::Simulation::saveFileMaster ( Serializable::OArchive ar)
protected

Save FileMaster to archive.

Parameters
aroutput/saving archive

Definition at line 1039 of file ddMd/simulation/Simulation.cpp.

void DdMd::Simulation::readPotentialStyles ( std::istream &  in)
protected

Read potential styles and maskedPairPolicy.

Parameters
ininput parameter stream

Definition at line 1045 of file ddMd/simulation/Simulation.cpp.

void DdMd::Simulation::loadPotentialStyles ( Serializable::IArchive ar)
protected

Load potential styles.

Parameters
arinput/loading archive

Definition at line 1081 of file ddMd/simulation/Simulation.cpp.

void DdMd::Simulation::savePotentialStyles ( Serializable::OArchive ar)
protected

Save potential styles to archive.

Parameters
aroutput/saving archive

Definition at line 1113 of file ddMd/simulation/Simulation.cpp.

void DdMd::Simulation::readEnsembles ( std::istream &  in)
protected

Read energy and boundary ensembles.

Parameters
ininput parameter stream

Definition at line 1143 of file ddMd/simulation/Simulation.cpp.

void DdMd::Simulation::loadEnsembles ( Serializable::IArchive ar)
protected

Load energy and boundary ensembles from an input archive.

Parameters
arinput/loading archive

Definition at line 1152 of file ddMd/simulation/Simulation.cpp.

void DdMd::Simulation::saveEnsembles ( Serializable::OArchive ar)
protected

Save energy and boundary ensembles to archive.

Parameters
aroutput/saving archive

Definition at line 1161 of file ddMd/simulation/Simulation.cpp.


The documentation for this class was generated from the following files: