bool new_data(t_xrama *xr) { if (!read_next_x(xr->traj,&xr->t,xr->natoms,xr->x,xr->box)) return FALSE; calc_dihs(xr); return TRUE; }
gmx_bool new_data(t_xrama *xr) { if (!read_next_x(xr->oenv, xr->traj, &xr->t, xr->x, xr->box)) { return FALSE; } calc_dihs(xr); return TRUE; }
void init_rama(char *infile,char *topfile,t_xrama *xr) { static t_topology *top; real t; top=read_top(topfile); /*get_dih2(xr,top->idef.functype,&(top->idef.bondeds),&(top->atoms));*/ get_dih(xr,&(top->atoms)); get_dih_props(xr,&(top->idef)); xr->natoms=read_first_x(&xr->traj,infile,&t,&(xr->x),xr->box); xr->idef=&(top->idef); min_max(xr); calc_dihs(xr); }
t_topology *init_rama(char *infile,char *topfile,t_xrama *xr,int mult) { t_topology *top; int ePBC; real t; top=read_top(topfile,&xr->ePBC); /*get_dih2(xr,top->idef.functype,&(top->idef.bondeds),&(top->atoms));*/ get_dih(xr,&(top->atoms)); get_dih_props(xr,&(top->idef),mult); xr->natoms=read_first_x(&xr->traj,infile,&t,&(xr->x),xr->box); xr->idef=&(top->idef); min_max(xr); calc_dihs(xr); return top; }
void read_ang_dih(const char *trj_fn, gmx_bool bAngles, gmx_bool bSaveAll, gmx_bool bRb, gmx_bool bPBC, int maxangstat, int angstat[], int *nframes, real **time, int isize, atom_id index[], real **trans_frac, real **aver_angle, real *dih[], const output_env_t oenv) { t_pbc *pbc; t_trxstatus *status; int i, angind, natoms, total, teller; int nangles, n_alloc; real t, fraction, pifac, aa, angle; real *angles[2]; matrix box; rvec *x; int cur = 0; #define prev (1-cur) snew(pbc, 1); natoms = read_first_x(oenv, &status, trj_fn, &t, &x, box); if (bAngles) { nangles = isize/3; pifac = M_PI; } else { nangles = isize/4; pifac = 2.0*M_PI; } snew(angles[cur], nangles); snew(angles[prev], nangles); /* Start the loop over frames */ total = 0; teller = 0; n_alloc = 0; *time = NULL; *trans_frac = NULL; *aver_angle = NULL; do { if (teller >= n_alloc) { n_alloc += 100; if (bSaveAll) { for (i = 0; (i < nangles); i++) { srenew(dih[i], n_alloc); } } srenew(*time, n_alloc); srenew(*trans_frac, n_alloc); srenew(*aver_angle, n_alloc); } (*time)[teller] = t; if (pbc) { set_pbc(pbc, -1, box); } if (bAngles) { calc_angles(pbc, isize, index, angles[cur], x); } else { calc_dihs(pbc, isize, index, angles[cur], x); /* Trans fraction */ fraction = calc_fraction(angles[cur], nangles); (*trans_frac)[teller] = fraction; /* Change Ryckaert-Bellemans dihedrals to polymer convention * Modified 990913 by Erik: * We actually shouldn't change the convention, since it's * calculated from polymer above, but we change the intervall * from [-180,180] to [0,360]. */ if (bRb) { for (i = 0; (i < nangles); i++) { if (angles[cur][i] <= 0.0) { angles[cur][i] += 2*M_PI; } } } /* Periodicity in dihedral space... */ if (bPBC) { for (i = 0; (i < nangles); i++) { real dd = angles[cur][i]; angles[cur][i] = atan2(sin(dd), cos(dd)); } } else { if (teller > 1) { for (i = 0; (i < nangles); i++) { while (angles[cur][i] <= angles[prev][i] - M_PI) { angles[cur][i] += 2*M_PI; } while (angles[cur][i] > angles[prev][i] + M_PI) { angles[cur][i] -= 2*M_PI; } } } } } /* Average angles */ aa = 0; for (i = 0; (i < nangles); i++) { aa = aa+angles[cur][i]; /* angle in rad / 2Pi * max determines bin. bins go from 0 to maxangstat, even though scale goes from -pi to pi (dihedral) or -pi/2 to pi/2 (angle) Basically: translate the x-axis by Pi. Translate it back by -Pi when plotting. */ angle = angles[cur][i]; if (!bAngles) { while (angle < -M_PI) { angle += 2*M_PI; } while (angle >= M_PI) { angle -= 2*M_PI; } angle += M_PI; } /* Update the distribution histogram */ angind = (int) ((angle*maxangstat)/pifac + 0.5); if (angind == maxangstat) { angind = 0; } if ( (angind < 0) || (angind >= maxangstat) ) { /* this will never happen */ gmx_fatal(FARGS, "angle (%f) index out of range (0..%d) : %d\n", angle, maxangstat, angind); } angstat[angind]++; if (angind == maxangstat) { fprintf(stderr, "angle %d fr %d = %g\n", i, cur, angle); } total++; } /* average over all angles */ (*aver_angle)[teller] = (aa/nangles); /* this copies all current dih. angles to dih[i], teller is frame */ if (bSaveAll) { for (i = 0; i < nangles; i++) { dih[i][teller] = angles[cur][i]; } } /* Swap buffers */ cur = prev; /* Increment loop counter */ teller++; } while (read_next_x(oenv, status, &t, x, box)); close_trj(status); sfree(x); sfree(angles[cur]); sfree(angles[prev]); *nframes = teller; }