gmx_bool bPrintEnergy; /* Whether to print the energy in the dhdl */
int n_lambda; /* The number of foreign lambda points */
double **all_lambda; /* The array of all lambda values */
+ int lambda_neighbors; /* The number of neighboring lambda states to
+ calculate the energy for in up and down directions
+ (-1 for all) */
+ int lambda_start_n; /* The first lambda to calculate energies for */
+ int lambda_stop_n; /* The last lambda +1 to calculate energies for */
real sc_alpha; /* free energy soft-core parameter */
int sc_power; /* lambda power for soft-core interactions */
real sc_r_power; /* r power for soft-core interactions */
be determined and written to dhdl.xvg every <b>nstdhdl</b> steps. Values must be between 0 and 1.
Only the temperatures controlled with this component of the lambda vector.
Note that these lambdas should not be used for replica exchange, only for simulated tempering.</dd>
+<dt><b>calc-lambda-neighbors (1)</b></dt>
+<dd>Controls the number of lambda values for which Delta H values will be
+calculated and written out, if <b>init-lambda-state</b> has been set. A
+positive value will limit the number of lambda points calculated to only the
+nth neighbors of <b>init-lambda-state</b>: for example, if
+<b>init-lambda-state</b> is 5 and this parameter has a value of 2, energies for
+lambda points 3-7 will be calculated and writen out. A value of -1 means all
+lambda points will be written out. For normal BAR such as with g_bar, a value
+of 1 is sufficient, while for MBAR -1 should be used.</dd>
<dt><b>sc-alpha: (0)</b></dt>
<dd>the soft-core alpha parameter, a value of 0 results in linear interpolation of the LJ and Coulomb interactions</dd>
<dt><b>sc-r-power: (6)</b></dt>
static const char *tpx_tag = TPX_TAG_RELEASE;
/* This number should be increased whenever the file format changes! */
-static const int tpx_version = 82;
+static const int tpx_version = 83;
/* This number should only be increased when you edit the TOPOLOGY section
* or the HEADER of the tpx format.
}
}
-static void do_expandedvals(t_fileio *fio,t_expanded *expand,int n_lambda, gmx_bool bRead, int file_version)
+static void do_expandedvals(t_fileio *fio,t_expanded *expand,t_lambda *fepvals, gmx_bool bRead, int file_version)
{
/* i is used in the ndo_double macro*/
int i;
real fv;
gmx_bool bDum=TRUE;
real rdum;
+ int n_lambda=fepvals->n_lambda;
+ /* reset the lambda calculation window */
+ fepvals->lambda_start_n = 0;
+ fepvals->lambda_stop_n = n_lambda;
if (file_version >= 79)
{
if (n_lambda>0)
real rdum;
/* free energy values */
+
if (file_version >= 79)
{
gmx_fio_do_int(fio,fepvals->init_fep_state);
{
fepvals->bPrintEnergy = FALSE;
}
+
+ /* handle lambda_neighbors */
+ if (file_version >= 83)
+ {
+ gmx_fio_do_int(fio,fepvals->lambda_neighbors);
+ if ( (fepvals->lambda_neighbors >= 0) && (fepvals->init_fep_state>=0) &&
+ (fepvals->init_lambda < 0) )
+ {
+ fepvals->lambda_start_n = (fepvals->init_fep_state -
+ fepvals->lambda_neighbors);
+ fepvals->lambda_stop_n = (fepvals->init_fep_state +
+ fepvals->lambda_neighbors + 1);
+ if (fepvals->lambda_start_n < 0)
+ {
+ fepvals->lambda_start_n = 0;;
+ }
+ if (fepvals->lambda_stop_n >= fepvals->n_lambda)
+ {
+ fepvals->lambda_stop_n = fepvals->n_lambda;
+ }
+ }
+ else
+ {
+ fepvals->lambda_start_n = 0;
+ fepvals->lambda_stop_n = fepvals->n_lambda;
+ }
+ }
+ else
+ {
+ fepvals->lambda_start_n = 0;
+ fepvals->lambda_stop_n = fepvals->n_lambda;
+ }
}
static void do_pull(t_fileio *fio, t_pull *pull,gmx_bool bRead, int file_version)
}
if (ir->bExpanded)
{
- do_expandedvals(fio,ir->expandedvals,ir->fepvals->n_lambda,bRead,file_version);
+ do_expandedvals(fio,ir->expandedvals,ir->fepvals,bRead,file_version);
}
if (file_version >= 57) {
gmx_fio_do_int(fio,ir->eDisre);
fprintf(fp,"\n");
}
}
+ PI("calc-lambda-neighbors",fep->lambda_neighbors);
PR("sc-alpha",fep->sc_alpha);
PS("bScCoul",EBOOL(fep->bScCoul));
STYPE ("bonded-lambdas", fep_lambda[efptBONDED], NULL);
STYPE ("restraint-lambdas", fep_lambda[efptRESTRAINT], NULL);
STYPE ("temperature-lambdas", fep_lambda[efptTEMPERATURE], NULL);
+ ITYPE ("calc-lambda-neighbors",fep->lambda_neighbors, 1);
STYPE ("init-lambda-weights",lambda_weights,NULL);
EETYPE("dhdl-print-energy", fep->bPrintEnergy, yesno_names);
RTYPE ("sc-alpha",fep->sc_alpha,0.0);
cmp_double(fp,"inputrec->fepvals->all_lambda",-1,fep1->all_lambda[i][j],fep2->all_lambda[i][j],ftol,abstol);
}
}
+ cmp_int(fp,"inputrec->fepvals->lambda_neighbors",1,fep1->lambda_neighbors,
+ fep2->lambda_neighbors);
cmp_real(fp,"inputrec->fepvals->sc_alpha",-1,fep1->sc_alpha,fep2->sc_alpha,ftol,abstol);
cmp_int(fp,"inputrec->fepvals->sc_power",-1,fep1->sc_power,fep2->sc_power);
cmp_real(fp,"inputrec->fepvals->sc_r_power",-1,fep1->sc_r_power,fep2->sc_r_power,ftol,abstol);
nsets_dhdl = n_lambda_terms;
}
/* count the number of delta_g states */
- nsets_de = fep->n_lambda;
+ nsets_de = fep->lambda_stop_n - fep->lambda_start_n;
nsets = nsets_dhdl + nsets_de; /* dhdl + fep differences */
}
nsetsbegin += nsets_dhdl;
- for(i=0; i<fep->n_lambda; i++)
+ for(i=fep->lambda_start_n; i<fep->lambda_stop_n; i++)
{
print_lambda_vector(fep, i, FALSE, FALSE, lambda_vec_str);
if ( (fep->init_lambda >= 0) && (n_lambda_terms == 1 ))
}
}
}
- for(i=0;i<fep->n_lambda;i++)
+ for(i=fep->lambda_start_n;i<fep->lambda_stop_n;i++)
{
fprintf(md->fp_dhdl," %#.8g",md->dE[i]);
}
store_energy,
pv,
store_dhdl,
- md->dE,
+ md->dE + fep->lambda_start_n,
time);
}
}
}
}
/* add the lambdas */
- dhc->nlambda = ir->fepvals->n_lambda;
+ dhc->nlambda = ir->fepvals->lambda_stop_n - ir->fepvals->lambda_start_n;
dhc->ndh += dhc->nlambda;
/* another compatibility check */
if (dhc->start_lambda < 0)
/* add the lambdas */
dhc->dh_du = dhc->dh + n;
snew(lambda_vec, n_lambda_components);
- for(i=0;i<ir->fepvals->n_lambda;i++)
+ for(i=ir->fepvals->lambda_start_n;i<ir->fepvals->lambda_stop_n;i++)
{
int k=0;