LCOV - code coverage report
Current view: top level - mapping - PathBase.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 35 35 100.0 %
Date: 2020-11-18 11:20:57 Functions: 8 9 88.9 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2013-2019 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 "PathBase.h"
      23             : #include "tools/SwitchingFunction.h"
      24             : 
      25             : namespace PLMD {
      26             : namespace mapping {
      27             : 
      28          11 : void PathBase::registerKeywords( Keywords& keys ) {
      29          11 :   Mapping::registerKeywords( keys );
      30          55 :   keys.add("compulsory","LAMBDA","0","the value of the lambda parameter for paths");
      31          33 :   keys.addFlag("NOZPATH",false,"do not calculate the zpath position");
      32          11 : }
      33             : 
      34           9 : PathBase::PathBase(const ActionOptions& ao):
      35             :   Action(ao),
      36           9 :   Mapping(ao)
      37             : {
      38           9 :   weightHasDerivatives=true;
      39          18 :   bool noz; parseFlag("NOZPATH",noz);
      40          18 :   parse("LAMBDA",lambda);
      41             : 
      42             :   // Create the list of tasks
      43         414 :   for(unsigned i=0; i<getNumberOfReferencePoints(); ++i) addTaskToList( i );
      44             :   // And activate them all
      45           9 :   deactivateAllTasks();
      46         801 :   for(unsigned i=0; i<getFullNumberOfTasks(); ++i) taskFlags[i]=1;
      47           9 :   lockContributors();
      48             : 
      49           9 :   std::string empty="LABEL=zpath";
      50           9 :   if(!noz) {
      51           7 :     if( lambda==0 ) error("you must set LAMDBA value in order to calculate ZPATH coordinate.  Use LAMBDA/NOZPATH keyword");
      52          14 :     addVessel("ZPATH",empty,0);
      53             :   }
      54           9 : }
      55             : 
      56        1103 : double PathBase::getLambda() {
      57        1103 :   return lambda;
      58             : }
      59             : 
      60        4914 : void PathBase::calculate() {
      61             :   // Loop over all frames is now performed by ActionWithVessel
      62        4914 :   runAllTasks();
      63        4914 : }
      64             : 
      65      170352 : void PathBase::performTask( const unsigned& task_index, const unsigned& current, MultiValue& myvals ) const {
      66             :   // This builds a pack to hold the derivatives
      67      340704 :   ReferenceValuePack mypack( getNumberOfArguments(), getNumberOfAtoms(), myvals );
      68      170352 :   finishPackSetup( current, mypack );
      69             :   // Calculate the distance from the frame
      70      170352 :   double val=calculateDistanceFunction( current, mypack, true );
      71             :   // Put the element value in element zero
      72             :   myvals.setValue( 0, val ); myvals.setValue( 1, 1.0 );
      73      170352 :   return;
      74             : }
      75             : 
      76      170352 : double PathBase::transformHD( const double& dist, double& df ) const {
      77      170352 :   if( lambda==0 ) { df=1; return dist; }
      78      114660 :   double val = exp( -dist*lambda );
      79      114660 :   df = -lambda*val;
      80      114660 :   return val;
      81             : }
      82             : 
      83             : }
      84        4839 : }

Generated by: LCOV version 1.13