Classes | Public Member Functions | Public Attributes | Private Attributes | List of all members
PLMD::PlumedMain Class Reference


Main plumed object. More...

#include <PlumedMain.h>

Inheritance diagram for PLMD::PlumedMain:
Inheritance graph
[legend]

Classes

struct  plumed_error_handler
 Error handler. More...
 

Public Member Functions

 PlumedMain ()
 
 ~PlumedMain ()
 
void backwardPropagate ()
 Perform the backward loop on active actions. More...
 
void calc ()
 Complete PLUMED calculation. More...
 
bool callErrorHandler (int code, const char *msg) const
 Call error handler. More...
 
std::string cite (const std::string &)
 Add a citation, returning a string containing the reference number, something like "[10]". More...
 
void cmd (const std::string &key, const void *val)
 Const val version, which indeed just overrides the const and call the virtual method. More...
 
virtual void cmd (const std::string &key, void *val=NULL)=0
 This has to be implemented in daughter classes. More...
 
void cmd (const std::string &key, const void *val)
 Const val version, which indeed just overrides the const and call the virtual method. More...
 
void cmd (const std::string &key, void *val=NULL) override
 
cmd method, accessible with standard Plumed.h interface. More...
 
void eraseFile (FileBase &)
 Erase a file. More...
 
void exit (int c=0)
 Stop the run. More...
 
int fclose (FILE *fp)
 Closes a file opened with PlumedMain::fopen() More...
 
void fflush ()
 Flush all files. More...
 
FILE * fopen (const char *path, const char *mode)
 Opens a file. More...
 
const ActionSetgetActionSet () const
 Reference to the list of Action's. More...
 
AtomsgetAtoms ()
 Reference to atoms object. More...
 
double getBias () const
 get the value of the bias More...
 
bool getCPT () const
 Check if checkpointing. More...
 
ExchangePatternsgetExchangePatterns ()
 Access to exchange patterns. More...
 
bool getExchangeStep () const
 Get exchangeStep flag. More...
 
template<typename T >
unsigned getGoodNumThreads (const T *x, unsigned s) const
 Get a reasonable number of threads so as to access to an array of size s located at x. More...
 
template<typename T >
unsigned getGoodNumThreads (const std::vector< T > &v) const
 Get a reasonable number of threads so as to access to vector v;. More...
 
LoggetLog ()
 Referenge to the log stream. More...
 
unsigned getNumThreads () const
 Get number of threads that can be used by openmp. More...
 
bool getRestart () const
 Check if restarting. More...
 
long int getStep () const
 Return the number of the step. More...
 
const std::string & getSuffix () const
 Get the suffix string. More...
 
double getWork () const
 get the value of the work More...
 
void init ()
 Initialize the object. More...
 
void insertFile (FileBase &)
 Insert a file. More...
 
void justApply ()
 Backward propagate and update. More...
 
void justCalculate ()
 Perform the forward loop on active actions. More...
 
void load (const std::string &)
 Load a shared library. More...
 
void performCalc ()
 Perform the calculation. More...
 
void performCalcNoUpdate ()
 Perform the calculation without update() Shortcut for: waitData() + justCalculate() + backwardPropagate() More...
 
void prepareCalc ()
 Prepare the calculation. More...
 
void prepareDependencies ()
 Prepare the list of active Actions and needed atoms. More...
 
void readInputFile (std::string str)
 Read an input file. More...
 
void readInputLine (const std::string &str)
 Read an input string. More...
 
void readInputWords (const std::vector< std::string > &str)
 Read an input string. More...
 
void resetActive (bool active)
 Enforce active flag. More...
 
void runJobsAtEndOfCalculation ()
 If there are calculations that need to be done at the very end of the calculations this makes sures they are done. More...
 
void setEndPlumed ()
 Set end of input file. More...
 
void setExchangeStep (bool f)
 Set exchangeStep flag. More...
 
void setRestart (bool f)
 Set restart flag. More...
 
void setSuffix (const std::string &)
 Set the suffix string. More...
 
void shareData ()
 Share the needed atoms. More...
 
void stop ()
 Stop the calculation cleanly (both the MD code and plumed) More...
 
void update ()
 Call the update() method. More...
 
void updateFlagsPop ()
 Pop a state from update flags. More...
 
void updateFlagsPush (bool)
 Push a state to update flags. More...
 
bool updateFlagsTop ()
 Get top of update flags. More...
 
