Ejemplo n.º 1
0
/* initialize the collection*/
void mde_delta_h_coll_init(t_mde_delta_h_coll *dhc, const t_inputrec *ir)
{
    int i;
    double lambda;
    int ndhmax=ir->nstenergy/ir->nstcalcenergy;

    dhc->temperature=ir->opts.ref_t[0];  /* only store system temperature */
    dhc->start_time=0.;
    dhc->delta_time=ir->delta_t*ir->fepvals->nstdhdl;
    dhc->start_time_set=FALSE;

    /* for continuous change of lambda values */
    dhc->start_lambda=ir->fepvals->init_lambda;
    dhc->delta_lambda=ir->fepvals->delta_lambda*ir->fepvals->nstdhdl;

    /* total number of raw data points in the sample */
    dhc->ndh = 0;

    /* include one more for the specification of the state, by lambda or fep_state, store as double for now*/
    if (ir->expandedvals->elamstats > elamstatsNO) {
        dhc->ndh +=1;
    }

    /* whether to print energies */
    if (ir->fepvals->bPrintEnergy) {
        dhc->ndh += 1;
    }

    /* add the dhdl's */
    for (i=0;i<efptNR;i++)
    {
        if (ir->fepvals->separate_dvdl[i])
        {
            dhc->ndh+=1;
        }
    }

    /* add the lambdas */
    dhc->ndh += ir->fepvals->n_lambda;

    if (ir->epc > epcNO) {
        dhc->ndh += 1;  /* include pressure-volume work */
    }

    snew(dhc->dh, dhc->ndh);
    for(i=0;i<dhc->ndh;i++)
    {
        mde_delta_h_init(dhc->dh+i, ir->fepvals->dh_hist_size,
                         ir->fepvals->dh_hist_spacing, ndhmax);
    }
}
Ejemplo n.º 2
0
/* initialize the collection*/
void mde_delta_h_coll_init(t_mde_delta_h_coll *dhc, const t_inputrec *ir)
{
    int       i, j, n;
    double    lambda;
    double   *lambda_vec;
    int       ndhmax = ir->nstenergy/ir->nstcalcenergy;
    t_lambda *fep    = ir->fepvals;

    dhc->temperature    = ir->opts.ref_t[0]; /* only store system temperature */
    dhc->start_time     = 0.;
    dhc->delta_time     = ir->delta_t*ir->fepvals->nstdhdl;
    dhc->start_time_set = FALSE;

    /* this is the compatibility lambda value. If it is >=0, it is valid,
       and there is either an old-style lambda or a slow growth simulation. */
    dhc->start_lambda = ir->fepvals->init_lambda;
    /* for continuous change of lambda values */
    dhc->delta_lambda = ir->fepvals->delta_lambda*ir->fepvals->nstdhdl;

    if (dhc->start_lambda < 0)
    {
        /* create the native lambda vectors */
        dhc->lambda_index = fep->init_fep_state;
        dhc->n_lambda_vec = 0;
        for (i = 0; i < efptNR; i++)
        {
            if (fep->separate_dvdl[i])
            {
                dhc->n_lambda_vec++;
            }
        }
        snew(dhc->native_lambda_vec, dhc->n_lambda_vec);
        snew(dhc->native_lambda_components, dhc->n_lambda_vec);
        j = 0;
        for (i = 0; i < efptNR; i++)
        {
            if (fep->separate_dvdl[i])
            {
                dhc->native_lambda_components[j] = i;
                if (fep->init_fep_state >= 0 &&
                    fep->init_fep_state < fep->n_lambda)
                {
                    dhc->native_lambda_vec[j] =
                        fep->all_lambda[i][fep->init_fep_state];
                }
                else
                {
                    dhc->native_lambda_vec[j] = -1;
                }
                j++;
            }
        }
    }
    else
    {
        /* don't allocate the meta-data subblocks for lambda vectors */
        dhc->native_lambda_vec        = NULL;
        dhc->n_lambda_vec             = 0;
        dhc->native_lambda_components = 0;
        dhc->lambda_index             = -1;
    }
    /* allocate metadata subblocks */
    snew(dhc->subblock_d, 5 + dhc->n_lambda_vec);
    snew(dhc->subblock_i, 1 + dhc->n_lambda_vec);

    /* now decide which data to write out */
    dhc->nlambda     = 0;
    dhc->ndhdl       = 0;
    dhc->dh_expanded = NULL;
    dhc->dh_energy   = NULL;
    dhc->dh_pv       = NULL;

    /* total number of raw data point collections in the sample */
    dhc->ndh = 0;

    {
        gmx_bool bExpanded           = FALSE;
        gmx_bool bEnergy             = FALSE;
        gmx_bool bPV                 = FALSE;
        int      n_lambda_components = 0;

        /* first count the number of states */

        /* add the dhdl's */
        if (fep->dhdl_derivatives == edhdlderivativesYES)
        {
            for (i = 0; i < efptNR; i++)
            {
                if (ir->fepvals->separate_dvdl[i])
                {
                    dhc->ndh   += 1;
                    dhc->ndhdl += 1;
                }
            }
        }
        /* add the lambdas */
        dhc->nlambda = ir->fepvals->lambda_stop_n - ir->fepvals->lambda_start_n;
        dhc->ndh    += dhc->nlambda;
        /* another compatibility check */
        if (dhc->start_lambda < 0)
        {
            /* include one more for the specification of the state, by lambda or
               fep_state*/
            if (ir->expandedvals->elmcmove > elmcmoveNO)
            {
                dhc->ndh += 1;
                bExpanded = TRUE;
            }
            /* whether to print energies */
            if (ir->fepvals->bPrintEnergy)
            {
                dhc->ndh += 1;
                bEnergy   = TRUE;
            }
            if (ir->epc > epcNO)
            {
                dhc->ndh += 1;  /* include pressure-volume work */
                bPV       = TRUE;
            }
        }
        /* allocate them */
        snew(dhc->dh, dhc->ndh);

        /* now initialize them */
        /* the order, for now, must match that of the dhdl.xvg file because of
           how g_energy -odh is implemented */
        n = 0;
        if (bExpanded)
        {
            dhc->dh_expanded = dhc->dh+n;
            mde_delta_h_init(dhc->dh+n, ir->fepvals->dh_hist_size,
                             ir->fepvals->dh_hist_spacing, ndhmax,
                             dhbtEXPANDED, 0, 0, NULL);
            n++;
        }
        if (bEnergy)
        {
            dhc->dh_energy = dhc->dh+n;
            mde_delta_h_init(dhc->dh+n, ir->fepvals->dh_hist_size,
                             ir->fepvals->dh_hist_spacing, ndhmax,
                             dhbtEN, 0, 0, NULL);
            n++;
        }
        /* add the dhdl's */
        n_lambda_components = 0;
        if (fep->dhdl_derivatives == edhdlderivativesYES)
        {
            dhc->dh_dhdl = dhc->dh + n;
            for (i = 0; i < efptNR; i++)
            {
                if (ir->fepvals->separate_dvdl[i])
                {
                    /* we give it init_lambda for compatibility */
                    mde_delta_h_init(dhc->dh+n, ir->fepvals->dh_hist_size,
                                     ir->fepvals->dh_hist_spacing, ndhmax,
                                     dhbtDHDL, n_lambda_components, 1,
                                     &(fep->init_lambda));
                    n++;
                    n_lambda_components++;
                }
            }
        }
        else
        {
            for (i = 0; i < efptNR; i++)
            {
                if (ir->fepvals->separate_dvdl[i])
                {
                    n_lambda_components++; /* count the components */
                }
            }

        }
        /* add the lambdas */
        dhc->dh_du = dhc->dh + n;
        snew(lambda_vec, n_lambda_components);
        for (i = ir->fepvals->lambda_start_n; i < ir->fepvals->lambda_stop_n; i++)
        {
            int k = 0;

            for (j = 0; j < efptNR; j++)
            {
                if (ir->fepvals->separate_dvdl[j])
                {
                    lambda_vec[k++] = fep->all_lambda[j][i];
                }
            }

            mde_delta_h_init(dhc->dh+n, ir->fepvals->dh_hist_size,
                             ir->fepvals->dh_hist_spacing, ndhmax,
                             dhbtDH, 0, n_lambda_components, lambda_vec);
            n++;
        }
        sfree(lambda_vec);
        if (bPV)
        {
            dhc->dh_pv = dhc->dh+n;
            mde_delta_h_init(dhc->dh+n, ir->fepvals->dh_hist_size,
                             ir->fepvals->dh_hist_spacing, ndhmax,
                             dhbtPV, 0, 0, NULL);
            n++;
        }
    }
}