LCOV - code coverage report
Current view: top level - colvar - PropertyMap.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 25 29 86.2 %
Date: 2024-10-18 13:59:31 Functions: 2 4 50.0 %

          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             :   std::string getOutputComponentDescription( const std::string& cname, const Keywords& keys ) const override ;
      96             : };
      97             : 
      98             : PLUMED_REGISTER_ACTION(PropertyMap,"PROPERTYMAP")
      99             : 
     100          13 : void PropertyMap::registerKeywords(Keywords& keys) {
     101          13 :   PathMSDBase::registerKeywords(keys);
     102          26 :   keys.add("compulsory","PROPERTY","the property to be used in the indexing: this goes in the REMARK field of the reference");
     103          26 :   keys.addOutputComponent("zzz","default","scalar","the minimum distance from the reference points");
     104          13 :   ActionWithValue::useCustomisableComponents(keys);
     105          13 : }
     106             : 
     107          11 : PropertyMap::PropertyMap(const ActionOptions&ao):
     108             :   Action(ao),
     109          11 :   PathMSDBase(ao)
     110             : {
     111             :   // this is the only additional keyword needed
     112          11 :   parseVector("PROPERTY",labels);
     113          11 :   checkRead();
     114          11 :   log<<"  Bibliography "
     115          22 :      <<plumed.cite("Spiwok V, Kralova B  J. Chem. Phys. 135,  224504 (2011)")
     116          22 :      <<"\n";
     117          11 :   if(labels.size()==0) {
     118             :     const std::size_t buflen=500;
     119             :     char buf[buflen];
     120             :     std::snprintf(buf,buflen,"Need to specify PROPERTY with this action\n");
     121           0 :     plumed_merror(buf);
     122             :   } else {
     123          33 :     for(unsigned i=0; i<labels.size(); i++) {
     124          22 :       log<<" found custom propety to be found in the REMARK line: "<<labels[i].c_str()<<"\n";
     125          44 :       addComponentWithDerivatives(labels[i]); componentIsNotPeriodic(labels[i]);
     126             :     }
     127             :     // add distance anyhow
     128          22 :     addComponentWithDerivatives("zzz"); componentIsNotPeriodic("zzz");
     129             :     //reparse the REMARK field and pick the index
     130         473 :     for(unsigned i=0; i<pdbv.size(); i++) {
     131             :       // now look for X=1.34555 Y=5.6677
     132             :       std::vector<double> labelvals;
     133        1386 :       for(unsigned j=0; j<labels.size(); j++) {
     134         924 :         std::vector<double> val(1);
     135         924 :         if( pdbv[i].getArgumentValue(labels[j],val) ) {labelvals.push_back(val[0]);}
     136             :         else {
     137             :           const std::size_t buflen=500;
     138             :           char buf[buflen];
     139             :           std::snprintf(buf,buflen,"PROPERTY LABEL \" %s \" NOT FOUND IN REMARK FOR FRAME %u \n",labels[j].c_str(),i);
     140           0 :           plumed_merror(buf);
     141             :         };
     142             :       }
     143         462 :       indexvec.push_back(labelvals);
     144             :     }
     145             :   }
     146          11 :   requestAtoms(pdbv[0].getAtomNumbers());
     147             : 
     148          11 : }
     149             : 
     150           0 : std::string PropertyMap::getOutputComponentDescription( const std::string& cname, const Keywords& keys ) const {
     151           0 :   return "the projection of the instanenous position in CV space on the coordinate " + cname + " that is defined in the reference file";
     152             : }
     153             : 
     154             : }
     155             : }
     156             : 
     157             : 

Generated by: LCOV version 1.16