Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2015-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 "VesselRegister.h" 23 : #include "FunctionVessel.h" 24 : 25 : namespace PLMD { 26 : namespace vesselbase { 27 : 28 : class AltMin : public vesselbase::FunctionVessel { 29 : private: 30 : double beta; 31 : public: 32 : static void registerKeywords( Keywords& keys ); 33 : static void reserveKeyword( Keywords& keys ); 34 : explicit AltMin( const vesselbase::VesselOptions& da ); 35 : std::string value_descriptor() override; 36 : double calcTransform( const double& val, double& dv ) const override; 37 : double finalTransform( const double& val, double& dv ) override; 38 : }; 39 : 40 10421 : PLUMED_REGISTER_VESSEL(AltMin,"ALT_MIN") 41 : 42 2 : void AltMin::registerKeywords( Keywords& keys ) { 43 2 : FunctionVessel::registerKeywords(keys); 44 4 : keys.add("compulsory","BETA","the value of beta for the equation in the manual"); 45 2 : } 46 : 47 3473 : void AltMin::reserveKeyword( Keywords& keys ) { 48 6946 : keys.reserve("vessel","ALT_MIN","calculate the minimum value. " 49 : "To make this quantity continuous the minimum is calculated using " 50 : "\\f$ \\textrm{min} = -\\frac{1}{\\beta} \\log \\sum_i \\exp\\left( -\\beta s_i \\right) \\f$ " 51 : "The value of \\f$\\beta\\f$ in this function is specified using (BETA=\\f$\\beta\\f$)."); 52 6946 : keys.addOutputComponent("altmin","ALT_MIN","the minimum value. This is calculated using the formula described in the description of the " 53 : "keyword so as to make it continuous."); 54 3473 : } 55 : 56 2 : AltMin::AltMin( const vesselbase::VesselOptions& da ): 57 2 : FunctionVessel(da) 58 : { 59 2 : if( getAction()->isPeriodic() ) error("MIN is not a meaningful option for periodic variables"); 60 2 : parse("BETA",beta); usetol=true; 61 2 : } 62 : 63 2 : std::string AltMin::value_descriptor() { 64 2 : std::string str_beta; Tools::convert( beta, str_beta ); 65 4 : return "the minimum value. Beta is equal to " + str_beta; 66 : } 67 : 68 10 : double AltMin::calcTransform( const double& val, double& dv ) const { 69 10 : double f = exp( -beta*val ); dv = -beta*f; return f; 70 : } 71 : 72 5 : double AltMin::finalTransform( const double& val, double& dv ) { 73 5 : dv = - 1.0 /(beta*val); return -std::log( val ) / beta; 74 : } 75 : 76 : } 77 : }