}
}
-void setCurrentLambdasRerun(int64_t step,
- const t_lambda* fepvals,
- const t_trxframe* rerun_fr,
- const double* lam0,
- t_state* globalState)
-{
- GMX_RELEASE_ASSERT(globalState != nullptr,
- "setCurrentLambdasGlobalRerun should be called with a valid state object");
-
- if (rerun_fr->bLambda)
- {
- if (fepvals->delta_lambda == 0)
- {
- globalState->lambda[efptFEP] = rerun_fr->lambda;
- }
- else
- {
- /* find out between which two value of lambda we should be */
- real frac = step * fepvals->delta_lambda;
- int fep_state = static_cast<int>(std::floor(frac * fepvals->n_lambda));
- /* interpolate between this state and the next */
- /* this assumes that the initial lambda corresponds to lambda==0, which is verified in grompp */
- frac = frac * fepvals->n_lambda - fep_state;
- for (int i = 0; i < efptNR; i++)
- {
- globalState->lambda[i] =
- lam0[i] + (fepvals->all_lambda[i][fep_state])
- + frac * (fepvals->all_lambda[i][fep_state + 1] - fepvals->all_lambda[i][fep_state]);
- }
- }
- }
- else if (rerun_fr->bFepState)
- {
- globalState->fep_state = rerun_fr->fep_state;
- for (int i = 0; i < efptNR; i++)
- {
- globalState->lambda[i] = fepvals->all_lambda[i][globalState->fep_state];
- }
- }
-}
-
-void setCurrentLambdasLocal(const int64_t step,
- const t_lambda* fepvals,
- const double* lam0,
- gmx::ArrayRef<real> lambda,
- const int currentFEPState)
-/* find the current lambdas. If rerunning, we either read in a state, or a lambda value,
- requiring different logic. */
-{
- if (fepvals->delta_lambda != 0)
- {
- /* find out between which two value of lambda we should be */
- real frac = step * fepvals->delta_lambda;
- if (fepvals->n_lambda > 0)
- {
- int fep_state = static_cast<int>(std::floor(frac * fepvals->n_lambda));
- /* interpolate between this state and the next */
- /* this assumes that the initial lambda corresponds to lambda==0, which is verified in grompp */
- frac = frac * fepvals->n_lambda - fep_state;
- for (int i = 0; i < efptNR; i++)
- {
- lambda[i] = lam0[i] + (fepvals->all_lambda[i][fep_state])
- + frac * (fepvals->all_lambda[i][fep_state + 1] - fepvals->all_lambda[i][fep_state]);
- }
- }
- else
- {
- for (int i = 0; i < efptNR; i++)
- {
- lambda[i] = lam0[i] + frac;
- }
- }
- }
- else
- {
- /* if < 0, fep_state was never defined, and we should not set lambda from the state */
- if (currentFEPState > -1)
- {
- for (int i = 0; i < efptNR; i++)
- {
- lambda[i] = fepvals->all_lambda[i][currentFEPState];
- }
- }
- }
-}
-
static void min_zero(int* n, int i)
{
if (i > 0 && (*n == 0 || i < *n))