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 setDerivative (unsigned i, double d)
 Set the value of 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...
 
void applyPeriodicity ()
 

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.

Member Enumeration Documentation

anonymous enum
private

Is this quantity periodic.

Enumerator
unset 
periodic 
notperiodic 

Constructor & Destructor Documentation

PLMD::Value::Value ( )

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

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.

Member Function Documentation

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

Add something to the value of the function.

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

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

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

Add some force on this value.

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.

void PLMD::Value::applyPeriodicity ( )
inlineprivate
double PLMD::Value::bringBackInPbc ( double  d1) const
inline

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

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

Apply the chain rule to the derivatives.

void PLMD::Value::clearDerivatives ( )
inline

Set all the derivatives to zero.

void PLMD::Value::clearInputForce ( )
inline

Clear the input force on the variable.

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.

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

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

d2-d1

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

Get the value of the function.

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

Get the derivative with respect to component n.

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

Get the domain of the quantity.

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

Get the domain of the quantity.

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

Get the value of the force on this colvar.

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

Get the name of the quantity.

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

Get the number of derivatives that this particular value has.

ActionWithValue * PLMD::Value::getPntrToAction ( )

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

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

Check whether or not this particular quantity has derivatives.

bool PLMD::Value::isPeriodic ( ) const

Check if the value is periodic.

double PLMD::Value::projection ( const Value v1,
const Value v2 
)
static
void PLMD::Value::resizeDerivatives ( int  n)
inline

Set the number of derivatives.

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

Set the value of the function.

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

Set the value of the ith component of the derivatives array.

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

Set the domain of the function.

void PLMD::Value::setGradients ( )

This sets up the gradients.

void PLMD::Value::setNotPeriodic ( )

Set the function not periodic.

void PLMD::Value::setupPeriodicity ( )
private

Complete the setup of the periodicity.

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

Find out if the value has been set.

Friends And Related Function Documentation

friend class ActionWithValue
friend
void add ( const Value val1,
Value valout 
)
friend

This adds some derivatives onto the value.

void copy ( const Value val1,
Value val2 
)
friend

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

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)

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

This calculates val1*val2 and sorts out the derivatives.

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

This calculates va1/val2 and sorts out the derivatives.

Member Data Documentation

ActionWithValue* PLMD::Value::action
private

The action in which this quantity is calculated.

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

The derivatives of the quantity stored in value.

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

Does this quanity have derivatives.

bool PLMD::Value::hasForce
private

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

double PLMD::Value::inputForce
private

The force acting on this quantity.

double PLMD::Value::inv_max_minus_min
private
double PLMD::Value::max
private
double PLMD::Value::max_minus_min
private
double PLMD::Value::min
private
std::string PLMD::Value::name
private

The name of this quantiy.

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

Is this quantity periodic.

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

Various quantities that describe the domain of this value.

double PLMD::Value::value
private

The value of the quantity.

bool PLMD::Value::value_set
private

Had the value been set.


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