All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Density.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 "MultiColvar.h"
23 #include "core/ActionRegister.h"
24 
25 #include <string>
26 #include <cmath>
27 
28 using namespace std;
29 
30 namespace PLMD{
31 namespace multicolvar{
32 
33 //+PLUMEDOC MCOLVAR DENSITY
34 /*
35 Calculate functions of the density of atoms as a function of the box. This allows one to calculate
36 the number of atoms in half the box.
37 
38 \par Examples
39 
40 The following example calculates the number of atoms in one half of the simulation box.
41 
42 \verbatim
43 DENSITY SPECIES=1-100 LABEL=d
44 SUBCELL ARG=d XLOWER=0.0 XUPPER=0.5 LABEL=d1
45 PRINT ARG=d1.* FILE=colvar1 FMT=%8.4f
46 \endverbatim
47 
48 */
49 //+ENDPLUMEDOC
50 
51 
52 class Density : public MultiColvar {
53 public:
54  static void registerKeywords( Keywords& keys );
55  Density(const ActionOptions&);
56 // active methods:
57  virtual double compute( const unsigned& j );
58  Vector getCentralAtom();
59  /// Returns the number of coordinates of the field
60  bool isPeriodic(){ return false; }
61  bool isDensity(){ return true; }
62 };
63 
64 PLUMED_REGISTER_ACTION(Density,"DENSITY")
65 
66 void Density::registerKeywords( Keywords& keys ){
67  MultiColvar::registerKeywords( keys );
68  keys.use("SPECIES");
69 }
70 
71 Density::Density(const ActionOptions&ao):
73 {
74  int nat; readAtoms( nat );
76  // And check everything has been read in correctly
77  checkRead();
78 }
79 
80 double Density::compute( const unsigned& j ){
81  return 1.0;
82 }
83 
86  return getPosition(0);
87 }
88 
89 }
90 }
91 
void readAtoms(int &natoms)
Read in all the keywords that can be used to define atoms.
Definition: MultiColvar.cpp:71
virtual double compute(const unsigned &j)
Actually compute the colvar.
Definition: Density.cpp:80
Class implementing fixed size vectors of doubles.
Definition: Vector.h:74
void checkRead()
Check if Action was properly read.
Definition: Action.cpp:161
STL namespace.
void readVesselKeywords()
Complete the setup of this object (this routine must be called after construction of ActionWithValue)...
void addCentralAtomDerivatives(const unsigned &iatom, const Tensor &der)
Add derivatives to the central atom position.
Definition: MultiColvar.h:123
static TensorGeneric< n, n > identity()
return an identity tensor
Definition: Tensor.h:318
This class holds the keywords and their documentation.
Definition: Keywords.h:36
#define PLUMED_MULTICOLVAR_INIT(ao)
Definition: MultiColvar.h:28
bool isPeriodic()
Returns the number of coordinates of the field.
Definition: Density.cpp:60
This class is used to bring the relevant information to the Action constructor.
Definition: Action.h:41
bool isDensity()
Is this a density?
Definition: Density.cpp:61
Provides the keyword DENSITY
Definition: Density.cpp:52
Vector getCentralAtom()
Get the position of the central atom.
Definition: Density.cpp:84
const Vector & getPosition(unsigned) const
Get the position of atom iatom.
Definition: MultiColvar.h:93
This is the abstract base class to use for creating distributions of colvars and functions thereof...
Definition: MultiColvar.h:39