void waitData ()
 Scatters the needed atoms. More...
 

Public Attributes

Communicatorcomm =*comm_fwd
 Communicator for plumed. More...
 
bool detailedTimers
 Flag to switch on detailed timers. More...
 
Communicatormulti_sim_comm =*multi_sim_comm_fwd
 
bool novirial
 Flag to switch off virial calculation (for debug and MD codes with no barostat) More...
 
std::map< std::string, double > passMap
 Generic map string -> double intended to pass information across Actions. More...
 

Private Attributes

ActionSetactionSet =*actionSet_fwd
 Set of actions found in plumed.dat file. More...
 
ForwardDecl< ActionSetactionSet_fwd
 Forward declaration. More...
 
bool active
 Condition for plumed to be active. More...
 
Atomsatoms =*atoms_fwd
 Object containing information about atoms (such as positions,...). More...
 
ForwardDecl< Atomsatoms_fwd
 Forward declaration. More...
 
double bias
 The total bias (=total energy of the restraints) More...
 
Citationscitations =*citations_fwd
 tools/Citations.holder More...
 
ForwardDecl< Citationscitations_fwd
 Forward declaration. More...
 
std::unique_ptr< WithCmdcltool
 
ForwardDecl< Communicatorcomm_fwd
 Forward declaration. More...
 
DLLoaderdlloader =*dlloader_fwd
 
ForwardDecl< DLLoaderdlloader_fwd
 Forward declaration. More...
 
bool doCheckPoint
 Flag for checkpointig. More...
 
bool endPlumed
 End of input file. More...
 
plumed_error_handler error_handler = {NULL,NULL}
 
ExchangePatternsexchangePatterns =*exchangePatterns_fwd
 Class of possible exchange patterns, used for BIASEXCHANGE but also for future parallel tempering. More...
 
ForwardDecl< ExchangePatternsexchangePatterns_fwd
 Forward declaration. More...
 
bool exchangeStep
 Set to true if on an exchange step. More...
 
std::set< FileBase * > files
 Pointers to files opened in actions associated to this object. More...
 
std::unique_ptr< WithCmdgrex
 
bool initialized
 Flag to avoid double initialization. More...
 
Loglog =*log_fwd
 Log stream. More...
 
ForwardDecl< Loglog_fwd
 Forward declaration. More...
 
std::string MDEngine
 Name of MD engine. More...
 
ForwardDecl< Communicatormulti_sim_comm_fwd
 Forward declaration. More...
 
std::unique_ptr< DataFetchingObjectmydatafetcher
 Object containing data we would like to grab and pass back. More...
 
std::vector< ActionPilot * > pilots
 Set of Pilot actions. More...
 
std::string plumedDat
 Name of the input file. More...
 
bool restart
 Flag for restart. More...
 
long int step
 Present step number. More...
 
int * stopFlag
 Stuff to make plumed stop the MD code cleanly. More...
 
bool stopNow
 
Stopwatchstopwatch =*stopwatch_fwd
 
ForwardDecl< Stopwatchstopwatch_fwd
 Forward declaration. More...
 
std::string suffix
 Suffix string for file opening, useful for multiple simulations in the same directory. More...
 
std::stack< bool > updateFlags
 Stack for update flags. More...
 
double work
 The total work. More...
 

Detailed Description


Main plumed object.

In MD engines this object is not manipulated directly but it is wrapped in plumed or PLMD::Plumed objects. Its main method is cmd(), which defines completely the external plumed interface. It does not contain any static data.

Constructor & Destructor Documentation

◆ PlumedMain()

PLMD::PlumedMain::PlumedMain ( )

◆ ~PlumedMain()

PLMD::PlumedMain::~PlumedMain ( )

Member Function Documentation

◆ backwardPropagate()

void PLMD::PlumedMain::backwardPropagate ( )

Perform the backward loop on active actions.

Needed to apply the forces back.

◆ calc()

void PLMD::PlumedMain::calc ( )

Complete PLUMED calculation.

Shortcut for prepareCalc() + performCalc()

◆ callErrorHandler()

bool PLMD::PlumedMain::callErrorHandler ( int  code,
const char *  msg 
) const
inline

Call error handler.

Should only be called from plumed_plumedmain_cmd(). If the error handler was not set, returns false.

◆ cite()

std::string PLMD::PlumedMain::cite ( const std::string &  item)

Add a citation, returning a string containing the reference number, something like "[10]".

◆ cmd() [1/4]

