/*! \brief
* Read parameters of an AWH bias dimension.
*
- * \param[in,out] ninp_p Number of read input file entries.
- * \param[in,out] inp_p Input file entries.
+ * \param[in,out] inp Input file entries.
* \param[in] prefix Prefix for dimension parameters.
* \param[in,out] dimParams AWH dimensional parameters.
* \param[in] pull_params Pull parameters.
* \param[in,out] wi Struct for bookeeping warnings.
* \param[in] bComment True if comments should be printed.
*/
-static void readDimParams(int *ninp_p, t_inpfile **inp_p, const char *prefix,
+static void readDimParams(std::vector<t_inpfile> *inp, const char *prefix,
AwhDimParams *dimParams, const pull_params_t *pull_params,
warninp_t wi, bool bComment)
{
- char warningmsg[STRLEN];
-
- int ninp = *ninp_p;
- t_inpfile *inp = *inp_p;
+ char warningmsg[STRLEN];
if (bComment)
{
- CTYPE("The provider of the reaction coordinate, currently only pull is supported");
+ printStringNoNewline(inp, "The provider of the reaction coordinate, currently only pull is supported");
}
char opt[STRLEN];
sprintf(opt, "%s-coord-provider", prefix);
- EETYPE(opt, dimParams->eCoordProvider, eawhcoordprovider_names);
+ dimParams->eCoordProvider = get_eeenum(inp, opt, eawhcoordprovider_names, wi);
if (bComment)
{
- CTYPE("The coordinate index for this dimension");
+ printStringNoNewline(inp, "The coordinate index for this dimension");
}
sprintf(opt, "%s-coord-index", prefix);
int coordIndexInput;
- ITYPE(opt, coordIndexInput, 1);
+ coordIndexInput = get_eint(inp, opt, 1, wi);
if (coordIndexInput < 1)
{
gmx_fatal(FARGS, "Failed to read a valid coordinate index for %s. "
if (bComment)
{
- CTYPE("Start and end values for each coordinate dimension");
+ printStringNoNewline(inp, "Start and end values for each coordinate dimension");
}
sprintf(opt, "%s-start", prefix);
- RTYPE(opt, dimParams->origin, 0.);
+ dimParams->origin = get_ereal(inp, opt, 0., wi);
sprintf(opt, "%s-end", prefix);
- RTYPE(opt, dimParams->end, 0.);
+ dimParams->end = get_ereal(inp, opt, 0., wi);
if (gmx_within_tol(dimParams->end - dimParams->origin, 0, GMX_REAL_EPS))
{
if (bComment)
{
- CTYPE("The force constant for this coordinate (kJ/mol/nm^2 or kJ/mol/rad^2)");
+ printStringNoNewline(inp, "The force constant for this coordinate (kJ/mol/nm^2 or kJ/mol/rad^2)");
}
sprintf(opt, "%s-force-constant", prefix);
- RTYPE(opt, dimParams->forceConstant, 0);
+ dimParams->forceConstant = get_ereal(inp, opt, 0, wi);
if (dimParams->forceConstant <= 0)
{
warning_error(wi, "The force AWH bias force constant should be > 0");
if (bComment)
{
- CTYPE("Estimated diffusion constant (nm^2/ps or rad^2/ps)");
+ printStringNoNewline(inp, "Estimated diffusion constant (nm^2/ps or rad^2/ps)");
}
sprintf(opt, "%s-diffusion", prefix);
- RTYPE(opt, dimParams->diffusion, 0);
+ dimParams->diffusion = get_ereal(inp, opt, 0, wi);
if (dimParams->diffusion <= 0)
{
if (bComment)
{
- CTYPE("Diameter that needs to be sampled around a point before it is considered covered.");
+ printStringNoNewline(inp, "Diameter that needs to be sampled around a point before it is considered covered.");
}
sprintf(opt, "%s-cover-diameter", prefix);
- RTYPE(opt, dimParams->coverDiameter, 0);
+ dimParams->coverDiameter = get_ereal(inp, opt, 0, wi);
if (dimParams->coverDiameter < 0)
{
gmx_fatal(FARGS, "%s (%g) cannot be negative.",
opt, dimParams->coverDiameter);
}
-
- *ninp_p = ninp;
- *inp_p = inp;
}
/*! \brief
/*! \brief
* Read parameters of an AWH bias.
*
- * \param[in,out] ninp_p Number of read input file entries.
- * \param[in,out] inp_p Input file entries.
+ * \param[in,out] inp Input file entries.
* \param[in,out] awhBiasParams AWH dimensional parameters.
* \param[in] prefix Prefix for bias parameters.
* \param[in] ir Input parameter struct.
* \param[in,out] wi Struct for bookeeping warnings.
* \param[in] bComment True if comments should be printed.
*/
-static void read_bias_params(int *ninp_p, t_inpfile **inp_p, AwhBiasParams *awhBiasParams, const char *prefix,
+static void read_bias_params(std::vector<t_inpfile> *inp, AwhBiasParams *awhBiasParams, const char *prefix,
const t_inputrec *ir, warninp_t wi, bool bComment)
{
- int ninp;
- t_inpfile *inp;
char opt[STRLEN], prefixdim[STRLEN];
char warningmsg[STRLEN];
- /* These are assumed to be declared by the gromacs reading functions */
- ninp = *ninp_p;
- inp = *inp_p;
-
if (bComment)
{
- CTYPE("Estimated initial PMF error (kJ/mol)");
+ printStringNoNewline(inp, "Estimated initial PMF error (kJ/mol)");
}
sprintf(opt, "%s-error-init", prefix);
/* We allow using a default value here without warning (but warn the user if the diffusion constant is not set). */
- RTYPE(opt, awhBiasParams->errorInitial, 10);
+ awhBiasParams->errorInitial = get_ereal(inp, opt, 10, wi);
if (awhBiasParams->errorInitial <= 0)
{
gmx_fatal(FARGS, "%s (%d) needs to be > 0.", opt);
if (bComment)
{
- CTYPE("Growth rate of the reference histogram determining the bias update size: exp-linear or linear");
+ printStringNoNewline(inp, "Growth rate of the reference histogram determining the bias update size: exp-linear or linear");
}
sprintf(opt, "%s-growth", prefix);
- EETYPE(opt, awhBiasParams->eGrowth, eawhgrowth_names);
+ awhBiasParams->eGrowth = get_eeenum(inp, opt, eawhgrowth_names, wi);
if (bComment)
{
- CTYPE("Start the simulation by equilibrating histogram towards the target distribution: no or yes");
+ printStringNoNewline(inp, "Start the simulation by equilibrating histogram towards the target distribution: no or yes");
}
sprintf(opt, "%s-equilibrate-histogram", prefix);
- EETYPE(opt, awhBiasParams->equilibrateHistogram, yesno_names);
+ awhBiasParams->equilibrateHistogram = get_eeenum(inp, opt, yesno_names, wi);
if (awhBiasParams->equilibrateHistogram && awhBiasParams->eGrowth != eawhgrowthEXP_LINEAR)
{
sprintf(warningmsg, "Option %s will only have an effect for histogram growth type '%s'.",
if (bComment)
{
- CTYPE("Target distribution type: constant, cutoff, boltzmann or local-boltzmann");
+ printStringNoNewline(inp, "Target distribution type: constant, cutoff, boltzmann or local-boltzmann");
}
sprintf(opt, "%s-target", prefix);
- EETYPE(opt, awhBiasParams->eTarget, eawhtarget_names);
+ awhBiasParams->eTarget = get_eeenum(inp, opt, eawhtarget_names, wi);
if ((awhBiasParams->eTarget == eawhtargetLOCALBOLTZMANN) &&
(awhBiasParams->eGrowth == eawhgrowthEXP_LINEAR))
if (bComment)
{
- CTYPE("Boltzmann beta scaling factor for target distribution types 'boltzmann' and 'boltzmann-local'");
+ printStringNoNewline(inp, "Boltzmann beta scaling factor for target distribution types 'boltzmann' and 'boltzmann-local'");
}
sprintf(opt, "%s-target-beta-scaling", prefix);
- RTYPE(opt, awhBiasParams->targetBetaScaling, 0);
+ awhBiasParams->targetBetaScaling = get_ereal(inp, opt, 0, wi);
switch (awhBiasParams->eTarget)
{
if (bComment)
{
- CTYPE("Free energy cutoff value for target distribution type 'cutoff'");
+ printStringNoNewline(inp, "Free energy cutoff value for target distribution type 'cutoff'");
}
sprintf(opt, "%s-target-cutoff", prefix);
- RTYPE(opt, awhBiasParams->targetCutoff, 0);
+ awhBiasParams->targetCutoff = get_ereal(inp, opt, 0, wi);
switch (awhBiasParams->eTarget)
{
if (bComment)
{
- CTYPE("Initialize PMF and target with user data: no or yes");
+ printStringNoNewline(inp, "Initialize PMF and target with user data: no or yes");
}
sprintf(opt, "%s-user-data", prefix);
- EETYPE(opt, awhBiasParams->bUserData, yesno_names);
+ awhBiasParams->bUserData = get_eeenum(inp, opt, yesno_names, wi);
if (bComment)
{
- CTYPE("Group index to share the bias with, 0 means not shared");
+ printStringNoNewline(inp, "Group index to share the bias with, 0 means not shared");
}
sprintf(opt, "%s-share-group", prefix);
- ITYPE(opt, awhBiasParams->shareGroup, 0);
+ awhBiasParams->shareGroup = get_eint(inp, opt, 0, wi);
if (awhBiasParams->shareGroup < 0)
{
warning_error(wi, "AWH bias share-group should be >= 0");
if (bComment)
{
- CTYPE("Dimensionality of the coordinate");
+ printStringNoNewline(inp, "Dimensionality of the coordinate");
}
sprintf(opt, "%s-ndim", prefix);
- ITYPE(opt, awhBiasParams->ndim, 0);
+ awhBiasParams->ndim = get_eint(inp, opt, 0, wi);
if (awhBiasParams->ndim <= 0 ||
awhBiasParams->ndim > c_biasMaxNumDim)
{
bComment = bComment && d == 0;
sprintf(prefixdim, "%s-dim%d", prefix, d + 1);
- readDimParams(&ninp, &inp, prefixdim, &awhBiasParams->dimParams[d], ir->pull, wi, bComment);
+ readDimParams(inp, prefixdim, &awhBiasParams->dimParams[d], ir->pull, wi, bComment);
}
/* Check consistencies here that cannot be checked at read time at a lower level. */
checkInputConsistencyAwhBias(*awhBiasParams, wi);
-
- *ninp_p = ninp;
- *inp_p = inp;
}
/*! \brief
}
}
-AwhParams *readAndCheckAwhParams(int *ninp_p, t_inpfile **inp_p, const t_inputrec *ir, warninp_t wi)
+AwhParams *readAndCheckAwhParams(std::vector<t_inpfile> *inp, const t_inputrec *ir, warninp_t wi)
{
char opt[STRLEN], prefix[STRLEN], prefixawh[STRLEN];
AwhParams *awhParams;
snew(awhParams, 1);
- int ninp = *ninp_p;
- t_inpfile *inp = *inp_p;
-
sprintf(prefix, "%s", "awh");
/* Parameters common for all biases */
- CTYPE("The way to apply the biasing potential: convolved or umbrella");
+ printStringNoNewline(inp, "The way to apply the biasing potential: convolved or umbrella");
sprintf(opt, "%s-potential", prefix);
- EETYPE(opt, awhParams->ePotential, eawhpotential_names);
+ awhParams->ePotential = get_eeenum(inp, opt, eawhpotential_names, wi);
- CTYPE("The random seed used for sampling the umbrella center in the case of umbrella type potential");
+ printStringNoNewline(inp, "The random seed used for sampling the umbrella center in the case of umbrella type potential");
sprintf(opt, "%s-seed", prefix);
- ITYPE(opt, awhParams->seed, -1);
+ awhParams->seed = get_eint(inp, opt, -1, wi);
if (awhParams->seed == -1)
{
awhParams->seed = static_cast<int>(gmx::makeRandomSeed());
fprintf(stderr, "Setting the AWH bias MC random seed to %" GMX_PRId64 "\n", awhParams->seed);
}
- CTYPE("Data output interval in number of steps");
+ printStringNoNewline(inp, "Data output interval in number of steps");
sprintf(opt, "%s-nstout", prefix);
- ITYPE(opt, awhParams->nstOut, 100000);
+ awhParams->nstOut = get_eint(inp, opt, 100000, wi);
if (awhParams->nstOut <= 0)
{
char buf[STRLEN];
warning_error(wi, buf);
}
- CTYPE("Coordinate sampling interval in number of steps");
+ printStringNoNewline(inp, "Coordinate sampling interval in number of steps");
sprintf(opt, "%s-nstsample", prefix);
- ITYPE(opt, awhParams->nstSampleCoord, 10);
+ awhParams->nstSampleCoord = get_eint(inp, opt, 10, wi);
- CTYPE("Free energy and bias update interval in number of samples");
+ printStringNoNewline(inp, "Free energy and bias update interval in number of samples");
sprintf(opt, "%s-nsamples-update", prefix);
- ITYPE(opt, awhParams->numSamplesUpdateFreeEnergy, 10);
+ awhParams->numSamplesUpdateFreeEnergy = get_eint(inp, opt, 10, wi);
if (awhParams->numSamplesUpdateFreeEnergy <= 0)
{
char buf[STRLEN];
warning_error(wi, buf);
}
- CTYPE("When true, biases with share-group>0 are shared between multiple simulations");
+ printStringNoNewline(inp, "When true, biases with share-group>0 are shared between multiple simulations");
sprintf(opt, "%s-share-multisim", prefix);
- EETYPE(opt, awhParams->shareBiasMultisim, yesno_names);
+ awhParams->shareBiasMultisim = get_eeenum(inp, opt, yesno_names, wi);
- CTYPE("The number of independent AWH biases");
+ printStringNoNewline(inp, "The number of independent AWH biases");
sprintf(opt, "%s-nbias", prefix);
- ITYPE(opt, awhParams->numBias, 1);
+ awhParams->numBias = get_eint(inp, opt, 1, wi);
if (awhParams->numBias <= 0)
{
gmx_fatal(FARGS, "%s needs to be an integer > 0", opt);
{
bool bComment = (k == 0);
sprintf(prefixawh, "%s%d", prefix, k + 1);
- read_bias_params(&ninp, &inp, &awhParams->awhBiasParams[k], prefixawh, ir, wi, bComment);
+ read_bias_params(inp, &awhParams->awhBiasParams[k], prefixawh, ir, wi, bComment);
}
/* Do a final consistency check before returning */
warning_error(wi, "With AWH init-step should be 0");
}
- *ninp_p = ninp;
- *inp_p = inp;
-
return awhParams;
}
* when read_awhParams is called (in get ir).
* It is known first after do_index has been called in grompp.cpp.
*/
- if (inputrecGroupOptions->ref_t == NULL ||
+ if (inputrecGroupOptions->ref_t == nullptr ||
inputrecGroupOptions->ref_t[0] <= 0)
{
gmx_fatal(FARGS, "AWH biasing is only supported for temperatures > 0");