Preparation for further refactoring.
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* \param[in] pointState The state of the points in a bias.
* \returns the total sample count.
*/
-static int64_t countSamples(const std::vector<PointState>& pointState)
+static int64_t countSamples(ArrayRef<const PointState> pointState)
{
double numSamples = 0;
for (const PointState& point : pointState)
Bias::Bias(int biasIndexInCollection,
const AwhParams& awhParams,
const AwhBiasParams& awhBiasParams,
- const std::vector<DimParams>& dimParamsInit,
+ ArrayRef<const DimParams> dimParamsInit,
double beta,
double mdTimeStep,
int numSharingSimulations,
const std::string& biasInitFilename,
ThisRankWillDoIO thisRankWillDoIO,
BiasParams::DisableUpdateSkips disableUpdateSkips) :
- dimParams_(dimParamsInit),
+ dimParams_(dimParamsInit.begin(), dimParamsInit.end()),
grid_(dimParamsInit, awhBiasParams.dimParams),
params_(awhParams,
awhBiasParams,
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
Bias(int biasIndexInCollection,
const AwhParams& awhParams,
const AwhBiasParams& awhBiasParams,
- const std::vector<DimParams>& dimParams,
+ ArrayRef<const DimParams> dimParams,
double beta,
double mdTimeStep,
int numSharingSimulations,
/*! \brief Returns the dimension parameters.
*/
- inline const std::vector<DimParams>& dimParams() const { return dimParams_; }
+ inline ArrayRef<const DimParams> dimParams() const { return dimParams_; }
//! Returns the bias parameters
inline const BiasParams& params() const { return params_; }
* \param[in] indexMulti Multidimensional grid point index to convert to a linear one.
* \returns the linear index.
*/
-int multiDimGridIndexToLinear(const std::vector<GridAxis>& axis, const awh_ivec indexMulti)
+int multiDimGridIndexToLinear(ArrayRef<const GridAxis> axis, const awh_ivec indexMulti)
{
awh_ivec numPointsDim = { 0 };
* \param[in] axis The grid axes.
* \returns true if the value is in the grid.
*/
-static bool valueIsInGrid(const awh_dvec value, const std::vector<GridAxis>& axis)
+static bool valueIsInGrid(const awh_dvec value, ArrayRef<const GridAxis> axis)
{
/* For each dimension get the one-dimensional index and check if it is in range. */
for (size_t d = 0; d < axis.size(); d++)
* \param[in] axis The grid axes.
* \returns the point index nearest to the value.
*/
-static int getNearestIndexInGrid(const awh_dvec value, const std::vector<GridAxis>& axis)
+static int getNearestIndexInGrid(const awh_dvec value, ArrayRef<const GridAxis> axis)
{
awh_ivec indexMulti;
}
}
-BiasGrid::BiasGrid(const std::vector<DimParams>& dimParams, const AwhDimParams* awhDimParams)
+BiasGrid::BiasGrid(ArrayRef<const DimParams> dimParams, const AwhDimParams* awhDimParams)
{
/* Define the discretization along each dimension */
awh_dvec period;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016,2017,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include <optional>
#include <string>
+#include "gromacs/utility/arrayref.h"
+
#include "dimparams.h" /* This is needed for awh_dvec */
namespace gmx
* coordinate living on the grid (determines the grid spacing).
* \param[in] awhDimParams Dimension params from inputrec.
*/
- BiasGrid(const std::vector<DimParams>& dimParams, const AwhDimParams* awhDimParams);
+ BiasGrid(ArrayRef<const DimParams> dimParams, const AwhDimParams* awhDimParams);
/*! \brief Returns the number of points in the grid.
*
*
* \returns a constant reference to the grid axes.
*/
- const std::vector<GridAxis>& axis() const { return axis_; }
+ ArrayRef<const GridAxis> axis() const { return axis_; }
/*! \brief Returns a grid axis.
*
* \param[in] gridAxis The BiasGrid axes.
* \returns the check interval in steps.
*/
-int64_t calcCheckCoveringInterval(const AwhParams& awhParams,
- const std::vector<DimParams>& dimParams,
- const std::vector<GridAxis>& gridAxis)
+int64_t calcCheckCoveringInterval(const AwhParams& awhParams,
+ ArrayRef<const DimParams> dimParams,
+ ArrayRef<const GridAxis> gridAxis)
{
/* Each sample will have a width of sigma. To cover the axis a
minimum number of samples of width sigma is required. */
* \param[in] samplingTimestep Sampling frequency of probability weights.
* \returns estimate of initial histogram size.
*/
-double getInitialHistogramSizeEstimate(const AwhBiasParams& awhBiasParams,
- const std::vector<GridAxis>& gridAxis,
- double beta,
- double samplingTimestep)
+double getInitialHistogramSizeEstimate(const AwhBiasParams& awhBiasParams,
+ ArrayRef<const GridAxis> gridAxis,
+ double beta,
+ double samplingTimestep)
{
/* Get diffusion factor */
double maxCrossingTime = 0.;
} // namespace
-BiasParams::BiasParams(const AwhParams& awhParams,
- const AwhBiasParams& awhBiasParams,
- const std::vector<DimParams>& dimParams,
- double beta,
- double mdTimeStep,
- DisableUpdateSkips disableUpdateSkips,
- int numSharingSimulations,
- const std::vector<GridAxis>& gridAxis,
- int biasIndex) :
+BiasParams::BiasParams(const AwhParams& awhParams,
+ const AwhBiasParams& awhBiasParams,
+ ArrayRef<const DimParams> dimParams,
+ double beta,
+ double mdTimeStep,
+ DisableUpdateSkips disableUpdateSkips,
+ int numSharingSimulations,
+ ArrayRef<const GridAxis> gridAxis,
+ int biasIndex) :
invBeta(beta > 0 ? 1 / beta : 0),
numStepsSampleCoord_(awhParams.nstSampleCoord),
numSamplesUpdateFreeEnergy_(awhParams.numSamplesUpdateFreeEnergy),
namespace gmx
{
+template<typename>
+class ArrayRef;
struct AwhBiasParams;
struct AwhParams;
struct DimParams;
* \param[in] disableUpdateSkips If to disable update skips, useful for testing.
* \param[in] biasIndex Index of the bias.
*/
- BiasParams(const AwhParams& awhParams,
- const AwhBiasParams& awhBiasParams,
- const std::vector<DimParams>& dimParams,
- double beta,
- double mdTimeStep,
- DisableUpdateSkips disableUpdateSkips,
- int numSharingSimulations,
- const std::vector<GridAxis>& gridAxis,
- int biasIndex);
+ BiasParams(const AwhParams& awhParams,
+ const AwhBiasParams& awhBiasParams,
+ ArrayRef<const DimParams> dimParams,
+ double beta,
+ double mdTimeStep,
+ DisableUpdateSkips disableUpdateSkips,
+ int numSharingSimulations,
+ ArrayRef<const GridAxis> gridAxis,
+ int biasIndex);
/* Data members */
const double invBeta; /**< 1/beta = kT in kJ/mol */
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
return haveSharing;
}
-void biasesAreCompatibleForSharingBetweenSimulations(const AwhParams& awhParams,
- const std::vector<size_t>& pointSize,
- const gmx_multisim_t* multiSimComm)
+void biasesAreCompatibleForSharingBetweenSimulations(const AwhParams& awhParams,
+ ArrayRef<const size_t> pointSize,
+ const gmx_multisim_t* multiSimComm)
{
const int numSim = multiSimComm->numSimulations_;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2017,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2017,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
namespace gmx
{
+template<typename>
+class ArrayRef;
struct AwhParams;
/*! \brief Returns if any bias is sharing within a simulation.
* \param[in] pointSize Vector of grid-point sizes for each bias.
* \param[in] multiSimComm Struct for multi-simulation communication.
*/
-void biasesAreCompatibleForSharingBetweenSimulations(const AwhParams& awhParams,
- const std::vector<size_t>& pointSize,
- const gmx_multisim_t* multiSimComm);
+void biasesAreCompatibleForSharingBetweenSimulations(const AwhParams& awhParams,
+ ArrayRef<const size_t> pointSize,
+ const gmx_multisim_t* multiSimComm);
} // namespace gmx
* \param[in] gridpointIndex The index of the current grid point.
* \returns the log of the biased probability weight.
*/
-double biasedLogWeightFromPoint(const std::vector<DimParams>& dimParams,
- const std::vector<PointState>& points,
- const BiasGrid& grid,
- int pointIndex,
- double pointBias,
- const awh_dvec value,
- gmx::ArrayRef<const double> neighborLambdaEnergies,
- int gridpointIndex)
+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)
{
double logWeight = detail::c_largeNegativeExponent;
* \returns The calculated marginal distribution in a 1D array with
* as many elements as there are points along the axis of interest.
*/
-std::vector<double> calculateFELambdaMarginalDistribution(const BiasGrid& grid,
- gmx::ArrayRef<const int> neighbors,
- gmx::ArrayRef<const double> probWeightNeighbor)
+std::vector<double> calculateFELambdaMarginalDistribution(const BiasGrid& grid,
+ ArrayRef<const int> neighbors,
+ ArrayRef<const double> probWeightNeighbor)
{
const std::optional<int> lambdaAxisIndex = grid.lambdaAxisIndex();
GMX_RELEASE_ASSERT(lambdaAxisIndex,
} // namespace
-void BiasState::calcConvolvedPmf(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- std::vector<float>* convolvedPmf) const
+void BiasState::calcConvolvedPmf(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ std::vector<float>* convolvedPmf) const
{
size_t numPoints = grid.numPoints();
* \param[in,out] pointState The state of all points.
* \param[in] params The bias parameters.
*/
-void updateTargetDistribution(gmx::ArrayRef<PointState> pointState, const BiasParams& params)
+void updateTargetDistribution(ArrayRef<PointState> pointState, const BiasParams& params)
{
double freeEnergyCutoff = 0;
if (params.eTarget == AwhTargetType::Cutoff)
return numWarnings;
}
-double BiasState::calcUmbrellaForceAndPotential(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- int point,
- ArrayRef<const double> neighborLambdaDhdl,
- gmx::ArrayRef<double> force) const
+double BiasState::calcUmbrellaForceAndPotential(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ int point,
+ ArrayRef<const double> neighborLambdaDhdl,
+ ArrayRef<double> force) const
{
double potential = 0;
for (size_t d = 0; d < dimParams.size(); d++)
return potential;
}
-void BiasState::calcConvolvedForce(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- gmx::ArrayRef<const double> probWeightNeighbor,
- ArrayRef<const double> neighborLambdaDhdl,
- gmx::ArrayRef<double> forceWorkBuffer,
- gmx::ArrayRef<double> force) const
+void BiasState::calcConvolvedForce(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ ArrayRef<const double> probWeightNeighbor,
+ ArrayRef<const double> neighborLambdaDhdl,
+ ArrayRef<double> forceWorkBuffer,
+ ArrayRef<double> force) const
{
for (size_t d = 0; d < dimParams.size(); d++)
{
}
}
-double BiasState::moveUmbrella(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- gmx::ArrayRef<const double> probWeightNeighbor,
- ArrayRef<const double> neighborLambdaDhdl,
- gmx::ArrayRef<double> biasForce,
- int64_t step,
- int64_t seed,
- int indexSeed,
- bool onlySampleUmbrellaGridpoint)
+double BiasState::moveUmbrella(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ ArrayRef<const double> probWeightNeighbor,
+ ArrayRef<const double> neighborLambdaDhdl,
+ ArrayRef<double> biasForce,
+ int64_t step,
+ int64_t seed,
+ int indexSeed,
+ bool onlySampleUmbrellaGridpoint)
{
/* Generate and set a new coordinate reference value */
coordState_.sampleUmbrellaGridpoint(
* last update. \param[in] endUpdatelist The end of the rectangular that has been sampled since
* last update. \param[in,out] updateList Local update list to set (assumed >= npoints long).
*/
-void makeLocalUpdateList(const BiasGrid& grid,
- const std::vector<PointState>& points,
- const awh_ivec originUpdatelist,
- const awh_ivec endUpdatelist,
- std::vector<int>* updateList)
+void makeLocalUpdateList(const BiasGrid& grid,
+ ArrayRef<const PointState> points,
+ const awh_ivec originUpdatelist,
+ const awh_ivec endUpdatelist,
+ std::vector<int>* updateList)
{
awh_ivec origin;
awh_ivec numPoints;
} // namespace
-bool BiasState::isSamplingRegionCovered(const BiasParams& params,
- const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- const t_commrec* commRecord,
- const gmx_multisim_t* multiSimComm) const
+bool BiasState::isSamplingRegionCovered(const BiasParams& params,
+ ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ const t_commrec* commRecord,
+ const gmx_multisim_t* multiSimComm) const
{
/* Allocate and initialize arrays: one for checking visits along each dimension,
one for keeping track of which points to check and one for the covered points.
}
}
-void BiasState::updateFreeEnergyAndAddSamplesToHistogram(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- const BiasParams& params,
- const t_commrec* commRecord,
- const gmx_multisim_t* multiSimComm,
- double t,
- int64_t step,
- FILE* fplog,
- std::vector<int>* updateList)
+void BiasState::updateFreeEnergyAndAddSamplesToHistogram(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ const BiasParams& params,
+ const t_commrec* commRecord,
+ const gmx_multisim_t* multiSimComm,
+ double t,
+ int64_t step,
+ FILE* fplog,
+ std::vector<int>* updateList)
{
/* Note hat updateList is only used in this scope and is always
* re-initialized. We do not use a local vector, because that would
histogramSize_.incrementNumUpdates();
}
-double BiasState::updateProbabilityWeightsAndConvolvedBias(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- gmx::ArrayRef<const double> neighborLambdaEnergies,
+double BiasState::updateProbabilityWeightsAndConvolvedBias(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ ArrayRef<const double> neighborLambdaEnergies,
std::vector<double, AlignedAllocator<double>>* weight) const
{
/* Only neighbors of the current coordinate value will have a non-negligible chance of getting sampled */
return std::log(weightSum);
}
-double BiasState::calcConvolvedBias(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- const awh_dvec& coordValue) const
+double BiasState::calcConvolvedBias(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ const awh_dvec& coordValue) const
{
int point = grid.nearestIndex(coordValue);
const GridPoint& gridPoint = grid.point(point);
gmx_bcast(sizeof(histogramSize_), &histogramSize_, commRecord->mpi_comm_mygroup);
}
-void BiasState::setFreeEnergyToConvolvedPmf(const std::vector<DimParams>& dimParams, const BiasGrid& grid)
+void BiasState::setFreeEnergyToConvolvedPmf(ArrayRef<const DimParams> dimParams, const BiasGrid& grid)
{
std::vector<float> convolvedPmf;
* \param[in] biasIndex The index of the bias.
* \param[in,out] pointState The state of the points in this bias.
*/
-static void readUserPmfAndTargetDistribution(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- const std::string& filename,
- int numBias,
- int biasIndex,
- std::vector<PointState>* pointState)
+static void readUserPmfAndTargetDistribution(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ const std::string& filename,
+ int numBias,
+ int biasIndex,
+ std::vector<PointState>* pointState)
{
/* Read the PMF and target distribution.
From the PMF, the convolved PMF, or the reference value free energy, can be calculated
}
}
-void BiasState::initGridPointState(const AwhBiasParams& awhBiasParams,
- const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- const BiasParams& params,
- const std::string& filename,
- int numBias)
+void BiasState::initGridPointState(const AwhBiasParams& awhBiasParams,
+ ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ const BiasParams& params,
+ const std::string& filename,
+ int numBias)
{
/* Modify PMF, free energy and the constant target distribution factor
* to user input values if there is data given.
normalizePmf(params.numSharedUpdate);
}
-BiasState::BiasState(const AwhBiasParams& awhBiasParams,
- double histogramSizeInitial,
- const std::vector<DimParams>& dimParams,
- const BiasGrid& grid) :
+BiasState::BiasState(const AwhBiasParams& awhBiasParams,
+ double histogramSizeInitial,
+ ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid) :
coordState_(awhBiasParams, dimParams, grid),
points_(grid.numPoints()),
weightSumCovering_(grid.numPoints()),
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* \param[in] dimParams The dimension parameters.
* \param[in] grid The bias grid.
*/
- BiasState(const AwhBiasParams& awhBiasParams,
- double histogramSizeInitial,
- const std::vector<DimParams>& dimParams,
- const BiasGrid& grid);
+ BiasState(const AwhBiasParams& awhBiasParams,
+ double histogramSizeInitial,
+ ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid);
/*! \brief
* Restore the bias state from history.
* \param[in] grid The grid.
* \param[in,out] convolvedPmf Array returned will be of the same length as the AWH grid to store the convolved PMF in.
*/
- void calcConvolvedPmf(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- std::vector<float>* convolvedPmf) const;
+ void calcConvolvedPmf(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ std::vector<float>* convolvedPmf) const;
/*! \brief
* Convolves the PMF and sets the initial free energy to its convolution.
* \param[in] dimParams The bias dimensions parameters
* \param[in] grid The bias grid.
*/
- void setFreeEnergyToConvolvedPmf(const std::vector<DimParams>& dimParams, const BiasGrid& grid);
+ void setFreeEnergyToConvolvedPmf(ArrayRef<const DimParams> dimParams, const BiasGrid& grid);
/*! \brief
* Normalize the PMF histogram.
* \param[in] filename Name of file to read PMF and target from.
* \param[in] numBias The number of biases.
*/
- void initGridPointState(const AwhBiasParams& awhBiasParams,
- const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- const BiasParams& params,
- const std::string& filename,
- int numBias);
+ void initGridPointState(const AwhBiasParams& awhBiasParams,
+ ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ const BiasParams& params,
+ const std::string& filename,
+ int numBias);
/*! \brief
* Performs statistical checks on the collected histograms and warns if issues are detected.
* \param[in,out] force Force vector to set.
* Returns the umbrella potential.
*/
- double calcUmbrellaForceAndPotential(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- int point,
- ArrayRef<const double> neighborLambdaDhdl,
- gmx::ArrayRef<double> force) const;
+ double calcUmbrellaForceAndPotential(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ int point,
+ ArrayRef<const double> neighborLambdaDhdl,
+ ArrayRef<double> force) const;
/*! \brief
* Calculates and sets the convolved force acting on the coordinate.
* \param[in] forceWorkBuffer Force work buffer, values only used internally.
* \param[in,out] force Bias force vector to set.
*/
- void calcConvolvedForce(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- gmx::ArrayRef<const double> probWeightNeighbor,
- ArrayRef<const double> neighborLambdaDhdl,
- gmx::ArrayRef<double> forceWorkBuffer,
- gmx::ArrayRef<double> force) const;
+ void calcConvolvedForce(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ ArrayRef<const double> probWeightNeighbor,
+ ArrayRef<const double> neighborLambdaDhdl,
+ ArrayRef<double> forceWorkBuffer,
+ ArrayRef<double> force) const;
/*! \brief
* Move the center point of the umbrella potential.
* force and potential.
* \returns the new potential value.
*/
- double moveUmbrella(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- gmx::ArrayRef<const double> probWeightNeighbor,
- ArrayRef<const double> neighborLambdaDhdl,
- gmx::ArrayRef<double> biasForce,
- int64_t step,
- int64_t seed,
- int indexSeed,
- bool onlySampleUmbrellaGridpoint);
+ double moveUmbrella(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ ArrayRef<const double> probWeightNeighbor,
+ ArrayRef<const double> neighborLambdaDhdl,
+ ArrayRef<double> biasForce,
+ int64_t step,
+ int64_t seed,
+ int indexSeed,
+ bool onlySampleUmbrellaGridpoint);
private:
/*! \brief
* \param[in] multiSimComm Struct for multi-simulation communication.
* \returns true if covered.
*/
- bool isSamplingRegionCovered(const BiasParams& params,
- const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- const t_commrec* commRecord,
- const gmx_multisim_t* multiSimComm) const;
+ bool isSamplingRegionCovered(const BiasParams& params,
+ ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ const t_commrec* commRecord,
+ const gmx_multisim_t* multiSimComm) const;
/*! \brief
* Return the new reference weight histogram size for the current update.
* \param[in,out] fplog Log file.
* \param[in,out] updateList Work space to store a temporary list.
*/
- void updateFreeEnergyAndAddSamplesToHistogram(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- const BiasParams& params,
- const t_commrec* commRecord,
- const gmx_multisim_t* ms,
- double t,
- int64_t step,
- FILE* fplog,
- std::vector<int>* updateList);
+ void updateFreeEnergyAndAddSamplesToHistogram(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ const BiasParams& params,
+ const t_commrec* commRecord,
+ const gmx_multisim_t* ms,
+ double t,
+ int64_t step,
+ FILE* fplog,
+ std::vector<int>* updateList);
/*! \brief
* Update the probability weights and the convolved bias.
* \returns the convolved bias.
*/
- double updateProbabilityWeightsAndConvolvedBias(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
+ double updateProbabilityWeightsAndConvolvedBias(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
ArrayRef<const double> neighborLambdaEnergies,
std::vector<double, AlignedAllocator<double>>* weight) const;
* \param[in] grid The grid.
* \param[in] probWeightNeighbor Probability weights of the neighbors.
*/
- void sampleProbabilityWeights(const BiasGrid& grid, gmx::ArrayRef<const double> probWeightNeighbor);
+ void sampleProbabilityWeights(const BiasGrid& grid, ArrayRef<const double> probWeightNeighbor);
/*! \brief
* Sample the reaction coordinate and PMF for future updates or analysis.
*/
void sampleCoordAndPmf(const std::vector<DimParams>& dimParams,
const BiasGrid& grid,
- gmx::ArrayRef<const double> probWeightNeighbor,
+ ArrayRef<const double> probWeightNeighbor,
double convolvedBias);
/*! \brief
* Calculates the convolved bias for a given coordinate value.
* \param[in] coordValue Coordinate value.
* \returns the convolved bias >= -GMX_FLOAT_MAX.
*/
- double calcConvolvedBias(const std::vector<DimParams>& dimParams,
- const BiasGrid& grid,
- const awh_dvec& coordValue) const;
+ double calcConvolvedBias(ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid,
+ const awh_dvec& coordValue) const;
/*! \brief
* Fills the given array with PMF values.
*
* \param[out] pmf Array(ref) to be filled with the PMF values, should have the same size as the bias grid.
*/
- void getPmf(gmx::ArrayRef<float> /*pmf*/) const;
+ void getPmf(ArrayRef<float> /*pmf*/) const;
/*! \brief Returns the current coordinate state.
*/
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
namespace gmx
{
-CoordState::CoordState(const AwhBiasParams& awhBiasParams,
- const std::vector<DimParams>& dimParams,
- const BiasGrid& grid)
+CoordState::CoordState(const AwhBiasParams& awhBiasParams,
+ ArrayRef<const DimParams> dimParams,
+ const BiasGrid& grid)
{
for (size_t d = 0; d < dimParams.size(); d++)
{
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* \param[in] dimParams The dimension Parameters.
* \param[in] grid The grid.
*/
- CoordState(const AwhBiasParams& awhBiasParams,
- const std::vector<DimParams>& dimParams,
- const BiasGrid& grid);
+ CoordState(const AwhBiasParams& awhBiasParams, ArrayRef<const DimParams> dimParams, const BiasGrid& grid);
/*! \brief
* Sample a new umbrella reference point given the current coordinate value.
* \param[in] pointStates The state of the bias points.
* \returns true if the histogram is equilibrated.
*/
-bool histogramIsEquilibrated(const std::vector<PointState>& pointStates)
+bool histogramIsEquilibrated(ArrayRef<const PointState> pointStates)
{
/* Get the total weight of the total weight histogram; needed for normalization. */
double totalWeight = 0;
} // namespace
-double HistogramSize::newHistogramSize(const BiasParams& params,
- double t,
- bool covered,
- const std::vector<PointState>& pointStates,
- ArrayRef<double> weightsumCovering,
- FILE* fplog)
+double HistogramSize::newHistogramSize(const BiasParams& params,
+ double t,
+ bool covered,
+ ArrayRef<const PointState> pointStates,
+ ArrayRef<double> weightsumCovering,
+ FILE* fplog)
{
double newHistogramSize;
if (inInitialStage_)
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* \param[in,out] fplog Log file.
* \returns the new histogram size.
*/
- double newHistogramSize(const BiasParams& params,
- double t,
- bool covered,
- const std::vector<PointState>& pointStates,
- ArrayRef<double> weightsumCovering,
- FILE* fplog);
+ double newHistogramSize(const BiasParams& params,
+ double t,
+ bool covered,
+ ArrayRef<const PointState> pointStates,
+ ArrayRef<double> weightsumCovering,
+ FILE* fplog);
/*! \brief Restores the histogram size from history.
*