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. | |
| Value (ActionWithValue *av, const std::string &valname, const bool withderiv, const std::vector< std::size_t > &ss=std::vector< std::size_t >()) | |
| A constructor that is used throughout the code to setup the value poiters. | |
| Value (const std::string &valname) | |
| A constructor that can be used to make Vectors of named values. | |
| void | add (const std::size_t &n, const double &v) |
| Add something to the ith element of the data array. | |
| void | add (double) |
| Add something to the value of the function. | |
| void | addDerivative (unsigned i, double d) |
| Add some derivative to the ith component of the derivatives array. | |
| void | addForce () |
| Set hasForce equal to true. | |
| void | addForce (const std::size_t &ival, double f, const bool trueind=true) |
| Add some force on the ival th component of this value. | |
| void | addForce (double f) |
| Add some force on this value. | |
| std::size_t | addForces (View< const double > f) |
| Add forces from a vector, imples trueInd=false and retunrs the number of forces assigned. | |
| void | addGridDerivatives (const unsigned &n, const unsigned &j, const double &val) |
| Add the derivatives of the grid to the corner. | |
| bool | allElementsEqual () const |
| Check if all the elements in the value have the same value. | |
| 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) | |
| std::size_t | assignValues (View< double > target) |
| A variant of get() for assigning data to an external view (assuems trueind=false), returns the number of arguments assigned. | |
| double | bringBackInPbc (double d1) const |
| Bring back one value into the correct pbc if needed, else give back the value. | |
| bool | checkValueIsActiveForMMul (std::size_t task) const |
| A variant of get() for checking that at least one of the values on the row is !=0. | |
| void | clearDerivatives (const bool force=false) |
| Set all the derivatives to zero. | |
| void | clearInputForce () |
| Clear the input force on the variable. | |
| void | clearInputForce (const std::vector< AtomNumber > &index) |
| Special method for clearing forces on variables used by DataPassingObject. | |
| void | convertIndexToindices (const std::size_t &index, std::vector< unsigned > &indices) const |
| Convert the input index to its corresponding indices. | |
| void | copyBookeepingArrayFromArgument (Value *myarg) |
| Copy the matrix bookeeping stuff. | |
| double | difference (double d1, double d2) const |
| Calculate the difference between two values of this function: d2 -d1. | |
| double | difference (double) const |
| Calculate the difference between the instantaneous value of the function and some other point: other_point-inst_val. | |
| bool | forcesWereAdded () const |
| Check if forces have been added on this value. | |
| double | get (const std::size_t ival=0, const bool trueind=true) const |
| Get the value of the function. | |
| double | getDerivative (const unsigned n) const |
| Get the derivative with respect to component n. | |
| void | getDomain (double &, double &) const |
| Get the domain of the quantity. | |
| void | getDomain (std::string &, std::string &) const |
| Get the domain of the quantity. | |
| double | getForce (const std::size_t &ival=0) const |
| Get the value of the force on this colvar. | |
| unsigned | getGoodNumThreads (const unsigned &j, const unsigned &k) const |
| Get the number of threads to use when assigning this value. | |
| double | getGridDerivative (const unsigned &n, const unsigned &j) const |
| get the derivative of a grid at a point n with resepct to argument j | |
| std::size_t | getIndexInStore (const std::size_t &ival) const |
| Get the location of this element of in the store. | |
| double | getMaxMinusMin () const |
| Get the difference between max and minimum of domain. | |
| const std::string & | getName () const |
| Get the name of the quantity. | |
| std::size_t | getNumberOfColumns () const |
| unsigned | getNumberOfDerivatives () const |
| Get the number of derivatives that this particular value has. | |
| unsigned | getNumberOfGridDerivatives () const |
| Get the number of derivatives that the grid has. | |
| std::size_t | getNumberOfStoredValues () const |
| Get the number of values that are actually stored here once sparse matrices are taken into account. | |
| std::size_t | getNumberOfValues () const |
| Get the total number of scalars that are stored here. | |
| ActionWithValue * | getPntrToAction () |
| This returns the pointer to the action where this value is calculated. | |
| unsigned | getRank () const |
| Get the rank of the object that is contained in this value. | |
| unsigned | getRowIndex (std::size_t irow, std::size_t jind) const |
| unsigned | getRowLength (const std::size_t &irow) const |
| const std::vector< std::size_t > & | getShape () const |
| Get the shape of the object that is contained in this value. | |
| std::string | getValueType () const |
| Get the type of value that is stored here. | |
| bool | hasDerivatives () const |
| Check whether or not this particular quantity has derivatives. | |
| bool | ignoreStoredValue (const std::string &n) const |
| Are we to ignore the stored value. | |
| bool | isConstant () const |
| These are used for making constant values. | |
| bool | isDerivativeZeroWhenValueIsZero () const |
| Return a bool that tells us if the derivative is zero when the value is zero. | |
| bool | isPeriodic () const |
| Check if the value is periodic. | |
| bool | isSymmetric () const |
| void | passGradients (const double &der, std::map< AtomNumber, Vector > &g) const |
| This passes gradients from one action to another. | |
| void | print (OFile &ofile) const |
| Print out all the values in this Value. | |
| void | printForce (OFile &ofile) const |
| Print out all the forces in this Value. | |
| void | push_back (const double &val) |
| Add another value to the end of the data vector held by this value. This is used in COLLECT. | |
| void | readBinary (std::istream &i) |
| void | reshapeConstantValue (const std::vector< std::size_t > &sh) |
| void | reshapeMatrixStore (const unsigned &n) |
| Reshape the storage for sparse matrices. | |
| void | resizeDerivatives (int n) |
| Set the number of derivatives. | |
| void | retrieveEdgeList (unsigned &nedge, std::vector< std::pair< unsigned, unsigned > > &active, std::vector< double > &elems) |
| Retrieve the non-zero edges in a matrix. | |
| void | set (const std::size_t &n, const double &v) |
| Set the value of the stored data. | |
| void | set (double) |
| Set the value of the function. | |
| void | setConstant () |
| void | setDerivative (unsigned i, double d) |
| Set the value of the ith component of the derivatives array. | |
| void | setDerivativeIsZeroWhenValueIsZero () |
| Set a bool that tells us if the derivative is zero when the value is zero true. | |
| void | setDomain (const std::string &, const std::string &) |
| Set the domain of the function. | |
| void | setGradients (ActionAtomistic *aa, unsigned &start) |
| This sets up the gradients. | |
| void | setGridDerivatives (const unsigned &n, const unsigned &j, const double &val) |
| void | setMatrixBookeepingElement (const unsigned &i, const unsigned &n) |
| Set a matrix element to be non zero. | |
| void | setNotPeriodic () |
| Set the function not periodic. | |
| void | setRowIndices (const std::size_t &irow, const std::vector< std::size_t > &ind) |
| void | setShape (const std::vector< std::size_t > &ss) |
| Set the shape of the Value. | |
| void | setSymmetric (const bool &sym) |
| Set the symmetric flag equal true for this matrix. | |
| bool | valueHasBeenSet () const |
| Find out if the value has been set. | |
| void | writeBinary (std::ostream &o) const |
| These are used for passing around the data in this value when we are doing replica exchange. | |
Static Public Member Functions | |
| static double | projection (const Value &, const Value &) |
Private Types | |
| enum | { normal , constant , average , calcFromAverage } |
| The way this value is used in the code normal = regular value that is determined during calculate constant = constnt value that is determined during startup and that doesn't change during simulation average = value that is averaged/collected over multiple steps of trajectory calcFromAverage = value that is calculated from an average value. More... | |
| enum | { unset , periodic , notperiodic } |
| Is this quantity periodic. More... | |
Private Member Functions | |
| void | applyPeriodicity (const unsigned &ival) |
| bool | calculateOnUpdate () const |
| This is used by ActionWithValue to determine if we need to calculate on update. | |
| void | setupPeriodicity () |
| Complete the setup of the periodicity. | |
| void | setValType (const std::string &vtype) |
| This is used by ActionWithValue to set the valtype. | |
Private Attributes | |
| ActionWithValue * | action =nullptr |
| The action in which this quantity is calculated. | |
| unsigned | bufstart =0 |
| Variables for storing data. | |
| std::vector< double > | data |
| The value of the quantity. | |
| bool | derivativeIsZeroWhenValueIsZero =false |
| Is the derivative of this quantity zero when the value is zero. | |
| std::map< AtomNumber, Vector > | gradients |
| The derivatives of the quantity stored in value. | |
| bool | hasDeriv =true |
| Does this quanity have derivatives. | |
| bool | hasForce =false |
| A flag telling us we have a force acting on this quantity. | |
| std::vector< double > | inputForce |
| The force acting on this quantity. | |
| double | inv_max_minus_min =0.0 |
| std::vector< unsigned > | matrix_bookeeping |
| This is a bookeeping array that holds the non-zero elements of the "sparse" matrix. | |
| double | max =0.0 |
| double | max_minus_min =0.0 |
| double | min =0.0 |
| std::string | name |
| The name of this quantiy. | |
| std::size_t | ncols =0 |
| unsigned | ngrid_der =0 |
| enum PLMD::Value:: { ... } | periodicity =unset |
| Is this quantity periodic. | |
| std::vector< std::size_t > | shape |
| What is the shape of the value (0 dimensional=scalar, n dimensional with derivatives=grid, 1 dimensional no derivatives=vector, 2 dimensional no derivatives=matrix) | |
| std::string | str_max |
| std::string | str_min |
| Various quantities that describe the domain of this value. | |
| bool | symmetric =false |
| If we are storing a matrix is it symmetric? | |
| enum PLMD::Value:: { ... } | valtype =normal |
| The way this value is used in the code normal = regular value that is determined during calculate constant = constnt value that is determined during startup and that doesn't change during simulation average = value that is averaged/collected over multiple steps of trajectory calcFromAverage = value that is calculated from an average value. | |
| bool | value_set =false |
| Had the value been set. | |
Friends | |
| class | ActionAtomistic |
| class | ActionWithArguments |
| class | ActionWithMatrix |
| class | ActionWithValue |
| class | ActionWithVector |
| class | ActionWithVirtualAtom |
| struct | ArgumentsBookkeeping |
| template<typename T> | |
| class | DataPassingObjectTyped |
| class | DomainDecomposition |
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.
|
private |
The way this value is used in the code normal = regular value that is determined during calculate constant = constnt value that is determined during startup and that doesn't change during simulation average = value that is averaged/collected over multiple steps of trajectory calcFromAverage = value that is calculated from an average value.
| Enumerator | |
|---|---|
| normal | |
| constant | |
| average | |
| calcFromAverage | |
| PLMD::Value::Value | ( | ) |
A constructor that can be used to make Vectors of values.
|
explicit |
A constructor that can be used to make Vectors of named values.
| PLMD::Value::Value | ( | ActionWithValue * | av, |
| const std::string & | valname, | ||
| const bool | withderiv, | ||
| const std::vector< std::size_t > & | ss = std::vector<std::size_t>() ) |
A constructor that is used throughout the code to setup the value poiters.
|
inline |
Add something to the ith element of the data array.
|
inline |
Add something to the value of the function.
|
inline |
Add some derivative to the ith component of the derivatives array.
|
inline |
Set hasForce equal to true.
| void PLMD::Value::addForce | ( | const std::size_t & | ival, |
| double | f, | ||
| const bool | trueind = true ) |
Add some force on the ival th component of this value.
|
inline |
Add some force on this value.
| size_t PLMD::Value::addForces | ( | View< const double > | f | ) |
Add forces from a vector, imples trueInd=false and retunrs the number of forces assigned.
|
inline |
Add the derivatives of the grid to the corner.
| bool PLMD::Value::allElementsEqual | ( | ) | const |
Check if all the elements in the value have the same 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)
|
inlineprivate |
| size_t PLMD::Value::assignValues | ( | View< double > | target | ) |
A variant of get() for assigning data to an external view (assuems trueind=false), returns the number of arguments assigned.
|
inline |
Bring back one value into the correct pbc if needed, else give back the value.
|
private |
This is used by ActionWithValue to determine if we need to calculate on update.
| bool PLMD::Value::checkValueIsActiveForMMul | ( | std::size_t | task | ) | const |
A variant of get() for checking that at least one of the values on the row is !=0.
|
inline |
Set all the derivatives to zero.
|
inline |
Clear the input force on the variable.
|
inline |
Special method for clearing forces on variables used by DataPassingObject.
| void PLMD::Value::convertIndexToindices | ( | const std::size_t & | index, |
| std::vector< unsigned > & | indices ) const |
Convert the input index to its corresponding indices.
| void PLMD::Value::copyBookeepingArrayFromArgument | ( | Value * | myarg | ) |
Copy the matrix bookeeping stuff.
|
inline |
Calculate the difference between two values of this function: d2 -d1.
d2-d1
|
inline |
Calculate the difference between the instantaneous value of the function and some other point: other_point-inst_val.
|
inline |
Check if forces have been added on this value.
| double PLMD::Value::get | ( | const std::size_t | ival = 0, |
| const bool | trueind = true ) const |
Get the value of the function.
|
inline |
Get the derivative with respect to component n.
| void PLMD::Value::getDomain | ( | double & | minout, |
| double & | maxout ) const |
Get the domain of the quantity.
| void PLMD::Value::getDomain | ( | std::string & | minout, |
| std::string & | maxout ) const |
Get the domain of the quantity.
|
inline |
Get the value of the force on this colvar.
| unsigned PLMD::Value::getGoodNumThreads | ( | const unsigned & | j, |
| const unsigned & | k ) const |
Get the number of threads to use when assigning this value.
|
inline |
get the derivative of a grid at a point n with resepct to argument j
| std::size_t PLMD::Value::getIndexInStore | ( | const std::size_t & | ival | ) | const |
Get the location of this element of in the store.
|
inline |
Get the difference between max and minimum of domain.
|
inline |
Get the name of the quantity.
|
inline |
|
inline |
Get the number of derivatives that this particular value has.
|
inline |
Get the number of derivatives that the grid has.
|
inline |
Get the number of values that are actually stored here once sparse matrices are taken into account.
|
inline |
Get the total number of scalars that are stored here.
| ActionWithValue * PLMD::Value::getPntrToAction | ( | ) |
This returns the pointer to the action where this value is calculated.
|
inline |
Get the rank of the object that is contained in this value.
|
inline |
|
inline |
|
inline |
Get the shape of the object that is contained in this value.
| std::string PLMD::Value::getValueType | ( | ) | const |
Get the type of value that is stored here.
|
inline |
Check whether or not this particular quantity has derivatives.
| bool PLMD::Value::ignoreStoredValue | ( | const std::string & | n | ) | const |
Are we to ignore the stored value.
|
inline |
These are used for making constant values.
|
inline |
Return a bool that tells us if the derivative is zero when the value is zero.
| bool PLMD::Value::isPeriodic | ( | ) | const |
Check if the value is periodic.
|
inline |
| void PLMD::Value::passGradients | ( | const double & | der, |
| std::map< AtomNumber, Vector > & | g ) const |
This passes gradients from one action to another.
| void PLMD::Value::push_back | ( | const double & | val | ) |
Add another value to the end of the data vector held by this value. This is used in COLLECT.
| void PLMD::Value::readBinary | ( | std::istream & | i | ) |
| void PLMD::Value::reshapeConstantValue | ( | const std::vector< std::size_t > & | sh | ) |
| void PLMD::Value::reshapeMatrixStore | ( | const unsigned & | n | ) |
Reshape the storage for sparse matrices.
|
inline |
Set the number of derivatives.
| void PLMD::Value::retrieveEdgeList | ( | unsigned & | nedge, |
| std::vector< std::pair< unsigned, unsigned > > & | active, | ||
| std::vector< double > & | elems ) |
Retrieve the non-zero edges in a matrix.
| void PLMD::Value::set | ( | const std::size_t & | n, |
| const double & | v ) |
Set the value of the stored data.
|
inline |
Set the value of the function.
| void PLMD::Value::setConstant | ( | ) |
|
inline |
Set the value of the ith component of the derivatives array.
|
inline |
Set a bool that tells us if the derivative is zero when the value is zero true.
| void PLMD::Value::setDomain | ( | const std::string & | pmin, |
| const std::string & | pmax ) |
Set the domain of the function.
| void PLMD::Value::setGradients | ( | ActionAtomistic * | aa, |
| unsigned & | start ) |
This sets up the gradients.
|
inline |
|
inline |
Set a matrix element to be non zero.
| void PLMD::Value::setNotPeriodic | ( | ) |
Set the function not periodic.
|
inline |
| void PLMD::Value::setShape | ( | const std::vector< std::size_t > & | ss | ) |
Set the shape of the Value.
| void PLMD::Value::setSymmetric | ( | const bool & | sym | ) |
Set the symmetric flag equal true for this matrix.
|
private |
Complete the setup of the periodicity.
|
private |
This is used by ActionWithValue to set the valtype.
|
inline |
Find out if the value has been set.
| void PLMD::Value::writeBinary | ( | std::ostream & | o | ) | const |
These are used for passing around the data in this value when we are doing replica exchange.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
The action in which this quantity is calculated.
|
private |
Variables for storing data.
|
private |
The value of the quantity.
|
private |
Is the derivative of this quantity zero when the value is zero.
|
private |
The derivatives of the quantity stored in value.
|
private |
Does this quanity have derivatives.
|
private |
A flag telling us we have a force acting on this quantity.
|
private |
The force acting on this quantity.
|
private |
|
private |
This is a bookeeping array that holds the non-zero elements of the "sparse" matrix.
|
private |
|
private |
|
private |
|
private |
The name of this quantiy.
|
private |
|
private |
| enum { ... } PLMD::Value::periodicity |
Is this quantity periodic.
|
private |
What is the shape of the value (0 dimensional=scalar, n dimensional with derivatives=grid, 1 dimensional no derivatives=vector, 2 dimensional no derivatives=matrix)
|
private |
|
private |
Various quantities that describe the domain of this value.
|
private |
If we are storing a matrix is it symmetric?
| enum { ... } PLMD::Value::valtype |
The way this value is used in the code normal = regular value that is determined during calculate constant = constnt value that is determined during startup and that doesn't change during simulation average = value that is averaged/collected over multiple steps of trajectory calcFromAverage = value that is calculated from an average value.
|
private |
Had the value been set.
Hosted by GitHub
|
1.13.2
|