22 #ifndef __PLUMED_core_Value_h
23 #define __PLUMED_core_Value_h
28 #include "tools/Exception.h"
29 #include "tools/Tools.h"
30 #include "tools/AtomNumber.h"
31 #include "tools/Vector.h"
35 class ActionWithValue;
103 void setDomain(
const std::string&,
const std::string&);
105 void getDomain(std::string&,std::string&)
const;
109 const std::string&
getName()
const;
131 bool applyForce( std::vector<double>& forces )
const ;
166 double u, v; u=val1.
get(); v=val2.
get();
202 plumed_massert(
hasDeriv,
"the derivatives array for this value has zero size");
208 plumed_dbg_massert(n<
derivatives.size(),
"you are asking for a derivative that is out of bounds");
219 plumed_massert(
hasDeriv,
"cannot resize derivatives in values that have not got derivatives");
225 plumed_dbg_massert(i<
derivatives.size(),
"derivative is out of bounds");
248 plumed_massert(
hasDerivatives(),
"forces can only be added to values with derivatives");
267 }
else plumed_merror(
"periodicity should be set to compute differences");
ActionWithValue * action
The action in which this quantity is calculated.
friend void copy(const Value &val1, Value &val2)
This copies the contents of a value into a second value (just the derivatives and value) ...
const std::string & getName() const
Get the name of the quantity.
friend void add(const Value &val1, Value *valout)
This adds some derivatives onto the value.
Value()
A constructor that can be used to make Vectors of values.
double difference(double) const
Calculate the difference between the instantaneous value of the function and some other point: other_...
void addForce(double f)
Add some force on this value.
void add(const Value &val1, Value *val2)
void copy(const Value &val1, Value &val2)
bool applyForce(std::vector< double > &forces) const
Apply the forces to the derivatives using the chain rule (if there are no forces this routine returns...
double get() const
Get the value of the function.
void clearInputForce()
Clear the input force on the variable.
double inputForce
The force acting on this quantity.
A class for holding the value of a function together with its derivatives.
unsigned getNumberOfDerivatives() const
Get the number of derivatives that this particular value has.
void clearDerivatives()
Set all the derivatives to zero.
void setGradients()
This sets up the gradients.
bool value_set
Had the value been set.
bool valueHasBeenSet() const
Find out if the value has been set.
bool hasForce
A flag telling us we have a force acting on this quantity.
void set(double)
Set the value of the function.
Used to create a PLMD::Action that has some scalar or vectorial output that may or may not have some ...
void getDomain(std::string &, std::string &) const
Get the domain of the quantity.
void setNotPeriodic()
Set the function not periodic.
friend void quotient(const Value &val1, const Value &val2, Value *valout)
This calculates va1/val2 and sorts out the derivatives.
bool hasDeriv
Does this quanity have derivatives.
static double projection(const Value &, const Value &)
void resizeDerivatives(int n)
Set the number of derivatives.
ActionWithValue * getPntrToAction()
This returns the pointer to the action where this value is calculated.
friend void product(const Value &val1, const Value &val2, Value &valout)
This calculates val1*val2 and sorts out the derivatives.
double getForce() const
Get the value of the force on this colvar.
std::vector< double > derivatives
The derivatives of the quantity stored in value.
enum PLMD::Value::@1 periodicity
Is this quantity periodic.
void product(const Value &val1, const Value &val2, Value &valout)
void setupPeriodicity()
Complete the setup of the periodicity.
bool isPeriodic() const
Check if the value is periodic.
double bringBackInPbc(double d1) const
Bring back one value into the correct pbc if needed, else give back the value.
std::string name
The name of this quantiy.
std::string str_min
Various quantities that describe the domain of this value.
std::map< AtomNumber, Vector > gradients
void chainRule(double df)
Apply the chain rule to the derivatives.
void quotient(const Value &val1, const Value &val2, Value *valout)
void addDerivative(unsigned i, double d)
Add some derivative to the ith component of the derivatives array.
double getDerivative(const unsigned n) const
Get the derivative with respect to component n.
void setDomain(const std::string &, const std::string &)
Set the domain of the function.
bool hasDerivatives() const
Check whether or not this particular quantity has derivatives.
double value
The value of the quantity.