LCOV - code coverage report
Current view: top level - bias - ReweightBase.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 22 24 91.7 %
Date: 2026-03-30 13:16:06 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          36 : void ReweightBase::registerKeywords(Keywords& keys) {
      30          36 :   Action::registerKeywords( keys );
      31          36 :   ActionWithValue::registerKeywords( keys );
      32          36 :   ActionWithArguments::registerKeywords( keys );
      33          36 :   keys.setComponentsIntroduction("This action calculates the logarithm of a weight for reweighting");
      34          72 :   keys.add("optional","TEMP","the system temperature.  This is not required if your MD code passes this quantity to PLUMED");
      35          36 :   keys.remove("NUMERICAL_DERIVATIVES");
      36          36 : }
      37             : 
      38          20 : ReweightBase::ReweightBase(const ActionOptions&ao):
      39             :   Action(ao),
      40             :   ActionWithValue(ao),
      41          20 :   ActionWithArguments(ao) {
      42          20 :   simtemp=0.;
      43          20 :   parse("TEMP",simtemp);
      44          20 :   if(simtemp>0) {
      45          20 :     simtemp*=plumed.getAtoms().getKBoltzmann();
      46             :   } else {
      47           0 :     simtemp=plumed.getAtoms().getKbT();
      48             :   }
      49          20 :   if(simtemp==0) {
      50           0 :     error("The MD engine does not pass the temperature to plumed so you have to specify it using TEMP");
      51             :   }
      52             :   // Create something to hold the weight
      53          20 :   addValue();
      54          20 :   setNotPeriodic();
      55          20 : }
      56             : 
      57        6232 : void ReweightBase::calculate() {
      58        6232 :   double weight = getLogWeight();
      59        6232 :   setValue( weight );
      60        6232 : }
      61             : 
      62             : }
      63             : }

Generated by: LCOV version 1.16