/* ******************************************************* */ /* com.c: center center-of-mas and remove velocity and rot */ /* funcions: com2zero(), com_vw2zero() */ /* ******************************************************* */ int com_psinv(double *, double *); /* ******************************************************* */ /* com2zero(x): move center-of-mass to zero */ /* ******************************************************* */ int com2zero(REAL_T *x, REAL_T *minv) { int n, i; REAL_T xs, ys, zs, m_t; n = 3 * prm->Natom; xs = ys = zs = 0.0; /* total mass */ for (i = 0; i < n/3; i++) { m_t += 1./minv[3*i]; } /* center of mass */ for (i = 0; i < n/3; i++) { xs += x[3*i ] / minv[3*i ]; ys += x[3*i+1] / minv[3*i+1]; zs += x[3*i+2] / minv[3*i+2]; } xs /= m_t; ys /= m_t; zs /= m_t; // printf("com: %f, %f, %f\n", xs, ys, zs); /* move com to center */ for (i = 0; i < n/3; i++) { x[3*i ] -= xs; x[3*i+1] -= ys; x[3*i+2] -= zs; } return (0); } /* ******************************************************* */ /* com_vw2zero(x): remove com velocity and rotation */ /* ******************************************************* */ int com_vw2zero(REAL_T *x, REAL_T *v,REAL_T *minv) { int n,i; REAL_T Lx,Ly,Lz; REAL_T vsx,vsy,vsz; REAL_T xx,xy,xz,yy,yz,zz; REAL_T I[9], Iinv[9]; REAL_T Omx,Omy,Omz; REAL_T m_t; #define SCFAC 1.e-3 n = 3 * prm->Natom; vsx = vsy = vsz = 0.0; /* total mass */ for(i=0;i