void PLMD::WithCmd::cmd ( const std::string &  key,
const void *  val 
)
inlineinherited

Const val version, which indeed just overrides the const and call the virtual method.

◆ cmd() [2/4]

void PLMD::WithCmd::cmd
inline

Const val version, which indeed just overrides the const and call the virtual method.

◆ cmd() [3/4]

virtual void PLMD::WithCmd::cmd

This has to be implemented in daughter classes.

◆ cmd() [4/4]

void PLMD::PlumedMain::cmd ( const std::string &  key,
void *  val = NULL 
)
overridevirtual


cmd method, accessible with standard Plumed.h interface.

Parameters
keyThe name of the command to be executed.
valThe argument of the command to be executed. It is called as plumed_cmd() or as PLMD::Plumed::cmd() It is the interpreter for plumed commands. It basically contains the definition of the plumed interface. If you want to add a new functionality to the interface between plumed and an MD engine, this is the right place Notice that this interface should always keep retro-compatibility

Implements PLMD::WithCmd.

◆ eraseFile()

void PLMD::PlumedMain::eraseFile ( FileBase f)

Erase a file.

◆ exit()

void PLMD::PlumedMain::exit ( int  c = 0)

Stop the run.

◆ fclose()

int PLMD::PlumedMain::fclose ( FILE *  fp)

Closes a file opened with PlumedMain::fopen()

◆ fflush()

void PLMD::PlumedMain::fflush ( )

Flush all files.

◆ fopen()

FILE * PLMD::PlumedMain::fopen ( const char *  path,
const char *  mode 
)

Opens a file.

Similar to plain fopen, but, if it finds an error in opening the file, it also tries with path+suffix. This trick is useful for multiple replica simulations.

◆ getActionSet()

const ActionSet & PLMD::PlumedMain::getActionSet ( ) const
inline

Reference to the list of Action's.

◆ getAtoms()

Atoms & PLMD::PlumedMain::getAtoms ( )
inline

Reference to atoms object.

◆ getBias()

double PLMD::PlumedMain::getBias ( ) const

get the value of the bias

◆ getCPT()

bool PLMD::PlumedMain::getCPT ( ) const
inline

Check if checkpointing.

◆ getExchangePatterns()

ExchangePatterns& PLMD::PlumedMain::getExchangePatterns ( )
inline

Access to exchange patterns.

◆ getExchangeStep()

bool PLMD::PlumedMain::getExchangeStep ( ) const
inline

Get exchangeStep flag.

◆ getGoodNumThreads() [1/2]

template<typename T >
unsigned PLMD::PlumedMain::getGoodNumThreads ( const T *  x,
unsigned  s 
) const

Get a reasonable number of threads so as to access to an array of size s located at x.

◆ getGoodNumThreads() [2/2]

template<typename T >
unsigned PLMD::PlumedMain::getGoodNumThreads ( const std::vector< T > &  v) const

Get a reasonable number of threads so as to access to vector v;.

◆ getLog()

Log & PLMD::PlumedMain::getLog ( )

Referenge to the log stream.

◆ getNumThreads()

unsigned PLMD::PlumedMain::getNumThreads ( ) const

Get number of threads that can be used by openmp.

◆ getRestart()

bool PLMD::PlumedMain::getRestart ( ) const
inline

Check if restarting.

◆ getStep()

long int PLMD::PlumedMain::getStep ( ) const
inline

Return the number of the step.

◆ getSuffix()

const std::string & PLMD::PlumedMain::getSuffix ( ) const
inline

Get the suffix string.

◆ getWork()

double PLMD::PlumedMain::getWork ( ) const

get the value of the work

◆ init()

void PLMD::PlumedMain::init ( )

Initialize the object.

Should be called once.

◆ insertFile()

void PLMD::PlumedMain::insertFile ( FileBase f)

Insert a file.

◆ justApply()

void PLMD::PlumedMain::justApply ( )

Backward propagate and update.

Shortcut for backwardPropagate() + update() I leave it here for backward compatibility

◆ justCalculate()

void PLMD::PlumedMain::justCalculate ( )

Perform the forward loop on active actions.

◆ load()

void PLMD::PlumedMain::load ( const std::string &  ss)

Load a shared library.

◆ performCalc()

void PLMD::PlumedMain::performCalc ( )

Perform the calculation.

Shortcut for waitData() + justCalculate() + justApply(). Equivalently: waitData() + justCalculate() + backwardPropagate() + update().

