All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
PLMD::Value Class Reference

A class for holding the value of a function together with its derivatives. More...

#include <Value.h>

Public Member Functions

 Value ()
 A constructor that can be used to make Vectors of values. More...
 
 Value (ActionWithValue *av, const std::string &name, const bool withderiv)
 A constructor that is used throughout the code to setup the value poiters. More...
 
void set (double)
 Set the value of the function. More...
 
void add (double)
 Add something to the value of the function. More...
 
double get () const
 Get the value of the function. More...
 
bool valueHasBeenSet () const
 Find out if the value has been set. More...
 
bool isPeriodic () const
 Check if the value is periodic. More...
 
void setNotPeriodic ()
 Set the function not periodic. More...
 
void setDomain (const std::string &, const std::string &)
 Set the domain of the function. More...
 
void getDomain (std::string &, std::string &) const
 Get the domain of the quantity. More...
 
void getDomain (double &, double &) const
 Get the domain of the quantity. More...
 
const std::string & getName () const
 Get the name of the quantity. More...
 
bool hasDerivatives () const
 Check whether or not this particular quantity has derivatives. More...
 
unsigned getNumberOfDerivatives () const
 Get the number of derivatives that this particular value has. More...
 
void resizeDerivatives (int n)
 Set the number of derivatives. More...
 
void clearDerivatives ()
 Set all the derivatives to zero. More...
 
void addDerivative (unsigned i, double d)
 Add some derivative to the ith component of the derivatives array. More...
 
void chainRule (double df)
 Apply the chain rule to the derivatives. More...
 
double getDerivative (const unsigned n) const
 Get the derivative with respect to component n. More...
 
void clearInputForce ()
 Clear the input force on the variable. More...
 
void addForce (double f)
 Add some force on this value. More...
 
double getForce () const
 Get the value of the force on this colvar. More...
 
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 false. More...
 
double difference (double) const
 Calculate the difference between the instantaneous value of the function and some other point: other_point-inst_val. More...
 
double difference (double d1, double d2) const
 Calculate the difference between two values of this function: d2 -d1. More...
 
ActionWithValuegetPntrToAction ()
 This returns the pointer to the action where this value is calculated. More...
 
double bringBackInPbc (double d1) const
 Bring back one value into the correct pbc if needed, else give back the value. More...
 
void setGradients ()
 This sets up the gradients. More...
 

Static Public Member Functions

static double projection (const Value &, const Value &)
 

Private Types

enum  { unset, periodic, notperiodic }
 Is this quantity periodic. More...
 

Private Member Functions

void setupPeriodicity ()
 Complete the setup of the periodicity. More...
 

Private Attributes

ActionWithValueaction
 The action in which this quantity is calculated. More...
 
bool value_set
 Had the value been set. More...
 
double value
 The value of the quantity. More...
 
double inputForce
 The force acting on this quantity. More...
 
bool hasForce
 A flag telling us we have a force acting on this quantity. More...
 
std::vector< double > derivatives
 The derivatives of the quantity stored in value. More...
 
std::map< AtomNumber, Vectorgradients
 
std::string name
 The name of this quantiy. More...
 
bool hasDeriv
 Does this quanity have derivatives. More...
 
enum PLMD::Value:: { ... }  periodicity
 Is this quantity periodic. More...
 
std::string str_min
 Various quantities that describe the domain of this value. More...
 
std::string str_max
 
double min
 
double max
 
double max_minus_min
 
double inv_max_minus_min
 

Friends

class ActionWithValue
 
void copy (const Value &val1, Value &val2)
 This copies the contents of a value into a second value (just the derivatives and value) More...
 
void copy (const Value &val, Value *val2)
 This copies the contents of a value into a second value (but second value is a pointer) More...
 
void add (const Value &val1, Value *valout)
 This adds some derivatives onto the value. More...
 
