LCOV - code coverage report
Current view: top level - bias - ReweightMetad.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 6 13 46.2 %
Date: 2020-11-18 11:20:57 Functions: 5 11 45.5 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2016-2019 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 "core/ActionRegister.h"
      23             : #include "ReweightBase.h"
      24             : 
      25             : //+PLUMEDOC REWEIGHTING REWEIGHT_METAD
      26             : /*
      27             : Calculate the weights configurations should contribute to the histogram in a simulation in which a metadynamics bias acts upon the system.
      28             : 
      29             : This command allows you to use the reweighting algorithm discussed in \cite PratyushReweighting when constructing a histogram
      30             : of the configurations visited during a metadynamics simulation.
      31             : 
      32             : \par Examples
      33             : 
      34             : In the following example there is a metadynamics bias acting on the distance between atoms 1 and 2.  Clearly, this
      35             : bias will have an effect on the region of phase space that will be sampled when an MD simulation is
      36             : run using this variable.  Consequently, when the histogram as a function of the angle, \f$a\f$, is accumulated,
      37             : we use reweighting into order to discount the effect of the bias from our final histogram.  We do not use
      38             : \ref REWEIGHT_BIAS here, however, as the bias changes with time.  We thus use the reweighting algorithm for
      39             : metadynamics instead.  Notice also that we have to specify how often we would like to calculate the c(t) reweighting
      40             : factor and the grid over which we calculate c(t) in the input to the METAD command.
      41             : 
      42             : \plumedfile
      43             : a: ANGLE ATOMS=1,2,3
      44             : x: DISTANCE ATOMS=1,2
      45             : METAD ARG=x PACE=100 SIGMA=0.1 HEIGHT=1.5 BIASFACTOR=5 GRID_MIN=0 GRID_MAX=10 GRID_BIN=100 REWEIGHTING_NGRID=100 REWEIGHTING_NHILLS=50
      46             : 
      47             : bias: REWEIGHT_METAD TEMP=300
      48             : 
      49             : HISTOGRAM ...
      50             :   ARG=a
      51             :   GRID_MIN=0.0
      52             :   GRID_MAX=pi
      53             :   GRID_BIN=100
      54             :   BANDWIDTH=0.1
      55             :   LOGWEIGHTS=bias
      56             :   LABEL=hB
      57             : ... HISTOGRAM
      58             : 
      59             : DUMPGRID GRID=hB FILE=histoB STRIDE=1 FMT=%8.4f
      60             : \endplumedfile
      61             : 
      62             : */
      63             : //+ENDPLUMEDOC
      64             : 
      65             : namespace PLMD {
      66             : namespace bias {
      67             : 
      68           0 : class ReweightMetad : public ReweightBase {
      69             : public:
      70             :   static void registerKeywords(Keywords&);
      71             :   explicit ReweightMetad(const ActionOptions&ao);
      72             :   double getLogWeight() const ;
      73             : };
      74             : 
      75        6452 : PLUMED_REGISTER_ACTION(ReweightMetad,"REWEIGHT_METAD")
      76             : 
      77           1 : void ReweightMetad::registerKeywords(Keywords& keys ) {
      78           2 :   ReweightBase::registerKeywords( keys ); keys.remove("ARG");
      79           5 :   keys.add("compulsory","ARG","*.rbias","the biases that must be taken into account when reweighting");
      80           1 : }
      81             : 
      82           0 : ReweightMetad::ReweightMetad(const ActionOptions&ao):
      83             :   Action(ao),
      84           0 :   ReweightBase(ao)
      85             : {
      86           0 : }
      87             : 
      88           0 : double ReweightMetad::getLogWeight() const {
      89             :   // Retrieve the bias
      90           0 :   double bias=0.0; for(unsigned i=0; i<getNumberOfArguments(); ++i) bias+=getArgument(i);
      91           0 :   return bias / simtemp;
      92             : }
      93             : 
      94             : }
      95        4839 : }

Generated by: LCOV version 1.13