Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2016-2020 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 18 : void ReweightBase::registerKeywords(Keywords& keys) { 30 18 : Action::registerKeywords( keys ); 31 18 : ActionWithValue::registerKeywords( keys ); 32 18 : 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 18 : } 37 : 38 14 : ReweightBase::ReweightBase(const ActionOptions&ao): 39 : Action(ao), 40 : ActionWithValue(ao), 41 14 : ActionWithArguments(ao) 42 : { 43 28 : simtemp=0.; parse("TEMP",simtemp); 44 28 : if(simtemp>0) simtemp*=plumed.getAtoms().getKBoltzmann(); 45 0 : else simtemp=plumed.getAtoms().getKbT(); 46 14 : 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 14 : addValue(); setNotPeriodic(); 49 14 : } 50 : 51 4230 : void ReweightBase::calculate() { 52 4230 : double weight = getLogWeight(); 53 4230 : setValue( weight ); 54 4230 : } 55 : 56 : } 57 5517 : }