void product (const Value &val1, const Value &val2, Value &valout)
 This calculates val1*val2 and sorts out the derivatives. More...
 
void quotient (const Value &val1, const Value &val2, Value *valout)
 This calculates va1/val2 and sorts out the derivatives. More...
 

Detailed Description

A class for holding the value of a function together with its derivatives.

Typically, an object of type PLMD::ActionWithValue will contain one object of type PLUMD::Value that will be named after the label. If the PLMD::ActionWithValue is part of a class that calculates multiple components then the class will contain multiple that will be called label.component-name This class is used to pass information between different PLMD::Action objects. However, if you find a use for a tempory PLMD::Value in some method you are implementing please feel free to use it.

Definition at line 46 of file Value.h.

Constructor & Destructor Documentation

PLMD::Value::Value ( )

A constructor that can be used to make Vectors of values.

Definition at line 33 of file Value.cpp.

PLMD::Value::Value ( ActionWithValue av,
const std::string &  name,
const bool  withderiv 
)

A constructor that is used throughout the code to setup the value poiters.

Definition at line 48 of file Value.cpp.

Member Function Documentation

void PLMD::Value::add ( double  v)
inline

Add something to the value of the function.

Definition at line 180 of file Value.h.

void PLMD::Value::addDerivative ( unsigned  i,
double  d 
)
inline

Add some derivative to the ith component of the derivatives array.

Definition at line 224 of file Value.h.

void PLMD::Value::addForce ( double  f)
inline

Add some force on this value.

Definition at line 247 of file Value.h.

bool PLMD::Value::applyForce ( std::vector< double > &  forces) const

