Public Member Functions | Public Attributes | Private Types | 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]

Public Member Functions

std::string cite (const std::string &)
 Add a citation, returning a string containing the reference number, something like "[10]". More...
 
unsigned getNumThreads () const
 Get number of threads that can be used by openmp. 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...
 
 PlumedMain ()
 
void cmd (const std::string &key, void *val=NULL)
 cmd method, accessible with standard Plumed.h interface. More...
 
 ~PlumedMain ()
 
void readInputFile (std::string str)
 Read an input file. More...
 
void readInputWords (const std::vector< std::string > &str)
 Read an input string. More...
 
void init ()
 Initialize the object. More...
 
void prepareCalc ()
 Prepare the calculation. More...
 
void prepareDependencies ()
 Prepare the list of active Actions and needed atoms. More...
 
void shareData ()
 Share the needed atoms. More...
 
void performCalc ()
 Perform the calculation. More...
 
void calc ()
 Complete PLUMED calculation. More...
 
void waitData ()
 Scatters the needed atoms. More...
 
void justCalculate ()
 Perform the forward loop on active actions. More...
 
void justApply ()
 Perform the backward loop on active actions. 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...
 
AtomsgetAtoms ()
 Reference to atoms object. More...
 
const ActionSetgetActionSet () const
 Reference to the list of Action's. More...
 
LoggetLog ()
 Referenge to the log stream. More...
 
long int getStep () const
 Return the number of the step. More...
 
void exit (int c=0)
 Stop the run. More...
 
void load (const std::string &)
 Load a shared library. More...
 
const std::string & getSuffix () const
 Get the suffix string. More...
 
void setSuffix (const std::string &)
 Set the suffix string. More...
 
double getBias () const
 get the value of the bias More...
 
double getWork () const
 get the value of the work More...
 
FILE * fopen (const char *path, const char *mode)
 Opens a file. More...
 
int fclose (FILE *fp)
 Closes a file opened with PlumedMain::fopen() More...
 
void insertFile (FileBase &)
 Insert a file. More...
 
void eraseFile (FileBase &)
 Erase a file. More...
 
void fflush ()
 Flush all files. More...
 
bool getRestart () const
 Check if restarting. More...
 
void setRestart (bool f)
 Set restart flag. More...
 
void setExchangeStep (bool f)
 Set exchangeStep flag. More...
 
bool getExchangeStep () const
 Get exchangeStep flag. More...
 
void stop ()
 Stop the calculation cleanly (both the MD code and plumed) More...
 
void resetActive (bool active)
 Enforce active flag. More...
 
ExchangePatternsgetExchangePatterns ()
 Access to exchange patterns. 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...
 

Public Attributes

Communicatorcomm
 Communicator for plumed. More...
 
Communicatormulti_sim_comm
 
bool novirial
 Flag to switch off virial calculation (for debug and MD codes with no barostat) More...
 
bool detailedTimers
 Flag to switch on detailed timers. More...
 
std::map< std::string, int > word_map
 word list command More...
 

Private Types

typedef std::set< FileBase * >::iterator files_iterator
 

Private Attributes

DLLoaderdlloader
 
WithCmdcltool
 
Stopwatchstopwatch
 
WithCmdgrex
 
bool initialized
 Flag to avoid double initialization. More...
 
std::string MDEngine
 Name of MD engine. More...
 
Loglog
 Log stream. More...
 
Citationscitations
 tools/Citations.holder More...
 
long int step
 Present step number. More...
 
bool active
 Condition for plumed to be active. More...
 
std::string plumedDat
 Name of the input file. More...
 
Atomsatoms
 Object containing information about atoms (such as positions,...). More...
 
ActionSetactionSet
 Set of actions found in plumed.dat file. More...
 
std::vector< ActionPilot * > pilots
 Set of Pilot actions. More...
 
std::string suffix
 Suffix string for file opening, useful for multiple simulations in the same directory. More...
 
double bias
 The total bias (=total energy of the restraints) More...
 
double work
 The total work. More...
 
ExchangePatternsexchangePatterns
 Class of possible exchange patterns, used for BIASEXCHANGE but also for future parallel tempering. More...
 
