LCOV - code coverage report
Current view: top level - contour - DistanceFromContourBase.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 5 6 83.3 %
Date: 2024-10-18 14:00:25 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2013-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             : #ifndef __PLUMED_contour_DistanceFromContourBase_h
      23             : #define __PLUMED_contour_DistanceFromContourBase_h
      24             : 
      25             : #include "core/ActionAtomistic.h"
      26             : #include "core/ActionWithValue.h"
      27             : #include "core/ActionWithArguments.h"
      28             : #include "tools/SwitchingFunction.h"
      29             : #include "tools/RootFindingBase.h"
      30             : 
      31             : namespace PLMD {
      32             : namespace contour {
      33             : 
      34             : class DistanceFromContourBase :
      35             :   public ActionWithValue,
      36             :   public ActionAtomistic,
      37             :   public ActionWithArguments
      38             : {
      39             : private:
      40             :   double contour, gvol;
      41             :   RootFindingBase<DistanceFromContourBase> mymin;
      42             : protected:
      43             :   std::string kerneltype;
      44             :   std::vector<double> bw;
      45             :   double rcut2;
      46             :   unsigned nactive;
      47             :   Vector pval;
      48             :   std::vector<double> forcesToApply;
      49             :   std::vector<unsigned> active_list;
      50             :   SwitchingFunction switchingFunction;
      51             : ///
      52             :   double evaluateKernel( const Vector& cpos, const Vector& apos, std::vector<double>& der ) const ;
      53             : /// Find a contour along line specified by direction
      54             :   void findContour( const std::vector<double>& direction, std::vector<double>& point ) const ;
      55             : public:
      56             :   static void registerKeywords( Keywords& keys );
      57             :   explicit DistanceFromContourBase( const ActionOptions& );
      58             :   unsigned getNumberOfDerivatives() override ;
      59             :   void lockRequests();
      60             :   void unlockRequests();
      61           0 :   void calculateNumericalDerivatives( ActionWithValue* a ) { plumed_merror("numerical derivatives are not implemented for this action"); }
      62             :   double getDifferenceFromContour( const std::vector<double>& x, std::vector<double>& der );
      63             :   void apply();
      64             : };
      65             : 
      66             : inline
      67         166 : unsigned DistanceFromContourBase::getNumberOfDerivatives() {
      68         166 :   if( getNumberOfArguments()==1 ) return 4*getNumberOfAtoms() + 8;  // One derivative for each weight hence four times the number of atoms - 1
      69         149 :   return 3*getNumberOfAtoms() + 9;
      70             : }
      71             : 
      72             : inline
      73             : void DistanceFromContourBase::findContour( const std::vector<double>& direction, std::vector<double>& point ) const {
      74         291 :   mymin.lsearch( direction, point, &DistanceFromContourBase::getDifferenceFromContour );
      75         291 : }
      76             : 
      77             : }
      78             : }
      79             : #endif

Generated by: LCOV version 1.16