23 #include "vesselbase/Vessel.h"
24 #include "tools/Pbc.h"
31 namespace multicolvar{
33 void MultiColvarBase::registerKeywords(
Keywords& keys ){
34 Action::registerKeywords( keys );
35 ActionWithValue::registerKeywords( keys );
36 ActionAtomistic::registerKeywords( keys );
37 keys.
addFlag(
"NOPBC",
false,
"ignore the periodic boundary conditions when calculating distances");
38 ActionWithVessel::registerKeywords( keys );
40 keys.
add(
"hidden",
"NL_STRIDE",
"the frequency with which the neighbor list should be updated. Between neighbour list update steps all quantities "
41 "that contributed less than TOL at the previous neighbor list update step are ignored.");
42 keys.
setComponentsIntroduction(
"This Action can be used to calculate the following quantities by employing the keywords listed below. "
43 "You must select which from amongst these quantities you wish to calculate - this command cannot be run "
44 "unless one of the quantities below is being calculated."
45 "These quantities can then be referenced elsewhere in the input file by using this Action's label "
46 "followed by a dot and the name of the quantity. Some amongst them can be calculated multiple times "
47 "with different parameters. In this case the quantities calculated can be referenced elsewhere in the "
48 "input by using the name of the quantity followed by a numerical identifier "
49 "e.g. <em>label</em>.less_than-1, <em>label</em>.less_than-2 etc.");
67 else log.
printf(
" Updating contributors every step.\n");
72 for(
unsigned i=0;i<newatoms.size();++i) newlist.
addIndexToList( newatoms[i] );
90 bool updatetime=
false;
166 return df[0]*
central_derivs[iatom](0,jcomp) + df[1]*central_derivs[iatom](1,jcomp) + df[2]*central_derivs[iatom](2,jcomp);
171 else{
return delta( vec1, vec2 ); }
183 for(
unsigned j=0;j<9;++j){
197 for(
unsigned j=0;j<9;++j){
211 if( mycatoms )
return mycatoms;
void setupMPICommunication(Communicator &comm)
Setup MPI communication if things are activated/deactivated on different nodes.
void setComponentsIntroduction(const std::string &instr)
Set the text that introduces how the components for this action are introduced.
std::vector< Tensor > central_derivs
void parseFlag(const std::string &key, bool &t)
Parse one keyword as boolean flag.
unsigned current
The numerical index of the task we are curently performing.
void addCentralAtomDerivatives(const unsigned &iatom, const Tensor &der)
Add derivative of central atom position wrt to position of iatom'th atom.
Log & log
Reference to the log stream.
Vector getSeparation(const Vector &vec1, const Vector &vec2) const
Get the separation between a pair of vectors.
TensorGeneric< m, n > transpose() const
return the transpose matrix
void mpi_gatherActiveMembers(Communicator &comm, std::vector< DynamicList< U > > &ll)
void prepare()
Prepare for the calculation.
Class implementing fixed size matrices of doubles.
Class implementing fixed size vectors of doubles.
void resizeLocalArrays()
This resizes the local arrays after neighbor list updates and during initialization.
void setElementDerivative(const unsigned &, const double &)
Set the derivative of the jth element wrt to a numbered element.
virtual void resizeDynamicArrays()=0
double getElementDerivative(const unsigned &) const
Retrieve the derivative of the quantity in the sum wrt to a numbered element.
void add(const std::string &t, const std::string &k, const std::string &d)
Add a new keyword of type t with name k and description d.
void addVessel(const std::string &name, const std::string &input, const int numlab=0, const std::string thislab="")
Add a vessel to the list of vessels.
void activate(const unsigned ii)
Make something active.
void clearDerivativesAfterTask(const unsigned &ider)
void addColvar(const std::vector< unsigned > &newatoms)
Add a colvar to the set of colvars we are calculating (in practise just a list of atoms) ...
virtual void calculateWeight()
You can use this to screen contributions that are very small so we can avoid expensive (and pointless...
friend class StoreCentralAtomsVessel
void setupMultiColvarBase()
Finish setting up the multicolvar base.
bool getForcesFromVessels(std::vector< double > &forcesToApply)
Retrieve the forces from all the vessels (used in apply)
const Pbc & getPbc() const
Get reference to Pbc.
std::vector< double > forcesToApply
The forces we are going to apply to things.
void apply()
Apply the forces from this action.
Used to create a PLMD::Action that has some scalar or vectorial output that may or may not have some ...
DynamicList< unsigned > atomsWithCatomDer
void parse(const std::string &key, T &t)
Parse one keyword as generic type.
This class holds the keywords and their documentation.
void clear()
Clear the list.
std::vector< DynamicList< unsigned > > colvar_atoms
The lists of the atoms involved in each of the individual colvars note these refer to the atoms in al...
This class is used to bring the relevant information to the Action constructor.
virtual Vector calculateCentralAtomPosition()=0
A virtual routine to get the position of the central atom - used for things like cv gradient...
Action used to create objects that access the positions of the atoms from the MD code.
void addIndexToList(const T &ii)
Add something to the active list.
StoreCentralAtomsVessel * getCentralAtoms()
Return a pointer to the vessel that stores the positions of all the central atoms.
void mergeDerivatives(const unsigned &ider, const double &df)
These replace the functions in ActionWithVessel to make the code faster.
bool usepbc
Use periodic boundary conditions.
int printf(const char *fmt,...)
Formatted output with explicit format - a la printf.
void setElementValue(const unsigned &, const double &)
Set the value of the element.
Base class for all the input Actions.
virtual void lockContributors()
VectorGeneric< n > delta(const VectorGeneric< n > &v1, const VectorGeneric< n > &v2)
bool isActive(const unsigned &) const
Find out if a member is active.
virtual void unlockContributors()
Used to make sure we are calculating everything during neighbor list update step. ...
void accumulateDerivative(const unsigned &ider, const double &df)
This is used to accumulate the derivatives when we merge using chainRuleForElementDerivatives.
void use(const std::string &k)
Use one of the reserved keywords.
const Tensor & getInvBox() const
Returns the inverse matrix of box.
DynamicList< unsigned > taskList
The list of tasks we have to perform.
Vector retrieveCentralAtomPos()
Retrieve the position of the central atom.
This class is used to pass the input to Vessels.
unsigned getNumberOfVessels() const
Get the number of vessels.
double getTolerance() const
Return the value of the tolerance.
long int getStep() const
Return the present timestep.
bool exists(const std::string &k) const
Check if there is a keyword with name k.
Tensor ibox
Variables used for central atoms.
friend void mpi_gatherActiveMembers(Communicator &, std::vector< DynamicList< U > > &)
This gathers data split across nodes list of Dynamic lists.
virtual double doCalculation(const unsigned &j)=0
And a virtual function which actually computes the colvar.
Vector pbcDistance(const Vector &, const Vector &) const
Compute the pbc distance between two positions.
DynamicList< unsigned > atoms_with_derivatives
A dynamic list containing those atoms with derivatives.
void performTask(const unsigned &j)
Perform one of the tasks.
unsigned getNumberOfDerivatives()
Get the number of derivatives for this action.
void setForcesOnAtoms(const std::vector< double > &forcesToApply, unsigned ind=0)
Add the forces to the atoms.
unsigned getNumberOfAtoms() const
Get number of available atoms.
double getCentralAtomDerivative(const unsigned &iatom, const unsigned jcomp, const Vector &df) const
Retrieve derivative of central atom position wrt jcomp'th component of position of iatom'th atom...
const Keywords & keywords
void deactivateAll()
Make everything in the list inactive.
bool contributorsAreUnlocked
The terms in the series are locked.
void resizeFunctions()
Resize all the functions when the number of derivatives change.
void activateAll()
Make everything in the list active.
int updateFreq
Everything for controlling the updating of neighbor lists.
unsigned getNumberActive() const
Return the number of elements that are currently active.
void addFlag(const std::string &k, const bool def, const std::string &d)
Add a falg with name k that is by default on if def is true and off if def is false. d should provide a description of the flag.
Vessel * getPntrToVessel(const unsigned &i)
Get a pointer to the ith vessel.
double getElementValue(const unsigned &ival) const
Get the value of this element.