All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SumHills.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 "CLTool.h"
23 #include "CLToolRegister.h"
24 #include "tools/Tools.h"
25 #include "core/Action.h"
26 #include "core/ActionRegister.h"
27 #include "core/PlumedMain.h"
28 #include "tools/Communicator.h"
29 #include "tools/Random.h"
30 #include <cstdio>
31 #include <string>
32 #include <vector>
33 #include <iostream>
34 #include "tools/File.h"
35 #include "core/Value.h"
36 #include "tools/Matrix.h"
37 
38 using namespace std;
39 
40 namespace PLMD {
41 namespace cltools {
42 
43 //+PLUMEDOC TOOLS sum_hills
44 /*
45 sum_hills is a tool that allows one to to use plumed to post-process an existing hills/colvar file
46 
47 \par Examples
48 
49 a typical case is about the integration of a hills file:
50 
51 \verbatim
52 plumed sum_hills --hills PATHTOMYHILLSFILE
53 \endverbatim
54 
55 The default name for the output file will be fes.dat
56 Note that starting from this version plumed will automatically detect the
57 number of the variables you have and their periodicity.
58 Additionally, if you use flexible hills (multivariate gaussians), plumed will understand it from the HILLS file.
59 
60 now sum_hills tool accepts als multiple files that will be integrated one after the other
61 
62 \verbatim
63 plumed sum_hills --hills PATHTOMYHILLSFILE1,PATHTOMYHILLSFILE2,PATHTOMYHILLSFILE3
64 \endverbatim
65 
66 if you want to integrate out some variable you do
67 
68 \verbatim
69 plumed sum_hills --hills PATHTOMYHILLSFILE --idw t1 --kt 0.6
70 \endverbatim
71 
72 where with --idw you define the variables that you want
73 all the others will be integrated out. --kt defines the temperature of the system in energy units.
74 (be consistent with the units you have in your hills: plumed will not check this for you)
75 If you need more variables then you may use a comma separated syntax
76 
77 \verbatim
78 plumed sum_hills --hills PATHTOMYHILLSFILE --idw t1,t2 --kt 0.6
79 \endverbatim
80 
81 You can define the output grid only with the number of bins you want
82 while min/max will be detected for you
83 
84 \verbatim
85 plumed sum_hills --bin 99,99 --hills PATHTOMYHILLSFILE
86 \endverbatim
87 
88 or full grid specification
89 
90 \verbatim
91 plumed sum_hills --bin 99,99 --min -pi,-pi --max pi,pi --hills PATHTOMYHILLSFILE
92 \endverbatim
93 
94 You can of course use numbers instead of -pi/pi.
95 
96 You can use a --stride keyword to have a dump each bunch of hills you read
97 \verbatim
98 plumed sum_hills --stride 300 --hills PATHTOMYHILLSFILE
99 \endverbatim
100 
101 You can also have, in case of welltempered metadynamics, only the negative
102 bias instead of the free energy through the keyword --negbias
103 
104 \verbatim
105 plumed sum_hills --negbias --hills PATHTOMYHILLSFILE
106 \endverbatim
107 
108 Here the default name will be negativebias.dat
109 
110 From time to time you might need to use HILLS or a COLVAR file
111 as it was just a simple set of points from which you want to build
112 a free energy by using -(1/beta)log(P)
113 then you use --histo
114 
115 \verbatim
116 plumed sum_hills --histo PATHTOMYCOLVARORHILLSFILE --sigma 0.2,0.2 --kt 0.6
117 \endverbatim
118 
119 in this case you need a --kt to do the reweighting and then you
120 need also some width (with the --sigma keyword) for the histogram calculation (actually will be done with
121 gaussians, so it will be a continuous histogram)
122 Here the default output will be correction.dat.
123 Note that also here you can have multiple input files separated by a comma.
124 
125 Additionally, if you want to do histogram and hills from the same file you can do as this
126 \verbatim
127 plumed sum_hills --hills --histo PATHTOMYCOLVARORHILLSFILE --sigma 0.2,0.2 --kt 0.6
128 \endverbatim
129 The two files can be eventually the same
130 
131 Another interesting thing one can do is monitor the difference in blocks as a metadynamics goes on.
132 When the bias deposited is constant over the whole domain one can consider to be at convergence.
133 This can be done with the --nohistory keyword
134 
135 \verbatim
136 plumed sum_hills --stride 300 --hills PATHTOMYHILLSFILE --nohistory
137 \endverbatim
138 
139 and similarly one can do the same for an histogram file
140 
141 \verbatim
142 plumed sum_hills --histo PATHTOMYCOLVARORHILLSFILE --sigma 0.2,0.2 --kt 0.6 --nohistory
143 \endverbatim
144 
145 just to check the hypothetical free energy calculated in single blocks of time during a simulation
146 and not in a cumulative way
147 
148 Output format can be controlled via the --fmt field
149 
150 \verbatim
151 plumed sum_hills --hills PATHTOMYHILLSFILE --fmt %8.3f
152 \endverbatim
153 
154 where here we chose a float with length of 8 and 3 digits
155 
156 The output can be named in a arbitrary way :
157 
158 \verbatim
159 plumed sum_hills --hills PATHTOMYHILLSFILE --outfile myfes.dat
160 \endverbatim
161 
162 will produce a file myfes.dat which contains the free energy.
163 
164 If you use stride, this keyword is the suffix
165 
166 \verbatim
167 plumed sum_hills --hills PATHTOMYHILLSFILE --outfile myfes_ --stride 100
168 \endverbatim
169 
170 will produce myfes_0.dat, myfes_1.dat, myfes_2.dat etc.
171 
172 The same is true for the output coming from histogram corrections
173 \verbatim
174 plumed sum_hills --histo HILLS --kt 2.5 --sigma 0.01 --outhisto mycorrection.dat
175 \endverbatim
176 
177 is producing a file mycorrection.dat
178 while, when using stride, this is the suffix
179 
180 \verbatim
181 plumed sum_hills --histo HILLS --kt 2.5 --sigma 0.01 --outhisto mycorrection_ --stride 100
182 \endverbatim
183 
184 that gives mycorrection_0.dat, mycorrection_1.dat, mycorrection_3.dat etc..
185 
186 */
187 //+ENDPLUMEDOC
188 
189 class CLToolSumHills : public CLTool {
190 public:
191  static void registerKeywords( Keywords& keys );
192  CLToolSumHills(const CLToolOptions& co );
193  int main(FILE* in,FILE*out,Communicator& pc);
194  string description()const;
195 /// find a list of variables present, if they are periodic and which is the period
196 /// return false if the file does not exist
197  static bool findCvsAndPeriodic(std::string filename, std::vector< std::vector <std::string> > &cvs,std::vector<std::string> &pmin,std::vector<std::string> &pmax, bool &multivariate);
198 };
199 
200 void CLToolSumHills::registerKeywords( Keywords& keys ){
201  CLTool::registerKeywords( keys );
202  keys.addFlag("--help-debug",false,"print special options that can be used to create regtests");
203  keys.add("optional","--hills","specify the name of the hills file");
204  keys.add("optional","--histo","specify the name of the file for histogram a colvar/hills file is good");
205  keys.add("optional","--stride","specify the stride for integrating hills file (default 0=never)");
206  keys.add("optional","--min","the lower bounds for the grid");
207  keys.add("optional","--max","the upper bounds for the grid");
208  keys.add("optional","--bin","the number of bins for the grid");
209  keys.add("optional","--idw","specify the variables to be integrated (default is all)");
210  keys.add("optional","--outfile","specify the outputfile for sumhills");
211  keys.add("optional","--outhisto","specify the outputfile for the histogram");
212  keys.add("optional","--kt","specify temperature for integrating out variables");
213  keys.add("optional","--sigma"," a vector that specify the sigma for binning (only needed when doing histogram ");
214  keys.addFlag("--negbias",false," print the negative bias instead of the free energy (only needed with welltempered runs and flexible hills) ");
215  keys.addFlag("--nohistory",false," to be used with --stride: it splits the bias/histogram in pieces without previous history ");
216  keys.add("optional","--fmt","specify the output format");
217 }
218 
219 CLToolSumHills::CLToolSumHills(const CLToolOptions& co ):
220 CLTool(co)
221 {
223 }
224 
225 string CLToolSumHills::description()const{ return "sum the hills with plumed"; }
226 
227 int CLToolSumHills::main(FILE* in,FILE*out,Communicator& pc){
228 
229 // Read the hills input file name
230  vector<string> hillsFiles;
231  bool dohills;
232  dohills=parseVector("--hills",hillsFiles);
233 // Read the histogram file
234  vector<string> histoFiles;
235  bool dohisto;
236  dohisto=parseVector("--histo",histoFiles);
237 
238  plumed_massert(dohisto || dohills,"you should use --histo or/and --hills command");
239 
240  vector< vector<string> > vcvs;
241  vector<string> vpmin;
242  vector<string> vpmax;
243  bool vmultivariate;
244  if(dohills){
245  // parse it as it was a restart
246  findCvsAndPeriodic(hillsFiles[0], vcvs, vpmin, vpmax, vmultivariate);
247  }
248 
249  vector< vector<string> > hcvs;
250  vector<string> hpmin;
251  vector<string> hpmax;
252  bool hmultivariate;
253 
254  vector<std::string> sigma;
255  if(dohisto){
256  findCvsAndPeriodic(histoFiles[0], hcvs, hpmin, hpmax, hmultivariate);
257  // here need also the vector of sigmas
258  parseVector("--sigma",sigma);
259  if(sigma.size()!=hcvs.size())plumed_merror("you should define --sigma vector when using histogram");
260  }
261 
262  if(dohisto && dohills){
263  plumed_massert(vcvs==hcvs,"variables for histogram and bias should have the same labels");
264  plumed_massert(hpmin==vpmin,"variables for histogram and bias should have the same min for periodicity");
265  plumed_massert(hpmax==vpmax,"variables for histogram and bias should have the same max for periodicity");
266  }
267 
268  // now put into a neutral vector
269 
270  vector< vector<string> > cvs;
271  vector<string> pmin;
272  vector<string> pmax;
273 
274  if(dohills){
275  cvs=vcvs;
276  pmin=vpmin;
277  pmax=vpmax;
278  }
279  if(dohisto){
280  cvs=hcvs;
281  pmin=hpmin;
282  pmax=hpmax;
283  }
284 
285 
286  // setup grids
287  unsigned grid_check=0;
288  vector<std::string> gmin(cvs.size());
289  if(parseVector("--min",gmin)){
290  if(gmin.size()!=cvs.size() && gmin.size()!=0) plumed_merror("not enough values for --min");
291  grid_check++;
292  }
293  vector<std::string> gmax(cvs.size() );
294  if(parseVector("--max",gmax)){
295  if(gmax.size()!=cvs.size() && gmax.size()!=0) plumed_merror("not enough values for --max");
296  grid_check++;
297  }
298  vector<std::string> gbin(cvs.size());
299  bool grid_has_bin; grid_has_bin=false;
300  if(parseVector("--bin",gbin)){
301  if(gbin.size()!=cvs.size() && gbin.size()!=0) plumed_merror("not enough values for --bin");
302  grid_has_bin=true;
303  }
304  // allowed: no grids only bin
305  // not allowed: partial grid definition
306  plumed_massert( gmin.size()==gmax.size() && (gmin.size()==0 || gmin.size()==cvs.size() ) ,"you should specify --min and --max together with same number of components");
307 
308 
309 
311  std::string ss;
312  unsigned nn=1;
313  ss="setNatoms";
314  plumed.cmd(ss,&nn);
315  if(Communicator::initialized()) plumed.cmd("setMPIComm",&pc.Get_comm());
316  plumed.cmd("init",&nn);
317  vector <bool> isdone(cvs.size(),false);
318  for(int i=0;i<cvs.size();i++){
319  if(!isdone[i]){
320  isdone[i]=true;
321  std::vector<std::string> actioninput;
322  std::vector <unsigned> inds;
323  actioninput.push_back("FAKE");
324  actioninput.push_back("ATOMS=1");
325  actioninput.push_back("LABEL="+cvs[i][0]);
326  std::vector<std::string> comps, periods;
327  if(cvs[i].size()>1){comps.push_back(cvs[i][1]);inds.push_back(i);}
328  periods.push_back(pmin[i]);periods.push_back(pmax[i]);
329  for(unsigned j=i+1;j<cvs.size();j++){
330  if(cvs[i][0]==cvs[j][0] && !isdone[j]){
331  if(cvs[i].size()==1 || cvs[j].size()==1 )plumed_merror("you cannot have twice the same label and no components ");
332  if(cvs[j].size()>1){
333  comps.push_back(cvs[j][1]);
334  periods.push_back(pmin[j]);periods.push_back(pmax[j]);
335  isdone[j]=true; inds.push_back(j);
336  }
337  }
338 
339  }
340  // drain all the components
341  std::string addme;
342  if(comps.size()>0){
343  addme="COMPONENTS=";
344  for(unsigned i=0;i<comps.size()-1;i++)addme+=comps[i]+",";
345  addme+=comps.back();
346  actioninput.push_back(addme);
347  }
348  // periodicity (always explicit here)
349  addme="PERIODIC=";
350  for(unsigned j=0;j<periods.size()-1;j++){
351  addme+=periods[j]+",";
352  }
353  addme+=periods.back();
354  actioninput.push_back(addme);
355  for(unsigned j=0;j<inds.size();j++){
356  unsigned jj;jj=inds[j];
357  if(grid_check==2){
358  double gm;
359  double pm;
360  if(pmin[jj]!="none"){
361  Tools::convert(gmin[jj],gm);
362  Tools::convert(pmin[jj],pm);
363  if( gm<pm ){
364  plumed_merror("Periodicity issue : GRID_MIN value ( "+gmin[jj]+" ) is less than periodicity in HILLS file in "+cvs[jj][0]+ " ( "+pmin[jj]+" ) ");
365  }
366  }
367  if(pmax[jj]!="none"){
368  Tools::convert(gmax[jj],gm);
369  Tools::convert(pmax[jj],pm);
370  if( gm>pm ){
371  plumed_merror("Periodicity issue : GRID_MAX value ( "+gmax[jj]+" ) is more than periodicity in HILLS file in "+cvs[jj][0]+ " ( "+pmax[jj]+" ) ");
372  }
373  }
374  }
375  }
376 
377 // for(unsigned i=0;i< actioninput.size();i++){
378 // cerr<<"AA "<<actioninput[i]<<endl;
379 // }
380  plumed.readInputWords(actioninput);
381  }
382 
383  }
384  unsigned ncv=cvs.size();
385  std::vector<std::string> actioninput;
386  vector<std::string> idw;
387  // check if the variables to be used are correct
388  if(parseVector("--idw",idw)){
389  for(unsigned i=0;i<idw.size();i++){
390  bool found=false;
391  for(unsigned j=0;j<cvs.size();j++){
392  if(cvs[j].size()>1){
393  if(idw[i]==cvs[j][0]+"."+cvs[j][1])found=true;
394  }else{
395  if(idw[i]==cvs[j][0])found=true;
396  }
397  }
398  if(!found)plumed_merror("variable "+idw[i]+" is not found in the bunch of cvs: revise your --idw option" );
399  }
400  plumed_massert( idw.size()<=cvs.size() ,"the number of variables to be integrated should be at most equal to the total number of cvs ");
401  // in this case you neeed a beta factor!
402  }
403 
404  std::string kt; kt=std::string("1.");// assign an arbitrary value just in case that idw.size()==cvs.size()
405  if ( dohisto || idw.size()!=0 ) {
406  plumed_massert(parse("--kt",kt),"if you make a dimensionality reduction (--idw) or a histogram (--histo) then you need to define --kt ");
407  }
408 
409  std::string addme;
410 
411  actioninput.push_back("FUNCSUMHILLS");
412  actioninput.push_back("ISCLTOOL");
413 
414  // set names
415  std::string outfile;
416  if(parse("--outfile",outfile)){
417  actioninput.push_back("OUTHILLS="+outfile);
418  }
419  std::string outhisto;
420  if(parse("--outhisto",outhisto)){
421  actioninput.push_back("OUTHISTO="+outhisto);
422  }
423 
424 
425  addme="ARG=";
426  for(unsigned i=0;i<(ncv-1);i++){
427  if(cvs[i].size()==1){
428  addme+=std::string(cvs[i][0])+",";
429  }else{
430  addme+=std::string(cvs[i][0])+"."+std::string(cvs[i][1])+",";
431  }
432  }
433  if(cvs[ncv-1].size()==1){
434  addme+=std::string(cvs[ncv-1][0]);
435  }else{
436  addme+=std::string(cvs[ncv-1][0])+"."+std::string(cvs[ncv-1][1]);
437  }
438  actioninput.push_back(addme);
439  //for(unsigned i=0;i< actioninput.size();i++){
440  // cerr<<"AA "<<actioninput[i]<<endl;
441  //}
442  if(dohills){
443  addme="HILLSFILES="; for(unsigned i=0;i<hillsFiles.size()-1;i++)addme+=hillsFiles[i]+","; addme+=hillsFiles[hillsFiles.size()-1];
444  actioninput.push_back(addme);
445  // set the grid
446  }
447  if(grid_check==2){
448  addme="GRID_MAX="; for(unsigned i=0;i<(ncv-1);i++)addme+=gmax[i]+","; addme+=gmax[ncv-1];
449  actioninput.push_back(addme);
450  addme="GRID_MIN="; for(unsigned i=0;i<(ncv-1);i++)addme+=gmin[i]+","; addme+=gmin[ncv-1];
451  actioninput.push_back(addme);
452  }
453  if(grid_has_bin){
454  addme="GRID_BIN="; for(unsigned i=0;i<(ncv-1);i++)addme+=gbin[i]+","; addme+=gbin[ncv-1];
455  actioninput.push_back(addme);
456 // }else{
457 // //automatic bin: 50 per dimension;
458 // addme="GRID_BIN="; for(unsigned i=0;i<(ncv-1);i++)addme+="50,"; addme+="50";
459 // actioninput.push_back(addme);
460  }
461  std::string stride; stride="";
462  if(parse("--stride",stride)){
463  actioninput.push_back("INITSTRIDE="+stride);
464  bool nohistory;
465  parseFlag("--nohistory",nohistory);
466  if(nohistory){
467  actioninput.push_back("NOHISTORY");
468  }
469  }
470  if(idw.size()!=0){
471  addme="PROJ=";
472  for(unsigned i=0;i<idw.size()-1;i++){addme+=idw[i]+",";}
473  addme+=idw.back();
474  actioninput.push_back(addme);
475  }
476  if(idw.size()!=0 || dohisto){
477  actioninput.push_back("KT="+kt);
478  }
479  if(dohisto){
480  addme="HISTOFILES="; for(unsigned i=0;i<histoFiles.size()-1;i++){addme+=histoFiles[i]+",";}addme+=histoFiles[histoFiles.size()-1];
481  actioninput.push_back(addme);
482 
483  addme="HISTOSIGMA=";
484  for(unsigned i=0;i<sigma.size()-1;i++){addme+=sigma[i]+",";}
485  addme+=sigma.back();
486  actioninput.push_back(addme);
487  }
488 
489  bool negbias;
490  parseFlag("--negbias",negbias);
491  if(negbias){
492  actioninput.push_back("NEGBIAS");
493  }
494 
495 
496  std::string fmt;fmt="";
497  parse("--fmt",fmt);
498  if(fmt!="")actioninput.push_back("FMT="+fmt);
499 
500 
501 // for(unsigned i=0;i< actioninput.size();i++){
502 // cerr<<"AA "<<actioninput[i]<<endl;
503 // }
504  plumed.readInputWords(actioninput);
505  // if not a grid, then set it up automatically
506  return 0;
507 }
508 
509 bool CLToolSumHills::findCvsAndPeriodic(std::string filename, std::vector< std::vector<std::string> > &cvs, std::vector<std::string> &pmin,std::vector<std::string> &pmax, bool &multivariate){
510  IFile ifile;
511  ifile.allowIgnoredFields();
512  std::vector<std::string> fields;
513  if(ifile.FileExist(filename)){
514  cvs.clear(); pmin.clear(); pmax.clear();
515  ifile.open(filename);
516  ifile.scanFieldList(fields);
517  size_t founds,foundm,foundp;
518  bool before_sigma=true;
519  for(int i=0;i<fields.size();i++){
520  size_t pos = 0;
521  //found=(fields[i].find("sigma_", pos) || fields[i].find("min_", pos) || fields[i].find("max_", pos) ) ;
522  founds=fields[i].find("sigma_", pos) ;
523  foundm=fields[i].find("min_", pos) ;
524  foundp=fields[i].find("max_", pos) ;
525  if (founds!=std::string::npos || foundm!=std::string::npos || foundp!=std::string::npos )before_sigma=false;
526  // cvs are after time and before sigmas
527  size_t found;
528  found=fields[i].find("time", pos);
529  if( found==std::string::npos && before_sigma){
530  // separate the components
531  size_t dot=fields[i].find_first_of('.');
532  std::vector<std::string> ss;
533  // this loop does not take into account repetitions
534  if(dot!=std::string::npos){
535  std::string a=fields[i].substr(0,dot);
536  std::string name=fields[i].substr(dot+1);
537  ss.push_back(a);
538  ss.push_back(name);
539  cvs.push_back(ss);
540  }else{
541  std::vector<std::string> ss;
542  ss.push_back(fields[i]);
543  cvs.push_back(ss);
544  }
545  //std::cerr<<"found variable number "<<cvs.size()<<" : "<<cvs.back()[0]<<std::endl;
546  //if((cvs.back()).size()!=1){
547  // std::cerr<<"component "<<(cvs.back()).back()<<std::endl;
548  //}
549  // get periodicity
550  pmin.push_back("none");
551  pmax.push_back("none");
552  std::string mm; if((cvs.back()).size()>1){mm=cvs.back()[0]+"."+cvs.back()[1];}else{mm=cvs.back()[0];}
553  if(ifile.FieldExist("min_"+mm)){
554  std::string val;
555  ifile.scanField("min_"+mm,val);
556  pmin[pmin.size()-1]=val;
557  // std::cerr<<"found min : "<<pmin.back()<<std::endl;
558  }
559  //std::cerr<<"found min : "<<pmin.back()<<std::endl;
560  if(ifile.FieldExist("max_"+mm)){
561  std::string val;
562  ifile.scanField("max_"+mm,val);
563  pmax[pmax.size()-1]=val;
564  // std::cerr<<"found max : "<<pmax.back()<<std::endl;
565  }
566  //std::cerr<<"found max : "<<pmax.back()<<std::endl;
567  }
568  }
569  // is multivariate ???
570  std::string sss;
571  multivariate=false;
572  if(ifile.FieldExist("multivariate")){;
573  ifile.scanField("multivariate",sss);
574  if(sss=="true"){ multivariate=true;}
575  else if(sss=="false"){ multivariate=false;}
576  }
577  ifile.scanField();
578  ifile.close();
579  return true;
580  }else {
581  return false;
582  }
583 }
584 
585 
586 PLUMED_REGISTER_CLTOOL(CLToolSumHills,"sum_hills")
587 
588 
589 
590 }
591 }
bool FieldExist(const std::string &s)
Check if a field exist.
Definition: IFile.cpp:104
static bool initialized()
Tests if MPI library is initialized.
int main(int argc, char **argv)
This main uses only the interface published in Plumed.h.
Definition: main.cpp:38
MPI_Comm & Get_comm()
Reference to MPI communicator.
static bool convert(const std::string &str, double &t)
Convert a string to a double, reading it.
Definition: Tools.cpp:74
Class containing wrappers to MPI.
Definition: Communicator.h:44
STL namespace.
void add(const std::string &t, const std::string &k, const std::string &d)
Add a new keyword of type t with name k and description d.
Definition: Keywords.cpp:167
bool parseVector(const std::string &key, std::vector< T > &t)
Definition: CLTool.h:118
int main(FILE *in, FILE *out, Communicator &pc)
virtual function mapping to the specific main for each tool
Definition: SumHills.cpp:227
This is the abstract base class to use for implementing new command line tool, within it there is inf...
Definition: CLTool.h:55
This class holds the keywords and their documentation.
Definition: Keywords.h:36
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
const std::string name
The name of this command line tool.
Definition: CLTool.h:58
static bool findCvsAndPeriodic(std::string filename, std::vector< std::vector< std::string > > &cvs, std::vector< std::string > &pmin, std::vector< std::string > &pmax, bool &multivariate)
find a list of variables present, if they are periodic and which is the period return false if the fi...
Definition: SumHills.cpp:509
void close()
Closes the file Should be used only for explicitely opened files.
Definition: FileBase.cpp:140
Class for input files.
Definition: IFile.h:40
IFile & scanField(const std::string &, double &)
Read a double field.
Definition: IFile.cpp:121
bool parse(const std::string &key, T &t)
Get the value of one of the command line arguments.
Definition: CLTool.h:104
void parseFlag(const std::string &key, bool &t)
Find out whether one of the command line flags is present or not.
Definition: CLTool.cpp:51
bool FileExist(const std::string &path)
Check if the file exists.
Definition: FileBase.cpp:118
void cmd(const std::string &key, void *val=NULL)
cmd method, accessible with standard Plumed.h interface.
Definition: PlumedMain.cpp:104
string description() const
virtual function returning a one-line descriptor for the tool
Definition: SumHills.cpp:225
Main plumed object.
Definition: PlumedMain.h:71
Main plumed object.
Definition: Plumed.h:201
enum PLMD::CLTool::@0 inputdata
How is the input specified on the command line or in an input file.
IFile & scanFieldList(std::vector< std::string > &)
Gets the list of all fields.
Definition: IFile.cpp:95
void const char const char int double * a
Definition: Matrix.h:42
void addFlag(const std::string &k, const bool def, const std::string &d)
Add a falg with name k that is by default on if def is true and off if def is false. d should provide a description of the flag.
Definition: Keywords.cpp:193
void allowIgnoredFields()
Allow some of the fields in the input to be ignored.
Definition: IFile.cpp:199