From 99ed989715adcb1b2ea0602cc42b57581dc57db5 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Tue, 19 Apr 2011 19:33:05 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5977 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/USER-EWALDN/ewald_n.cpp | 34 +++++++++--------- src/fix_rigid.cpp | 70 +++++++++++++++---------------------- src/math_extra.cpp | 6 ++-- 3 files changed, 48 insertions(+), 62 deletions(-) diff --git a/src/USER-EWALDN/ewald_n.cpp b/src/USER-EWALDN/ewald_n.cpp index affca321c3..d45b90f05d 100644 --- a/src/USER-EWALDN/ewald_n.cpp +++ b/src/USER-EWALDN/ewald_n.cpp @@ -353,10 +353,10 @@ void EwaldN::init_coeff_sums() // sums based on atoms } } if (function[3]) { // dipole - int *type = atom->type, *ntype = type+atom->nlocal; - double *dipole = atom->dipole; - for (int *i=type; imu; + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) + sum_local[9].x2 += mu[i][3]*mu[i][3]; } MPI_Allreduce(sum_local, sum, 2*EWALD_MAX_NSUMS, MPI_DOUBLE, MPI_SUM, world); } @@ -413,7 +413,7 @@ void EwaldN::compute_ek() complex *cek, zxyz, zxy, cx; vector mui; double *x = atom->x[0], *xn = x+3*atom->nlocal, *q = atom->q, qi, bi, ci[7]; - double *dipole = atom->dipole, *mu = atom->mu ? atom->mu[0] : NULL; + double *mu = atom->mu ? atom->mu[0] : NULL; int i, kx, ky, n = nkvec*nsums, *type = atom->type, tri = domain->triclinic; int func[EWALD_NFUNCS]; @@ -444,7 +444,8 @@ void EwaldN::compute_ek() if (func[2]) memcpy(ci, B+7*type[0], 7*sizeof(double)); if (func[3]) { memcpy(mui, mu, sizeof(vector)); mu += 3; - vec_scalar_mult(mui, dipole[*type]); + vec_scalar_mult(mui, mu[3]); + mu += 4; h = hvec; } for (k=kvec; kf[0], *fn = f+3*atom->nlocal, *q = atom->q, *t = NULL; - double *dipole = atom->dipole, *mu = atom->mu ? atom->mu[0] : NULL; + double *mu = atom->mu ? atom->mu[0] : NULL; double *ke, c[EWALD_NFUNCS] = { 8.0*M_PI*qqrd2e*scale/volume, 2.0*M_PI*sqrt(M_PI)/(12.0*volume), 2.0*M_PI*sqrt(M_PI)/(192.0*volume), 8.0*M_PI*mumurd2e/volume}; @@ -500,8 +501,9 @@ void EwaldN::compute_force() cek = cek_global; memset(sum, 0, EWALD_MAX_NSUMS*sizeof(vector)); if (func[3]) { - register double di = dipole[*type]*c[3]; + register double di = mu[3] * c[3]; mui[0] = di*(mu++)[0]; mui[1] = di*(mu++)[1]; mui[2] = di*(mu++)[2]; + mu++; } for (nh = (h = hvec)+nkvec; hy) { // based on order in @@ -556,20 +558,19 @@ void EwaldN::compute_force() } } - void EwaldN::compute_surface() { if (!function[3]) return; vector sum_local = VECTOR_NULL, sum_total; - double *mu = atom->mu ? atom->mu[0] : NULL, *dipole = atom->dipole; - int *type = atom->type, *ntype = type+atom->nlocal; + double **mu = atom->mu; + int nlocal = atom->nlocal; - for (int *i=type; iall("Insufficient Jacobi rotations for rigid body"); @@ -818,14 +811,13 @@ void FixRigid::init() (displace[i][0]*displace[i][0] + displace[i][2]*displace[i][2]); sum[ibody][2] += massone * (displace[i][0]*displace[i][0] + displace[i][1]*displace[i][1]); - sum[ibody][3] -= massone * displace[i][0]*displace[i][1]; - sum[ibody][4] -= massone * displace[i][1]*displace[i][2]; - sum[ibody][5] -= massone * displace[i][0]*displace[i][2]; + sum[ibody][3] -= massone * displace[i][1]*displace[i][2]; + sum[ibody][4] -= massone * displace[i][0]*displace[i][2]; + sum[ibody][5] -= massone * displace[i][0]*displace[i][1]; } if (extended) { - double ex[3],ey[3],ez[3],idiag[3]; - double p[3][3],ptrans[3][3],ispace[3][3],itemp[3][3]; + double ivec[6]; double *shape; for (i = 0; i < nlocal; i++) { @@ -843,19 +835,13 @@ void FixRigid::init() } if (eflags[i] & INERTIA_ELLIPSOID) { shape = ebonus[ellipsoid[i]].shape; - MathExtra::quat_to_mat(qorient[i],p); - MathExtra::quat_to_mat_trans(qorient[i],ptrans); - idiag[0] = 0.2*massone * (shape[1]*shape[1]+shape[2]*shape[2]); - idiag[1] = 0.2*massone * (shape[0]*shape[0]+shape[2]*shape[2]); - idiag[2] = 0.2*massone * (shape[0]*shape[0]+shape[1]*shape[1]); - MathExtra::diag_times3(idiag,ptrans,itemp); - MathExtra::times3(p,itemp,ispace); - sum[ibody][0] += ispace[0][0]; - sum[ibody][1] += ispace[1][1]; - sum[ibody][2] += ispace[2][2]; - sum[ibody][3] += ispace[0][1]; - sum[ibody][4] += ispace[1][2]; - sum[ibody][5] += ispace[0][2]; + MathExtra::inertia_ellipsoid(shape,qorient[i],massone,ivec); + sum[ibody][0] += ivec[0]; + sum[ibody][1] += ivec[1]; + sum[ibody][2] += ivec[2]; + sum[ibody][3] += ivec[3]; + sum[ibody][4] += ivec[4]; + sum[ibody][5] += ivec[5]; } } } diff --git a/src/math_extra.cpp b/src/math_extra.cpp index 2f25a1f6c3..5bbf3fdca1 100644 --- a/src/math_extra.cpp +++ b/src/math_extra.cpp @@ -421,9 +421,9 @@ void inertia_triangle(double *v0, double *v1, double *v2, // NOTE: use mass - inertia[0] = inv24*a * (sum-vtsv[0][0]); - inertia[1] = inv24*a * (sum-vtsv[1][1]); - inertia[2] = inv24*a * (sum-vtsv[2][2]); + inertia[0] = inv24*a*(sum-vtsv[0][0]); + inertia[1] = inv24*a*(sum-vtsv[1][1]); + inertia[2] = inv24*a*(sum-vtsv[2][2]); inertia[3] = -inv24*a*vtsv[1][2]; inertia[4] = -inv24*a*vtsv[0][2]; inertia[5] = -inv24*a*vtsv[0][1];