Apply the forces to the derivatives using the chain rule (if there are no forces this routine returns false.

Definition at line 80 of file Value.cpp.

double PLMD::Value::bringBackInPbc ( double  d1) const
inline

Bring back one value into the correct pbc if needed, else give back the value.

Definition at line 271 of file Value.h.

void PLMD::Value::chainRule ( double  df)
inline

Apply the chain rule to the derivatives.

Definition at line 230 of file Value.h.

void PLMD::Value::clearDerivatives ( )
inline

Set all the derivatives to zero.

Definition at line 241 of file Value.h.

void PLMD::Value::clearInputForce ( )
inline

Clear the input force on the variable.

Definition at line 235 of file Value.h.

double PLMD::Value::difference ( double  d) const
inline

Calculate the difference between the instantaneous value of the function and some other point: other_point-inst_val.

Definition at line 276 of file Value.h.

double PLMD::Value::difference ( double  d1,
double  d2 
) const
inline

Calculate the difference between two values of this function: d2 -d1.

d2-d1

Definition at line 259 of file Value.h.

double PLMD::Value::get ( ) const
inline

Get the value of the function.

Definition at line 186 of file Value.h.

double PLMD::Value::getDerivative ( const unsigned  n) const
inline

Get the derivative with respect to component n.

Definition at line 207 of file Value.h.

void PLMD::Value::getDomain ( std::string &  minout,
std::string &  maxout 
) const

Get the domain of the quantity.

Definition at line 99 of file Value.cpp.

void PLMD::Value::getDomain ( double &  minout,
double &  maxout 
) const

Get the domain of the quantity.

Definition at line 105 of file Value.cpp.

double PLMD::Value::getForce ( ) const
inline

Get the value of the force on this colvar.

Definition at line 254 of file Value.h.

const std::string & PLMD::Value::getName ( ) const
inline

Get the name of the quantity.

Definition at line 196 of file Value.h.

unsigned PLMD::Value::getNumberOfDerivatives ( ) const
inline

Get the number of derivatives that this particular value has.

Definition at line 201 of file Value.h.

ActionWithValue * PLMD::Value::getPntrToAction ( )

This returns the pointer to the action where this value is calculated.

Definition at line 154 of file Value.cpp.

bool PLMD::Value::hasDerivatives ( ) const
inline

Check whether or not this particular quantity has derivatives.

Definition at line 213 of file Value.h.

bool PLMD::Value::isPeriodic ( ) const

Check if the value is periodic.

Definition at line 75 of file Value.cpp.

double PLMD::Value::projection ( const Value v1,
const Value v2 
)
static

Definition at line 140 of file Value.cpp.

void PLMD::Value::resizeDerivatives ( int  n)
inline

Set the number of derivatives.

Definition at line 218 of file Value.h.

void PLMD::Value::set ( double  v)
inline

Set the value of the function.

Definition at line 174 of file Value.h.

void PLMD::Value::setDomain ( const std::string &  pmin,
const std::string &  pmax 
)

Set the domain of the function.

Definition at line 91 of file Value.cpp.

void PLMD::Value::setGradients ( )

This sets up the gradients.

Definition at line 111 of file Value.cpp.

void PLMD::Value::setNotPeriodic ( )

Set the function not periodic.

Definition at line 87 of file Value.cpp.

void PLMD::Value::setupPeriodicity ( )
private

Complete the setup of the periodicity.

Definition at line 64 of file Value.cpp.

bool PLMD::Value::valueHasBeenSet ( ) const
inline

Find out if the value has been set.

Definition at line 191 of file Value.h.

Friends And Related Function Documentation

friend class ActionWithValue
friend

Definition at line 47 of file Value.h.

void add ( const Value val1,
Value valout 
)
friend

This adds some derivatives onto the value.

Definition at line 175 of file Value.cpp.

void copy ( const Value val1,
Value val2 
)
friend

This copies the contents of a value into a second value (just the derivatives and value)

Definition at line 159 of file Value.cpp.

void copy ( const Value val,
Value val2 
)
friend

This copies the contents of a value into a second value (but second value is a pointer)

Definition at line 167 of file Value.cpp.

void product ( const Value val1,
const Value val2,
Value valout 
)
friend

This calculates val1*val2 and sorts out the derivatives.

Definition at line 150 of file Value.h.

void quotient ( const Value val1,
const Value val2,
Value valout 
)
friend

This calculates va1/val2 and sorts out the derivatives.

Definition at line 162 of file Value.h.

Member Data Documentation

ActionWithValue* PLMD::Value::action
private

The action in which this quantity is calculated.

Definition at line 60 of file Value.h.

std::vector<double> PLMD::Value::derivatives
private

The derivatives of the quantity stored in value.

Definition at line 70 of file Value.h.

std::map<AtomNumber,Vector> PLMD::Value::gradients
private

Definition at line 71 of file Value.h.

bool PLMD::Value::hasDeriv
private

Does this quanity have derivatives.

Definition at line 75 of file Value.h.

bool PLMD::Value::hasForce
private

A flag telling us we have a force acting on this quantity.

Definition at line 68 of file Value.h.

double PLMD::Value::inputForce
private

The force acting on this quantity.

Definition at line 66 of file Value.h.

double PLMD::Value::inv_max_minus_min
private

Definition at line 82 of file Value.h.

double PLMD::Value::max
private

Definition at line 80 of file Value.h.

double PLMD::Value::max_minus_min
private

Definition at line 81 of file Value.h.

double PLMD::Value::min
private

Definition at line 80 of file Value.h.

std::string PLMD::Value::name
private

The name of this quantiy.

Definition at line 73 of file Value.h.

enum { ... } PLMD::Value::periodicity

Is this quantity periodic.

std::string PLMD::Value::str_max
private

Definition at line 79 of file Value.h.

std::string PLMD::Value::str_min
private

Various quantities that describe the domain of this value.

Definition at line 79 of file Value.h.

double PLMD::Value::value
private

The value of the quantity.

Definition at line 64 of file Value.h.

bool PLMD::Value::value_set
private

Had the value been set.

Definition at line 62 of file Value.h.


The documentation for this class was generated from the following files: