LCOV - code coverage report
Current view: top level - bias - ReweightBase.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 19 20 95.0 %
Date: 2024-10-11 08:09:47 Functions: 3 4 75.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2016-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 "ReweightBase.h"
      23             : #include "core/PlumedMain.h"
      24             : #include "core/Atoms.h"
      25             : 
      26             : namespace PLMD {
      27             : namespace bias {
      28             : 
      29          24 : void ReweightBase::registerKeywords(Keywords& keys) {
      30          24 :   Action::registerKeywords( keys );
      31          24 :   ActionWithValue::registerKeywords( keys );
      32          24 :   ActionWithArguments::registerKeywords( keys );
      33          24 :   keys.setComponentsIntroduction("This action calculates the logarithm of a weight for reweighting");
      34          48 :   keys.add("optional","TEMP","the system temperature.  This is not required if your MD code passes this quantity to PLUMED");
      35          24 :   keys.remove("NUMERICAL_DERIVATIVES");
      36          24 : }
      37             : 
      38          20 : ReweightBase::ReweightBase(const ActionOptions&ao):
      39             :   Action(ao),
      40             :   ActionWithValue(ao),
      41          20 :   ActionWithArguments(ao)
      42             : {
      43          20 :   simtemp=0.; parse("TEMP",simtemp);
      44          20 :   if(simtemp>0) simtemp*=plumed.getAtoms().getKBoltzmann();
      45           0 :   else simtemp=plumed.getAtoms().getKbT();
      46          20 :   if(simtemp==0) error("The MD engine does not pass the temperature to plumed so you have to specify it using TEMP");
      47             :   // Create something to hold the weight
      48          20 :   addValue(); setNotPeriodic();
      49          20 : }
      50             : 
      51        6232 : void ReweightBase::calculate() {
      52        6232 :   double weight = getLogWeight();
      53        6232 :   setValue( weight );
      54        6232 : }
      55             : 
      56             : }
      57             : }

Generated by: LCOV version 1.15