22 #include "core/ActionRegister.h"
75 std::vector<std::pair<double,double> >
points;
79 static void registerKeywords(
Keywords& keys);
83 PLUMED_REGISTER_ACTION(
Piecewise,
"PIECEWISE")
86 Function::registerKeywords(keys);
88 keys.add(
"numbered",
"POINT",
"This keyword is used to specify the various points in the function above.");
89 keys.reset_style(
"POINT",
"compulsory");
90 ActionWithValue::useCustomisableComponents(keys);
103 std::vector<double> pp;
105 if(pp.size()!=2)
error(
"points should be in x,y format");
106 points.push_back(std::pair<double,double>(pp[0],pp[1]));
107 if(i>0 &&
points[i].first<=
points[i-1].first)
error(
"points abscissas should be monotonously increasing");
112 error(
"Cannot use PIECEWISE on periodic arguments");
136 for(;p<
points.size();p++){
137 if(val<
points[p].first)
break;
143 }
else if(p==
points.size()){
void setNotPeriodic()
Set your default value to have no periodicity.
Log & log
Reference to the log stream.
A class for holding the value of a function together with its derivatives.
void error(const std::string &msg) const
Crash calculation and print documentation.
void checkRead()
Check if Action was properly read.
Value * getPntrToArgument(const unsigned n)
Return a pointer to specific argument.
void set(double)
Set the value of the function.
Provides the keyword PIECEWISE
void addComponentWithDerivatives(const std::string &name)
This class holds the keywords and their documentation.
void setNotPeriodic()
Set the function not periodic.
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 calculate()
Calculate an Action.
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()
bool parseNumberedVector(const std::string &key, const int no, std::vector< T > &t)
Parse a vector with a number.
bool isPeriodic() const
Check if the value is periodic.
std::vector< std::pair< double, double > > points
This is the abstract base class to use for implementing new CV function, within it there is informati...
Value * getPntrToComponent(int i)
Return a pointer to the component by index.
unsigned getNumberOfArguments() const
Returns the number of arguments.
void addDerivative(unsigned i, double d)
Add some derivative to the ith component of the derivatives array.
void setDerivative(int, double)