22 #include "core/PlumedMain.h"
23 #include "core/ActionSet.h"
27 namespace multicolvar {
33 ActionWithVessel::registerKeywords( keys );
34 keys.
setComponentsIntroduction(
"This Action can be used to calculate the following quantities by employing the keywords listed below. "
35 "You must select which from amongst these quantities you wish to calculate - this command cannot be run "
36 "unless one of the quantities below is being calculated."
37 "These quantities can then be referenced elsewhere in the input file by using this Action's label "
38 "followed by a dot and the name of the quantity. Some amongst them can be calculated multiple times "
39 "with different parameters. In this case the quantities calculated can be referenced elsewhere in the "
40 "input by using the name of the quantity followed by a numerical identifier "
41 "e.g. <em>label</em>.less_than-1, <em>label</em>.less_than-2 etc.");
42 keys.
use(
"MEAN"); keys.
use(
"LESS_THAN"); keys.
use(
"MORE_THAN");
43 keys.
use(
"BETWEEN"); keys.
use(
"HISTOGRAM");
44 keys.
add(
"compulsory",
"ARG",
"the label of the action that calculates the multicolvar we are interested in");
45 keys.
add(
"compulsory",
"SIGMA",
"the width of the function to be used for kernel density estimation");
46 keys.
add(
"compulsory",
"KERNEL",
"gaussian",
"the type of kernel function to be used");
47 keys.
addFlag(
"OUTSIDE",
false,
"calculate quantities for colvars that are on atoms outside the region of interest");
49 keys.
add(
"hidden",
"NL_STRIDE",
"the frequency with which the neighbor list should be updated. Between neighbour list update steps all quantities "
50 "that contributed less than TOL at the previous neighbor list update step are ignored.");
61 std::string mlab;
parse(
"ARG",mlab);
63 if(!
mycolv)
error(
"action labeled " + mlab +
" does not exist or is not a multicolvar");
65 std::transform( functype.begin(), functype.end(), functype.begin(), tolower );
66 log.
printf(
" calculating %s inside region of insterest\n",functype.c_str() );
79 error(
"update frequency must be a multiple of update frequency for base multicolvar");
83 log.
printf(
" Updating contributors every step.\n");
88 std::string kerneltype;
parse(
"KERNEL",kerneltype);
115 ActionWithVessel::doJobsRequiredBeforeTaskList();
119 bool updatetime=
false;
146 double weight;
Vector wdf;
148 if(
not_in ){ weight = 1.0 - weight; wdf *= -1.; }
171 for(
unsigned i=0;i<9;++i){
189 for(
unsigned i=0;i<9;++i){
217 for(
unsigned j=0;j<9;++j){
240 for(
unsigned j=0;j<9;++j){
261 plumed_merror(
"This should never be called");
265 plumed_dbg_assert( bb.size()==
tmpforces.size()-9 );
267 for(
unsigned i=0;i<bb.size();++i)
tmpforces[i]=bb[i];
269 for(
unsigned i=bb.size();i<bb.size()+9;++i)
tmpforces[i]=0.0;
BridgeVessel * addBridgingVessel(ActionWithVessel *tome)
Add a bridging vessel to the list of vessels.
void setComponentsIntroduction(const std::string &instr)
Set the text that introduces how the components for this action are introduced.
void doJobsRequiredBeforeTaskList()
Do jobs required before tasks are undertaken.
static void registerKeywords(Keywords &keys)
Register all the relevant keywords for the action.
void parseFlag(const std::string &key, bool &t)
Parse one keyword as boolean flag.
Log & log
Reference to the log stream.
static void registerKeywords(Keywords &keys)
double sigma
The value of sigma.
void applyBridgeForces(const std::vector< double > &bb)
Forces here are applied through the bridge.
Class implementing fixed size vectors of doubles.
void setKernelType(const std::string &ktype)
void setElementDerivative(const unsigned &, const double &)
Set the derivative of the jth element wrt to a numbered element.
void addElementDerivative(const unsigned &, const double &)
Add some derivative of the quantity in the sum wrt to a numbered element.
DynamicList< unsigned > activeAtoms
Fast merging of derivatives (automatic skips of zero contributions)
void error(const std::string &msg) const
Crash calculation and print documentation.
virtual void setupRegion()=0
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 calculateNumericalDerivatives(ActionWithValue *a=NULL)
We need our own calculate numerical derivatives here.
void prepare()
Jobs to be done when the action is activated.
void updateActiveMembers()
Get the list of active members.
unsigned bridgeVariable
This is used for numerical derivatives of bridge variables.
bool not_in
Are we interested in the area outside the colvar.
void mergeDerivatives(const unsigned &ider, const double &df)
These routines replace the virtual routines in ActionWithVessel for code optimization.
void readVesselKeywords()
Complete the setup of this object (this routine must be called after construction of ActionWithValue)...
bool weightHasDerivatives
Does the weight have derivatives.
void addDependency(Action *)
Specify that this Action depends on another one.
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.
unsigned getNumberOfDerivatives()
Get the number of derivatives for this action.
This class holds the keywords and their documentation.
void clear()
Clear the list.
bool isPeriodic()
Is the output quantity periodic.
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 bool isDensity()
Is this a density?
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.
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.
const std::string & getName() const
Returns the name.
Base class for all the input Actions.
virtual void lockContributors()
static void registerKeywords(Keywords &keys)
Register all the relevant keywords for the action.
ActionVolume(const ActionOptions &)
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 deactivate_task()
Routines that have to be defined so as not to have problems with virtual methods. ...
void use(const std::string &k)
Use one of the reserved keywords.
DynamicList< unsigned > taskList
The list of tasks we have to perform.
Vector retrieveCentralAtomPos()
Retrieve the position of the central atom.
MultiColvarBase * mycolv
The action that is calculating the colvars of interest.
void resizeLocalArrays()
This sets up array above.
bool checkNumericalDerivatives() const
Check if numerical derivatives should be used.
unsigned getNumberOfVessels() const
Get the number of vessels.
int updateFreq
Everything for controlling the updating of neighbor lists.
void performTask(const unsigned &i)
This calculates all the vessels and is called from within a bridge vessel.
long int getStep() const
Return the present timestep.
HistogramBead bead
The bead for the histogram.
virtual double calculateNumberInside(const Vector &cpos, HistogramBead &bead, Vector &derivatives)=0
virtual bool isPeriodic()=0
Are the base quantities periodic.
void clearDerivativesAfterTask(const unsigned &ider)
virtual void clearDerivatives()
Clear the derivatives of values wrt parameters.
void requestAtoms(const std::vector< AtomNumber > &a)
Request an array of atoms.
void useNumericalDerivatives()
This forces the class to use numerical derivatives.
DynamicList< unsigned > atoms_with_derivatives
A dynamic list containing those atoms with derivatives.
void completeNumericalDerivatives()
Calculate numerical derivatives.
void setForcesOnAtoms(const std::vector< double > &forcesToApply, unsigned ind=0)
Add the forces to the atoms.
unsigned getNumberOfAtoms() const
Get number of available atoms.
static void registerKeywords(Keywords &keys)
vesselbase::BridgeVessel * myBridgeVessel
The vessel that bridges.
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...
void deactivateAll()
Make everything in the list inactive.
bool contributorsAreUnlocked
The terms in the series are locked.
std::vector< double > tmpforces
This is used to store forces temporarily in apply.
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.
double getElementValue(const unsigned &ival) const
Get the value of this element.
void requestAtoms(const std::vector< AtomNumber > &atoms)
Request the atoms.