Exemplo n.º 1
0
real ca_phi(int gnx, int index[], rvec x[])
/* Assume we have a list of Calpha atoms only! */
{
    real phi, phitot;
    int  i, ai, aj, ak, al, t1, t2, t3;
    rvec r_ij, r_kj, r_kl, m, n;
    real sign;

    if (gnx <= 4)
    {
        return 0;
    }

    phitot = 0;
    for (i = 0; (i < gnx-4); i++)
    {
        ai  = index[i+0];
        aj  = index[i+1];
        ak  = index[i+2];
        al  = index[i+3];
        phi = RAD2DEG*
            dih_angle(x[ai], x[aj], x[ak], x[al], NULL,
                      r_ij, r_kj, r_kl, m, n,
                      &sign, &t1, &t2, &t3);
        phitot += phi;
    }

    return (phitot/(gnx-4.0));
}
Exemplo n.º 2
0
void calc_hxprops(int nres, t_bb bb[], rvec x[])
{
    int  i, ao, an, t1, t2, t3;
    rvec dx, r_ij, r_kj, r_kl, m, n;
    real sign;

    for (i = 0; (i < nres); i++)
    {
        ao       = bb[i].O;
        bb[i].d4 = bb[i].d3 = bb[i].d5 = 0;
        if (i < nres-3)
        {
            an = bb[i+3].N;
            rvec_sub(x[ao], x[an], dx);
            bb[i].d3 = norm(dx);
        }
        if (i < nres-4)
        {
            an = bb[i+4].N;
            rvec_sub(x[ao], x[an], dx);
            bb[i].d4 = norm(dx);
        }
        if (i < nres-5)
        {
            an = bb[i+5].N;
            rvec_sub(x[ao], x[an], dx);
            bb[i].d5 = norm(dx);
        }

        bb[i].phi = RAD2DEG*
            dih_angle(x[bb[i].Cprev], x[bb[i].N], x[bb[i].CA], x[bb[i].C], NULL,
                      r_ij, r_kj, r_kl, m, n,
                      &sign, &t1, &t2, &t3);
        bb[i].psi = RAD2DEG*
            dih_angle(x[bb[i].N], x[bb[i].CA], x[bb[i].C], x[bb[i].Nnext], NULL,
                      r_ij, r_kj, r_kl, m, n,
                      &sign, &t1, &t2, &t3);
        bb[i].pprms2 = sqr(bb[i].phi-PHI_AHX)+sqr(bb[i].psi-PSI_AHX);

        bb[i].jcaha +=
            1.4*std::sin((bb[i].psi+138.0)*DEG2RAD) -
            4.1*std::cos(2.0*DEG2RAD*(bb[i].psi+138.0)) +
            2.0*std::cos(2.0*DEG2RAD*(bb[i].phi+30.0));
    }
}
Exemplo n.º 3
0
static void calc_dihs(FILE *log,t_pbc *pbc,
		      int n4,atom_id index[],real ang[],rvec x_s[])
{
  int  i,ix,t1,t2,t3;
  rvec r_ij,r_kj,r_kl,m,n;
  real cos_phi,sign,aaa;
  
  for(i=ix=0; (ix<n4); i++,ix+=4) {
    aaa=dih_angle(x_s[index[ix]],x_s[index[ix+1]],x_s[index[ix+2]],
		  x_s[index[ix+3]],pbc,
		  r_ij,r_kj,r_kl,m,n,
		  &cos_phi,&sign,&t1,&t2,&t3);
	  
    ang[i]=aaa;  /* not taking into account ryckaert bellemans yet */
  }
}
Exemplo n.º 4
0
void calc_angles_dihs(t_params *ang, t_params *dih, rvec x[], gmx_bool bPBC,
                      matrix box)
{
    int    i, ai, aj, ak, al, t1, t2, t3;
    rvec   r_ij, r_kj, r_kl, m, n;
    real   sign, th, costh, ph;
    t_pbc  pbc;

    if (bPBC)
    {
        set_pbc(&pbc, epbcXYZ, box);
    }
    if (debug)
    {
        pr_rvecs(debug, 0, "X2TOP", box, DIM);
    }
    for (i = 0; (i < ang->nr); i++)
    {
        ai = ang->param[i].AI;
        aj = ang->param[i].AJ;
        ak = ang->param[i].AK;
        th = RAD2DEG*bond_angle(x[ai], x[aj], x[ak], bPBC ? &pbc : NULL,
                                r_ij, r_kj, &costh, &t1, &t2);
        if (debug)
        {
            fprintf(debug, "X2TOP: ai=%3d aj=%3d ak=%3d r_ij=%8.3f r_kj=%8.3f th=%8.3f\n",
                    ai, aj, ak, norm(r_ij), norm(r_kj), th);
        }
        ang->param[i].C0 = th;
    }
    for (i = 0; (i < dih->nr); i++)
    {
        ai = dih->param[i].AI;
        aj = dih->param[i].AJ;
        ak = dih->param[i].AK;
        al = dih->param[i].AL;
        ph = RAD2DEG*dih_angle(x[ai], x[aj], x[ak], x[al], bPBC ? &pbc : NULL,
                               r_ij, r_kj, r_kl, m, n, &sign, &t1, &t2, &t3);
        if (debug)
        {
            fprintf(debug, "X2TOP: ai=%3d aj=%3d ak=%3d al=%3d r_ij=%8.3f r_kj=%8.3f r_kl=%8.3f ph=%8.3f\n",
                    ai, aj, ak, al, norm(r_ij), norm(r_kj), norm(r_kl), ph);
        }
        dih->param[i].C0 = ph;
    }
}
Exemplo n.º 5
0
static void calc_dihs(struct t_pbc *pbc,
                      int n4, const int index[], real ang[], rvec x_s[])
{
    int  i, ix, t1, t2, t3;
    rvec r_ij, r_kj, r_kl, m, n;
    real aaa;

    for (i = ix = 0; (ix < n4); i++, ix += 4)
    {
        aaa = dih_angle(x_s[index[ix]], x_s[index[ix+1]], x_s[index[ix+2]],
                        x_s[index[ix+3]], pbc,
                        r_ij, r_kj, r_kl, m, n,
                        &t1, &t2, &t3);

        ang[i] = aaa; /* not taking into account ryckaert bellemans yet */
    }
}
Exemplo n.º 6
0
static void calc_dihs(t_xrama *xr)
{
  int    i;
  rvec   r_ij,r_kj,r_kl,m,n;
  real   cos_phi,sign;
  t_dih  *dd;

  rm_pbc(xr->idef,xr->natoms,xr->box,xr->x,xr->x);

  for(i=0; (i<xr->ndih); i++) {
    dd=&(xr->dih[i]);
    dd->ang=dih_angle(xr->box,
		      xr->x[dd->ai[0]],xr->x[dd->ai[1]],
		      xr->x[dd->ai[2]],xr->x[dd->ai[3]],
		      r_ij,r_kj,r_kl,m,n,&cos_phi,&sign);
  }
}
Exemplo n.º 7
0
static void calc_dihs(t_xrama *xr)
{
    int          i, t1, t2, t3;
    rvec         r_ij, r_kj, r_kl, m, n;
    t_dih       *dd;
    gmx_rmpbc_t  gpbc = nullptr;

    gpbc = gmx_rmpbc_init(xr->idef, xr->ePBC, xr->natoms);
    gmx_rmpbc(gpbc, xr->natoms, xr->box, xr->x);
    gmx_rmpbc_done(gpbc);

    for (i = 0; (i < xr->ndih); i++)
    {
        dd      = &(xr->dih[i]);
        dd->ang = dih_angle(xr->x[dd->ai[0]], xr->x[dd->ai[1]],
                            xr->x[dd->ai[2]], xr->x[dd->ai[3]],
                            nullptr,
                            r_ij, r_kj, r_kl, m, n, &t1, &t2, &t3);
    }
}
Exemplo n.º 8
0
real ta_dihres(int nfa,const t_iatom forceatoms[],const t_iparams ip[],
	       const rvec x[],rvec f[],rvec fshift[],
	       const t_pbc *pbc,const t_graph *g,
	       real lambda,real *dvdlambda,
	       const t_mdatoms *md,t_fcdata *fcd,
	       int *ddgatindex)
{
  real vtot = 0;
  int  ai,aj,ak,al,i,k,type,typep,label,power,t1,t2,t3;
  real phi0,phi,ddphi,ddp,dp,dp2,dphi,kfac,cos_phi,sign,d2r,fc;
  rvec r_ij,r_kj,r_kl,m,n;
  
  fc  = fcd->dihre_fc;
  d2r = DEG2RAD;
  k   = 0;
  for(i=0; (i<nfa); ) {
    type = forceatoms[i++];
    ai   = forceatoms[i++];
    aj   = forceatoms[i++];
    ak   = forceatoms[i++];
    al   = forceatoms[i++];
    
    phi0  = ip[type].dihres.phi*d2r;
    dphi  = ip[type].dihres.dphi*d2r;
    kfac  = ip[type].dihres.kfac*fc; 
    power = ip[type].dihres.power;
    label = ip[type].dihres.label;
    
    phi = dih_angle(x[ai],x[aj],x[ak],x[al],pbc,r_ij,r_kj,r_kl,m,n,
                    &cos_phi,&sign,&t1,&t2,&t3);	  
    /* 84 flops */
    
    if (debug)
        fprintf(debug,"dihres[%d]: %d %d %d %d : phi=%f, dphi=%f, kfac=%f, power=%d, label=%d\n",
                k++,ai,aj,ak,al,phi,dphi,kfac,power,label);

    /* phi can jump if phi0 is close to Pi/-Pi, which will cause huge
     * force changes if we just apply a normal harmonic.
     * Instead, we first calculate phi-phi0 and take it modulo (-Pi,Pi).
     * This means we will never have the periodicity problem, unless
     * the dihedral is Pi away from phiO, which is very unlikely due to
     * the potential.
     */
    dp = phi-phi0;  
    if (fabs(dp) > dphi) {
      /* dp cannot be outside (-2*pi,2*pi) */
      if (dp >= M_PI)
	dp -= 2*M_PI;
      else if(dp < -M_PI)
	dp += 2*M_PI;

      if (dp > dphi)
	ddp = dp-dphi;
      else if (dp < -dphi)
	ddp = dp+dphi;
      else
	ddp = 0;

      if (ddp != 0.0) {
	vtot += 0.5*kfac*ddp*ddp;
	ddphi = kfac*ddp;
	
	do_dih_fup(ai,aj,ak,al,ddphi,r_ij,r_kj,r_kl,m,n,
		   f,fshift,pbc,g,x,t1,t2,t3);		/* 112		*/
      }
    }
  }
  return vtot;
}
void do_gkr(t_gkrbin *gb,int ncos,int *ngrp,int *molindex[],
            int mindex[],rvec x[],rvec mu[],
            int ePBC,matrix box,t_atom *atom,int *nAtom)
{
    static rvec *xcm[2] = { NULL, NULL};
    int    gi,gj,j0,j1,i,j,k,n,index,grp0,grp1;
    real   qtot,q,r2,cosa,rr,phi;
    rvec   dx;
    t_pbc  pbc;
  
    for(n=0; (n<ncos); n++) {
        if (!xcm[n])
            snew(xcm[n],ngrp[n]);
        for(i=0; (i<ngrp[n]); i++) {
            /* Calculate center of mass of molecule */
            gi = molindex[n][i];
            j0 = mindex[gi];
      
            if (nAtom[n] > 0)
                copy_rvec(x[j0+nAtom[n]-1],xcm[n][i]);
            else {
                j1 = mindex[gi+1];
                clear_rvec(xcm[n][i]);
                qtot = 0;
                for(j=j0; j<j1; j++) {
                    q = fabs(atom[j].q);
                    qtot += q;
                    for(k=0; k<DIM; k++)
                        xcm[n][i][k] += q*x[j][k];
                }
                svmul(1/qtot,xcm[n][i],xcm[n][i]);
            }
        }
    }
    set_pbc(&pbc,ePBC,box);
    grp0 = 0;
    grp1 = ncos-1;
    for(i=0; i<ngrp[grp0]; i++) {
        gi = molindex[grp0][i];
        j0 = (ncos == 2) ? 0 : i+1;
        for(j=j0; j<ngrp[grp1]; j++) {
            gj   = molindex[grp1][j];
            if ((iprod(mu[gi],mu[gi]) > 0) && (iprod(mu[gj],mu[gj]) > 0)) {
                /* Compute distance between molecules including PBC */
                pbc_dx(&pbc,xcm[grp0][i],xcm[grp1][j],dx);
                rr = norm(dx);
	
                if (gb->bPhi) {
                    rvec xi,xj,xk,xl;
                    rvec r_ij,r_kj,r_kl,mm,nn;
                    real sign;
                    int  t1,t2,t3;
	  
                    copy_rvec(xcm[grp0][i],xj);
                    copy_rvec(xcm[grp1][j],xk);
                    rvec_add(xj,mu[gi],xi);
                    rvec_add(xk,mu[gj],xl);
                    phi = dih_angle(xi,xj,xk,xl,&pbc,
                                    r_ij,r_kj,r_kl,mm,nn, /* out */
                                    &sign,&t1,&t2,&t3);
                    cosa = cos(phi);
                }
                else {
                    cosa = cos_angle(mu[gi],mu[gj]);
                    phi = 0;
                }
                if (debug || (cosa != cosa))  {
                    fprintf(debug ? debug : stderr,
                            "mu[%d] = %5.2f %5.2f %5.2f |mi| = %5.2f, mu[%d] = %5.2f %5.2f %5.2f |mj| = %5.2f rr = %5.2f cosa = %5.2f\n",
                            gi,mu[gi][XX],mu[gi][YY],mu[gi][ZZ],norm(mu[gi]),
                            gj,mu[gj][XX],mu[gj][YY],mu[gj][ZZ],norm(mu[gj]),
                            rr,cosa);
                }
	
                add2gkr(gb,rr,cosa,phi);
            }
        }
    }
}