Gromacs  2025-dev-20240910-a7e2421
gmx::anonymous_namespace{biasstate.cpp} Namespace Reference

## Functions

void sumPmf (gmx::ArrayRef< PointState > pointState, int numSharedUpdate, const BiasSharing *biasSharing, const int biasIndex)
Sum PMF over multiple simulations, when requested. More...

double freeEnergyMinimumValue (gmx::ArrayRef< const PointState > pointState)
Find the minimum free energy value. More...

double biasedLogWeightFromPoint (ArrayRef< const DimParams > dimParams, ArrayRef< const PointState > points, const BiasGrid &grid, int pointIndex, double pointBias, const awh_dvec value, ArrayRef< const double > neighborLambdaEnergies, int gridpointIndex)
Find and return the log of the probability weight of a point given a coordinate value. More...

std::vector< double > calculateFELambdaMarginalDistribution (const BiasGrid &grid, ArrayRef< const int > neighbors, ArrayRef< const double > probWeightNeighbor)
Calculates the marginal distribution (marginal probability) for each value along a free energy lambda axis. The marginal distribution of one coordinate dimension value is the sum of the probability distribution of all values (herein all neighbor values) with the same value in the dimension of interest. More...

std::string gridPointValueString (const BiasGrid &grid, int point)
Puts together a string describing a grid point. More...

void setHistogramUpdateScaleFactors (const BiasParams &params, double newHistogramSize, double oldHistogramSize, double *weightHistScaling, double *logPmfSumScaling)
Sets the histogram rescaling factors needed to control the histogram size. More...

void mergeSharedUpdateLists (std::vector< int > *updateList, int numPoints, const BiasSharing &biasSharing, const int biasIndex)
Merge update lists from multiple sharing simulations. More...

void makeLocalUpdateList (const BiasGrid &grid, ArrayRef< const PointState > points, const awh_ivec originUpdatelist, const awh_ivec endUpdatelist, std::vector< int > *updateList)
Generate an update list of points sampled since the last update. More...

void sumHistograms (gmx::ArrayRef< PointState > pointState, gmx::ArrayRef< double > weightSumCovering, int numSharedUpdate, const BiasSharing *biasSharing, const int biasIndex, const std::vector< int > &localUpdateList)

void labelCoveredPoints (const std::vector< bool > &visited, const std::vector< bool > &checkCovering, int numPoints, int period, int coverRadius, gmx::ArrayRef< int > covered)
Label points along an axis as covered or not. More...

## Function Documentation

 double gmx::anonymous_namespace{biasstate.cpp}::biasedLogWeightFromPoint ( ArrayRef< const DimParams > dimParams, ArrayRef< const PointState > points, const BiasGrid & grid, int pointIndex, double pointBias, const awh_dvec value, ArrayRef< const double > neighborLambdaEnergies, int gridpointIndex )

Find and return the log of the probability weight of a point given a coordinate value.

The unnormalized weight is given by w(point|value) = exp(bias(point) - U(value,point)), where U is a harmonic umbrella potential.

Parameters
 [in] dimParams The bias dimensions parameters [in] points The point state. [in] grid The grid. [in] pointIndex Point to evaluate probability weight for. [in] pointBias Bias for the point (as a log weight). [in] value Coordinate value. [in] neighborLambdaEnergies The energy of the system in neighboring lambdas states. Can be empty when there are no free energy lambda state dimensions. [in] gridpointIndex The index of the current grid point.
Returns
the log of the biased probability weight.
 std::vector gmx::anonymous_namespace{biasstate.cpp}::calculateFELambdaMarginalDistribution ( const BiasGrid & grid, ArrayRef< const int > neighbors, ArrayRef< const double > probWeightNeighbor )

Calculates the marginal distribution (marginal probability) for each value along a free energy lambda axis. The marginal distribution of one coordinate dimension value is the sum of the probability distribution of all values (herein all neighbor values) with the same value in the dimension of interest.

