All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Group.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 
23 #include "core/ActionRegister.h"
24 #include "core/ActionAtomistic.h"
25 #include "core/Atoms.h"
26 
27 using namespace std;
28 
29 namespace PLMD{
30 namespace generic{
31 
32 //+PLUMEDOC GENERIC GROUP
33 /*
34 Define a group of atoms so that a particular list of atoms can be referenced with a single label
35 in definitions of CVs or virtual atoms.
36 
37 Notice that this command just creates a shortcut, and does not imply any real calculation.
38 It is just convenient to better organize input files. Might be used in combination with
39 the \ref INCLUDE command so as to store long group definitions in a separate file.
40 
41 \par Examples
42 
43 This command create a group of atoms containing atoms 1,4,7,11 and 14 (labeled 'o'), and another containing
44 atoms 2,3,5,6,8,9,12,13 (labeled 'h'):
45 \verbatim
46 o: GROUP ATOMS=1,4,7,11,14
47 h: GROUP ATOMS=2,3,5,6,8,9,12,13
48 # compute the coordination among the two groups
49 c: COORDINATION GROUPA=o GROUPB=h R_0=0.3
50 # same could have been obtained without GROUP, just writing:
51 # c: COORDINATION GROUPA=1,4,7,11,14 GROUPB=2,3,5,6,8,9,12,13
52 
53 # print the coordination on file 'colvar'
54 PRINT ARG=c FILE=colvar
55 \endverbatim
56 (see also \ref COORDINATION and \ref PRINT)
57 
58 Groups can be conveniently stored in a separate file.
59 E.g. one could create a file named 'groups.dat' which reads
60 \verbatim
61 o: GROUP ATOMS=1,4,7,11,14
62 h: GROUP ATOMS=2,3,5,6,8,9,12,13
63 \endverbatim
64 and then include it in the main 'plumed.dat' file
65 \verbatim
66 INCLUDE FILE=groups.dat
67 # compute the coordination among the two groups
68 c: COORDINATION GROUPA=o GROUPB=h R_0=0.3
69 # print the coordination on file 'colvar'
70 PRINT ARG=c FILE=colvar
71 \endverbatim
72 (see also \ref INCLUDE, \ref COORDINATION, and \ref PRINT).
73 The groups.dat file could be very long and include lists of thousand atoms without cluttering the main plumed.dat file.
74 
75 */
76 //+ENDPLUMEDOC
77 
78 class Group:
79  public ActionAtomistic
80 {
81 
82 public:
83  Group(const ActionOptions&ao);
84  ~Group();
85  static void registerKeywords( Keywords& keys );
86  void calculate(){}
87  void apply(){}
88 };
89 
90 PLUMED_REGISTER_ACTION(Group,"GROUP")
91 
93  Action(ao),
94  ActionAtomistic(ao)
95 {
96  vector<AtomNumber> atoms;
97  parseAtomList("ATOMS",atoms);
98  this->atoms.insertGroup(getLabel(),atoms);
99  log.printf(" of atoms ");
100  for(unsigned i=0;i<atoms.size();i++) log.printf(" %d",atoms[i].serial());
101  log.printf("\n");
102 }
103 
104 void Group::registerKeywords( Keywords& keys ){
105  Action::registerKeywords( keys );
106  ActionAtomistic::registerKeywords( keys );
107  keys.add("atoms", "ATOMS", "the numerical indexes for the set of atoms in the group");
108 }
109 
110 Group::~Group(){
111  atoms.removeGroup(getLabel());
112 }
113 
114 }
115 }
116 
Provides the keyword GROUP
Definition: Group.cpp:78
void calculate()
Calculate an Action.
Definition: Group.cpp:86
STL namespace.
void add(const std::string &t, const std::string &k, const std::string &d)
Add a new keyword of type t with name k and description d.
Definition: Keywords.cpp:167
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.
Base class for all the input Actions.
Definition: Action.h:60
void apply()
Apply an Action.
Definition: Group.cpp:87