◆ performCalcNoUpdate()

void PLMD::PlumedMain::performCalcNoUpdate ( )

Perform the calculation without update() Shortcut for: waitData() + justCalculate() + backwardPropagate()

◆ prepareCalc()

void PLMD::PlumedMain::prepareCalc ( )

Prepare the calculation.

Here it is checked which are the active Actions and communication of the relevant atoms is initiated. Shortcut for prepareDependencies() + shareData()

◆ prepareDependencies()

void PLMD::PlumedMain::prepareDependencies ( )

Prepare the list of active Actions and needed atoms.

Scan the Actions to see which are active and which are not, so as to prepare a list of the atoms needed at this step.

◆ readInputFile()

void PLMD::PlumedMain::readInputFile ( std::string  str)

Read an input file.

Parameters
strname of the file

◆ readInputLine()

void PLMD::PlumedMain::readInputLine ( const std::string &  str)

Read an input string.

Parameters
strname of the string At variance with readInputWords(), this is splitting the string into words

◆ readInputWords()

void PLMD::PlumedMain::readInputWords ( const std::vector< std::string > &  str)

Read an input string.

Parameters
strname of the string

◆ resetActive()

void PLMD::PlumedMain::resetActive ( bool  active)
inline

Enforce active flag.

This is a (bit dirty) hack to solve a bug. When there is no active ActionPilot, several shortcuts are used. However, these shortcuts can block GREX module. This function allows to enforce active plumed when doing exchanges, thus fixing the bug.

◆ runJobsAtEndOfCalculation()

void PLMD::PlumedMain::runJobsAtEndOfCalculation ( )

If there are calculations that need to be done at the very end of the calculations this makes sures they are done.

◆ setEndPlumed()

void PLMD::PlumedMain::setEndPlumed ( )
inline

Set end of input file.

◆ setExchangeStep()

void PLMD::PlumedMain::setExchangeStep ( bool  f)
inline

Set exchangeStep flag.

◆ setRestart()

void PLMD::PlumedMain::setRestart ( bool  f)
inline

Set restart flag.

◆ setSuffix()

void PLMD::PlumedMain::setSuffix ( const std::string &  s)
inline

Set the suffix string.

◆ shareData()

void PLMD::PlumedMain::shareData ( )

Share the needed atoms.

In asynchronous implementations, this method sends the required atoms to all the plumed processes, without waiting for the communication to complete.

◆ stop()

void PLMD::PlumedMain::stop ( )

Stop the calculation cleanly (both the MD code and plumed)

◆ update()

void PLMD::PlumedMain::update ( )

Call the update() method.

◆ updateFlagsPop()

void PLMD::PlumedMain::updateFlagsPop ( )
inline

Pop a state from update flags.

◆ updateFlagsPush()

void PLMD::PlumedMain::updateFlagsPush ( bool  on)
inline

Push a state to update flags.

◆ updateFlagsTop()

bool PLMD::PlumedMain::updateFlagsTop ( )
inline

Get top of update flags.

◆ waitData()

void PLMD::PlumedMain::waitData ( )

Scatters the needed atoms.

In asynchronous implementations, this method waits for the communications started in shareData() to be completed. Otherwise, just send around needed atoms.

Member Data Documentation

◆ actionSet

ActionSet& PLMD::PlumedMain::actionSet =*actionSet_fwd
private

Set of actions found in plumed.dat file.

◆ actionSet_fwd

ForwardDecl<ActionSet> PLMD::PlumedMain::actionSet_fwd
private

Forward declaration.

◆ active

bool PLMD::PlumedMain::active
private

Condition for plumed to be active.

At every step, PlumedMain is checking if there are Action's requiring some work. If at least one Action requires some work, this variable is set to true.

◆ atoms

Atoms& PLMD::PlumedMain::atoms =*atoms_fwd
private

Object containing information about atoms (such as positions,...).

◆ atoms_fwd

ForwardDecl<Atoms> PLMD::PlumedMain::atoms_fwd
private

Forward declaration.

◆ bias

double PLMD::PlumedMain::bias
private

The total bias (=total energy of the restraints)

◆ citations

Citations& PLMD::PlumedMain::citations =*citations_fwd
private

tools/Citations.holder

◆ citations_fwd

ForwardDecl<Citations> PLMD::PlumedMain::citations_fwd
private

Forward declaration.

◆ cltool

std::unique_ptr<WithCmd> PLMD::PlumedMain::cltool
private

