All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Fake.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 "Colvar.h"
23 #include "ActionRegister.h"
24 
25 #include <string>
26 #include <cmath>
27 #include <cassert>
28 #include <iostream>
29 
30 using namespace std;
31 
32 namespace PLMD{
33 namespace colvar{
34 
35 //+PLUMEDOC COLVAR FAKE
36 /*
37 This is a fake colvar container used by cltools or various other actions
38 and just support input and period definition
39 
40 \par Examples
41 
42 \verbatim
43 FAKE ATOMS=1 PERIODIC=-3.14,3.14 LABEL=d2
44 \endverbatim
45 (See also \ref PRINT).
46 
47 */
48 //+ENDPLUMEDOC
49 
50 class ColvarFake : public Colvar {
51 
52 public:
53  static void registerKeywords( Keywords& keys );
54  ColvarFake(const ActionOptions&);
55 // active methods:
56  virtual void calculate();
57 };
58 
59 PLUMED_REGISTER_ACTION(ColvarFake,"FAKE")
60 
61 void ColvarFake::registerKeywords( Keywords& keys ){
62  Colvar::registerKeywords( keys );
63  keys.add("atoms","ATOMS","the fake atom index, a number is enough");
64  keys.reserve("compulsory","PERIODIC","if the output of your function is periodic then you should specify the periodicity of the function. If the output is not periodic you must state this using PERIODIC=NO,NO (one for the lower and the other for the upper boundary). For multicomponents then it is PERIODIC=mincomp1,maxcomp1,mincomp2,maxcomp2 etc ");
65  keys.use("PERIODIC");
66  keys.add("optional","COMPONENTS","additional componnets that this variable is supposed to have. Periodicity is ruled by PERIODIC keyword ");
67 }
68 
69 ColvarFake::ColvarFake(const ActionOptions&ao):
71 {
72  vector<AtomNumber> atoms;
73  parseAtomList("ATOMS",atoms);
74 
75  vector<string> comps;
76  // multiple components for this variable
77  parseVector("COMPONENTS",comps);
78  if(comps.size()!=0){
79  for(unsigned i=0;i<comps.size();i++){
81  }
82  // periodicity
83  }else{
84  // only one component for this variable
86  }
87  std::vector<std::string> period;
88  parseVector("PERIODIC",period);
89  if(period.size()!=0){
90  plumed_massert(getNumberOfComponents()*2==period.size(),"the periodicty should coincide with the number of components");
91  if(comps.size()!=0){
92  for(unsigned i=0;i<getNumberOfComponents();i++){
93  string pp=comps[i];
94  if(period[i*2]!="none" && period[i*2+1]!="none" ){
95  componentIsPeriodic(pp,period[i*2],period[i*2+1]);
96  }else{
98  }
99  }
100  }else{
101  if(period[0]!="none" && period[1]!="none" ){
102  setPeriodic(period[0],period[1]);
103  }else{
104  setNotPeriodic();
105  }
106  }
107  }else{
108  if(comps.size()!=0){
109  for(unsigned i=0;i<getNumberOfComponents();i++){
111  }
112  } else {
113  setNotPeriodic();
114  }
115  }
116  checkRead();
117  requestAtoms(atoms);
118 
119 }
120 
121 
122 // calculator
124  plumed_merror("you should never have got here");
125 }
126 
127 }
128 }
129 
130 
131 
void setNotPeriodic()
Set your default value to have no periodicity.
void componentIsNotPeriodic(const std::string &name)
Set your value component to have no periodicity.
void checkRead()
Check if Action was properly read.
Definition: Action.cpp:161
STL namespace.
void parseAtomList(const std::string &key, std::vector< AtomNumber > &t)
Parse a list of atoms without a numbered keyword.
void addValueWithDerivatives()
Add a value with the name label that has derivatives.
void requestAtoms(const std::vector< AtomNumber > &a)
Definition: Colvar.cpp:44
#define PLUMED_COLVAR_INIT(ao)
Definition: Colvar.h:29
This class holds the keywords and their documentation.
Definition: Keywords.h:36
This class is used to bring the relevant information to the Action constructor.
Definition: Action.h:41
void setPeriodic(const std::string &min, const std::string &max)
Set the value to be periodic with a particular domain.
This is the abstract base class to use for implementing new collective variables, within it there is ...
Definition: Colvar.h:39
const std::string & getName() const
Returns the name.
Definition: Action.h:268
void parseVector(const std::string &key, std::vector< T > &t)
Parse one keyword as std::vector.
Definition: Action.h:311
void componentIsPeriodic(const std::string &name, const std::string &min, const std::string &max)
Set the value to be periodic with a particular domain.
virtual void calculate()
Calculate an Action.
Definition: Fake.cpp:123
Provides the keyword FAKE
Definition: Fake.cpp:50
void addComponentWithDerivatives(const std::string &name)
Add a value with a name like label.name that has derivatives.
int getNumberOfComponents() const
Returns the number of values defined.
Value * getPntrToComponent(int i)
Return a pointer to the component by index.