From e85b65f387ebfe19c919b885b5da0359b893ce6f Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 1 Dec 2010 16:59:10 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5349 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/KSPACE/pair_buck_coul_long.cpp | 30 ++++++++++++++++++++++++++++++ src/fix_wall_reflect.cpp | 2 +- src/pair_buck.cpp | 30 ++++++++++++++++++++++++++++++ src/pair_buck_coul_cut.cpp | 30 ++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) diff --git a/src/KSPACE/pair_buck_coul_long.cpp b/src/KSPACE/pair_buck_coul_long.cpp index a865a583b8..800900cdc2 100644 --- a/src/KSPACE/pair_buck_coul_long.cpp +++ b/src/KSPACE/pair_buck_coul_long.cpp @@ -287,6 +287,36 @@ double PairBuckCoulLong::init_one(int i, int j) buck2[j][i] = buck2[i][j]; offset[j][i] = offset[i][j]; + // compute I,J contribution to long-range tail correction + // count total # of atoms of type I and J via Allreduce + + if (tail_flag) { + int *type = atom->type; + int nlocal = atom->nlocal; + + double count[2],all[2]; + count[0] = count[1] = 0.0; + for (int k = 0; k < nlocal; k++) { + if (type[k] == i) count[0] += 1.0; + if (type[k] == j) count[1] += 1.0; + } + MPI_Allreduce(count,all,2,MPI_DOUBLE,MPI_SUM,world); + + double PI = 4.0*atan(1.0); + double rho1 = rho[i][j]; + double rho2 = rho1*rho1; + double rho3 = rho2*rho1; + double rc = cut_lj[i][j]; + double rc2 = rc*rc; + double rc3 = rc2*rc; + etail_ij = 2.0*PI*all[0]*all[1]* + (a[i][j]*exp(-rc/rho1)*rho1*(rc2 + 2.0*rho1*rc + 2.0*rho2) - + c[i][j]/(3.0*rc3)); + ptail_ij = (-1/3.0)*2.0*PI*all[0]*all[1]* + (-a[i][j]*exp(-rc/rho1)* + (rc3 + 3.0*rho1*rc2 + 6.0*rho2*rc + 6.0*rho3) + 2.0*c[i][j]/rc3); + } + return cut; } diff --git a/src/fix_wall_reflect.cpp b/src/fix_wall_reflect.cpp index 95407231b0..fa74faf48a 100644 --- a/src/fix_wall_reflect.cpp +++ b/src/fix_wall_reflect.cpp @@ -213,7 +213,7 @@ void FixWallReflect::post_integrate() v[i][dim] = -v[i][dim]; } } else { - if (x[i][0] > coord) { + if (x[i][dim] > coord) { x[i][dim] = coord - (x[i][dim] - coord); v[i][dim] = -v[i][dim]; } diff --git a/src/pair_buck.cpp b/src/pair_buck.cpp index f8c48ca1c5..8d02aa2b84 100644 --- a/src/pair_buck.cpp +++ b/src/pair_buck.cpp @@ -242,6 +242,36 @@ double PairBuck::init_one(int i, int j) buck2[j][i] = buck2[i][j]; offset[j][i] = offset[i][j]; + // compute I,J contribution to long-range tail correction + // count total # of atoms of type I and J via Allreduce + + if (tail_flag) { + int *type = atom->type; + int nlocal = atom->nlocal; + + double count[2],all[2]; + count[0] = count[1] = 0.0; + for (int k = 0; k < nlocal; k++) { + if (type[k] == i) count[0] += 1.0; + if (type[k] == j) count[1] += 1.0; + } + MPI_Allreduce(count,all,2,MPI_DOUBLE,MPI_SUM,world); + + double PI = 4.0*atan(1.0); + double rho1 = rho[i][j]; + double rho2 = rho1*rho1; + double rho3 = rho2*rho1; + double rc = cut[i][j]; + double rc2 = rc*rc; + double rc3 = rc2*rc; + etail_ij = 2.0*PI*all[0]*all[1]* + (a[i][j]*exp(-rc/rho1)*rho1*(rc2 + 2.0*rho1*rc + 2.0*rho2) - + c[i][j]/(3.0*rc3)); + ptail_ij = (-1/3.0)*2.0*PI*all[0]*all[1]* + (-a[i][j]*exp(-rc/rho1)* + (rc3 + 3.0*rho1*rc2 + 6.0*rho2*rc + 6.0*rho3) + 2.0*c[i][j]/rc3); + } + return cut[i][j]; } diff --git a/src/pair_buck_coul_cut.cpp b/src/pair_buck_coul_cut.cpp index 9bcec376ea..4d57d22186 100644 --- a/src/pair_buck_coul_cut.cpp +++ b/src/pair_buck_coul_cut.cpp @@ -296,6 +296,36 @@ double PairBuckCoulCut::init_one(int i, int j) buck2[j][i] = buck2[i][j]; offset[j][i] = offset[i][j]; + // compute I,J contribution to long-range tail correction + // count total # of atoms of type I and J via Allreduce + + if (tail_flag) { + int *type = atom->type; + int nlocal = atom->nlocal; + + double count[2],all[2]; + count[0] = count[1] = 0.0; + for (int k = 0; k < nlocal; k++) { + if (type[k] == i) count[0] += 1.0; + if (type[k] == j) count[1] += 1.0; + } + MPI_Allreduce(count,all,2,MPI_DOUBLE,MPI_SUM,world); + + double PI = 4.0*atan(1.0); + double rho1 = rho[i][j]; + double rho2 = rho1*rho1; + double rho3 = rho2*rho1; + double rc = cut_lj[i][j]; + double rc2 = rc*rc; + double rc3 = rc2*rc; + etail_ij = 2.0*PI*all[0]*all[1]* + (a[i][j]*exp(-rc/rho1)*rho1*(rc2 + 2.0*rho1*rc + 2.0*rho2) - + c[i][j]/(3.0*rc3)); + ptail_ij = (-1/3.0)*2.0*PI*all[0]*all[1]* + (-a[i][j]*exp(-rc/rho1)* + (rc3 + 3.0*rho1*rc2 + 6.0*rho2*rc + 6.0*rho3) + 2.0*c[i][j]/rc3); + } + return cut; }