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 : #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 22 : keys.add("compulsory","LAMBDA","0","the value of the lambda parameter for paths"); 31 22 : 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 : setLowMemOption( true ); 39 9 : weightHasDerivatives=true; 40 9 : bool noz; parseFlag("NOZPATH",noz); 41 9 : parse("LAMBDA",lambda); 42 : 43 : // Create the list of tasks 44 405 : for(unsigned i=0; i<getNumberOfReferencePoints(); ++i) addTaskToList( i ); 45 : // And activate them all 46 9 : deactivateAllTasks(); 47 405 : for(unsigned i=0; i<getFullNumberOfTasks(); ++i) taskFlags[i]=1; 48 9 : lockContributors(); 49 : 50 9 : std::string empty="LABEL=zpath"; 51 9 : if(!noz) { 52 7 : if( lambda==0 ) error("you must set LAMDBA value in order to calculate ZPATH coordinate. Use LAMBDA/NOZPATH keyword"); 53 14 : addVessel("ZPATH",empty,0); 54 : } 55 9 : } 56 : 57 1103 : double PathBase::getLambda() { 58 1103 : return lambda; 59 : } 60 : 61 4914 : void PathBase::calculate() { 62 : // Loop over all frames is now performed by ActionWithVessel 63 4914 : runAllTasks(); 64 4914 : } 65 : 66 170352 : void PathBase::performTask( const unsigned& task_index, const unsigned& current, MultiValue& myvals ) const { 67 : // This builds a pack to hold the derivatives 68 170352 : ReferenceValuePack mypack( getNumberOfArguments(), getNumberOfAtoms(), myvals ); 69 170352 : finishPackSetup( current, mypack ); 70 : // Calculate the distance from the frame 71 170352 : double val=calculateDistanceFunction( current, mypack, true ); 72 : // Put the element value in element zero 73 : myvals.setValue( 0, val ); myvals.setValue( 1, 1.0 ); 74 170352 : return; 75 170352 : } 76 : 77 170352 : double PathBase::transformHD( const double& dist, double& df ) const { 78 170352 : if( lambda==0 ) { df=1; return dist; } 79 114660 : double val = exp( -dist*lambda ); 80 114660 : df = -lambda*val; 81 114660 : return val; 82 : } 83 : 84 : } 85 : }