Gromacs
2025.0-dev-20241011-013a99c
|
#include <gromacs/applied_forces/awh/correlationtensor.h>
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 | |
gmx::CorrelationTensor::CorrelationTensor | ( | int | numDim, |
int | numBlockData, | ||
double | blockLengthInit | ||
) |
Constructor.
[in] | numDim | The dimensionality. |
[in] | numBlockData | The number of data block data structs. |
[in] | blockLengthInit | The initial block length. |
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.
[in] | weight | The weight of the data. |
[in] | data | One data point for each grid dimension. |
[in] | blockLengthInWeight | If true, a block is measured in probability weight, otherwise in time. |
[in] | t | The 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.)
[in] | tensorIndex | Index in the tensor. |
[in] | dtSample | The sampling interval length. |
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).
[in] | dtSample | The sampling interval length. |
|
inline |
Get the total weight of the data in the correlation matrix.
void gmx::CorrelationTensor::restoreFromHistory | ( | const std::vector< CorrelationBlockDataHistory > & | blockDataBuffer, |
size_t * | bufferIndex | ||
) |
Restore a correlation element from history.
[in] | blockDataBuffer | The linear correlation grid data history buffer. |
[in,out] | bufferIndex | The index in blockDataBuffer to start reading, is increased with the number of blocks read. |