Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2013-2018 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 9 : void PathBase::registerKeywords( Keywords& keys ) {
29 9 : Mapping::registerKeywords( keys );
30 9 : keys.add("compulsory","LAMBDA","the value of the lambda parameter for paths");
31 9 : keys.addFlag("NOZPATH",false,"do not calculate the zpath position");
32 9 : }
33 :
34 7 : PathBase::PathBase(const ActionOptions& ao):
35 : Action(ao),
36 7 : Mapping(ao)
37 : {
38 7 : weightHasDerivatives=true;
39 7 : bool noz; parseFlag("NOZPATH",noz);
40 7 : parse("LAMBDA",lambda);
41 :
42 : // Create the list of tasks
43 7 : for(unsigned i=0; i<getNumberOfReferencePoints(); ++i) addTaskToList( i );
44 : // And activate them all
45 7 : deactivateAllTasks();
46 7 : for(unsigned i=0; i<getFullNumberOfTasks(); ++i) taskFlags[i]=1;
47 7 : lockContributors();
48 :
49 7 : std::string empty="LABEL=zpath";
50 7 : if(!noz) addVessel("ZPATH",empty,0);
51 7 : }
52 :
53 7 : double PathBase::getLambda() {
54 7 : return lambda;
55 : }
56 :
57 3822 : void PathBase::calculate() {
58 : // Loop over all frames is now performed by ActionWithVessel
59 3822 : runAllTasks();
60 3822 : }
61 :
62 114242 : void PathBase::performTask( const unsigned& task_index, const unsigned& current, MultiValue& myvals ) const {
63 : // This builds a pack to hold the derivatives
64 114242 : ReferenceValuePack mypack( getNumberOfArguments(), getNumberOfAtoms(), myvals );
65 113405 : finishPackSetup( current, mypack );
66 : // Calculate the distance from the frame
67 114622 : double val=calculateDistanceFunction( current, mypack, true );
68 : // Put the element value in element zero
69 114592 : myvals.setValue( 0, val ); myvals.setValue( 1, 1.0 );
70 114536 : return;
71 : }
72 :
73 113945 : double PathBase::transformHD( const double& dist, double& df ) const {
74 113945 : double val = exp( -dist*lambda );
75 113945 : df = -lambda*val;
76 113945 : return val;
77 : }
78 :
79 : }
80 2523 : }
|