All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PlumedMain.cpp
Go to the documentation of this file.
1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  Copyright (c) 2013 The plumed team
3  (see the PEOPLE file at the root of the distribution for a list of names)
4 
5  See http://www.plumed-code.org for more information.
6 
7  This file is part of plumed, version 2.0.
8 
9  plumed is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  plumed is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with plumed. If not, see <http://www.gnu.org/licenses/>.
21 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
22 #include "PlumedMain.h"
23 #include "tools/Tools.h"
24 #include <cstring>
25 #include "ActionPilot.h"
26 #include "ActionWithValue.h"
27 #include "ActionAtomistic.h"
28 #include "ActionWithVirtualAtom.h"
29 #include "Atoms.h"
30 #include <set>
31 #include "config/Config.h"
32 #include <cstdlib>
33 #include "ActionRegister.h"
34 #include "GREX.h"
35 #include "tools/Exception.h"
36 #include "Atoms.h"
37 #include "ActionSet.h"
38 #include "tools/Log.h"
39 #include "tools/DLLoader.h"
40 #include "tools/Communicator.h"
41 #include "CLToolMain.h"
42 #include "tools/Stopwatch.h"
43 #include "tools/Citations.h"
44 #include "ExchangePatterns.h"
45 #include "tools/IFile.h"
46 
47 using namespace std;
48 
49 namespace PLMD{
50 
51 PlumedMain::PlumedMain():
52  comm(*new Communicator),
53  multi_sim_comm(*new Communicator),
54  dlloader(*new DLLoader),
55  cltool(NULL),
56  stopwatch(*new Stopwatch),
57  grex(NULL),
58  initialized(false),
59  log(*new Log),
60  citations(*new Citations),
61  step(0),
62  active(false),
63  atoms(*new Atoms(*this)),
64  actionSet(*new ActionSet(*this)),
65  bias(0.0),
66  exchangePatterns(*new(ExchangePatterns)),
67  exchangeStep(false),
68  restart(false),
69  stopFlag(NULL),
70  stopNow(false),
71  novirial(false),
72  detailedTimers(false)
73 {
74  log.link(comm);
75  log.setLinePrefix("PLUMED: ");
76  stopwatch.start();
77  stopwatch.pause();
78 }
79 
81  stopwatch.start();
82  stopwatch.stop();
84  delete &exchangePatterns;
85  delete &actionSet;
86  delete &citations;
87  delete &atoms;
88  delete &log;
89  if(grex) delete grex;
90  delete &stopwatch;
91  if(cltool) delete cltool;
92  delete &dlloader;
93  delete &comm;
94  delete &multi_sim_comm;
95 }
96 
97 /////////////////////////////////////////////////////////////
98 // MAIN INTERPRETER
99 
100 #define CHECK_INIT(ini,word) plumed_massert(ini,"cmd(\"" + word +"\") should be only used after plumed initialization")
101 #define CHECK_NOTINIT(ini,word) plumed_massert(!(ini),"cmd(\"" + word +"\") should be only used before plumed initialization")
102 #define CHECK_NULL(val,word) plumed_massert(val,"NULL pointer received in cmd(\"" + word + "\")");
103 
104 void PlumedMain::cmd(const std::string & word,void*val){
105 
106  stopwatch.start();
107 
108  if(false){
109 // for efficiency, words frequently used are checked first
110 
111 // words used at every MD steps:
112  } else if(word=="setBox") {
113  CHECK_INIT(initialized,word);
114  CHECK_NULL(val,word);
115  atoms.setBox(val);
116  } else if(word=="setPositions") {
117  CHECK_INIT(initialized,word);
118  atoms.setPositions(val);
119  } else if(word=="setMasses") {
120  CHECK_INIT(initialized,word);
121  atoms.setMasses(val);
122  } else if(word=="setCharges") {
123  CHECK_INIT(initialized,word);
124  atoms.setCharges(val);
125  } else if(word=="setPositionsX") {
126  CHECK_INIT(initialized,word);
127  atoms.setPositions(val,0);
128  } else if(word=="setPositionsY") {
129  CHECK_INIT(initialized,word);
130  atoms.setPositions(val,1);
131  } else if(word=="setPositionsZ") {
132  CHECK_INIT(initialized,word);
133  atoms.setPositions(val,2);
134  } else if(word=="setVirial") {
135  CHECK_INIT(initialized,word);
136  CHECK_NULL(val,word);
137  atoms.setVirial(val);
138  } else if(word=="setEnergy") {
139  CHECK_INIT(initialized,word);
140  CHECK_NULL(val,word);
141  atoms.setEnergy(val);
142  } else if(word=="setForces") {
143  CHECK_INIT(initialized,word);
144  atoms.setForces(val);
145  } else if(word=="setForcesX") {
146  CHECK_INIT(initialized,word);
147  atoms.setForces(val,0);
148  } else if(word=="setForcesY") {
149  CHECK_INIT(initialized,word);
150  atoms.setForces(val,1);
151  } else if(word=="setForcesZ") {
152  CHECK_INIT(initialized,word);
153  atoms.setForces(val,2);
154  } else if(word=="calc") {
155  CHECK_INIT(initialized,word);
156  calc();
157  } else if(word=="prepareDependencies") {
158  CHECK_INIT(initialized,word);
160  } else if(word=="shareData") {
161  CHECK_INIT(initialized,word);
162  shareData();
163  } else if(word=="prepareCalc") {
164  CHECK_INIT(initialized,word);
165  prepareCalc();
166  } else if(word=="performCalc") {
167  CHECK_INIT(initialized,word);
168  performCalc();
169  } else if(word=="setStep") {
170  CHECK_INIT(initialized,word);
171  CHECK_NULL(val,word);
172  step=(*static_cast<int*>(val));
173  atoms.startStep();
174  } else if(word=="setStepLong") {
175  CHECK_INIT(initialized,word);
176  CHECK_NULL(val,word);
177  step=(*static_cast<long int*>(val));
178  atoms.startStep();
179 // words used less frequently:
180  } else if(word=="setAtomsNlocal"){
181  CHECK_INIT(initialized,word);
182  CHECK_NULL(val,word);
183  atoms.setAtomsNlocal(*static_cast<int*>(val));
184  } else if(word=="setAtomsGatindex"){
185  CHECK_INIT(initialized,word);
186  atoms.setAtomsGatindex(static_cast<int*>(val));
187  } else if(word=="setAtomsContiguous"){
188  CHECK_INIT(initialized,word);
189  CHECK_NULL(val,word);
190  atoms.setAtomsContiguous(*static_cast<int*>(val));
191  } else if(word=="createFullList"){
192  CHECK_INIT(initialized,word);
193  CHECK_NULL(val,word);
194  atoms.createFullList(static_cast<int*>(val));
195  } else if(word=="getFullList"){
196  CHECK_INIT(initialized,word);
197  CHECK_NULL(val,word);
198  atoms.getFullList(static_cast<int**>(val));
199  } else if(word=="clearFullList"){
200  CHECK_INIT(initialized,word);
202  } else if(word=="read"){
203  CHECK_INIT(initialized,word);
204  if(val)readInputFile(static_cast<char*>(val));
205  else readInputFile("plumed.dat");
206  } else if(word=="clear"){
207  CHECK_INIT(initialized,word);
209  } else if(word=="getApiVersion"){
210  CHECK_NULL(val,word);
211  *(static_cast<int*>(val))=1;
212 // commands which can be used only before initialization:
213  } else if(word=="init"){
215  init();
216  } else if(word=="setRealPrecision"){
218  CHECK_NULL(val,word);
219  atoms.setRealPrecision(*static_cast<int*>(val));
220  } else if(word=="setMDLengthUnits"){
222  CHECK_NULL(val,word);
223  double d;
224  atoms.MD2double(val,d);
226  } else if(word=="setMDEnergyUnits"){
228  CHECK_NULL(val,word);
229  double d;
230  atoms.MD2double(val,d);
232  } else if(word=="setMDTimeUnits"){
234  CHECK_NULL(val,word);
235  double d;
236  atoms.MD2double(val,d);
238  } else if(word=="setNaturalUnits"){
239 // set the boltzman constant for MD in natural units (kb=1)
240 // only needed in LJ codes if the MD is passing temperatures to plumed (so, not yet...)
241 // use as cmd("setNaturalUnits")
243  atoms.setMDNaturalUnits(true);
244  } else if(word=="setNoVirial"){
246  novirial=true;
247  } else if(word=="setPlumedDat"){
249  CHECK_NULL(val,word);
250  plumedDat=static_cast<char*>(val);
251  } else if(word=="setMPIComm"){
253  comm.Set_comm(val);
255  } else if(word=="setMPIFComm"){
257  comm.Set_fcomm(val);
259  } else if(word=="setMPImultiSimComm"){
262  } else if(word=="setNatoms"){
264  CHECK_NULL(val,word);
265  atoms.setNatoms(*static_cast<int*>(val));
266  } else if(word=="setTimestep"){
268  CHECK_NULL(val,word);
269  atoms.setTimeStep(val);
270  } else if(word=="setMDEngine"){
272  CHECK_NULL(val,word);
273  MDEngine=static_cast<char*>(val);
274  } else if(word=="setLog"){
276  log.link(static_cast<FILE*>(val));
277  } else if(word=="setLogFile"){
279  CHECK_NULL(val,word);
280  log.open(static_cast<char*>(val),"w");
281 // other commands that should be used after initialization:
282  } else if(word=="setStopFlag"){
283  CHECK_INIT(initialized,word);
284  CHECK_NULL(val,word);
285  stopFlag=static_cast<int*>(val);
286  } else if(word=="getExchangesFlag"){
287  CHECK_INIT(initialized,word);
288  CHECK_NULL(val,word);
289  exchangePatterns.getFlag((*static_cast<int*>(val)));
290  } else if(word=="setExchangesSeed"){
291  CHECK_INIT(initialized,word);
292  CHECK_NULL(val,word);
293  exchangePatterns.setSeed((*static_cast<int*>(val)));
294  } else if(word=="setNumberOfReplicas"){
295  CHECK_INIT(initialized,word);
296  CHECK_NULL(val,word);
297  exchangePatterns.setNofR((*static_cast<int*>(val)));
298  } else if(word=="getExchangesList"){
299  CHECK_INIT(initialized,word);
300  CHECK_NULL(val,word);
301  exchangePatterns.getList((static_cast<int*>(val)));
302  } else if(word=="runFinalJobs"){
303  CHECK_INIT(initialized,word);
305  } else if(word=="isEnergyNeeded"){
306  CHECK_INIT(initialized,word);
307  CHECK_NULL(val,word);
308  if(atoms.isEnergyNeeded()) *(static_cast<int*>(val))=1;
309  else *(static_cast<int*>(val))=0;
310  } else if(word=="getBias"){
311  CHECK_INIT(initialized,word);
312  CHECK_NULL(val,word);
314  atoms.double2MD(x,val);
315  } else {
316 // multi word commands
317 
318  std::vector<std::string> words=Tools::getWords(word);
319  int nw=words.size();
320 
321  if(false){
322  } else if(nw==2 && words[0]=="checkAction"){
323  int check=0;
324  if(actionRegister().check(words[1])) check=1;
325  *(static_cast<int*>(val))=check;
326  } else if(nw>1 && words[0]=="GREX"){
327  if(!grex) grex=new GREX(*this);
328  plumed_massert(grex,"error allocating grex");
329  std::string kk=words[1];
330  for(unsigned i=2;i<words.size();i++) kk+=" "+words[i];
331  grex->cmd(kk.c_str(),val);
332  } else if(nw>1 && words[0]=="CLTool"){
334  if(!cltool) cltool=new CLToolMain;
335  std::string kk=words[1];
336  for(unsigned i=2;i<words.size();i++) kk+=" "+words[i];
337  cltool->cmd(kk.c_str(),val);
338  } else{
339  plumed_merror("cannot interpret cmd(\"" + word + "\"). check plumed developers manual to see the available commands.");
340  };
341  };
342 
343  stopwatch.pause();
344 }
345 
346 /////
347 ////////////////////////////////////////////////////////////////////////
348 
350 // check that initialization just happens once
351  initialized=true;
352  atoms.init();
353  if(!log.isOpen()) log.link(stdout);
354  log<<"PLUMED is starting\n";
355  log<<"Version: "<<config::getVersionLong()<<" (git: "<<config::getVersionGit()<<") compiled on " __DATE__ " at " __TIME__ "\n";
356  log<<"Please cite this paper when using PLUMED ";
357  log<<cite("Tribello, Bonomi, Branduardi, Camilloni, and Bussi, Comput. Phys. Commun. 185, 604 (2014)");
358  log<<"\n";
359  log<<"For further information see the PLUMED web page at http://www.plumed-code.org\n";
360  log.printf("Molecular dynamics engine: %s\n",MDEngine.c_str());
361  log.printf("Precision of reals: %d\n",atoms.getRealPrecision());
362  log.printf("Running over %d %s\n",comm.Get_size(),(comm.Get_size()>1?"nodes":"node"));
363  log.printf("Number of atoms: %d\n",atoms.getNatoms());
364  if(grex) log.printf("GROMACS-like replica exchange is on\n");
365  log.printf("File suffix: %s\n",getSuffix().c_str());
366  if(plumedDat.length()>0){
368  plumedDat="";
369  }
370  atoms.updateUnits();
371  log.printf("Timestep: %f\n",atoms.getTimeStep());
372  log<<"Relevant bibliography:\n";
373  log<<citations;
374  log<<"Please read and cite where appropriate!\n";
375  log<<"Finished setup\n";
376 }
377 
378 void PlumedMain::readInputFile(std::string str){
379  plumed_assert(initialized);
380  log.printf("FILE: %s\n",str.c_str());
381  IFile ifile;
382  ifile.link(*this);
383  ifile.open(str);
384  std::vector<std::string> words;
386  while(Tools::getParsedLine(ifile,words) && words[0]!="ENDPLUMED") readInputWords(words);
387  log.printf("END FILE: %s\n",str.c_str());
388  log.flush();
389 
391 }
392 
393 void PlumedMain::readInputWords(const std::vector<std::string> & words){
394  plumed_assert(initialized);
395  if(words.empty())return;
396  else if(words[0]=="ENDPLUMED") return;
397  else if(words[0]=="_SET_SUFFIX"){
398  plumed_assert(words.size()==2);
399  setSuffix(words[1]);
400  } else {
401  std::vector<std::string> interpreted(words);
402  Tools::interpretLabel(interpreted);
403  Action* action=actionRegister().create(ActionOptions(*this,interpreted));
404  if(!action){
405  log<<"ERROR\n";
406  log<<"I cannot understand line:";
407  for(unsigned i=0;i<interpreted.size();++i) log<<" "<<interpreted[i];
408  log<<"\n";
409  exit(1);
410  };
411  action->checkRead();
412  actionSet.push_back(action);
413  };
414 
416 }
417 
418 
419 
420 ////////////////////////////////////////////////////////////////////////
421 
422 void PlumedMain::exit(int c){
423  comm.Abort(c);
424 }
425 
427  return log;
428 }
429 
430 
431 
432 
433 
435  prepareCalc();
436  performCalc();
437 }
438 
441  shareData();
442 }
443 
444 
445 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
446 // here we have the main steps in "calc()"
447 // they can be called individually, but the standard thing is to
448 // traverse them in this order:
450 
451  stopwatch.start("1 Prepare dependencies");
452 
453 // activate all the actions which are on step
454 // activation is recursive and enables also the dependencies
455 // before doing that, the prepare() method is called to see if there is some
456 // new/changed dependency (up to now, only useful for dependences on virtual atoms,
457 // which can be dynamically changed).
458 //
459 
460 // First switch off all actions
461  for(ActionSet::iterator p=actionSet.begin();p!=actionSet.end();++p){
462  (*p)->deactivate();
463  (*p)->clearOptions();
464  }
465 
466 // for optimization, an "active" flag remains false if no action at all is active
467  active=false;
468  for(unsigned i=0;i<pilots.size();++i){
469  if(pilots[i]->onStep()){
470  pilots[i]->activate();
471  active=true;
472  }
473  };
474 
475 // also, if one of them is the total energy, tell to atoms that energy should be collected
476  for(ActionSet::iterator p=actionSet.begin();p!=actionSet.end();++p){
477  if((*p)->isActive()){
478  if((*p)->checkNeedsGradients()) (*p)->setOption("GRADIENTS");
479  }
480  }
481 
482  stopwatch.stop("1 Prepare dependencies");
483 
484 }
485 
487 // atom positions are shared (but only if there is something to do)
488  if(!active)return;
489  stopwatch.start("2 Sharing data");
490  if(atoms.getNatoms()>0) atoms.share();
491  stopwatch.stop("2 Sharing data");
492 }
493 
495  waitData();
496  justCalculate();
497  justApply();
498 }
499 
501  if(!active)return;
502  stopwatch.start("3 Waiting for data");
503  if(atoms.getNatoms()>0) atoms.wait();
504  stopwatch.stop("3 Waiting for data");
505 }
506 
507 
509  if(!active)return;
510  stopwatch.start("4 Calculating (forward loop)");
511  bias=0.0;
512 
513  int iaction=0;
514 // calculate the active actions in order (assuming *backward* dependence)
515  for(ActionSet::iterator p=actionSet.begin();p!=actionSet.end();++p){
516  std::string actionNumberLabel;
517  if(detailedTimers){
518  Tools::convert(iaction,actionNumberLabel);
519  actionNumberLabel="4A "+actionNumberLabel+" "+(*p)->getLabel();
520  stopwatch.start(actionNumberLabel);
521  }
522  ActionWithValue*av=dynamic_cast<ActionWithValue*>(*p);
523  ActionAtomistic*aa=dynamic_cast<ActionAtomistic*>(*p);
524  {
525  if(av) av->clearInputForces();
526  if(av) av->clearDerivatives();
527  }
528  {
529  if(aa) aa->clearOutputForces();
530  if(aa) if(aa->isActive()) aa->retrieveAtoms();
531  }
532  if((*p)->isActive()){
533  if((*p)->checkNumericalDerivatives()) (*p)->calculateNumericalDerivatives();
534  else (*p)->calculate();
535  // This retrieves components called bias
536  if(av) bias+=av->getOutputQuantity("bias");
537  if(av)av->setGradientsIfNeeded();
538  ActionWithVirtualAtom*avv=dynamic_cast<ActionWithVirtualAtom*>(*p);
539  if(avv)avv->setGradientsIfNeeded();
540  }
541 
542  if(detailedTimers) stopwatch.stop(actionNumberLabel);
543  iaction++;
544  }
545  stopwatch.stop("4 Calculating (forward loop)");
546 }
547 
549 
550  if(!active)return;
551  int iaction=0;
552  stopwatch.start("5 Applying (backward loop)");
553 // apply them in reverse order
554  for(ActionSet::reverse_iterator p=actionSet.rbegin();p!=actionSet.rend();++p){
555  if((*p)->isActive()){
556 
557  std::string actionNumberLabel;
558  if(detailedTimers){
559  Tools::convert(iaction,actionNumberLabel);
560  actionNumberLabel="5A "+actionNumberLabel+" "+(*p)->getLabel();
561  stopwatch.start(actionNumberLabel);
562  }
563 
564  (*p)->apply();
565  ActionAtomistic*a=dynamic_cast<ActionAtomistic*>(*p);
566 // still ActionAtomistic has a special treatment, since they may need to add forces on atoms
567  if(a) a->applyForces();
568 
569  if(detailedTimers) stopwatch.stop(actionNumberLabel);
570  }
571  iaction++;
572  }
573 
574 // this is updating the MD copy of the forces
575  if(detailedTimers) stopwatch.start("5B Update forces");
576  if(atoms.getNatoms()>0) atoms.updateForces();
577  if(detailedTimers) stopwatch.stop("5B Update forces");
578 
579  if(detailedTimers) stopwatch.start("5C Update");
580 // update step (for statistics, etc)
581  for(ActionSet::iterator p=actionSet.begin();p!=actionSet.end();++p){
582  if((*p)->isActive()) (*p)->update();
583  }
584  if(detailedTimers) stopwatch.stop("5C Update");
585 // Check that no action has told the calculation to stop
586  if(stopNow){
587  if(stopFlag) (*stopFlag)=1;
588  else plumed_merror("your md code cannot handle plumed stop events - add a call to plumed.comm(stopFlag,stopCondition)");
589  }
590  stopwatch.stop("5 Applying (backward loop)");
591 
592 // flush by default every 10000 steps
593 // hopefully will not affect performance
594  if(step%10000==0){
595  fflush();
596  log.flush();
597  for(ActionSet::const_iterator p=actionSet.begin();p!=actionSet.end();++p) (*p)->fflush();
598  }
599 }
600 
601 void PlumedMain::load(const std::string& ss){
602  if(DLLoader::installed()){
603  string s=ss;
604  size_t n=s.find_last_of(".");
605  string extension="";
606  string base=s;
607  if(n!=std::string::npos && n<s.length()-1) extension=s.substr(n+1);
608  if(n!=std::string::npos && n<s.length()) base=s.substr(0,n);
609  if(extension=="cpp"){
610  string cmd="plumed mklib "+s;
611  log<<"Executing: "<<cmd;
612  if(comm.Get_size()>0) log<<" (only on master node)";
613  log<<"\n";
614  if(comm.Get_rank()==0) system(cmd.c_str());
615  comm.Barrier();
616  base="./"+base;
617  }
618  s=base+"."+config::getSoExt();
619  void *p=dlloader.load(s);
620  if(!p){
621  log<<"ERROR\n";
622  log<<"I cannot load library "<<ss<<"\n";
623  log<<dlloader.error();
624  log<<"\n";
625  this->exit(1);
626  }
627  log<<"Loading shared library "<<s.c_str()<<"\n";
628  log<<"Here is the new list of available actions\n";
629  log<<actionRegister();
630  } else plumed_merror("loading not enabled, please recompile with -D__PLUMED_HAS_DLOPEN");
631 }
632 
633 double PlumedMain::getBias() const{
634  return bias;
635 }
636 
637 FILE* PlumedMain::fopen(const char *path, const char *mode){
638  std::string mmode(mode);
639  std::string ppath(path);
640  std::string suffix(getSuffix());
641  std::string ppathsuf=ppath+suffix;
642  FILE*fp=std::fopen(const_cast<char*>(ppathsuf.c_str()),const_cast<char*>(mmode.c_str()));
643  if(!fp) fp=std::fopen(const_cast<char*>(ppath.c_str()),const_cast<char*>(mmode.c_str()));
644  plumed_massert(fp,"file " + ppath + " cannot be found");
645  return fp;
646 }
647 
648 int PlumedMain::fclose(FILE*fp){
649  return std::fclose(fp);
650 }
651 
652 std::string PlumedMain::cite(const std::string&item){
653  return citations.cite(item);
654 }
655 
657  for(files_iterator p=files.begin();p!=files.end();++p){
658  (*p)->flush();
659  }
660 }
661 
663  files.insert(&f);
664 }
665 
667  files.erase(&f);
668 }
669 
671  stopNow=true;
672 }
673 
675  for(ActionSet::iterator p=actionSet.begin();p!=actionSet.end();++p){
676  (*p)->runFinalJobs();
677  }
678 }
679 
680 }
681 
682 
683 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
684 
685 
686 
void wait()
Definition: Atoms.cpp:204
const int & getNatoms() const
Definition: Atoms.h:201
long int step
Present step number.
Definition: PlumedMain.h:96
bool isActive() const
Check if action is active.
Definition: Action.h:375
WithCmd * cltool
Definition: PlumedMain.h:83
void init()
Initialize the object.
Definition: PlumedMain.cpp:349
void setVirial(void *)
Definition: Atoms.cpp:96
void getFullList(int **)
Definition: Atoms.cpp:341
ActionRegister & actionRegister()
std::string plumedDat
Name of the input file.
Definition: PlumedMain.h:104
bool isEnergyNeeded() const
Definition: Atoms.h:174
void setTimeStep(void *)
Definition: Atoms.cpp:322
Class taking care of dynamic loading.
Definition: DLLoader.h:40
void setCharges(void *)
Definition: Atoms.cpp:90
std::vector containing the sequence of Action to be done.
Definition: ActionSet.h:38
bool novirial
Flag to switch off virial calculation (for debug and MD codes with no barostat)
Definition: PlumedMain.h:140
This is used to create PLMD::Action objects that are run with some set frequency. ...
Definition: ActionPilot.h:39
void setAtomsContiguous(int)
Definition: Atoms.cpp:296
Log & log
Log stream.
Definition: PlumedMain.h:91
std::vector< ActionPilot * > pilots
Set of Pilot actions.
Definition: PlumedMain.h:114
#define CHECK_NULL(val, word)
Definition: PlumedMain.cpp:102
void updateForces()
Definition: Atoms.cpp:237
int getRealPrecision() const
Definition: Atoms.cpp:307
void waitData()
Scatters the needed atoms.
Definition: PlumedMain.cpp:500
static bool convert(const std::string &str, double &t)
Convert a string to a double, reading it.
Definition: Tools.cpp:74
void setAtomsNlocal(int)
Definition: Atoms.cpp:278
Communicator & multi_sim_comm
Definition: PlumedMain.h:78
void load(const std::string &)
Load a shared library.
Definition: PlumedMain.cpp:601
FileBase & link(FILE *)
Link to an already open filed.
Definition: FileBase.cpp:64
Class containing wrappers to MPI.
Definition: Communicator.h:44
void stop()
Stop the calculation cleanly (both the MD code and plumed)
Definition: PlumedMain.cpp:670
void checkRead()
Check if Action was properly read.
Definition: Action.cpp:161
STL namespace.
Class containing atom related quantities from the MD code.
Definition: Atoms.h:45
double bias
The total bias (=total energy of the restraints)
Definition: PlumedMain.h:120
std::string getVersionLong()
Definition: Config.cpp:42
int * stopFlag
Stuff to make plumed stop the MD code cleanly.
Definition: PlumedMain.h:135
Class containing the log stream.
Definition: Log.h:35
void const char const char int * n
Definition: Matrix.h:42
void justCalculate()
Perform the forward loop on active actions.
Definition: PlumedMain.cpp:508
void justApply()
Perform the backward loop on active actions.
Definition: PlumedMain.cpp:548
void setGradientsIfNeeded()
Calculate the gradients and store them for all the values (need for projections)
std::vector< T > select() const
Extract pointers to all Action's of type T To extract all Colvar , use select();.
Definition: ActionSet.h:73
void double2MD(const double &d, void *m) const
Definition: Atoms.cpp:314
void setMDEnergyUnits(double d)
Definition: Atoms.h:176
Used to create a PLMD::Action that has some scalar or vectorial output that may or may not have some ...
void runJobsAtEndOfCalculation()
If there are calculations that need to be done at the very end of the calculations this makes sures t...
Definition: PlumedMain.cpp:674
void share(const std::set< AtomNumber > &)
Definition: Atoms.cpp:145
DLLoader & dlloader
Definition: PlumedMain.h:81
FileBase & flush()
Flushes the file to disk.
Definition: FileBase.cpp:70
int Get_rank() const
Obtain the rank of the present process.
const std::string & error()
Returns the last error in dynamic loader.
Definition: DLLoader.cpp:54
void eraseFile(FileBase &)
Erase a file.
Definition: PlumedMain.cpp:666
void createFullList(int *)
Definition: Atoms.cpp:330
void prepareDependencies()
Prepare the list of active Actions and needed atoms.
Definition: PlumedMain.cpp:449
WithCmd * grex
Definition: PlumedMain.h:85
IFile & open(const std::string &name)
Opens the file.
Definition: IFile.cpp:90
void readInputWords(const std::vector< std::string > &str)
Read an input string.
Definition: PlumedMain.cpp:393
This class is used to bring the relevant information to the Action constructor.
Definition: Action.h:41
void exit(int c=0)
Stop the run.
Definition: PlumedMain.cpp:422
Action used to create objects that access the positions of the atoms from the MD code.
void fflush()
Flush all files.
Definition: PlumedMain.cpp:656
void clearInputForces()
Clear the forces on the values.
static std::vector< std::string > getWords(const std::string &line, const char *sep=NULL, int *parlevel=NULL, const char *parenthesis="{")
Split the line in words using separators.
Definition: Tools.cpp:112
OFile & link(OFile &)
Allows linking this OFile to another one.
Definition: OFile.cpp:71
bool initialized
Flag to avoid double initialization.
Definition: PlumedMain.h:87
int printf(const char *fmt,...)
Formatted output with explicit format - a la printf.
Definition: OFile.cpp:82
static bool getParsedLine(IFile &ifile, std::vector< std::string > &line)
Get a parsed line from the file pointer ifile This function already takes care of joining continued l...
Definition: Tools.cpp:153
const double & getEnergy() const
Get energy units as double.
Definition: Units.h:90
Base class for all the input Actions.
Definition: Action.h:60
void cmd(const std::string &key, const void *val)
Const val version, which indeed just overrides the const and call the virtual method.
Definition: WithCmd.h:44
void setNatoms(int)
Definition: Atoms.cpp:250
bool isOpen()
Check if a file is open.
Definition: FileBase.cpp:134
void setSuffix(const std::string &)
Set the suffix string.
Definition: PlumedMain.h:298
Citations & citations
tools/Citations.holder
Definition: PlumedMain.h:93
Atoms & atoms
Object containing information about atoms (such as positions,...).
Definition: PlumedMain.h:107
void setEnergy(void *)
Definition: Atoms.cpp:102
void setMDLengthUnits(double d)
Definition: Atoms.h:177
Inherit from here if you are calculating the position of a virtual atom (eg a center of mass) ...
std::string cite(const std::string &)
Add a citation.
Definition: Citations.cpp:30
void insertFile(FileBase &)
Insert a file.
Definition: PlumedMain.cpp:662
Class taking care of bibliography.
Definition: Citations.h:54
void setMDTimeUnits(double d)
Definition: Atoms.h:178
std::set< FileBase * >::iterator files_iterator
Definition: PlumedMain.h:132
void calc()
Complete PLUMED calculation.
Definition: PlumedMain.cpp:434
bool active
Condition for plumed to be active.
Definition: PlumedMain.h:101
void startStep()
Definition: Atoms.cpp:66
void setMasses(void *)
Definition: Atoms.cpp:83
void prepareCalc()
Prepare the calculation.
Definition: PlumedMain.cpp:439
Communicator & comm
Communicator for plumed.
Definition: PlumedMain.h:77
void readInputFile(std::string str)
Read an input file.
Definition: PlumedMain.cpp:378
void setAtomsGatindex(int *)
Definition: Atoms.cpp:289
Class for input files.
Definition: IFile.h:40
FILE * fopen(const char *path, const char *mode)
Opens a file.
Definition: PlumedMain.cpp:637
void pause(const std::string &name)
Pause timer named "name".
Definition: Stopwatch.cpp:137
static bool installed()
Returns true if the dynamic loader is available (on some systems it may not).
Definition: DLLoader.cpp:30
ActionSet & actionSet
Set of actions found in plumed.dat file.
Definition: PlumedMain.h:110
void init()
Definition: Atoms.cpp:350
double getOutputQuantity(const unsigned j) const
Get the value of one of the components of the PLMD::Action.
double getBias() const
get the value of the bias
Definition: PlumedMain.cpp:633
std::string getVersionGit()
Definition: Config.cpp:46
void stop(const std::string &name)
Stop timer named "name".
Definition: Stopwatch.cpp:133
const Units & getMDUnits()
Definition: Atoms.h:179
std::set< FileBase * > files
Definition: PlumedMain.h:131
const std::string & getSuffix() const
Get the suffix string.
Definition: PlumedMain.h:293
void cmd(const std::string &key, void *val=NULL)
cmd method, accessible with standard Plumed.h interface.
Definition: PlumedMain.cpp:104
int fclose(FILE *fp)
Closes a file opened with PlumedMain::fopen()
Definition: PlumedMain.cpp:648
const Units & getUnits()
Definition: Atoms.h:181
void * load(const std::string &)
Load a library, returning its handle.
Definition: DLLoader.cpp:39
std::string getSoExt()
Definition: Config.cpp:30
void setDomainDecomposition(Communicator &)
Definition: Atoms.cpp:359
void clearFullList()
Definition: Atoms.cpp:346
virtual void clearDerivatives()
Clear the derivatives of values wrt parameters.
bool detailedTimers
Flag to switch on detailed timers.
Definition: PlumedMain.h:143
std::string suffix
Suffix string for file opening, useful for multiple simulations in the same directory.
Definition: PlumedMain.h:117
void Barrier() const
Wrapper to MPI_Barrier.
void setRealPrecision(int)
Definition: Atoms.cpp:302
void setMDNaturalUnits(bool n)
Definition: Atoms.h:196
Class implementing stopwatch to time execution.
Definition: Stopwatch.h:98
void shareData()
Share the needed atoms.
Definition: PlumedMain.cpp:486
void performCalc()
Perform the calculation.
Definition: PlumedMain.cpp:494
void Set_comm(MPI_Comm)
Set from a real MPI communicator.
static void interpretLabel(std::vector< std::string > &s)
interpret ":" syntax for labels
Definition: Tools.cpp:261
Base class for dealing with files.
Definition: FileBase.h:39
Class providing cmd() access to command line tools.
Definition: CLToolMain.h:77
#define CHECK_NOTINIT(ini, word)
Definition: PlumedMain.cpp:101
double getTimeStep() const
Definition: Atoms.cpp:326
int Get_size() const
Obtain the number of processes.
std::string cite(const std::string &)
Add a citation, returning a string containing the reference number, something like "[10]"...
Definition: PlumedMain.cpp:652
Action * create(const ActionOptions &ao)
Create an Action of the type indicated in the options.
void Set_fcomm(void *comm)
Set from a pointer to a real MPI communicator (FORTRAN)
void const char const char int double * a
Definition: Matrix.h:42
#define CHECK_INIT(ini, word)
Definition: PlumedMain.cpp:100
Stopwatch & stopwatch
Definition: PlumedMain.h:84
OFile & setLinePrefix(const std::string &)
Set the prefix for output.
Definition: OFile.cpp:77
OFile & open(const std::string &name)
Opens the file using automatic append/backup.
Definition: OFile.cpp:264
ExchangePatterns & exchangePatterns
Class of possible exchange patterns, used for BIASEXCHANGE but also for future parallel tempering...
Definition: PlumedMain.h:123
Log & getLog()
Referenge to the log stream.
Definition: PlumedMain.cpp:426
std::string MDEngine
Name of MD engine.
Definition: PlumedMain.h:89
void setForces(void *)
Definition: Atoms.cpp:109
void updateUnits()
Definition: Atoms.cpp:318
void MD2double(const void *m, double &d) const
Definition: Atoms.cpp:311
void start(const std::string &name)
Start timer named "name".
Definition: Stopwatch.cpp:129
void setPositions(void *)
Definition: Atoms.cpp:77
void Abort(int)
Wrapper to MPI_Abort.
void setBox(void *)
Definition: Atoms.cpp:72
void clearDelete()
Clear and deletes all the included pointers.
Definition: ActionSet.cpp:37