bool exchangeStep
 Set to true if on an exchange step. More...
 
bool restart
 Flag for restart. More...
 
std::set< FileBase * > files
 
int * stopFlag
 Stuff to make plumed stop the MD code cleanly. More...
 
bool stopNow
 

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.

Member Typedef Documentation

typedef std::set<FileBase*>::iterator PLMD::PlumedMain::files_iterator
private

Constructor & Destructor Documentation

PLMD::PlumedMain::PlumedMain ( )
PLMD::PlumedMain::~PlumedMain ( )

Member Function Documentation

void PLMD::PlumedMain::calc ( )

Complete PLUMED calculation.

Shortcut for prepareCalc() + performCalc()

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

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

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.

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

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.

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

Erase a file.

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

Stop the run.

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

Closes a file opened with PlumedMain::fopen()

void PLMD::PlumedMain::fflush ( )

Flush all files.

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.

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

Reference to the list of Action's.

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

Reference to atoms object.

double PLMD::PlumedMain::getBias ( ) const

get the value of the bias

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

Access to exchange patterns.

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

Get exchangeStep flag.

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.

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;.

Log & PLMD::PlumedMain::getLog ( )

Referenge to the log stream.

unsigned PLMD::PlumedMain::getNumThreads ( ) const

Get number of threads that can be used by openmp.

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

Check if restarting.

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

Return the number of the step.

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

Get the suffix string.

double PLMD::PlumedMain::getWork ( ) const

get the value of the work

void PLMD::PlumedMain::init ( )

Initialize the object.

Should be called once.

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

Insert a file.

void PLMD::PlumedMain::justApply ( )

Perform the backward loop on active actions.

Needed to apply the forces back.

void PLMD::PlumedMain::justCalculate ( )

Perform the forward loop on active actions.

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

Load a shared library.

void PLMD::PlumedMain::performCalc ( )

Perform the calculation.

Shortcut for waitData() + justCalculate() + justApply()

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()

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.

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

Read an input file.

Parameters
strname of the file
void PLMD::PlumedMain::readInputWords ( const std::vector< std::string > &  str)

Read an input string.

Parameters
strname of the string
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.

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.

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

Set exchangeStep flag.

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

Set restart flag.

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

Set the suffix string.

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.

void PLMD::PlumedMain::stop ( )

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

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& PLMD::PlumedMain::actionSet
private

Set of actions found in plumed.dat file.

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& PLMD::PlumedMain::atoms
private

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

double PLMD::PlumedMain::bias
private

The total bias (=total energy of the restraints)

Citations& PLMD::PlumedMain::citations
private

tools/Citations.holder

WithCmd* PLMD::PlumedMain::cltool
private
Communicator& PLMD::PlumedMain::comm

Communicator for plumed.

Includes all the processors used by plumed.

bool PLMD::PlumedMain::detailedTimers

Flag to switch on detailed timers.

DLLoader& PLMD::PlumedMain::dlloader
private
ExchangePatterns& PLMD::PlumedMain::exchangePatterns
private

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

bool PLMD::PlumedMain::exchangeStep
private

Set to true if on an exchange step.

std::set<FileBase*> PLMD::PlumedMain::files
private
WithCmd* PLMD::PlumedMain::grex
private
bool PLMD::PlumedMain::initialized
private

Flag to avoid double initialization.

Log& PLMD::PlumedMain::log
private

Log stream.

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

Name of MD engine.

Communicator& PLMD::PlumedMain::multi_sim_comm
bool PLMD::PlumedMain::novirial

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

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

Set of Pilot actions.

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

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

Name of the input file.

bool PLMD::PlumedMain::restart
private

Flag for restart.

long int PLMD::PlumedMain::step
private

Present step number.

int* PLMD::PlumedMain::stopFlag
private

Stuff to make plumed stop the MD code cleanly.

bool PLMD::PlumedMain::stopNow
private
Stopwatch& PLMD::PlumedMain::stopwatch
private
std::string PLMD::PlumedMain::suffix
private

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

std::map<std::string, int> PLMD::PlumedMain::word_map

word list command

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: