FILE *xvgropen_type(const char *fn, const char *title, const char *xaxis, const char *yaxis, int exvg_graph_type, const gmx_output_env_t *oenv) { FILE *fp; fp = gmx_fio_fopen(fn, "w"); xvgr_header(fp, title, xaxis, yaxis, exvg_graph_type, oenv); return fp; }
extern FILE *open_dhdl(const char *filename, const t_inputrec *ir, const gmx_output_env_t *oenv) { FILE *fp; const char *dhdl = "dH/d\\lambda", *deltag = "\\DeltaH", *lambda = "\\lambda", *lambdastate = "\\lambda state"; char title[STRLEN], label_x[STRLEN], label_y[STRLEN]; int i, nps, nsets, nsets_de, nsetsbegin; int n_lambda_terms = 0; t_lambda *fep = ir->fepvals; /* for simplicity */ t_expanded *expand = ir->expandedvals; char **setname; char buf[STRLEN], lambda_vec_str[STRLEN], lambda_name_str[STRLEN]; int bufplace = 0; int nsets_dhdl = 0; int s = 0; int nsetsextend; gmx_bool write_pV = FALSE; /* count the number of different lambda terms */ for (i = 0; i < efptNR; i++) { if (fep->separate_dvdl[i]) { n_lambda_terms++; } } if (fep->n_lambda == 0) { sprintf(title, "%s", dhdl); sprintf(label_x, "Time (ps)"); sprintf(label_y, "%s (%s %s)", dhdl, unit_energy, "[\\lambda]\\S-1\\N"); } else { sprintf(title, "%s and %s", dhdl, deltag); sprintf(label_x, "Time (ps)"); sprintf(label_y, "%s and %s (%s %s)", dhdl, deltag, unit_energy, "[\\8l\\4]\\S-1\\N"); } fp = gmx_fio_fopen(filename, "w+"); xvgr_header(fp, title, label_x, label_y, exvggtXNY, oenv); if (!(ir->bSimTemp)) { bufplace = sprintf(buf, "T = %g (K) ", ir->opts.ref_t[0]); } if ((ir->efep != efepSLOWGROWTH) && (ir->efep != efepEXPANDED)) { if ( (fep->init_lambda >= 0) && (n_lambda_terms == 1 )) { /* compatibility output */ sprintf(&(buf[bufplace]), "%s = %.4f", lambda, fep->init_lambda); } else { print_lambda_vector(fep, fep->init_fep_state, TRUE, FALSE, lambda_vec_str); print_lambda_vector(fep, fep->init_fep_state, TRUE, TRUE, lambda_name_str); sprintf(&(buf[bufplace]), "%s %d: %s = %s", lambdastate, fep->init_fep_state, lambda_name_str, lambda_vec_str); } } xvgr_subtitle(fp, buf, oenv); nsets_dhdl = 0; if (fep->dhdl_derivatives == edhdlderivativesYES) { nsets_dhdl = n_lambda_terms; } /* count the number of delta_g states */ nsets_de = fep->lambda_stop_n - fep->lambda_start_n; nsets = nsets_dhdl + nsets_de; /* dhdl + fep differences */ if (fep->n_lambda > 0 && (expand->elmcmove > elmcmoveNO)) { nsets += 1; /*add fep state for expanded ensemble */ } if (fep->edHdLPrintEnergy != edHdLPrintEnergyNO) { nsets += 1; /* add energy to the dhdl as well */ } nsetsextend = nsets; if ((ir->epc != epcNO) && (fep->n_lambda > 0) && (fep->init_lambda < 0)) { nsetsextend += 1; /* for PV term, other terms possible if required for the reduced potential (only needed with foreign lambda, and only output when init_lambda is not set in order to maintain compatibility of the dhdl.xvg file) */ write_pV = TRUE; } snew(setname, nsetsextend); if (expand->elmcmove > elmcmoveNO) { /* state for the fep_vals, if we have alchemical sampling */ sprintf(buf, "%s", "Thermodynamic state"); setname[s] = gmx_strdup(buf); s += 1; } if (fep->edHdLPrintEnergy != edHdLPrintEnergyNO) { switch (fep->edHdLPrintEnergy) { case edHdLPrintEnergyPOTENTIAL: sprintf(buf, "%s (%s)", "Potential Energy", unit_energy); break; case edHdLPrintEnergyTOTAL: case edHdLPrintEnergyYES: default: sprintf(buf, "%s (%s)", "Total Energy", unit_energy); } setname[s] = gmx_strdup(buf); s += 1; } if (fep->dhdl_derivatives == edhdlderivativesYES) { for (i = 0; i < efptNR; i++) { if (fep->separate_dvdl[i]) { if ( (fep->init_lambda >= 0) && (n_lambda_terms == 1 )) { /* compatibility output */ sprintf(buf, "%s %s %.4f", dhdl, lambda, fep->init_lambda); } else { double lam = fep->init_lambda; if (fep->init_lambda < 0) { lam = fep->all_lambda[i][fep->init_fep_state]; } sprintf(buf, "%s %s = %.4f", dhdl, efpt_singular_names[i], lam); } setname[s] = gmx_strdup(buf); s += 1; } } } if (fep->n_lambda > 0) { /* g_bar has to determine the lambda values used in this simulation * from this xvg legend. */ if (expand->elmcmove > elmcmoveNO) { nsetsbegin = 1; /* for including the expanded ensemble */ } else { nsetsbegin = 0; } if (fep->edHdLPrintEnergy != edHdLPrintEnergyNO) { nsetsbegin += 1; } nsetsbegin += nsets_dhdl; 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 compatible dhdl.xvg files */ nps = sprintf(buf, "%s %s %s", deltag, lambda, lambda_vec_str); } else { nps = sprintf(buf, "%s %s to %s", deltag, lambda, lambda_vec_str); } if (ir->bSimTemp) { /* print the temperature for this state if doing simulated annealing */ sprintf(&buf[nps], "T = %g (%s)", ir->simtempvals->temperatures[s-(nsetsbegin)], unit_temp_K); } setname[s] = gmx_strdup(buf); s++; } if (write_pV) { sprintf(buf, "pV (%s)", unit_energy); setname[nsetsextend-1] = gmx_strdup(buf); /* the first entry after nsets */ } xvgr_legend(fp, nsetsextend, (const char **)setname, oenv); for (s = 0; s < nsetsextend; s++) { sfree(setname[s]); } sfree(setname); } return fp; }
FILE *open_dhdl(const char *filename,const t_inputrec *ir, const output_env_t oenv) { FILE *fp; const char *dhdl="dH/d\\lambda",*deltag="\\DeltaH",*lambda="\\lambda"; char title[STRLEN],label_x[STRLEN],label_y[STRLEN]; char **setname; char buf[STRLEN]; sprintf(label_x,"%s (%s)","Time",unit_time); if (ir->n_flambda == 0) { sprintf(title,"%s",dhdl); sprintf(label_y,"%s (%s %s)", dhdl,unit_energy,"[\\lambda]\\S-1\\N"); } else { sprintf(title,"%s, %s",dhdl,deltag); sprintf(label_y,"(%s)",unit_energy); } fp = gmx_fio_fopen(filename,"w+"); xvgr_header(fp,title,label_x,label_y,exvggtXNY,oenv); if (ir->delta_lambda == 0) { sprintf(buf,"T = %g (K), %s = %g", ir->opts.ref_t[0],lambda,ir->init_lambda); } else { sprintf(buf,"T = %g (K)", ir->opts.ref_t[0]); } xvgr_subtitle(fp,buf,oenv); if (ir->n_flambda > 0) { int nsets,s,nsi=0; /* g_bar has to determine the lambda values used in this simulation * from this xvg legend. */ nsets = ( (ir->dhdl_derivatives==dhdlderivativesYES) ? 1 : 0) + ir->n_flambda; snew(setname,nsets); if (ir->dhdl_derivatives == dhdlderivativesYES) { sprintf(buf,"%s %s %g",dhdl,lambda,ir->init_lambda); setname[nsi++] = strdup(buf); } for(s=0; s<ir->n_flambda; s++) { sprintf(buf,"%s %s %g",deltag,lambda,ir->flambda[s]); setname[nsi++] = strdup(buf); } xvgr_legend(fp,nsets,(const char**)setname,oenv); for(s=0; s<nsets; s++) { sfree(setname[s]); } sfree(setname); } return fp; }
static FILE *open_pull_out(const char *fn, t_pull *pull, const output_env_t oenv, gmx_bool bCoord, unsigned long Flags) { FILE *fp; int nsets, c, m; char **setname, buf[10]; if (Flags & MD_APPENDFILES) { fp = gmx_fio_fopen(fn, "a+"); } else { fp = gmx_fio_fopen(fn, "w+"); if (bCoord) { xvgr_header(fp, "Pull COM", "Time (ps)", "Position (nm)", exvggtXNY, oenv); } else { xvgr_header(fp, "Pull force", "Time (ps)", "Force (kJ/mol/nm)", exvggtXNY, oenv); } snew(setname, 2*pull->ncoord*DIM); nsets = 0; for (c = 0; c < pull->ncoord; c++) { if (bCoord) { if (pull->bPrintRef) { for (m = 0; m < DIM; m++) { if (pull->dim[m]) { sprintf(buf, "%d %s%c", c+1, "c", 'X'+m); setname[nsets] = strdup(buf); nsets++; } } } for (m = 0; m < DIM; m++) { if (pull->dim[m]) { sprintf(buf, "%d %s%c", c+1, "d", 'X'+m); setname[nsets] = strdup(buf); nsets++; } } } else { sprintf(buf, "%d", c+1); setname[nsets] = strdup(buf); nsets++; } } if (nsets > 1) { xvgr_legend(fp, nsets, (const char**)setname, oenv); } for (c = 0; c < nsets; c++) { sfree(setname[c]); } sfree(setname); } return fp; }
static FILE *open_pull_out(const char *fn,t_pull *pull,const output_env_t oenv, gmx_bool bCoord, unsigned long Flags) { FILE *fp; int nsets,g,m; char **setname,buf[10]; if(Flags & MD_APPENDFILES) { fp = gmx_fio_fopen(fn,"a+"); } else { fp = gmx_fio_fopen(fn,"w+"); if (bCoord) { xvgr_header(fp,"Pull COM", "Time (ps)","Position (nm)", exvggtXNY,oenv); } else { xvgr_header(fp,"Pull force","Time (ps)","Force (kJ/mol/nm)", exvggtXNY,oenv); } snew(setname,(1+pull->ngrp)*DIM); nsets = 0; for(g=0; g<1+pull->ngrp; g++) { if (pull->grp[g].nat > 0 && (g > 0 || (bCoord && !PULL_CYL(pull)))) { if (bCoord || pull->eGeom == epullgPOS) { if (PULL_CYL(pull)) { for(m=0; m<DIM; m++) { if (pull->dim[m]) { sprintf(buf,"%d %s%c",g,"c",'X'+m); setname[nsets] = strdup(buf); nsets++; } } } for(m=0; m<DIM; m++) { if (pull->dim[m]) { sprintf(buf,"%d %s%c", g,(bCoord && g > 0)?"d":"",'X'+m); setname[nsets] = strdup(buf); nsets++; } } } else { sprintf(buf,"%d",g); setname[nsets] = strdup(buf); nsets++; } } } if (bCoord || nsets > 1) { xvgr_legend(fp,nsets,(const char**)setname,oenv); } for(g=0; g<nsets; g++) { sfree(setname[g]); } sfree(setname); } return fp; }
extern FILE *open_dhdl(const char *filename,const t_inputrec *ir, const output_env_t oenv) { FILE *fp; const char *dhdl="dH/d\\lambda",*deltag="\\DeltaH",*lambda="\\lambda", *lambdastate="\\lambda state",*remain="remaining"; char title[STRLEN],label_x[STRLEN],label_y[STRLEN]; int i,np,nps,nsets,nsets_de,nsetsbegin; t_lambda *fep; char **setname; char buf[STRLEN]; int bufplace=0; int nsets_dhdl = 0; int s = 0; int nsetsextend; /* for simplicity */ fep = ir->fepvals; if (fep->n_lambda == 0) { sprintf(title,"%s",dhdl); sprintf(label_x,"Time (ps)"); sprintf(label_y,"%s (%s %s)", dhdl,unit_energy,"[\\lambda]\\S-1\\N"); } else { sprintf(title,"%s and %s",dhdl,deltag); sprintf(label_x,"Time (ps)"); sprintf(label_y,"%s and %s (%s %s)", dhdl,deltag,unit_energy,"[\\8l\\4]\\S-1\\N"); } fp = gmx_fio_fopen(filename,"w+"); xvgr_header(fp,title,label_x,label_y,exvggtXNY,oenv); if (!(ir->bSimTemp)) { bufplace = sprintf(buf,"T = %g (K) ", ir->opts.ref_t[0]); } if (ir->efep != efepSLOWGROWTH) { if (fep->n_lambda == 0) { sprintf(&(buf[bufplace]),"%s = %g", lambda,fep->init_lambda); } else { sprintf(&(buf[bufplace]),"%s = %d", lambdastate,fep->init_fep_state); } } xvgr_subtitle(fp,buf,oenv); for (i=0;i<efptNR;i++) { if (fep->separate_dvdl[i]) {nsets_dhdl++;} } /* count the number of delta_g states */ nsets_de = fep->n_lambda; nsets = nsets_dhdl + nsets_de; /* dhdl + fep differences */ if (fep->n_lambda>0 && ir->bExpanded) { nsets += 1; /*add fep state for expanded ensemble */ } if (fep->bPrintEnergy) { nsets += 1; /* add energy to the dhdl as well */ } nsetsextend = nsets; if ((ir->epc!=epcNO) && (fep->n_lambda>0)) { nsetsextend += 1; /* for PV term, other terms possible if required for the reduced potential (only needed with foreign lambda) */ } snew(setname,nsetsextend); if (ir->bExpanded) { /* state for the fep_vals, if we have alchemical sampling */ sprintf(buf,"%s","Thermodynamic state"); setname[s] = strdup(buf); s+=1; } if (fep->bPrintEnergy) { sprintf(buf,"%s (%s)","Energy",unit_energy); setname[s] = strdup(buf); s+=1; } for (i=0;i<efptNR;i++) { if (fep->separate_dvdl[i]) { sprintf(buf,"%s (%s)",dhdl,efpt_names[i]); setname[s] = strdup(buf); s+=1; } } if (fep->n_lambda > 0) { /* g_bar has to determine the lambda values used in this simulation * from this xvg legend. */ if (ir->bExpanded) { nsetsbegin = 1; /* for including the expanded ensemble */ } else { nsetsbegin = 0; } if (fep->bPrintEnergy) { nsetsbegin += 1; } nsetsbegin += nsets_dhdl; for(s=nsetsbegin; s<nsets; s++) { nps = sprintf(buf,"%s %s (",deltag,lambda); for (i=0;i<efptNR;i++) { if (fep->separate_dvdl[i]) { np = sprintf(&buf[nps],"%g,",fep->all_lambda[i][s-(nsetsbegin)]); nps += np; } } if (ir->bSimTemp) { /* print the temperature for this state if doing simulated annealing */ sprintf(&buf[nps],"T = %g (%s))",ir->simtempvals->temperatures[s-(nsetsbegin)],unit_temp_K); } else { sprintf(&buf[nps-1],")"); /* -1 to overwrite the last comma */ } setname[s] = strdup(buf); } if (ir->epc!=epcNO) { np = sprintf(buf,"pV (%s)",unit_energy); setname[nsetsextend-1] = strdup(buf); /* the first entry after nsets */ } xvgr_legend(fp,nsetsextend,(const char **)setname,oenv); for(s=0; s<nsetsextend; s++) { sfree(setname[s]); } sfree(setname); } return fp; }