All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MultiColvar.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_multicolvar_MultiColvar_h
23 #define __PLUMED_multicolvar_MultiColvar_h
24 
25 #include "MultiColvarBase.h"
26 #include <vector>
27 
28 #define PLUMED_MULTICOLVAR_INIT(ao) Action(ao),MultiColvar(ao)
29 
30 namespace PLMD {
31 namespace multicolvar {
32 
33 /**
34 \ingroup INHERIT
35 This is the abstract base class to use for creating distributions of colvars and functions
36 thereof, whtin it there is \ref AddingAMultiColvar "information" as to how to go implementing these types of actions.
37 */
38 
39 class MultiColvar : public MultiColvarBase {
40 private:
41 /// Have atoms been read in
43 /// Read in the various GROUP keywords
44  void readGroupsKeyword( int& natoms );
45 /// Read in the various SPECIES keywords
46  void readSpeciesKeyword( int& natoms );
47 /// Update the atoms request
48  void requestAtoms();
49 protected:
50 /// Read in all the keywords that can be used to define atoms
51  void readAtoms( int& natoms );
52 /// Read in ATOMS keyword
53  void readAtomsLikeKeyword( const std::string & key, int& natoms );
54 /// Read two group keywords
55  void readTwoGroups( const std::string& key1, const std::string& key2 );
56 /// Read three groups
57  void readThreeGroups( const std::string& key1, const std::string& key2, const std::string& key3, const bool& allow2 );
58 /// Add a collective variable
59  void addColvar( const std::vector<unsigned>& newatoms );
60 /// Add some derivatives for an atom
61  void addAtomsDerivatives(const int&,const Vector&);
62 /// Set the derivative of the weight (used in MEAN and HISTOGRAM)
63  void addAtomsDerivativeOfWeight( const unsigned& i, const Vector& wder );
64 /// Add derivatives to the central atom position
65  void addCentralAtomDerivatives( const unsigned& iatom, const Tensor& der );
66 public:
67  MultiColvar(const ActionOptions&);
69  static void registerKeywords( Keywords& keys );
70 /// Resize all the dynamic arrays (used at neighbor list update time and during setup)
71  void resizeDynamicArrays();
72 /// Get the position of atom iatom
73  const Vector & getPosition(unsigned) const;
74 /// Calculate the multicolvar
75  virtual void calculate();
76 /// Do the calculation
77  double doCalculation( const unsigned& j );
78 /// Actually compute the colvar
79  virtual double compute( const unsigned& j )=0;
80 /// Calculate the position of the central atom
82 /// Get the position of the central atom
83  virtual Vector getCentralAtom()=0;
84 /// Get the mass of atom iatom
85  double getMass(unsigned) const ;
86 /// Get the charge of atom iatom
87  double getCharge(unsigned) const ;
88 /// Get the absolute index of atom iatom
89  AtomNumber getAbsoluteIndex(unsigned) const ;
90 };
91 
92 inline
93 const Vector & MultiColvar::getPosition( unsigned iatom ) const {
95 }
96 
97 inline
98 double MultiColvar::getMass(unsigned iatom ) const {
99  return ActionAtomistic::getMass( getAtomIndex(iatom) );
100 }
101 
102 inline
103 double MultiColvar::getCharge(unsigned iatom ) const {
104  return ActionAtomistic::getCharge( getAtomIndex(iatom) );
105 }
106 
107 inline
110 }
111 
112 inline
113 void MultiColvar::addAtomsDerivatives(const int& iatom, const Vector& der){
115 }
116 
117 inline
118 void MultiColvar::addAtomsDerivativeOfWeight( const unsigned& iatom, const Vector& wder ){
120 }
121 
122 inline
123 void MultiColvar::addCentralAtomDerivatives( const unsigned& iatom, const Tensor& der ){
125 }
126 
127 }
128 }
129 
130 #endif
Simple class to store the index of an atom.
Definition: AtomNumber.h:39
void addAtomsDerivativeOfWeight(const unsigned &i, const Vector &wder)
Set the derivative of the weight (used in MEAN and HISTOGRAM)
Definition: MultiColvar.h:118
const Vector & getPosition(int) const
Get position of i-th atom.
void addAtomsDerivatives(const int &, const Vector &)
Add some derivatives for an atom.
void addCentralAtomDerivatives(const unsigned &iatom, const Tensor &der)
Add derivative of central atom position wrt to position of iatom'th atom.
void readAtoms(int &natoms)
Read in all the keywords that can be used to define atoms.
Definition: MultiColvar.cpp:71
Class implementing fixed size matrices of doubles.
Definition: Tensor.h:70
void readAtomsLikeKeyword(const std::string &key, int &natoms)
Read in ATOMS keyword.
Definition: MultiColvar.cpp:81
Class implementing fixed size vectors of doubles.
Definition: Vector.h:74
double getCharge(unsigned) const
Get the charge of atom iatom.
Definition: MultiColvar.h:103
void requestAtoms()
Update the atoms request.
void addColvar(const std::vector< unsigned > &newatoms)
Add a collective variable.
Definition: MultiColvar.cpp:62
AtomNumber getAbsoluteIndex(int i) const
Get the absolute index of an atom.
void resizeDynamicArrays()
Resize all the dynamic arrays (used at neighbor list update time and during setup) ...
double doCalculation(const unsigned &j)
Do the calculation.
unsigned getAtomIndex(const unsigned &) const
Return the index of an atom.
virtual double compute(const unsigned &j)=0
Actually compute the colvar.
void addCentralAtomDerivatives(const unsigned &iatom, const Tensor &der)
Add derivatives to the central atom position.
Definition: MultiColvar.h:123
This class holds the keywords and their documentation.
Definition: Keywords.h:36
virtual Vector getCentralAtom()=0
Get the position of the central atom.
This class is used to bring the relevant information to the Action constructor.
Definition: Action.h:41
void readTwoGroups(const std::string &key1, const std::string &key2)
Read two group keywords.
bool verbose_output
Have atoms been read in.
Definition: MultiColvar.h:42
void addAtomsDerivatives(const int &, const Vector &)
Add some derivatives for an atom.
Definition: MultiColvar.h:113
const Vector & getPosition(unsigned) const
Get the position of atom iatom.
Definition: MultiColvar.h:93
double getCharge(int i) const
Get charge of i-th atom.
AtomNumber getAbsoluteIndex(unsigned) const
Get the absolute index of atom iatom.
Definition: MultiColvar.h:108
This is the abstract base class to use for creating distributions of colvars and functions thereof...
Definition: MultiColvar.h:39
Vector calculateCentralAtomPosition()
Calculate the position of the central atom.
void readThreeGroups(const std::string &key1, const std::string &key2, const std::string &key3, const bool &allow2)
Read three groups.
MultiColvar(const ActionOptions &)
Definition: MultiColvar.cpp:54
void readGroupsKeyword(int &natoms)
Read in the various GROUP keywords.
void readSpeciesKeyword(int &natoms)
Read in the various SPECIES keywords.
double getMass(int i) const
Get mass of i-th atom.
double getMass(unsigned) const
Get the mass of atom iatom.
Definition: MultiColvar.h:98
virtual void calculate()
Calculate the multicolvar.
void addAtomsDerivativeOfWeight(const unsigned &i, const Vector &wder)
Set the derivative of the weight (used in MEAN and HISTOGRAM)
static void registerKeywords(Keywords &keys)
Definition: MultiColvar.cpp:35