Example #1
0
File: build.cpp Project: qzlshy/smc
int Build_s::rt_fit(Build_m m_c)
{
 int i,j,k;
 
 for(i=0;i<resnum;i++)
 for(j=0;j<rtmn[i];j++)
	{
	 if(cs[i][j].atomn>0)
	 fit_one(m_c,i,j);
	 get_ct(i,j);
	}
}
Example #2
0
void calc_tauc(bool bVerbose,int npair,t_pair pair[],real dt,
	       int nframes,t_sij spec[],real **corr)
{
  FILE *fp;
  char buf[32];
  int  i,j,k,n;
  real S2,S22,tauc,fac;
  real *x,*dy;
  real ftol = 1e-3;
  
  snew(x,nframes);
  snew(dy,nframes);
  for(i=0; (i<nframes); i++) 
    x[i]  = i*dt;
  
  fprintf(stderr,"Fitting correlation function to Lipari&Szabo function\n");
  fac=1.0/((real)nframes);
  for(i=0; (i<npair); i++) {
    if (spec[i].bNOE) {
      /* Use Levenberg-Marquardt method to fit */
      for(j=0; (j<nframes); j++) 
	dy[j] = fac;
      fit_one(bVerbose,
	      nframes,x,corr[i],dy,ftol,
	      &(spec[i].S2),&(spec[i].dS2),
	      &(spec[i].tauc),&(spec[i].dtauc));
      if (bVerbose) {
	sprintf(buf,"test%d.xvg",i);
	fp = ffopen(buf,"w");
	for(j=0; (j<nframes); j++) {
	  fprintf(fp,"%10g  %10g  %10g\n",j*dt,corr[i][j],
		  spec[i].S2 + (1-spec[i].S2)*exp(-j*dt/spec[i].tauc));
	}
	fclose(fp);
      }
    }
  }
}