LCOV - code coverage report
Current view: top level - vesselbase - AltMin.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 25 26 96.2 %
Date: 2026-03-30 13:16:06 Functions: 9 9 100.0 %

          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       13787 : 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        4595 : void AltMin::reserveKeyword( Keywords& keys ) {
      48        9190 :   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        9190 :   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        4595 : }
      55             : 
      56           2 : AltMin::AltMin( const vesselbase::VesselOptions& da ):
      57           2 :   FunctionVessel(da) {
      58           2 :   if( getAction()->isPeriodic() ) {
      59           0 :     error("MIN is not a meaningful option for periodic variables");
      60             :   }
      61           2 :   parse("BETA",beta);
      62           2 :   usetol=true;
      63           2 : }
      64             : 
      65           2 : std::string AltMin::value_descriptor() {
      66             :   std::string str_beta;
      67           2 :   Tools::convert( beta, str_beta );
      68           4 :   return "the minimum value. Beta is equal to " + str_beta;
      69             : }
      70             : 
      71          10 : double AltMin::calcTransform( const double& val, double& dv ) const {
      72          10 :   double f = exp( -beta*val );
      73          10 :   dv = -beta*f;
      74          10 :   return f;
      75             : }
      76             : 
      77           5 : double AltMin::finalTransform( const double& val, double& dv ) {
      78           5 :   dv = - 1.0 /(beta*val);
      79           5 :   return -std::log( val ) / beta;
      80             : }
      81             : 
      82             : }
      83             : }

Generated by: LCOV version 1.16