All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ActionWithVirtualAtom.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_ActionWithVirtualAtom_h
23 #define __PLUMED_core_ActionWithVirtualAtom_h
24 
25 #include "ActionAtomistic.h"
26 #include "tools/AtomNumber.h"
27 #include "tools/Vector.h"
28 #include "tools/Tensor.h"
29 #include "Atoms.h"
30 
31 namespace PLMD{
32 
33 /**
34 \ingroup INHERIT
35 Inherit from here if you are calculating the position of a virtual atom (eg a center of mass)
36 */
37 
38 /// Class to add a single virtual atom to the system.
39 /// (it might be extended to add multiple virtual atoms).
41  public ActionAtomistic
42 {
44  std::vector<Tensor> derivatives;
45  std::map<AtomNumber,Tensor> gradients;
46  void apply();
47 protected:
48 /// Set position of the virtual atom
49  void setPosition(const Vector &);
50 /// Set its mass
51  void setMass(double);
52 /// Set its charge
53  void setCharge(double);
54 /// Request atoms on which the calculation depends
55  void requestAtoms(const std::vector<AtomNumber> & a);
56 /// Set the derivatives of virtual atom coordinate wrt atoms on which it dependes
57  void setAtomsDerivatives(const std::vector<Tensor> &d);
58 public:
59  void setGradients();
60  const std::map<AtomNumber,Tensor> & getGradients()const;
61 /// Return the atom id of the corresponding virtual atom
62  AtomNumber getIndex()const;
65  static void registerKeywords(Keywords& keys);
66  void setGradientsIfNeeded();
67 };
68 
69 inline
71  return index;
72 }
73 
74 inline
76  atoms.positions[index.index()]=pos;
77 }
78 
79 inline
82 }
83 
84 inline
86  atoms.charges[index.index()]=c;
87 }
88 
89 inline
90 void ActionWithVirtualAtom::setAtomsDerivatives(const std::vector<Tensor> &d){
91  derivatives=d;
92 }
93 
94 inline
95 const std::map<AtomNumber,Tensor> & ActionWithVirtualAtom::getGradients()const{
96  return gradients;
97 }
98 
99 }
100 
101 #endif
std::map< AtomNumber, Tensor > gradients
Simple class to store the index of an atom.
Definition: AtomNumber.h:39
std::vector< double > charges
Definition: Atoms.h:53
void setPosition(const Vector &)
Set position of the virtual atom.
Class implementing fixed size vectors of doubles.
Definition: Vector.h:74
std::vector< Tensor > derivatives
std::vector< double > masses
Definition: Atoms.h:52
void setMass(double)
Set its mass.
std::vector< Vector > positions
Definition: Atoms.h:50
void requestAtoms(const std::vector< AtomNumber > &a)
Request atoms on which the calculation depends.
const std::map< AtomNumber, Tensor > & getGradients() const
This class holds the keywords and their documentation.
Definition: Keywords.h:36
void setAtomsDerivatives(const std::vector< Tensor > &d)
Set the derivatives of virtual atom coordinate wrt atoms on which it dependes.
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.
Inherit from here if you are calculating the position of a virtual atom (eg a center of mass) ...
unsigned index() const
Returns the index number.
Definition: AtomNumber.h:89
static void registerKeywords(Keywords &keys)
ActionWithVirtualAtom(const ActionOptions &ao)
AtomNumber getIndex() const
Return the atom id of the corresponding virtual atom.
void const char const char int double int double double int int double int * m
Definition: Matrix.h:42
void setCharge(double)
Set its charge.
void const char const char int double * a
Definition: Matrix.h:42