◆ comm

Communicator& PLMD::PlumedMain::comm =*comm_fwd

Communicator for plumed.

Includes all the processors used by plumed.

◆ comm_fwd

ForwardDecl<Communicator> PLMD::PlumedMain::comm_fwd
private

Forward declaration.

◆ detailedTimers

bool PLMD::PlumedMain::detailedTimers

Flag to switch on detailed timers.

◆ dlloader

DLLoader& PLMD::PlumedMain::dlloader =*dlloader_fwd
private

◆ dlloader_fwd

ForwardDecl<DLLoader> PLMD::PlumedMain::dlloader_fwd
private

Forward declaration.

◆ doCheckPoint

bool PLMD::PlumedMain::doCheckPoint
private

Flag for checkpointig.

◆ endPlumed

bool PLMD::PlumedMain::endPlumed
private

End of input file.

Set to true to terminate reading

◆ error_handler

plumed_error_handler PLMD::PlumedMain::error_handler = {NULL,NULL}
private

◆ exchangePatterns

ExchangePatterns& PLMD::PlumedMain::exchangePatterns =*exchangePatterns_fwd
private

Class of possible exchange patterns, used for BIASEXCHANGE but also for future parallel tempering.

◆ exchangePatterns_fwd

ForwardDecl<ExchangePatterns> PLMD::PlumedMain::exchangePatterns_fwd
private

Forward declaration.

◆ exchangeStep

bool PLMD::PlumedMain::exchangeStep
private

Set to true if on an exchange step.

◆ files

std::set<FileBase*> PLMD::PlumedMain::files
private

Pointers to files opened in actions associated to this object.

Notice that with the current implementation this should be at the top of this structure. Indeed, this should be destroyed after all the actions allocated in this PlumedMain object have been destroyed.

◆ grex

std::unique_ptr<WithCmd> PLMD::PlumedMain::grex
private

◆ initialized

bool PLMD::PlumedMain::initialized
private

Flag to avoid double initialization.

◆ log

Log& PLMD::PlumedMain::log =*log_fwd
private

Log stream.

◆ log_fwd

ForwardDecl<Log> PLMD::PlumedMain::log_fwd
private

Forward declaration.

◆ MDEngine

std::string PLMD::PlumedMain::MDEngine
private

Name of MD engine.

◆ multi_sim_comm

Communicator& PLMD::PlumedMain::multi_sim_comm =*multi_sim_comm_fwd

◆ multi_sim_comm_fwd

ForwardDecl<Communicator> PLMD::PlumedMain::multi_sim_comm_fwd
private

Forward declaration.

◆ mydatafetcher

std::unique_ptr<DataFetchingObject> PLMD::PlumedMain::mydatafetcher
private

Object containing data we would like to grab and pass back.

◆ novirial

bool PLMD::PlumedMain::novirial

Flag to switch off virial calculation (for debug and MD codes with no barostat)

◆ passMap

std::map<std::string,double> PLMD::PlumedMain::passMap

Generic map string -> double intended to pass information across Actions.

◆ pilots

std::vector<ActionPilot*> PLMD::PlumedMain::pilots
private

Set of Pilot actions.

These are the action the, if they are Pilot::onStep(), can trigger execution

◆ plumedDat

std::string PLMD::PlumedMain::plumedDat
private

Name of the input file.

◆ restart

bool PLMD::PlumedMain::restart
private

Flag for restart.

◆ step

long int PLMD::PlumedMain::step
private

Present step number.

◆ stopFlag

int* PLMD::PlumedMain::stopFlag
private

Stuff to make plumed stop the MD code cleanly.

◆ stopNow

bool PLMD::PlumedMain::stopNow
private

◆ stopwatch

Stopwatch& PLMD::PlumedMain::stopwatch =*stopwatch_fwd
private

◆ stopwatch_fwd

ForwardDecl<Stopwatch> PLMD::PlumedMain::stopwatch_fwd
private

Forward declaration.

Should be placed after log since its constructor takes a log reference as an argument.

◆ suffix

std::string PLMD::PlumedMain::suffix
private

Suffix string for file opening, useful for multiple simulations in the same directory.

◆ updateFlags

std::stack<bool> PLMD::PlumedMain::updateFlags
private

Stack for update flags.

Store information used in class generic::UpdateIf

◆ work

double PLMD::PlumedMain::work
private

The total work.

This computed by accumulating the change in external potentials.


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