forked from plumed/plumed2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fake.cpp
131 lines (106 loc) · 3.74 KB
/
Fake.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copyright (c) 2013 The plumed team
(see the PEOPLE file at the root of the distribution for a list of names)
See http://www.plumed-code.org for more information.
This file is part of plumed, version 2.0.
plumed is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
plumed is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with plumed. If not, see <http://www.gnu.org/licenses/>.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#include "Colvar.h"
#include "ActionRegister.h"
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
using namespace std;
namespace PLMD{
namespace colvar{
//+PLUMEDOC COLVAR FAKE
/*
This is a fake colvar container used by cltools or various other actions
and just support input and period definition
\par Examples
\verbatim
FAKE ATOMS=1 PERIODIC=-3.14,3.14 LABEL=d2
\endverbatim
(See also \ref PRINT).
*/
//+ENDPLUMEDOC
class ColvarFake : public Colvar {
public:
static void registerKeywords( Keywords& keys );
ColvarFake(const ActionOptions&);
// active methods:
virtual void calculate();
};
PLUMED_REGISTER_ACTION(ColvarFake,"FAKE")
void ColvarFake::registerKeywords( Keywords& keys ){
Colvar::registerKeywords( keys );
keys.add("atoms","ATOMS","the fake atom index, a number is enough");
keys.reserve("compulsory","PERIODIC","if the output of your function is periodic then you should specify the periodicity of the function. If the output is not periodic you must state this using PERIODIC=NO,NO (one for the lower and the other for the upper boundary). For multicomponents then it is PERIODIC=mincomp1,maxcomp1,mincomp2,maxcomp2 etc ");
keys.use("PERIODIC");
keys.add("optional","COMPONENTS","additional componnets that this variable is supposed to have. Periodicity is ruled by PERIODIC keyword ");
}
ColvarFake::ColvarFake(const ActionOptions&ao):
PLUMED_COLVAR_INIT(ao)
{
vector<AtomNumber> atoms;
parseAtomList("ATOMS",atoms);
vector<string> comps;
// multiple components for this variable
parseVector("COMPONENTS",comps);
if(comps.size()!=0){
for(unsigned i=0;i<comps.size();i++){
addComponentWithDerivatives(comps[i]);
}
// periodicity
}else{
// only one component for this variable
addValueWithDerivatives();
}
std::vector<std::string> period;
parseVector("PERIODIC",period);
if(period.size()!=0){
plumed_massert(getNumberOfComponents()*2==period.size(),"the periodicty should coincide with the number of components");
if(comps.size()!=0){
for(unsigned i=0;i<getNumberOfComponents();i++){
string pp=comps[i];
if(period[i*2]!="none" && period[i*2+1]!="none" ){
componentIsPeriodic(pp,period[i*2],period[i*2+1]);
}else{
componentIsNotPeriodic(pp);
}
}
}else{
if(period[0]!="none" && period[1]!="none" ){
setPeriodic(period[0],period[1]);
}else{
setNotPeriodic();
}
}
}else{
if(comps.size()!=0){
for(unsigned i=0;i<getNumberOfComponents();i++){
componentIsNotPeriodic(getPntrToComponent(i)->getName());
}
} else {
setNotPeriodic();
}
}
checkRead();
requestAtoms(atoms);
}
// calculator
void ColvarFake::calculate(){
plumed_merror("you should never have got here");
}
}
}