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

anonymous enum
private

Is this quantity periodic.

Enumerator
unset 
periodic 
notperiodic 

Constructor & Destructor Documentation

◆ Value() [1/2]

PLMD::Value::Value ( )

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

◆ Value() [2/2]

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

◆ add()

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

Add something to the value of the function.

◆ addDerivative()

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

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

◆ addForce()

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

Add some force on this value.

◆ applyForce()

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)

◆ applyPeriodicity()

void PLMD::Value::applyPeriodicity ( )
inlineprivate

◆ bringBackInPbc()

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

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

◆ chainRule()

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

Apply the chain rule to the derivatives.

◆ clearDerivatives()

void PLMD::Value::clearDerivatives ( )
inline

Set all the derivatives to zero.

◆ clearInputForce()

void PLMD::Value::clearInputForce ( )
inline

Clear the input force on the variable.

◆ difference() [1/2]

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.

◆ difference() [2/2]

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

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

d2-d1

◆ get()

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

Get the value of the function.

◆ getDerivative()

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

Get the derivative with respect to component n.

◆ getDomain() [1/2]

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

Get the domain of the quantity.

◆ getDomain() [2/2]

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

Get the domain of the quantity.

◆ getForce()

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

Get the value of the force on this colvar.

◆ getName()

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

Get the name of the quantity.

◆ getNumberOfDerivatives()

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

Get the number of derivatives that this particular value has.

◆ getPntrToAction()

ActionWithValue * PLMD::Value::getPntrToAction ( )

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

◆ hasDerivatives()

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

Check whether or not this particular quantity has derivatives.

◆ isPeriodic()

bool PLMD::Value::isPeriodic ( ) const

Check if the value is periodic.

◆ projection()

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

◆ resizeDerivatives()

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

Set the number of derivatives.

◆ set()

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

Set the value of the function.

◆ setDerivative()

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

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

◆ setDomain()

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

Set the domain of the function.

◆ setGradients()

void PLMD::Value::setGradients ( )

This sets up the gradients.

◆ setNotPeriodic()

void PLMD::Value::setNotPeriodic ( )

Set the function not periodic.

◆ setupPeriodicity()

void PLMD::Value::setupPeriodicity ( )
private

Complete the setup of the periodicity.

◆ valueHasBeenSet()

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

Find out if the value has been set.

Friends And Related Function Documentation

◆ ActionWithValue

friend class ActionWithValue
friend

◆ add

void add ( const Value val1,
Value valout 
)
friend

This adds some derivatives onto the value.

◆ copy [1/2]

void copy ( const Value val1,
Value val2 
)
friend

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

◆ copy [2/2]

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)

◆ product

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

This calculates val1*val2 and sorts out the derivatives.

◆ quotient

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

This calculates va1/val2 and sorts out the derivatives.

Member Data Documentation

◆ action

ActionWithValue* PLMD::Value::action
private

The action in which this quantity is calculated.

◆ derivatives

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

The derivatives of the quantity stored in value.

◆ gradients

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

◆ hasDeriv

bool PLMD::Value::hasDeriv
private

Does this quanity have derivatives.

◆ hasForce

bool PLMD::Value::hasForce
private

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

◆ inputForce

double PLMD::Value::inputForce
private

The force acting on this quantity.

◆ inv_max_minus_min

double PLMD::Value::inv_max_minus_min
private

◆ max

double PLMD::Value::max
private

◆ max_minus_min

double PLMD::Value::max_minus_min
private

◆ min

double PLMD::Value::min
private

◆ name

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

The name of this quantiy.

◆ periodicity

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

Is this quantity periodic.

◆ str_max

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

◆ str_min

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

Various quantities that describe the domain of this value.

◆ value

double PLMD::Value::value
private

The value of the quantity.

◆ value_set

bool PLMD::Value::value_set
private

Had the value been set.


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