Skip to content
Snippets Groups Projects
Commit 4bb2fb1c authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Added virtual method update() to Action

Small change in the mani flow. Now, after the backward loop to apply
forces, there is another forward loop calling "update()". update() should
be used to dump/analyse data, and/or to modify a biasing potential
(e.g. in metadynamics or tamd). Also, since it is called after full
calculation, analysis tools could access to more quantities (e.g.: forces
on a specific CV have been already computed and could be dumped).
parent cc0164dd
No related branches found
No related tags found
No related merge requests found
......@@ -128,6 +128,11 @@ public:
/// The set of all Actions is applied in backward order.
virtual void apply()=0;
/// Update.
/// This method is called one time per step.
/// The set of all Actions is updated in forward order.
virtual void update(){};
/// Tell to the Action to flush open files
void fflush();
......
......@@ -34,7 +34,8 @@ public:
GenericDumpAtoms(const ActionOptions&);
~GenericDumpAtoms();
void calculate(){};
void apply();
void apply(){};
void update();
};
PLUMED_REGISTER_ACTION(GenericDumpAtoms,"DUMPATOMS")
......@@ -54,7 +55,7 @@ GenericDumpAtoms::GenericDumpAtoms(const ActionOptions&ao):
requestAtoms(atoms);
}
void GenericDumpAtoms::apply(){
void GenericDumpAtoms::update(){
fprintf(fp,"%d\n",getNatoms());
const Tensor & t(getPbc().getBox());
if(getPbc().isOrthorombic()){
......
......@@ -47,7 +47,8 @@ public ActionWithArguments
public:
void calculate(){};
GenericDumpDerivatives(const ActionOptions&);
void apply();
void apply(){};
void update();
~GenericDumpDerivatives();
};
......@@ -81,7 +82,7 @@ fp(NULL)
}
void GenericDumpDerivatives::apply(){
void GenericDumpDerivatives::update(){
if(comm.Get_rank()!=0)return;
const std::vector<Value*>& arguments(getArguments());
unsigned npar=arguments[0]->getDerivatives().size();
......
......@@ -58,7 +58,8 @@ public:
void calculate(){};
void prepare();
GenericPrint(const ActionOptions&);
void apply();
void apply(){};
void update();
~GenericPrint();
};
......@@ -123,7 +124,7 @@ void GenericPrint::prepare(){
/////////////////////////////////////////
}
void GenericPrint::apply(){
void GenericPrint::update(){
if(comm.Get_rank()!=0)return;
if(!fp){
log.printf("PRINT:");
......
......@@ -471,6 +471,10 @@ void PlumedMain::justApply(){
// this is updating the MD copy of the forces
atoms.updateForces();
// update step (for statistics, etc)
for(ActionSet::iterator p=actionSet.begin();p!=actionSet.end();++p){
if((*p)->isActive()) (*p)->update();
}
}
void PlumedMain::load(std::vector<std::string> & words){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment