All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PropertyMap.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 "PathMSDBase.h"
23 #include "core/PlumedMain.h"
24 
25 using namespace std;
26 
27 namespace PLMD{
28 namespace colvar{
29 
30 //+PLUMEDOC COLVAR PROPERTYMAP
31 /*
32 Calculate generic property maps.
33 
34 This Colvar calculates the property maps according to the work of Spiwok \cite Spiwok:2011ce.
35 
36 
37 Basically it calculates
38 \f{eqnarray}
39 X=\frac{\sum_i X_i*\exp(-\lambda D_i(x))}{\sum_i \exp(-\lambda D_i(x))} \\
40 Y=\frac{\sum_i Y_i*\exp(-\lambda D_i(x))}{\sum_i \exp(-\lambda D_i(x))} \\
41 \cdots\\
42 zzz=-\frac{1}{\lambda}\log(\sum_i \exp(-\lambda D_i(x)))
43 \f}
44 
45 where the parameters \f$X_i\f$ and \f$Y_i\f$ are provided in the input pdb (allv.pdb in this case) and
46  \f$D_i(x)\f$ is the MSD after optimal alignment calculated on the pdb frames you input (see Kearsley).
47 
48 \par Examples
49 \verbatim
50 p3: PROPERTYMAP REFERENCE=../../trajectories/path_msd/allv.pdb PROPERTY=X,Y LAMBDA=69087 NEIGH_SIZE=8 NEIGH_STRIDE=4
51 PRINT ARG=p3.X,p3.Y,p3.zzz STRIDE=1 FILE=colvar FMT=%8.4f
52 \endverbatim
53 
54 note that NEIGH_STRIDE=4 NEIGH_SIZE=8 control the neighborlist parameter (optional but
55 recommended for performance) and states that the neighbor list will be calculated every 4
56 timesteps and consider only the closest 8 member to the actual md snapshots.
57 
58 In this case the input line instructs plumed to look for two properties X and Y with attached values in the REMARK
59 line of the reference pdb (Note: No spaces from X and = and 1 !!!!).
60 e.g.
61 
62 \verbatim
63 REMARK X=1 Y=2
64 ATOM 1 CL ALA 1 -3.171 0.295 2.045 1.00 1.00
65 ATOM 5 CLP ALA 1 -1.819 -0.143 1.679 1.00 1.00
66 .......
67 END
68 REMARK X=2 Y=3
69 ATOM 1 CL ALA 1 -3.175 0.365 2.024 1.00 1.00
70 ATOM 5 CLP ALA 1 -1.814 -0.106 1.685 1.00 1.00
71 ....
72 END
73 \endverbatim
74 
75 \note
76 The implementation of this collective variable and of \ref PATHMSD
77 is shared, as well as most input options.
78 
79 */
80 //+ENDPLUMEDOC
81 
82 class PropertyMap : public PathMSDBase {
83 public:
84  PropertyMap(const ActionOptions&);
85  static void registerKeywords(Keywords& keys);
86 };
87 
88 PLUMED_REGISTER_ACTION(PropertyMap,"PROPERTYMAP")
89 
90 void PropertyMap::registerKeywords(Keywords& keys){
91  PathMSDBase::registerKeywords(keys);
92  keys.add("compulsory","PROPERTY","the property to be used in the indexing: this goes in the REMARK field of the reference");
93  ActionWithValue::useCustomisableComponents(keys);
94  keys.addOutputComponent("zzz","default","the minimum distance from the reference points");
95 }
96 
97 PropertyMap::PropertyMap(const ActionOptions&ao):
98 Action(ao),
99 PathMSDBase(ao)
100 {
101  // this is the only additional keyword needed
102  parseVector("PROPERTY",labels);
103  checkRead();
104  log<<" Bibliography "
105  <<plumed.cite("Spiwok V, Kralova B J. Chem. Phys. 135, 224504 (2011)")
106  <<"\n";
107  if(labels.size()==0){
108  char buf[500];
109  sprintf(buf,"Need to specify PROPERTY with this action\n");
110  plumed_merror(buf);
111  }else{
112  for(unsigned i=0;i<labels.size();i++){
113  log<<" found custom propety to be found in the REMARK line: "<<labels[i].c_str()<<"\n";
115  }
116  // add distance anyhow
118  //reparse the REMARK field and pick the index
119  for(unsigned i=0;i<pdbv.size();i++){
120  vector<std::string> myv(pdbv[i].getRemark());
121  // now look for X=1.34555 Y=5.6677
122  vector<double> labelvals;
123  for(unsigned j=0;j<labels.size();j++){
124  double val;
125  if(Tools::parse(myv,labels[j],val)){labelvals.push_back(val);}
126  else{
127  char buf[500];
128  sprintf(buf,"PROPERTY LABEL \" %s \" NOT FOUND IN REMARK FOR FRAME %u \n",labels[j].c_str(),i);
129  plumed_merror(buf);
130  };
131  }
132  indexvec.push_back(labelvals);
133  }
134  }
135  requestAtoms(pdbv[0].getAtomNumbers());
136 
137 }
138 
139 }
140 }
141 
142 
Log & log
Reference to the log stream.
Definition: Action.h:93
void componentIsNotPeriodic(const std::string &name)
Set your value component to have no periodicity.
static bool parse(std::vector< std::string > &line, const std::string &key, T &val)
Find a keyword on the input line, eventually deleting it, and saving its value to val...
Definition: Tools.h:127
void checkRead()
Check if Action was properly read.
Definition: Action.cpp:161
STL namespace.
void requestAtoms(const std::vector< AtomNumber > &a)
Definition: Colvar.cpp:44
This class holds the keywords and their documentation.
Definition: Keywords.h:36
Provides the keyword PROPERTYMAP
Definition: PropertyMap.cpp:82
This class is used to bring the relevant information to the Action constructor.
Definition: Action.h:41
Base class for all the input Actions.
Definition: Action.h:60
void parseVector(const std::string &key, std::vector< T > &t)
Parse one keyword as std::vector.
Definition: Action.h:311
void addComponentWithDerivatives(const std::string &name)
Add a value with a name like label.name that has derivatives.
Main plumed object.
Definition: Plumed.h:201
std::vector< std::string > labels
Definition: PathMSDBase.h:74
std::vector< PDB > pdbv
Definition: PathMSDBase.h:73
std::vector< std::vector< double > > indexvec
Definition: PathMSDBase.h:75