All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Colvar.h
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 #ifndef __PLUMED_core_Colvar_h
23 #define __PLUMED_core_Colvar_h
24 
25 #include "ActionAtomistic.h"
26 #include "ActionWithValue.h"
27 #include <vector>
28 
29 #define PLUMED_COLVAR_INIT(ao) Action(ao),Colvar(ao)
30 
31 namespace PLMD {
32 
33 /**
34 \ingroup INHERIT
35 This is the abstract base class to use for implementing new collective variables, within it there is
36 \ref AddingAColvar "information" as to how to go about implementing a new CV.
37 */
38 
39 class Colvar :
40  public ActionAtomistic,
41  public ActionWithValue
42  {
43 private:
44 /// This is used by apply to retrive the forces on the atoms
45  std::vector<double> forces;
46 protected:
47  bool isEnergy;
48  void requestAtoms(const std::vector<AtomNumber> & a);
49 // Set the derivatives for a particular atom equal to the input Vector
50 // This routine is called setAtomsDerivatives because not because you
51 // are setting the derivative of many atoms but because you are setting
52 // the derivatives of a particular atom. The s is an apostrophe s
53 // but you can't put apostrophes in function names
54  void setAtomsDerivatives(int,const Vector&);
55  void setAtomsDerivatives(Value*,int,const Vector&);
56  void setBoxDerivatives(const Tensor&);
57  void setBoxDerivatives(Value*,const Tensor&);
58  const Tensor & getBoxDerivatives()const;
59  const double & getForce()const;
60  void apply();
61 /// Set box derivatives automatically.
62 /// It should be called after the setAtomsDerivatives has been used for all
63 /// single atoms.
64 /// \warning It only works for collective variable NOT using PBCs!
67 public:
68  bool checkIsEnergy(){return isEnergy;}
69  Colvar(const ActionOptions&);
70  ~Colvar(){}
71  static void registerKeywords( Keywords& keys );
72 };
73 
74 inline
76  v->addDerivative(3*i+0,d[0]);
77  v->addDerivative(3*i+1,d[1]);
78  v->addDerivative(3*i+2,d[2]);
79 }
80 
81 
82 inline
84  unsigned nat=getNumberOfAtoms();
85  v->addDerivative(3*nat+0,d(0,0));
86  v->addDerivative(3*nat+1,d(0,1));
87  v->addDerivative(3*nat+2,d(0,2));
88  v->addDerivative(3*nat+3,d(1,0));
89  v->addDerivative(3*nat+4,d(1,1));
90  v->addDerivative(3*nat+5,d(1,2));
91  v->addDerivative(3*nat+6,d(2,0));
92  v->addDerivative(3*nat+7,d(2,1));
93  v->addDerivative(3*nat+8,d(2,2));
94 }
95 
96 inline
97 void Colvar::setAtomsDerivatives(int i,const Vector&d){
99 }
100 
101 inline
104 }
105 
106 inline
109 }
110 
111 
112 }
113 
114 #endif
Class implementing fixed size matrices of doubles.
Definition: Tensor.h:70
Class implementing fixed size vectors of doubles.
Definition: Vector.h:74
A class for holding the value of a function together with its derivatives.
Definition: Value.h:46
void setAtomsDerivatives(int, const Vector &)
Definition: Colvar.h:97
bool isEnergy
Definition: Colvar.h:47
Value * getPntrToValue()
Get a pointer to the default value.
Colvar(const ActionOptions &)
Definition: Colvar.cpp:29
const double & getForce() const
void requestAtoms(const std::vector< AtomNumber > &a)
Definition: Colvar.cpp:44
void setBoxDerivatives(const Tensor &)
Definition: Colvar.h:102
Used to create a PLMD::Action that has some scalar or vectorial output that may or may not have some ...
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
Action used to create objects that access the positions of the atoms from the MD code.
const Tensor & getBoxDerivatives() const
This is the abstract base class to use for implementing new collective variables, within it there is ...
Definition: Colvar.h:39
static void registerKeywords(Keywords &keys)
Definition: Colvar.cpp:37
void setBoxDerivativesNoPbc()
Set box derivatives automatically.
Definition: Colvar.h:107
bool checkIsEnergy()
Definition: Colvar.h:68
std::vector< double > forces
This is used by apply to retrive the forces on the atoms.
Definition: Colvar.h:45
unsigned getNumberOfAtoms() const
Get number of available atoms.
void const char const char int double * a
Definition: Matrix.h:42
void apply()
Apply an Action.
Definition: Colvar.cpp:54
void addDerivative(unsigned i, double d)
Add some derivative to the ith component of the derivatives array.
Definition: Value.h:224