Example #1
0
static void sum_ft(t_remd_data *d)
{
    int    i, j;
    double fac;

    for (j = 0; (j < d->nframe); j++)
    {
        d->sumft[j] = 0;
        d->sumit[j] = 0;
        if ((j == 0) || (j == d->nframe-1))
        {
            fac = d->dt*0.5;
        }
        else
        {
            fac = d->dt;
        }
        for (i = 0; (i < d->nreplica); i++)
        {
            if (d->bMask[i])
            {
                if (d->bDiscrete)
                {
                    d->sumft[j] += fac*is_folded(d, i, j);
                    d->sumit[j] += fac*is_intermediate(d, i, j);
                }
                else
                {
                    d->sumft[j] += fac*d->state[i][j];
                }
            }
        }
    }
}
Example #2
0
void ttree_view_node::clear()
{
	/** @todo Also try to find the optimal width. */
	int height_reduction = 0;

	if(!is_folded()) {
		FOREACH(const AUTO& node, children_) {
			height_reduction += node.get_current_size().y;
		}
	}
void ttree_view_node::clear()
{
	/** @todo Also try to find the optimal width. */
	unsigned height_reduction = 0;

	if(!is_folded()) {
		foreach(const ttree_view_node& node, children_) {
			height_reduction += node.get_current_size().y;
		}
	}
Example #4
0
static double calc_d2(t_remd_data *d)
{
    int    i, j;
    double dd2, d2 = 0, dr2, tmp;

    integrate_dfdt(d);

    if (d->bSum)
    {
        for (j = d->j0; (j < d->j1); j++)
        {
            if (d->bDiscrete)
            {
                d2  += sqr(d->sumft[j]-d->sumfct[j]);
                if (d->nstate > 2)
                {
                    d2 += sqr(d->sumit[j]-d->sumict[j]);
                }
            }
            else
            {
                d2  += sqr(d->sumft[j]-d->sumfct[j]);
            }
        }
    }
    else
    {
        for (i = 0; (i < d->nreplica); i++)
        {
            dr2 = 0;
            if (d->bMask[i])
            {
                for (j = d->j0; (j < d->j1); j++)
                {
                    tmp  = sqr(is_folded(d, i, j)-d->fcalt[i][j]);
                    d2  += tmp;
                    dr2 += tmp;
                    if (d->nstate > 2)
                    {
                        tmp  = sqr(is_intermediate(d, i, j)-d->icalt[i][j]);
                        d2  += tmp;
                        dr2 += tmp;
                    }
                }
                d->d2_replica[i] = dr2/(d->j1-d->j0);
            }
        }
    }
    dd2 = (d2/(d->j1-d->j0))/(d->bDiscrete ? d->nmask : 1);

    return dd2;
}
Example #5
0
ttree_view_node& ttree_view_node::add_child(
		  const std::string& id
		, const std::map<std::string /* widget id */, string_map>& data
		, const int index)
{

	boost::ptr_vector<ttree_view_node>::iterator itor = children_.end();

	if(static_cast<size_t>(index) < children_.size()) {
		itor = children_.begin() + index;
	}

	itor = children_.insert(itor, new ttree_view_node(
			  id
			, node_definitions_
			, this
			, tree_view()
			, data));

	if(is_folded() || is_root_node()) {
		return *itor;
	}

	if(tree_view().get_size() == tpoint(0, 0)) {
		return *itor;
	}

	assert(tree_view().content_grid());
	const int current_width = tree_view().content_grid()->get_width();

	// Calculate width modification.
	tpoint best_size = itor->get_best_size();
	best_size.x += get_indention_level() * tree_view().indention_step_size_;
	const unsigned width_modification = best_size.x > current_width
			? best_size.x - current_width
			: 0;

	// Calculate height modification.
	const int height_modification = best_size.y;
	assert(height_modification > 0);

	// Request new size.
	tree_view().resize_content(width_modification, height_modification);

	return *itor;
}
Example #6
0
static void dump_remd_parameters(FILE *gp, t_remd_data *d, const char *fn,
                                 const char *fn2, const char *rfn,
                                 const char *efn, const char *mfn, int skip, real tref,
                                 output_env_t oenv)
{
    FILE       *fp, *hp;
    int         i, j, np = d->nparams;
    real        rhs, tauf, taub, fff, DG;
    real       *params;
    const char *leg[]  = { "Measured", "Fit", "Difference" };
    const char *mleg[] = { "Folded fraction", "DG (kJ/mole)"};
    char      **rleg;
    real        fac[] = { 0.97, 0.98, 0.99, 1.0, 1.01, 1.02, 1.03 };
#define NFAC asize(fac)
    real        d2[NFAC];
    double      norm;

    integrate_dfdt(d);
    print_tau(gp, d, tref);
    norm = (d->bDiscrete ? 1.0/d->nmask : 1.0);

    if (fn)
    {
        fp = xvgropen(fn, "Optimized fit to data", "Time (ps)", "Fraction Folded", oenv);
        xvgr_legend(fp, asize(leg), leg, oenv);
        for (i = 0; (i < d->nframe); i++)
        {
            if ((skip <= 0) || ((i % skip) == 0))
            {
                fprintf(fp, "%12.5e  %12.5e  %12.5e  %12.5e\n", d->time[i],
                        d->sumft[i]*norm, d->sumfct[i]*norm,
                        (d->sumft[i]-d->sumfct[i])*norm);
            }
        }
        ffclose(fp);
    }
    if (!d->bSum && rfn)
    {
        snew(rleg, d->nreplica*2);
        for (i = 0; (i < d->nreplica); i++)
        {
            snew(rleg[2*i], 32);
            snew(rleg[2*i+1], 32);
            sprintf(rleg[2*i], "\\f{4}F(t) %d", i);
            sprintf(rleg[2*i+1], "\\f{12}F \\f{4}(t) %d", i);
        }
        fp = xvgropen(rfn, "Optimized fit to data", "Time (ps)", "Fraction Folded", oenv);
        xvgr_legend(fp, d->nreplica*2, (const char**)rleg, oenv);
        for (j = 0; (j < d->nframe); j++)
        {
            if ((skip <= 0) || ((j % skip) == 0))
            {
                fprintf(fp, "%12.5e", d->time[j]);
                for (i = 0; (i < d->nreplica); i++)
                {
                    fprintf(fp, "  %5f  %9.2e", is_folded(d, i, j), d->fcalt[i][j]);
                }
                fprintf(fp, "\n");
            }
        }
        ffclose(fp);
    }

    if (fn2 && (d->nstate > 2))
    {
        fp = xvgropen(fn2, "Optimized fit to data", "Time (ps)",
                      "Fraction Intermediate", oenv);
        xvgr_legend(fp, asize(leg), leg, oenv);
        for (i = 0; (i < d->nframe); i++)
        {
            if ((skip <= 0) || ((i % skip) == 0))
            {
                fprintf(fp, "%12.5e  %12.5e  %12.5e  %12.5e\n", d->time[i],
                        d->sumit[i]*norm, d->sumict[i]*norm,
                        (d->sumit[i]-d->sumict[i])*norm);
            }
        }
        ffclose(fp);
    }
    if (mfn)
    {
        if (bBack(d))
        {
            fp = xvgropen(mfn, "Melting curve", "T (K)", "", oenv);
            xvgr_legend(fp, asize(mleg), mleg, oenv);
            for (i = 260; (i <= 420); i++)
            {
                tauf = tau(d->params[epAuf], d->params[epEuf], 1.0*i);
                taub = tau(d->params[epAfu], d->params[epEfu], 1.0*i);
                fff  = taub/(tauf+taub);
                DG   = BOLTZ*i*log(fff/(1-fff));
                fprintf(fp, "%5d  %8.3f  %8.3f\n", i, fff, DG);
            }
            ffclose(fp);
        }
    }

    if (efn)
    {
        snew(params, d->nparams);
        for (i = 0; (i < d->nparams); i++)
        {
            params[i] = d->params[i];
        }

        hp = xvgropen(efn, "Chi2 as a function of relative parameter",
                      "Fraction", "Chi2", oenv);
        for (j = 0; (j < d->nparams); j++)
        {
            /* Reset all parameters to optimized values */
            fprintf(hp, "@type xy\n");
            for (i = 0; (i < d->nparams); i++)
            {
                d->params[i] = params[i];
            }
            /* Now modify one of them */
            for (i = 0; (i < NFAC); i++)
            {
                d->params[j] = fac[i]*params[j];
                d2[i]        = calc_d2(d);
                fprintf(gp, "%s = %12g  d2 = %12g\n", epnm(np, j), d->params[j], d2[i]);
                fprintf(hp, "%12g  %12g\n", fac[i], d2[i]);
            }
            fprintf(hp, "&\n");
        }
        ffclose(hp);
        for (i = 0; (i < d->nparams); i++)
        {
            d->params[i] = params[i];
        }
        sfree(params);
    }
    if (!d->bSum)
    {
        for (i = 0; (i < d->nreplica); i++)
        {
            fprintf(gp, "Chi2[%3d] = %8.2e\n", i, d->d2_replica[i]);
        }
    }
}
Example #7
0
static void integrate_dfdt(t_remd_data *d)
{
    int    i, j;
    double beta, ddf, ddi, df, db, fac, sumf, sumi, area;

    d->sumfct[0] = 0;
    d->sumict[0] = 0;
    for (i = 0; (i < d->nreplica); i++)
    {
        if (d->bMask[i])
        {
            if (d->bDiscrete)
            {
                ddf = 0.5*d->dt*is_folded(d, i, 0);
                ddi = 0.5*d->dt*is_intermediate(d, i, 0);
            }
            else
            {
                ddf = 0.5*d->dt*d->state[i][0];
                ddi = 0.0;
            }
            d->fcalt[i][0] = ddf;
            d->icalt[i][0] = ddi;
            d->sumfct[0]  += ddf;
            d->sumict[0]  += ddi;
        }
    }
    for (j = 1; (j < d->nframe); j++)
    {
        if (j == d->nframe-1)
        {
            fac = 0.5*d->dt;
        }
        else
        {
            fac = d->dt;
        }
        sumf = sumi = 0;
        for (i = 0; (i < d->nreplica); i++)
        {
            if (d->bMask[i])
            {
                beta = d->beta[i][j];
                if ((d->nstate <= 2) || d->bDiscrete)
                {
                    if (d->bDiscrete)
                    {
                        df = (d->params[epAuf]*exp(-beta*d->params[epEuf])*
                              is_unfolded(d, i, j));
                    }
                    else
                    {
                        area = (d->data2 ? d->data2[i][j] : 1.0);
                        df   =  area*d->params[epAuf]*exp(-beta*d->params[epEuf]);
                    }
                    if (bBack(d))
                    {
                        db = 0;
                        if (d->bDiscrete)
                        {
                            db = (d->params[epAfu]*exp(-beta*d->params[epEfu])*
                                  is_folded(d, i, j));
                        }
                        else
                        {
                            gmx_fatal(FARGS, "Back reaction not implemented with continuous");
                        }
                        ddf = fac*(df-db);
                    }
                    else
                    {
                        ddf = fac*df;
                    }
                    d->fcalt[i][j] = d->fcalt[i][j-1] + ddf;
                    sumf          += ddf;
                }
                else
                {
                    ddf = fac*((d->params[eqAif]*exp(-beta*d->params[eqEif])*
                                is_intermediate(d, i, j)) -
                               (d->params[eqAfi]*exp(-beta*d->params[eqEfi])*
                                is_folded(d, i, j)));
                    ddi = fac*((d->params[eqAui]*exp(-beta*d->params[eqEui])*
                                is_unfolded(d, i, j)) -
                               (d->params[eqAiu]*exp(-beta*d->params[eqEiu])*
                                is_intermediate(d, i, j)));
                    d->fcalt[i][j] = d->fcalt[i][j-1] + ddf;
                    d->icalt[i][j] = d->icalt[i][j-1] + ddi;
                    sumf          += ddf;
                    sumi          += ddi;
                }
            }
        }
        d->sumfct[j] = d->sumfct[j-1] + sumf;
        d->sumict[j] = d->sumict[j-1] + sumi;
    }
    if (debug)
    {
        fprintf(debug, "@type xy\n");
        for (j = 0; (j < d->nframe); j++)
        {
            fprintf(debug, "%8.3f  %12.5e\n", d->time[j], d->sumfct[j]);
        }
        fprintf(debug, "&\n");
    }
}
void FoldablePanelWidget::slot_fold_unfold()
{
    set_folded(!is_folded());
}