Gromacs  2025.0-dev-20241011-013a99c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Attributes
gmx::CorrelationTensor Class Reference

#include <gromacs/applied_forces/awh/correlationtensor.h>

Description

Correlation data for computing the correlation tensor of one grid point.

The time integrated autocorrelation of the desired quantity is computed using block averages, which is a computationally efficient and low memory method. Most of the work here goes into computing the block averages for weights and the coordinate quantity. This is done for a number of blocks in the range of c_numCorrelationBlocks/2 + 1 to c_numCorrelationBlocks, depending on the current simulation length. As the simulation time progresses, the blocks get longer. This is implemented in an efficient way by keeping track of log2(c_numCorrelationBlocks) BlockData data blocks with block length increasing progressively by a factor of 2. Once c_numCorrelationBlocks are reached, all block lengths are doubled.

Public Member Functions

 CorrelationTensor (int numDim, int numBlockData, double blockLengthInit)
 Constructor. More...
 
const std::vector
< CorrelationBlockData > & 
blockDataList () const
 Get a const reference to the list of block data.
 
double getWeight () const
 Get the total weight of the data in the correlation matrix. More...
 
void restoreFromHistory (const std::vector< CorrelationBlockDataHistory > &blockDataBuffer, size_t *bufferIndex)
 Restore a correlation element from history. More...
 
void addData (double weight, gmx::ArrayRef< const double > data, bool blockLengthInWeight, double t)
 Adds a weighted data vector to one point in the correlation grid. More...
 
double getTimeIntegral (int tensorIndex, double dtSample) const
 Returns an element of the time integrated correlation tensor at a given point in the grid. More...
 
double getVolumeElement (double dtSample) const
 Returns the volume element of the correlation metric. More...
 

Static Public Attributes

static constexpr int c_numCorrelationBlocks = 64
 64 blocks is a good trade-off between signal and noise
 

Constructor & Destructor Documentation

gmx::CorrelationTensor::CorrelationTensor ( int  numDim,
int  numBlockData,
double  blockLengthInit 
)

Constructor.

Parameters
[in]numDimThe dimensionality.
[in]numBlockDataThe number of data block data structs.
[in]blockLengthInitThe initial block length.

Member Function Documentation

void gmx::CorrelationTensor::addData ( double  weight,
gmx::ArrayRef< const double >  data,
bool  blockLengthInWeight,
double  t 
)

Adds a weighted data vector to one point in the correlation grid.

Note
To avoid rounding noise, data with weight smaller than 1e-6 is ignored.
Parameters
[in]weightThe weight of the data.
[in]dataOne data point for each grid dimension.
[in]blockLengthInWeightIf true, a block is measured in probability weight, otherwise in time.
[in]tThe simulation time.
double gmx::CorrelationTensor::getTimeIntegral ( int  tensorIndex,
double  dtSample 
) const

Returns an element of the time integrated correlation tensor at a given point in the grid.

The units of the integral are time*(units of data)^2. This will be friction units time/length^2 if the data unit is 1/length.

The correlation index lists the elements of the upper-triangular correlation matrix row-wise, so e.g. in 3D: 0 (0,0), 1 (1,0), 2 (1,1), 3 (2,0), 4 (2,1), 5 (2,2). (TODO: this should ideally not have to be known by the caller.)

Parameters
[in]tensorIndexIndex in the tensor.
[in]dtSampleThe sampling interval length.
Returns
the integral.
double gmx::CorrelationTensor::getVolumeElement ( double  dtSample) const

Returns the volume element of the correlation metric.

The matrix of the metric equals the time-integrated correlation matrix. The volume element of the metric therefore equals the square-root of the absolute value of its determinant according to the standard formula for a volume element in a metric space.

Since the units of the metric matrix elements are time*(units of data)^2, the volume element has units of (sqrt(time)*(units of data))^(ndim of data).

Parameters
[in]dtSampleThe sampling interval length.
Returns
the volume element.
double gmx::CorrelationTensor::getWeight ( ) const
inline

Get the total weight of the data in the correlation matrix.

Returns
the weight of the added data.
void gmx::CorrelationTensor::restoreFromHistory ( const std::vector< CorrelationBlockDataHistory > &  blockDataBuffer,
size_t *  bufferIndex 
)

Restore a correlation element from history.

Parameters
[in]blockDataBufferThe linear correlation grid data history buffer.
[in,out]bufferIndexThe index in blockDataBuffer to start reading, is increased with the number of blocks read.

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