Parameters
 [in] grid The bias grid. [in] neighbors The points to use for the calculation of the marginal distribution. [in] probWeightNeighbor Probability weights of the neighbors.
Returns
The calculated marginal distribution in a 1D array with as many elements as there are points along the axis of interest.
 double gmx::anonymous_namespace{biasstate.cpp}::freeEnergyMinimumValue ( gmx::ArrayRef< const PointState > pointState )

Find the minimum free energy value.

Parameters
 [in] pointState The state of the points.
Returns
the minimum free energy value.
 std::string gmx::anonymous_namespace{biasstate.cpp}::gridPointValueString ( const BiasGrid & grid, int point )

Puts together a string describing a grid point.

Parameters
 [in] grid The grid. [in] point BiasGrid point index.
Returns
a string for the point.
 void gmx::anonymous_namespace{biasstate.cpp}::labelCoveredPoints ( const std::vector< bool > & visited, const std::vector< bool > & checkCovering, int numPoints, int period, int coverRadius, gmx::ArrayRef< int > covered )

Label points along an axis as covered or not.

A point is covered if it is surrounded by visited points up to a radius = coverRadius.

Parameters
 [in] visited Visited? For each point. [in] checkCovering Check for covering? For each point. [in] numPoints The number of grid points along this dimension. [in] period Period in number of points. [in] coverRadius Cover radius, in points, needed for defining a point as covered. [in,out] covered In this array elements are 1 for covered points and 0 for non-covered points, this routine assumes that `covered` has at least size `numPoints`.
 void gmx::anonymous_namespace{biasstate.cpp}::makeLocalUpdateList ( const BiasGrid & grid, ArrayRef< const PointState > points, const awh_ivec originUpdatelist, const awh_ivec endUpdatelist, std::vector< int > * updateList )

Generate an update list of points sampled since the last update.

Parameters
 [in] grid The AWH bias. [in] points The point state. [in] originUpdatelist The origin of the rectangular region that has been sampled since last update. [in] endUpdatelist The end of the rectangular that has been sampled since last update. [in,out] updateList Local update list to set (assumed >= npoints long).
 void gmx::anonymous_namespace{biasstate.cpp}::mergeSharedUpdateLists ( std::vector< int > * updateList, int numPoints, const BiasSharing & biasSharing, const int biasIndex )

Merge update lists from multiple sharing simulations.

Parameters
 [in,out] updateList Update list for this simulation (assumed >= npoints long). [in] numPoints Total number of points. [in] biasSharing Object for sharing bias data over multiple simulations [in] biasIndex Index of this bias in the total list of biases in this simulation
 void gmx::anonymous_namespace{biasstate.cpp}::setHistogramUpdateScaleFactors ( const BiasParams & params, double newHistogramSize, double oldHistogramSize, double * weightHistScaling, double * logPmfSumScaling )

Sets the histogram rescaling factors needed to control the histogram size.

For sake of robustness, the reference weight histogram can grow at a rate different from the actual sampling rate. Typically this happens for a limited initial time, alternatively growth is scaled down by a constant factor for all times. Since the size of the reference histogram sets the size of the free energy update this should be reflected also in the PMF. Thus the PMF histogram needs to be rescaled too.

This function should only be called by the bias update function or wrapped by a function that knows what scale factors should be applied when, e.g, getSkippedUpdateHistogramScaleFactors().

Parameters
 [in] params The bias parameters. [in] newHistogramSize New reference weight histogram size. [in] oldHistogramSize Previous reference weight histogram size (before adding new samples). [out] weightHistScaling Scaling factor for the reference weight histogram. [out] logPmfSumScaling Log of the scaling factor for the PMF histogram.
 void gmx::anonymous_namespace{biasstate.cpp}::sumHistograms ( gmx::ArrayRef< PointState > pointState, gmx::ArrayRef< double > weightSumCovering, int numSharedUpdate, const BiasSharing * biasSharing, const int biasIndex, const std::vector< int > & localUpdateList )