Simpatico
v1.10
|
A Modifier can modify the time evolution of the simulation.
Modifier is an abstract base class for classes that can modify the system during an MD simulation, and thus modify the time evolution defined by the integrator. The class declares a variety of virtual functions that, when re-implemented and activated by subclasses, will be invoked at specific points during the main integration loop, thus allowing the designer of a subclass to add almost arbitrary actions to the underlying integration algorithm.
The Modifier class declares interfaces for several virtual functions that that the integrator can be instructed to invoke at specific points within the body of the main integration loop. We refer to theses as integrator action functions. The name of each such function describes when it will be invoked. For example, the postForce() function is invoked (if at all) immediately after evaluation of all forces within the main integration loop. Modifier also declares several virtual functions with names that contain the words "pack" and "unpack", which we will call communication functions, that may be defined by subclasses to pack additional information into the messages that are communicated between processors during exchange and update steps.
Each subclass of Modifier will normally implement only a few of these possible action and communication functions. To record which virtual functions it defines, each subclass must also "activate" each such function by invoking the set() function within its constructor passing this function a named constant that activates a particular virtual function. Thus, for example, a subclass that implements the virtual postForce() function must also call the function set(Flags::PostForce) in its constructor. The constant Flags::PostForce and other named constants are defined as static constant members of the Modifier::Flags nested class. The name of each such constant is given by a capitalized version of the name of the corresponding virtual function. When the set() function is invoked to activate an integrator or communication function, it adds that function to list of functions that will be invoked at the appropriate point in the integration algorithm. The constants associated with communcation functions each activate a pair of associated "pack" and "unpack" function that must work together pack additional information into an MPI message on one processor and unpack it at the receiving processor.
Each Modifier also has an integer member named interval that determines the interval, in time steps, with which integrator actions should be taken. An activated integrator action function will be executed only during time steps that are multiples of this interval. Each Modifier object has a single interval value, which applies to all action function that it implements and activates. The value of the interval is initialized to 1 (i.e., every time step) in the base Modifier class constructor, but may be reset in the subclass readParameters function by invoking the readInterval() function to read a value from file.
The design of the Modifier class was inspired by the Lammps "Fix" base class, which provides a very flexible framework for designing algorithms that can modify the state of a system.
Definition at line 82 of file Modifier.h.
#include <Modifier.h>
Classes | |
class | Flags |
Bit flag constants associated with particular actions. More... | |
Public Member Functions | |
Modifier () | |
Default constructor (for unit testing) More... | |
Modifier (Simulation &simulation) | |
Constructor (for use in simulation). More... | |
virtual | ~Modifier () |
Destructor. More... | |
Integration action functions | |
virtual void | setup () |
Setup before entering the main loop. More... | |
virtual void | preIntegrate1 (long iStep) |
Call just before the first step of velocity-Verlet algorithm. More... | |
virtual void | postIntegrate1 (long iStep) |
Call just after the first step of velocity-Verlet algorithm. More... | |
virtual void | preTransform (long iStep) |
Call on exchange steps before transforming to scaled atomic coordinates. More... | |
virtual void | preExchange (long iStep) |
Call on exchange steps after transforming but before exchanging atoms. More... | |
virtual void | postExchange (long iStep) |
Call on exchange steps after atom exchange, before reneighboring. More... | |
virtual void | postNeighbor (long iStep) |
Call on exchange steps after re-building neighbor list (reneighboring). More... | |
virtual void | preUpdate (long iStep) |
Call on update steps before updating ghost positions. More... | |
virtual void | postUpdate (long iStep) |
Call on update steps after updating ghost positions. More... | |
virtual void | preForce (long iStep) |
Call after updating but before calculating forces. More... | |
virtual void | postForce (long iStep) |
Call after calculating forces. More... | |
virtual void | endOfStep (long iStep) |
Call at the end of the time step. More... | |
Interprocessor communication action functions | |
virtual void | packExchange () |
Pack data into buffer used to exchange atoms. More... | |
virtual void | unpackExchange () |
Unpack data from buffer used to exchange atoms. More... | |
virtual void | packUpdate () |
Pack data into buffer used to update ghost positions. More... | |
virtual void | unpackUpdate () |
Unpack data from buffer used to update ghost positions. More... | |
virtual void | packReverseUpdate () |
Pack data into buffer used to reverse update forces. More... | |
virtual void | unpackReverseUpdate () |
Unpack data from the buffer used to reverse update forces. More... | |
Bit Flags | |
bool | isSet (Bit flag) const |
Return true if a flag is set, false otherwise. More... | |
unsigned int | flags () const |
Return the unsigned int representation of all bit flags. More... | |
Interval functions | |
int | interval () const |
Get interval value. More... | |
bool | isAtInterval (long iStep) const |
Return true iff iStep is a multiple of the interval. More... | |
![]() | |
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 | readParam (std::istream &in) |
Read the parameter file block. More... | |
virtual void | readParamOptional (std::istream &in) |
Read optional parameter file block. More... | |
virtual void | readParameters (std::istream &in) |
Read the body of parameter block, without begin and end lines. 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... | |
virtual void | loadParameters (Serializable::IArchive &ar) |
Load state from archive, without adding Begin and End lines. More... | |
virtual void | save (Serializable::OArchive &ar) |
Saves all parameters to an archive. 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... | |
Begin & | readBegin (std::istream &in, const char *label, bool isRequired=true) |
Add and read a class label and opening bracket. More... | |
End & | readEnd (std::istream &in) |
Add and read the closing bracket. More... | |
Blank & | readBlank (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... | |
Begin & | addBegin (const char *label) |
Add a Begin object representing a class name and bracket. More... | |
End & | addEnd () |
Add a closing bracket. More... | |
Blank & | addBlank () |
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... | |
![]() | |
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... | |
![]() | |
virtual | ~Serializable () |
Destructor. More... | |
![]() | |
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... | |
Static Public Member Functions | |
static void | initStatic () |
Call this to guarantee initialization of static variables. More... | |
![]() | |
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... | |
Protected Member Functions | |
Simulation & | simulation () |
Get the parent Simulation by reference. More... | |
void | set (Bit flag) |
Set the flag associated with a particular action. More... | |
void | readInterval (std::istream &in) |
Read parameter interval from file. More... | |
void | loadInterval (Serializable::IArchive &ar) |
Load parameter interval from input archive. More... | |
void | saveInterval (Serializable::OArchive &ar) |
Save interval parameter to an archive. More... | |
![]() | |
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 ¶m, bool next=true) |
Set this to the parent of a child component. More... | |
void | addComponent (ParamComponent ¶m, 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... | |
![]() | |
ParamComponent () | |
Constructor. More... | |
ParamComponent (const ParamComponent &other) | |
Copy constructor. More... | |
Additional Inherited Members | |
![]() | |
typedef BinaryFileOArchive | OArchive |
Type of output archive used by save method. More... | |
typedef BinaryFileIArchive | IArchive |
Type of input archive used by load method. More... | |
DdMd::Modifier::Modifier | ( | ) |
Default constructor (for unit testing)
Definition at line 49 of file Modifier.cpp.
DdMd::Modifier::Modifier | ( | Simulation & | simulation | ) |
Constructor (for use in simulation).
Definition at line 59 of file Modifier.cpp.
|
virtual |
Destructor.
Definition at line 69 of file Modifier.cpp.
|
inlinevirtual |
Setup before entering the main loop.
Definition at line 108 of file Modifier.h.
|
inlinevirtual |
Call just before the first step of velocity-Verlet algorithm.
Atom positions are Cartesian on entry and return.
Definition at line 115 of file Modifier.h.
Referenced by DdMd::ModifierManager::preIntegrate1().
|
inlinevirtual |
Call just after the first step of velocity-Verlet algorithm.
Atom positions are Cartesian on entry and return.
Definition at line 122 of file Modifier.h.
Referenced by DdMd::ModifierManager::postIntegrate1().
|
inlinevirtual |
Call on exchange steps before transforming to scaled atomic coordinates.
Atom positions are Cartesian on entry and return.
Definition at line 129 of file Modifier.h.
Referenced by DdMd::ModifierManager::preTransform().
|
inlinevirtual |
Call on exchange steps after transforming but before exchanging atoms.
Atom positions are scaled [0,1] on entry and return.
Definition at line 136 of file Modifier.h.
Referenced by DdMd::ModifierManager::preExchange().
|
inlinevirtual |
Call on exchange steps after atom exchange, before reneighboring.
Atom positions are scaled [0,1] on entry and return.
Definition at line 143 of file Modifier.h.
Referenced by DdMd::ModifierManager::postExchange().
|
inlinevirtual |
Call on exchange steps after re-building neighbor list (reneighboring).
Atom positions are scaled [0,1] on entry and return.
Definition at line 150 of file Modifier.h.
Referenced by DdMd::ModifierManager::postNeighbor().
|
inlinevirtual |
Call on update steps before updating ghost positions.
Atom positions are Cartesian on entry and return.
Definition at line 157 of file Modifier.h.
Referenced by DdMd::ModifierManager::preUpdate().
|
inlinevirtual |
Call on update steps after updating ghost positions.
Atom positions are Cartesian on entry and return.
Definition at line 164 of file Modifier.h.
Referenced by DdMd::ModifierManager::postUpdate().
|
inlinevirtual |
Call after updating but before calculating forces.
Atom positions are Cartesian on entry and return.
Definition at line 171 of file Modifier.h.
Referenced by DdMd::ModifierManager::preForce().
|
inlinevirtual |
Call after calculating forces.
Atom positions are Cartesian on entry and return.
Definition at line 178 of file Modifier.h.
Referenced by DdMd::ModifierManager::postForce().
|
inlinevirtual |
Call at the end of the time step.
Atom positions are Cartesian on entry and return.
Definition at line 185 of file Modifier.h.
Referenced by DdMd::ModifierManager::endOfStep().
|
inlinevirtual |
Pack data into buffer used to exchange atoms.
Definition at line 194 of file Modifier.h.
Referenced by DdMd::ModifierManager::packExchange().
|
inlinevirtual |
Unpack data from buffer used to exchange atoms.
Definition at line 199 of file Modifier.h.
Referenced by DdMd::ModifierManager::unpackExchange().
|
inlinevirtual |
Pack data into buffer used to update ghost positions.
Definition at line 204 of file Modifier.h.
Referenced by DdMd::ModifierManager::packUpdate().
|
inlinevirtual |
Unpack data from buffer used to update ghost positions.
Definition at line 209 of file Modifier.h.
Referenced by DdMd::ModifierManager::unpackUpdate().
|
inlinevirtual |
Pack data into buffer used to reverse update forces.
Will only be used if reverse communication is enabled.
Definition at line 216 of file Modifier.h.
Referenced by DdMd::ModifierManager::packReverseUpdate().
|
inlinevirtual |
Unpack data from the buffer used to reverse update forces.
Will only be used if reverse communication is enabled.
Definition at line 223 of file Modifier.h.
Referenced by DdMd::ModifierManager::unpackReverseUpdate().
bool DdMd::Modifier::isSet | ( | Bit | flag | ) | const |
Return true if a flag is set, false otherwise.
Definition at line 75 of file Modifier.cpp.
References Util::Bit::isSet().
Referenced by DdMd::ModifierManager::readParameters().
unsigned int DdMd::Modifier::flags | ( | ) | const |
Return the unsigned int representation of all bit flags.
Definition at line 81 of file Modifier.cpp.
|
inline |
Get interval value.
Definition at line 379 of file Modifier.h.
|
inline |
Return true iff iStep is a multiple of the interval.
iStep | simulation step iStep |
Definition at line 385 of file Modifier.h.
Referenced by DdMd::ModifierManager::endOfStep(), DdMd::ModifierManager::postExchange(), DdMd::ModifierManager::postForce(), DdMd::ModifierManager::postIntegrate1(), DdMd::ModifierManager::postNeighbor(), DdMd::ModifierManager::postUpdate(), DdMd::ModifierManager::preExchange(), DdMd::ModifierManager::preForce(), DdMd::ModifierManager::preIntegrate1(), DdMd::ModifierManager::preTransform(), and DdMd::ModifierManager::preUpdate().
|
static |
Call this to guarantee initialization of static variables.
Definition at line 37 of file Modifier.cpp.
Referenced by DdMd::initStatic().
|
inlineprotected |
Get the parent Simulation by reference.
Definition at line 391 of file Modifier.h.
|
protected |
Set the flag associated with a particular action.
Definition at line 89 of file Modifier.cpp.
References Util::Bit::set().
|
protected |
Read parameter interval from file.
in | input parameter file stream. |
Definition at line 95 of file Modifier.cpp.
References UTIL_THROW.
|
protected |
Load parameter interval from input archive.
ar | input archive |
Definition at line 114 of file Modifier.cpp.
References UTIL_THROW.
|
protected |
Save interval parameter to an archive.
ar | output archive |
Definition at line 130 of file Modifier.cpp.