24 #include "tools/Grid.h"
25 #include "tools/Exception.h"
26 #include "tools/File.h"
105 static void registerKeywords(
Keywords& keys);
108 PLUMED_REGISTER_ACTION(
External,
"EXTERNAL")
111 Bias::registerKeywords(keys);
113 keys.add(
"compulsory",
"FILE",
"the name of the file containing the external potential.");
114 keys.addFlag(
"NOSPLINE",
false,
"specifies that no spline interpolation is to be used when calculating the energy and forces due to the external potential");
115 keys.addFlag(
"SPARSE",
false,
"specifies that the external potential uses a sparse grid");
116 componentsAreNotOptional(keys);
117 keys.addOutputComponent(
"bias",
"default",
"the instantaneous value of the bias potential");
120 External::~External(){
129 parse(
"FILE",filename);
130 if( filename.length()==0 )
error(
"No external potential file was specified");
131 bool sparsegrid=
false;
135 bool spline=!nospline;
139 log.
printf(
" External potential from file %s\n",filename.c_str());
140 if(spline){
log.
printf(
" External potential uses spline interpolation\n");}
141 if(sparsegrid){
log.
printf(
" External potential uses sparse grid\n");}
147 std::string funcl=
getLabel() +
".bias";
159 vector<double> cv(ncv), der(ncv);
168 for(
unsigned i=0;i<ncv;++i){
169 const double f=-der[i];
void parseFlag(const std::string &key, bool &t)
Parse one keyword as boolean flag.
Log & log
Reference to the log stream.
void componentIsNotPeriodic(const std::string &name)
Set your value component to have no periodicity.
void error(const std::string &msg) const
Crash calculation and print documentation.
virtual double getValueAndDerivatives(unsigned index, std::vector< double > &der) const
get grid value and derivatives
unsigned getDimension() const
get grid dimension
const std::string & getLabel() const
Returns the label.
void checkRead()
Check if Action was properly read.
Value * getPntrToArgument(const unsigned n)
Return a pointer to specific argument.
void addComponent(const std::string &name)
Add a value with a name like label.name.
void set(double)
Set the value of the function.
void parse(const std::string &key, T &t)
Parse one keyword as generic type.
This class holds the keywords and their documentation.
void calculate()
Calculate an Action.
IFile & open(const std::string &name)
Opens the file.
This class is used to bring the relevant information to the Action constructor.
std::vector< Value * > & getArguments()
Returns an array of pointers to the arguments.
int printf(const char *fmt,...)
Formatted output with explicit format - a la printf.
void close()
Closes the file Should be used only for explicitely opened files.
void setOutputForce(int i, double g)
double getArgument(const unsigned n) const
Returns the value of an argument.
This is the abstract base class to use for implementing new simulation biases, within it there is inf...
bool isPeriodic() const
Check if the value is periodic.
#define PLUMED_BIAS_INIT(ao)
Value * getPntrToComponent(int i)
Return a pointer to the component by index.
unsigned getNumberOfArguments() const
Returns the number of arguments.
static Grid * create(const std::string &, std::vector< Value * >, IFile &, bool, bool, bool)
read grid from file
Provides the keyword EXTERNAL
std::vector< bool > getIsPeriodic() const
get if periodic