From 4fbc4692aa3f0b7c021a481b282a95f9e751146f Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 5 Oct 2012 14:41:25 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8907 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/KSPACE/pppm_disp.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 118c92d754..7cc5059e5f 100755 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -2646,24 +2646,27 @@ void PPPMDisp::set_grid_6() Calculate the sum of the squared dispersion coefficients and other related quantities required for the calculations ------------------------------------------------------------------------- */ + void PPPMDisp::calc_csum() { - csumij = 0.0; csum = 0.0; + int ntypes = atom->ntypes; - int neach[ntypes+1]; int i,j,k; + delete [] cii; cii = new double[ntypes +1]; for (i = 0; i<=ntypes; i++) cii[i] = 0.0; delete [] csumi; csumi = new double[ntypes +1]; for (i = 0; i<=ntypes; i++) csumi[i] = 0.0; + int *neach = new int[ntypes+1]; for (i = 0; i<=ntypes; i++) neach[i] = 0; - int tmp; + //the following variables are needed to distinguish between arithmetic // and geometric mixing + double mix1; // scales 20/16 to 4 int mix2; // shifts the value to the sigma^3 value int mix3; // shifts the value to the right atom type @@ -2680,18 +2683,24 @@ void PPPMDisp::calc_csum() for (i = 1; i <= ntypes; i++) { cii[i] = mix1*B[mix3*i+mix2]*B[mix3*i+mix2]; } + + int tmp; for (i = 0; i < atom->nlocal; i++) { tmp = atom->type[i]; neach[tmp]++; csum += mix1*B[mix3*tmp+mix2]*B[mix3*tmp+mix2]; } + double tmp2; MPI_Allreduce(&csum,&tmp2,1,MPI_DOUBLE,MPI_SUM,world); csum = tmp2; csumflag = 1; - int neach_all[ntypes+1]; + + int *neach_all = new int[ntypes+1]; MPI_Allreduce(neach,neach_all,ntypes+1,MPI_INT,MPI_SUM,world); + // copmute csumij and csumi + if (function[1]){ for (i=1; i<=ntypes; i++) { for (j=1; j<=ntypes; j++) { @@ -2709,6 +2718,9 @@ void PPPMDisp::calc_csum() } } } + + delete [] neach; + delete [] neach_all; } /* ----------------------------------------------------------------------