All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FuncSumHills.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 "ActionRegister.h"
23 #include "Function.h"
24 #include "tools/Exception.h"
25 #include "tools/Communicator.h"
26 #include "tools/BiasRepresentation.h"
27 #include "tools/File.h"
28 #include "tools/Tools.h"
29 #include <iostream>
30 
31 using namespace std;
32 
33 namespace PLMD{
34 namespace function{
35 
36 
37 //+PLUMEDOC FUNCTION FUNCSUMHILLS
38 /*
39 This function is intended to be called by the command line tool sum_hills
40 and it is meant to integrate a HILLS file or an HILLS file interpreted as
41 a histogram i a variety of ways. Therefore it is not expected that you use this
42 during your dynamics (it will crash!)
43 
44 In the future one could implement periodic integration during the metadynamics
45 or straightforward MD as a tool to check convergence
46 
47 */
48 //+ENDPLUMEDOC
49 
51  vector <string> filenames;
52  vector <IFile*> ifiles;
54  Log *log;
56  unsigned beingread;
57  bool isopen;
58  public:
59  FilesHandler(const vector<string> &filenames, const bool &parallelread , Action &myaction , Log &mylog);
60  bool readBunch(BiasRepresentation *br, int stride);
61  bool scanOneHill(BiasRepresentation *br, IFile *ifile );
62  void getMinMaxBin(vector<Value*> vals, Communicator &cc, vector<double> &vmin, vector<double> &vmax, vector<unsigned> &vbin);
63  void getMinMaxBin(vector<Value*> vals, Communicator &cc, vector<double> &vmin, vector<double> &vmax, vector<unsigned> &vbin, vector<double> &histosigma);
64  ~FilesHandler();
65 };
66 FilesHandler::FilesHandler(const vector<string> &filenames, const bool &parallelread , Action &action , Log &mylog ):filenames(filenames),log(&mylog),parallelread(parallelread),beingread(0),isopen(false){
67  this->action=&action;
68  for(unsigned i=0;i<filenames.size();i++){
69  IFile *ifile = new IFile();
70  ifile->link(action);
71  ifiles.push_back(ifile);
72  plumed_massert((ifile->FileExist(filenames[i])), "the file "+filenames[i]+" does not exist " );
73  }
74 
75 }
76 
78  for(unsigned i=0;i<ifiles.size();i++) delete ifiles[i];
79 }
80 
81 // note that the FileHandler is completely transparent respect to the biasrepresentation
82 // no check are made at this level
83 bool FilesHandler::readBunch(BiasRepresentation *br , int stride = -1){
84  bool morefiles; morefiles=true;
85  if(parallelread){
86  (*log)<<" doing parallelread \n";
87  plumed_merror("parallelread is not yet implemented !!!");
88  }else{
89  (*log)<<" doing serialread \n";
90  // read one by one hills
91  // is the type defined? if not, assume it is a gaussian
92  IFile *ff;
93  ff=ifiles[beingread];
94  if(!isopen){
95  (*log)<<" opening file "<<filenames[beingread]<<"\n";
96  ff->open(filenames[beingread]);isopen=true;
97  }
98  int n;
99  while(true){
100  bool fileisover=true;
101  while(scanOneHill(br,ff)){
102  // here do the dump if needed
103  n=br->getNumberOfKernels();
104  if(stride>0 && n%stride==0 && n!=0 ){
105  (*log)<<" done with this chunk: now with "<<n<<" kernels \n";
106  fileisover=false;
107  break;
108  }
109  }
110  if(fileisover){
111  (*log)<<" closing file "<<filenames[beingread]<<"\n";
112  ff->close();
113  isopen=false;
114  (*log)<<" now total "<<br->getNumberOfKernels()<<" kernels \n";
115  beingread++;
116  if(beingread<ifiles.size()){
117  ff=ifiles[beingread];ff->open(filenames[beingread]);
118  (*log)<<" opening file "<<filenames[beingread]<<"\n";
119  isopen=true;
120  }else{morefiles=false;
121  (*log)<<" final chunk: now with "<<n<<" kernels \n";
122  break;
123  }
124  }
125  // if there are no more files to read and this file is over then quit
126  if(fileisover && !morefiles){break;}
127  // if you are in the middle of a file and you are here
128  // then means that you read what you need to read
129  if(!fileisover ){break;}
130  }
131  }
132  return morefiles;
133 }
134 void FilesHandler::getMinMaxBin(vector<Value*> vals, Communicator &cc, vector<double> &vmin, vector<double> &vmax, vector<unsigned> &vbin){
135  // create the representation (no grid)
136  BiasRepresentation br(vals,cc);
137  // read all the kernels
138  readBunch(&br);
139  // loop over the kernels and get the support
140  br.getMinMaxBin(vmin,vmax,vbin);
141 }
142 void FilesHandler::getMinMaxBin(vector<Value*> vals, Communicator &cc, vector<double> &vmin, vector<double> &vmax, vector<unsigned> &vbin, vector<double> &histosigma){
143  BiasRepresentation br(vals,cc,histosigma);
144  // read all the kernels
145  readBunch(&br);
146  // loop over the kernels and get the support
147  br.getMinMaxBin(vmin,vmax,vbin);
148  //for(unsigned i=0;i<vals.size();i++){cerr<<"XXX "<<vmin[i]<<" "<<vmax[i]<<" "<<vbin[i]<<"\n";}
149 }
151  double dummy;
152  if(ifile->scanField("time",dummy)){
153  //(*log)<<" scanning one hill: "<<dummy<<" \n";
154  ifile->scanField("biasf",dummy);
155  if(ifile->FieldExist("clock")) ifile->scanField("clock",dummy);
156  // keep this intermediate function in case you need to parse more data in the future
157  br->pushKernel(ifile);
158  //(*log)<<" read hill\n";
159  if(br->hasSigmaInInput())ifile->allowIgnoredFields();
160  ifile->scanField();
161  return true;
162  }else{
163  return false;
164  }
165 }
166 
167 
168 double mylog( double v1 ){
169  return log(v1);
170 }
171 
172 double mylogder( double v1 ){
173  return 1./v1;
174 }
175 
176 
177 
179  public Function
180 {
181  vector<string> hillsFiles,histoFiles;
182  vector<string> proj;
186  bool nohistory;
187  double beta;
191 public:
192  FuncSumHills(const ActionOptions&);
193  ~FuncSumHills();
194  void calculate(); // this probably is not needed
195  bool checkFilesAreExisting(const vector<string> & hills );
196  static void registerKeywords(Keywords& keys);
197 };
198 
199 PLUMED_REGISTER_ACTION(FuncSumHills,"FUNCSUMHILLS")
200 
201 void FuncSumHills::registerKeywords(Keywords& keys){
203  keys.use("ARG");
204  keys.add("optional","HILLSFILES"," source file for hills creation(may be the same as HILLS)"); // this can be a vector!
205  keys.add("optional","HISTOFILES"," source file for histogram creation(may be the same as HILLS)"); // also this can be a vector!
206  keys.add("optional","HISTOSIGMA"," sigmas for binning when the histogram correction is needed ");
207  keys.add("optional","PROJ"," only with sumhills: the projection on the cvs");
208  keys.add("optional","KT"," only with sumhills: the kt factor when projection on cvs");
209  keys.add("optional","GRID_MIN","the lower bounds for the grid");
210  keys.add("optional","GRID_MAX","the upper bounds for the grid");
211  keys.add("optional","GRID_BIN","the number of bins for the grid");
212  keys.add("optional","OUTHILLS"," output file for hills ");
213  keys.add("optional","OUTHISTO"," output file for histogram ");
214  keys.add("optional","INITSTRIDE"," stride if you want an initial dump ");
215  keys.add("optional","STRIDE"," stride when you do it on the fly ");
216  keys.addFlag("ISCLTOOL",true,"use via plumed commandline: calculate at read phase and then go");
217  keys.addFlag("PARALLELREAD",false,"read parallel HILLS file");
218  keys.addFlag("NEGBIAS",false,"dump negative bias ( -bias ) instead of the free energy: needed in welltempered with flexible hills ");
219  keys.addFlag("NOHISTORY",false,"to be used with INITSTRIDE: it splits the bias/histogram in pieces without previous history ");
220  keys.add("optional","FMT","the format that should be used to output real numbers");
221 }
222 
224 Action(ao),
225 Function(ao),
226 initstride(-1),
227 iscltool(false),
228 integratehills(false),
229 integratehisto(false),
230 parallelread(false),
231 negativebias(false),
232 nohistory(false),
233 beta(-1.),
234 fmt("%14.9f"),
235 biasrep(NULL),
236 historep(NULL)
237 {
238 
239  // format
240  parse("FMT",fmt);
241  log<<" Output format is "<<fmt<<"\n";
242  // here read
243  // Grid Stuff
244  vector<std::string> gmin;
245  parseVector("GRID_MIN",gmin);
246  if(gmin.size()!=getNumberOfArguments() && gmin.size()!=0) error("not enough values for GRID_MIN");
247  plumed_massert(gmin.size()==getNumberOfArguments() || gmin.size()==0,"need GRID_MIN argument for this") ;
248  vector<std::string> gmax;
249  parseVector("GRID_MAX",gmax);
250  if(gmax.size()!=getNumberOfArguments() && gmax.size()!=0) error("not enough values for GRID_MAX");
251  plumed_massert(gmax.size()==getNumberOfArguments() || gmax.size()==0,"need GRID_MAX argument for this") ;
252  vector<unsigned> gbin;
253  parseVector("GRID_BIN",gbin);
254  plumed_massert(gbin.size()==getNumberOfArguments() || gbin.size()==0,"need GRID_BIN argument for this");
255  if(gbin.size()!=getNumberOfArguments() && gbin.size()!=0) error("not enough values for GRID_BIN");
256  //plumed_assert(getNumberOfArguments()==gbin.size());
257 
258  // hills file:
259  parseVector("HILLSFILES",hillsFiles);
260  if(hillsFiles.size()==0){
261  integratehills=false; // default behaviour
262  }else{
263  integratehills=true;
264  for(unsigned i=0;i<hillsFiles.size();i++) log<<" hillsfile : "<<hillsFiles[i]<<"\n";
265  }
266  // histo file:
267  parseVector("HISTOFILES",histoFiles);
268  if(histoFiles.size()==0){
269  integratehisto=false;
270  }else{
271  integratehisto=true;
272  for(unsigned i=0;i<histoFiles.size();i++) log<<" histofile : "<<histoFiles[i]<<"\n";
273  }
274  vector<double> histoSigma;
275  if(integratehisto){
276  parseVector("HISTOSIGMA",histoSigma);
277  plumed_massert(histoSigma.size()==getNumberOfArguments()," The number of sigmas must be the same of the number of arguments ");
278  for(unsigned i=0;i<histoSigma.size();i++) log<<" histosigma : "<<histoSigma[i]<<"\n";
279  }
280 
281  // add some automatic hills width: not in case stride is defined
282  // since when you start from zero the automatic size will be zero!
283  if(gmin.size()==0 || gmax.size()==0){
284  log<<" \n";
285  log<<" No boundaries defined: need to do a prescreening of hills \n";
286  std::vector<Value*> tmpvalues;
287  for(unsigned i=0;i<getNumberOfArguments();i++)tmpvalues.push_back( getPntrToArgument(i) );
288  if(integratehills) {
289  FilesHandler *hillsHandler;
290  hillsHandler=new FilesHandler(hillsFiles,parallelread,*this, log);
291  vector<double> vmin,vmax;
292  vector<unsigned> vbin;
293  hillsHandler->getMinMaxBin(tmpvalues,comm,vmin,vmax,vbin);
294  log<<" found boundaries from hillsfile: \n";
295  gmin.resize(vmin.size());
296  gmax.resize(vmax.size());
297  if(gbin.size()==0){
298  gbin=vbin;
299  }else{
300  log<<" found nbins in input, this overrides the automatic choice \n";
301  }
302  for(unsigned i=0;i<getNumberOfArguments();i++){
303  Tools::convert(vmin[i],gmin[i]);
304  Tools::convert(vmax[i],gmax[i]);
305  log<<" variable "<< getPntrToArgument(i)->getName()<<" min: "<<gmin[i]<<" max: "<<gmax[i]<<" nbin: "<<gbin[i]<<"\n";
306  }
307  delete hillsHandler;
308  }
309  // if at this stage bins are not there then do it with histo
310  if(gmin.size()==0){
311  FilesHandler *histoHandler;
312  histoHandler=new FilesHandler(histoFiles,parallelread,*this, log);
313  vector<double> vmin,vmax;
314  vector<unsigned> vbin;
315  histoHandler->getMinMaxBin(tmpvalues,comm,vmin,vmax,vbin,histoSigma);
316  log<<" found boundaries from histofile: \n";
317  gmin.resize(vmin.size());
318  gmax.resize(vmax.size());
319  if(gbin.size()==0){
320  gbin=vbin;
321  }else{
322  log<<" found nbins in input, this overrides the automatic choice \n";
323  }
324  for(unsigned i=0;i<getNumberOfArguments();i++){
325  Tools::convert(vmin[i],gmin[i]);
326  Tools::convert(vmax[i],gmax[i]);
327  log<<" variable "<< getPntrToArgument(i)->getName()<<" min: "<<gmin[i]<<" max: "<<gmax[i]<<" nbin: "<<gbin[i]<<"\n";
328  }
329  delete histoHandler;
330  }
331  log<<" done!\n";
332  log<<" \n";
333  }
334 
335  // needs a projection?
336  proj.clear();
337  parseVector("PROJ",proj);
338  plumed_massert(proj.size()<getNumberOfArguments()," The number of projection must be less than the full list of arguments ");
339 
340  if( proj.size() != 0 || integratehisto==true ) {
341  parse("KT",beta);
342  for(unsigned i=0;i<proj.size();i++) log<<" projection "<<i<<" : "<<proj[i]<<"\n";
343  plumed_massert(beta>0.,"if you make a projection or a histogram correction then you need KT flag!");
344  beta=1./beta;
345  log<<" beta is "<<beta<<"\n";
346  }
347  // is a cltool: then you start and then die
348  parseFlag("ISCLTOOL",iscltool);
349  //
350  parseFlag("NEGBIAS",negativebias);
351  //
352  parseFlag("PARALLELREAD",parallelread);
353  // stride
354  parse("INITSTRIDE",initstride);
355  // output suffix or names
356  if(initstride<0){ log<<" Doing only one integration: no stride \n";
357  outhills="fes.dat";outhisto="correction.dat";}
358  else{outhills="fes_";outhisto="correction_";
359  log<<" Doing integration slices every "<<initstride<<" kernels\n";
360  parseFlag("NOHISTORY",nohistory);
361  if(nohistory)log<<" nohistory: each stride block has no memory of the previous block\n";
362  }
363 
364  //what might it be this?
365  // here start
366  // want something right now?? do it and return
367  // your argument is a set of cvs
368  // then you need: a hills / a colvar-like file (to do a histogram)
369  // create a bias representation for this
370  if(iscltool){
371 
372  std::vector<Value*> tmpvalues;
373  for(unsigned i=0;i<getNumberOfArguments();i++){
374  // allocate a new value from the old one: no deriv here
375  tmpvalues.push_back( getPntrToArgument(i) );
376  }
377 
378  // check if the files exists
379  if(integratehills){
381  biasrep=new BiasRepresentation(tmpvalues,comm, gmin, gmax, gbin);
382  if(negativebias){
383  biasrep->setRescaledToBias(true);
384  log<<" required the -bias instead of the free energy \n";
385  if(initstride<0){outhills="negativebias.dat";}
386  else{outhills="negativebias_";}
387  }
388  }
389 
390  parse("OUTHILLS",outhills);
391  parse("OUTHISTO",outhisto);
392  if(integratehills)log<<" output file for fes/bias is : "<<outhills<<"\n";
393  if(integratehisto)log<<" output file for correction is : "<<outhisto<<"\n";
394  checkRead();
395 
396  log<<"\n";
397  log<<" Now calculating...\n";
398  log<<"\n";
399 
400  if(integratehisto){
402  historep=new BiasRepresentation(tmpvalues,comm,gmin,gmax,gbin,histoSigma);
403  }
404 
405  // decide how to source hills ( serial/parallel )
406  // here below the input control
407  // say how many hills and it will read them from the
408  // bunch of files provided, will update the representation
409  // of hills (i.e. a list of hills and the associated grid)
410 
411  // decide how to source colvars ( serial parallel )
412  FilesHandler *hillsHandler;
413  FilesHandler *histoHandler;
414 
415  hillsHandler=NULL;
416  histoHandler=NULL;
417 
418  if(integratehills) hillsHandler=new FilesHandler(hillsFiles,parallelread,*this, log);
419  if(integratehisto) histoHandler=new FilesHandler(histoFiles,parallelread,*this, log);
420 
421  // read a number of hills and put in the bias representation
422  int nfiles=0;
423  bool ibias=integratehills; bool ihisto=integratehisto;
424  while(true){
425  if( integratehills && ibias ){
426  if(nohistory){biasrep->clear();log<<" clearing history before reading a new block\n";};
427  log<<" reading hills: \n";
428  ibias=hillsHandler->readBunch(biasrep,initstride) ; log<<"\n";
429  }
430 
431  if( integratehisto && ihisto ){
432  if(nohistory){historep->clear();log<<" clearing history before reading a new block\n";};
433  log<<" reading histogram: \n";
434  ihisto=histoHandler->readBunch(historep,initstride) ; log<<"\n";
435  }
436 
437  // dump: need to project?
438  if(proj.size()!=0){
439 
440  if(integratehills){
441 
442  log<<" Bias: Projecting on subgrid... \n";
443  BiasWeight *Bw=new BiasWeight(beta);
444  Grid biasGrid=*(biasrep->getGridPtr());
445  Grid smallGrid=biasGrid.project(proj,Bw);
446  OFile gridfile; gridfile.link(*this);
447  std::ostringstream ostr;ostr<<nfiles;
448  string myout;
449  if(initstride>0){ myout=outhills+ostr.str()+".dat" ;}else{myout=outhills;}
450  log<<" Bias: Writing subgrid on file "<<myout<<" \n";
451  gridfile.open(myout);
452  smallGrid.setOutputFmt(fmt);
453  smallGrid.writeToFile(gridfile);
454  gridfile.close();
455  if(!ibias)integratehills=false;// once you get to the final bunch just give up
456  delete Bw;
457  }
458  if(integratehisto){
459 
460  log<<" Histo: Projecting on subgrid... \n";
461  ProbWeight *Pw=new ProbWeight(beta);
462  Grid histoGrid=*(historep->getGridPtr());
463  Grid smallGrid=histoGrid.project(proj,Pw);
464 
465  OFile gridfile; gridfile.link(*this);
466  std::ostringstream ostr;ostr<<nfiles;
467  string myout;
468  if(initstride>0){ myout=outhisto+ostr.str()+".dat" ;}else{myout=outhisto;}
469  log<<" Histo: Writing subgrid on file "<<myout<<" \n";
470  gridfile.open(myout);
471 
472  smallGrid.setOutputFmt(fmt);
473  smallGrid.writeToFile(gridfile);
474  gridfile.close();
475 
476  if(!ihisto)integratehisto=false;// once you get to the final bunch just give up
477  }
478 
479  }else{
480 
481  if(integratehills){
482 
483  Grid biasGrid=*(biasrep->getGridPtr());
484  biasGrid.scaleAllValuesAndDerivatives(-1.);
485 
486  OFile gridfile; gridfile.link(*this);
487  std::ostringstream ostr;ostr<<nfiles;
488  string myout;
489  if(initstride>0){ myout=outhills+ostr.str()+".dat" ;}else{myout=outhills;}
490  log<<" Writing full grid on file "<<myout<<" \n";
491  gridfile.open(myout);
492 
493  biasGrid.setOutputFmt(fmt);
494  biasGrid.writeToFile(gridfile);
495  gridfile.close();
496  // rescale back prior to accumulate
497  if(!ibias)integratehills=false;// once you get to the final bunch just give up
498  }
499  if(integratehisto){
500 
501  Grid histoGrid=*(historep->getGridPtr());
503  histoGrid.scaleAllValuesAndDerivatives(-1./beta);
504 
505  OFile gridfile; gridfile.link(*this);
506  std::ostringstream ostr;ostr<<nfiles;
507  string myout;
508  if(initstride>0){ myout=outhisto+ostr.str()+".dat" ;}else{myout=outhisto;}
509  log<<" Writing full grid on file "<<myout<<" \n";
510  gridfile.open(myout);
511 
512  histoGrid.setOutputFmt(fmt);
513  histoGrid.writeToFile(gridfile);
514  gridfile.close();
515 
516  if(!ihisto)integratehisto=false;// once you get to the final bunch just give up
517  }
518  }
519  if ( !ibias && !ihisto) break; //when both are over then just quit
520 
521  nfiles++;
522  }
523  if(hillsHandler) delete hillsHandler;
524  if(histoHandler) delete histoHandler;
525 
526  return;
527  }
528  // just an initialization but you need to do something on the fly?: need to connect with a metad run and its grid representation
529  // your argument is a metad run
530  // if the grid does not exist crash and say that you need some data
531  // otherwise just link with it
532 
533 }
534 
536  // this should be connected only with a grid representation to metadynamics
537  // at regular time just dump it
538  plumed_merror("You should have never got here: this stuff is not yet implemented!");
539 }
540 
542  if(historep) delete historep;
543  if(biasrep) delete biasrep;
544 }
545 
546 bool FuncSumHills::checkFilesAreExisting(const vector<string> & hills ){
547  plumed_massert(hills.size()!=0,"the number of files provided should be at least one" );
548  IFile *ifile = new IFile();
549  ifile->link(*this);
550  for(unsigned i=0; i< hills.size();i++){
551  plumed_massert(ifile->FileExist(hills[i]),"missing file "+hills[i]);
552  }
553  delete ifile;
554  return true;
555 
556 }
557 
558 }
559 
560 }
561 
562 
bool FieldExist(const std::string &s)
Check if a field exist.
Definition: IFile.cpp:104
double mylogder(double v1)
const std::string & getName() const
Get the name of the quantity.
Definition: Value.h:196
void parseFlag(const std::string &key, bool &t)
Parse one keyword as boolean flag.
Definition: Action.cpp:104
Log & log
Reference to the log stream.
Definition: Action.h:93
Grid project(const std::vector< std::string > &proj, WeightBase *ptr2obj)
project a high dimensional grid onto a low dimensional one: this should be changed at some time to en...
Definition: Grid.cpp:751
void pushKernel(IFile *ff)
push a kernel on the representation (includes widths and height)
bool hasSigmaInInput()
check if the sigma values are already provided (in case of a histogram representation with input sigm...
Grid * getGridPtr()
get the pointer to the grid
BiasRepresentation * biasrep
void getMinMaxBin(vector< double > &vmin, vector< double > &vmax, vector< unsigned > &vbin)
get an automatic min/max from the set so to know how to configure the grid
static bool convert(const std::string &str, double &t)
Convert a string to a double, reading it.
Definition: Tools.cpp:74
void error(const std::string &msg) const
Crash calculation and print documentation.
Definition: Action.cpp:195
Provides the keyword FUNCSUMHILLS
FileBase & link(FILE *)
Link to an already open filed.
Definition: FileBase.cpp:64
Class containing wrappers to MPI.
Definition: Communicator.h:44
void checkRead()
Check if Action was properly read.
Definition: Action.cpp:161
STL namespace.
Value * getPntrToArgument(const unsigned n)
Return a pointer to specific argument.
Communicator & comm
Definition: Action.h:158
double mylog(double v1)
bool checkFilesAreExisting(const vector< string > &hills)
BiasRepresentation * historep
Class containing the log stream.
Definition: Log.h:35
void const char const char int * n
Definition: Matrix.h:42
static void registerKeywords(Keywords &keys)
int getNumberOfKernels()
get the number of kernels contained in the representation
void clear()
clear the representation (grid included)
void parse(const std::string &key, T &t)
Parse one keyword as generic type.
Definition: Action.h:273
This class holds the keywords and their documentation.
Definition: Keywords.h:36
FuncSumHills(const ActionOptions &)
IFile & open(const std::string &name)
Opens the file.
Definition: IFile.cpp:90
This class is used to bring the relevant information to the Action constructor.
Definition: Action.h:41
OFile & link(OFile &)
Allows linking this OFile to another one.
Definition: OFile.cpp:71
bool scanOneHill(BiasRepresentation *br, IFile *ifile)
virtual void applyFunctionAllValuesAndDerivatives(double(*func)(double val), double(*funcder)(double valder))
apply function: takes pointer to function that accepts a double and apply
Definition: Grid.cpp:511
void close()
Closes the file Should be used only for explicitely opened files.
Definition: FileBase.cpp:140
Base class for all the input Actions.
Definition: Action.h:60
bool readBunch(BiasRepresentation *br, int stride)
void parseVector(const std::string &key, std::vector< T > &t)
Parse one keyword as std::vector.
Definition: Action.h:311
void getMinMaxBin(vector< Value * > vals, Communicator &cc, vector< double > &vmin, vector< double > &vmax, vector< unsigned > &vbin)
static void registerKeywords(Keywords &)
Definition: Function.cpp:28
Class for input files.
Definition: IFile.h:40
void setRescaledToBias(bool rescaled)
set the flag that rescales the free energy to the bias
static int dummy
Definition: Plumed.c:80
virtual void writeToFile(OFile &)
dump grid on file
Definition: Grid.cpp:531
IFile & scanField(const std::string &, double &)
Read a double field.
Definition: IFile.cpp:121
void calculate()
Calculate an Action.
Class for output files.
Definition: OFile.h:84
virtual void scaleAllValuesAndDerivatives(const double &scalef)
Scale all grid values and derivatives by a constant factor.
Definition: Grid.cpp:500
bool FileExist(const std::string &path)
Check if the file exists.
Definition: FileBase.cpp:118
This is the abstract base class to use for implementing new CV function, within it there is informati...
Definition: Function.h:37
void setOutputFmt(std::string ss)
set output format
Definition: Grid.h:191
unsigned getNumberOfArguments() const
Returns the number of arguments.
OFile & open(const std::string &name)
Opens the file using automatic append/backup.
Definition: OFile.cpp:264
this class implements a general purpose class that aims to provide a Grid/list transparently add gaus...
void allowIgnoredFields()
Allow some of the fields in the input to be ignored.
Definition: IFile.cpp:199