All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ManyRestraintsBase.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_manyrestraints_ManyRestraintsBase_h
23 #define __PLUMED_manyrestraints_ManyRestraintsBase_h
24 
25 #include "core/ActionAtomistic.h"
26 #include "core/ActionWithValue.h"
27 #include "core/ActionPilot.h"
28 #include "vesselbase/ActionWithVessel.h"
29 
30 namespace PLMD {
31 namespace manyrestraints {
32 
34  public ActionAtomistic,
35  public ActionWithValue,
36  public ActionPilot,
38 {
39 private:
40  std::vector<double> forcesToApply;
41 protected:
42  void createRestraints( const unsigned& nrestraints );
43 /// Add some derivatives to a particular atom
44  void addAtomsDerivatives(const int&,const Vector&);
45 /// Add some derivatives to the virial
46  void addBoxDerivatives(const Tensor&);
47 public:
48  static void registerKeywords( Keywords& keys );
50  unsigned getNumberOfDerivatives();
51 /// Deactivate task now does nothing
52  void deactivate_task(){}
53  void apply();
54 };
55 
56 inline
58  return 3*getNumberOfAtoms() + 9;
59 }
60 
61 inline
62 void ManyRestraintsBase::addAtomsDerivatives(const int& iatom, const Vector& der){
63  plumed_dbg_assert( iatom<getNumberOfAtoms() );
64  addElementDerivative( 3*iatom+0, der[0] );
65  addElementDerivative( 3*iatom+1, der[1] );
66  addElementDerivative( 3*iatom+2, der[2] );
67 }
68 
69 inline
71  int natoms=getNumberOfAtoms();
72  addElementDerivative( 3*natoms+0, vir(0,0) );
73  addElementDerivative( 3*natoms+1, vir(0,1) );
74  addElementDerivative( 3*natoms+2, vir(0,2) );
75  addElementDerivative( 3*natoms+3, vir(1,0) );
76  addElementDerivative( 3*natoms+4, vir(1,1) );
77  addElementDerivative( 3*natoms+5, vir(1,2) );
78  addElementDerivative( 3*natoms+6, vir(2,0) );
79  addElementDerivative( 3*natoms+7, vir(2,1) );
80  addElementDerivative( 3*natoms+8, vir(2,2) );
81 }
82 
83 }
84 }
85 
86 #endif
This is used to create PLMD::Action objects that are run with some set frequency. ...
Definition: ActionPilot.h:39
Class implementing fixed size matrices of doubles.
Definition: Tensor.h:70
Class implementing fixed size vectors of doubles.
Definition: Vector.h:74
void addAtomsDerivatives(const int &, const Vector &)
Add some derivatives to a particular atom.
void addElementDerivative(const unsigned &, const double &)
Add some derivative of the quantity in the sum wrt to a numbered element.
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.
void deactivate_task()
Deactivate task now does nothing.
void addBoxDerivatives(const Tensor &)
Add some derivatives to the virial.
unsigned getNumberOfAtoms() const
Get number of available atoms.
void createRestraints(const unsigned &nrestraints)
static void registerKeywords(Keywords &keys)
This is used to create PLMD::Action objects that are computed by calculating the same function multip...