LCOV - code coverage report
Current view: top level - colvar - PropertyMap.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 25 27 92.6 %
Date: 2024-10-11 08:09:47 Functions: 5 6 83.3 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-2023 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.org for more information.
       6             : 
       7             :    This file is part of plumed, version 2.
       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             : namespace PLMD {
      26             : namespace colvar {
      27             : 
      28             : //+PLUMEDOC COLVAR PROPERTYMAP
      29             : /*
      30             : Calculate generic property maps.
      31             : 
      32             : This Colvar calculates the property maps according to the work of Spiwok \cite Spiwok:2011ce.
      33             : 
      34             : 
      35             : Basically it calculates
      36             : \f{eqnarray*}{
      37             : X=\frac{\sum_i X_i*\exp(-\lambda D_i(x))}{\sum_i  \exp(-\lambda D_i(x))} \\
      38             : Y=\frac{\sum_i Y_i*\exp(-\lambda D_i(x))}{\sum_i  \exp(-\lambda D_i(x))} \\
      39             : \cdots\\
      40             : zzz=-\frac{1}{\lambda}\log(\sum_i  \exp(-\lambda D_i(x)))
      41             : \f}
      42             : 
      43             : where the parameters \f$X_i\f$  and  \f$Y_i\f$ are provided in the input pdb (allv.pdb in this case) and
      44             :  \f$D_i(x)\f$  is the mean squared displacement after optimal alignment calculated on the pdb frames you input (see Kearsley).
      45             : 
      46             : 
      47             : When running with periodic boundary conditions, the atoms should be
      48             : in the proper periodic image. This is done automatically since PLUMED 2.5,
      49             : by considering the ordered list of atoms and rebuilding molecules using a procedure
      50             : that is equivalent to that done in \ref WHOLEMOLECULES . Notice that
      51             : rebuilding is local to this action. This is different from \ref WHOLEMOLECULES
      52             : which actually modifies the coordinates stored in PLUMED.
      53             : 
      54             : In case you want to recover the old behavior you should use the NOPBC flag.
      55             : In that case you need to take care that atoms are in the correct
      56             : periodic image.
      57             : 
      58             : \par Examples
      59             : 
      60             : \plumedfile
      61             : p3: PROPERTYMAP REFERENCE=allv.pdb PROPERTY=X,Y LAMBDA=69087 NEIGH_SIZE=8 NEIGH_STRIDE=4
      62             : PRINT ARG=p3.X,p3.Y,p3.zzz STRIDE=1 FILE=colvar FMT=%8.4f
      63             : \endplumedfile
      64             : 
      65             : note that NEIGH_STRIDE=4 NEIGH_SIZE=8 control the neighbor list parameter (optional but
      66             : recommended for performance) and states that the neighbor list will be calculated every 4
      67             : steps and consider only the closest 8 member to the actual md snapshots.
      68             : 
      69             : In this case the input line instructs plumed to look for two properties X and Y with attached values in the REMARK
      70             : line of the reference pdb (Note: No spaces from X and = and 1 !!!!).
      71             : e.g.
      72             : 
      73             : \auxfile{allv.pdb}
      74             : REMARK X=1 Y=2
      75             : ATOM      1  CL  ALA     1      -3.171   0.295   2.045  1.00  1.00
      76             : ATOM      5  CLP ALA     1      -1.819  -0.143   1.679  1.00  1.00
      77             : END
      78             : REMARK X=2 Y=3
      79             : ATOM      1  CL  ALA     1      -3.175   0.365   2.024  1.00  1.00
      80             : ATOM      5  CLP ALA     1      -1.814  -0.106   1.685  1.00  1.00
      81             : END
      82             : \endauxfile
      83             : 
      84             : \note
      85             : The implementation of this collective variable and of \ref PATHMSD
      86             : is shared, as well as most input options.
      87             : 
      88             : */
      89             : //+ENDPLUMEDOC
      90             : 
      91             : class PropertyMap : public PathMSDBase {
      92             : public:
      93             :   explicit PropertyMap(const ActionOptions&);
      94             :   static void registerKeywords(Keywords& keys);
      95             : };
      96             : 
      97       10441 : PLUMED_REGISTER_ACTION(PropertyMap,"PROPERTYMAP")
      98             : 
      99          12 : void PropertyMap::registerKeywords(Keywords& keys) {
     100          12 :   PathMSDBase::registerKeywords(keys);
     101          24 :   keys.add("compulsory","PROPERTY","the property to be used in the indexing: this goes in the REMARK field of the reference");
     102          12 :   ActionWithValue::useCustomisableComponents(keys);
     103          24 :   keys.addOutputComponent("zzz","default","the minimum distance from the reference points");
     104          12 : }
     105             : 
     106          11 : PropertyMap::PropertyMap(const ActionOptions&ao):
     107             :   Action(ao),
     108          11 :   PathMSDBase(ao)
     109             : {
     110             :   // this is the only additional keyword needed
     111          11 :   parseVector("PROPERTY",labels);
     112          11 :   checkRead();
     113          11 :   log<<"  Bibliography "
     114          33 :      <<plumed.cite("Spiwok V, Kralova B  J. Chem. Phys. 135,  224504 (2011)")
     115          22 :      <<"\n";
     116          11 :   if(labels.size()==0) {
     117             :     char buf[500];
     118             :     std::sprintf(buf,"Need to specify PROPERTY with this action\n");
     119           0 :     plumed_merror(buf);
     120             :   } else {
     121          33 :     for(unsigned i=0; i<labels.size(); i++) {
     122          22 :       log<<" found custom propety to be found in the REMARK line: "<<labels[i].c_str()<<"\n";
     123          22 :       addComponentWithDerivatives(labels[i]); componentIsNotPeriodic(labels[i]);
     124             :     }
     125             :     // add distance anyhow
     126          22 :     addComponentWithDerivatives("zzz"); componentIsNotPeriodic("zzz");
     127             :     //reparse the REMARK field and pick the index
     128         473 :     for(unsigned i=0; i<pdbv.size(); i++) {
     129             :       // now look for X=1.34555 Y=5.6677
     130             :       std::vector<double> labelvals;
     131        1386 :       for(unsigned j=0; j<labels.size(); j++) {
     132             :         double val;
     133         924 :         if( pdbv[i].getArgumentValue(labels[j],val) ) {labelvals.push_back(val);}
     134             :         else {
     135             :           char buf[500];
     136             :           std::sprintf(buf,"PROPERTY LABEL \" %s \" NOT FOUND IN REMARK FOR FRAME %u \n",labels[j].c_str(),i);
     137           0 :           plumed_merror(buf);
     138             :         };
     139             :       }
     140         462 :       indexvec.push_back(labelvals);
     141             :     }
     142             :   }
     143          11 :   requestAtoms(pdbv[0].getAtomNumbers());
     144             : 
     145          11 : }
     146             : 
     147             : }
     148             : }
     149             : 
     150             : 

Generated by: LCOV version 1.15