}
}
-void sum_dhdl(gmx_enerdata_t *enerd, gmx::ArrayRef<const real> lambda, t_lambda *fepvals)
+void sum_dhdl(gmx_enerdata_t *enerd, gmx::ArrayRef<const real> lambda, const t_lambda &fepvals)
{
int index;
enerd->term[F_DVDL] = 0.0;
for (int i = 0; i < efptNR; i++)
{
- if (fepvals->separate_dvdl[i])
+ if (fepvals.separate_dvdl[i])
{
/* could this be done more readably/compactly? */
switch (i)
}
}
- if (fepvals->separate_dvdl[efptBONDED])
+ if (fepvals.separate_dvdl[efptBONDED])
{
enerd->term[F_DVDL_BONDED] += enerd->term[F_DVDL_CONSTR];
}
enerd->term[F_DVDL] += enerd->term[F_DVDL_CONSTR];
}
- for (int i = 0; i < fepvals->n_lambda; i++)
+ for (int i = 0; i < fepvals.n_lambda; i++)
{
/* note we are iterating over fepvals here!
For the current lam, dlam = 0 automatically,
for (gmx::index j = 0; j < lambda.ssize(); j++)
{
/* Note that this loop is over all dhdl components, not just the separated ones */
- const double dlam = fepvals->all_lambda[j][i] - lambda[j];
+ const double dlam = fepvals.all_lambda[j][i] - lambda[j];
enerpart_lambda += dlam*enerd->dvdl_lin[j];
* a linear extrapolation. This is an approximation, but usually
* quite accurate since constraints change little between lambdas.
*/
- if ((j == efptBONDED && fepvals->separate_dvdl[efptBONDED]) ||
- (j == efptFEP && !fepvals->separate_dvdl[efptBONDED]))
+ if ((j == efptBONDED && fepvals.separate_dvdl[efptBONDED]) ||
+ (j == efptFEP && !fepvals.separate_dvdl[efptBONDED]))
{
enerpart_lambda += dlam*enerd->term[F_DVDL_CONSTR];
}
- if (j == efptMASS && !fepvals->separate_dvdl[j])
+ if (j == efptMASS && !fepvals.separate_dvdl[j])
{
enerpart_lambda += dlam*enerd->term[F_DKDL];
}
if (debug)
{
fprintf(debug, "enerdiff lam %g: (%15s), non-linear %f linear %f*%f\n",
- fepvals->all_lambda[j][i], efpt_names[j],
+ fepvals.all_lambda[j][i], efpt_names[j],
enerpart_lambda - enerd->enerpart_lambda[0],
dlam, enerd->dvdl_lin[j]);
}
void sum_epot(gmx_grppairener_t *grpp, real *epot);
/* Locally sum the non-bonded potential energy terms */
-void sum_dhdl(gmx_enerdata_t *enerd, gmx::ArrayRef<const real> lambda, t_lambda *fepvals);
+void sum_dhdl(gmx_enerdata_t *enerd, gmx::ArrayRef<const real> lambda, const t_lambda &fepvals);
/* Sum the free energy contributions */
#endif
}
}
-void setCurrentLambdasLocal(int64_t step, const t_lambda *fepvals,
- const double *lam0, t_state *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. */
{
frac = frac*fepvals->n_lambda - fep_state;
for (int i = 0; i < efptNR; i++)
{
- state->lambda[i] = lam0[i] + (fepvals->all_lambda[i][fep_state]) +
+ lambda[i] = lam0[i] + (fepvals->all_lambda[i][fep_state]) +
frac*(fepvals->all_lambda[i][fep_state + 1] - fepvals->all_lambda[i][fep_state]);
}
}
{
for (int i = 0; i < efptNR; i++)
{
- state->lambda[i] = lam0[i] + frac;
+ lambda[i] = lam0[i] + frac;
}
}
}
else
{
/* if < 0, fep_state was never defined, and we should not set lambda from the state */
- if (state->fep_state > -1)
+ if (currentFEPState > -1)
{
for (int i = 0; i < efptNR; i++)
{
- state->lambda[i] = fepvals->all_lambda[i][state->fep_state];
+ lambda[i] = fepvals->all_lambda[i][currentFEPState];
}
}
}
namespace gmx
{
+template <typename T> class ArrayRef;
class Constraints;
class MDLogger;
class SimulationSignaller;
/* Set the lambda values at each step of mdrun when they change */
void setCurrentLambdasLocal(int64_t step, const t_lambda *fepvals,
- const double *lam0, t_state *state);
+ const double *lam0, gmx::ArrayRef<real> lambda,
+ int currentFEPState);
int multisim_min(const gmx_multisim_t *ms, int nmin, int n);
/* Set an appropriate value for n across the whole multi-simulation */
if (ir->efep != efepNO || ir->bSimTemp)
{
/* find and set the current lambdas */
- setCurrentLambdasLocal(step, ir->fepvals, lam0, state);
+ setCurrentLambdasLocal(step, ir->fepvals, lam0, state->lambda, state->fep_state);
bDoDHDL = do_per_step(step, ir->fepvals->nstdhdl);
bDoFEP = ((ir->efep != efepNO) && do_per_step(step, nstfep));
/* sum up the foreign energy and dhdl terms for vv. currently done every step so that dhdl is correct in the .edr */
if (ir->efep != efepNO)
{
- sum_dhdl(enerd, state->lambda, ir->fepvals);
+ sum_dhdl(enerd, state->lambda, *ir->fepvals);
}
}
{
/* Sum up the foreign energy and dhdl terms for md and sd.
Currently done every step so that dhdl is correct in the .edr */
- sum_dhdl(enerd, state->lambda, ir->fepvals);
+ sum_dhdl(enerd, state->lambda, *ir->fepvals);
}
update_pcouple_after_coordinates(fplog, step, ir, mdatoms,
if (ir->efep != efepNO)
{
- setCurrentLambdasLocal(step, ir->fepvals, lam0, state);
+ setCurrentLambdasLocal(step, ir->fepvals, lam0, state->lambda, state->fep_state);
}
if (MASTER(cr))
{
/* Sum up the foreign energy and dhdl terms for md and sd.
Currently done every step so that dhdl is correct in the .edr */
- sum_dhdl(enerd, state->lambda, ir->fepvals);
+ sum_dhdl(enerd, state->lambda, *ir->fepvals);
}
/* Output stuff */
enerd->term[F_PRES] =
calc_pres(fr->ePBC, inputrec->nwall, ems->s.box, ekin, vir, pres);
- sum_dhdl(enerd, ems->s.lambda, inputrec->fepvals);
+ sum_dhdl(enerd, ems->s.lambda, *inputrec->fepvals);
if (EI_ENERGY_MINIMIZATION(inputrec->eI))
{
{
/* Sum up the foreign energy and dhdl terms for md and sd.
Currently done every step so that dhdl is correct in the .edr */
- sum_dhdl(enerd, state->lambda, ir->fepvals);
+ sum_dhdl(enerd, state->lambda, *ir->fepvals);
}
/* Output stuff */