25 #ifdef __PLUMED_HAS_MATHEVAL
82 static void registerKeywords(
Keywords& keys);
85 #ifdef __PLUMED_HAS_MATHEVAL
86 PLUMED_REGISTER_ACTION(
Matheval,
"MATHEVAL")
89 Function::registerKeywords(keys);
90 keys.use(
"ARG"); keys.use(
"PERIODIC");
91 keys.add(
"compulsory",
"FUNC",
"the function you wish to evaluate");
92 keys.add(
"optional",
"VAR",
"the names to give each of the arguments in the function. If you have up to three arguments in your function you can use x, y and z to refer to them. Otherwise you must use this flag to give your variables names.");
98 evaluator_deriv(getNumberOfArguments()),
99 values(getNumberOfArguments()),
100 names(getNumberOfArguments())
106 error(
"Using more than 3 arguments you should explicitly write their names with VAR");
107 if(
var.size()>0)
var[0]=
"x";
108 if(
var.size()>1)
var[1]=
"y";
109 if(
var.size()>2)
var[2]=
"z";
112 error(
"Size of VAR array should be the same as number of arguments");
123 evaluator_get_variables(
evaluator,&check_names,&check_count);
127 error(
"Your function string contains "+sc+
" arguments. This should be equal to the number of ARGs");
132 if(
var[i]==check_names[j])found=
true;
135 error(
"Variable "+
var[i]+
" cannot be found in your function string");
150 for(
unsigned i=0;i<getNumberOfArguments();i++) names[i]=const_cast<char*>(
var[i].c_str());
Log & log
Reference to the log stream.
void error(const std::string &msg) const
Crash calculation and print documentation.
void checkRead()
Check if Action was properly read.
void parse(const std::string &key, T &t)
Parse one keyword as generic type.
This class holds the keywords and their documentation.
This class is used to bring the relevant information to the Action constructor.
int printf(const char *fmt,...)
Formatted output with explicit format - a la printf.
Base class for all the input Actions.
void parseVector(const std::string &key, std::vector< T > &t)
Parse one keyword as std::vector.
void setValue(const double &d)
Set the default value (the one without name)
double getArgument(const unsigned n) const
Returns the value of an argument.
void addValueWithDerivatives()
vector< void * > evaluator_deriv
Provides the keyword MATHEVAL
This is the abstract base class to use for implementing new CV function, within it there is informati...
void calculate()
Calculate an Action.
unsigned getNumberOfArguments() const
Returns the number of arguments.
void setDerivative(int, double)