From 42e8bfbcaf954bfceedcc929bfae606617e3771b Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 3 Dec 2020 10:28:03 -0700 Subject: [PATCH 01/51] first step to flip sign of FFTs --- src/KSPACE/pppm.cpp | 94 +++++++++++----------- src/KSPACE/pppm_dipole.cpp | 159 ++++++++++++++++--------------------- src/KSPACE/pppm_disp.cpp | 137 ++++++++++++++++---------------- 3 files changed, 184 insertions(+), 206 deletions(-) diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index de665f7f0f..80f9cc4312 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -51,6 +51,7 @@ using namespace MathSpecial; enum{REVERSE_RHO}; enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; +enum{FORWARD=-1,BACKWARD=1}; #ifdef FFT_SINGLE #define ZEROF 0.0f @@ -2010,7 +2011,7 @@ void PPPM::poisson_ik() work1[n++] = ZEROF; } - fft1->compute(work1,work1,1); + fft1->compute(work1,work1,FORWARD); // global energy and virial contribution @@ -2056,7 +2057,7 @@ void PPPM::poisson_ik() return; } - // compute gradients of V(r) in each of 3 dims by transformimg -ik*V(k) + // compute gradients of V(r) in each of 3 dims by transformimg ik*V(k) // FFT leaves data in 3d brick decomposition // copy it into inner portion of vdx,vdy,vdz arrays @@ -2066,12 +2067,12 @@ void PPPM::poisson_ik() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work2[n] = fkx[i]*work1[n+1]; - work2[n+1] = -fkx[i]*work1[n]; + work2[n] = -fkx[i]*work1[n+1]; + work2[n+1] = fkx[i]*work1[n]; n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2087,12 +2088,12 @@ void PPPM::poisson_ik() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work2[n] = fky[j]*work1[n+1]; - work2[n+1] = -fky[j]*work1[n]; + work2[n] = -fky[j]*work1[n+1]; + work2[n+1] = fky[j]*work1[n]; n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2108,12 +2109,12 @@ void PPPM::poisson_ik() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work2[n] = fkz[k]*work1[n+1]; - work2[n+1] = -fkz[k]*work1[n]; + work2[n] = -fkz[k]*work1[n+1]; + work2[n+1] = fkz[k]*work1[n]; n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2132,7 +2133,7 @@ void PPPM::poisson_ik_triclinic() { int i,j,k,n; - // compute gradients of V(r) in each of 3 dims by transformimg -ik*V(k) + // compute gradients of V(r) in each of 3 dims by transformimg ik*V(k) // FFT leaves data in 3d brick decomposition // copy it into inner portion of vdx,vdy,vdz arrays @@ -2140,12 +2141,12 @@ void PPPM::poisson_ik_triclinic() n = 0; for (i = 0; i < nfft; i++) { - work2[n] = fkx[i]*work1[n+1]; - work2[n+1] = -fkx[i]*work1[n]; + work2[n] = -fkx[i]*work1[n+1]; + work2[n+1] = fkx[i]*work1[n]; n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2159,12 +2160,12 @@ void PPPM::poisson_ik_triclinic() n = 0; for (i = 0; i < nfft; i++) { - work2[n] = fky[i]*work1[n+1]; - work2[n+1] = -fky[i]*work1[n]; + work2[n] = -fky[i]*work1[n+1]; + work2[n+1] = fky[i]*work1[n]; n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2178,12 +2179,12 @@ void PPPM::poisson_ik_triclinic() n = 0; for (i = 0; i < nfft; i++) { - work2[n] = fkz[i]*work1[n+1]; - work2[n+1] = -fkz[i]*work1[n]; + work2[n] = -fkz[i]*work1[n+1]; + work2[n+1] = fkz[i]*work1[n]; n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2211,7 +2212,7 @@ void PPPM::poisson_ad() work1[n++] = ZEROF; } - fft1->compute(work1,work1,1); + fft1->compute(work1,work1,FORWARD); // global energy and virial contribution @@ -2257,7 +2258,7 @@ void PPPM::poisson_ad() n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2286,7 +2287,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2308,7 +2309,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2325,7 +2326,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2342,7 +2343,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2359,7 +2360,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2376,7 +2377,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2393,7 +2394,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,-1); + fft2->compute(work2,work2,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -3002,11 +3003,11 @@ int PPPM::timing_1d(int n, double &time1d) time1 = MPI_Wtime(); for (int i = 0; i < n; i++) { - fft1->timing1d(work1,nfft_both,1); - fft2->timing1d(work1,nfft_both,-1); + fft1->timing1d(work1,nfft_both,FORWARD); + fft2->timing1d(work1,nfft_both,BACKWARD); if (differentiation_flag != 1) { - fft2->timing1d(work1,nfft_both,-1); - fft2->timing1d(work1,nfft_both,-1); + fft2->timing1d(work1,nfft_both,BACKWARD); + fft2->timing1d(work1,nfft_both,BACKWARD); } } @@ -3032,11 +3033,11 @@ int PPPM::timing_3d(int n, double &time3d) time1 = MPI_Wtime(); for (int i = 0; i < n; i++) { - fft1->compute(work1,work1,1); - fft2->compute(work1,work1,-1); + fft1->compute(work1,work1,FORWARD); + fft2->compute(work1,work1,BACKWARD); if (differentiation_flag != 1) { - fft2->compute(work1,work1,-1); - fft2->compute(work1,work1,-1); + fft2->compute(work1,work1,BACKWARD); + fft2->compute(work1,work1,BACKWARD); } } @@ -3313,7 +3314,7 @@ void PPPM::poisson_groups(int AA_flag) work_A[n++] = ZEROF; } - fft1->compute(work_A,work_A,1); + fft1->compute(work_A,work_A,FORWARD); // group B @@ -3323,7 +3324,7 @@ void PPPM::poisson_groups(int AA_flag) work_B[n++] = ZEROF; } - fft1->compute(work_B,work_B,1); + fft1->compute(work_B,work_B,FORWARD); // group-group energy and force contribution, // keep everything in reciprocal space so @@ -3343,7 +3344,6 @@ void PPPM::poisson_groups(int AA_flag) if (AA_flag) return; - // multiply by Green's function and s2 // (only for work_A so it is not squared below) @@ -3368,7 +3368,7 @@ void PPPM::poisson_groups(int AA_flag) for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - partial_group = work_A[n+1]*work_B[n] - work_A[n]*work_B[n+1]; + partial_group = work_A[n]*work_B[n+1] - work_A[n+1]*work_B[n]; f2group[0] += fkx[i] * partial_group; n += 2; } @@ -3379,7 +3379,7 @@ void PPPM::poisson_groups(int AA_flag) for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - partial_group = work_A[n+1]*work_B[n] - work_A[n]*work_B[n+1]; + partial_group = work_A[n]*work_B[n+1] - work_A[n+1]*work_B[n]; f2group[1] += fky[j] * partial_group; n += 2; } @@ -3390,7 +3390,7 @@ void PPPM::poisson_groups(int AA_flag) for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - partial_group = work_A[n+1]*work_B[n] - work_A[n]*work_B[n+1]; + partial_group = work_A[n]*work_B[n+1] - work_A[n+1]*work_B[n]; f2group[2] += fkz[k] * partial_group; n += 2; } @@ -3416,7 +3416,7 @@ void PPPM::poisson_groups_triclinic() n = 0; for (i = 0; i < nfft; i++) { - partial_group = work_A[n+1]*work_B[n] - work_A[n]*work_B[n+1]; + partial_group = work_A[n]*work_B[n+1] - work_A[n+1]*work_B[n]; f2group[0] += fkx[i] * partial_group; n += 2; } @@ -3425,7 +3425,7 @@ void PPPM::poisson_groups_triclinic() n = 0; for (i = 0; i < nfft; i++) { - partial_group = work_A[n+1]*work_B[n] - work_A[n]*work_B[n+1]; + partial_group = work_A[n]*work_B[n+1] - work_A[n+1]*work_B[n]; f2group[1] += fky[i] * partial_group; n += 2; } @@ -3434,7 +3434,7 @@ void PPPM::poisson_groups_triclinic() n = 0; for (i = 0; i < nfft; i++) { - partial_group = work_A[n+1]*work_B[n] - work_A[n]*work_B[n+1]; + partial_group = work_A[n]*work_B[n+1] - work_A[n+1]*work_B[n]; f2group[2] += fkz[i] * partial_group; n += 2; } diff --git a/src/KSPACE/pppm_dipole.cpp b/src/KSPACE/pppm_dipole.cpp index b433be9373..27cad11ab3 100644 --- a/src/KSPACE/pppm_dipole.cpp +++ b/src/KSPACE/pppm_dipole.cpp @@ -46,6 +46,7 @@ using namespace MathSpecial; enum{REVERSE_MU}; enum{FORWARD_MU,FORWARD_MU_PERATOM}; +enum{FORWARD=-1,BACKWARD=1}; #ifdef FFT_SINGLE #define ZEROF 0.0f @@ -462,8 +463,8 @@ void PPPMDipole::compute(int eflag, int vflag) // extra per-atom energy/virial communication if (evflag_atom) - gc->forward_comm_kspace(this,18,sizeof(FFT_SCALAR),FORWARD_MU_PERATOM, - gc_buf1,gc_buf2,MPI_FFT_SCALAR); + gc_dipole->forward_comm_kspace(this,18,sizeof(FFT_SCALAR),FORWARD_MU_PERATOM, + gc_buf1,gc_buf2,MPI_FFT_SCALAR); // calculate the force on my particles @@ -610,7 +611,7 @@ void PPPMDipole::allocate() nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in, nxlo_out,nxhi_out,nylo_out,nyhi_out,nzlo_out,nzhi_out); - gc->setup(ngc_buf1,ngc_buf2); + gc_dipole->setup(ngc_buf1,ngc_buf2); npergrid = 9; @@ -643,29 +644,10 @@ void PPPMDipole::deallocate() memory->destroy(densityy_fft_dipole); memory->destroy(densityz_fft_dipole); - memory->destroy(greensfn); - memory->destroy(work1); - memory->destroy(work2); memory->destroy(work3); memory->destroy(work4); - memory->destroy(vg); - memory->destroy1d_offset(fkx,nxlo_fft); - memory->destroy1d_offset(fky,nylo_fft); - memory->destroy1d_offset(fkz,nzlo_fft); - - memory->destroy(gf_b); - memory->destroy2d_offset(rho1d,-order_allocated/2); - memory->destroy2d_offset(drho1d,-order_allocated/2); - memory->destroy2d_offset(rho_coeff,(1-order_allocated)/2); - memory->destroy2d_offset(drho_coeff,(1-order_allocated)/2); - - delete fft1; - delete fft2; - delete remap; delete gc_dipole; - memory->destroy(gc_buf1); - memory->destroy(gc_buf2); } /* ---------------------------------------------------------------------- @@ -1312,9 +1294,9 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft1->compute(work1,work1,1); - fft1->compute(work2,work2,1); - fft1->compute(work3,work3,1); + fft1->compute(work1,work1,FORWARD); + fft1->compute(work2,work2,FORWARD); + fft1->compute(work3,work3,FORWARD); // global energy and virial contribution @@ -1390,7 +1372,7 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1411,7 +1393,7 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1432,7 +1414,7 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1448,12 +1430,12 @@ void PPPMDipole::poisson_ik_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkx[i]*fkx[i]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); - work4[n+1] = -fkx[i]*fkx[i]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); + work4[n] = -fkx[i]*fkx[i]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); + work4[n+1] = +fkx[i]*fkx[i]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); n += 2; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1469,12 +1451,12 @@ void PPPMDipole::poisson_ik_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fky[j]*fky[j]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); - work4[n+1] = -fky[j]*fky[j]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); + work4[n] = -fky[j]*fky[j]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); + work4[n+1] = fky[j]*fky[j]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); n += 2; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1490,12 +1472,12 @@ void PPPMDipole::poisson_ik_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkz[k]*fkz[k]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); - work4[n+1] = -fkz[k]*fkz[k]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); + work4[n] = -fkz[k]*fkz[k]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); + work4[n+1] = fkz[k]*fkz[k]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); n += 2; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1511,12 +1493,12 @@ void PPPMDipole::poisson_ik_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkx[i]*fky[j]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); - work4[n+1] = -fkx[i]*fky[j]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); + work4[n] = -fkx[i]*fky[j]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); + work4[n+1] = fkx[i]*fky[j]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); n += 2; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1532,12 +1514,12 @@ void PPPMDipole::poisson_ik_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkx[i]*fkz[k]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); - work4[n+1] = -fkx[i]*fkz[k]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); + work4[n] = -fkx[i]*fkz[k]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); + work4[n+1] = fkx[i]*fkz[k]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); n += 2; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1553,12 +1535,12 @@ void PPPMDipole::poisson_ik_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fky[j]*fkz[k]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); - work4[n+1] = -fky[j]*fkz[k]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); + work4[n] = -fky[j]*fkz[k]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); + work4[n+1] = fky[j]*fkz[k]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); n += 2; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1594,7 +1576,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1617,7 +1599,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1640,7 +1622,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1663,7 +1645,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1686,7 +1668,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1709,7 +1691,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1732,7 +1714,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1755,7 +1737,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1778,7 +1760,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1801,7 +1783,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1824,7 +1806,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1847,7 +1829,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1870,7 +1852,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1893,7 +1875,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1916,7 +1898,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1939,7 +1921,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1962,7 +1944,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1985,7 +1967,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,-1); + fft2->compute(work4,work4,BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2013,7 +1995,6 @@ void PPPMDipole::fieldforce_ik_dipole() // (dx,dy,dz) = distance to "lower left" grid pt // (mx,my,mz) = global coords of moving stencil pt - double **mu = atom->mu; double **x = atom->x; double **f = atom->f; @@ -2417,18 +2398,18 @@ int PPPMDipole::timing_1d(int n, double &time1d) time1 = MPI_Wtime(); for (int i = 0; i < n; i++) { - fft1->timing1d(work1,nfft_both,1); - fft1->timing1d(work1,nfft_both,1); - fft1->timing1d(work1,nfft_both,1); - fft2->timing1d(work1,nfft_both,-1); - fft2->timing1d(work1,nfft_both,-1); - fft2->timing1d(work1,nfft_both,-1); - fft2->timing1d(work1,nfft_both,-1); - fft2->timing1d(work1,nfft_both,-1); - fft2->timing1d(work1,nfft_both,-1); - fft2->timing1d(work1,nfft_both,-1); - fft2->timing1d(work1,nfft_both,-1); - fft2->timing1d(work1,nfft_both,-1); + fft1->timing1d(work1,nfft_both,FORWARD); + fft1->timing1d(work1,nfft_both,FORWARD); + fft1->timing1d(work1,nfft_both,FORWARD); + fft2->timing1d(work1,nfft_both,BACKWARD); + fft2->timing1d(work1,nfft_both,BACKWARD); + fft2->timing1d(work1,nfft_both,BACKWARD); + fft2->timing1d(work1,nfft_both,BACKWARD); + fft2->timing1d(work1,nfft_both,BACKWARD); + fft2->timing1d(work1,nfft_both,BACKWARD); + fft2->timing1d(work1,nfft_both,BACKWARD); + fft2->timing1d(work1,nfft_both,BACKWARD); + fft2->timing1d(work1,nfft_both,BACKWARD); } MPI_Barrier(world); @@ -2452,18 +2433,18 @@ int PPPMDipole::timing_3d(int n, double &time3d) time1 = MPI_Wtime(); for (int i = 0; i < n; i++) { - fft1->compute(work1,work1,1); - fft1->compute(work1,work1,1); - fft1->compute(work1,work1,1); - fft2->compute(work1,work1,-1); - fft2->compute(work1,work1,-1); - fft2->compute(work1,work1,-1); - fft2->compute(work1,work1,-1); - fft2->compute(work1,work1,-1); - fft2->compute(work1,work1,-1); - fft2->compute(work1,work1,-1); - fft2->compute(work1,work1,-1); - fft2->compute(work1,work1,-1); + fft1->compute(work1,work1,FORWARD); + fft1->compute(work1,work1,FORWARD); + fft1->compute(work1,work1,FORWARD); + fft2->compute(work1,work1,BACKWARD); + fft2->compute(work1,work1,BACKWARD); + fft2->compute(work1,work1,BACKWARD); + fft2->compute(work1,work1,BACKWARD); + fft2->compute(work1,work1,BACKWARD); + fft2->compute(work1,work1,BACKWARD); + fft2->compute(work1,work1,BACKWARD); + fft2->compute(work1,work1,BACKWARD); + fft2->compute(work1,work1,BACKWARD); } MPI_Barrier(world); diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 0c412cc923..c4cc456487 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -51,6 +51,7 @@ enum{FORWARD_IK, FORWARD_AD, FORWARD_IK_PERATOM, FORWARD_AD_PERATOM, FORWARD_IK_A, FORWARD_AD_A, FORWARD_IK_PERATOM_A, FORWARD_AD_PERATOM_A, FORWARD_IK_NONE, FORWARD_AD_NONE, FORWARD_IK_PERATOM_NONE, FORWARD_AD_PERATOM_NONE}; +enum{FORWARD=-1,BACKWARD=1}; #ifdef FFT_SINGLE #define ZEROF 0.0f @@ -4555,7 +4556,7 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, wk1[n++] = ZEROF; } - ft1->compute(wk1,wk1,1); + ft1->compute(wk1,wk1,FORWARD); // if requested, compute energy and virial contribution @@ -4600,12 +4601,12 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (k = nzlo_ft; k <= nzhi_ft; k++) for (j = nylo_ft; j <= nyhi_ft; j++) for (i = nxlo_ft; i <= nxhi_ft; i++) { - wk2[n] = 0.5*(kx[i]-kx2[i])*wk1[n+1] + 0.5*(ky[j]-ky2[j])*wk1[n]; - wk2[n+1] = -0.5*(kx[i]-kx2[i])*wk1[n] + 0.5*(ky[j]-ky2[j])*wk1[n+1]; + wk2[n] = -0.5*(kx[i]-kx2[i])*wk1[n+1] + 0.5*(ky[j]-ky2[j])*wk1[n]; + wk2[n+1] = 0.5*(kx[i]-kx2[i])*wk1[n] + 0.5*(ky[j]-ky2[j])*wk1[n+1]; n += 2; } - ft2->compute(wk2,wk2,-1); + ft2->compute(wk2,wk2,BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4622,13 +4623,12 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (k = nzlo_ft; k <= nzhi_ft; k++) for (j = nylo_ft; j <= nyhi_ft; j++) for (i = nxlo_ft; i <= nxhi_ft; i++) { - wk2[n] = kz[k]*wk1[n+1]; - wk2[n+1] = -kz[k]*wk1[n]; + wk2[n] = -kz[k]*wk1[n+1]; + wk2[n+1] = kz[k]*wk1[n]; n += 2; } - ft2->compute(wk2,wk2,-1); - + ft2->compute(wk2,wk2,BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4647,12 +4647,12 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (k = nzlo_ft; k <= nzhi_ft; k++) for (j = nylo_ft; j <= nyhi_ft; j++) for (i = nxlo_ft; i <= nxhi_ft; i++) { - wk2[n] = 0.5*(kz[k]-kz2[k])*wk1[n+1] - wk1[n+1]; - wk2[n+1] = -0.5*(kz[k]-kz2[k])*wk1[n] + wk1[n]; + wk2[n] = -0.5*(kz[k]-kz2[k])*wk1[n+1] - wk1[n+1]; + wk2[n+1] = 0.5*(kz[k]-kz2[k])*wk1[n] + wk1[n]; n += 2; } - ft2->compute(wk2,wk2,-1); + ft2->compute(wk2,wk2,BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4696,7 +4696,7 @@ void PPPMDisp::poisson_ad(FFT_SCALAR* wk1, FFT_SCALAR* wk2, wk1[n++] = ZEROF; } - ft1->compute(wk1,wk1,1); + ft1->compute(wk1,wk1,FORWARD); // if requested, compute energy and virial contribution @@ -4739,10 +4739,9 @@ void PPPMDisp::poisson_ad(FFT_SCALAR* wk1, FFT_SCALAR* wk2, wk2[n] = wk1[n]; wk2[n+1] = wk1[n+1]; n += 2; - } - - ft2->compute(wk2,wk2,-1); + } + ft2->compute(wk2,wk2,BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4781,7 +4780,7 @@ void PPPMDisp:: poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT n += 2; } - ft2->compute(wk2,wk2,-1); + ft2->compute(wk2,wk2,BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4800,7 +4799,7 @@ void PPPMDisp:: poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT n += 2; } - ft2->compute(wk2,wk2,-1); + ft2->compute(wk2,wk2,BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4819,7 +4818,7 @@ void PPPMDisp:: poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT n += 2; } - ft2->compute(wk2,wk2,-1); + ft2->compute(wk2,wk2,BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4863,7 +4862,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work1_6[n++] = dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,1); + fft1_6->compute(work1_6,work1_6,FORWARD); } // two transforms are required when energies and pressures are // calculated @@ -4876,8 +4875,8 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work2_6[n++] = dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,1); - fft1_6->compute(work2_6,work2_6,1); + fft1_6->compute(work1_6,work1_6,FORWARD); + fft1_6->compute(work2_6,work2_6,FORWARD); double s2 = scaleinv*scaleinv; @@ -4927,7 +4926,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -4948,7 +4947,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -4969,7 +4968,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -4989,7 +4988,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5037,7 +5036,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work1_6[n++] = dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,1); + fft1_6->compute(work1_6,work1_6,FORWARD); } // two transforms are required when energies and pressures are calculated @@ -5052,8 +5051,8 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, } - fft1_6->compute(work1_6,work1_6,1); - fft1_6->compute(work2_6,work2_6,1); + fft1_6->compute(work1_6,work1_6,FORWARD); + fft1_6->compute(work2_6,work2_6,FORWARD); double s2 = scaleinv*scaleinv; @@ -5106,7 +5105,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5127,7 +5126,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5148,7 +5147,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5168,7 +5167,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5213,7 +5212,7 @@ poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work1_6[n++] = dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,1); + fft1_6->compute(work1_6,work1_6,FORWARD); } // two transforms are required when energies and pressures are calculated @@ -5227,8 +5226,8 @@ poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work2_6[n++] = dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,1); - fft1_6->compute(work2_6,work2_6,1); + fft1_6->compute(work1_6,work1_6,FORWARD); + fft1_6->compute(work2_6,work2_6,FORWARD); double s2 = scaleinv*scaleinv; @@ -5270,7 +5269,7 @@ poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5312,7 +5311,7 @@ poisson_none_ad(int n1, int n2, FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work1_6[n++] = dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,1); + fft1_6->compute(work1_6,work1_6,FORWARD); } // two transforms are required when energies and pressures are calculated @@ -5326,8 +5325,8 @@ poisson_none_ad(int n1, int n2, FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work2_6[n++] = dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,1); - fft1_6->compute(work2_6,work2_6,1); + fft1_6->compute(work1_6,work1_6,FORWARD); + fft1_6->compute(work2_6,work2_6,FORWARD); double s2 = scaleinv*scaleinv; @@ -5374,7 +5373,7 @@ poisson_none_ad(int n1, int n2, FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5410,7 +5409,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5429,7 +5428,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5448,7 +5447,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5467,7 +5466,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5486,7 +5485,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5505,7 +5504,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5541,7 +5540,7 @@ poisson_none_peratom(int n1, int n2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5560,7 +5559,7 @@ poisson_none_peratom(int n1, int n2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5579,7 +5578,7 @@ poisson_none_peratom(int n1, int n2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5598,7 +5597,7 @@ poisson_none_peratom(int n1, int n2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5617,7 +5616,7 @@ poisson_none_peratom(int n1, int n2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5636,7 +5635,7 @@ poisson_none_peratom(int n1, int n2, n += 2; } - fft2_6->compute(work2_6,work2_6,-1); + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -8153,11 +8152,11 @@ int PPPMDisp::timing_1d(int n, double &time1d) if (function[0]) { for (int i = 0; i < n; i++) { - fft1->timing1d(work1,nfft_both,1); - fft2->timing1d(work1,nfft_both,-1); + fft1->timing1d(work1,nfft_both,FORWARD); + fft2->timing1d(work1,nfft_both,BACKWARD); if (differentiation_flag != 1){ - fft2->timing1d(work1,nfft_both,-1); - fft2->timing1d(work1,nfft_both,-1); + fft2->timing1d(work1,nfft_both,BACKWARD); + fft2->timing1d(work1,nfft_both,BACKWARD); } } } @@ -8171,11 +8170,11 @@ int PPPMDisp::timing_1d(int n, double &time1d) if (function[1] + function[2] + function[3]) { for (int i = 0; i < n; i++) { - fft1_6->timing1d(work1_6,nfft_both_6,1); - fft2_6->timing1d(work1_6,nfft_both_6,-1); + fft1_6->timing1d(work1_6,nfft_both_6,FORWARD); + fft2_6->timing1d(work1_6,nfft_both_6,BACKWARD); if (differentiation_flag != 1){ - fft2_6->timing1d(work1_6,nfft_both_6,-1); - fft2_6->timing1d(work1_6,nfft_both_6,-1); + fft2_6->timing1d(work1_6,nfft_both_6,BACKWARD); + fft2_6->timing1d(work1_6,nfft_both_6,BACKWARD); } } } @@ -8203,18 +8202,16 @@ int PPPMDisp::timing_3d(int n, double &time3d) if (function[1] + function[2] + function[3]) for (int i = 0; i < 2*nfft_both_6; i++) work1_6[i] = ZEROF; - - MPI_Barrier(world); time1 = MPI_Wtime(); if (function[0]) { for (int i = 0; i < n; i++) { - fft1->compute(work1,work1,1); - fft2->compute(work1,work1,-1); + fft1->compute(work1,work1,FORWARD); + fft2->compute(work1,work1,BACKWARD); if (differentiation_flag != 1) { - fft2->compute(work1,work1,-1); - fft2->compute(work1,work1,-1); + fft2->compute(work1,work1,BACKWARD); + fft2->compute(work1,work1,BACKWARD); } } } @@ -8228,11 +8225,11 @@ int PPPMDisp::timing_3d(int n, double &time3d) if (function[1] + function[2] + function[3]) { for (int i = 0; i < n; i++) { - fft1_6->compute(work1_6,work1_6,1); - fft2_6->compute(work1_6,work1_6,-1); + fft1_6->compute(work1_6,work1_6,FORWARD); + fft2_6->compute(work1_6,work1_6,BACKWARD); if (differentiation_flag != 1) { - fft2_6->compute(work1_6,work1_6,-1); - fft2_6->compute(work1_6,work1_6,-1); + fft2_6->compute(work1_6,work1_6,BACKWARD); + fft2_6->compute(work1_6,work1_6,BACKWARD); } } } From fddf80b972165c092655ee71ab49bebef2baeae9 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Fri, 4 Dec 2020 11:01:36 -0700 Subject: [PATCH 02/51] further changes to pppm/disp for sign flip --- src/KSPACE/pppm_disp.cpp | 624 +++++++++++++++++++++------------------ 1 file changed, 329 insertions(+), 295 deletions(-) diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index c4cc456487..9d8a9906e4 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -45,11 +45,11 @@ using namespace MathConst; #define LARGE 10000.0 #define EPS_HOC 1.0e-7 -enum{REVERSE_RHO, REVERSE_RHO_G, REVERSE_RHO_A, REVERSE_RHO_NONE}; -enum{FORWARD_IK, FORWARD_AD, FORWARD_IK_PERATOM, FORWARD_AD_PERATOM, - FORWARD_IK_G, FORWARD_AD_G, FORWARD_IK_PERATOM_G, FORWARD_AD_PERATOM_G, - FORWARD_IK_A, FORWARD_AD_A, FORWARD_IK_PERATOM_A, FORWARD_AD_PERATOM_A, - FORWARD_IK_NONE, FORWARD_AD_NONE, FORWARD_IK_PERATOM_NONE, +enum{REVERSE_RHO,REVERSE_RHO_G,REVERSE_RHO_A,REVERSE_RHO_NONE}; +enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM, + FORWARD_IK_G,FORWARD_AD_G,FORWARD_IK_PERATOM_G,FORWARD_AD_PERATOM_G, + FORWARD_IK_A,FORWARD_AD_A,FORWARD_IK_PERATOM_A,FORWARD_AD_PERATOM_A, + FORWARD_IK_NONE,FORWARD_AD_NONE,FORWARD_IK_PERATOM_NONE, FORWARD_AD_PERATOM_NONE}; enum{FORWARD=-1,BACKWARD=1}; @@ -305,13 +305,13 @@ void PPPMDisp::init() cutoff_lj = *p_cutoff_lj; double tmp2; - MPI_Allreduce(&cutoff, &tmp2,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&cutoff,&tmp2,1,MPI_DOUBLE,MPI_SUM,world); // check out which types of potentials will have to be calculated int ewald_order = ptr ? *((int *) ptr) : 1<<1; int ewald_mix = ptr ? *((int *) pair->extract("ewald_mix",tmp)) : Pair::GEOMETRIC; - memset(function, 0, EWALD_FUNCS*sizeof(int)); + memset(function,0,EWALD_FUNCS*sizeof(int)); for (int i=0; i<=EWALD_MAXORDER; ++i) // transcribe order if (ewald_order&(1<= OFFSET || ny_pppm >= OFFSET || nz_pppm >= OFFSET) error->all(FLERR,"PPPMDisp Coulomb grid is too large"); - set_fft_parameters(nx_pppm, ny_pppm, nz_pppm, - nxlo_fft, nylo_fft, nzlo_fft, - nxhi_fft, nyhi_fft, nzhi_fft, - nxlo_in, nylo_in, nzlo_in, - nxhi_in, nyhi_in, nzhi_in, - nxlo_out, nylo_out, nzlo_out, - nxhi_out, nyhi_out, nzhi_out, - nlower, nupper, - ngrid, nfft, nfft_both, - shift, shiftone, order); + set_fft_parameters(nx_pppm,ny_pppm,nz_pppm, + nxlo_fft,nylo_fft,nzlo_fft, + nxhi_fft,nyhi_fft,nzhi_fft, + nxlo_in,nylo_in,nzlo_in, + nxhi_in,nyhi_in,nzhi_in, + nxlo_out,nylo_out,nzlo_out, + nxhi_out,nyhi_out,nzhi_out, + nlower,nupper, + ngrid,nfft,nfft_both, + shift,shiftone,order); if (overlap_allowed) break; @@ -485,7 +485,7 @@ void PPPMDisp::init() acc/two_charge_force); mesg += " using " LMP_FFT_PREC " precision " LMP_FFT_LIB "\n"; mesg += fmt::format(" 3d grid and FFT values/proc = {} {}\n", - ngrid_max, nfft_both_max); + ngrid_max,nfft_both_max); utils::logmesg(lmp,mesg); } } @@ -506,16 +506,16 @@ void PPPMDisp::init() if (nx_pppm_6 >= OFFSET || ny_pppm_6 >= OFFSET || nz_pppm_6 >= OFFSET) error->all(FLERR,"PPPMDisp Dispersion grid is too large"); - set_fft_parameters(nx_pppm_6, ny_pppm_6, nz_pppm_6, - nxlo_fft_6, nylo_fft_6, nzlo_fft_6, - nxhi_fft_6, nyhi_fft_6, nzhi_fft_6, - nxlo_in_6, nylo_in_6, nzlo_in_6, - nxhi_in_6, nyhi_in_6, nzhi_in_6, - nxlo_out_6, nylo_out_6, nzlo_out_6, - nxhi_out_6, nyhi_out_6, nzhi_out_6, - nlower_6, nupper_6, - ngrid_6, nfft_6, nfft_both_6, - shift_6, shiftone_6, order_6); + set_fft_parameters(nx_pppm_6,ny_pppm_6,nz_pppm_6, + nxlo_fft_6,nylo_fft_6,nzlo_fft_6, + nxhi_fft_6,nyhi_fft_6,nzhi_fft_6, + nxlo_in_6,nylo_in_6,nzlo_in_6, + nxhi_in_6,nyhi_in_6,nzhi_in_6, + nxlo_out_6,nylo_out_6,nzlo_out_6, + nxhi_out_6,nyhi_out_6,nzhi_out_6, + nlower_6,nupper_6, + ngrid_6,nfft_6,nfft_both_6, + shift_6,shiftone_6,order_6); if (overlap_allowed) break; @@ -548,8 +548,8 @@ void PPPMDisp::init() // calculate the final accuracy - double acc, acc_real, acc_kspace; - final_accuracy_6(acc, acc_real, acc_kspace); + double acc,acc_real,acc_kspace; + final_accuracy_6(acc,acc_real,acc_kspace); // print stats @@ -559,7 +559,7 @@ void PPPMDisp::init() if (me == 0) { std::string mesg = fmt::format(" Dispersion G vector (1/distance)= " - "{:.8}\n", g_ewald_6); + "{:.8}\n",g_ewald_6); mesg += fmt::format(" Dispersion grid = {} {} {}\n", nx_pppm_6,ny_pppm_6,nz_pppm_6); mesg += fmt::format(" Dispersion stencil order = {}\n",order_6); @@ -569,7 +569,7 @@ void PPPMDisp::init() "= {:.8}\n",acc/two_charge_force); mesg += " using " LMP_FFT_PREC " precision " LMP_FFT_LIB "\n"; mesg += fmt::format(" 3d grid and FFT values/proc = {} {}\n", - ngrid_max, nfft_both_max); + ngrid_max,nfft_both_max); utils::logmesg(lmp,mesg); } } @@ -582,24 +582,24 @@ void PPPMDisp::init() // pre-compute 1d charge distribution coefficients if (function[0]) { - compute_gf_denom(gf_b, order); - compute_rho_coeff(rho_coeff, drho_coeff, order); + compute_gf_denom(gf_b,order); + compute_rho_coeff(rho_coeff,drho_coeff,order); if (differentiation_flag == 1) - compute_sf_precoeff(nx_pppm, ny_pppm, nz_pppm, order, - nxlo_fft, nylo_fft, nzlo_fft, - nxhi_fft, nyhi_fft, nzhi_fft, - sf_precoeff1, sf_precoeff2, sf_precoeff3, - sf_precoeff4, sf_precoeff5, sf_precoeff6); + compute_sf_precoeff(nx_pppm,ny_pppm,nz_pppm,order, + nxlo_fft,nylo_fft,nzlo_fft, + nxhi_fft,nyhi_fft,nzhi_fft, + sf_precoeff1,sf_precoeff2,sf_precoeff3, + sf_precoeff4,sf_precoeff5,sf_precoeff6); } if (function[1] + function[2] + function[3]) { - compute_gf_denom(gf_b_6, order_6); - compute_rho_coeff(rho_coeff_6, drho_coeff_6, order_6); + compute_gf_denom(gf_b_6,order_6); + compute_rho_coeff(rho_coeff_6,drho_coeff_6,order_6); if (differentiation_flag == 1) - compute_sf_precoeff(nx_pppm_6, ny_pppm_6, nz_pppm_6, order_6, - nxlo_fft_6, nylo_fft_6, nzlo_fft_6, - nxhi_fft_6, nyhi_fft_6, nzhi_fft_6, - sf_precoeff1_6, sf_precoeff2_6, sf_precoeff3_6, - sf_precoeff4_6, sf_precoeff5_6, sf_precoeff6_6); + compute_sf_precoeff(nx_pppm_6,ny_pppm_6,nz_pppm_6,order_6, + nxlo_fft_6,nylo_fft_6,nzlo_fft_6, + nxhi_fft_6,nyhi_fft_6,nzhi_fft_6, + sf_precoeff1_6,sf_precoeff2_6,sf_precoeff3_6, + sf_precoeff4_6,sf_precoeff5_6,sf_precoeff6_6); } } @@ -649,7 +649,7 @@ void PPPMDisp::setup() delvolinv = delxinv*delyinv*delzinv; double per; - int i, j, k, n; + int i,j,k,n; for (i = nxlo_fft; i <= nxhi_fft; i++) { per = i - nx_pppm*(2*i/nx_pppm); @@ -716,7 +716,7 @@ void PPPMDisp::setup() delvolinv_6 = delxinv_6*delyinv_6*delzinv_6; double per; - int i, j, k, n; + int i,j,k,n; for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { per = i - nx_pppm_6*(2*i/nx_pppm_6); fkx_6[i] = unitkx*per; @@ -739,8 +739,8 @@ void PPPMDisp::setup() fkz2_6[i] = unitkz*per; } double sqk,vterm; - long double erft, expt,nom, denom; - long double b, bs, bt; + long double erft,expt,nom,denom; + long double b,bs,bt; double rtpi = sqrt(MY_PI); double gewinv = 1/g_ewald_6; n = 0; @@ -799,28 +799,28 @@ void PPPMDisp::setup_grid() // reset portion of global grid that each proc owns if (function[0]) - set_fft_parameters(nx_pppm, ny_pppm, nz_pppm, - nxlo_fft, nylo_fft, nzlo_fft, - nxhi_fft, nyhi_fft, nzhi_fft, - nxlo_in, nylo_in, nzlo_in, - nxhi_in, nyhi_in, nzhi_in, - nxlo_out, nylo_out, nzlo_out, - nxhi_out, nyhi_out, nzhi_out, - nlower, nupper, - ngrid, nfft, nfft_both, - shift, shiftone, order); + set_fft_parameters(nx_pppm,ny_pppm,nz_pppm, + nxlo_fft,nylo_fft,nzlo_fft, + nxhi_fft,nyhi_fft,nzhi_fft, + nxlo_in,nylo_in,nzlo_in, + nxhi_in,nyhi_in,nzhi_in, + nxlo_out,nylo_out,nzlo_out, + nxhi_out,nyhi_out,nzhi_out, + nlower,nupper, + ngrid,nfft,nfft_both, + shift,shiftone,order); if (function[1] + function[2] + function[3]) - set_fft_parameters(nx_pppm_6, ny_pppm_6, nz_pppm_6, - nxlo_fft_6, nylo_fft_6, nzlo_fft_6, - nxhi_fft_6, nyhi_fft_6, nzhi_fft_6, - nxlo_in_6, nylo_in_6, nzlo_in_6, - nxhi_in_6, nyhi_in_6, nzhi_in_6, - nxlo_out_6, nylo_out_6, nzlo_out_6, - nxhi_out_6, nyhi_out_6, nzhi_out_6, - nlower_6, nupper_6, - ngrid_6, nfft_6, nfft_both_6, - shift_6, shiftone_6, order_6); + set_fft_parameters(nx_pppm_6,ny_pppm_6,nz_pppm_6, + nxlo_fft_6,nylo_fft_6,nzlo_fft_6, + nxhi_fft_6,nyhi_fft_6,nzhi_fft_6, + nxlo_in_6,nylo_in_6,nzlo_in_6, + nxhi_in_6,nyhi_in_6,nzhi_in_6, + nxlo_out_6,nylo_out_6,nzlo_out_6, + nxhi_out_6,nyhi_out_6,nzhi_out_6, + nlower_6,nupper_6, + ngrid_6,nfft_6,nfft_both_6, + shift_6,shiftone_6,order_6); // reallocate K-space dependent memory // check if grid communication is now overlapping if not allowed @@ -843,24 +843,24 @@ void PPPMDisp::setup_grid() // pre-compute 1d charge distribution coefficients if (function[0]) { - compute_gf_denom(gf_b, order); - compute_rho_coeff(rho_coeff, drho_coeff, order); + compute_gf_denom(gf_b,order); + compute_rho_coeff(rho_coeff,drho_coeff,order); if (differentiation_flag == 1) - compute_sf_precoeff(nx_pppm, ny_pppm, nz_pppm, order, - nxlo_fft, nylo_fft, nzlo_fft, - nxhi_fft, nyhi_fft, nzhi_fft, - sf_precoeff1, sf_precoeff2, sf_precoeff3, - sf_precoeff4, sf_precoeff5, sf_precoeff6); + compute_sf_precoeff(nx_pppm,ny_pppm,nz_pppm,order, + nxlo_fft,nylo_fft,nzlo_fft, + nxhi_fft,nyhi_fft,nzhi_fft, + sf_precoeff1,sf_precoeff2,sf_precoeff3, + sf_precoeff4,sf_precoeff5,sf_precoeff6); } if (function[1] + function[2] + function[3]) { - compute_gf_denom(gf_b_6, order_6); - compute_rho_coeff(rho_coeff_6, drho_coeff_6, order_6); + compute_gf_denom(gf_b_6,order_6); + compute_rho_coeff(rho_coeff_6,drho_coeff_6,order_6); if (differentiation_flag == 1) - compute_sf_precoeff(nx_pppm_6, ny_pppm_6, nz_pppm_6, order_6, - nxlo_fft_6, nylo_fft_6, nzlo_fft_6, - nxhi_fft_6, nyhi_fft_6, nzhi_fft_6, - sf_precoeff1_6, sf_precoeff2_6, sf_precoeff3_6, - sf_precoeff4_6, sf_precoeff5_6, sf_precoeff6_6); + compute_sf_precoeff(nx_pppm_6,ny_pppm_6,nz_pppm_6,order_6, + nxlo_fft_6,nylo_fft_6,nzlo_fft_6, + nxhi_fft_6,nyhi_fft_6,nzhi_fft_6, + sf_precoeff1_6,sf_precoeff2_6,sf_precoeff3_6, + sf_precoeff4_6,sf_precoeff5_6,sf_precoeff6_6); } // pre-compute volume-dependent coeffs @@ -918,25 +918,25 @@ void PPPMDisp::compute(int eflag, int vflag) // perform calculations for coulomb interactions only - particle_map_c(delxinv, delyinv, delzinv, shift, part2grid, nupper, nlower, - nxlo_out, nylo_out, nzlo_out, nxhi_out, nyhi_out, nzhi_out); + particle_map_c(delxinv,delyinv,delzinv,shift,part2grid,nupper,nlower, + nxlo_out,nylo_out,nzlo_out,nxhi_out,nyhi_out,nzhi_out); make_rho_c(); gc->reverse_comm_kspace(this,1,sizeof(FFT_SCALAR),REVERSE_RHO, gc_buf1,gc_buf2,MPI_FFT_SCALAR); - brick2fft(nxlo_in, nylo_in, nzlo_in, nxhi_in, nyhi_in, nzhi_in, - density_brick, density_fft, work1,remap); + brick2fft(nxlo_in,nylo_in,nzlo_in,nxhi_in,nyhi_in,nzhi_in, + density_brick,density_fft,work1,remap); if (differentiation_flag == 1) { - poisson_ad(work1, work2, density_fft, fft1, fft2, - nx_pppm, ny_pppm, nz_pppm, nfft, - nxlo_fft, nylo_fft, nzlo_fft, nxhi_fft, nyhi_fft, nzhi_fft, - nxlo_in, nylo_in, nzlo_in, nxhi_in, nyhi_in, nzhi_in, - energy_1, greensfn, - virial_1, vg,vg2, - u_brick, v0_brick, v1_brick, v2_brick, v3_brick, v4_brick, v5_brick); + poisson_ad(work1,work2,density_fft,fft1,fft2, + nx_pppm,ny_pppm,nz_pppm,nfft, + nxlo_fft,nylo_fft,nzlo_fft,nxhi_fft,nyhi_fft,nzhi_fft, + nxlo_in,nylo_in,nzlo_in,nxhi_in,nyhi_in,nzhi_in, + energy_1,greensfn, + virial_1,vg,vg2, + u_brick,v0_brick,v1_brick,v2_brick,v3_brick,v4_brick,v5_brick); gc->forward_comm_kspace(this,1,sizeof(FFT_SCALAR),FORWARD_AD, gc_buf1,gc_buf2,MPI_FFT_SCALAR); @@ -948,14 +948,14 @@ void PPPMDisp::compute(int eflag, int vflag) gc_buf1,gc_buf2,MPI_FFT_SCALAR); } else { - poisson_ik(work1, work2, density_fft, fft1, fft2, - nx_pppm, ny_pppm, nz_pppm, nfft, - nxlo_fft, nylo_fft, nzlo_fft, nxhi_fft, nyhi_fft, nzhi_fft, - nxlo_in, nylo_in, nzlo_in, nxhi_in, nyhi_in, nzhi_in, - energy_1, greensfn, - fkx, fky, fkz,fkx2, fky2, fkz2, - vdx_brick, vdy_brick, vdz_brick, virial_1, vg,vg2, - u_brick, v0_brick, v1_brick, v2_brick, v3_brick, v4_brick, v5_brick); + poisson_ik(work1,work2,density_fft,fft1,fft2, + nx_pppm,ny_pppm,nz_pppm,nfft, + nxlo_fft,nylo_fft,nzlo_fft,nxhi_fft,nyhi_fft,nzhi_fft, + nxlo_in,nylo_in,nzlo_in,nxhi_in,nyhi_in,nzhi_in, + energy_1,greensfn, + fkx,fky,fkz,fkx2,fky2,fkz2, + vdx_brick,vdy_brick,vdz_brick,virial_1,vg,vg2, + u_brick,v0_brick,v1_brick,v2_brick,v3_brick,v4_brick,v5_brick); gc->forward_comm_kspace(this,3,sizeof(FFT_SCALAR),FORWARD_IK, gc_buf1,gc_buf2,MPI_FFT_SCALAR); @@ -974,28 +974,28 @@ void PPPMDisp::compute(int eflag, int vflag) // perform calculations for geometric mixing - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, part2grid_6, - nupper_6, nlower_6, - nxlo_out_6, nylo_out_6, nzlo_out_6, - nxhi_out_6, nyhi_out_6, nzhi_out_6); + particle_map(delxinv_6,delyinv_6,delzinv_6,shift_6,part2grid_6, + nupper_6,nlower_6, + nxlo_out_6,nylo_out_6,nzlo_out_6, + nxhi_out_6,nyhi_out_6,nzhi_out_6); make_rho_g(); gc6->reverse_comm_kspace(this,1,sizeof(FFT_SCALAR),REVERSE_RHO_G, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); - brick2fft(nxlo_in_6, nylo_in_6, nzlo_in_6, nxhi_in_6, nyhi_in_6, nzhi_in_6, - density_brick_g, density_fft_g, work1_6,remap_6); + brick2fft(nxlo_in_6,nylo_in_6,nzlo_in_6,nxhi_in_6,nyhi_in_6,nzhi_in_6, + density_brick_g,density_fft_g,work1_6,remap_6); if (differentiation_flag == 1) { - poisson_ad(work1_6, work2_6, density_fft_g, fft1_6, fft2_6, - nx_pppm_6, ny_pppm_6, nz_pppm_6, nfft_6, - nxlo_fft_6, nylo_fft_6, nzlo_fft_6, nxhi_fft_6, nyhi_fft_6, nzhi_fft_6, - nxlo_in_6, nylo_in_6, nzlo_in_6, nxhi_in_6, nyhi_in_6, nzhi_in_6, - energy_6, greensfn_6, - virial_6, vg_6, vg2_6, - u_brick_g, v0_brick_g, v1_brick_g, v2_brick_g, - v3_brick_g, v4_brick_g, v5_brick_g); + poisson_ad(work1_6,work2_6,density_fft_g,fft1_6,fft2_6, + nx_pppm_6,ny_pppm_6,nz_pppm_6,nfft_6, + nxlo_fft_6,nylo_fft_6,nzlo_fft_6,nxhi_fft_6,nyhi_fft_6,nzhi_fft_6, + nxlo_in_6,nylo_in_6,nzlo_in_6,nxhi_in_6,nyhi_in_6,nzhi_in_6, + energy_6,greensfn_6, + virial_6,vg_6,vg2_6, + u_brick_g,v0_brick_g,v1_brick_g,v2_brick_g, + v3_brick_g,v4_brick_g,v5_brick_g); gc6->forward_comm_kspace(this,1,sizeof(FFT_SCALAR),FORWARD_AD_G, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); @@ -1007,15 +1007,15 @@ void PPPMDisp::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); } else { - poisson_ik(work1_6, work2_6, density_fft_g, fft1_6, fft2_6, - nx_pppm_6, ny_pppm_6, nz_pppm_6, nfft_6, - nxlo_fft_6, nylo_fft_6, nzlo_fft_6, nxhi_fft_6, nyhi_fft_6, nzhi_fft_6, - nxlo_in_6, nylo_in_6, nzlo_in_6, nxhi_in_6, nyhi_in_6, nzhi_in_6, - energy_6, greensfn_6, - fkx_6, fky_6, fkz_6,fkx2_6, fky2_6, fkz2_6, - vdx_brick_g, vdy_brick_g, vdz_brick_g, virial_6, vg_6, vg2_6, - u_brick_g, v0_brick_g, v1_brick_g, v2_brick_g, - v3_brick_g, v4_brick_g, v5_brick_g); + poisson_ik(work1_6,work2_6,density_fft_g,fft1_6,fft2_6, + nx_pppm_6,ny_pppm_6,nz_pppm_6,nfft_6, + nxlo_fft_6,nylo_fft_6,nzlo_fft_6,nxhi_fft_6,nyhi_fft_6,nzhi_fft_6, + nxlo_in_6,nylo_in_6,nzlo_in_6,nxhi_in_6,nyhi_in_6,nzhi_in_6, + energy_6,greensfn_6, + fkx_6,fky_6,fkz_6,fkx2_6,fky2_6,fkz2_6, + vdx_brick_g,vdy_brick_g,vdz_brick_g,virial_6,vg_6,vg2_6, + u_brick_g,v0_brick_g,v1_brick_g,v2_brick_g, + v3_brick_g,v4_brick_g,v5_brick_g); gc6->forward_comm_kspace(this,3,sizeof(FFT_SCALAR),FORWARD_IK_G, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); @@ -1034,10 +1034,10 @@ void PPPMDisp::compute(int eflag, int vflag) // perform calculations for arithmetic mixing - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, part2grid_6, - nupper_6, nlower_6, - nxlo_out_6, nylo_out_6, nzlo_out_6, - nxhi_out_6, nyhi_out_6, nzhi_out_6); + particle_map(delxinv_6,delyinv_6,delzinv_6,shift_6,part2grid_6, + nupper_6,nlower_6, + nxlo_out_6,nylo_out_6,nzlo_out_6, + nxhi_out_6,nyhi_out_6,nzhi_out_6); make_rho_a(); @@ -1047,29 +1047,29 @@ void PPPMDisp::compute(int eflag, int vflag) brick2fft_a(); if (differentiation_flag == 1) { - poisson_ad(work1_6, work2_6, density_fft_a3, fft1_6, fft2_6, - nx_pppm_6, ny_pppm_6, nz_pppm_6, nfft_6, - nxlo_fft_6, nylo_fft_6, nzlo_fft_6, nxhi_fft_6, nyhi_fft_6, nzhi_fft_6, - nxlo_in_6, nylo_in_6, nzlo_in_6, nxhi_in_6, nyhi_in_6, nzhi_in_6, - energy_6, greensfn_6, - virial_6, vg_6, vg2_6, - u_brick_a3, v0_brick_a3, v1_brick_a3, v2_brick_a3, - v3_brick_a3, v4_brick_a3, v5_brick_a3); - poisson_2s_ad(density_fft_a0, density_fft_a6, - u_brick_a0, v0_brick_a0, v1_brick_a0, v2_brick_a0, - v3_brick_a0, v4_brick_a0, v5_brick_a0, - u_brick_a6, v0_brick_a6, v1_brick_a6, v2_brick_a6, - v3_brick_a6, v4_brick_a6, v5_brick_a6); - poisson_2s_ad(density_fft_a1, density_fft_a5, - u_brick_a1, v0_brick_a1, v1_brick_a1, v2_brick_a1, - v3_brick_a1, v4_brick_a1, v5_brick_a1, - u_brick_a5, v0_brick_a5, v1_brick_a5, v2_brick_a5, - v3_brick_a5, v4_brick_a5, v5_brick_a5); - poisson_2s_ad(density_fft_a2, density_fft_a4, - u_brick_a2, v0_brick_a2, v1_brick_a2, v2_brick_a2, - v3_brick_a2, v4_brick_a2, v5_brick_a2, - u_brick_a4, v0_brick_a4, v1_brick_a4, v2_brick_a4, - v3_brick_a4, v4_brick_a4, v5_brick_a4); + poisson_ad(work1_6,work2_6,density_fft_a3,fft1_6,fft2_6, + nx_pppm_6,ny_pppm_6,nz_pppm_6,nfft_6, + nxlo_fft_6,nylo_fft_6,nzlo_fft_6,nxhi_fft_6,nyhi_fft_6,nzhi_fft_6, + nxlo_in_6,nylo_in_6,nzlo_in_6,nxhi_in_6,nyhi_in_6,nzhi_in_6, + energy_6,greensfn_6, + virial_6,vg_6,vg2_6, + u_brick_a3,v0_brick_a3,v1_brick_a3,v2_brick_a3, + v3_brick_a3,v4_brick_a3,v5_brick_a3); + poisson_2s_ad(density_fft_a0,density_fft_a6, + u_brick_a0,v0_brick_a0,v1_brick_a0,v2_brick_a0, + v3_brick_a0,v4_brick_a0,v5_brick_a0, + u_brick_a6,v0_brick_a6,v1_brick_a6,v2_brick_a6, + v3_brick_a6,v4_brick_a6,v5_brick_a6); + poisson_2s_ad(density_fft_a1,density_fft_a5, + u_brick_a1,v0_brick_a1,v1_brick_a1,v2_brick_a1, + v3_brick_a1,v4_brick_a1,v5_brick_a1, + u_brick_a5,v0_brick_a5,v1_brick_a5,v2_brick_a5, + v3_brick_a5,v4_brick_a5,v5_brick_a5); + poisson_2s_ad(density_fft_a2,density_fft_a4, + u_brick_a2,v0_brick_a2,v1_brick_a2,v2_brick_a2, + v3_brick_a2,v4_brick_a2,v5_brick_a2, + u_brick_a4,v0_brick_a4,v1_brick_a4,v2_brick_a4, + v3_brick_a4,v4_brick_a4,v5_brick_a4); gc6->forward_comm_kspace(this,7,sizeof(FFT_SCALAR),FORWARD_AD_A, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); @@ -1081,36 +1081,36 @@ void PPPMDisp::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); } else { - poisson_ik(work1_6, work2_6, density_fft_a3, fft1_6, fft2_6, - nx_pppm_6, ny_pppm_6, nz_pppm_6, nfft_6, - nxlo_fft_6, nylo_fft_6, nzlo_fft_6, nxhi_fft_6, nyhi_fft_6, nzhi_fft_6, - nxlo_in_6, nylo_in_6, nzlo_in_6, nxhi_in_6, nyhi_in_6, nzhi_in_6, - energy_6, greensfn_6, - fkx_6, fky_6, fkz_6,fkx2_6, fky2_6, fkz2_6, - vdx_brick_a3, vdy_brick_a3, vdz_brick_a3, virial_6, vg_6, vg2_6, - u_brick_a3, v0_brick_a3, v1_brick_a3, v2_brick_a3, - v3_brick_a3, v4_brick_a3, v5_brick_a3); - poisson_2s_ik(density_fft_a0, density_fft_a6, - vdx_brick_a0, vdy_brick_a0, vdz_brick_a0, - vdx_brick_a6, vdy_brick_a6, vdz_brick_a6, - u_brick_a0, v0_brick_a0, v1_brick_a0, v2_brick_a0, - v3_brick_a0, v4_brick_a0, v5_brick_a0, - u_brick_a6, v0_brick_a6, v1_brick_a6, v2_brick_a6, - v3_brick_a6, v4_brick_a6, v5_brick_a6); - poisson_2s_ik(density_fft_a1, density_fft_a5, - vdx_brick_a1, vdy_brick_a1, vdz_brick_a1, - vdx_brick_a5, vdy_brick_a5, vdz_brick_a5, - u_brick_a1, v0_brick_a1, v1_brick_a1, v2_brick_a1, - v3_brick_a1, v4_brick_a1, v5_brick_a1, - u_brick_a5, v0_brick_a5, v1_brick_a5, v2_brick_a5, - v3_brick_a5, v4_brick_a5, v5_brick_a5); - poisson_2s_ik(density_fft_a2, density_fft_a4, - vdx_brick_a2, vdy_brick_a2, vdz_brick_a2, - vdx_brick_a4, vdy_brick_a4, vdz_brick_a4, - u_brick_a2, v0_brick_a2, v1_brick_a2, v2_brick_a2, - v3_brick_a2, v4_brick_a2, v5_brick_a2, - u_brick_a4, v0_brick_a4, v1_brick_a4, v2_brick_a4, - v3_brick_a4, v4_brick_a4, v5_brick_a4); + poisson_ik(work1_6,work2_6,density_fft_a3,fft1_6,fft2_6, + nx_pppm_6,ny_pppm_6,nz_pppm_6,nfft_6, + nxlo_fft_6,nylo_fft_6,nzlo_fft_6,nxhi_fft_6,nyhi_fft_6,nzhi_fft_6, + nxlo_in_6,nylo_in_6,nzlo_in_6,nxhi_in_6,nyhi_in_6,nzhi_in_6, + energy_6,greensfn_6, + fkx_6,fky_6,fkz_6,fkx2_6,fky2_6,fkz2_6, + vdx_brick_a3,vdy_brick_a3,vdz_brick_a3,virial_6,vg_6,vg2_6, + u_brick_a3,v0_brick_a3,v1_brick_a3,v2_brick_a3, + v3_brick_a3,v4_brick_a3,v5_brick_a3); + poisson_2s_ik(density_fft_a0,density_fft_a6, + vdx_brick_a0,vdy_brick_a0,vdz_brick_a0, + vdx_brick_a6,vdy_brick_a6,vdz_brick_a6, + u_brick_a0,v0_brick_a0,v1_brick_a0,v2_brick_a0, + v3_brick_a0,v4_brick_a0,v5_brick_a0, + u_brick_a6,v0_brick_a6,v1_brick_a6,v2_brick_a6, + v3_brick_a6,v4_brick_a6,v5_brick_a6); + poisson_2s_ik(density_fft_a1,density_fft_a5, + vdx_brick_a1,vdy_brick_a1,vdz_brick_a1, + vdx_brick_a5,vdy_brick_a5,vdz_brick_a5, + u_brick_a1,v0_brick_a1,v1_brick_a1,v2_brick_a1, + v3_brick_a1,v4_brick_a1,v5_brick_a1, + u_brick_a5,v0_brick_a5,v1_brick_a5,v2_brick_a5, + v3_brick_a5,v4_brick_a5,v5_brick_a5); + poisson_2s_ik(density_fft_a2,density_fft_a4, + vdx_brick_a2,vdy_brick_a2,vdz_brick_a2, + vdx_brick_a4,vdy_brick_a4,vdz_brick_a4, + u_brick_a2,v0_brick_a2,v1_brick_a2,v2_brick_a2, + v3_brick_a2,v4_brick_a2,v5_brick_a2, + u_brick_a4,v0_brick_a4,v1_brick_a4,v2_brick_a4, + v3_brick_a4,v4_brick_a4,v5_brick_a4); gc6->forward_comm_kspace(this,18,sizeof(FFT_SCALAR),FORWARD_IK_A, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); @@ -1129,10 +1129,10 @@ void PPPMDisp::compute(int eflag, int vflag) // perform calculations if no mixing rule applies - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, part2grid_6, - nupper_6, nlower_6, - nxlo_out_6, nylo_out_6, nzlo_out_6, - nxhi_out_6, nyhi_out_6, nzhi_out_6); + particle_map(delxinv_6,delyinv_6,delzinv_6,shift_6,part2grid_6, + nupper_6,nlower_6, + nxlo_out_6,nylo_out_6,nzlo_out_6, + nxhi_out_6,nyhi_out_6,nzhi_out_6); make_rho_none(); @@ -1146,8 +1146,8 @@ void PPPMDisp::compute(int eflag, int vflag) for (int k = 0; knatoms != natoms_original) { qsum_qsq(); @@ -1387,7 +1387,7 @@ void PPPMDisp::init_coeffs() // local pair coeffs if (me == 0) utils::logmesg(lmp,fmt::format(" Using {} structure factors\n", nsplit)); - if (nsplit > 9) error->warning(FLERR, "Simulations might be very slow because of large number of structure factors"); + if (nsplit > 9) error->warning(FLERR,"Simulations might be very slow because of large number of structure factors"); } memory->destroy(A); @@ -1400,15 +1400,15 @@ void PPPMDisp::init_coeffs() // local pair coeffs for (int i=1; i<=n; ++i) B[i] = sqrt(fabs(b[i][i])); } if (function[2]) { // arithmetic 1/r^6 - //cannot use epsilon, because this has not been set yet + //cannot use epsilon,because this has not been set yet double **epsilon = (double **) force->pair->extract("epsilon",tmp); - //cannot use sigma, because this has not been set yet + //cannot use sigma,because this has not been set yet double **sigma = (double **) force->pair->extract("sigma",tmp); if (!(epsilon&&sigma)) error->all(FLERR,"Epsilon or sigma reference not set by pair style in PPPMDisp"); - double eps_i, sigma_i, sigma_n, *bi = B = new double[7*n+7]; + double eps_i,sigma_i,sigma_n,*bi = B = new double[7*n+7]; double c[7] = { - 1.0, sqrt(6.0), sqrt(15.0), sqrt(20.0), sqrt(15.0), sqrt(6.0), 1.0}; + 1.0,sqrt(6.0),sqrt(15.0),sqrt(20.0),sqrt(15.0),sqrt(6.0),1.0}; for (int i=0; i<=n; ++i) { eps_i = sqrt(epsilon[i][i]); sigma_i = sigma[i][i]; @@ -1422,7 +1422,7 @@ void PPPMDisp::init_coeffs() // local pair coeffs } /* ---------------------------------------------------------------------- - Eigenvalue decomposition of a real, symmetric matrix with the QR + Eigenvalue decomposition of a real,symmetric matrix with the QR method (includes transpformation to Tridiagonal Matrix + Wilkinson shift) ------------------------------------------------------------------------- */ @@ -1430,7 +1430,7 @@ void PPPMDisp::init_coeffs() // local pair coeffs int PPPMDisp::qr_alg(double **A, double **Q, int n) { int converged = 0; - double an1, an, bn1, d, mue; + double an1,an,bn1,d,mue; // allocate some memory for the required operations double **A0,**Qi,**C,**D,**E; // make a copy of A for convergence check @@ -1534,7 +1534,7 @@ void PPPMDisp::hessenberg(double **A, double **Q, int n) is stored in A and Qi ------------------------------------------------------------------------- */ -void PPPMDisp::qr_tri(double** Qi,double** A,int n) +void PPPMDisp::qr_tri(double** Qi, double** A, int n) { double r,a,b,c,s,x1,x2; int j,k,k0,kmax; @@ -1544,16 +1544,22 @@ void PPPMDisp::qr_tri(double** Qi,double** A,int n) Qi[i][j] = 0.0; for (int i = 0; i < n; i++) Qi[i][i] = 1.0; + // loop over main diagonal and first of diagonal of A + for (int i = 0; i < n-1; i++) { j = i+1; + // coefficients of the rotation matrix + a = A[i][i]; b = A[j][i]; r = sqrt(a*a + b*b); c = a/r; s = b/r; + // update the entries of A and Q + k0 = (i-1>0)?i-1:0; //min(i-1,0); kmax = (i+3A0[i][j])?Bmax:A0[i][j]; //max(Bmax,A0[i][j]); @@ -1614,25 +1625,36 @@ int PPPMDisp::check_convergence(double** A,double** Q,double** A0, // reconstruct the original matrix // store the diagonal elements in D + for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) D[i][j] = 0.0; for (int i = 0; i < n; i++) D[i][i] = A[i][i]; + // store matrix Q in E + for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) E[i][j] = Q[i][j]; + // E = Q*A + mmult(E,D,C,n); + // store transpose of Q in D + for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) D[i][j] = Q[j][i]; + // E = Q*A*Q.t + mmult(E,D,C,n); + //compare the original matrix and the final matrix + for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { diff = A0[i][j] - E[i][j]; @@ -2646,16 +2668,16 @@ void PPPMDisp::set_grid() set the FFT parameters ------------------------------------------------------------------------- */ -void PPPMDisp::set_fft_parameters(int& nx_p,int& ny_p,int& nz_p, - int& nxlo_f,int& nylo_f,int& nzlo_f, - int& nxhi_f,int& nyhi_f,int& nzhi_f, - int& nxlo_i,int& nylo_i,int& nzlo_i, - int& nxhi_i,int& nyhi_i,int& nzhi_i, - int& nxlo_o,int& nylo_o,int& nzlo_o, - int& nxhi_o,int& nyhi_o,int& nzhi_o, - int& nlow, int& nupp, - int& ng, int& nf, int& nfb, - double& sft,double& sftone, int& ord) +void PPPMDisp::set_fft_parameters(int& nx_p, int& ny_p, int& nz_p, + int& nxlo_f, int& nylo_f, int& nzlo_f, + int& nxhi_f, int& nyhi_f, int& nzhi_f, + int& nxlo_i, int& nylo_i, int& nzlo_i, + int& nxhi_i, int& nyhi_i, int& nzhi_i, + int& nxlo_o, int& nylo_o, int& nzlo_o, + int& nxhi_o, int& nyhi_o, int& nzhi_o, + int& nlow, int& nupp, + int& ng, int& nf, int& nfb, + double& sft, double& sftone, int& ord) { // global indices of PPPM grid range from 0 to N-1 // nlo_in,nhi_in = lower/upper limits of the 3d sub-brick of @@ -3986,6 +4008,7 @@ void PPPMDisp::compute_gf_6() compute self force coefficients for ad-differentiation scheme and Coulomb interaction ------------------------------------------------------------------------- */ + void PPPMDisp::compute_sf_coeff() { int i,k,l,m,n; @@ -4280,6 +4303,8 @@ void PPPMDisp::particle_map(double delx, double dely, double delz, if (flag) error->one(FLERR,"Out of range atoms - cannot compute PPPMDisp"); } +/* ---------------------------------------------------------------------- +------------------------------------------------------------------------- */ void PPPMDisp::particle_map_c(double delx, double dely, double delz, double sft, int** p2g, int nup, int nlow, @@ -4550,6 +4575,7 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, double eng; // transform charge/dispersion density (r -> k) + n = 0; for (i = 0; i < nft; i++) { wk1[n++] = dfft[i]; @@ -4616,9 +4642,9 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, vy_brick[k][j][i] = wk2[n++]; } - if (!eflag_atom) { - // z direction gradient only + // z direction gradient only + if (!eflag_atom) { n = 0; for (k = nzlo_ft; k <= nzhi_ft; k++) for (j = nylo_ft; j <= nyhi_ft; j++) @@ -4640,15 +4666,15 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, } - else { - // z direction gradient & per-atom energy + // z direction gradient & per-atom energy + else { n = 0; for (k = nzlo_ft; k <= nzhi_ft; k++) for (j = nylo_ft; j <= nyhi_ft; j++) for (i = nxlo_ft; i <= nxhi_ft; i++) { - wk2[n] = -0.5*(kz[k]-kz2[k])*wk1[n+1] - wk1[n+1]; - wk2[n+1] = 0.5*(kz[k]-kz2[k])*wk1[n] + wk1[n]; + wk2[n] = -0.5*(kz[k]-kz2[k])*wk1[n+1] + wk1[n+1]; + wk2[n+1] = 0.5*(kz[k]-kz2[k])*wk1[n] - wk1[n]; n += 2; } @@ -4663,9 +4689,9 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, } } - if (vflag_atom) poisson_peratom(wk1, wk2, ft2, vcoeff, vcoeff2, nft, - nxlo_i, nylo_i, nzlo_i, nxhi_i, nyhi_i, nzhi_i, - v0_pa, v1_pa, v2_pa, v3_pa, v4_pa, v5_pa); + if (vflag_atom) poisson_peratom(wk1,wk2,ft2,vcoeff,vcoeff2,nft, + nxlo_i,nylo_i,nzlo_i,nxhi_i,nyhi_i,nzhi_i, + v0_pa,v1_pa,v2_pa,v3_pa,v4_pa,v5_pa); } /* ---------------------------------------------------------------------- @@ -4690,6 +4716,7 @@ void PPPMDisp::poisson_ad(FFT_SCALAR* wk1, FFT_SCALAR* wk2, double eng; // transform charge/dispersion density (r -> k) + n = 0; for (i = 0; i < nft; i++) { wk1[n++] = dfft[i]; @@ -4752,9 +4779,9 @@ void PPPMDisp::poisson_ad(FFT_SCALAR* wk1, FFT_SCALAR* wk2, } - if (vflag_atom) poisson_peratom(wk1, wk2, ft2, vcoeff, vcoeff2, nft, - nxlo_i, nylo_i, nzlo_i, nxhi_i, nyhi_i, nzhi_i, - v0_pa, v1_pa, v2_pa, v3_pa, v4_pa, v5_pa); + if (vflag_atom) poisson_peratom(wk1,wk2,ft2,vcoeff,vcoeff2,nft, + nxlo_i,nylo_i,nzlo_i,nxhi_i,nyhi_i,nzhi_i, + v0_pa,v1_pa,v2_pa,v3_pa,v4_pa,v5_pa); } @@ -4762,21 +4789,22 @@ void PPPMDisp::poisson_ad(FFT_SCALAR* wk1, FFT_SCALAR* wk2, Fourier Transform for per atom virial calculations ------------------------------------------------------------------------- */ -void PPPMDisp:: poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT3d* ft2, - double** vcoeff, double** vcoeff2, int nft, - int nxlo_i, int nylo_i, int nzlo_i, - int nxhi_i, int nyhi_i, int nzhi_i, - FFT_SCALAR*** v0_pa, FFT_SCALAR*** v1_pa, - FFT_SCALAR*** v2_pa, - FFT_SCALAR*** v3_pa, FFT_SCALAR*** v4_pa, - FFT_SCALAR*** v5_pa) +void PPPMDisp::poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT3d* ft2, + double** vcoeff, double** vcoeff2, int nft, + int nxlo_i, int nylo_i, int nzlo_i, + int nxhi_i, int nyhi_i, int nzhi_i, + FFT_SCALAR*** v0_pa, FFT_SCALAR*** v1_pa, + FFT_SCALAR*** v2_pa, + FFT_SCALAR*** v3_pa, FFT_SCALAR*** v4_pa, + FFT_SCALAR*** v5_pa) { - //v0 & v1 term + // v0 & v1 term + int n, i, j, k; n = 0; for (i = 0; i < nft; i++) { - wk2[n] = wk1[n]*vcoeff[i][0] - wk1[n+1]*vcoeff[i][1]; - wk2[n+1] = wk1[n+1]*vcoeff[i][0] + wk1[n]*vcoeff[i][1]; + wk2[n] = wk1[n]*vcoeff[i][0] + wk1[n+1]*vcoeff[i][1]; + wk2[n+1] = wk1[n+1]*vcoeff[i][0] - wk1[n]*vcoeff[i][1]; n += 2; } @@ -4790,12 +4818,12 @@ void PPPMDisp:: poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT v1_pa[k][j][i] = wk2[n++]; } - //v2 & v3 term - + // v2 & v3 term + n = 0; for (i = 0; i < nft; i++) { - wk2[n] = wk1[n]*vcoeff[i][2] - wk1[n+1]*vcoeff2[i][0]; - wk2[n+1] = wk1[n+1]*vcoeff[i][2] + wk1[n]*vcoeff2[i][0]; + wk2[n] = wk1[n]*vcoeff[i][2] + wk1[n+1]*vcoeff2[i][0]; + wk2[n+1] = wk1[n+1]*vcoeff[i][2] - wk1[n]*vcoeff2[i][0]; n += 2; } @@ -4809,12 +4837,12 @@ void PPPMDisp:: poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT v3_pa[k][j][i] = wk2[n++]; } - //v4 & v5 term + // v4 & v5 term n = 0; for (i = 0; i < nft; i++) { - wk2[n] = wk1[n]*vcoeff2[i][1] - wk1[n+1]*vcoeff2[i][2]; - wk2[n+1] = wk1[n+1]*vcoeff2[i][1] + wk1[n]*vcoeff2[i][2]; + wk2[n] = wk1[n]*vcoeff2[i][1] + wk1[n+1]*vcoeff2[i][2]; + wk2[n+1] = wk1[n+1]*vcoeff2[i][1] - wk1[n]*vcoeff2[i][2]; n += 2; } @@ -4853,8 +4881,8 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, double scaleinv = 1.0/(nx_pppm_6*ny_pppm_6*nz_pppm_6); // transform charge/dispersion density (r -> k) - // only one tansform required when energies and pressures do not - // need to be calculated + // only one transform when energies and pressures not calculated + if (eflag_global + vflag_global == 0) { n = 0; for (i = 0; i < nfft_6; i++) { @@ -4864,8 +4892,9 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, fft1_6->compute(work1_6,work1_6,FORWARD); } - // two transforms are required when energies and pressures are - // calculated + + // two transforms when energies and pressures are calculated + else { n = 0; for (i = 0; i < nfft_6; i++) { @@ -4884,16 +4913,16 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n = 0; for (i = 0; i < nfft_6; i++) { eng = 2 * s2 * greensfn_6[i] * - (work1_6[n]*work2_6[n+1] - work1_6[n+1]*work2_6[n]); + (-work1_6[n]*work2_6[n+1] + work1_6[n+1]*work2_6[n]); for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; - if (eflag_global)energy_6 += eng; + if (eflag_global) energy_6 += eng; n += 2; } } else { n = 0; for (i = 0; i < nfft_6; i++) { energy_6 += - 2 * s2 * greensfn_6[i] * (work1_6[n]*work2_6[n+1] - work1_6[n+1]*work2_6[n]); + 2 * s2 * greensfn_6[i] * (-work1_6[n]*work2_6[n+1] + work1_6[n+1]*work2_6[n]); n += 2; } } @@ -4921,8 +4950,8 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (k = nzlo_fft_6; k <= nzhi_fft_6; k++) for (j = nylo_fft_6; j <= nyhi_fft_6; j++) for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { - work2_6[n] = 0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n+1]; - work2_6[n+1] = -0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n]; + work2_6[n] = -0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n+1]; + work2_6[n+1] = 0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n]; n += 2; } @@ -4942,8 +4971,8 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (k = nzlo_fft_6; k <= nzhi_fft_6; k++) for (j = nylo_fft_6; j <= nyhi_fft_6; j++) for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { - work2_6[n] = 0.5*(fky_6[j]-fky2_6[j])*work1_6[n+1]; - work2_6[n+1] = -0.5*(fky_6[j]-fky2_6[j])*work1_6[n]; + work2_6[n] = -0.5*(fky_6[j]-fky2_6[j])*work1_6[n+1]; + work2_6[n+1] = 0.5*(fky_6[j]-fky2_6[j])*work1_6[n]; n += 2; } @@ -4963,8 +4992,8 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (k = nzlo_fft_6; k <= nzhi_fft_6; k++) for (j = nylo_fft_6; j <= nyhi_fft_6; j++) for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { - work2_6[n] = 0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n+1]; - work2_6[n+1] = -0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n]; + work2_6[n] = -0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n+1]; + work2_6[n+1] = 0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n]; n += 2; } @@ -4978,7 +5007,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, vzbrick_2[k][j][i] = work2_6[n++]; } - //Per-atom energy + // per-atom energy if (eflag_atom) { n = 0; @@ -4999,10 +5028,10 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, } } - if (vflag_atom) poisson_2s_peratom(v0_pa_1, v1_pa_1, v2_pa_1, - v3_pa_1, v4_pa_1, v5_pa_1, - v0_pa_2, v1_pa_2, v2_pa_2, - v3_pa_2, v4_pa_2, v5_pa_2); + if (vflag_atom) poisson_2s_peratom(v0_pa_1,v1_pa_1,v2_pa_1, + v3_pa_1,v4_pa_1,v5_pa_1, + v0_pa_2,v1_pa_2,v2_pa_2, + v3_pa_2,v4_pa_2,v5_pa_2); } @@ -5063,7 +5092,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, (B[n1]*(work1_6[n]*work1_6[n] + work1_6[n+1]*work1_6[n+1]) + B[n2]*(work2_6[n]*work2_6[n] + work2_6[n+1]*work2_6[n+1])); for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; - if (eflag_global)energy_6 += eng; + if (eflag_global) energy_6 += eng; n += 2; } } else { @@ -5100,8 +5129,8 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (k = nzlo_fft_6; k <= nzhi_fft_6; k++) for (j = nylo_fft_6; j <= nyhi_fft_6; j++) for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { - work2_6[n] = 0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n+1]; - work2_6[n+1] = -0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n]; + work2_6[n] = -0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n+1]; + work2_6[n+1] = 0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n]; n += 2; } @@ -5121,8 +5150,8 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (k = nzlo_fft_6; k <= nzhi_fft_6; k++) for (j = nylo_fft_6; j <= nyhi_fft_6; j++) for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { - work2_6[n] = 0.5*(fky_6[j]-fky2_6[j])*work1_6[n+1]; - work2_6[n+1] = -0.5*(fky_6[j]-fky2_6[j])*work1_6[n]; + work2_6[n] = -0.5*(fky_6[j]-fky2_6[j])*work1_6[n+1]; + work2_6[n+1] = 0.5*(fky_6[j]-fky2_6[j])*work1_6[n]; n += 2; } @@ -5142,8 +5171,8 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (k = nzlo_fft_6; k <= nzhi_fft_6; k++) for (j = nylo_fft_6; j <= nyhi_fft_6; j++) for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { - work2_6[n] = 0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n+1]; - work2_6[n+1] = -0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n]; + work2_6[n] = -0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n+1]; + work2_6[n+1] = 0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n]; n += 2; } @@ -5157,7 +5186,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, vzbrick_2[k][j][i] = B[n2]*work2_6[n++]; } - //Per-atom energy + // per-atom energy if (eflag_atom) { n = 0; @@ -5178,9 +5207,10 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, } } - if (vflag_atom) poisson_none_peratom(n1,n2, - v0_pa[n1], v1_pa[n1], v2_pa[n1], v3_pa[n1], v4_pa[n1], v5_pa[n1], - v0_pa[n2], v1_pa[n2], v2_pa[n2], v3_pa[n2], v4_pa[n2], v5_pa[n2]); + if (vflag_atom) + poisson_none_peratom(n1,n2, + v0_pa[n1],v1_pa[n1],v2_pa[n1],v3_pa[n1],v4_pa[n1],v5_pa[n1], + v0_pa[n2],v1_pa[n2],v2_pa[n2],v3_pa[n2],v4_pa[n2],v5_pa[n2]); } /* ---------------------------------------------------------------------- @@ -5235,7 +5265,7 @@ poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n = 0; for (i = 0; i < nfft_6; i++) { eng = 2 * s2 * greensfn_6[i] * - (work1_6[n]*work2_6[n+1] - work1_6[n+1]*work2_6[n]); + (-work1_6[n]*work2_6[n+1] + work1_6[n+1]*work2_6[n]); for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; if (eflag_global)energy_6 += eng; n += 2; @@ -5244,11 +5274,13 @@ poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n = 0; for (i = 0; i < nfft_6; i++) { energy_6 += - 2 * s2 * greensfn_6[i] * (work1_6[n]*work2_6[n+1] - work1_6[n+1]*work2_6[n]); + 2 * s2 * greensfn_6[i] * (-work1_6[n]*work2_6[n+1] + work1_6[n+1]*work2_6[n]); n += 2; } } + // unify the two transformed vectors for efficient calculations later + for ( i = 0; i < 2*nfft_6; i++) { work1_6[i] += work2_6[i]; } @@ -5279,10 +5311,10 @@ poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, u_pa_2[k][j][i] = work2_6[n++]; } - if (vflag_atom) poisson_2s_peratom(v0_pa_1, v1_pa_1, v2_pa_1, - v3_pa_1, v4_pa_1, v5_pa_1, - v0_pa_2, v1_pa_2, v2_pa_2, - v3_pa_2, v4_pa_2, v5_pa_2); + if (vflag_atom) poisson_2s_peratom(v0_pa_1,v1_pa_1,v2_pa_1, + v3_pa_1,v4_pa_1,v5_pa_1, + v0_pa_2,v1_pa_2,v2_pa_2, + v3_pa_2,v4_pa_2,v5_pa_2); } /* ---------------------------------------------------------------------- @@ -5383,9 +5415,10 @@ poisson_none_ad(int n1, int n2, FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, u_pa_2[k][j][i] = B[n2]*work2_6[n++]; } - if (vflag_atom) poisson_none_peratom(n1,n2, - v0_pa[n1], v1_pa[n1], v2_pa[n1], v3_pa[n1], v4_pa[n1], v5_pa[n1], - v0_pa[n2], v1_pa[n2], v2_pa[n2], v3_pa[n2], v4_pa[n2], v5_pa[n2]); + if (vflag_atom) + poisson_none_peratom(n1,n2, + v0_pa[n1],v1_pa[n1],v2_pa[n1],v3_pa[n1],v4_pa[n1],v5_pa[n1], + v0_pa[n2],v1_pa[n2],v2_pa[n2],v3_pa[n2],v4_pa[n2],v5_pa[n2]); } /* ---------------------------------------------------------------------- @@ -5398,7 +5431,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v FFT_SCALAR*** v0_pa_2, FFT_SCALAR*** v1_pa_2, FFT_SCALAR*** v2_pa_2, FFT_SCALAR*** v3_pa_2, FFT_SCALAR*** v4_pa_2, FFT_SCALAR*** v5_pa_2) { - //Compute first virial term v0 + // compute first virial term v0 int n, i, j, k; @@ -5419,7 +5452,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v v0_pa_2[k][j][i] = work2_6[n++]; } - //Compute second virial term v1 + // compute second virial term v1 n = 0; for (i = 0; i < nfft_6; i++) { @@ -5438,7 +5471,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v v1_pa_2[k][j][i] = work2_6[n++]; } - //Compute third virial term v2 + // compute third virial term v2 n = 0; for (i = 0; i < nfft_6; i++) { @@ -5457,7 +5490,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v v2_pa_2[k][j][i] = work2_6[n++]; } - //Compute fourth virial term v3 + // compute fourth virial term v3 n = 0; for (i = 0; i < nfft_6; i++) { @@ -5476,7 +5509,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v v3_pa_2[k][j][i] = work2_6[n++]; } - //Compute fifth virial term v4 + // compute fifth virial term v4 n = 0; for (i = 0; i < nfft_6; i++) { @@ -5495,7 +5528,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v v4_pa_2[k][j][i] = work2_6[n++]; } - //Compute last virial term v5 + // compute last virial term v5 n = 0; for (i = 0; i < nfft_6; i++) { @@ -5530,7 +5563,8 @@ poisson_none_peratom(int n1, int n2, FFT_SCALAR*** v3_pa_2, FFT_SCALAR*** v4_pa_2, FFT_SCALAR*** v5_pa_2) { - //Compute first virial term v0 + // compute first virial term v0 + int n, i, j, k; n = 0; @@ -5550,7 +5584,7 @@ poisson_none_peratom(int n1, int n2, v0_pa_2[k][j][i] = B[n2]*work2_6[n++]; } - //Compute second virial term v1 + // compute second virial term v1 n = 0; for (i = 0; i < nfft_6; i++) { @@ -5569,7 +5603,7 @@ poisson_none_peratom(int n1, int n2, v1_pa_2[k][j][i] = B[n2]*work2_6[n++]; } - //Compute third virial term v2 + // compute third virial term v2 n = 0; for (i = 0; i < nfft_6; i++) { @@ -5588,7 +5622,7 @@ poisson_none_peratom(int n1, int n2, v2_pa_2[k][j][i] = B[n2]*work2_6[n++]; } - //Compute fourth virial term v3 + // compute fourth virial term v3 n = 0; for (i = 0; i < nfft_6; i++) { @@ -5607,7 +5641,7 @@ poisson_none_peratom(int n1, int n2, v3_pa_2[k][j][i] = B[n2]*work2_6[n++]; } - //Compute fifth virial term v4 + // compute fifth virial term v4 n = 0; for (i = 0; i < nfft_6; i++) { @@ -5626,7 +5660,7 @@ poisson_none_peratom(int n1, int n2, v4_pa_2[k][j][i] = B[n2]*work2_6[n++]; } - //Compute last virial term v5 + // compute last virial term v5 n = 0; for (i = 0; i < nfft_6; i++) { From 4c09549bbd0beb8e129089a950f3555db9cf1b52 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Tue, 15 Dec 2020 12:25:08 -0700 Subject: [PATCH 03/51] more changes to pppm/disp and pppm/dipole --- src/KSPACE/pppm.cpp | 7 +- src/KSPACE/pppm_dipole.cpp | 146 ++++++++---- src/KSPACE/pppm_disp.cpp | 463 +++++++++++++++++++------------------ src/KSPACE/pppm_disp.h | 9 +- 4 files changed, 344 insertions(+), 281 deletions(-) diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index 80f9cc4312..489e8e28af 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -1365,7 +1365,7 @@ void PPPM::set_grid_local() // nlo_out,nhi_out = lower/upper limits of the 3d sub-brick of // global PPPM grid that my particles can contribute charge to // effectively nlo_in,nhi_in + ghost cells - // nlo,nhi = global coords of grid pt to "lower left" of smallest/largest + // nlo,nhi = index of global grid pt to "lower left" of smallest/largest // position a particle in my box can be at // dist[3] = particle position bound = subbox + skin/2.0 + qdist // qdist = offset due to TIP4P fictitious charge @@ -1887,7 +1887,10 @@ void PPPM::particle_map() for (int i = 0; i < nlocal; i++) { - // (nx,ny,nz) = global coords of grid pt to "lower left" of charge + // order = even: + // (nx,ny,nz) = global index of grid pt to "lower left" of charge + // order = odd: + // (nx,ny,nz) = global index of grid pt closest to charge due to shift // current particle coord can be outside global and local box // add/subtract OFFSET to avoid int(-0.75) = 0 when want it to be -1 diff --git a/src/KSPACE/pppm_dipole.cpp b/src/KSPACE/pppm_dipole.cpp index 27cad11ab3..884bd3731c 100644 --- a/src/KSPACE/pppm_dipole.cpp +++ b/src/KSPACE/pppm_dipole.cpp @@ -1334,7 +1334,7 @@ void PPPMDipole::poisson_ik_dipole() wimg = (work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); energy += s2 * greensfn[ii] * (wreal*wreal + wimg*wimg); - ii++; + ii++; n += 2; } } @@ -1430,8 +1430,10 @@ void PPPMDipole::poisson_ik_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = -fkx[i]*fkx[i]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); - work4[n+1] = +fkx[i]*fkx[i]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); + work4[n] = -fkx[i]*fkx[i]*(work1[n+1]*fkx[i] + + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); + work4[n+1] = fkx[i]*fkx[i]*(work1[n]*fkx[i] + + work2[n]*fky[j] + work3[n]*fkz[k]); n += 2; } @@ -1451,8 +1453,10 @@ void PPPMDipole::poisson_ik_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = -fky[j]*fky[j]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); - work4[n+1] = fky[j]*fky[j]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); + work4[n] = -fky[j]*fky[j]*(work1[n+1]*fkx[i] + + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); + work4[n+1] = fky[j]*fky[j]*(work1[n]*fkx[i] + + work2[n]*fky[j] + work3[n]*fkz[k]); n += 2; } @@ -1472,8 +1476,10 @@ void PPPMDipole::poisson_ik_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = -fkz[k]*fkz[k]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); - work4[n+1] = fkz[k]*fkz[k]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); + work4[n] = -fkz[k]*fkz[k]*(work1[n+1]*fkx[i] + + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); + work4[n+1] = fkz[k]*fkz[k]*(work1[n]*fkx[i] + + work2[n]*fky[j] + work3[n]*fkz[k]); n += 2; } @@ -1493,8 +1499,10 @@ void PPPMDipole::poisson_ik_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = -fkx[i]*fky[j]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); - work4[n+1] = fkx[i]*fky[j]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); + work4[n] = -fkx[i]*fky[j]*(work1[n+1]*fkx[i] + + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); + work4[n+1] = fkx[i]*fky[j]*(work1[n]*fkx[i] + + work2[n]*fky[j] + work3[n]*fkz[k]); n += 2; } @@ -1514,8 +1522,10 @@ void PPPMDipole::poisson_ik_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = -fkx[i]*fkz[k]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); - work4[n+1] = fkx[i]*fkz[k]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); + work4[n] = -fkx[i]*fkz[k]*(work1[n+1]*fkx[i] + + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); + work4[n+1] = fkx[i]*fkz[k]*(work1[n]*fkx[i] + + work2[n]*fky[j] + work3[n]*fkz[k]); n += 2; } @@ -1535,8 +1545,10 @@ void PPPMDipole::poisson_ik_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = -fky[j]*fkz[k]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); - work4[n+1] = fky[j]*fkz[k]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]); + work4[n] = -fky[j]*fkz[k]*(work1[n+1]*fkx[i] + + work2[n+1]*fky[j] + work3[n+1]*fkz[k]); + work4[n+1] = fky[j]*fkz[k]*(work1[n]*fkx[i] + + work2[n]*fky[j] + work3[n]*fkz[k]); n += 2; } @@ -1570,8 +1582,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkx[i]*(vg[ii][0]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fkx[i]*work1[n]); - work4[n+1] = fkx[i]*(vg[ii][0]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fkx[i]*work1[n+1]); + work4[n] = fkx[i]*(vg[ii][0]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fkx[i]*work1[n]); + work4[n+1] = fkx[i]*(vg[ii][0]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fkx[i]*work1[n+1]); n += 2; ii++; } @@ -1593,8 +1607,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fky[j]*(vg[ii][0]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fkx[i]*work1[n]); - work4[n+1] = fky[j]*(vg[ii][0]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fkx[i]*work1[n+1]); + work4[n] = fky[j]*(vg[ii][0]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fkx[i]*work1[n]); + work4[n+1] = fky[j]*(vg[ii][0]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fkx[i]*work1[n+1]); n += 2; ii++; } @@ -1616,8 +1632,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkz[k]*(vg[ii][0]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fkx[i]*work1[n]); - work4[n+1] = fkz[k]*(vg[ii][0]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fkx[i]*work1[n+1]); + work4[n] = fkz[k]*(vg[ii][0]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fkx[i]*work1[n]); + work4[n+1] = fkz[k]*(vg[ii][0]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fkx[i]*work1[n+1]); n += 2; ii++; } @@ -1639,8 +1657,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkx[i]*(vg[ii][1]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fky[j]*work2[n]); - work4[n+1] = fkx[i]*(vg[ii][1]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fky[j]*work2[n+1]); + work4[n] = fkx[i]*(vg[ii][1]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fky[j]*work2[n]); + work4[n+1] = fkx[i]*(vg[ii][1]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fky[j]*work2[n+1]); n += 2; ii++; } @@ -1662,8 +1682,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fky[j]*(vg[ii][1]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fky[j]*work2[n]); - work4[n+1] = fky[j]*(vg[ii][1]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fky[j]*work2[n+1]); + work4[n] = fky[j]*(vg[ii][1]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fky[j]*work2[n]); + work4[n+1] = fky[j]*(vg[ii][1]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fky[j]*work2[n+1]); n += 2; ii++; } @@ -1685,8 +1707,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkz[k]*(vg[ii][1]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fky[j]*work2[n]); - work4[n+1] = fkz[k]*(vg[ii][1]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fky[j]*work2[n+1]); + work4[n] = fkz[k]*(vg[ii][1]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fky[j]*work2[n]); + work4[n+1] = fkz[k]*(vg[ii][1]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fky[j]*work2[n+1]); n += 2; ii++; } @@ -1708,8 +1732,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkx[i]*(vg[ii][2]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fkz[k]*work3[n]); - work4[n+1] = fkx[i]*(vg[ii][2]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work3[n+1]); + work4[n] = fkx[i]*(vg[ii][2]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fkz[k]*work3[n]); + work4[n+1] = fkx[i]*(vg[ii][2]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work3[n+1]); n += 2; ii++; } @@ -1731,8 +1757,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fky[j]*(vg[ii][2]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fkz[k]*work3[n]); - work4[n+1] = fky[j]*(vg[ii][2]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work3[n+1]); + work4[n] = fky[j]*(vg[ii][2]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fkz[k]*work3[n]); + work4[n+1] = fky[j]*(vg[ii][2]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work3[n+1]); n += 2; ii++; } @@ -1754,8 +1782,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkz[k]*(vg[ii][2]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fkz[k]*work3[n]); - work4[n+1] = fkz[k]*(vg[ii][2]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work3[n+1]); + work4[n] = fkz[k]*(vg[ii][2]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fkz[k]*work3[n]); + work4[n+1] = fkz[k]*(vg[ii][2]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work3[n+1]); n += 2; ii++; } @@ -1777,8 +1807,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkx[i]*(vg[ii][3]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fky[j]*work1[n]); - work4[n+1] = fkx[i]*(vg[ii][3]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fky[j]*work1[n+1]); + work4[n] = fkx[i]*(vg[ii][3]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fky[j]*work1[n]); + work4[n+1] = fkx[i]*(vg[ii][3]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fky[j]*work1[n+1]); n += 2; ii++; } @@ -1800,8 +1832,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fky[j]*(vg[ii][3]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fky[j]*work1[n]); - work4[n+1] = fky[j]*(vg[ii][3]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fky[j]*work1[n+1]); + work4[n] = fky[j]*(vg[ii][3]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fky[j]*work1[n]); + work4[n+1] = fky[j]*(vg[ii][3]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fky[j]*work1[n+1]); n += 2; ii++; } @@ -1823,8 +1857,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkz[k]*(vg[ii][3]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fky[j]*work1[n]); - work4[n+1] = fkz[k]*(vg[ii][3]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fky[j]*work1[n+1]); + work4[n] = fkz[k]*(vg[ii][3]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fky[j]*work1[n]); + work4[n+1] = fkz[k]*(vg[ii][3]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fky[j]*work1[n+1]); n += 2; ii++; } @@ -1846,8 +1882,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkx[i]*(vg[ii][4]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fkz[k]*work1[n]); - work4[n+1] = fkx[i]*(vg[ii][4]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work1[n+1]); + work4[n] = fkx[i]*(vg[ii][4]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fkz[k]*work1[n]); + work4[n+1] = fkx[i]*(vg[ii][4]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work1[n+1]); n += 2; ii++; } @@ -1869,8 +1907,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fky[j]*(vg[ii][4]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fkz[k]*work1[n]); - work4[n+1] = fky[j]*(vg[ii][4]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work1[n+1]); + work4[n] = fky[j]*(vg[ii][4]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fkz[k]*work1[n]); + work4[n+1] = fky[j]*(vg[ii][4]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work1[n+1]); n += 2; ii++; } @@ -1892,8 +1932,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkz[k]*(vg[ii][4]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fkz[k]*work1[n]); - work4[n+1] = fkz[k]*(vg[ii][4]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work1[n+1]); + work4[n] = fkz[k]*(vg[ii][4]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fkz[k]*work1[n]); + work4[n+1] = fkz[k]*(vg[ii][4]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work1[n+1]); n += 2; ii++; } @@ -1915,8 +1957,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkx[i]*(vg[ii][5]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fkz[k]*work2[n]); - work4[n+1] = fkx[i]*(vg[ii][5]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work2[n+1]); + work4[n] = fkx[i]*(vg[ii][5]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fkz[k]*work2[n]); + work4[n+1] = fkx[i]*(vg[ii][5]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work2[n+1]); n += 2; ii++; } @@ -1938,8 +1982,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fky[j]*(vg[ii][5]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fkz[k]*work2[n]); - work4[n+1] = fky[j]*(vg[ii][5]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work2[n+1]); + work4[n] = fky[j]*(vg[ii][5]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fkz[k]*work2[n]); + work4[n+1] = fky[j]*(vg[ii][5]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work2[n+1]); n += 2; ii++; } @@ -1961,8 +2007,10 @@ void PPPMDipole::poisson_peratom_dipole() for (k = nzlo_fft; k <= nzhi_fft; k++) for (j = nylo_fft; j <= nyhi_fft; j++) for (i = nxlo_fft; i <= nxhi_fft; i++) { - work4[n] = fkz[k]*(vg[ii][5]*(work1[n]*fkx[i] + work2[n]*fky[j] + work3[n]*fkz[k]) + 2.0*fkz[k]*work2[n]); - work4[n+1] = fkz[k]*(vg[ii][5]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work2[n+1]); + work4[n] = fkz[k]*(vg[ii][5]*(work1[n]*fkx[i] + work2[n]*fky[j] + + work3[n]*fkz[k]) + 2.0*fkz[k]*work2[n]); + work4[n+1] = fkz[k]*(vg[ii][5]*(work1[n+1]*fkx[i] + work2[n+1]*fky[j] + + work3[n+1]*fkz[k]) + 2.0*fkz[k]*work2[n+1]); n += 2; ii++; } diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 9d8a9906e4..6ad39d8d1b 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -45,10 +45,12 @@ using namespace MathConst; #define LARGE 10000.0 #define EPS_HOC 1.0e-7 -enum{REVERSE_RHO,REVERSE_RHO_G,REVERSE_RHO_A,REVERSE_RHO_NONE}; +enum{REVERSE_RHO,REVERSE_RHO_GEOM,REVERSE_RHO_ARITH,REVERSE_RHO_NONE}; enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM, - FORWARD_IK_G,FORWARD_AD_G,FORWARD_IK_PERATOM_G,FORWARD_AD_PERATOM_G, - FORWARD_IK_A,FORWARD_AD_A,FORWARD_IK_PERATOM_A,FORWARD_AD_PERATOM_A, + FORWARD_IK_GEOM,FORWARD_AD_GEOM, + FORWARD_IK_PERATOM_GEOM,FORWARD_AD_PERATOM_GEOM, + FORWARD_IK_ARITH,FORWARD_AD_ARITH, + FORWARD_IK_PERATOM_ARITH,FORWARD_AD_PERATOM_ARITH, FORWARD_IK_NONE,FORWARD_AD_NONE,FORWARD_IK_PERATOM_NONE, FORWARD_AD_PERATOM_NONE}; enum{FORWARD=-1,BACKWARD=1}; @@ -333,7 +335,6 @@ void PPPMDisp::init() function[k] = 1; } - // warn, if function[0] is not set but charge attribute is set! if (!function[0] && atom->q_flag && me == 0) @@ -474,7 +475,7 @@ void PPPMDisp::init() MPI_Allreduce(&nfft_both,&nfft_both_max,1,MPI_INT,MPI_MAX,world); if (me == 0) { - std::string mesg = fmt::format(" Coulomb G vector (1/distance)= {:.8g}\n", + std::string mesg = fmt::format(" Coulomb G vector (1/distance)= {:.16g}\n", g_ewald); mesg += fmt::format(" Coulomb grid = {} {} {}\n", nx_pppm,ny_pppm,nz_pppm); @@ -553,13 +554,13 @@ void PPPMDisp::init() // print stats - int ngrid_max,nfft_both_max; - MPI_Allreduce(&ngrid_6,&ngrid_max,1,MPI_INT,MPI_MAX,world); - MPI_Allreduce(&nfft_both_6,&nfft_both_max,1,MPI_INT,MPI_MAX,world); + int ngrid_6_max,nfft_both_6_max; + MPI_Allreduce(&ngrid_6,&ngrid_6_max,1,MPI_INT,MPI_MAX,world); + MPI_Allreduce(&nfft_both_6,&nfft_both_6_max,1,MPI_INT,MPI_MAX,world); if (me == 0) { std::string mesg = fmt::format(" Dispersion G vector (1/distance)= " - "{:.8}\n",g_ewald_6); + "{:.16}\n",g_ewald_6); mesg += fmt::format(" Dispersion grid = {} {} {}\n", nx_pppm_6,ny_pppm_6,nz_pppm_6); mesg += fmt::format(" Dispersion stencil order = {}\n",order_6); @@ -569,7 +570,7 @@ void PPPMDisp::init() "= {:.8}\n",acc/two_charge_force); mesg += " using " LMP_FFT_PREC " precision " LMP_FFT_LIB "\n"; mesg += fmt::format(" 3d grid and FFT values/proc = {} {}\n", - ngrid_max,nfft_both_max); + ngrid_6_max,nfft_both_6_max); utils::logmesg(lmp,mesg); } } @@ -689,6 +690,9 @@ void PPPMDisp::setup() vg[n][3] = 0.0; vg[n][4] = 0.0; vg[n][5] = 0.0; + vg2[n][0] = 0.0; + vg2[n][1] = 0.0; + vg2[n][2] = 0.0; } else { vterm = -2.0 * (1.0/sqk + 0.25*gew2inv); vg[n][0] = 1.0 + vterm*fkx[i]*fkx[i]; @@ -755,6 +759,9 @@ void PPPMDisp::setup() vg_6[n][3] = 0.0; vg_6[n][4] = 0.0; vg_6[n][5] = 0.0; + vg2_6[n][0] = 0.0; + vg2_6[n][1] = 0.0; + vg2_6[n][2] = 0.0; } else { b = 0.5*sqrt(sqk)*gewinv; bs = b*b; @@ -981,7 +988,7 @@ void PPPMDisp::compute(int eflag, int vflag) make_rho_g(); - gc6->reverse_comm_kspace(this,1,sizeof(FFT_SCALAR),REVERSE_RHO_G, + gc6->reverse_comm_kspace(this,1,sizeof(FFT_SCALAR),REVERSE_RHO_GEOM, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); brick2fft(nxlo_in_6,nylo_in_6,nzlo_in_6,nxhi_in_6,nyhi_in_6,nzhi_in_6, @@ -997,13 +1004,13 @@ void PPPMDisp::compute(int eflag, int vflag) u_brick_g,v0_brick_g,v1_brick_g,v2_brick_g, v3_brick_g,v4_brick_g,v5_brick_g); - gc6->forward_comm_kspace(this,1,sizeof(FFT_SCALAR),FORWARD_AD_G, + gc6->forward_comm_kspace(this,1,sizeof(FFT_SCALAR),FORWARD_AD_GEOM, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); fieldforce_g_ad(); if (vflag_atom) - gc6->forward_comm_kspace(this,7,sizeof(FFT_SCALAR),FORWARD_AD_PERATOM_G, + gc6->forward_comm_kspace(this,6,sizeof(FFT_SCALAR),FORWARD_AD_PERATOM_GEOM, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); } else { @@ -1017,13 +1024,13 @@ void PPPMDisp::compute(int eflag, int vflag) u_brick_g,v0_brick_g,v1_brick_g,v2_brick_g, v3_brick_g,v4_brick_g,v5_brick_g); - gc6->forward_comm_kspace(this,3,sizeof(FFT_SCALAR),FORWARD_IK_G, + gc6->forward_comm_kspace(this,3,sizeof(FFT_SCALAR),FORWARD_IK_GEOM, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); fieldforce_g_ik(); if (evflag_atom) - gc6->forward_comm_kspace(this,6,sizeof(FFT_SCALAR),FORWARD_IK_PERATOM_G, + gc6->forward_comm_kspace(this,7,sizeof(FFT_SCALAR),FORWARD_IK_PERATOM_GEOM, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); } @@ -1041,8 +1048,8 @@ void PPPMDisp::compute(int eflag, int vflag) make_rho_a(); - gc->reverse_comm_kspace(this,7,sizeof(FFT_SCALAR),REVERSE_RHO_A, - gc_buf1,gc_buf2,MPI_FFT_SCALAR); + gc6->reverse_comm_kspace(this,7,sizeof(FFT_SCALAR),REVERSE_RHO_ARITH, + gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); brick2fft_a(); @@ -1071,13 +1078,13 @@ void PPPMDisp::compute(int eflag, int vflag) u_brick_a4,v0_brick_a4,v1_brick_a4,v2_brick_a4, v3_brick_a4,v4_brick_a4,v5_brick_a4); - gc6->forward_comm_kspace(this,7,sizeof(FFT_SCALAR),FORWARD_AD_A, + gc6->forward_comm_kspace(this,7,sizeof(FFT_SCALAR),FORWARD_AD_ARITH, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); fieldforce_a_ad(); if (evflag_atom) - gc6->forward_comm_kspace(this,42,sizeof(FFT_SCALAR),FORWARD_AD_PERATOM_A, + gc6->forward_comm_kspace(this,42,sizeof(FFT_SCALAR),FORWARD_AD_PERATOM_ARITH, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); } else { @@ -1112,13 +1119,13 @@ void PPPMDisp::compute(int eflag, int vflag) u_brick_a4,v0_brick_a4,v1_brick_a4,v2_brick_a4, v3_brick_a4,v4_brick_a4,v5_brick_a4); - gc6->forward_comm_kspace(this,18,sizeof(FFT_SCALAR),FORWARD_IK_A, + gc6->forward_comm_kspace(this,21,sizeof(FFT_SCALAR),FORWARD_IK_ARITH, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); fieldforce_a_ik(); if (evflag_atom) - gc6->forward_comm_kspace(this,49,sizeof(FFT_SCALAR),FORWARD_IK_PERATOM_A, + gc6->forward_comm_kspace(this,49,sizeof(FFT_SCALAR),FORWARD_IK_PERATOM_ARITH, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); } @@ -1136,14 +1143,14 @@ void PPPMDisp::compute(int eflag, int vflag) make_rho_none(); - gc->reverse_comm_kspace(this,1,sizeof(FFT_SCALAR),REVERSE_RHO_NONE, - gc_buf1,gc_buf2,MPI_FFT_SCALAR); + gc6->reverse_comm_kspace(this,nsplit_alloc,sizeof(FFT_SCALAR),REVERSE_RHO_NONE, + gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); brick2fft_none(); if (differentiation_flag == 1) { int n = 0; - for (int k = 0; kforward_comm_kspace(this,1,sizeof(FFT_SCALAR),FORWARD_AD_NONE, + gc6->forward_comm_kspace(this,1*nsplit_alloc,sizeof(FFT_SCALAR), + FORWARD_AD_NONE, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); fieldforce_none_ad(); if (vflag_atom) - gc6->forward_comm_kspace(this,6,sizeof(FFT_SCALAR),FORWARD_AD_PERATOM_NONE, + gc6->forward_comm_kspace(this,6*nsplit_alloc,sizeof(FFT_SCALAR), + FORWARD_AD_PERATOM_NONE, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); } else { int n = 0; - for (int k = 0; kforward_comm_kspace(this,3,sizeof(FFT_SCALAR),FORWARD_IK_NONE, + gc6->forward_comm_kspace(this,3*nsplit_alloc,sizeof(FFT_SCALAR), + FORWARD_IK_NONE, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); fieldforce_none_ik(); if (evflag_atom) - gc6->forward_comm_kspace(this,7,sizeof(FFT_SCALAR),FORWARD_IK_PERATOM_NONE, + gc6->forward_comm_kspace(this,7*nsplit_alloc,sizeof(FFT_SCALAR), + FORWARD_IK_PERATOM_NONE, gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); } @@ -1205,7 +1215,7 @@ void PPPMDisp::compute(int eflag, int vflag) energy_1 *= 0.5*volume; energy_6 *= 0.5*volume; - + energy_1 -= g_ewald*qsqsum/MY_PIS + MY_PI2*qsum*qsum / (g_ewald*g_ewald*volume); energy_6 += - MY_PI*MY_PIS/(6*volume)*pow(g_ewald_6,3)*csumij + @@ -1221,7 +1231,7 @@ void PPPMDisp::compute(int eflag, int vflag) for (i = 0; i < 6; i++) virial[i] = 0.5*qscale*volume*virial_all[i]; MPI_Allreduce(virial_6,virial_all,6,MPI_DOUBLE,MPI_SUM,world); for (i = 0; i < 6; i++) virial[i] += 0.5*volume*virial_all[i]; - if (function[1]+function[2]+function[3]){ + if (function[1]+function[2]+function[3]) { double a = MY_PI*MY_PIS/(6*volume)*pow(g_ewald_6,3)*csumij; virial[0] -= a; virial[1] -= a; @@ -1260,7 +1270,6 @@ void PPPMDisp::compute(int eflag, int vflag) } } - // 2d slab correction if (slabflag) slabcorr(eflag); @@ -1276,21 +1285,25 @@ void PPPMDisp::compute(int eflag, int vflag) initialize coefficients needed for the dispersion density on the grids ------------------------------------------------------------------------- */ -void PPPMDisp::init_coeffs() // local pair coeffs +void PPPMDisp::init_coeffs() { int tmp; int n = atom->ntypes; int converged; + delete [] B; B = nullptr; - if (function[3] + function[2]) { // no mixing rule or arithmetic + + // no mixing rule or arithmetic + + if (function[3] + function[2]) { if (function[2] && me == 0) utils::logmesg(lmp," Optimizing splitting of Dispersion coefficients\n"); // allocate data for eigenvalue decomposition double **A=nullptr; double **Q=nullptr; - if ( n > 1 ) { + if (n > 1) { // get dispersion coefficients double **b = (double **) force->pair->extract("B",tmp); memory->create(A,n,n,"pppm/disp:A"); @@ -1308,11 +1321,14 @@ void PPPMDisp::init_coeffs() // local pair coeffs // perform eigenvalue decomposition with QR algorithm converged = qr_alg(A,Q,n); if (function[3] && !converged) { - error->all(FLERR,"Matrix factorization to split dispersion coefficients failed"); + error->all(FLERR, + "Matrix factorization to split dispersion coefficients failed"); } + // determine number of used eigenvalues // based on maximum allowed number or cutoff criterion // sort eigenvalues according to their size with bubble sort + double t; for (int i = 0; i < n; i++) { for (int j = 0; j < n-1-i; j++) { @@ -1329,9 +1345,9 @@ void PPPMDisp::init_coeffs() // local pair coeffs } } - // check which eigenvalue is the first that is smaller - // than a specified tolerance - // check how many are maximum allowed by the user + // check which eigenvalue is the first that is smaller than a specified tolerance + // check how many are maximum allowed by the user + double amax = fabs(A[0][0]); double acrit = amax*splittol; double bmax = 0; @@ -1350,8 +1366,9 @@ void PPPMDisp::init_coeffs() // local pair coeffs error->warning(FLERR,fmt::format("Estimated error in splitting of " "dispersion coeffs is {}",err)); // set B + B = new double[nsplit*n+nsplit]; - for (int i = 0; i< nsplit; i++) { + for (int i = 0; i < nsplit; i++) { B[i] = A[i][i]; for (int j = 0; j < n; j++) { B[nsplit*(j+1) + i] = Q[j][i]; @@ -1359,62 +1376,70 @@ void PPPMDisp::init_coeffs() // local pair coeffs } nsplit_alloc = nsplit; - if (nsplit%2 == 1) nsplit_alloc = nsplit + 1; - } else - nsplit = 1; // use geometric mixing + if (nsplit % 2 == 1) nsplit_alloc = nsplit + 1; + + } else nsplit = 1; // use geometric mixing // check if the function should preferably be [1] or [2] or [3] + if (nsplit == 1) { - if ( B ) delete [] B; + if (B) delete [] B; function[3] = 0; function[2] = 0; function[1] = 1; if (me == 0) utils::logmesg(lmp," Using geometric mixing for reciprocal space\n"); } + if (function[2] && nsplit <= 6) { if (me == 0) utils::logmesg(lmp,fmt::format(" Using {} instead of 7 structure " "factors\n",nsplit)); - function[3] = 1; - function[2] = 0; - } + //function[3] = 1; + //function[2] = 0; + if (B) delete [] B; // remove this when un-comment previous 2 lines + } + if (function[2] && (nsplit > 6)) { if (me == 0) utils::logmesg(lmp," Using 7 structure factors\n"); - if ( B ) delete [] B; + if (B) delete [] B; } + if (function[3]) { if (me == 0) utils::logmesg(lmp,fmt::format(" Using {} structure factors\n", nsplit)); - if (nsplit > 9) error->warning(FLERR,"Simulations might be very slow because of large number of structure factors"); + if (nsplit > 9) + error->warning(FLERR,"Simulations might be very slow " + "because of large number of structure factors"); } memory->destroy(A); memory->destroy(Q); } + if (function[1]) { // geometric 1/r^6 double **b = (double **) force->pair->extract("B",tmp); B = new double[n+1]; B[0] = 0.0; for (int i=1; i<=n; ++i) B[i] = sqrt(fabs(b[i][i])); } + if (function[2]) { // arithmetic 1/r^6 - //cannot use epsilon,because this has not been set yet double **epsilon = (double **) force->pair->extract("epsilon",tmp); - //cannot use sigma,because this has not been set yet double **sigma = (double **) force->pair->extract("sigma",tmp); if (!(epsilon&&sigma)) - error->all(FLERR,"Epsilon or sigma reference not set by pair style in PPPMDisp"); - double eps_i,sigma_i,sigma_n,*bi = B = new double[7*n+7]; - double c[7] = { - 1.0,sqrt(6.0),sqrt(15.0),sqrt(20.0),sqrt(15.0),sqrt(6.0),1.0}; - for (int i=0; i<=n; ++i) { + error->all(FLERR,"Epsilon or sigma reference not set by pair style for PPPMDisp"); + double eps_i,sigma_i,sigma_n; + B = new double[7*n+7]; + double c[7] = {1.0,sqrt(6.0),sqrt(15.0),sqrt(20.0),sqrt(15.0),sqrt(6.0),1.0}; + + for (int i=1; i<=n; ++i) { eps_i = sqrt(epsilon[i][i]); sigma_i = sigma[i][i]; sigma_n = 1.0; for (int j=0; j<7; ++j) { - *(bi++) = sigma_n*eps_i*c[j]*0.25; + B[7*i+j] = sigma_n*eps_i*c[j]*0.25; sigma_n *= sigma_i; } } @@ -1422,9 +1447,8 @@ void PPPMDisp::init_coeffs() // local pair coeffs } /* ---------------------------------------------------------------------- - Eigenvalue decomposition of a real,symmetric matrix with the QR - method (includes transpformation to Tridiagonal Matrix + Wilkinson - shift) + eigenvalue decomposition of a real,symmetric matrix with the QR method + includes transpformation to Tridiagonal Matrix + Wilkinson shift ------------------------------------------------------------------------- */ int PPPMDisp::qr_alg(double **A, double **Q, int n) @@ -1827,7 +1851,7 @@ void _noopt PPPMDisp::allocate() gc6->setup(ngc6_buf1,ngc6_buf2); if (differentiation_flag) npergrid6 = 1; - else npergrid6 = 7; + else npergrid6 = 3; memory->create(gc6_buf1,npergrid6*ngc6_buf1,"pppm:gc_buf1"); memory->create(gc6_buf2,npergrid6*ngc6_buf2,"pppm:gc_buf2"); @@ -1887,7 +1911,6 @@ void _noopt PPPMDisp::allocate() memory->create(density_fft_a5,nfft_both_6,"pppm/disp:density_fft_a5"); memory->create(density_fft_a6,nfft_both_6,"pppm/disp:density_fft_a6"); - if (differentiation_flag == 1) { memory->create3d_offset(u_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a0"); @@ -1991,7 +2014,7 @@ void _noopt PPPMDisp::allocate() gc6->setup(ngc6_buf1,ngc6_buf2); if (differentiation_flag) npergrid6 = 7; - else npergrid6 = 18; + else npergrid6 = 21; memory->create(gc6_buf1,npergrid6*ngc6_buf1,"pppm:gc_buf1"); memory->create(gc6_buf2,npergrid6*ngc6_buf2,"pppm:gc_buf2"); @@ -2024,7 +2047,7 @@ void _noopt PPPMDisp::allocate() memory->create4d_offset(density_brick_none,nsplit_alloc, nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_none"); - if ( differentiation_flag == 1) { + if (differentiation_flag == 1) { memory->create4d_offset(u_brick_none,nsplit_alloc, nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_none"); @@ -2036,7 +2059,7 @@ void _noopt PPPMDisp::allocate() memory->create(sf_precoeff5_6,nfft_both_6,"pppm/disp:sf_precoeff5_6"); memory->create(sf_precoeff6_6,nfft_both_6,"pppm/disp:sf_precoeff6_6"); - } else { + } else { memory->create4d_offset(vdx_brick_none,nsplit_alloc, nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_none"); @@ -2077,11 +2100,11 @@ void _noopt PPPMDisp::allocate() gc6->setup(ngc6_buf1,ngc6_buf2); - if (differentiation_flag) npergrid6 = 1; - else npergrid6 = 3; + if (differentiation_flag) npergrid6 = 1*nsplit_alloc; + else npergrid6 = 3*nsplit_alloc; - memory->create(gc6_buf1,npergrid6*ngc6_buf1,"pppm:gc_buf1"); - memory->create(gc6_buf2,npergrid6*ngc6_buf2,"pppm:gc_buf2"); + memory->create(gc6_buf1,npergrid6*ngc6_buf1,"pppm:gc6_buf1"); + memory->create(gc6_buf2,npergrid6*ngc6_buf2,"pppm:gc6_buf2"); } } @@ -2143,13 +2166,13 @@ void PPPMDisp::allocate_peratom() // use same GC ghost grid object for peratom grid communication // but need to reallocate a larger gc_buf1 and gc_buf2 - if (differentiation_flag) npergrid = 6; - else npergrid = 7; + if (differentiation_flag) npergrid6 = 6; + else npergrid6 = 7; memory->destroy(gc6_buf1); memory->destroy(gc6_buf2); - memory->create(gc6_buf1,npergrid*ngc6_buf1,"pppm:gc6_buf1"); - memory->create(gc6_buf2,npergrid*ngc6_buf2,"pppm:gc6_buf2"); + memory->create(gc6_buf1,npergrid6*ngc6_buf1,"pppm:gc6_buf1"); + memory->create(gc6_buf2,npergrid6*ngc6_buf2,"pppm:gc6_buf2"); } if (function[2]) { @@ -2264,13 +2287,13 @@ void PPPMDisp::allocate_peratom() // use same GC ghost grid object for peratom grid communication // but need to reallocate a larger gc_buf1 and gc_buf2 - if (differentiation_flag) npergrid = 42; - else npergrid = 49; + if (differentiation_flag) npergrid6 = 42; + else npergrid6 = 49; memory->destroy(gc6_buf1); memory->destroy(gc6_buf2); - memory->create(gc6_buf1,npergrid*ngc6_buf1,"pppm:gc6_buf1"); - memory->create(gc6_buf2,npergrid*ngc6_buf2,"pppm:gc6_buf2"); + memory->create(gc6_buf1,npergrid6*ngc6_buf1,"pppm:gc6_buf1"); + memory->create(gc6_buf2,npergrid6*ngc6_buf2,"pppm:gc6_buf2"); } if (function[3]) { @@ -2301,13 +2324,13 @@ void PPPMDisp::allocate_peratom() // use same GC ghost grid object for peratom grid communication // but need to reallocate a larger gc_buf1 and gc_buf2 - if (differentiation_flag) npergrid = 6; - else npergrid = 7; + if (differentiation_flag) npergrid6 = 6*nsplit_alloc; + else npergrid6 = 7*nsplit_alloc; memory->destroy(gc6_buf1); memory->destroy(gc6_buf2); - memory->create(gc6_buf1,npergrid*ngc6_buf1,"pppm:gc6_buf1"); - memory->create(gc6_buf2,npergrid*ngc6_buf2,"pppm:gc6_buf2"); + memory->create(gc6_buf1,npergrid6*ngc6_buf1,"pppm:gc6_buf1"); + memory->create(gc6_buf2,npergrid6*ngc6_buf2,"pppm:gc6_buf2"); } } @@ -2676,7 +2699,7 @@ void PPPMDisp::set_fft_parameters(int& nx_p, int& ny_p, int& nz_p, int& nxlo_o, int& nylo_o, int& nzlo_o, int& nxhi_o, int& nyhi_o, int& nzhi_o, int& nlow, int& nupp, - int& ng, int& nf, int& nfb, + int& ng, int& nf, int& nfb, double& sft, double& sftone, int& ord) { // global indices of PPPM grid range from 0 to N-1 @@ -2814,9 +2837,9 @@ void PPPMDisp::set_fft_parameters(int& nx_p, int& ny_p, int& nz_p, ng = (nxhi_o-nxlo_o+1) * (nyhi_o-nylo_o+1) * (nzhi_o-nzlo_o+1); // FFT arrays on this proc, without ghosts - // nfft = FFT points in FFT decomposition on this proc + // nf = nfft = FFT points in FFT decomposition on this proc // nfft_brick = FFT points in 3d brick-decomposition on this proc - // nfft_both = greater of 2 values + // nfb = nfft_both = greater of 2 values nf = (nxhi_f-nxlo_f+1) * (nyhi_f-nylo_f+1) * (nzhi_f-nzlo_f+1); int nfft_brick = (nxhi_i-nxlo_i+1) * (nyhi_i-nylo_i+1) * (nzhi_i-nzlo_i+1); @@ -2851,21 +2874,23 @@ int PPPMDisp::factorable(int n) void PPPMDisp::adjust_gewald() { - // Use Newton solver to find g_ewald + // use Newton solver to find g_ewald double dx; - // Begin algorithm + // begin algorithm + + MPI_Barrier(world); for (int i = 0; i < LARGE; i++) { dx = f() / derivf(); - g_ewald -= dx; //Update g_ewald + g_ewald -= dx; // update g_ewald if (fabs(f()) < SMALL) return; } // Failed to converge - error->all(FLERR, "Could not compute g_ewald"); + error->all(FLERR,"Could not compute g_ewald"); } /* ---------------------------------------------------------------------- @@ -2887,7 +2912,6 @@ double PPPMDisp::f() double qopt = compute_qopt(); df_kspace = sqrt(qopt/natoms)*q2/(xprd*yprd*zprd_slab); - return df_rspace - df_kspace; } @@ -2898,16 +2922,18 @@ double PPPMDisp::f() double PPPMDisp::derivf() { - double h = 0.000001; //Derivative step-size double df,f1,f2,g_ewald_old; + // derivative step-size + + double h = 0.000001; + f1 = f(); g_ewald_old = g_ewald; g_ewald += h; f2 = f(); g_ewald = g_ewald_old; df = (f2 - f1)/h; - return df; } @@ -2978,6 +3004,7 @@ double PPPMDisp::compute_qopt_6() double qopt; if (differentiation_flag == 1) qopt = compute_qopt_6_ad(); else qopt = compute_qopt_6_ik(); + double qopt_all; MPI_Allreduce(&qopt,&qopt_all,1,MPI_DOUBLE,MPI_SUM,world); return qopt_all; @@ -3160,7 +3187,7 @@ double PPPMDisp::compute_qopt_ad() sum2 *= sum2; qopt += sum1 - sum2/(sum3*sum4); } - + return qopt; } @@ -3391,10 +3418,10 @@ void PPPMDisp::calc_csum() int i,j,k; delete [] cii; - cii = new double[ntypes +1]; + cii = new double[ntypes+1]; for (i = 0; i<=ntypes; i++) cii[i] = 0.0; delete [] csumi; - csumi = new double[ntypes +1]; + 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; @@ -4246,7 +4273,7 @@ void PPPMDisp::brick2fft_none() // remap could be done as pre-stage of FFT, // but this works optimally on only double values, not complex values - for (k = 0; kperform(density_fft_none[k],density_fft_none[k],work1_6); } @@ -4342,7 +4369,6 @@ void PPPMDisp::make_rho_c() int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - nx = part2grid[i][0]; ny = part2grid[i][1]; nz = part2grid[i][2]; @@ -4389,12 +4415,12 @@ void PPPMDisp::make_rho_g() // (nx,ny,nz) = global coords of grid pt to "lower left" of charge // (dx,dy,dz) = distance to "lower left" grid pt // (mx,my,mz) = global coords of moving stencil pt + int type; double **x = atom->x; int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - nx = part2grid_6[i][0]; ny = part2grid_6[i][1]; nz = part2grid_6[i][2]; @@ -4402,7 +4428,8 @@ void PPPMDisp::make_rho_g() dy = ny+shiftone_6 - (x[i][1]-boxlo[1])*delyinv_6; dz = nz+shiftone_6 - (x[i][2]-boxlo[2])*delzinv_6; - compute_rho1d(dx,dy,dz, order_6, rho_coeff_6, rho1d_6); + compute_rho1d(dx,dy,dz,order_6,rho_coeff_6,rho1d_6); + type = atom->type[i]; z0 = delvolinv_6 * B[type]; for (n = nlower_6; n <= nupper_6; n++) { @@ -4420,7 +4447,6 @@ void PPPMDisp::make_rho_g() } } - /* ---------------------------------------------------------------------- create discretized "density" on section of global grid due to my particles density(x,y,z) = dispersion "density" at grid points of my 3d brick @@ -4454,20 +4480,21 @@ void PPPMDisp::make_rho_a() // (nx,ny,nz) = global coords of grid pt to "lower left" of charge // (dx,dy,dz) = distance to "lower left" grid pt // (mx,my,mz) = global coords of moving stencil pt + int type; double **x = atom->x; int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - - //do the following for all 4 grids nx = part2grid_6[i][0]; ny = part2grid_6[i][1]; nz = part2grid_6[i][2]; dx = nx+shiftone_6 - (x[i][0]-boxlo[0])*delxinv_6; dy = ny+shiftone_6 - (x[i][1]-boxlo[1])*delyinv_6; dz = nz+shiftone_6 - (x[i][2]-boxlo[2])*delzinv_6; - compute_rho1d(dx,dy,dz, order_6, rho_coeff_6, rho1d_6); + + compute_rho1d(dx,dy,dz,order_6,rho_coeff_6,rho1d_6); + type = atom->type[i]; z0 = delvolinv_6; for (n = nlower_6; n <= nupper_6; n++) { @@ -4505,31 +4532,32 @@ void PPPMDisp::make_rho_none() FFT_SCALAR dx,dy,dz,x0,y0,z0,w; // clear 3d density array + for (k = 0; k < nsplit_alloc; k++) memset(&(density_brick_none[k][nzlo_out_6][nylo_out_6][nxlo_out_6]),0, ngrid_6*sizeof(FFT_SCALAR)); - // loop over my particles, add their contribution to nearby grid points // (nx,ny,nz) = global coords of grid pt to "lower left" of charge // (dx,dy,dz) = distance to "lower left" grid pt // (mx,my,mz) = global coords of moving stencil pt + int type; double **x = atom->x; int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - - //do the following for all 4 grids nx = part2grid_6[i][0]; ny = part2grid_6[i][1]; nz = part2grid_6[i][2]; dx = nx+shiftone_6 - (x[i][0]-boxlo[0])*delxinv_6; dy = ny+shiftone_6 - (x[i][1]-boxlo[1])*delyinv_6; dz = nz+shiftone_6 - (x[i][2]-boxlo[2])*delzinv_6; - compute_rho1d(dx,dy,dz, order_6, rho_coeff_6, rho1d_6); + + compute_rho1d(dx,dy,dz,order_6,rho_coeff_6,rho1d_6); + type = atom->type[i]; - z0 = delvolinv_6; + z0 = delvolinv_6; for (n = nlower_6; n <= nupper_6; n++) { mz = n+nz; y0 = z0*rho1d_6[2][n]; @@ -4537,17 +4565,17 @@ void PPPMDisp::make_rho_none() my = m+ny; x0 = y0*rho1d_6[1][m]; for (l = nlower_6; l <= nupper_6; l++) { - mx = l+nx; + mx = l+nx; w = x0*rho1d_6[0][l]; - for (k = 0; k < nsplit; k++) + for (k = 0; k < nsplit; k++) { density_brick_none[k][mz][my][mx] += w*B[nsplit*type + k]; + } } } } } } - /* ---------------------------------------------------------------------- FFT-based Poisson solver for ik differentiation ------------------------------------------------------------------------- */ @@ -4639,7 +4667,7 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (j = nylo_i; j <= nyhi_i; j++) for (i = nxlo_i; i <= nxhi_i; i++) { vx_brick[k][j][i] = wk2[n++]; - vy_brick[k][j][i] = wk2[n++]; + vy_brick[k][j][i] = -wk2[n++]; } // z direction gradient only @@ -4655,7 +4683,7 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, } ft2->compute(wk2,wk2,BACKWARD); - + n = 0; for (k = nzlo_i; k <= nzhi_i; k++) for (j = nylo_i; j <= nyhi_i; j++) @@ -4663,7 +4691,6 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, vz_brick[k][j][i] = wk2[n]; n += 2; } - } // z direction gradient & per-atom energy @@ -4679,13 +4706,13 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, } ft2->compute(wk2,wk2,BACKWARD); - + n = 0; for (k = nzlo_i; k <= nzhi_i; k++) for (j = nylo_i; j <= nyhi_i; j++) for (i = nxlo_i; i <= nxhi_i; i++) { vz_brick[k][j][i] = wk2[n++]; - u_pa[k][j][i] = wk2[n++];; + u_pa[k][j][i] = -wk2[n++];; } } @@ -4758,7 +4785,6 @@ void PPPMDisp::poisson_ad(FFT_SCALAR* wk1, FFT_SCALAR* wk2, wk1[n++] *= scaleinv * gfn[i]; } - n = 0; for (k = nzlo_ft; k <= nzhi_ft; k++) for (j = nylo_ft; j <= nyhi_ft; j++) @@ -4774,15 +4800,13 @@ void PPPMDisp::poisson_ad(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (k = nzlo_i; k <= nzhi_i; k++) for (j = nylo_i; j <= nyhi_i; j++) for (i = nxlo_i; i <= nxhi_i; i++) { - u_pa[k][j][i] = wk2[n++]; - n++; + u_pa[k][j][i] = wk2[n]; + n += 2; } - if (vflag_atom) poisson_peratom(wk1,wk2,ft2,vcoeff,vcoeff2,nft, nxlo_i,nylo_i,nzlo_i,nxhi_i,nyhi_i,nzhi_i, v0_pa,v1_pa,v2_pa,v3_pa,v4_pa,v5_pa); - } /* ---------------------------------------------------------------------- @@ -4815,7 +4839,7 @@ void PPPMDisp::poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT3 for (j = nylo_i; j <= nyhi_i; j++) for (i = nxlo_i; i <= nxhi_i; i++) { v0_pa[k][j][i] = wk2[n++]; - v1_pa[k][j][i] = wk2[n++]; + v1_pa[k][j][i] = -wk2[n++]; } // v2 & v3 term @@ -4834,7 +4858,7 @@ void PPPMDisp::poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT3 for (j = nylo_i; j <= nyhi_i; j++) for (i = nxlo_i; i <= nxhi_i; i++) { v2_pa[k][j][i] = wk2[n++]; - v3_pa[k][j][i] = wk2[n++]; + v3_pa[k][j][i] = -wk2[n++]; } // v4 & v5 term @@ -4853,7 +4877,7 @@ void PPPMDisp::poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT3 for (j = nylo_i; j <= nyhi_i; j++) for (i = nxlo_i; i <= nxhi_i; i++) { v4_pa[k][j][i] = wk2[n++]; - v5_pa[k][j][i] = wk2[n++]; + v5_pa[k][j][i] = -wk2[n++]; } } @@ -4887,21 +4911,20 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n = 0; for (i = 0; i < nfft_6; i++) { work1_6[n++] = dfft_1[i]; - work1_6[n++] = dfft_2[i]; + work1_6[n++] = -dfft_2[i]; } fft1_6->compute(work1_6,work1_6,FORWARD); - } // two transforms when energies and pressures are calculated - else { + } else { n = 0; for (i = 0; i < nfft_6; i++) { work1_6[n] = dfft_1[i]; work2_6[n++] = ZEROF; work1_6[n] = ZEROF; - work2_6[n++] = dfft_2[i]; + work2_6[n++] = -dfft_2[i]; } fft1_6->compute(work1_6,work1_6,FORWARD); @@ -4913,7 +4936,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n = 0; for (i = 0; i < nfft_6; i++) { eng = 2 * s2 * greensfn_6[i] * - (-work1_6[n]*work2_6[n+1] + work1_6[n+1]*work2_6[n]); + (work1_6[n+1]*work2_6[n] - work1_6[n]*work2_6[n+1]); for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; if (eflag_global) energy_6 += eng; n += 2; @@ -4922,7 +4945,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n = 0; for (i = 0; i < nfft_6; i++) { energy_6 += - 2 * s2 * greensfn_6[i] * (-work1_6[n]*work2_6[n+1] + work1_6[n+1]*work2_6[n]); + 2 * s2 * greensfn_6[i] * (work1_6[n+1]*work2_6[n] - work1_6[n]*work2_6[n+1]); n += 2; } } @@ -4962,7 +4985,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { vxbrick_1[k][j][i] = work2_6[n++]; - vxbrick_2[k][j][i] = work2_6[n++]; + vxbrick_2[k][j][i] = -work2_6[n++]; } // y direction gradient @@ -4983,7 +5006,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { vybrick_1[k][j][i] = work2_6[n++]; - vybrick_2[k][j][i] = work2_6[n++]; + vybrick_2[k][j][i] = -work2_6[n++]; } // z direction gradient @@ -5004,7 +5027,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { vzbrick_1[k][j][i] = work2_6[n++]; - vzbrick_2[k][j][i] = work2_6[n++]; + vzbrick_2[k][j][i] = -work2_6[n++]; } // per-atom energy @@ -5024,7 +5047,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { u_pa_1[k][j][i] = work2_6[n++]; - u_pa_2[k][j][i] = work2_6[n++]; + u_pa_2[k][j][i] = -work2_6[n++]; } } @@ -5034,7 +5057,6 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, v3_pa_2,v4_pa_2,v5_pa_2); } - /* ---------------------------------------------------------------------- Poisson solver for one mesh with 2 different dispersion densities for ik scheme @@ -5056,30 +5078,28 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, double scaleinv = 1.0/(nx_pppm_6*ny_pppm_6*nz_pppm_6); // transform charge/dispersion density (r -> k) - // only one tansform required when energies and pressures not needed + // only one transform required when energies and pressures not needed if (eflag_global + vflag_global == 0) { n = 0; for (i = 0; i < nfft_6; i++) { work1_6[n++] = dfft_1[i]; - work1_6[n++] = dfft_2[i]; + work1_6[n++] = -dfft_2[i]; } fft1_6->compute(work1_6,work1_6,FORWARD); - } // two transforms are required when energies and pressures are calculated - else { + } else { n = 0; for (i = 0; i < nfft_6; i++) { work1_6[n] = dfft_1[i]; work2_6[n++] = ZEROF; work1_6[n] = ZEROF; - work2_6[n++] = dfft_2[i]; + work2_6[n++] = -dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,FORWARD); fft1_6->compute(work2_6,work2_6,FORWARD); @@ -5108,9 +5128,8 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, // unify the two transformed vectors for efficient calculations later - for ( i = 0; i < 2*nfft_6; i++) { + for ( i = 0; i < 2*nfft_6; i++) work1_6[i] += work2_6[i]; - } } n = 0; @@ -5141,7 +5160,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { vxbrick_1[k][j][i] = B[n1]*work2_6[n++]; - vxbrick_2[k][j][i] = B[n2]*work2_6[n++]; + vxbrick_2[k][j][i] = -B[n2]*work2_6[n++]; } // y direction gradient @@ -5154,7 +5173,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work2_6[n+1] = 0.5*(fky_6[j]-fky2_6[j])*work1_6[n]; n += 2; } - + fft2_6->compute(work2_6,work2_6,BACKWARD); n = 0; @@ -5162,7 +5181,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { vybrick_1[k][j][i] = B[n1]*work2_6[n++]; - vybrick_2[k][j][i] = B[n2]*work2_6[n++]; + vybrick_2[k][j][i] = -B[n2]*work2_6[n++]; } // z direction gradient @@ -5183,7 +5202,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { vzbrick_1[k][j][i] = B[n1]*work2_6[n++]; - vzbrick_2[k][j][i] = B[n2]*work2_6[n++]; + vzbrick_2[k][j][i] = -B[n2]*work2_6[n++]; } // per-atom energy @@ -5203,7 +5222,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { u_pa[n1][k][j][i] = B[n1]*work2_6[n++]; - u_pa[n2][k][j][i] = B[n2]*work2_6[n++]; + u_pa[n2][k][j][i] = -B[n2]*work2_6[n++]; } } @@ -5239,21 +5258,20 @@ poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n = 0; for (i = 0; i < nfft_6; i++) { work1_6[n++] = dfft_1[i]; - work1_6[n++] = dfft_2[i]; + work1_6[n++] = -dfft_2[i]; } fft1_6->compute(work1_6,work1_6,FORWARD); - } // two transforms are required when energies and pressures are calculated - else { + } else { n = 0; for (i = 0; i < nfft_6; i++) { work1_6[n] = dfft_1[i]; work2_6[n++] = ZEROF; work1_6[n] = ZEROF; - work2_6[n++] = dfft_2[i]; + work2_6[n++] = -dfft_2[i]; } fft1_6->compute(work1_6,work1_6,FORWARD); @@ -5265,25 +5283,24 @@ poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n = 0; for (i = 0; i < nfft_6; i++) { eng = 2 * s2 * greensfn_6[i] * - (-work1_6[n]*work2_6[n+1] + work1_6[n+1]*work2_6[n]); + (work1_6[n+1]*work2_6[n] - work1_6[n]*work2_6[n+1]); for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; - if (eflag_global)energy_6 += eng; + if (eflag_global) energy_6 += eng; n += 2; } } else { n = 0; for (i = 0; i < nfft_6; i++) { energy_6 += - 2 * s2 * greensfn_6[i] * (-work1_6[n]*work2_6[n+1] + work1_6[n+1]*work2_6[n]); + 2 * s2 * greensfn_6[i] * (work1_6[n+1]*work2_6[n] - work1_6[n]*work2_6[n+1]); n += 2; } } // unify the two transformed vectors for efficient calculations later - for ( i = 0; i < 2*nfft_6; i++) { + for (i = 0; i < 2*nfft_6; i++) work1_6[i] += work2_6[i]; - } } @@ -5293,7 +5310,6 @@ poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work1_6[n++] *= scaleinv * greensfn_6[i]; } - n = 0; for (i = 0; i < nfft_6; i++) { work2_6[n] = work1_6[n]; @@ -5308,7 +5324,7 @@ poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { u_pa_1[k][j][i] = work2_6[n++]; - u_pa_2[k][j][i] = work2_6[n++]; + u_pa_2[k][j][i] = -work2_6[n++]; } if (vflag_atom) poisson_2s_peratom(v0_pa_1,v1_pa_1,v2_pa_1, @@ -5340,7 +5356,7 @@ poisson_none_ad(int n1, int n2, FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n = 0; for (i = 0; i < nfft_6; i++) { work1_6[n++] = dfft_1[i]; - work1_6[n++] = dfft_2[i]; + work1_6[n++] = -dfft_2[i]; } fft1_6->compute(work1_6,work1_6,FORWARD); @@ -5354,7 +5370,7 @@ poisson_none_ad(int n1, int n2, FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work1_6[n] = dfft_1[i]; work2_6[n++] = ZEROF; work1_6[n] = ZEROF; - work2_6[n++] = dfft_2[i]; + work2_6[n++] = -dfft_2[i]; } fft1_6->compute(work1_6,work1_6,FORWARD); @@ -5369,7 +5385,7 @@ poisson_none_ad(int n1, int n2, FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, (B[n1]*(work1_6[n]*work1_6[n] + work1_6[n+1]*work1_6[n+1]) + B[n2]*(work2_6[n]*work2_6[n] + work2_6[n+1]*work2_6[n+1])); for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; - if (eflag_global)energy_6 += eng; + if (eflag_global) energy_6 += eng; n += 2; } } else { @@ -5385,19 +5401,16 @@ poisson_none_ad(int n1, int n2, FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, // unify the two transformed vectors for efficient calculations later - for ( i = 0; i < 2*nfft_6; i++) { + for (i = 0; i < 2*nfft_6; i++) work1_6[i] += work2_6[i]; - } } - n = 0; for (i = 0; i < nfft_6; i++) { work1_6[n++] *= scaleinv * greensfn_6[i]; work1_6[n++] *= scaleinv * greensfn_6[i]; } - n = 0; for (i = 0; i < nfft_6; i++) { work2_6[n] = work1_6[n]; @@ -5412,7 +5425,7 @@ poisson_none_ad(int n1, int n2, FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { u_pa_1[k][j][i] = B[n1]*work2_6[n++]; - u_pa_2[k][j][i] = B[n2]*work2_6[n++]; + u_pa_2[k][j][i] = -B[n2]*work2_6[n++]; } if (vflag_atom) @@ -5431,9 +5444,9 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v FFT_SCALAR*** v0_pa_2, FFT_SCALAR*** v1_pa_2, FFT_SCALAR*** v2_pa_2, FFT_SCALAR*** v3_pa_2, FFT_SCALAR*** v4_pa_2, FFT_SCALAR*** v5_pa_2) { - // compute first virial term v0 + int n,i,j,k; - int n, i, j, k; + // compute first virial term v0 n = 0; for (i = 0; i < nfft_6; i++) { @@ -5449,7 +5462,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { v0_pa_1[k][j][i] = work2_6[n++]; - v0_pa_2[k][j][i] = work2_6[n++]; + v0_pa_2[k][j][i] = -work2_6[n++]; } // compute second virial term v1 @@ -5468,7 +5481,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { v1_pa_1[k][j][i] = work2_6[n++]; - v1_pa_2[k][j][i] = work2_6[n++]; + v1_pa_2[k][j][i] = -work2_6[n++]; } // compute third virial term v2 @@ -5487,7 +5500,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { v2_pa_1[k][j][i] = work2_6[n++]; - v2_pa_2[k][j][i] = work2_6[n++]; + v2_pa_2[k][j][i] = -work2_6[n++]; } // compute fourth virial term v3 @@ -5506,7 +5519,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { v3_pa_1[k][j][i] = work2_6[n++]; - v3_pa_2[k][j][i] = work2_6[n++]; + v3_pa_2[k][j][i] = -work2_6[n++]; } // compute fifth virial term v4 @@ -5525,7 +5538,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { v4_pa_1[k][j][i] = work2_6[n++]; - v4_pa_2[k][j][i] = work2_6[n++]; + v4_pa_2[k][j][i] = -work2_6[n++]; } // compute last virial term v5 @@ -5544,7 +5557,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { v5_pa_1[k][j][i] = work2_6[n++]; - v5_pa_2[k][j][i] = work2_6[n++]; + v5_pa_2[k][j][i] = -work2_6[n++]; } } @@ -5563,10 +5576,10 @@ poisson_none_peratom(int n1, int n2, FFT_SCALAR*** v3_pa_2, FFT_SCALAR*** v4_pa_2, FFT_SCALAR*** v5_pa_2) { + int n,i,j,k; + // compute first virial term v0 - int n, i, j, k; - n = 0; for (i = 0; i < nfft_6; i++) { work2_6[n] = work1_6[n]*vg_6[i][0]; @@ -5581,7 +5594,7 @@ poisson_none_peratom(int n1, int n2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { v0_pa_1[k][j][i] = B[n1]*work2_6[n++]; - v0_pa_2[k][j][i] = B[n2]*work2_6[n++]; + v0_pa_2[k][j][i] = -B[n2]*work2_6[n++]; } // compute second virial term v1 @@ -5600,7 +5613,7 @@ poisson_none_peratom(int n1, int n2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { v1_pa_1[k][j][i] = B[n1]*work2_6[n++]; - v1_pa_2[k][j][i] = B[n2]*work2_6[n++]; + v1_pa_2[k][j][i] = -B[n2]*work2_6[n++]; } // compute third virial term v2 @@ -5619,7 +5632,7 @@ poisson_none_peratom(int n1, int n2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { v2_pa_1[k][j][i] = B[n1]*work2_6[n++]; - v2_pa_2[k][j][i] = B[n2]*work2_6[n++]; + v2_pa_2[k][j][i] = -B[n2]*work2_6[n++]; } // compute fourth virial term v3 @@ -5638,7 +5651,7 @@ poisson_none_peratom(int n1, int n2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { v3_pa_1[k][j][i] = B[n1]*work2_6[n++]; - v3_pa_2[k][j][i] = B[n2]*work2_6[n++]; + v3_pa_2[k][j][i] = -B[n2]*work2_6[n++]; } // compute fifth virial term v4 @@ -5657,7 +5670,7 @@ poisson_none_peratom(int n1, int n2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { v4_pa_1[k][j][i] = B[n1]*work2_6[n++]; - v4_pa_2[k][j][i] = B[n2]*work2_6[n++]; + v4_pa_2[k][j][i] = -B[n2]*work2_6[n++]; } // compute last virial term v5 @@ -5676,7 +5689,7 @@ poisson_none_peratom(int n1, int n2, for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { v5_pa_1[k][j][i] = B[n1]*work2_6[n++]; - v5_pa_2[k][j][i] = B[n2]*work2_6[n++]; + v5_pa_2[k][j][i] = -B[n2]*work2_6[n++]; } } @@ -5711,7 +5724,7 @@ void PPPMDisp::fieldforce_c_ik() dy = ny+shiftone - (x[i][1]-boxlo[1])*delyinv; dz = nz+shiftone - (x[i][2]-boxlo[2])*delzinv; - compute_rho1d(dx,dy,dz, order, rho_coeff, rho1d); + compute_rho1d(dx,dy,dz,order,rho_coeff,rho1d); ekx = eky = ekz = ZEROF; for (n = nlower; n <= nupper; n++) { @@ -5950,6 +5963,7 @@ void PPPMDisp::fieldforce_g_ik() } // convert E-field to force + type = atom->type[i]; lj = B[type]; f[i][0] += lj*ekx; @@ -6028,6 +6042,7 @@ void PPPMDisp::fieldforce_g_ad() ekz *= hz_inv; // convert E-field to force + type = atom->type[i]; lj = B[type]; @@ -6110,6 +6125,7 @@ void PPPMDisp::fieldforce_g_peratom() } // convert E-field to force + type = atom->type[i]; lj = B[type]*0.5; @@ -6784,11 +6800,13 @@ void PPPMDisp::fieldforce_none_peratom() } } } + // convert D-field to force + type = atom->type[i]; for (k = 0; k < nsplit; k++) { lj = B[nsplit*type + k]*0.5; - + if (eflag_atom) { eatom[i] += u_pa[k]*lj; } @@ -6885,9 +6903,9 @@ void PPPMDisp::pack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - // Dispersion interactions, geometric mixing + // dispersion interactions, geometric mixing - case FORWARD_IK_G: { + case FORWARD_IK_GEOM: { FFT_SCALAR *xsrc = &vdx_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *ysrc = &vdy_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *zsrc = &vdz_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -6899,14 +6917,14 @@ void PPPMDisp::pack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - case FORWARD_AD_G: { + case FORWARD_AD_GEOM: { FFT_SCALAR *src = &u_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; for (int i = 0; i < nlist; i++) buf[i] = src[list[i]]; break; } - case FORWARD_IK_PERATOM_G: { + case FORWARD_IK_PERATOM_GEOM: { FFT_SCALAR *esrc = &u_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v0src = &v0_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v1src = &v1_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -6928,7 +6946,7 @@ void PPPMDisp::pack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - case FORWARD_AD_PERATOM_G: { + case FORWARD_AD_PERATOM_GEOM: { FFT_SCALAR *v0src = &v0_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v1src = &v1_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v2src = &v2_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -6946,9 +6964,9 @@ void PPPMDisp::pack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - // Dispersion interactions, arithmetic mixing + // dispersion interactions, arithmetic mixing - case FORWARD_IK_A: { + case FORWARD_IK_ARITH: { FFT_SCALAR *xsrc0 = &vdx_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *ysrc0 = &vdy_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *zsrc0 = &vdz_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -7009,7 +7027,7 @@ void PPPMDisp::pack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - case FORWARD_AD_A: { + case FORWARD_AD_ARITH: { FFT_SCALAR *src0 = &u_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *src1 = &u_brick_a1[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *src2 = &u_brick_a2[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -7030,7 +7048,7 @@ void PPPMDisp::pack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - case FORWARD_IK_PERATOM_A: { + case FORWARD_IK_PERATOM_ARITH: { FFT_SCALAR *esrc0 = &u_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v0src0 = &v0_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v1src0 = &v1_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -7151,7 +7169,7 @@ void PPPMDisp::pack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - case FORWARD_AD_PERATOM_A: { + case FORWARD_AD_PERATOM_ARITH: { FFT_SCALAR *v0src0 = &v0_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v1src0 = &v1_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v2src0 = &v2_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -7254,7 +7272,7 @@ void PPPMDisp::pack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - // Dispersion interactions, no mixing + // dispersion interactions, no mixing case FORWARD_IK_NONE: { for (int k = 0; k < nsplit_alloc; k++) { @@ -7398,9 +7416,9 @@ void PPPMDisp::unpack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - // Disperion interactions, geometric mixing + // disperion interactions, geometric mixing - case FORWARD_IK_G: { + case FORWARD_IK_GEOM: { FFT_SCALAR *xdest = &vdx_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *ydest = &vdy_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *zdest = &vdz_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -7412,14 +7430,14 @@ void PPPMDisp::unpack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - case FORWARD_AD_G: { + case FORWARD_AD_GEOM: { FFT_SCALAR *dest = &u_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; for (int i = 0; i < nlist; i++) dest[list[i]] = buf[n++]; break; } - case FORWARD_IK_PERATOM_G: { + case FORWARD_IK_PERATOM_GEOM: { FFT_SCALAR *esrc = &u_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v0src = &v0_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v1src = &v1_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -7441,7 +7459,7 @@ void PPPMDisp::unpack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - case FORWARD_AD_PERATOM_G: { + case FORWARD_AD_PERATOM_GEOM: { FFT_SCALAR *v0src = &v0_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v1src = &v1_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v2src = &v2_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -7459,9 +7477,9 @@ void PPPMDisp::unpack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - // Disperion interactions, arithmetic mixing + // disperion interactions, arithmetic mixing - case FORWARD_IK_A: { + case FORWARD_IK_ARITH: { FFT_SCALAR *xdest0 = &vdx_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *ydest0 = &vdy_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *zdest0 = &vdz_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -7522,7 +7540,7 @@ void PPPMDisp::unpack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - case FORWARD_AD_A: { + case FORWARD_AD_ARITH: { FFT_SCALAR *dest0 = &u_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *dest1 = &u_brick_a1[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *dest2 = &u_brick_a2[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -7543,7 +7561,7 @@ void PPPMDisp::unpack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - case FORWARD_IK_PERATOM_A: { + case FORWARD_IK_PERATOM_ARITH: { FFT_SCALAR *esrc0 = &u_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v0src0 = &v0_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v1src0 = &v1_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -7664,7 +7682,7 @@ void PPPMDisp::unpack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - case FORWARD_AD_PERATOM_A: { + case FORWARD_AD_PERATOM_ARITH: { FFT_SCALAR *v0src0 = &v0_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v1src0 = &v1_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *v2src0 = &v2_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -7767,7 +7785,7 @@ void PPPMDisp::unpack_forward_grid(int flag, void *vbuf, int nlist, int *list) break; } - // Disperion interactions, geometric mixing + // disperion interactions, geometric mixing case FORWARD_IK_NONE: { for (int k = 0; k < nsplit_alloc; k++) { @@ -7848,23 +7866,23 @@ void PPPMDisp::pack_reverse_grid(int flag, void *vbuf, int nlist, int *list) int n = 0; - //Coulomb interactions + // Coulomb interactions if (flag == REVERSE_RHO) { FFT_SCALAR *src = &density_brick[nzlo_out][nylo_out][nxlo_out]; for (int i = 0; i < nlist; i++) buf[i] = src[list[i]]; - //Dispersion interactions, geometric mixing + // dispersion interactions, geometric mixing - } else if (flag == REVERSE_RHO_G) { + } else if (flag == REVERSE_RHO_GEOM) { FFT_SCALAR *src = &density_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; for (int i = 0; i < nlist; i++) buf[i] = src[list[i]]; + + // dispersion interactions, arithmetic mixing - //Dispersion interactions, arithmetic mixing - - } else if (flag == REVERSE_RHO_A) { + } else if (flag == REVERSE_RHO_ARITH) { FFT_SCALAR *src0 = &density_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *src1 = &density_brick_a1[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *src2 = &density_brick_a2[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -7882,14 +7900,13 @@ void PPPMDisp::pack_reverse_grid(int flag, void *vbuf, int nlist, int *list) buf[n++] = src6[list[i]]; } - //Dispersion interactions, no mixing + // dispersion interactions, no mixing } else if (flag == REVERSE_RHO_NONE) { for (int k = 0; k < nsplit_alloc; k++) { FFT_SCALAR *src = &density_brick_none[k][nzlo_out_6][nylo_out_6][nxlo_out_6]; - for (int i = 0; i < nlist; i++) { + for (int i = 0; i < nlist; i++) buf[n++] = src[list[i]]; - } } } } @@ -7904,23 +7921,23 @@ void PPPMDisp::unpack_reverse_grid(int flag, void *vbuf, int nlist, int *list) int n = 0; - //Coulomb interactions + // Coulomb interactions if (flag == REVERSE_RHO) { FFT_SCALAR *dest = &density_brick[nzlo_out][nylo_out][nxlo_out]; for (int i = 0; i < nlist; i++) dest[list[i]] += buf[i]; - //Dispersion interactions, geometric mixing + // dispersion interactions, geometric mixing - } else if (flag == REVERSE_RHO_G) { + } else if (flag == REVERSE_RHO_GEOM) { FFT_SCALAR *dest = &density_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]; for (int i = 0; i < nlist; i++) dest[list[i]] += buf[i]; - //Dispersion interactions, arithmetic mixing + // dispersion interactions, arithmetic mixing - } else if (flag == REVERSE_RHO_A) { + } else if (flag == REVERSE_RHO_ARITH) { FFT_SCALAR *dest0 = &density_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *dest1 = &density_brick_a1[nzlo_out_6][nylo_out_6][nxlo_out_6]; FFT_SCALAR *dest2 = &density_brick_a2[nzlo_out_6][nylo_out_6][nxlo_out_6]; @@ -7938,7 +7955,7 @@ void PPPMDisp::unpack_reverse_grid(int flag, void *vbuf, int nlist, int *list) dest6[list[i]] += buf[n++]; } - //Dispersion interactions, no mixing + // dispersion interactions, no mixing } else if (flag == REVERSE_RHO_NONE) { for (int k = 0; k < nsplit_alloc; k++) { diff --git a/src/KSPACE/pppm_disp.h b/src/KSPACE/pppm_disp.h index 456785d8b5..02a8eb9f05 100644 --- a/src/KSPACE/pppm_disp.h +++ b/src/KSPACE/pppm_disp.h @@ -59,13 +59,6 @@ class PPPMDisp : public KSpace { virtual double memory_usage(); protected: - -/* ---------------------------------------------------------------------- -Variables needed for calculating the 1/r and 1/r^6 potential -------------------------------------------------------------------------- */ - - int function[EWALD_FUNCS]; - int me,nprocs; int nfactors; int *factors; @@ -83,6 +76,7 @@ Variables needed for calculating the 1/r and 1/r^6 potential int nsplit; int nsplit_alloc; + int function[EWALD_FUNCS]; double delxinv,delyinv,delzinv,delvolinv; double delxinv_6,delyinv_6,delzinv_6,delvolinv_6; @@ -102,6 +96,7 @@ Variables needed for calculating the 1/r and 1/r^6 potential int ngrid_6,nfft_6,nfft_both_6; //// the following variables are needed for every structure factor + FFT_SCALAR ***density_brick; FFT_SCALAR ***vdx_brick,***vdy_brick,***vdz_brick; FFT_SCALAR *density_fft; From fcf39b613a396b73ec574eec42941bab774fd812 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Tue, 15 Dec 2020 12:36:02 -0700 Subject: [PATCH 04/51] make fix phonon use of FFTs compatible --- src/USER-PHONON/fix_phonon.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/USER-PHONON/fix_phonon.cpp b/src/USER-PHONON/fix_phonon.cpp index a4915d6930..4e02147c81 100644 --- a/src/USER-PHONON/fix_phonon.cpp +++ b/src/USER-PHONON/fix_phonon.cpp @@ -46,6 +46,8 @@ using namespace FixConst; #define INVOKED_VECTOR 2 #define MAXLINE 512 +enum{FORWARD=-1,BACKWARD=1}; + static const char cite_fix_phonon[] = "fix phonon command:\n\n" "@Article{Kong11,\n" @@ -381,7 +383,7 @@ void FixPhonon::end_of_step() fft_data[m++] = static_cast(0.); } - fft->compute(fft_data, fft_data, -1); + fft->compute(fft_data,fft_data,FORWARD); m = 0; for (idq = 0; idq < mynq; ++idq){ @@ -650,7 +652,7 @@ void FixPhonon::postprocess( ) fft_data[m++] = static_cast(0.); } - fft->compute(fft_data,fft_data,-1); + fft->compute(fft_data,fft_data,FORWARD); m = 0; for (idq = 0; idq < mynq; ++idq){ From a575662d5cf88edcaad7e923881ac231a2bf5a33 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Tue, 15 Dec 2020 16:08:32 -0700 Subject: [PATCH 05/51] flip sign within FFT3d itself --- src/KSPACE/fft3d.cpp | 26 ++++---- src/KSPACE/fft3d_wrap.h | 2 + src/KSPACE/gridcomm.cpp | 2 +- src/KSPACE/pppm.cpp | 53 ++++++++-------- src/KSPACE/pppm_dipole.cpp | 109 ++++++++++++++++---------------- src/KSPACE/pppm_disp.cpp | 123 ++++++++++++++++++------------------- src/KSPACE/pppm_disp.h | 2 +- 7 files changed, 158 insertions(+), 159 deletions(-) diff --git a/src/KSPACE/fft3d.cpp b/src/KSPACE/fft3d.cpp index 0329a7a198..84534b6fd8 100644 --- a/src/KSPACE/fft3d.cpp +++ b/src/KSPACE/fft3d.cpp @@ -14,8 +14,8 @@ /* ---------------------------------------------------------------------- Contributing authors: Jim Shepherd (GA Tech) added SGI SCSL support Axel Kohlmeyer (Temple U) added support for - FFTW3, KISS FFT, Dfti/MKL, and ACML. - Phil Blood (PSC) added single precision FFT. + FFTW3, KISS FFT, Dfti/MKL, and ACML + Phil Blood (PSC) added single precision FFTs Paul Coffman (IBM) added MPI collectives remap ------------------------------------------------------------------------- */ @@ -63,7 +63,7 @@ in starting address of input data on this proc out starting address of where output data for this proc will be placed (can be same as in) - flag 1 for forward FFT, -1 for inverse FFT + flag 1 for forward FFT, -1 for backward FFT plan plan returned by previous call to fft_3d_create_plan ------------------------------------------------------------------------- */ @@ -103,18 +103,18 @@ void fft_3d(FFT_DATA *in, FFT_DATA *out, int flag, struct fft_plan_3d *plan) length = plan->length1; #if defined(FFT_MKL) - if (flag == -1) + if (flag == 1) DftiComputeForward(plan->handle_fast,data); else DftiComputeBackward(plan->handle_fast,data); #elif defined(FFT_FFTW3) - if (flag == -1) + if (flag == 1) theplan=plan->plan_fast_forward; else theplan=plan->plan_fast_backward; FFTW_API(execute_dft)(theplan,data,data); #else - if (flag == -1) + if (flag == 1) for (offset = 0; offset < total; offset += length) kiss_fft(plan->cfg_fast_forward,&data[offset],&data[offset]); else @@ -137,18 +137,18 @@ void fft_3d(FFT_DATA *in, FFT_DATA *out, int flag, struct fft_plan_3d *plan) length = plan->length2; #if defined(FFT_MKL) - if (flag == -1) + if (flag == 1) DftiComputeForward(plan->handle_mid,data); else DftiComputeBackward(plan->handle_mid,data); #elif defined(FFT_FFTW3) - if (flag == -1) + if (flag == 1) theplan=plan->plan_mid_forward; else theplan=plan->plan_mid_backward; FFTW_API(execute_dft)(theplan,data,data); #else - if (flag == -1) + if (flag == 1) for (offset = 0; offset < total; offset += length) kiss_fft(plan->cfg_mid_forward,&data[offset],&data[offset]); else @@ -171,18 +171,18 @@ void fft_3d(FFT_DATA *in, FFT_DATA *out, int flag, struct fft_plan_3d *plan) length = plan->length3; #if defined(FFT_MKL) - if (flag == -1) + if (flag == 1) DftiComputeForward(plan->handle_slow,data); else DftiComputeBackward(plan->handle_slow,data); #elif defined(FFT_FFTW3) - if (flag == -1) + if (flag == 1) theplan=plan->plan_slow_forward; else theplan=plan->plan_slow_backward; FFTW_API(execute_dft)(theplan,data,data); #else - if (flag == -1) + if (flag == 1) for (offset = 0; offset < total; offset += length) kiss_fft(plan->cfg_slow_forward,&data[offset],&data[offset]); else @@ -199,7 +199,7 @@ void fft_3d(FFT_DATA *in, FFT_DATA *out, int flag, struct fft_plan_3d *plan) // scaling if required - if (flag == 1 && plan->scaled) { + if (flag == -1 && plan->scaled) { norm = plan->norm; num = plan->normnum; #if defined(FFT_FFTW3) diff --git a/src/KSPACE/fft3d_wrap.h b/src/KSPACE/fft3d_wrap.h index 372dced4ef..2809b0cd7e 100644 --- a/src/KSPACE/fft3d_wrap.h +++ b/src/KSPACE/fft3d_wrap.h @@ -21,6 +21,8 @@ namespace LAMMPS_NS { class FFT3d : protected Pointers { public: + enum{FORWARD=1,BACKWARD=-1}; + FFT3d(class LAMMPS *, MPI_Comm,int,int,int,int,int,int,int,int,int, int,int,int,int,int,int,int,int,int *,int); ~FFT3d(); diff --git a/src/KSPACE/gridcomm.cpp b/src/KSPACE/gridcomm.cpp index a6445f023e..186cfad7b6 100644 --- a/src/KSPACE/gridcomm.cpp +++ b/src/KSPACE/gridcomm.cpp @@ -525,7 +525,7 @@ void GridComm::setup_regular(int &nbuf1, int &nbuf2) ngrid = MAX(ngrid,swap[i].npack); ngrid = MAX(ngrid,swap[i].nunpack); } - + nbuf1 = nbuf2 = ngrid; } diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index 489e8e28af..1d50eab50d 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -51,7 +51,6 @@ using namespace MathSpecial; enum{REVERSE_RHO}; enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; -enum{FORWARD=-1,BACKWARD=1}; #ifdef FFT_SINGLE #define ZEROF 0.0f @@ -2014,7 +2013,7 @@ void PPPM::poisson_ik() work1[n++] = ZEROF; } - fft1->compute(work1,work1,FORWARD); + fft1->compute(work1,work1,FFT3d::FORWARD); // global energy and virial contribution @@ -2075,7 +2074,7 @@ void PPPM::poisson_ik() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2096,7 +2095,7 @@ void PPPM::poisson_ik() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2117,7 +2116,7 @@ void PPPM::poisson_ik() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2149,7 +2148,7 @@ void PPPM::poisson_ik_triclinic() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2168,7 +2167,7 @@ void PPPM::poisson_ik_triclinic() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2187,7 +2186,7 @@ void PPPM::poisson_ik_triclinic() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2215,7 +2214,7 @@ void PPPM::poisson_ad() work1[n++] = ZEROF; } - fft1->compute(work1,work1,FORWARD); + fft1->compute(work1,work1,FFT3d::FORWARD); // global energy and virial contribution @@ -2261,7 +2260,7 @@ void PPPM::poisson_ad() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2290,7 +2289,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2312,7 +2311,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2329,7 +2328,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2346,7 +2345,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2363,7 +2362,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2380,7 +2379,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2397,7 +2396,7 @@ void PPPM::poisson_peratom() n += 2; } - fft2->compute(work2,work2,BACKWARD); + fft2->compute(work2,work2,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -3006,11 +3005,11 @@ int PPPM::timing_1d(int n, double &time1d) time1 = MPI_Wtime(); for (int i = 0; i < n; i++) { - fft1->timing1d(work1,nfft_both,FORWARD); - fft2->timing1d(work1,nfft_both,BACKWARD); + fft1->timing1d(work1,nfft_both,FFT3d::FORWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); if (differentiation_flag != 1) { - fft2->timing1d(work1,nfft_both,BACKWARD); - fft2->timing1d(work1,nfft_both,BACKWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); } } @@ -3036,11 +3035,11 @@ int PPPM::timing_3d(int n, double &time3d) time1 = MPI_Wtime(); for (int i = 0; i < n; i++) { - fft1->compute(work1,work1,FORWARD); - fft2->compute(work1,work1,BACKWARD); + fft1->compute(work1,work1,FFT3d::FORWARD); + fft2->compute(work1,work1,FFT3d::BACKWARD); if (differentiation_flag != 1) { - fft2->compute(work1,work1,BACKWARD); - fft2->compute(work1,work1,BACKWARD); + fft2->compute(work1,work1,FFT3d::BACKWARD); + fft2->compute(work1,work1,FFT3d::BACKWARD); } } @@ -3317,7 +3316,7 @@ void PPPM::poisson_groups(int AA_flag) work_A[n++] = ZEROF; } - fft1->compute(work_A,work_A,FORWARD); + fft1->compute(work_A,work_A,FFT3d::FORWARD); // group B @@ -3327,7 +3326,7 @@ void PPPM::poisson_groups(int AA_flag) work_B[n++] = ZEROF; } - fft1->compute(work_B,work_B,FORWARD); + fft1->compute(work_B,work_B,FFT3d::FORWARD); // group-group energy and force contribution, // keep everything in reciprocal space so diff --git a/src/KSPACE/pppm_dipole.cpp b/src/KSPACE/pppm_dipole.cpp index 884bd3731c..7a472be818 100644 --- a/src/KSPACE/pppm_dipole.cpp +++ b/src/KSPACE/pppm_dipole.cpp @@ -46,7 +46,6 @@ using namespace MathSpecial; enum{REVERSE_MU}; enum{FORWARD_MU,FORWARD_MU_PERATOM}; -enum{FORWARD=-1,BACKWARD=1}; #ifdef FFT_SINGLE #define ZEROF 0.0f @@ -1294,9 +1293,9 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft1->compute(work1,work1,FORWARD); - fft1->compute(work2,work2,FORWARD); - fft1->compute(work3,work3,FORWARD); + fft1->compute(work1,work1,FFT3d::FORWARD); + fft1->compute(work2,work2,FFT3d::FORWARD); + fft1->compute(work3,work3,FFT3d::FORWARD); // global energy and virial contribution @@ -1372,7 +1371,7 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1393,7 +1392,7 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1414,7 +1413,7 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1437,7 +1436,7 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1460,7 +1459,7 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1483,7 +1482,7 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1506,7 +1505,7 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1529,7 +1528,7 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1552,7 +1551,7 @@ void PPPMDipole::poisson_ik_dipole() n += 2; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1590,7 +1589,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1615,7 +1614,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1640,7 +1639,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1665,7 +1664,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1690,7 +1689,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1715,7 +1714,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1740,7 +1739,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1765,7 +1764,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1790,7 +1789,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1815,7 +1814,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1840,7 +1839,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1865,7 +1864,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1890,7 +1889,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1915,7 +1914,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1940,7 +1939,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1965,7 +1964,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -1990,7 +1989,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2015,7 +2014,7 @@ void PPPMDipole::poisson_peratom_dipole() ii++; } - fft2->compute(work4,work4,BACKWARD); + fft2->compute(work4,work4,FFT3d::BACKWARD); n = 0; for (k = nzlo_in; k <= nzhi_in; k++) @@ -2446,18 +2445,18 @@ int PPPMDipole::timing_1d(int n, double &time1d) time1 = MPI_Wtime(); for (int i = 0; i < n; i++) { - fft1->timing1d(work1,nfft_both,FORWARD); - fft1->timing1d(work1,nfft_both,FORWARD); - fft1->timing1d(work1,nfft_both,FORWARD); - fft2->timing1d(work1,nfft_both,BACKWARD); - fft2->timing1d(work1,nfft_both,BACKWARD); - fft2->timing1d(work1,nfft_both,BACKWARD); - fft2->timing1d(work1,nfft_both,BACKWARD); - fft2->timing1d(work1,nfft_both,BACKWARD); - fft2->timing1d(work1,nfft_both,BACKWARD); - fft2->timing1d(work1,nfft_both,BACKWARD); - fft2->timing1d(work1,nfft_both,BACKWARD); - fft2->timing1d(work1,nfft_both,BACKWARD); + fft1->timing1d(work1,nfft_both,FFT3d::FORWARD); + fft1->timing1d(work1,nfft_both,FFT3d::FORWARD); + fft1->timing1d(work1,nfft_both,FFT3d::FORWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); } MPI_Barrier(world); @@ -2481,18 +2480,18 @@ int PPPMDipole::timing_3d(int n, double &time3d) time1 = MPI_Wtime(); for (int i = 0; i < n; i++) { - fft1->compute(work1,work1,FORWARD); - fft1->compute(work1,work1,FORWARD); - fft1->compute(work1,work1,FORWARD); - fft2->compute(work1,work1,BACKWARD); - fft2->compute(work1,work1,BACKWARD); - fft2->compute(work1,work1,BACKWARD); - fft2->compute(work1,work1,BACKWARD); - fft2->compute(work1,work1,BACKWARD); - fft2->compute(work1,work1,BACKWARD); - fft2->compute(work1,work1,BACKWARD); - fft2->compute(work1,work1,BACKWARD); - fft2->compute(work1,work1,BACKWARD); + fft1->compute(work1,work1,FFT3d::FFT3d::FORWARD); + fft1->compute(work1,work1,FFT3d::FFT3d::FORWARD); + fft1->compute(work1,work1,FFT3d::FFT3d::FORWARD); + fft2->compute(work1,work1,FFT3d::FFT3d::BACKWARD); + fft2->compute(work1,work1,FFT3d::FFT3d::BACKWARD); + fft2->compute(work1,work1,FFT3d::FFT3d::BACKWARD); + fft2->compute(work1,work1,FFT3d::FFT3d::BACKWARD); + fft2->compute(work1,work1,FFT3d::FFT3d::BACKWARD); + fft2->compute(work1,work1,FFT3d::FFT3d::BACKWARD); + fft2->compute(work1,work1,FFT3d::FFT3d::BACKWARD); + fft2->compute(work1,work1,FFT3d::FFT3d::BACKWARD); + fft2->compute(work1,work1,FFT3d::FFT3d::BACKWARD); } MPI_Barrier(world); diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 6ad39d8d1b..85bc461848 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -53,7 +53,6 @@ enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM, FORWARD_IK_PERATOM_ARITH,FORWARD_AD_PERATOM_ARITH, FORWARD_IK_NONE,FORWARD_AD_NONE,FORWARD_IK_PERATOM_NONE, FORWARD_AD_PERATOM_NONE}; -enum{FORWARD=-1,BACKWARD=1}; #ifdef FFT_SINGLE #define ZEROF 0.0f @@ -4610,7 +4609,7 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, wk1[n++] = ZEROF; } - ft1->compute(wk1,wk1,FORWARD); + ft1->compute(wk1,wk1,FFT3d::FORWARD); // if requested, compute energy and virial contribution @@ -4660,7 +4659,7 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, n += 2; } - ft2->compute(wk2,wk2,BACKWARD); + ft2->compute(wk2,wk2,FFT3d::BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4682,7 +4681,7 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, n += 2; } - ft2->compute(wk2,wk2,BACKWARD); + ft2->compute(wk2,wk2,FFT3d::BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4705,7 +4704,7 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, n += 2; } - ft2->compute(wk2,wk2,BACKWARD); + ft2->compute(wk2,wk2,FFT3d::BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4750,7 +4749,7 @@ void PPPMDisp::poisson_ad(FFT_SCALAR* wk1, FFT_SCALAR* wk2, wk1[n++] = ZEROF; } - ft1->compute(wk1,wk1,FORWARD); + ft1->compute(wk1,wk1,FFT3d::FORWARD); // if requested, compute energy and virial contribution @@ -4794,7 +4793,7 @@ void PPPMDisp::poisson_ad(FFT_SCALAR* wk1, FFT_SCALAR* wk2, n += 2; } - ft2->compute(wk2,wk2,BACKWARD); + ft2->compute(wk2,wk2,FFT3d::BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4832,7 +4831,7 @@ void PPPMDisp::poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT3 n += 2; } - ft2->compute(wk2,wk2,BACKWARD); + ft2->compute(wk2,wk2,FFT3d::BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4851,7 +4850,7 @@ void PPPMDisp::poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT3 n += 2; } - ft2->compute(wk2,wk2,BACKWARD); + ft2->compute(wk2,wk2,FFT3d::BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4870,7 +4869,7 @@ void PPPMDisp::poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT3 n += 2; } - ft2->compute(wk2,wk2,BACKWARD); + ft2->compute(wk2,wk2,FFT3d::BACKWARD); n = 0; for (k = nzlo_i; k <= nzhi_i; k++) @@ -4914,7 +4913,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work1_6[n++] = -dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,FORWARD); + fft1_6->compute(work1_6,work1_6,FFT3d::FORWARD); // two transforms when energies and pressures are calculated @@ -4927,8 +4926,8 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work2_6[n++] = -dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,FORWARD); - fft1_6->compute(work2_6,work2_6,FORWARD); + fft1_6->compute(work1_6,work1_6,FFT3d::FORWARD); + fft1_6->compute(work2_6,work2_6,FFT3d::FORWARD); double s2 = scaleinv*scaleinv; @@ -4978,7 +4977,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -4999,7 +4998,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5020,7 +5019,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5040,7 +5039,7 @@ poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5087,7 +5086,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work1_6[n++] = -dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,FORWARD); + fft1_6->compute(work1_6,work1_6,FFT3d::FORWARD); // two transforms are required when energies and pressures are calculated @@ -5100,8 +5099,8 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work2_6[n++] = -dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,FORWARD); - fft1_6->compute(work2_6,work2_6,FORWARD); + fft1_6->compute(work1_6,work1_6,FFT3d::FORWARD); + fft1_6->compute(work2_6,work2_6,FFT3d::FORWARD); double s2 = scaleinv*scaleinv; @@ -5153,7 +5152,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5174,7 +5173,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5195,7 +5194,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5215,7 +5214,7 @@ poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5261,7 +5260,7 @@ poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work1_6[n++] = -dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,FORWARD); + fft1_6->compute(work1_6,work1_6,FFT3d::FORWARD); // two transforms are required when energies and pressures are calculated @@ -5274,8 +5273,8 @@ poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work2_6[n++] = -dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,FORWARD); - fft1_6->compute(work2_6,work2_6,FORWARD); + fft1_6->compute(work1_6,work1_6,FFT3d::FORWARD); + fft1_6->compute(work2_6,work2_6,FFT3d::FORWARD); double s2 = scaleinv*scaleinv; @@ -5317,7 +5316,7 @@ poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5359,7 +5358,7 @@ poisson_none_ad(int n1, int n2, FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work1_6[n++] = -dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,FORWARD); + fft1_6->compute(work1_6,work1_6,FFT3d::FORWARD); } // two transforms are required when energies and pressures are calculated @@ -5373,8 +5372,8 @@ poisson_none_ad(int n1, int n2, FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, work2_6[n++] = -dfft_2[i]; } - fft1_6->compute(work1_6,work1_6,FORWARD); - fft1_6->compute(work2_6,work2_6,FORWARD); + fft1_6->compute(work1_6,work1_6,FFT3d::FORWARD); + fft1_6->compute(work2_6,work2_6,FFT3d::FORWARD); double s2 = scaleinv*scaleinv; @@ -5418,7 +5417,7 @@ poisson_none_ad(int n1, int n2, FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5455,7 +5454,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5474,7 +5473,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5493,7 +5492,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5512,7 +5511,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5531,7 +5530,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5550,7 +5549,7 @@ poisson_2s_peratom(FFT_SCALAR*** v0_pa_1, FFT_SCALAR*** v1_pa_1, FFT_SCALAR*** v n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5587,7 +5586,7 @@ poisson_none_peratom(int n1, int n2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5606,7 +5605,7 @@ poisson_none_peratom(int n1, int n2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5625,7 +5624,7 @@ poisson_none_peratom(int n1, int n2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5644,7 +5643,7 @@ poisson_none_peratom(int n1, int n2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5663,7 +5662,7 @@ poisson_none_peratom(int n1, int n2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -5682,7 +5681,7 @@ poisson_none_peratom(int n1, int n2, n += 2; } - fft2_6->compute(work2_6,work2_6,BACKWARD); + fft2_6->compute(work2_6,work2_6,FFT3d::BACKWARD); n = 0; for (k = nzlo_in_6; k <= nzhi_in_6; k++) @@ -8203,11 +8202,11 @@ int PPPMDisp::timing_1d(int n, double &time1d) if (function[0]) { for (int i = 0; i < n; i++) { - fft1->timing1d(work1,nfft_both,FORWARD); - fft2->timing1d(work1,nfft_both,BACKWARD); - if (differentiation_flag != 1){ - fft2->timing1d(work1,nfft_both,BACKWARD); - fft2->timing1d(work1,nfft_both,BACKWARD); + fft1->timing1d(work1,nfft_both,FFT3d::FORWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); + if (differentiation_flag != 1) { + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); + fft2->timing1d(work1,nfft_both,FFT3d::BACKWARD); } } } @@ -8221,11 +8220,11 @@ int PPPMDisp::timing_1d(int n, double &time1d) if (function[1] + function[2] + function[3]) { for (int i = 0; i < n; i++) { - fft1_6->timing1d(work1_6,nfft_both_6,FORWARD); - fft2_6->timing1d(work1_6,nfft_both_6,BACKWARD); - if (differentiation_flag != 1){ - fft2_6->timing1d(work1_6,nfft_both_6,BACKWARD); - fft2_6->timing1d(work1_6,nfft_both_6,BACKWARD); + fft1_6->timing1d(work1_6,nfft_both_6,FFT3d::FORWARD); + fft2_6->timing1d(work1_6,nfft_both_6,FFT3d::BACKWARD); + if (differentiation_flag != 1) { + fft2_6->timing1d(work1_6,nfft_both_6,FFT3d::BACKWARD); + fft2_6->timing1d(work1_6,nfft_both_6,FFT3d::BACKWARD); } } } @@ -8258,11 +8257,11 @@ int PPPMDisp::timing_3d(int n, double &time3d) if (function[0]) { for (int i = 0; i < n; i++) { - fft1->compute(work1,work1,FORWARD); - fft2->compute(work1,work1,BACKWARD); + fft1->compute(work1,work1,FFT3d::FORWARD); + fft2->compute(work1,work1,FFT3d::BACKWARD); if (differentiation_flag != 1) { - fft2->compute(work1,work1,BACKWARD); - fft2->compute(work1,work1,BACKWARD); + fft2->compute(work1,work1,FFT3d::BACKWARD); + fft2->compute(work1,work1,FFT3d::BACKWARD); } } } @@ -8276,11 +8275,11 @@ int PPPMDisp::timing_3d(int n, double &time3d) if (function[1] + function[2] + function[3]) { for (int i = 0; i < n; i++) { - fft1_6->compute(work1_6,work1_6,FORWARD); - fft2_6->compute(work1_6,work1_6,BACKWARD); + fft1_6->compute(work1_6,work1_6,FFT3d::FORWARD); + fft2_6->compute(work1_6,work1_6,FFT3d::BACKWARD); if (differentiation_flag != 1) { - fft2_6->compute(work1_6,work1_6,BACKWARD); - fft2_6->compute(work1_6,work1_6,BACKWARD); + fft2_6->compute(work1_6,work1_6,FFT3d::BACKWARD); + fft2_6->compute(work1_6,work1_6,FFT3d::BACKWARD); } } } diff --git a/src/KSPACE/pppm_disp.h b/src/KSPACE/pppm_disp.h index 02a8eb9f05..7afd2e1119 100644 --- a/src/KSPACE/pppm_disp.h +++ b/src/KSPACE/pppm_disp.h @@ -95,7 +95,7 @@ class PPPMDisp : public KSpace { int nlower_6,nupper_6; int ngrid_6,nfft_6,nfft_both_6; - //// the following variables are needed for every structure factor + // the following variables are needed for every structure factor FFT_SCALAR ***density_brick; FFT_SCALAR ***vdx_brick,***vdy_brick,***vdz_brick; From 21f1fae60effd1f46815a31126f98c071b023f2a Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 16 Dec 2020 15:05:38 -0700 Subject: [PATCH 06/51] FFT changes for KOKKOS --- src/KOKKOS/fft3d_kokkos.cpp | 22 +++++++++--------- src/KOKKOS/fft3d_kokkos.h | 1 + src/KOKKOS/pppm_kokkos.cpp | 45 ++++++++++++++++++------------------- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/KOKKOS/fft3d_kokkos.cpp b/src/KOKKOS/fft3d_kokkos.cpp index 04a5512cc7..5db9ea607e 100644 --- a/src/KOKKOS/fft3d_kokkos.cpp +++ b/src/KOKKOS/fft3d_kokkos.cpp @@ -215,12 +215,12 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, length = plan->length1; #if defined(FFT_MKL) - if (flag == -1) + if (flag == FORWARD) DftiComputeForward(plan->handle_fast,d_data.data()); else DftiComputeBackward(plan->handle_fast,d_data.data()); #elif defined(FFT_FFTW3) - if (flag == -1) + if (flag == FORWARD) FFTW_API(execute_dft)(plan->plan_fast_forward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); else FFTW_API(execute_dft)(plan->plan_fast_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); @@ -230,7 +230,7 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, typename FFT_AT::t_FFT_DATA_1d d_tmp = typename FFT_AT::t_FFT_DATA_1d(Kokkos::view_alloc("fft_3d:tmp",Kokkos::WithoutInitializing),d_data.extent(0)); kiss_fft_functor f; - if (flag == -1) + if (flag == FORWARD) f = kiss_fft_functor(d_data,d_tmp,plan->cfg_fast_forward,length); else f = kiss_fft_functor(d_data,d_tmp,plan->cfg_fast_backward,length); @@ -238,7 +238,6 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, d_data = d_tmp; #endif - // 1st mid-remap to prepare for 2nd FFTs // copy = loc for remap result @@ -260,12 +259,12 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, length = plan->length2; #if defined(FFT_MKL) - if (flag == -1) + if (flag == FORWARD) DftiComputeForward(plan->handle_mid,d_data.data()); else DftiComputeBackward(plan->handle_mid,d_data.data()); #elif defined(FFT_FFTW3) - if (flag == -1) + if (flag == FORWARD) FFTW_API(execute_dft)(plan->plan_mid_forward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); else FFTW_API(execute_dft)(plan->plan_mid_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); @@ -273,7 +272,7 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, cufftExec(plan->plan_mid,d_data.data(),d_data.data(),flag); #else d_tmp = typename FFT_AT::t_FFT_DATA_1d(Kokkos::view_alloc("fft_3d:tmp",Kokkos::WithoutInitializing),d_data.extent(0)); - if (flag == -1) + if (flag == FORWARD) f = kiss_fft_functor(d_data,d_tmp,plan->cfg_mid_forward,length); else f = kiss_fft_functor(d_data,d_tmp,plan->cfg_mid_backward,length); @@ -302,12 +301,12 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, length = plan->length3; #if defined(FFT_MKL) - if (flag == -1) + if (flag == FORWARD) DftiComputeForward(plan->handle_slow,d_data.data()); else DftiComputeBackward(plan->handle_slow,d_data.data()); #elif defined(FFT_FFTW3) - if (flag == -1) + if (flag == FORWARD) FFTW_API(execute_dft)(plan->plan_slow_forward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); else FFTW_API(execute_dft)(plan->plan_slow_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); @@ -315,7 +314,7 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, cufftExec(plan->plan_slow,d_data.data(),d_data.data(),flag); #else d_tmp = typename FFT_AT::t_FFT_DATA_1d(Kokkos::view_alloc("fft_3d:tmp",Kokkos::WithoutInitializing),d_data.extent(0)); - if (flag == -1) + if (flag == FORWARD) f = kiss_fft_functor(d_data,d_tmp,plan->cfg_slow_forward,length); else f = kiss_fft_functor(d_data,d_tmp,plan->cfg_slow_backward,length); @@ -323,7 +322,6 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, d_data = d_tmp; #endif - // post-remap to put data in output format if needed // destination is always out @@ -338,7 +336,7 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, // scaling if required - if (flag == 1 && plan->scaled) { + if (flag == BACKWARD && plan->scaled) { FFT_SCALAR norm = plan->norm; int num = plan->normnum; diff --git a/src/KOKKOS/fft3d_kokkos.h b/src/KOKKOS/fft3d_kokkos.h index 192d2cb7da..d78cd6d7c9 100644 --- a/src/KOKKOS/fft3d_kokkos.h +++ b/src/KOKKOS/fft3d_kokkos.h @@ -72,6 +72,7 @@ struct fft_plan_3d_kokkos { template class FFT3dKokkos : protected Pointers { public: + enum{FORWARD=1,BACKWARD=-1}; typedef DeviceType device_type; typedef FFTArrayTypes FFT_AT; diff --git a/src/KOKKOS/pppm_kokkos.cpp b/src/KOKKOS/pppm_kokkos.cpp index 6af8ea230e..0b86c01d42 100644 --- a/src/KOKKOS/pppm_kokkos.cpp +++ b/src/KOKKOS/pppm_kokkos.cpp @@ -1653,8 +1653,7 @@ void PPPMKokkos::poisson_ik() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft1->compute(d_work1,d_work1,1); - + fft1->compute(d_work1,d_work1,FFT3d::FORWARD); // global energy and virial contribution @@ -1717,7 +1716,7 @@ void PPPMKokkos::poisson_ik() Kokkos::parallel_for(Kokkos::RangePolicy(0,inum_fft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,-1); + fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); copymode = 1; @@ -1731,7 +1730,7 @@ void PPPMKokkos::poisson_ik() Kokkos::parallel_for(Kokkos::RangePolicy(0,inum_fft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,-1); + fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); copymode = 1; @@ -1744,7 +1743,7 @@ void PPPMKokkos::poisson_ik() Kokkos::parallel_for(Kokkos::RangePolicy(0,inum_fft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,-1); + fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); copymode = 1; @@ -1883,7 +1882,7 @@ void PPPMKokkos::poisson_ik_triclinic() // n += 2; // } // -// fft2->compute(d_work2,d_work2,-1); +// fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); // // n = 0; // for (k = nzlo_in-nzlo_out; k <= nzhi_in-nzlo_out; k++) // parallel_for2 @@ -1898,7 +1897,7 @@ void PPPMKokkos::poisson_ik_triclinic() // n += 2; // } // -// fft2->compute(d_work2,d_work2,-1); +// fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); // // n = 0; // for (k = nzlo_in-nzlo_out; k <= nzhi_in-nzlo_out; k++) // parallel_for4 @@ -1917,7 +1916,7 @@ void PPPMKokkos::poisson_ik_triclinic() // n += 2; // } // -// fft2->compute(d_work2,d_work2,-1); +// fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); // // n = 0; // for (k = nzlo_in-nzlo_out; k <= nzhi_in-nzlo_out; k++) // parallel_for6 @@ -2000,7 +1999,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,-1); + fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); copymode = 1; @@ -2017,7 +2016,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,-1); + fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); copymode = 1; @@ -2029,7 +2028,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,-1); + fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); copymode = 1; @@ -2041,7 +2040,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,-1); + fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); copymode = 1; @@ -2052,7 +2051,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,-1); + fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); copymode = 1; @@ -2064,7 +2063,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,-1); + fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); copymode = 1; @@ -2076,7 +2075,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,-1); + fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); copymode = 1; @@ -2818,10 +2817,10 @@ int PPPMKokkos::timing_1d(int n, double &time1d) time1 = MPI_Wtime(); for (int i = 0; i < n; i++) { - fft1->timing1d(d_work1,nfft_both,1); - fft2->timing1d(d_work1,nfft_both,-1); - fft2->timing1d(d_work1,nfft_both,-1); - fft2->timing1d(d_work1,nfft_both,-1); + fft1->timing1d(d_work1,nfft_both,FFT3d::FORWARD); + fft2->timing1d(d_work1,nfft_both,FFT3d::BACKWARD); + fft2->timing1d(d_work1,nfft_both,FFT3d::BACKWARD); + fft2->timing1d(d_work1,nfft_both,FFT3d::BACKWARD); } MPI_Barrier(world); @@ -2855,10 +2854,10 @@ int PPPMKokkos::timing_3d(int n, double &time3d) time1 = MPI_Wtime(); for (int i = 0; i < n; i++) { - fft1->compute(d_work1,d_work1,1); - fft2->compute(d_work1,d_work1,-1); - fft2->compute(d_work1,d_work1,-1); - fft2->compute(d_work1,d_work1,-1); + fft1->compute(d_work1,d_work1,FFT3d::FORWARD); + fft2->compute(d_work1,d_work1,FFT3d::BACKWARD); + fft2->compute(d_work1,d_work1,FFT3d::BACKWARD); + fft2->compute(d_work1,d_work1,FFT3d::BACKWARD); } MPI_Barrier(world); From 8efd1c93ec8a2f65c31331a0111bda038b3816ce Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 09:19:01 -0700 Subject: [PATCH 07/51] Add more granular control of Kokkos pair and fix comm --- src/KOKKOS/comm_kokkos.cpp | 22 ++++- src/KOKKOS/comm_kokkos.h | 4 + src/KOKKOS/fix_qeq_reax_kokkos.cpp | 80 +++++++++++-------- src/KOKKOS/kokkos.cpp | 59 ++++++++++++++ src/KOKKOS/kokkos.h | 6 ++ src/KOKKOS/pair_buck_coul_cut_kokkos.cpp | 1 + src/KOKKOS/pair_buck_coul_long_kokkos.cpp | 1 + src/KOKKOS/pair_buck_kokkos.cpp | 1 + src/KOKKOS/pair_coul_cut_kokkos.cpp | 1 + src/KOKKOS/pair_coul_debye_kokkos.cpp | 1 + src/KOKKOS/pair_coul_dsf_kokkos.cpp | 1 + src/KOKKOS/pair_coul_long_kokkos.cpp | 1 + src/KOKKOS/pair_coul_wolf_kokkos.cpp | 1 + src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp | 1 + src/KOKKOS/pair_eam_alloy_kokkos.cpp | 19 ++++- src/KOKKOS/pair_eam_fs_kokkos.cpp | 17 +++- src/KOKKOS/pair_eam_kokkos.cpp | 19 ++++- src/KOKKOS/pair_exp6_rx_kokkos.cpp | 1 + src/KOKKOS/pair_gran_hooke_history_kokkos.cpp | 1 + src/KOKKOS/pair_hybrid_kokkos.cpp | 1 + ..._lj_charmm_coul_charmm_implicit_kokkos.cpp | 1 + .../pair_lj_charmm_coul_charmm_kokkos.cpp | 1 + .../pair_lj_charmm_coul_long_kokkos.cpp | 1 + src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp | 1 + .../pair_lj_class2_coul_long_kokkos.cpp | 1 + src/KOKKOS/pair_lj_class2_kokkos.cpp | 1 + src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp | 1 + src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp | 1 + src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp | 1 + src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp | 1 + src/KOKKOS/pair_lj_cut_kokkos.cpp | 1 + src/KOKKOS/pair_lj_expand_kokkos.cpp | 1 + .../pair_lj_gromacs_coul_gromacs_kokkos.cpp | 1 + src/KOKKOS/pair_lj_gromacs_kokkos.cpp | 1 + src/KOKKOS/pair_lj_sdk_kokkos.cpp | 1 + src/KOKKOS/pair_morse_kokkos.cpp | 1 + src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp | 1 + src/KOKKOS/pair_reaxc_kokkos.cpp | 1 + src/KOKKOS/pair_snap_kokkos_impl.h | 1 + src/KOKKOS/pair_sw_kokkos.cpp | 1 + src/KOKKOS/pair_table_kokkos.cpp | 1 + src/KOKKOS/pair_table_rx_kokkos.cpp | 1 + src/KOKKOS/pair_tersoff_kokkos.cpp | 1 + src/KOKKOS/pair_tersoff_mod_kokkos.cpp | 1 + src/KOKKOS/pair_tersoff_zbl_kokkos.cpp | 1 + src/KOKKOS/pair_vashishta_kokkos.cpp | 1 + src/KOKKOS/pair_yukawa_kokkos.cpp | 1 + src/KOKKOS/pair_zbl_kokkos.cpp | 1 + src/pair.cpp | 1 + src/pair.h | 1 + 50 files changed, 224 insertions(+), 44 deletions(-) diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index 2ef4b14d4f..c57a2c1431 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -107,9 +107,13 @@ void CommKokkos::init() atomKK = (AtomKokkos *) atom; exchange_comm_classic = lmp->kokkos->exchange_comm_classic; forward_comm_classic = lmp->kokkos->forward_comm_classic; + forward_pair_comm_classic = lmp->kokkos->forward_pair_comm_classic; + forward_fix_comm_classic = lmp->kokkos->forward_fix_comm_classic; reverse_comm_classic = lmp->kokkos->reverse_comm_classic; exchange_comm_on_host = lmp->kokkos->exchange_comm_on_host; forward_comm_on_host = lmp->kokkos->forward_comm_on_host; + forward_pair_comm_on_host = lmp->kokkos->forward_pair_comm_on_host; + forward_fix_comm_on_host = lmp->kokkos->forward_fix_comm_on_host; reverse_comm_on_host = lmp->kokkos->reverse_comm_on_host; CommBrick::init(); @@ -361,6 +365,17 @@ void CommKokkos::reverse_comm_device() void CommKokkos::forward_comm_fix(Fix *fix, int size) { + if (!fix->kokkosable || !fix->forward_comm_device || forward_fix_comm_classic) { + k_sendlist.sync(); + CommBrick::forward_comm_fix(fix); + } else if (forward_fix_comm_on_host) { + k_sendlist.sync(); + forward_comm_fix_device(fix); + } else { + k_sendlist.sync(); + forward_comm_fix_device(fix); + } + if (fix->execution_space == Device && fix->forward_comm_device) { k_sendlist.sync(); forward_comm_fix_device(fix,size); @@ -456,10 +471,13 @@ void CommKokkos::reverse_comm_compute(Compute *compute) void CommKokkos::forward_comm_pair(Pair *pair) { - if (pair->execution_space == Host) { + if (!pair->kokkosable || forward_pair_comm_classic) { k_sendlist.sync(); CommBrick::forward_comm_pair(pair); - } else if (pair->execution_space == Device) { + } else if (forward_pair_comm_on_host) { + k_sendlist.sync(); + forward_comm_pair_device(pair); + } else { k_sendlist.sync(); forward_comm_pair_device(pair); } diff --git a/src/KOKKOS/comm_kokkos.h b/src/KOKKOS/comm_kokkos.h index 6b4a201ab7..d1cb388954 100644 --- a/src/KOKKOS/comm_kokkos.h +++ b/src/KOKKOS/comm_kokkos.h @@ -25,9 +25,13 @@ class CommKokkos : public CommBrick { bool exchange_comm_classic; bool forward_comm_classic; + bool forward_pair_comm_classic; + bool forward_fix_comm_classic; bool reverse_comm_classic; bool exchange_comm_on_host; bool forward_comm_on_host; + bool forward_pair_comm_on_host; + bool forward_fix_comm_on_host; bool reverse_comm_on_host; CommKokkos(class LAMMPS *); diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reax_kokkos.cpp index c96f5ded68..88b5414fc6 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reax_kokkos.cpp @@ -263,15 +263,15 @@ void FixQEqReaxKokkos::pre_force(int /*vflag*/) // comm->forward_comm_fix(this); //Dist_vector( s ); pack_flag = 2; - k_s.template sync(); - comm->forward_comm_fix(this); k_s.template modify(); + comm->forward_comm_fix(this); + k_s.template sync(); // comm->forward_comm_fix(this); //Dist_vector( t ); pack_flag = 3; - k_t.template sync(); - comm->forward_comm_fix(this); k_t.template modify(); + comm->forward_comm_fix(this); + k_t.template sync(); need_dup = lmp->kokkos->need_dup(); @@ -752,9 +752,7 @@ void FixQEqReaxKokkos::cg_solve1() if (neighflag != FULL) { k_o.template modify(); - k_o.template sync(); comm->reverse_comm_fix(this); //Coll_vector( q ); - k_o.template modify(); k_o.template sync(); } @@ -781,9 +779,9 @@ void FixQEqReaxKokkos::cg_solve1() // comm->forward_comm_fix(this); //Dist_vector( d ); pack_flag = 1; - k_d.template sync(); - comm->forward_comm_fix(this); k_d.template modify(); + comm->forward_comm_fix(this); + k_d.template sync(); // sparse_matvec( &H, d, q ); FixQEqReaxKokkosSparse22Functor sparse22_functor(this); @@ -807,9 +805,7 @@ void FixQEqReaxKokkos::cg_solve1() if (neighflag != FULL) { k_o.template modify(); - k_o.template sync(); comm->reverse_comm_fix(this); //Coll_vector( q ); - k_o.template modify(); k_o.template sync(); } @@ -888,9 +884,7 @@ void FixQEqReaxKokkos::cg_solve2() if (neighflag != FULL) { k_o.template modify(); - k_o.template sync(); comm->reverse_comm_fix(this); //Coll_vector( q ); - k_o.template modify(); k_o.template sync(); } @@ -917,9 +911,9 @@ void FixQEqReaxKokkos::cg_solve2() // comm->forward_comm_fix(this); //Dist_vector( d ); pack_flag = 1; - k_d.template sync(); - comm->forward_comm_fix(this); k_d.template modify(); + comm->forward_comm_fix(this); + k_d.template sync(); // sparse_matvec( &H, d, q ); FixQEqReaxKokkosSparse22Functor sparse22_functor(this); @@ -943,9 +937,7 @@ void FixQEqReaxKokkos::cg_solve2() if (neighflag != FULL) { k_o.template modify(); - k_o.template sync(); comm->reverse_comm_fix(this); //Coll_vector( q ); - k_o.template modify(); k_o.template sync(); } @@ -1020,9 +1012,9 @@ void FixQEqReaxKokkos::calculate_q() pack_flag = 4; //comm->forward_comm_fix( this ); //Dist_vector( atom->q ); - atomKK->k_q.sync(); - comm->forward_comm_fix(this); atomKK->k_q.modify(); + comm->forward_comm_fix(this); + atomKK->k_q.sync(); } @@ -1411,14 +1403,19 @@ int FixQEqReaxKokkos::pack_forward_comm(int n, int *list, double *bu { int m; - if (pack_flag == 1) - for(m = 0; m < n; m++) buf[m] = h_d[list[m]]; - else if( pack_flag == 2 ) - for(m = 0; m < n; m++) buf[m] = h_s[list[m]]; - else if( pack_flag == 3 ) - for(m = 0; m < n; m++) buf[m] = h_t[list[m]]; - else if( pack_flag == 4 ) - for(m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + if (pack_flag == 1) { + k_d.sync_host(); + for (m = 0; m < n; m++) buf[m] = h_d[list[m]]; + } else if (pack_flag == 2) { + k_s.sync_host(); + for (m = 0; m < n; m++) buf[m] = h_s[list[m]]; + } else if (pack_flag == 3) { + k_t.sync_host(); + for (m = 0; m < n; m++) buf[m] = h_t[list[m]]; + } else if (pack_flag == 4) { + atomKK->sync(Host,Q_MASK); + for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + } return n; } @@ -1430,14 +1427,23 @@ void FixQEqReaxKokkos::unpack_forward_comm(int n, int first, double { int i, m; - if (pack_flag == 1) - for(m = 0, i = first; m < n; m++, i++) h_d[i] = buf[m]; - else if( pack_flag == 2) - for(m = 0, i = first; m < n; m++, i++) h_s[i] = buf[m]; - else if( pack_flag == 3) - for(m = 0, i = first; m < n; m++, i++) h_t[i] = buf[m]; - else if( pack_flag == 4) - for(m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + if (pack_flag == 1) { + k_d.sync_host(); + for (m = 0, i = first; m < n; m++, i++) h_d[i] = buf[m]; + k_d.modify_host(); + } else if (pack_flag == 2) { + k_s.sync_host(); + for (m = 0, i = first; m < n; m++, i++) h_s[i] = buf[m]; + k_d.modify_host(); + } else if (pack_flag == 3) { + k_t.sync_host(); + for (m = 0, i = first; m < n; m++, i++) h_t[i] = buf[m]; + k_d.modify_host(); + } else if (pack_flag == 4) { + atomKK->sync(Host,Q_MASK); + for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + atomKK->modified(Host,Q_MASK); + } } /* ---------------------------------------------------------------------- */ @@ -1445,6 +1451,8 @@ void FixQEqReaxKokkos::unpack_forward_comm(int n, int first, double template int FixQEqReaxKokkos::pack_reverse_comm(int n, int first, double *buf) { + k_o.sync_host(); + int i, m; for(m = 0, i = first; m < n; m++, i++) { buf[m] = h_o[i]; @@ -1457,9 +1465,13 @@ int FixQEqReaxKokkos::pack_reverse_comm(int n, int first, double *bu template void FixQEqReaxKokkos::unpack_reverse_comm(int n, int *list, double *buf) { + k_o.sync_host(); + for(int m = 0; m < n; m++) { h_o[list[m]] += buf[m]; } + + k_o.modify_host(); } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 64455fef4f..3be19e6190 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -77,6 +77,8 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) exchange_comm_changed = 0; forward_comm_changed = 0; + forward_pair_comm_changed = 0; + forward_fix_comm_changed = 0; reverse_comm_changed = 0; delete memory; @@ -203,8 +205,12 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) neighflag = FULL; neighflag_qeq = FULL; newtonflag = 0; + exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 0; + forward_pair_comm_classic = forward_fix_comm_classic = 0; + exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; + forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } else { if (nthreads > 1) { neighflag = HALFTHREAD; @@ -214,8 +220,12 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) neighflag_qeq = HALF; } newtonflag = 1; + exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 1; + forward_pair_comm_classic = forward_fix_comm_classic = 1; + exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; + forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } #ifdef LMP_KOKKOS_GPU @@ -339,13 +349,22 @@ void KokkosLMP::accelerator(int narg, char **arg) if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) { exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 1; + forward_pair_comm_classic = forward_fix_comm_classic = 1; + exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; + forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } else if (strcmp(arg[iarg+1],"host") == 0) { exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 0; + forward_pair_comm_classic = forward_fix_comm_classic = 0; + exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 1; + forward_pair_comm_on_host = forward_fix_comm_on_host = 1; } else if (strcmp(arg[iarg+1],"device") == 0) { exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 0; + forward_pair_comm_classic = forward_fix_comm_classic = 0; + exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; + forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } else error->all(FLERR,"Illegal package kokkos command"); iarg += 2; } else if (strcmp(arg[iarg],"comm/exchange") == 0) { @@ -372,6 +391,30 @@ void KokkosLMP::accelerator(int narg, char **arg) } else error->all(FLERR,"Illegal package kokkos command"); forward_comm_changed = 0; iarg += 2; + } else if (strcmp(arg[iarg],"comm/pair/forward") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); + if (strcmp(arg[iarg+1],"no") == 0) forward_pair_comm_classic = 1; + else if (strcmp(arg[iarg+1],"host") == 0) { + forward_pair_comm_classic = 0; + forward_pair_comm_on_host = 1; + } else if (strcmp(arg[iarg+1],"device") == 0) { + forward_pair_comm_classic = 0; + forward_pair_comm_on_host = 0; + } else error->all(FLERR,"Illegal package kokkos command"); + forward_pair_comm_changed = 0; + iarg += 2; + } else if (strcmp(arg[iarg],"comm/fix/forward") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); + if (strcmp(arg[iarg+1],"no") == 0) forward_fix_comm_classic = 1; + else if (strcmp(arg[iarg+1],"host") == 0) { + forward_fix_comm_classic = 0; + forward_fix_comm_on_host = 1; + } else if (strcmp(arg[iarg+1],"device") == 0) { + forward_fix_comm_classic = 0; + forward_fix_comm_on_host = 0; + } else error->all(FLERR,"Illegal package kokkos command"); + forward_fix_comm_changed = 0; + iarg += 2; } else if (strcmp(arg[iarg],"comm/reverse") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) reverse_comm_classic = 1; @@ -416,6 +459,14 @@ void KokkosLMP::accelerator(int narg, char **arg) forward_comm_on_host = 1; forward_comm_changed = 1; } + if (forward_pair_comm_classic == 0 && forward_pair_comm_on_host == 0) { + forward_pair_comm_on_host = 1; + forward_pair_comm_changed = 1; + } + if (forward_fix_comm_classic == 0 && forward_fix_comm_on_host == 0) { + forward_fix_comm_on_host = 1; + forward_fix_comm_changed = 1; + } if (reverse_comm_classic == 0 && reverse_comm_on_host == 0) { reverse_comm_on_host = 1; reverse_comm_changed = 1; @@ -433,6 +484,14 @@ void KokkosLMP::accelerator(int narg, char **arg) forward_comm_on_host = 0; forward_comm_changed = 0; } + if (forward_pair_comm_changed) { + forward_pair_comm_on_host = 0; + forward_pair_comm_changed = 0; + } + if (forward_fix_comm_changed) { + forward_fix_comm_on_host = 0; + forward_fix_comm_changed = 0; + } if (reverse_comm_changed) { reverse_comm_on_host = 0; reverse_comm_changed = 0; diff --git a/src/KOKKOS/kokkos.h b/src/KOKKOS/kokkos.h index eb0eb2e71f..f4d9b99dba 100644 --- a/src/KOKKOS/kokkos.h +++ b/src/KOKKOS/kokkos.h @@ -28,12 +28,18 @@ class KokkosLMP : protected Pointers { int neighflag_qeq_set; int exchange_comm_classic; int forward_comm_classic; + int forward_pair_comm_classic; + int forward_fix_comm_classic; int reverse_comm_classic; int exchange_comm_on_host; int forward_comm_on_host; + int forward_pair_comm_on_host; + int forward_fix_comm_on_host; int reverse_comm_on_host; int exchange_comm_changed; int forward_comm_changed; + int forward_pair_comm_changed; + int forward_fix_comm_changed; int reverse_comm_changed; int nthreads,ngpus; int numa; diff --git a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp index d3b00329d8..47b4f55662 100644 --- a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp @@ -44,6 +44,7 @@ PairBuckCoulCutKokkos::PairBuckCoulCutKokkos(LAMMPS *lmp):PairBuckCo { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_buck_coul_long_kokkos.cpp b/src/KOKKOS/pair_buck_coul_long_kokkos.cpp index e503dd7ba5..41bb7a5fdb 100644 --- a/src/KOKKOS/pair_buck_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_buck_coul_long_kokkos.cpp @@ -51,6 +51,7 @@ PairBuckCoulLongKokkos::PairBuckCoulLongKokkos(LAMMPS *lmp):PairBuck { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_buck_kokkos.cpp b/src/KOKKOS/pair_buck_kokkos.cpp index b361824adc..7535f757f2 100644 --- a/src/KOKKOS/pair_buck_kokkos.cpp +++ b/src/KOKKOS/pair_buck_kokkos.cpp @@ -42,6 +42,7 @@ PairBuckKokkos::PairBuckKokkos(LAMMPS *lmp) : PairBuck(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_coul_cut_kokkos.cpp b/src/KOKKOS/pair_coul_cut_kokkos.cpp index 8ac8f89db8..7dcc8549f9 100644 --- a/src/KOKKOS/pair_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_coul_cut_kokkos.cpp @@ -33,6 +33,7 @@ using namespace LAMMPS_NS; template PairCoulCutKokkos::PairCoulCutKokkos(LAMMPS *lmp) : PairCoulCut(lmp) { + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_coul_debye_kokkos.cpp b/src/KOKKOS/pair_coul_debye_kokkos.cpp index 1abd6bad05..da678eccf2 100644 --- a/src/KOKKOS/pair_coul_debye_kokkos.cpp +++ b/src/KOKKOS/pair_coul_debye_kokkos.cpp @@ -42,6 +42,7 @@ PairCoulDebyeKokkos::PairCoulDebyeKokkos(LAMMPS *lmp):PairCoulDebye( { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_coul_dsf_kokkos.cpp b/src/KOKKOS/pair_coul_dsf_kokkos.cpp index 17f87767d9..4981d3240f 100644 --- a/src/KOKKOS/pair_coul_dsf_kokkos.cpp +++ b/src/KOKKOS/pair_coul_dsf_kokkos.cpp @@ -46,6 +46,7 @@ PairCoulDSFKokkos::PairCoulDSFKokkos(LAMMPS *lmp) : PairCoulDSF(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_coul_long_kokkos.cpp b/src/KOKKOS/pair_coul_long_kokkos.cpp index e2407e6e53..91f80ba146 100644 --- a/src/KOKKOS/pair_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_coul_long_kokkos.cpp @@ -51,6 +51,7 @@ PairCoulLongKokkos::PairCoulLongKokkos(LAMMPS *lmp):PairCoulLong(lmp { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_coul_wolf_kokkos.cpp b/src/KOKKOS/pair_coul_wolf_kokkos.cpp index 843b3106c9..44d9222baf 100644 --- a/src/KOKKOS/pair_coul_wolf_kokkos.cpp +++ b/src/KOKKOS/pair_coul_wolf_kokkos.cpp @@ -41,6 +41,7 @@ PairCoulWolfKokkos::PairCoulWolfKokkos(LAMMPS *lmp) : PairCoulWolf(l { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp index 629c5b0bec..649459f178 100644 --- a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp @@ -44,6 +44,7 @@ PairDPDfdtEnergyKokkos::PairDPDfdtEnergyKokkos(LAMMPS *lmp) : rand_pool() #endif { + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = EMPTY_MASK; diff --git a/src/KOKKOS/pair_eam_alloy_kokkos.cpp b/src/KOKKOS/pair_eam_alloy_kokkos.cpp index c2fbe7b87a..48b5efaf54 100644 --- a/src/KOKKOS/pair_eam_alloy_kokkos.cpp +++ b/src/KOKKOS/pair_eam_alloy_kokkos.cpp @@ -46,6 +46,7 @@ PairEAMAlloyKokkos::PairEAMAlloyKokkos(LAMMPS *lmp) : PairEAM(lmp) one_coeff = 1; manybody_flag = 1; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; @@ -170,9 +171,7 @@ void PairEAMAlloyKokkos::compute(int eflag_in, int vflag_in) if (newton_pair) { k_rho.template modify(); - k_rho.template sync(); comm->reverse_comm_pair(this); - k_rho.template modify(); k_rho.template sync(); } @@ -198,9 +197,11 @@ void PairEAMAlloyKokkos::compute(int eflag_in, int vflag_in) ev.evdwl = 0.0; } - // communicate derivative of embedding function (on the device) + // communicate derivative of embedding function + k_fp.template modify(); comm->forward_comm_pair(this); + k_fp.template sync(); // compute kernel C @@ -467,6 +468,8 @@ template int PairEAMAlloyKokkos::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { + k_fp.sync_host(); + int i,j; for (i = 0; i < n; i++) { @@ -481,9 +484,13 @@ int PairEAMAlloyKokkos::pack_forward_comm(int n, int *list, double * template void PairEAMAlloyKokkos::unpack_forward_comm(int n, int first, double *buf) { + k_fp.sync_host(); + for (int i = 0; i < n; i++) { h_fp[i + first] = buf[i]; } + + k_fp.modify_host(); } /* ---------------------------------------------------------------------- */ @@ -491,6 +498,8 @@ void PairEAMAlloyKokkos::unpack_forward_comm(int n, int first, doubl template int PairEAMAlloyKokkos::pack_reverse_comm(int n, int first, double *buf) { + k_rho.sync_host(); + int i,m,last; m = 0; @@ -504,6 +513,8 @@ int PairEAMAlloyKokkos::pack_reverse_comm(int n, int first, double * template void PairEAMAlloyKokkos::unpack_reverse_comm(int n, int *list, double *buf) { + k_rho.sync_host(); + int i,j,m; m = 0; @@ -511,6 +522,8 @@ void PairEAMAlloyKokkos::unpack_reverse_comm(int n, int *list, doubl j = list[i]; h_rho[j] += buf[m++]; } + + k_fp.modify_host(); } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_eam_fs_kokkos.cpp b/src/KOKKOS/pair_eam_fs_kokkos.cpp index 54397cea51..2f9f67ba6f 100644 --- a/src/KOKKOS/pair_eam_fs_kokkos.cpp +++ b/src/KOKKOS/pair_eam_fs_kokkos.cpp @@ -46,6 +46,7 @@ PairEAMFSKokkos::PairEAMFSKokkos(LAMMPS *lmp) : PairEAM(lmp) manybody_flag = 1; respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; @@ -170,9 +171,7 @@ void PairEAMFSKokkos::compute(int eflag_in, int vflag_in) if (newton_pair) { k_rho.template modify(); - k_rho.template sync(); comm->reverse_comm_pair(this); - k_rho.template modify(); k_rho.template sync(); } @@ -200,7 +199,9 @@ void PairEAMFSKokkos::compute(int eflag_in, int vflag_in) // communicate derivative of embedding function (on the device) + k_fp.template sync(); comm->forward_comm_pair(this); + k_fp.template modify(); // compute kernel C @@ -467,6 +468,8 @@ template int PairEAMFSKokkos::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { + k_fp.sync_host(); + int i,j; for (i = 0; i < n; i++) { @@ -481,9 +484,13 @@ int PairEAMFSKokkos::pack_forward_comm(int n, int *list, double *buf template void PairEAMFSKokkos::unpack_forward_comm(int n, int first, double *buf) { + k_fp.sync_host(); + for (int i = 0; i < n; i++) { h_fp[i + first] = buf[i]; } + + k_fp.modify_host(); } /* ---------------------------------------------------------------------- */ @@ -491,6 +498,8 @@ void PairEAMFSKokkos::unpack_forward_comm(int n, int first, double * template int PairEAMFSKokkos::pack_reverse_comm(int n, int first, double *buf) { + k_rho.sync_host(); + int i,m,last; m = 0; @@ -504,6 +513,8 @@ int PairEAMFSKokkos::pack_reverse_comm(int n, int first, double *buf template void PairEAMFSKokkos::unpack_reverse_comm(int n, int *list, double *buf) { + k_rho.sync_host(); + int i,j,m; m = 0; @@ -511,6 +522,8 @@ void PairEAMFSKokkos::unpack_reverse_comm(int n, int *list, double * j = list[i]; h_rho[j] += buf[m++]; } + + k_rho.modify_host(); } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_eam_kokkos.cpp b/src/KOKKOS/pair_eam_kokkos.cpp index bcbddea28d..98dbcba633 100644 --- a/src/KOKKOS/pair_eam_kokkos.cpp +++ b/src/KOKKOS/pair_eam_kokkos.cpp @@ -39,6 +39,7 @@ PairEAMKokkos::PairEAMKokkos(LAMMPS *lmp) : PairEAM(lmp) respa_enable = 0; single_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; @@ -163,9 +164,7 @@ void PairEAMKokkos::compute(int eflag_in, int vflag_in) if (newton_pair) { k_rho.template modify(); - k_rho.template sync(); comm->reverse_comm_pair(this); - k_rho.template modify(); k_rho.template sync(); } @@ -191,9 +190,11 @@ void PairEAMKokkos::compute(int eflag_in, int vflag_in) ev.evdwl = 0.0; } - // communicate derivative of embedding function (on the device) + // communicate derivative of embedding function + k_fp.template modify(); comm->forward_comm_pair(this); + k_fp.template sync(); // compute kernel C @@ -465,6 +466,8 @@ template int PairEAMKokkos::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { + k_fp.sync_host(); + int i,j; for (i = 0; i < n; i++) { @@ -479,9 +482,13 @@ int PairEAMKokkos::pack_forward_comm(int n, int *list, double *buf, template void PairEAMKokkos::unpack_forward_comm(int n, int first, double *buf) { + k_fp.sync_host(); + for (int i = 0; i < n; i++) { h_fp[i + first] = buf[i]; } + + k_fp.modify_host(); } /* ---------------------------------------------------------------------- */ @@ -489,6 +496,8 @@ void PairEAMKokkos::unpack_forward_comm(int n, int first, double *bu template int PairEAMKokkos::pack_reverse_comm(int n, int first, double *buf) { + k_rho.sync_host(); + int i,m,last; m = 0; @@ -502,6 +511,8 @@ int PairEAMKokkos::pack_reverse_comm(int n, int first, double *buf) template void PairEAMKokkos::unpack_reverse_comm(int n, int *list, double *buf) { + k_rho.sync_host(); + int i,j,m; m = 0; @@ -509,6 +520,8 @@ void PairEAMKokkos::unpack_reverse_comm(int n, int *list, double *bu j = list[i]; h_rho[j] += buf[m++]; } + + k_rho.modify_host(); } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index bc60bab85c..81cd69fd4d 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -77,6 +77,7 @@ double getElapsedTime( const TimerType &t0, const TimerType &t1) template PairExp6rxKokkos::PairExp6rxKokkos(LAMMPS *lmp) : PairExp6rx(lmp) { + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = EMPTY_MASK; diff --git a/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp b/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp index f82351fc9c..81c82ab826 100644 --- a/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp +++ b/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp @@ -32,6 +32,7 @@ using namespace LAMMPS_NS; template PairGranHookeHistoryKokkos::PairGranHookeHistoryKokkos(LAMMPS *lmp) : PairGranHookeHistory(lmp) { + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | V_MASK | OMEGA_MASK | F_MASK | TORQUE_MASK | TYPE_MASK | MASK_MASK | ENERGY_MASK | VIRIAL_MASK | RMASS_MASK | RADIUS_MASK; diff --git a/src/KOKKOS/pair_hybrid_kokkos.cpp b/src/KOKKOS/pair_hybrid_kokkos.cpp index 0d28e4a15d..540a6a368a 100644 --- a/src/KOKKOS/pair_hybrid_kokkos.cpp +++ b/src/KOKKOS/pair_hybrid_kokkos.cpp @@ -30,6 +30,7 @@ using namespace LAMMPS_NS; PairHybridKokkos::PairHybridKokkos(LAMMPS *lmp) : PairHybrid(lmp) { + kokkosable = 1; atomKK = (AtomKokkos *) atom; // prevent overlapping host/device computation, which isn't diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp index 208fb8165b..04632c9eec 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp @@ -50,6 +50,7 @@ PairLJCharmmCoulCharmmImplicitKokkos::PairLJCharmmCoulCharmmImplicit { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp index 4d7341a40a..8fe3e405af 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp @@ -51,6 +51,7 @@ PairLJCharmmCoulCharmmKokkos::PairLJCharmmCoulCharmmKokkos(LAMMPS *l { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp index 0c04b8a9f6..e70bfdb811 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp @@ -51,6 +51,7 @@ PairLJCharmmCoulLongKokkos::PairLJCharmmCoulLongKokkos(LAMMPS *lmp): { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp b/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp index c2a221d928..7fc802e0eb 100644 --- a/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp @@ -39,6 +39,7 @@ PairLJClass2CoulCutKokkos::PairLJClass2CoulCutKokkos(LAMMPS *lmp):Pa { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp index a3efbec8dd..dc7858d8d1 100644 --- a/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp @@ -47,6 +47,7 @@ PairLJClass2CoulLongKokkos::PairLJClass2CoulLongKokkos(LAMMPS *lmp): { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_class2_kokkos.cpp b/src/KOKKOS/pair_lj_class2_kokkos.cpp index baac21f014..dbeb78d89a 100644 --- a/src/KOKKOS/pair_lj_class2_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_kokkos.cpp @@ -42,6 +42,7 @@ PairLJClass2Kokkos::PairLJClass2Kokkos(LAMMPS *lmp) : PairLJClass2(l { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp index 9cfae7a05b..ccdfd127bd 100644 --- a/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp @@ -38,6 +38,7 @@ PairLJCutCoulCutKokkos::PairLJCutCoulCutKokkos(LAMMPS *lmp):PairLJCu { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp index 2b523321e3..9a641b514f 100644 --- a/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp @@ -42,6 +42,7 @@ PairLJCutCoulDebyeKokkos::PairLJCutCoulDebyeKokkos(LAMMPS *lmp):Pair { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp index 12ecb1b576..b1af8df018 100644 --- a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp @@ -52,6 +52,7 @@ PairLJCutCoulDSFKokkos::PairLJCutCoulDSFKokkos(LAMMPS *lmp):PairLJCu { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp index 2e2a756a70..68d6fe3a11 100644 --- a/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp @@ -49,6 +49,7 @@ PairLJCutCoulLongKokkos::PairLJCutCoulLongKokkos(LAMMPS *lmp):PairLJ { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_kokkos.cpp index 518fb4d866..89bd82f682 100644 --- a/src/KOKKOS/pair_lj_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_kokkos.cpp @@ -37,6 +37,7 @@ PairLJCutKokkos::PairLJCutKokkos(LAMMPS *lmp) : PairLJCut(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_expand_kokkos.cpp b/src/KOKKOS/pair_lj_expand_kokkos.cpp index 07e37b75e7..1f80d501c5 100644 --- a/src/KOKKOS/pair_lj_expand_kokkos.cpp +++ b/src/KOKKOS/pair_lj_expand_kokkos.cpp @@ -42,6 +42,7 @@ PairLJExpandKokkos::PairLJExpandKokkos(LAMMPS *lmp) : PairLJExpand(l { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp index a0d86e3bdb..9bc294ae71 100644 --- a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp +++ b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp @@ -42,6 +42,7 @@ PairLJGromacsCoulGromacsKokkos::PairLJGromacsCoulGromacsKokkos(LAMMP { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_gromacs_kokkos.cpp b/src/KOKKOS/pair_lj_gromacs_kokkos.cpp index c907dc9c25..ad9d8ddbc5 100644 --- a/src/KOKKOS/pair_lj_gromacs_kokkos.cpp +++ b/src/KOKKOS/pair_lj_gromacs_kokkos.cpp @@ -42,6 +42,7 @@ PairLJGromacsKokkos::PairLJGromacsKokkos(LAMMPS *lmp):PairLJGromacs( { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_sdk_kokkos.cpp b/src/KOKKOS/pair_lj_sdk_kokkos.cpp index 27003089de..2c66aad25a 100644 --- a/src/KOKKOS/pair_lj_sdk_kokkos.cpp +++ b/src/KOKKOS/pair_lj_sdk_kokkos.cpp @@ -42,6 +42,7 @@ PairLJSDKKokkos::PairLJSDKKokkos(LAMMPS *lmp) : PairLJSDK(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_morse_kokkos.cpp b/src/KOKKOS/pair_morse_kokkos.cpp index 47bd636aa8..f6a67f81d5 100644 --- a/src/KOKKOS/pair_morse_kokkos.cpp +++ b/src/KOKKOS/pair_morse_kokkos.cpp @@ -44,6 +44,7 @@ PairMorseKokkos::PairMorseKokkos(LAMMPS *lmp) : PairMorse(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp index 644115ccd6..05421186c0 100644 --- a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp +++ b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp @@ -57,6 +57,7 @@ PairMultiLucyRXKokkos::PairMultiLucyRXKokkos(LAMMPS *lmp) : PairMult { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = EMPTY_MASK; diff --git a/src/KOKKOS/pair_reaxc_kokkos.cpp b/src/KOKKOS/pair_reaxc_kokkos.cpp index eea397dc69..cfb273cd97 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.cpp +++ b/src/KOKKOS/pair_reaxc_kokkos.cpp @@ -49,6 +49,7 @@ PairReaxCKokkos::PairReaxCKokkos(LAMMPS *lmp) : PairReaxC(lmp) cut_nbsq = cut_hbsq = cut_bosq = 0.0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | Q_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index bacb5f75d6..1037985670 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -53,6 +53,7 @@ PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : PairSNAP(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = EMPTY_MASK; diff --git a/src/KOKKOS/pair_sw_kokkos.cpp b/src/KOKKOS/pair_sw_kokkos.cpp index 3ff990ed4e..5d629dc42a 100644 --- a/src/KOKKOS/pair_sw_kokkos.cpp +++ b/src/KOKKOS/pair_sw_kokkos.cpp @@ -45,6 +45,7 @@ PairSWKokkos::PairSWKokkos(LAMMPS *lmp) : PairSW(lmp) respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TAG_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_table_kokkos.cpp b/src/KOKKOS/pair_table_kokkos.cpp index dbea12a1f0..f57956f1ea 100644 --- a/src/KOKKOS/pair_table_kokkos.cpp +++ b/src/KOKKOS/pair_table_kokkos.cpp @@ -35,6 +35,7 @@ template PairTableKokkos::PairTableKokkos(LAMMPS *lmp) : PairTable(lmp) { update_table = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_table_rx_kokkos.cpp b/src/KOKKOS/pair_table_rx_kokkos.cpp index 82807f944d..d6728098b5 100644 --- a/src/KOKKOS/pair_table_rx_kokkos.cpp +++ b/src/KOKKOS/pair_table_rx_kokkos.cpp @@ -141,6 +141,7 @@ template PairTableRXKokkos::PairTableRXKokkos(LAMMPS *lmp) : PairTable(lmp) { update_table = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK | diff --git a/src/KOKKOS/pair_tersoff_kokkos.cpp b/src/KOKKOS/pair_tersoff_kokkos.cpp index f90a803a49..74d3521940 100644 --- a/src/KOKKOS/pair_tersoff_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_kokkos.cpp @@ -42,6 +42,7 @@ PairTersoffKokkos::PairTersoffKokkos(LAMMPS *lmp) : PairTersoff(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp index 24f466d750..13222c2214 100644 --- a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp @@ -42,6 +42,7 @@ PairTersoffMODKokkos::PairTersoffMODKokkos(LAMMPS *lmp) : PairTersof { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp index 01612905b5..5e201dbc1c 100644 --- a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp @@ -44,6 +44,7 @@ PairTersoffZBLKokkos::PairTersoffZBLKokkos(LAMMPS *lmp) : PairTersof { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_vashishta_kokkos.cpp b/src/KOKKOS/pair_vashishta_kokkos.cpp index 23a0d10757..4b7b50afe9 100644 --- a/src/KOKKOS/pair_vashishta_kokkos.cpp +++ b/src/KOKKOS/pair_vashishta_kokkos.cpp @@ -45,6 +45,7 @@ PairVashishtaKokkos::PairVashishtaKokkos(LAMMPS *lmp) : PairVashisht { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TAG_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_yukawa_kokkos.cpp b/src/KOKKOS/pair_yukawa_kokkos.cpp index d927526320..6a6c8bffba 100644 --- a/src/KOKKOS/pair_yukawa_kokkos.cpp +++ b/src/KOKKOS/pair_yukawa_kokkos.cpp @@ -41,6 +41,7 @@ PairYukawaKokkos::PairYukawaKokkos(LAMMPS *lmp) : PairYukawa(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_zbl_kokkos.cpp b/src/KOKKOS/pair_zbl_kokkos.cpp index 2cbe65dcf7..a3cdbf3b6e 100644 --- a/src/KOKKOS/pair_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_zbl_kokkos.cpp @@ -43,6 +43,7 @@ PairZBLKokkos::PairZBLKokkos(LAMMPS *lmp) : PairZBL(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/pair.cpp b/src/pair.cpp index 5c8422c91a..afc5eb2785 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -115,6 +115,7 @@ Pair::Pair(LAMMPS *lmp) : Pointers(lmp) datamask_read = ALL_MASK; datamask_modify = ALL_MASK; + kokkosable = 0; copymode = 0; } diff --git a/src/pair.h b/src/pair.h index ff0ce82cc8..5801941458 100644 --- a/src/pair.h +++ b/src/pair.h @@ -115,6 +115,7 @@ class Pair : protected Pointers { ExecutionSpace execution_space; unsigned int datamask_read,datamask_modify; + int kokkosable; // 1 if Kokkos pair Pair(class LAMMPS *); virtual ~Pair(); From 60dc9f61872943fb13aded606b050a663edc7605 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 17 Dec 2020 15:57:51 -0700 Subject: [PATCH 08/51] Update docs --- doc/src/package.rst | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/doc/src/package.rst b/doc/src/package.rst index 725536310a..9ace307bd5 100644 --- a/doc/src/package.rst +++ b/doc/src/package.rst @@ -65,7 +65,7 @@ Syntax *no_affinity* values = none *kokkos* args = keyword value ... zero or more keyword/value pairs may be appended - keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* or *comm/reverse* or *cuda/aware* + keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* *pair/comm/forward* *fix/comm/forward* or *comm/reverse* or *cuda/aware* *neigh* value = *full* or *half* full = full neighbor list half = half neighbor list built in thread-safe manner @@ -81,9 +81,11 @@ Syntax *binsize* value = size size = bin size for neighbor list construction (distance units) *comm* value = *no* or *host* or *device* - use value for comm/exchange and comm/forward and comm/reverse + use value for comm/exchange and comm/forward and pair/comm/forward and fix/comm/forward and comm/reverse *comm/exchange* value = *no* or *host* or *device* *comm/forward* value = *no* or *host* or *device* + *pair/comm/forward* value = *no* or *host* or *device* + *fix/comm/forward* value = *no* or *host* or *device* *comm/reverse* value = *no* or *host* or *device* no = perform communication pack/unpack in non-KOKKOS mode host = perform pack/unpack on host (e.g. with OpenMP threading) @@ -484,7 +486,8 @@ because the GPU is faster at performing pairwise interactions, then this rule of thumb may give too large a binsize and the default should be overridden with a smaller value. -The *comm* and *comm/exchange* and *comm/forward* and *comm/reverse* +The *comm* and *comm/exchange* and *comm/forward* and *pair/comm/forward* +and *fix/comm/forward* and comm/reverse* keywords determine whether the host or device performs the packing and unpacking of data when communicating per-atom data between processors. "Exchange" communication happens only on timesteps that neighbor lists @@ -492,10 +495,12 @@ are rebuilt. The data is only for atoms that migrate to new processors. "Forward" communication happens every timestep. "Reverse" communication happens every timestep if the *newton* option is on. The data is for atom coordinates and any other atom properties that needs to be updated -for ghost atoms owned by each processor. +for ghost atoms owned by each processor. "Pair/comm" controls additional +communication in pair styles, such as pair_style EAM. "Fix/comm" controls +additional communication in fixes, such as fix SHAKE. -The *comm* keyword is simply a short-cut to set the same value for both -the *comm/exchange* and *comm/forward* and *comm/reverse* keywords. +The *comm* keyword is simply a short-cut to set the same value for all +the comm keywords. The value options for all 3 keywords are *no* or *host* or *device*\ . A value of *no* means to use the standard non-KOKKOS method of From 271cbad787ee078170cb2176fc7bf6327f8f0501 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 11:58:32 -0700 Subject: [PATCH 09/51] Remove redundant code --- src/KOKKOS/comm_kokkos.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index c57a2c1431..c25fd1d111 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -375,14 +375,6 @@ void CommKokkos::forward_comm_fix(Fix *fix, int size) k_sendlist.sync(); forward_comm_fix_device(fix); } - - if (fix->execution_space == Device && fix->forward_comm_device) { - k_sendlist.sync(); - forward_comm_fix_device(fix,size); - } else { - k_sendlist.sync(); - CommBrick::forward_comm_fix(fix,size); - } } template From 6f852e7b2cf41d6d0bac8ae8cf15da6c6364f5a0 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 12:55:44 -0700 Subject: [PATCH 10/51] Remove 'host' option for Kokkos pair and fix comm --- src/KOKKOS/comm_kokkos.cpp | 10 +--- src/KOKKOS/fix_qeq_reax_kokkos.cpp | 16 ++--- src/KOKKOS/kokkos.cpp | 75 ++++++++++-------------- src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp | 15 +++-- 4 files changed, 52 insertions(+), 64 deletions(-) diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index c25fd1d111..23923419e8 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -365,12 +365,9 @@ void CommKokkos::reverse_comm_device() void CommKokkos::forward_comm_fix(Fix *fix, int size) { - if (!fix->kokkosable || !fix->forward_comm_device || forward_fix_comm_classic) { + if (!(fix->execution_space == Device) || !fix->forward_comm_device || forward_fix_comm_classic) { k_sendlist.sync(); CommBrick::forward_comm_fix(fix); - } else if (forward_fix_comm_on_host) { - k_sendlist.sync(); - forward_comm_fix_device(fix); } else { k_sendlist.sync(); forward_comm_fix_device(fix); @@ -463,12 +460,9 @@ void CommKokkos::reverse_comm_compute(Compute *compute) void CommKokkos::forward_comm_pair(Pair *pair) { - if (!pair->kokkosable || forward_pair_comm_classic) { + if (!(fix->execution_space == Device) || forward_pair_comm_classic) { k_sendlist.sync(); CommBrick::forward_comm_pair(pair); - } else if (forward_pair_comm_on_host) { - k_sendlist.sync(); - forward_comm_pair_device(pair); } else { k_sendlist.sync(); forward_comm_pair_device(pair); diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reax_kokkos.cpp index 88b5414fc6..f380ab40f5 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reax_kokkos.cpp @@ -21,7 +21,7 @@ #include "atom.h" #include "atom_kokkos.h" #include "atom_masks.h" -#include "comm.h" +#include "comm_kokkos.h" #include "error.h" #include "force.h" #include "kokkos.h" @@ -49,6 +49,7 @@ FixQEqReaxKokkos(LAMMPS *lmp, int narg, char **arg) : kokkosable = 1; forward_comm_device = 1; atomKK = (AtomKokkos *) atom; + commKK = (CommKokkos *) comm; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | V_MASK | F_MASK | MASK_MASK | Q_MASK | TYPE_MASK | TAG_MASK; @@ -81,8 +82,8 @@ FixQEqReaxKokkos::~FixQEqReaxKokkos() template void FixQEqReaxKokkos::init() { - atomKK->k_q.modify(); - atomKK->k_q.sync(); + atomKK->modified(Host,Q_MASK); + atomKK->sync(execution_space,Q_MASK); FixQEqReax::init(); @@ -1012,9 +1013,9 @@ void FixQEqReaxKokkos::calculate_q() pack_flag = 4; //comm->forward_comm_fix( this ); //Dist_vector( atom->q ); - atomKK->k_q.modify(); + atomKK->modified(execution_space,Q_MASK); comm->forward_comm_fix(this); - atomKK->k_q.sync(); + atomKK->sync(execution_space,Q_MASK); } @@ -1349,6 +1350,7 @@ int FixQEqReaxKokkos::pack_forward_comm_fix_kokkos(int n, DAT::tdual int iswap_in, DAT::tdual_xfloat_1d &k_buf, int /*pbc_flag*/, int * /*pbc*/) { + k_sendlist.sync(); d_sendlist = k_sendlist.view(); iswap = iswap_in; d_buf = k_buf.view(); @@ -1434,11 +1436,11 @@ void FixQEqReaxKokkos::unpack_forward_comm(int n, int first, double } else if (pack_flag == 2) { k_s.sync_host(); for (m = 0, i = first; m < n; m++, i++) h_s[i] = buf[m]; - k_d.modify_host(); + k_s.modify_host(); } else if (pack_flag == 3) { k_t.sync_host(); for (m = 0, i = first; m < n; m++, i++) h_t[i] = buf[m]; - k_d.modify_host(); + k_t.modify_host(); } else if (pack_flag == 4) { atomKK->sync(Host,Q_MASK); for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 3be19e6190..11116b0c93 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -39,7 +39,7 @@ GPU_AWARE_UNKNOWN #elif defined(KOKKOS_ENABLE_CUDA) -// OpenMPI supports detecting CUDA-aware MPI as of version 2.0.0 +// OpenMPI supports detecting GPU-aware MPI as of version 2.0.0 #if (OPEN_MPI) #if (OMPI_MAJOR_VERSION >= 2) @@ -149,7 +149,7 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) if (ngpus > 1 && !set_flag) error->all(FLERR,"Could not determine local MPI rank for multiple " - "GPUs with Kokkos CUDA because MPI library not recognized"); + "GPUs with Kokkos CUDA or HIP because MPI library not recognized"); } else if (strcmp(arg[iarg],"t") == 0 || strcmp(arg[iarg],"threads") == 0) { @@ -210,7 +210,6 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) forward_pair_comm_classic = forward_fix_comm_classic = 0; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; - forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } else { if (nthreads > 1) { neighflag = HALFTHREAD; @@ -225,13 +224,12 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) forward_pair_comm_classic = forward_fix_comm_classic = 1; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; - forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } #ifdef LMP_KOKKOS_GPU - // check and warn about CUDA-aware MPI availability when using multiple MPI tasks - // change default only if we can safely detect that CUDA-aware MPI is not available + // check and warn about GPU-aware MPI availability when using multiple MPI tasks + // change default only if we can safely detect that GPU-aware MPI is not available int nmpi = 0; MPI_Comm_size(world,&nmpi); @@ -254,14 +252,14 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) if (!gpu_aware_flag) if (me == 0) - error->warning(FLERR,"The Spectrum MPI '-gpu' flag is not set. Disabling CUDA-aware MPI"); + error->warning(FLERR,"The Spectrum MPI '-gpu' flag is not set. Disabling GPU-aware MPI"); } #endif if (gpu_aware_flag == 1 && have_gpu_aware == 0) { if (me == 0) - error->warning(FLERR,"Turning off CUDA-aware MPI since it is not detected, " - "use '-pk kokkos cuda/aware on' to override"); + error->warning(FLERR,"Turning off GPU-aware MPI since it is not detected, " + "use '-pk kokkos gpu/aware on' to override"); gpu_aware_flag = 0; } else if (have_gpu_aware == -1) { // maybe we are dealing with MPICH, MVAPICH2 or some derivative? // MVAPICH2 @@ -274,17 +272,17 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) if (!gpu_aware_flag) if (me == 0) - error->warning(FLERR,"MVAPICH2 'MV2_USE_CUDA' environment variable is not set. Disabling CUDA-aware MPI"); + error->warning(FLERR,"MVAPICH2 'MV2_USE_CUDA' environment variable is not set. Disabling GPU-aware MPI"); // pure MPICH or some unsupported MPICH derivative #elif defined(MPICH) && !defined(MVAPICH2_VERSION) if (me == 0) - error->warning(FLERR,"Detected MPICH. Disabling CUDA-aware MPI"); + error->warning(FLERR,"Detected MPICH. Disabling GPU-aware MPI"); gpu_aware_flag = 0; #else if (me == 0) - error->warning(FLERR,"Kokkos with CUDA assumes CUDA-aware MPI is available," + error->warning(FLERR,"Kokkos with CUDA or HIP assumes GPU-aware MPI is available," " but cannot determine if this is the case\n try" - " '-pk kokkos cuda/aware off' if getting segmentation faults"); + " '-pk kokkos gpu/aware off' if getting segmentation faults"); #endif } // if (-1 == have_gpu_aware) @@ -352,19 +350,16 @@ void KokkosLMP::accelerator(int narg, char **arg) forward_pair_comm_classic = forward_fix_comm_classic = 1; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; - forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } else if (strcmp(arg[iarg+1],"host") == 0) { exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 0; forward_pair_comm_classic = forward_fix_comm_classic = 0; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 1; - forward_pair_comm_on_host = forward_fix_comm_on_host = 1; } else if (strcmp(arg[iarg+1],"device") == 0) { exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 0; forward_pair_comm_classic = forward_fix_comm_classic = 0; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; - forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } else error->all(FLERR,"Illegal package kokkos command"); iarg += 2; } else if (strcmp(arg[iarg],"comm/exchange") == 0) { @@ -394,25 +389,15 @@ void KokkosLMP::accelerator(int narg, char **arg) } else if (strcmp(arg[iarg],"comm/pair/forward") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) forward_pair_comm_classic = 1; - else if (strcmp(arg[iarg+1],"host") == 0) { - forward_pair_comm_classic = 0; - forward_pair_comm_on_host = 1; - } else if (strcmp(arg[iarg+1],"device") == 0) { - forward_pair_comm_classic = 0; - forward_pair_comm_on_host = 0; - } else error->all(FLERR,"Illegal package kokkos command"); + else if (strcmp(arg[iarg+1],"device") == 0) forward_pair_comm_classic = 0; + else error->all(FLERR,"Illegal package kokkos command"); forward_pair_comm_changed = 0; iarg += 2; } else if (strcmp(arg[iarg],"comm/fix/forward") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) forward_fix_comm_classic = 1; - else if (strcmp(arg[iarg+1],"host") == 0) { - forward_fix_comm_classic = 0; - forward_fix_comm_on_host = 1; - } else if (strcmp(arg[iarg+1],"device") == 0) { - forward_fix_comm_classic = 0; - forward_fix_comm_on_host = 0; - } else error->all(FLERR,"Illegal package kokkos command"); + else if (strcmp(arg[iarg+1],"device") == 0) forward_fix_comm_classic = 0; + else error->all(FLERR,"Illegal package kokkos command"); forward_fix_comm_changed = 0; iarg += 2; } else if (strcmp(arg[iarg],"comm/reverse") == 0) { @@ -427,7 +412,7 @@ void KokkosLMP::accelerator(int narg, char **arg) } else error->all(FLERR,"Illegal package kokkos command"); reverse_comm_changed = 0; iarg += 2; - } else if (strcmp(arg[iarg],"cuda/aware") == 0) { + } else if (strcmp(arg[iarg],"gpu/aware") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"off") == 0) gpu_aware_flag = 0; else if (strcmp(arg[iarg+1],"on") == 0) gpu_aware_flag = 1; @@ -448,52 +433,52 @@ void KokkosLMP::accelerator(int narg, char **arg) int nmpi = 0; MPI_Comm_size(world,&nmpi); - // if "cuda/aware off" and "comm device", change to "comm host" + // if "gpu/aware off" and "comm device", change to "comm classic" if (!gpu_aware_flag && nmpi > 1) { if (exchange_comm_classic == 0 && exchange_comm_on_host == 0) { - exchange_comm_on_host = 1; + exchange_comm_classic = 1; exchange_comm_changed = 1; } if (forward_comm_classic == 0 && forward_comm_on_host == 0) { - forward_comm_on_host = 1; + forward_comm_classic = 1; forward_comm_changed = 1; } - if (forward_pair_comm_classic == 0 && forward_pair_comm_on_host == 0) { - forward_pair_comm_on_host = 1; + if (forward_pair_comm_classic == 0) { + forward_pair_comm_classic = 1; forward_pair_comm_changed = 1; } - if (forward_fix_comm_classic == 0 && forward_fix_comm_on_host == 0) { - forward_fix_comm_on_host = 1; + if (forward_fix_comm_classic == 0) { + forward_fix_comm_classic = 1; forward_fix_comm_changed = 1; } if (reverse_comm_classic == 0 && reverse_comm_on_host == 0) { - reverse_comm_on_host = 1; + reverse_comm_classic = 1; reverse_comm_changed = 1; } } - // if "cuda/aware on" and comm flags were changed previously, change them back + // if "gpu/aware on" and comm flags were changed previously, change them back if (gpu_aware_flag) { if (exchange_comm_changed) { - exchange_comm_on_host = 0; + exchange_comm_classic = 0; exchange_comm_changed = 0; } if (forward_comm_changed) { - forward_comm_on_host = 0; + forward_comm_classic = 0; forward_comm_changed = 0; } if (forward_pair_comm_changed) { - forward_pair_comm_on_host = 0; + forward_pair_classic = 0; forward_pair_comm_changed = 0; } if (forward_fix_comm_changed) { - forward_fix_comm_on_host = 0; + forward_fix_comm_classic = 0; forward_fix_comm_changed = 0; } if (reverse_comm_changed) { - reverse_comm_on_host = 0; + reverse_comm_classic = 0; reverse_comm_changed = 0; } } diff --git a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp index 05421186c0..d0c8432af0 100644 --- a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp +++ b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp @@ -512,12 +512,17 @@ void PairMultiLucyRXKokkos::computeLocalDensity() atomKK->modified(execution_space,DPDRHO_MASK); - // communicate and sum densities (on the host) + // communicate and sum densities - if (newton_pair) + atomKK->modified(execution_space,DPDRHO_MASK); + + if (newton_pair) { comm->reverse_comm_pair(this); + atomKK->sync(execution_space,DPDRHO_MASK); + } comm->forward_comm_pair(this); + atomKK->sync(execution_space,DPDRHO_MASK); } template @@ -686,8 +691,6 @@ void PairMultiLucyRXKokkos::unpack_forward_comm_kokkos(int n, int fi first = first_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); - - atomKK->modified(execution_space,DPDRHO_MASK); } template @@ -721,6 +724,8 @@ void PairMultiLucyRXKokkos::unpack_forward_comm(int n, int first, do { int i,m,last; + atomKK->sync(Host,DPDRHO_MASK); + m = 0; last = first + n; for (i = first; i < last; i++) h_rho[i] = buf[m++]; @@ -750,6 +755,8 @@ void PairMultiLucyRXKokkos::unpack_reverse_comm(int n, int *list, do { int i,j,m; + atomKK->sync(Host,DPDRHO_MASK); + m = 0; for (i = 0; i < n; i++) { j = list[i]; From 8ba288e1676d2d06c92cc664773521238f6ad190 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 13:16:58 -0700 Subject: [PATCH 11/51] Remove unneeded UVM code --- src/KOKKOS/fix_neigh_history_kokkos.cpp | 4 ---- src/KOKKOS/fix_shardlow_kokkos.cpp | 5 ----- src/KOKKOS/kokkos.cpp | 12 +----------- src/KOKKOS/memory_kokkos.h | 16 ---------------- src/KOKKOS/nbin_kokkos.cpp | 4 ---- src/KOKKOS/nbin_ssa_kokkos.cpp | 10 ---------- src/KOKKOS/npair_ssa_kokkos.h | 8 -------- src/MAKE/MACHINES/Makefile.summit_kokkos | 2 +- 8 files changed, 2 insertions(+), 59 deletions(-) diff --git a/src/KOKKOS/fix_neigh_history_kokkos.cpp b/src/KOKKOS/fix_neigh_history_kokkos.cpp index bb12194af6..e7b16e64f8 100644 --- a/src/KOKKOS/fix_neigh_history_kokkos.cpp +++ b/src/KOKKOS/fix_neigh_history_kokkos.cpp @@ -43,11 +43,7 @@ FixNeighHistoryKokkos::FixNeighHistoryKokkos(LAMMPS *lmp, int narg, grow_arrays(atom->nmax); d_resize = typename ArrayTypes::t_int_scalar("FixNeighHistoryKokkos::resize"); -#ifndef KOKKOS_USE_CUDA_UVM h_resize = Kokkos::create_mirror_view(d_resize); -#else - h_resize = d_resize; -#endif h_resize() = 1; } diff --git a/src/KOKKOS/fix_shardlow_kokkos.cpp b/src/KOKKOS/fix_shardlow_kokkos.cpp index 564c405894..2fd16059bf 100644 --- a/src/KOKKOS/fix_shardlow_kokkos.cpp +++ b/src/KOKKOS/fix_shardlow_kokkos.cpp @@ -94,13 +94,8 @@ FixShardlowKokkos::FixShardlowKokkos(LAMMPS *lmp, int narg, char **a #ifdef DEBUG_SSA_PAIR_CT d_counters = typename AT::t_int_2d("FixShardlowKokkos::d_counters", 2, 3); d_hist = typename AT::t_int_1d("FixShardlowKokkos::d_hist", 32); -#ifndef KOKKOS_USE_CUDA_UVM h_counters = Kokkos::create_mirror_view(d_counters); h_hist = Kokkos::create_mirror_view(d_hist); -#else - h_counters = d_counters; - h_hist = d_hist; -#endif #endif } diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 11116b0c93..139fd8f318 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -352,7 +352,7 @@ void KokkosLMP::accelerator(int narg, char **arg) exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; } else if (strcmp(arg[iarg+1],"host") == 0) { exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 0; - forward_pair_comm_classic = forward_fix_comm_classic = 0; + forward_pair_comm_classic = forward_fix_comm_classic = 1; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 1; } else if (strcmp(arg[iarg+1],"device") == 0) { @@ -514,25 +514,15 @@ int KokkosLMP::neigh_count(int m) if (nk->lists[m]->execution_space == Host) { NeighListKokkos* nlistKK = (NeighListKokkos*) nk->lists[m]; inum = nlistKK->inum; -#ifndef KOKKOS_USE_CUDA_UVM h_ilist = Kokkos::create_mirror_view(nlistKK->d_ilist); h_numneigh = Kokkos::create_mirror_view(nlistKK->d_numneigh); -#else - h_ilist = nlistKK->d_ilist; - h_numneigh = nlistKK->d_numneigh; -#endif Kokkos::deep_copy(h_ilist,nlistKK->d_ilist); Kokkos::deep_copy(h_numneigh,nlistKK->d_numneigh); } else if (nk->lists[m]->execution_space == Device) { NeighListKokkos* nlistKK = (NeighListKokkos*) nk->lists[m]; inum = nlistKK->inum; -#ifndef KOKKOS_USE_CUDA_UVM h_ilist = Kokkos::create_mirror_view(nlistKK->d_ilist); h_numneigh = Kokkos::create_mirror_view(nlistKK->d_numneigh); -#else - h_ilist = nlistKK->d_ilist; - h_numneigh = nlistKK->d_numneigh; -#endif Kokkos::deep_copy(h_ilist,nlistKK->d_ilist); Kokkos::deep_copy(h_numneigh,nlistKK->d_numneigh); } diff --git a/src/KOKKOS/memory_kokkos.h b/src/KOKKOS/memory_kokkos.h index df85f72c65..2f9e0cc375 100644 --- a/src/KOKKOS/memory_kokkos.h +++ b/src/KOKKOS/memory_kokkos.h @@ -46,11 +46,7 @@ template const char *name) { data = TYPE(std::string(name),n1); -#ifndef KOKKOS_USE_CUDA_UVM h_data = Kokkos::create_mirror_view(data); -#else - h_data = data; -#endif array = h_data.data(); return data; } @@ -61,11 +57,7 @@ template int n1, const char *name) { data = TYPE(std::string(name),n1); -#ifndef KOKKOS_USE_CUDA_UVM h_data = Kokkos::create_mirror_view(data); -#else - h_data = data; -#endif return data; } @@ -167,11 +159,7 @@ template const char *name) { data = TYPE(std::string(name),n1,n2); -#ifndef KOKKOS_USE_CUDA_UVM h_data = Kokkos::create_mirror_view(data); -#else - h_data = data; -#endif return data; } @@ -200,11 +188,7 @@ template const char *name) { data = TYPE(std::string(name),n1,n2); -#ifndef KOKKOS_USE_CUDA_UVM h_data = Kokkos::create_mirror_view(data); -#else - h_data = data; -#endif bigint nbytes = ((bigint) sizeof(typename TYPE::value_type *)) * n1; array = (typename TYPE::value_type **) smalloc(nbytes,name); diff --git a/src/KOKKOS/nbin_kokkos.cpp b/src/KOKKOS/nbin_kokkos.cpp index 712ea345cf..36a5b09966 100644 --- a/src/KOKKOS/nbin_kokkos.cpp +++ b/src/KOKKOS/nbin_kokkos.cpp @@ -30,11 +30,7 @@ NBinKokkos::NBinKokkos(LAMMPS *lmp) : NBinStandard(lmp) { atoms_per_bin = 16; d_resize = typename AT::t_int_scalar("NeighborKokkosFunctor::resize"); -#ifndef KOKKOS_USE_CUDA_UVM h_resize = Kokkos::create_mirror_view(d_resize); -#else - h_resize = d_resize; -#endif h_resize() = 1; kokkos = 1; diff --git a/src/KOKKOS/nbin_ssa_kokkos.cpp b/src/KOKKOS/nbin_ssa_kokkos.cpp index 8c9ccb5f59..d04312d620 100644 --- a/src/KOKKOS/nbin_ssa_kokkos.cpp +++ b/src/KOKKOS/nbin_ssa_kokkos.cpp @@ -41,7 +41,6 @@ NBinSSAKokkos::NBinSSAKokkos(LAMMPS *lmp) : NBinStandard(lmp) d_lbinxhi = typename AT::t_int_scalar("NBinSSAKokkos::d_lbinxhi"); d_lbinyhi = typename AT::t_int_scalar("NBinSSAKokkos::d_lbinyhi"); d_lbinzhi = typename AT::t_int_scalar("NBinSSAKokkos::d_lbinzhi"); -#ifndef KOKKOS_USE_CUDA_UVM h_resize = Kokkos::create_mirror_view(d_resize); h_lbinxlo = Kokkos::create_mirror_view(d_lbinxlo); h_lbinylo = Kokkos::create_mirror_view(d_lbinylo); @@ -49,15 +48,6 @@ NBinSSAKokkos::NBinSSAKokkos(LAMMPS *lmp) : NBinStandard(lmp) h_lbinxhi = Kokkos::create_mirror_view(d_lbinxhi); h_lbinyhi = Kokkos::create_mirror_view(d_lbinyhi); h_lbinzhi = Kokkos::create_mirror_view(d_lbinzhi); -#else - h_resize = d_resize; - h_lbinxlo = d_lbinxlo; - h_lbinylo = d_lbinylo; - h_lbinzlo = d_lbinzlo; - h_lbinxhi = d_lbinxhi; - h_lbinyhi = d_lbinyhi; - h_lbinzhi = d_lbinzhi; -#endif h_resize() = 1; k_gbincount = DAT::tdual_int_1d("NBinSSAKokkos::gbincount",8); diff --git a/src/KOKKOS/npair_ssa_kokkos.h b/src/KOKKOS/npair_ssa_kokkos.h index b4f541cf2a..5bd0a67001 100644 --- a/src/KOKKOS/npair_ssa_kokkos.h +++ b/src/KOKKOS/npair_ssa_kokkos.h @@ -281,19 +281,11 @@ class NPairSSAKokkosExecute bboxhi[0] = _bboxhi[0]; bboxhi[1] = _bboxhi[1]; bboxhi[2] = _bboxhi[2]; resize = typename AT::t_int_scalar("NPairSSAKokkosExecute::resize"); -#ifndef KOKKOS_USE_CUDA_UVM h_resize = Kokkos::create_mirror_view(resize); -#else - h_resize = resize; -#endif h_resize() = 1; new_maxneighs = typename AT:: t_int_scalar("NPairSSAKokkosExecute::new_maxneighs"); -#ifndef KOKKOS_USE_CUDA_UVM h_new_maxneighs = Kokkos::create_mirror_view(new_maxneighs); -#else - h_new_maxneighs = new_maxneighs; -#endif h_new_maxneighs() = neigh_list.maxneighs; }; diff --git a/src/MAKE/MACHINES/Makefile.summit_kokkos b/src/MAKE/MACHINES/Makefile.summit_kokkos index 95ee7e39a8..19af61a209 100644 --- a/src/MAKE/MACHINES/Makefile.summit_kokkos +++ b/src/MAKE/MACHINES/Makefile.summit_kokkos @@ -48,7 +48,7 @@ MY_MPI_PATH = $(dir ${MY_MPI_EXE}) MPI_INC = -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I${MY_MPI_PATH}../include MPI_PATH = -MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm +MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm -lopen-pal -lopen-rte -lhwloc_ompi -levent_core -levent_pthreads -levent # FFT library # see discussion in Section 3.5.2 of manual From 679f1e83a48eaf0830b1c1e92eb3ef84b9cae5f9 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 13:49:21 -0700 Subject: [PATCH 12/51] More cleanup --- src/KOKKOS/comm_kokkos.cpp | 4 ++-- src/KOKKOS/fix_qeq_reax_kokkos.cpp | 4 +--- src/MAKE/MACHINES/Makefile.summit_kokkos | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index 23923419e8..d4dab67a39 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -365,7 +365,7 @@ void CommKokkos::reverse_comm_device() void CommKokkos::forward_comm_fix(Fix *fix, int size) { - if (!(fix->execution_space == Device) || !fix->forward_comm_device || forward_fix_comm_classic) { + if (fix->execution_space == Host || !fix->forward_comm_device || forward_fix_comm_classic) { k_sendlist.sync(); CommBrick::forward_comm_fix(fix); } else { @@ -460,7 +460,7 @@ void CommKokkos::reverse_comm_compute(Compute *compute) void CommKokkos::forward_comm_pair(Pair *pair) { - if (!(fix->execution_space == Device) || forward_pair_comm_classic) { + if (fix->execution_space == Host || forward_pair_comm_classic) { k_sendlist.sync(); CommBrick::forward_comm_pair(pair); } else { diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reax_kokkos.cpp index f380ab40f5..5383fc47e2 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reax_kokkos.cpp @@ -21,7 +21,7 @@ #include "atom.h" #include "atom_kokkos.h" #include "atom_masks.h" -#include "comm_kokkos.h" +#include "comm.h" #include "error.h" #include "force.h" #include "kokkos.h" @@ -49,7 +49,6 @@ FixQEqReaxKokkos(LAMMPS *lmp, int narg, char **arg) : kokkosable = 1; forward_comm_device = 1; atomKK = (AtomKokkos *) atom; - commKK = (CommKokkos *) comm; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | V_MASK | F_MASK | MASK_MASK | Q_MASK | TYPE_MASK | TAG_MASK; @@ -1350,7 +1349,6 @@ int FixQEqReaxKokkos::pack_forward_comm_fix_kokkos(int n, DAT::tdual int iswap_in, DAT::tdual_xfloat_1d &k_buf, int /*pbc_flag*/, int * /*pbc*/) { - k_sendlist.sync(); d_sendlist = k_sendlist.view(); iswap = iswap_in; d_buf = k_buf.view(); diff --git a/src/MAKE/MACHINES/Makefile.summit_kokkos b/src/MAKE/MACHINES/Makefile.summit_kokkos index 19af61a209..95ee7e39a8 100644 --- a/src/MAKE/MACHINES/Makefile.summit_kokkos +++ b/src/MAKE/MACHINES/Makefile.summit_kokkos @@ -48,7 +48,7 @@ MY_MPI_PATH = $(dir ${MY_MPI_EXE}) MPI_INC = -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I${MY_MPI_PATH}../include MPI_PATH = -MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm -lopen-pal -lopen-rte -lhwloc_ompi -levent_core -levent_pthreads -levent +MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm # FFT library # see discussion in Section 3.5.2 of manual From 4520ef16e3caeaaec7dce09eae13167a1f1cb579 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 14:22:41 -0700 Subject: [PATCH 13/51] Cleanup --- src/KOKKOS/comm_kokkos.cpp | 4 +--- src/KOKKOS/kokkos.cpp | 4 +++- src/KOKKOS/kokkos.h | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index d4dab67a39..e5016efef1 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -112,8 +112,6 @@ void CommKokkos::init() reverse_comm_classic = lmp->kokkos->reverse_comm_classic; exchange_comm_on_host = lmp->kokkos->exchange_comm_on_host; forward_comm_on_host = lmp->kokkos->forward_comm_on_host; - forward_pair_comm_on_host = lmp->kokkos->forward_pair_comm_on_host; - forward_fix_comm_on_host = lmp->kokkos->forward_fix_comm_on_host; reverse_comm_on_host = lmp->kokkos->reverse_comm_on_host; CommBrick::init(); @@ -460,7 +458,7 @@ void CommKokkos::reverse_comm_compute(Compute *compute) void CommKokkos::forward_comm_pair(Pair *pair) { - if (fix->execution_space == Host || forward_pair_comm_classic) { + if (pair->execution_space == Host || forward_pair_comm_classic) { k_sendlist.sync(); CommBrick::forward_comm_pair(pair); } else { diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 139fd8f318..2f7f69afdc 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -389,6 +389,7 @@ void KokkosLMP::accelerator(int narg, char **arg) } else if (strcmp(arg[iarg],"comm/pair/forward") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) forward_pair_comm_classic = 1; + else if (strcmp(arg[iarg+1],"host") == 0) forward_pair_comm_classic = 1; else if (strcmp(arg[iarg+1],"device") == 0) forward_pair_comm_classic = 0; else error->all(FLERR,"Illegal package kokkos command"); forward_pair_comm_changed = 0; @@ -396,6 +397,7 @@ void KokkosLMP::accelerator(int narg, char **arg) } else if (strcmp(arg[iarg],"comm/fix/forward") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) forward_fix_comm_classic = 1; + if (strcmp(arg[iarg+1],"host") == 0) forward_fix_comm_classic = 1; else if (strcmp(arg[iarg+1],"device") == 0) forward_fix_comm_classic = 0; else error->all(FLERR,"Illegal package kokkos command"); forward_fix_comm_changed = 0; @@ -470,7 +472,7 @@ void KokkosLMP::accelerator(int narg, char **arg) forward_comm_changed = 0; } if (forward_pair_comm_changed) { - forward_pair_classic = 0; + forward_pair_comm_classic = 0; forward_pair_comm_changed = 0; } if (forward_fix_comm_changed) { diff --git a/src/KOKKOS/kokkos.h b/src/KOKKOS/kokkos.h index f4d9b99dba..b247d583a6 100644 --- a/src/KOKKOS/kokkos.h +++ b/src/KOKKOS/kokkos.h @@ -33,8 +33,6 @@ class KokkosLMP : protected Pointers { int reverse_comm_classic; int exchange_comm_on_host; int forward_comm_on_host; - int forward_pair_comm_on_host; - int forward_fix_comm_on_host; int reverse_comm_on_host; int exchange_comm_changed; int forward_comm_changed; From 31626185126860bb91931464ae0e3e8ce6522f55 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 14:24:24 -0700 Subject: [PATCH 14/51] Update docs --- doc/src/Speed_kokkos.rst | 12 ++++---- doc/src/package.rst | 36 +++++++++++++----------- src/MAKE/MACHINES/Makefile.summit_kokkos | 2 +- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/doc/src/Speed_kokkos.rst b/doc/src/Speed_kokkos.rst index 7827c13811..da483567b3 100644 --- a/doc/src/Speed_kokkos.rst +++ b/doc/src/Speed_kokkos.rst @@ -38,14 +38,14 @@ produce an executable compatible with a specific hardware. :class: note Kokkos with CUDA currently implicitly assumes that the MPI library is - CUDA-aware. This is not always the case, especially when using + GPU-aware. This is not always the case, especially when using pre-compiled MPI libraries provided by a Linux distribution. This is not a problem when using only a single GPU with a single MPI rank. When running with multiple MPI ranks, you may see segmentation - faults without CUDA-aware MPI support. These can be avoided by adding - the flags :doc:`-pk kokkos cuda/aware off ` to the + faults without GPU-aware MPI support. These can be avoided by adding + the flags :doc:`-pk kokkos gpu/aware off ` to the LAMMPS command line or by using the command :doc:`package kokkos - cuda/aware off ` in the input file. + gpu/aware off ` in the input file. .. admonition:: AMD GPU support :class: note @@ -242,8 +242,8 @@ case, also packing/unpacking communication buffers on the host may give speedup (see the KOKKOS :doc:`package ` command). Using CUDA MPS is recommended in this scenario. -Using a CUDA-aware MPI library is highly recommended. CUDA-aware MPI use can be -avoided by using :doc:`-pk kokkos cuda/aware no `. As above for +Using a GPU-aware MPI library is highly recommended. GPU-aware MPI use can be +avoided by using :doc:`-pk kokkos gpu/aware no `. As above for multi-core CPUs (and no GPU), if N is the number of physical cores/node, then the number of MPI tasks/node should not exceed N. diff --git a/doc/src/package.rst b/doc/src/package.rst index 9ace307bd5..1adfc584e1 100644 --- a/doc/src/package.rst +++ b/doc/src/package.rst @@ -65,7 +65,7 @@ Syntax *no_affinity* values = none *kokkos* args = keyword value ... zero or more keyword/value pairs may be appended - keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* *pair/comm/forward* *fix/comm/forward* or *comm/reverse* or *cuda/aware* + keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* *pair/comm/forward* *fix/comm/forward* or *comm/reverse* or *gpu/aware* *neigh* value = *full* or *half* full = full neighbor list half = half neighbor list built in thread-safe manner @@ -84,15 +84,15 @@ Syntax use value for comm/exchange and comm/forward and pair/comm/forward and fix/comm/forward and comm/reverse *comm/exchange* value = *no* or *host* or *device* *comm/forward* value = *no* or *host* or *device* - *pair/comm/forward* value = *no* or *host* or *device* - *fix/comm/forward* value = *no* or *host* or *device* + *pair/comm/forward* value = *no* or *device* + *fix/comm/forward* value = *no* or *device* *comm/reverse* value = *no* or *host* or *device* no = perform communication pack/unpack in non-KOKKOS mode host = perform pack/unpack on host (e.g. with OpenMP threading) device = perform pack/unpack on device (e.g. on GPU) - *cuda/aware* = *off* or *on* - off = do not use CUDA-aware MPI - on = use CUDA-aware MPI (default) + *gpu/aware* = *off* or *on* + off = do not use GPU-aware MPI + on = use GPU-aware MPI (default) *omp* args = Nthreads keyword value ... Nthread = # of OpenMP threads to associate with each MPI process zero or more keyword/value pairs may be appended @@ -502,13 +502,15 @@ additional communication in fixes, such as fix SHAKE. The *comm* keyword is simply a short-cut to set the same value for all the comm keywords. -The value options for all 3 keywords are *no* or *host* or *device*\ . A +The value options for the keywords are *no* or *host* or *device*\ . A value of *no* means to use the standard non-KOKKOS method of packing/unpacking data for the communication. A value of *host* means to use the host, typically a multi-core CPU, and perform the packing/unpacking in parallel with threads. A value of *device* means to use the device, typically a GPU, to perform the packing/unpacking -operation. +operation. If a value of *host* is used for the *pair/comm/forward* or +*fix/comm/forward* keyword, it will be automatically be changed to *no* +since these keywords don't support *host* mode. The optimal choice for these keywords depends on the input script and the hardware used. The *no* value is useful for verifying that the @@ -529,18 +531,18 @@ pack/unpack communicated data. When running small systems on a GPU, performing the exchange pack/unpack on the host CPU can give speedup since it reduces the number of CUDA kernel launches. -The *cuda/aware* keyword chooses whether CUDA-aware MPI will be used. When +The *gpu/aware* keyword chooses whether GPU-aware MPI will be used. When this keyword is set to *on*\ , buffers in GPU memory are passed directly through MPI send/receive calls. This reduces overhead of first copying -the data to the host CPU. However CUDA-aware MPI is not supported on all +the data to the host CPU. However GPU-aware MPI is not supported on all systems, which can lead to segmentation faults and would require using a -value of *off*\ . If LAMMPS can safely detect that CUDA-aware MPI is not +value of *off*\ . If LAMMPS can safely detect that GPU-aware MPI is not available (currently only possible with OpenMPI v2.0.0 or later), then -the *cuda/aware* keyword is automatically set to *off* by default. When -the *cuda/aware* keyword is set to *off* while any of the *comm* +the *gpu/aware* keyword is automatically set to *off* by default. When +the *gpu/aware* keyword is set to *off* while any of the *comm* keywords are set to *device*\ , the value for these *comm* keywords will -be automatically changed to *host*\ . This setting has no effect if not -running on GPUs or if using only one MPI rank. CUDA-aware MPI is available +be automatically changed to *no*\ . This setting has no effect if not +running on GPUs or if using only one MPI rank. GPU-aware MPI is available for OpenMPI 1.8 (or later versions), Mvapich2 1.9 (or later) when the "MV2_USE_CUDA" environment variable is set to "1", CrayMPI, and IBM Spectrum MPI when the "-gpu" flag is used. @@ -654,8 +656,8 @@ script or via the "-pk intel" :doc:`command-line switch `. For the KOKKOS package, the option defaults for GPUs are neigh = full, neigh/qeq = full, newton = off, binsize for GPUs = 2x LAMMPS default -value, comm = device, cuda/aware = on. When LAMMPS can safely detect -that CUDA-aware MPI is not available, the default value of cuda/aware +value, comm = device, gpu/aware = on. When LAMMPS can safely detect +that GPU-aware MPI is not available, the default value of gpu/aware becomes "off". For CPUs or Xeon Phis, the option defaults are neigh = half, neigh/qeq = half, newton = on, binsize = 0.0, and comm = no. The option neigh/thread = on when there are 16K atoms or less on an MPI diff --git a/src/MAKE/MACHINES/Makefile.summit_kokkos b/src/MAKE/MACHINES/Makefile.summit_kokkos index 95ee7e39a8..19af61a209 100644 --- a/src/MAKE/MACHINES/Makefile.summit_kokkos +++ b/src/MAKE/MACHINES/Makefile.summit_kokkos @@ -48,7 +48,7 @@ MY_MPI_PATH = $(dir ${MY_MPI_EXE}) MPI_INC = -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I${MY_MPI_PATH}../include MPI_PATH = -MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm +MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm -lopen-pal -lopen-rte -lhwloc_ompi -levent_core -levent_pthreads -levent # FFT library # see discussion in Section 3.5.2 of manual From bfb85d3cb43aa20092e54dfb93b3a1da41a15303 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 14:37:34 -0700 Subject: [PATCH 15/51] Fix typo in docs --- doc/src/Speed_kokkos.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/Speed_kokkos.rst b/doc/src/Speed_kokkos.rst index da483567b3..e7724eb229 100644 --- a/doc/src/Speed_kokkos.rst +++ b/doc/src/Speed_kokkos.rst @@ -243,7 +243,7 @@ speedup (see the KOKKOS :doc:`package ` command). Using CUDA MPS is recommended in this scenario. Using a GPU-aware MPI library is highly recommended. GPU-aware MPI use can be -avoided by using :doc:`-pk kokkos gpu/aware no `. As above for +avoided by using :doc:`-pk kokkos gpu/aware off `. As above for multi-core CPUs (and no GPU), if N is the number of physical cores/node, then the number of MPI tasks/node should not exceed N. From d192a77763e3261fbe02bcfa9a8547e10b6072b4 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 14:47:41 -0700 Subject: [PATCH 16/51] Small tweaks --- src/KOKKOS/comm_kokkos.h | 2 -- src/KOKKOS/kokkos.cpp | 2 +- src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp | 4 ---- src/MAKE/MACHINES/Makefile.summit_kokkos | 2 +- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/KOKKOS/comm_kokkos.h b/src/KOKKOS/comm_kokkos.h index d1cb388954..c5772bafe7 100644 --- a/src/KOKKOS/comm_kokkos.h +++ b/src/KOKKOS/comm_kokkos.h @@ -30,8 +30,6 @@ class CommKokkos : public CommBrick { bool reverse_comm_classic; bool exchange_comm_on_host; bool forward_comm_on_host; - bool forward_pair_comm_on_host; - bool forward_fix_comm_on_host; bool reverse_comm_on_host; CommKokkos(class LAMMPS *); diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 2f7f69afdc..ca5762f088 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -435,7 +435,7 @@ void KokkosLMP::accelerator(int narg, char **arg) int nmpi = 0; MPI_Comm_size(world,&nmpi); - // if "gpu/aware off" and "comm device", change to "comm classic" + // if "gpu/aware off" and "comm device", change to "comm no" if (!gpu_aware_flag && nmpi > 1) { if (exchange_comm_classic == 0 && exchange_comm_on_host == 0) { diff --git a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp index d0c8432af0..97a6fe5699 100644 --- a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp +++ b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp @@ -514,8 +514,6 @@ void PairMultiLucyRXKokkos::computeLocalDensity() // communicate and sum densities - atomKK->modified(execution_space,DPDRHO_MASK); - if (newton_pair) { comm->reverse_comm_pair(this); atomKK->sync(execution_space,DPDRHO_MASK); @@ -667,8 +665,6 @@ void PairMultiLucyRXKokkos::getMixingWeights(int id, double &mixWtSi template int PairMultiLucyRXKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d k_sendlist, int iswap_in, DAT::tdual_xfloat_1d &buf, int /*pbc_flag*/, int * /*pbc*/) { - atomKK->sync(execution_space,DPDRHO_MASK); - d_sendlist = k_sendlist.view(); iswap = iswap_in; v_buf = buf.view(); diff --git a/src/MAKE/MACHINES/Makefile.summit_kokkos b/src/MAKE/MACHINES/Makefile.summit_kokkos index 19af61a209..95ee7e39a8 100644 --- a/src/MAKE/MACHINES/Makefile.summit_kokkos +++ b/src/MAKE/MACHINES/Makefile.summit_kokkos @@ -48,7 +48,7 @@ MY_MPI_PATH = $(dir ${MY_MPI_EXE}) MPI_INC = -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I${MY_MPI_PATH}../include MPI_PATH = -MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm -lopen-pal -lopen-rte -lhwloc_ompi -levent_core -levent_pthreads -levent +MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm # FFT library # see discussion in Section 3.5.2 of manual From 06596683c746a27ce830cf91890d9feda1e0f206 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 14:51:27 -0700 Subject: [PATCH 17/51] Add back in param --- src/KOKKOS/comm_kokkos.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index e5016efef1..cb1c3c60a1 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -365,7 +365,7 @@ void CommKokkos::forward_comm_fix(Fix *fix, int size) { if (fix->execution_space == Host || !fix->forward_comm_device || forward_fix_comm_classic) { k_sendlist.sync(); - CommBrick::forward_comm_fix(fix); + CommBrick::forward_comm_fix(fix,size); } else { k_sendlist.sync(); forward_comm_fix_device(fix); From 4befc0fa565894f1bbfa8260e84b81b23f92e8be Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 15:25:40 -0700 Subject: [PATCH 18/51] Fix logic error --- src/KOKKOS/kokkos.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index ca5762f088..f42f0177df 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -397,14 +397,14 @@ void KokkosLMP::accelerator(int narg, char **arg) } else if (strcmp(arg[iarg],"comm/fix/forward") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) forward_fix_comm_classic = 1; - if (strcmp(arg[iarg+1],"host") == 0) forward_fix_comm_classic = 1; + else if (strcmp(arg[iarg+1],"host") == 0) forward_fix_comm_classic = 1; else if (strcmp(arg[iarg+1],"device") == 0) forward_fix_comm_classic = 0; else error->all(FLERR,"Illegal package kokkos command"); forward_fix_comm_changed = 0; iarg += 2; } else if (strcmp(arg[iarg],"comm/reverse") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); - if (strcmp(arg[iarg+1],"no") == 0) reverse_comm_classic = 1; + else if (strcmp(arg[iarg+1],"no") == 0) reverse_comm_classic = 1; else if (strcmp(arg[iarg+1],"host") == 0) { reverse_comm_classic = 0; reverse_comm_on_host = 1; From 4382529158ec0a1fcdb9727b11dfdb4c345880b0 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 24 Dec 2020 10:28:52 -0700 Subject: [PATCH 19/51] Fix sync/modify issues in fix_qeq --- src/KOKKOS/atom_vec_charge_kokkos.cpp | 4 ++-- src/KOKKOS/fix_qeq_reax_kokkos.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/KOKKOS/atom_vec_charge_kokkos.cpp b/src/KOKKOS/atom_vec_charge_kokkos.cpp index 698703371f..6bfe227c9e 100644 --- a/src/KOKKOS/atom_vec_charge_kokkos.cpp +++ b/src/KOKKOS/atom_vec_charge_kokkos.cpp @@ -1131,7 +1131,7 @@ void AtomVecChargeKokkos::sync_overlapping_device(ExecutionSpace space, unsigned perform_async_copy(atomKK->k_mask,space); if ((mask & IMAGE_MASK) && atomKK->k_image.need_sync()) perform_async_copy(atomKK->k_image,space); - if ((mask & MOLECULE_MASK) && atomKK->k_q.need_sync()) + if ((mask & Q_MASK) && atomKK->k_q.need_sync()) perform_async_copy(atomKK->k_q,space); } else { if ((mask & X_MASK) && atomKK->k_x.need_sync()) @@ -1148,7 +1148,7 @@ void AtomVecChargeKokkos::sync_overlapping_device(ExecutionSpace space, unsigned perform_async_copy(atomKK->k_mask,space); if ((mask & IMAGE_MASK) && atomKK->k_image.need_sync()) perform_async_copy(atomKK->k_image,space); - if ((mask & MOLECULE_MASK) && atomKK->k_q.need_sync()) + if ((mask & Q_MASK) && atomKK->k_q.need_sync()) perform_async_copy(atomKK->k_q,space); } } diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reax_kokkos.cpp index 5383fc47e2..535a4cd555 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reax_kokkos.cpp @@ -51,8 +51,8 @@ FixQEqReaxKokkos(LAMMPS *lmp, int narg, char **arg) : atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; - datamask_read = X_MASK | V_MASK | F_MASK | MASK_MASK | Q_MASK | TYPE_MASK | TAG_MASK; - datamask_modify = Q_MASK | X_MASK; + datamask_read = X_MASK | V_MASK | F_MASK | Q_MASK | MASK_MASK | TYPE_MASK | TAG_MASK; + datamask_modify = X_MASK; nmax = m_cap = 0; allocated_flag = 0; @@ -81,7 +81,6 @@ FixQEqReaxKokkos::~FixQEqReaxKokkos() template void FixQEqReaxKokkos::init() { - atomKK->modified(Host,Q_MASK); atomKK->sync(execution_space,Q_MASK); FixQEqReax::init(); @@ -1009,13 +1008,11 @@ void FixQEqReaxKokkos::calculate_q() // q[i] = s[i] - u * t[i]; FixQEqReaxKokkosCalculateQFunctor calculateQ_functor(this); Kokkos::parallel_for(inum,calculateQ_functor); + atomKK->modified(execution_space,Q_MASK); pack_flag = 4; //comm->forward_comm_fix( this ); //Dist_vector( atom->q ); - atomKK->modified(execution_space,Q_MASK); comm->forward_comm_fix(this); - atomKK->sync(execution_space,Q_MASK); - } /* ---------------------------------------------------------------------- */ @@ -1379,6 +1376,9 @@ void FixQEqReaxKokkos::unpack_forward_comm_fix_kokkos(int n, int fir first = first_in; d_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); + + if (pack_flag == 4) + atomKK->modified(execution_space,Q_MASK); // needed for auto_sync } template From a4897d38b9b785dd3756c70859797267caa3ea3f Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 24 Dec 2020 10:36:24 -0700 Subject: [PATCH 20/51] Tweak sync/modify in pair_multi_lucy_rx_kokkos --- src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp index 97a6fe5699..6a48a0206a 100644 --- a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp +++ b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp @@ -514,10 +514,8 @@ void PairMultiLucyRXKokkos::computeLocalDensity() // communicate and sum densities - if (newton_pair) { + if (newton_pair) comm->reverse_comm_pair(this); - atomKK->sync(execution_space,DPDRHO_MASK); - } comm->forward_comm_pair(this); atomKK->sync(execution_space,DPDRHO_MASK); @@ -665,6 +663,8 @@ void PairMultiLucyRXKokkos::getMixingWeights(int id, double &mixWtSi template int PairMultiLucyRXKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d k_sendlist, int iswap_in, DAT::tdual_xfloat_1d &buf, int /*pbc_flag*/, int * /*pbc*/) { + atomKK->sync(execution_space,DPDRHO_MASK); + d_sendlist = k_sendlist.view(); iswap = iswap_in; v_buf = buf.view(); @@ -687,6 +687,8 @@ void PairMultiLucyRXKokkos::unpack_forward_comm_kokkos(int n, int fi first = first_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); + + atomKK->modified(execution_space,DPDRHO_MASK); // needed for auto_sync } template From cbc6197891ff307bb5b92b6a51d8da87b1d0d66d Mon Sep 17 00:00:00 2001 From: Plimpton Date: Thu, 24 Dec 2020 16:10:03 -0700 Subject: [PATCH 21/51] also flip sign on 1d timing FFTs --- src/KSPACE/fft3d.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/KSPACE/fft3d.cpp b/src/KSPACE/fft3d.cpp index 84534b6fd8..b123e16eae 100644 --- a/src/KSPACE/fft3d.cpp +++ b/src/KSPACE/fft3d.cpp @@ -708,7 +708,7 @@ void bifactor(int n, int *factor1, int *factor2) Arguments: in starting address of input data on this proc, all set to 0.0 nsize size of in - flag 1 for forward FFT, -1 for inverse FFT + flag 1 for forward FFT, -1 for backward FFT plan plan returned by previous call to fft_3d_create_plan ------------------------------------------------------------------------- */ @@ -733,7 +733,8 @@ void fft_1d_only(FFT_DATA *data, int nsize, int flag, struct fft_plan_3d *plan) int length3 = plan->length3; // fftw3 and Dfti in MKL encode the number of transforms -// into the plan, so we cannot operate on a smaller data set. +// into the plan, so we cannot operate on a smaller data set + #if defined(FFT_MKL) || defined(FFT_FFTW3) if ((total1 > nsize) || (total2 > nsize) || (total3 > nsize)) return; @@ -746,7 +747,7 @@ void fft_1d_only(FFT_DATA *data, int nsize, int flag, struct fft_plan_3d *plan) // data is just an array of 0.0 #if defined(FFT_MKL) - if (flag == -1) { + if (flag == 1) { DftiComputeForward(plan->handle_fast,data); DftiComputeForward(plan->handle_mid,data); DftiComputeForward(plan->handle_slow,data); @@ -757,23 +758,23 @@ void fft_1d_only(FFT_DATA *data, int nsize, int flag, struct fft_plan_3d *plan) } #elif defined(FFT_FFTW3) FFTW_API(plan) theplan; - if (flag == -1) + if (flag == 1) theplan=plan->plan_fast_forward; else theplan=plan->plan_fast_backward; FFTW_API(execute_dft)(theplan,data,data); - if (flag == -1) + if (flag == 1) theplan=plan->plan_mid_forward; else theplan=plan->plan_mid_backward; FFTW_API(execute_dft)(theplan,data,data); - if (flag == -1) + if (flag == 1) theplan=plan->plan_slow_forward; else theplan=plan->plan_slow_backward; FFTW_API(execute_dft)(theplan,data,data); #else - if (flag == -1) { + if (flag == 1) { for (int offset = 0; offset < total1; offset += length1) kiss_fft(plan->cfg_fast_forward,&data[offset],&data[offset]); for (int offset = 0; offset < total2; offset += length2) @@ -793,7 +794,7 @@ void fft_1d_only(FFT_DATA *data, int nsize, int flag, struct fft_plan_3d *plan) // scaling if required // limit num to size of data - if (flag == 1 && plan->scaled) { + if (flag == -1 && plan->scaled) { norm = plan->norm; num = MIN(plan->normnum,nsize); #if defined(FFT_FFTW3) From 086ac30267ea2b0d6fe59df1afc47380dccb9b61 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 29 Dec 2020 10:21:14 -0500 Subject: [PATCH 22/51] whitespace --- doc/src/Build_extras.rst | 2 +- src/MLIAP/README | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 78165f0150..f82c6c8d04 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -807,7 +807,7 @@ compiling LAMMPS with Python version 3.6 or later. the ``cythonize`` command in case the corresponding .pyx file(s) were modified. You may need to modify ``lib/python/Makefile.lammps`` if the LAMMPS build fails. - To manually enforce building MLIAP with Python support enabled, + To manually enforce building MLIAP with Python support enabled, you can add ``-DMLIAP_PYTHON`` to the ``LMP_INC`` variable in your machine makefile. You may have to manually run the ``cythonize`` command on .pyx file(s) diff --git a/src/MLIAP/README b/src/MLIAP/README index 59eb5e34b3..1ff1e250c5 100644 --- a/src/MLIAP/README +++ b/src/MLIAP/README @@ -9,13 +9,13 @@ and the geometric quantities that characterize the atomic positions (*descriptor*). By defining *model* and *descriptor* separately, it is possible to use many different models with a given descriptor, or many different descriptors with a given model. The pair_style -supports the following models: *linear*, *quadratic*, and +supports the following models: *linear*, *quadratic*, and *mliappy* (general Python interface to things like PyTorch, see below for build instructions). -It currently supports only one class of descriptors, +It currently supports only one class of descriptors, *sna*, the SNAP descriptors, including the -linear, quadratic, and chem variants. -It is straightforward to add new descriptor and model +linear, quadratic, and chem variants. +It is straightforward to add new descriptor and model styles. The mliap compute style provides gradients of the energy, force, @@ -37,7 +37,7 @@ potentials, see the examples in FitSNAP https://github.com/FitSNAP/FitSNAP. The *mliappy* energy model requires that the MLIAP package be compiled with Python support enabled. This extension, written by Nick Lubbers (LANL), -provides a coupling to PyTorch and other Python modules. +provides a coupling to PyTorch and other Python modules. This should be automatically enabled by default if the prerequisite software is installed. It can be enforced during CMake configuration by setting the variable From 76cb49d0a0001832ceb8f3576ddb33e372369210 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 29 Dec 2020 10:31:35 -0500 Subject: [PATCH 23/51] silence compiler warnings --- src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp | 2 +- src/USER-OMP/npair_half_size_multi_newton_omp.cpp | 2 +- src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp | 2 +- src/npair_half_size_multi_newtoff.cpp | 2 +- src/npair_half_size_multi_newton.cpp | 2 +- src/npair_half_size_multi_newton_tri.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp b/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp index 33722eb9d3..415bfd3323 100644 --- a/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp +++ b/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp @@ -48,7 +48,7 @@ void NPairHalfSizeMultiNewtoffOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nlocal); - int i,j,k,m,n,itype,jtype,ibin,ns; + int i,j,k,n,itype,jtype,ibin,ns; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutdistsq; int *neighptr,*s; diff --git a/src/USER-OMP/npair_half_size_multi_newton_omp.cpp b/src/USER-OMP/npair_half_size_multi_newton_omp.cpp index 0be87457e3..e4914fd9bd 100644 --- a/src/USER-OMP/npair_half_size_multi_newton_omp.cpp +++ b/src/USER-OMP/npair_half_size_multi_newton_omp.cpp @@ -47,7 +47,7 @@ void NPairHalfSizeMultiNewtonOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nlocal); - int i,j,k,m,n,itype,jtype,ibin,ns; + int i,j,k,n,itype,jtype,ibin,ns; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutdistsq; int *neighptr,*s; diff --git a/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp b/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp index ef26a5f2bd..ce54c4135f 100644 --- a/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp +++ b/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp @@ -47,7 +47,7 @@ void NPairHalfSizeMultiNewtonTriOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nlocal); - int i,j,k,m,n,itype,jtype,ibin,ns; + int i,j,k,n,itype,jtype,ibin,ns; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutdistsq; int *neighptr,*s; diff --git a/src/npair_half_size_multi_newtoff.cpp b/src/npair_half_size_multi_newtoff.cpp index 813a642b96..d57542f562 100644 --- a/src/npair_half_size_multi_newtoff.cpp +++ b/src/npair_half_size_multi_newtoff.cpp @@ -35,7 +35,7 @@ NPairHalfSizeMultiNewtoff::NPairHalfSizeMultiNewtoff(LAMMPS *lmp) : NPair(lmp) { void NPairHalfSizeMultiNewtoff::build(NeighList *list) { - int i,j,k,m,n,itype,jtype,ibin,ns; + int i,j,k,n,itype,jtype,ibin,ns; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutdistsq; int *neighptr,*s; diff --git a/src/npair_half_size_multi_newton.cpp b/src/npair_half_size_multi_newton.cpp index 943965ab63..01065876af 100644 --- a/src/npair_half_size_multi_newton.cpp +++ b/src/npair_half_size_multi_newton.cpp @@ -34,7 +34,7 @@ NPairHalfSizeMultiNewton::NPairHalfSizeMultiNewton(LAMMPS *lmp) : NPair(lmp) {} void NPairHalfSizeMultiNewton::build(NeighList *list) { - int i,j,k,m,n,itype,jtype,ibin,ns; + int i,j,k,n,itype,jtype,ibin,ns; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutdistsq; int *neighptr,*s; diff --git a/src/npair_half_size_multi_newton_tri.cpp b/src/npair_half_size_multi_newton_tri.cpp index e59a3f088a..361c0ba260 100644 --- a/src/npair_half_size_multi_newton_tri.cpp +++ b/src/npair_half_size_multi_newton_tri.cpp @@ -33,7 +33,7 @@ NPairHalfSizeMultiNewtonTri::NPairHalfSizeMultiNewtonTri(LAMMPS *lmp) : NPair(lm void NPairHalfSizeMultiNewtonTri::build(NeighList *list) { - int i,j,k,m,n,itype,jtype,ibin,ns; + int i,j,k,n,itype,jtype,ibin,ns; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutdistsq; int *neighptr,*s; From fec52f6a48e46dda23b24fdb012627f312620f2e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 29 Dec 2020 10:40:39 -0500 Subject: [PATCH 24/51] make CMake script formatting more consistent --- cmake/CMakeLists.txt | 10 +++++----- cmake/Modules/CodingStandard.cmake | 2 +- cmake/Modules/MPI4WIN.cmake | 2 +- unittest/c-library/CMakeLists.txt | 2 +- unittest/formats/CMakeLists.txt | 6 +++--- unittest/python/CMakeLists.txt | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 12b713f15c..c29fba5957 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -25,7 +25,7 @@ set(LAMMPS_POTENTIALS_DIR ${LAMMPS_DIR}/potentials) find_package(Git) # by default, install into $HOME/.local (not /usr/local), so that no root access (and sudo!!) is needed -if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "default install path" FORCE ) endif() @@ -33,7 +33,7 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules) # make sure LIBRARY_PATH is set if environment variable is set -if (DEFINED ENV{LIBRARY_PATH}) +if(DEFINED ENV{LIBRARY_PATH}) list(APPEND CMAKE_LIBRARY_PATH "$ENV{LIBRARY_PATH}") message(STATUS "Appending $ENV{LIBRARY_PATH} to CMAKE_LIBRARY_PATH: ${CMAKE_LIBRARY_PATH}") endif() @@ -580,7 +580,7 @@ add_dependencies(lammps gitversion) ############################################ get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) list (FIND LANGUAGES "Fortran" _index) -if (${_index} GREATER -1) +if(${_index} GREATER -1) target_link_libraries(lammps PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) endif() set(LAMMPS_CXX_HEADERS angle.h atom.h bond.h citeme.h comm.h compute.h dihedral.h domain.h error.h fix.h force.h group.h improper.h @@ -737,14 +737,14 @@ if(OPTIONS) endif() get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) list (FIND LANGUAGES "Fortran" _index) -if (${_index} GREATER -1) +if(${_index} GREATER -1) message(STATUS "Fortran Compiler: ${CMAKE_Fortran_COMPILER} Type: ${CMAKE_Fortran_COMPILER_ID} Version: ${CMAKE_Fortran_COMPILER_VERSION} Fortran Flags:${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${BTYPE}}") endif() list (FIND LANGUAGES "C" _index) -if (${_index} GREATER -1) +if(${_index} GREATER -1) message(STATUS "C compiler: ${CMAKE_C_COMPILER} Type: ${CMAKE_C_COMPILER_ID} Version: ${CMAKE_C_COMPILER_VERSION} diff --git a/cmake/Modules/CodingStandard.cmake b/cmake/Modules/CodingStandard.cmake index 72b064af66..646bdcdd4a 100644 --- a/cmake/Modules/CodingStandard.cmake +++ b/cmake/Modules/CodingStandard.cmake @@ -8,7 +8,7 @@ else() find_package(Python3 COMPONENTS Interpreter QUIET) endif() -if (Python3_EXECUTABLE) +if(Python3_EXECUTABLE) if(Python3_VERSION VERSION_GREATER_EQUAL 3.5) add_custom_target( check-whitespace diff --git a/cmake/Modules/MPI4WIN.cmake b/cmake/Modules/MPI4WIN.cmake index 035c6a22f3..529cefeab0 100644 --- a/cmake/Modules/MPI4WIN.cmake +++ b/cmake/Modules/MPI4WIN.cmake @@ -1,7 +1,7 @@ # Download and configure custom MPICH files for Windows message(STATUS "Downloading and configuring MPICH-1.4.1 for Windows") include(ExternalProject) -if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") +if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") ExternalProject_Add(mpi4win_build URL https://download.lammps.org/thirdparty/mpich2-win64-devel.tar.gz URL_MD5 4939fdb59d13182fd5dd65211e469f14 diff --git a/unittest/c-library/CMakeLists.txt b/unittest/c-library/CMakeLists.txt index 09717c058e..121c42f7fd 100644 --- a/unittest/c-library/CMakeLists.txt +++ b/unittest/c-library/CMakeLists.txt @@ -56,7 +56,7 @@ target_link_libraries(test_library_config PRIVATE lammps GTest::GTest GTest::GMo target_compile_definitions(test_library_config PRIVATE ${TEST_CONFIG_DEFS}) add_test(LibraryConfig test_library_config) -if (BUILD_MPI) +if(BUILD_MPI) add_executable(test_library_mpi test_library_mpi.cpp) target_link_libraries(test_library_mpi PRIVATE lammps GTest::GTest GTest::GMock) target_compile_definitions(test_library_mpi PRIVATE ${TEST_CONFIG_DEFS}) diff --git a/unittest/formats/CMakeLists.txt b/unittest/formats/CMakeLists.txt index 72cd81357b..3c1ed66c06 100644 --- a/unittest/formats/CMakeLists.txt +++ b/unittest/formats/CMakeLists.txt @@ -17,7 +17,7 @@ target_link_libraries(test_potential_file_reader PRIVATE lammps GTest::GMock GTe add_test(NAME PotentialFileReader COMMAND test_potential_file_reader WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set_tests_properties(PotentialFileReader PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}") -if (PKG_MANYBODY) +if(PKG_MANYBODY) add_executable(test_eim_potential_file_reader test_eim_potential_file_reader.cpp) target_link_libraries(test_eim_potential_file_reader PRIVATE lammps GTest::GMock GTest::GTest) add_test(NAME EIMPotentialFileReader COMMAND test_eim_potential_file_reader WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) @@ -33,7 +33,7 @@ target_link_libraries(test_dump_atom PRIVATE lammps GTest::GMock GTest::GTest) add_test(NAME DumpAtom COMMAND test_dump_atom WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set_tests_properties(DumpAtom PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}") -if (PKG_COMPRESS) +if(PKG_COMPRESS) find_program(GZIP_BINARY NAMES gzip REQUIRED) add_executable(test_dump_atom_gz test_dump_atom_gz.cpp) @@ -113,7 +113,7 @@ target_link_libraries(test_dump_cfg PRIVATE lammps GTest::GMock GTest::GTest) add_test(NAME DumpCfg COMMAND test_dump_cfg WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set_tests_properties(DumpCfg PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}") -if (BUILD_TOOLS) +if(BUILD_TOOLS) set_tests_properties(DumpAtom PROPERTIES ENVIRONMENT "BINARY2TXT_BINARY=$") set_tests_properties(DumpCustom PROPERTIES ENVIRONMENT "BINARY2TXT_BINARY=$") endif() diff --git a/unittest/python/CMakeLists.txt b/unittest/python/CMakeLists.txt index 640edf2733..d5328b1cfe 100644 --- a/unittest/python/CMakeLists.txt +++ b/unittest/python/CMakeLists.txt @@ -25,7 +25,7 @@ else() find_package(Python3 COMPONENTS Interpreter) endif() -if (Python_EXECUTABLE) +if(Python_EXECUTABLE) # prepare to augment the environment so that the LAMMPS python module and the shared library is found. set(PYTHON_TEST_ENVIRONMENT PYTHONPATH=${LAMMPS_PYTHON_DIR}:$ENV{PYTHONPATH}) if(APPLE) From 840dd61095ebb9cfb9ff8cb8a9723407c629c9fa Mon Sep 17 00:00:00 2001 From: Evan Weinberg Date: Tue, 29 Dec 2020 14:23:58 -0500 Subject: [PATCH 25/51] Further optimized algorithm for computing the Wigner U matrices and derivatives thereof. Replaced explicit double within the SNAP kernels with a compile-time "real" type. Optimized GPU compressed neighbor build within SNAP. --- src/KOKKOS/kokkos_type.h | 41 +- src/KOKKOS/pair_snap_kokkos.cpp | 6 +- src/KOKKOS/pair_snap_kokkos.h | 102 ++- src/KOKKOS/pair_snap_kokkos_impl.h | 996 +++++++++++++++----------- src/KOKKOS/sna_kokkos.h | 154 ++-- src/KOKKOS/sna_kokkos_impl.h | 1075 ++++++++++++++-------------- 6 files changed, 1341 insertions(+), 1033 deletions(-) diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index 72513d2b17..aac87e9153 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -1076,15 +1076,29 @@ struct params_lj_coul { // Pair SNAP +#define SNAP_KOKKOS_REAL double +#define SNAP_KOKKOS_HOST_VECLEN 1 + +#ifdef LMP_KOKKOS_GPU +#define SNAP_KOKKOS_DEVICE_VECLEN 32 +#else +#define SNAP_KOKKOS_DEVICE_VECLEN 1 +#endif + + +// intentional: SNAreal/complex gets reused beyond SNAP typedef double SNAreal; //typedef struct { SNAreal re, im; } SNAcomplex; -template -struct alignas(2*sizeof(real)) SNAComplex +template +struct alignas(2*sizeof(real_)) SNAComplex { + using real = real_; + using complex = SNAComplex; real re,im; - SNAComplex() = default; + KOKKOS_FORCEINLINE_FUNCTION SNAComplex() + : re(static_cast(0.)), im(static_cast(0.)) { ; } KOKKOS_FORCEINLINE_FUNCTION SNAComplex(real re) : re(re), im(static_cast(0.)) { ; } @@ -1117,6 +1131,15 @@ struct alignas(2*sizeof(real)) SNAComplex return *this; } + KOKKOS_INLINE_FUNCTION + static constexpr complex zero() { return complex(static_cast(0.), static_cast(0.)); } + + KOKKOS_INLINE_FUNCTION + static constexpr complex one() { return complex(static_cast(1.), static_cast(0.)); } + + KOKKOS_INLINE_FUNCTION + const complex conj() { return complex(re, -im); } + }; template @@ -1126,18 +1149,6 @@ KOKKOS_FORCEINLINE_FUNCTION SNAComplex operator*(const real& r, const SNAC typedef SNAComplex SNAcomplex; -// Cayley-Klein pack -// Can guarantee it's aligned to 2 complex -struct alignas(32) CayleyKleinPack { - - SNAcomplex a, b; - SNAcomplex da[3], db[3]; - SNAreal sfac; - SNAreal dsfacu[3]; - -}; - - #if defined(KOKKOS_ENABLE_CXX11) #undef ISFINITE #define ISFINITE(x) std::isfinite(x) diff --git a/src/KOKKOS/pair_snap_kokkos.cpp b/src/KOKKOS/pair_snap_kokkos.cpp index 6f324a97be..4677d178e0 100644 --- a/src/KOKKOS/pair_snap_kokkos.cpp +++ b/src/KOKKOS/pair_snap_kokkos.cpp @@ -15,9 +15,11 @@ #include "pair_snap_kokkos_impl.h" namespace LAMMPS_NS { -template class PairSNAPKokkos; + +template class PairSNAPKokkosDevice; #ifdef LMP_KOKKOS_GPU -template class PairSNAPKokkos; +template class PairSNAPKokkosHost; #endif + } diff --git a/src/KOKKOS/pair_snap_kokkos.h b/src/KOKKOS/pair_snap_kokkos.h index e7a1f3173d..352e6e30b1 100644 --- a/src/KOKKOS/pair_snap_kokkos.h +++ b/src/KOKKOS/pair_snap_kokkos.h @@ -13,9 +13,15 @@ #ifdef PAIR_CLASS -PairStyle(snap/kk,PairSNAPKokkos) -PairStyle(snap/kk/device,PairSNAPKokkos) -PairStyle(snap/kk/host,PairSNAPKokkos) +#include "kokkos_type.h" + +PairStyle(snap/kk,PairSNAPKokkosDevice) +PairStyle(snap/kk/device,PairSNAPKokkosDevice) +#ifdef LMP_KOKKOS_GPU +PairStyle(snap/kk/host,PairSNAPKokkosHost) +#else +PairStyle(snap/kk/host,PairSNAPKokkosDevice) +#endif #else @@ -33,9 +39,11 @@ namespace LAMMPS_NS { // Routines for both the CPU and GPU backend template struct TagPairSNAPComputeForce{}; -struct TagPairSNAPComputeNeigh{}; + // GPU backend only +struct TagPairSNAPComputeNeigh{}; +struct TagPairSNAPComputeCayleyKlein{}; struct TagPairSNAPPreUi{}; struct TagPairSNAPComputeUi{}; struct TagPairSNAPTransformUi{}; // re-order ulisttot from SoA to AoSoA, zero ylist @@ -44,10 +52,10 @@ struct TagPairSNAPBeta{}; struct TagPairSNAPComputeBi{}; struct TagPairSNAPTransformBi{}; // re-order blist from AoSoA to AoS struct TagPairSNAPComputeYi{}; -struct TagPairSNAPTransformYi{}; // re-order ylist from AoSoA to AoS struct TagPairSNAPComputeFusedDeidrj{}; // CPU backend only +struct TagPairSNAPComputeNeighCPU{}; struct TagPairSNAPPreUiCPU{}; struct TagPairSNAPComputeUiCPU{}; struct TagPairSNAPTransformUiCPU{}; @@ -59,7 +67,7 @@ struct TagPairSNAPComputeYiCPU{}; struct TagPairSNAPComputeDuidrjCPU{}; struct TagPairSNAPComputeDeidrjCPU{}; -template +template class PairSNAPKokkos : public PairSNAP { public: enum {EnabledNeighFlags=FULL|HALF|HALFTHREAD}; @@ -68,6 +76,10 @@ public: typedef ArrayTypes AT; typedef EV_FLOAT value_type; + static constexpr int vector_length = vector_length_; + using real = real_; + using complex = SNAComplex; + PairSNAPKokkos(class LAMMPS *); ~PairSNAPKokkos(); @@ -78,10 +90,10 @@ public: double memory_usage(); template - void check_team_size_for(int, int&, int); + void check_team_size_for(int, int&); template - void check_team_size_reduce(int, int&, int); + void check_team_size_reduce(int, int&); template KOKKOS_INLINE_FUNCTION @@ -91,15 +103,18 @@ public: KOKKOS_INLINE_FUNCTION void operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team, EV_FLOAT&) const; - KOKKOS_INLINE_FUNCTION - void operator() (TagPairSNAPComputeNeigh,const typename Kokkos::TeamPolicy::member_type& team) const; - KOKKOS_INLINE_FUNCTION void operator() (TagPairSNAPBetaCPU,const int& ii) const; // GPU backend only KOKKOS_INLINE_FUNCTION - void operator() (TagPairSNAPPreUi,const typename Kokkos::TeamPolicy::member_type& team) const; + void operator() (TagPairSNAPComputeNeigh,const typename Kokkos::TeamPolicy::member_type& team) const; + + KOKKOS_INLINE_FUNCTION + void operator() (TagPairSNAPComputeCayleyKlein, const int iatom_mod, const int jnbor, const int iatom_div) const; + + KOKKOS_INLINE_FUNCTION + void operator() (TagPairSNAPPreUi,const int iatom_mod, const int j, const int iatom_div) const; KOKKOS_INLINE_FUNCTION void operator() (TagPairSNAPComputeUi,const typename Kokkos::TeamPolicy::member_type& team) const; @@ -122,13 +137,13 @@ public: KOKKOS_INLINE_FUNCTION void operator() (TagPairSNAPComputeYi,const int iatom_mod, const int idxz, const int iatom_div) const; - KOKKOS_INLINE_FUNCTION - void operator() (TagPairSNAPTransformYi,const int iatom_mod, const int idxu, const int iatom_div) const; - KOKKOS_INLINE_FUNCTION void operator() (TagPairSNAPComputeFusedDeidrj,const typename Kokkos::TeamPolicy::member_type& team) const; // CPU backend only + KOKKOS_INLINE_FUNCTION + void operator() (TagPairSNAPComputeNeighCPU,const typename Kokkos::TeamPolicy::member_type& team) const; + KOKKOS_INLINE_FUNCTION void operator() (TagPairSNAPPreUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const; @@ -173,7 +188,7 @@ protected: t_bvec bvec; typedef Kokkos::View t_dbvec; t_dbvec dbvec; - SNAKokkos snaKK; + SNAKokkos snaKK; int inum,max_neighs,chunk_size,chunk_offset; int host_flag; @@ -208,14 +223,14 @@ inline double dist2(double* x,double* y); Kokkos::View i_uarraytot_r, i_uarraytot_i; Kokkos::View i_zarray_r, i_zarray_i; - Kokkos::View d_radelem; // element radii - Kokkos::View d_wjelem; // elements weights - Kokkos::View d_coeffelem; // element bispectrum coefficients + Kokkos::View d_radelem; // element radii + Kokkos::View d_wjelem; // elements weights + Kokkos::View d_coeffelem; // element bispectrum coefficients Kokkos::View d_map; // mapping from atom types to elements Kokkos::View d_ninside; // ninside for all atoms in list - Kokkos::View d_beta; // betas for all atoms in list - Kokkos::View d_beta_pack; // betas for all atoms in list, GPU - Kokkos::View d_bispectrum; // bispectrum components for all atoms in list + Kokkos::View d_beta; // betas for all atoms in list + Kokkos::View d_beta_pack; // betas for all atoms in list, GPU + Kokkos::View d_bispectrum; // bispectrum components for all atoms in list typedef Kokkos::DualView tdual_fparams; tdual_fparams k_cutsq; @@ -237,6 +252,49 @@ inline double dist2(double* x,double* y); }; + +// These wrapper classes exist to make the pair style factory happy/avoid having +// to extend the pair style factory to support Pair classes w/an arbitrary number +// of extra template parameters + +template +class PairSNAPKokkosDevice : public PairSNAPKokkos { + +private: + using Base = PairSNAPKokkos; + +public: + + PairSNAPKokkosDevice(class LAMMPS *); + + void coeff(int, char**); + void init_style(); + double init_one(int, int); + void compute(int, int); + double memory_usage(); + +}; + +#ifdef LMP_KOKKOS_GPU +template +class PairSNAPKokkosHost : public PairSNAPKokkos { + +private: + using Base = PairSNAPKokkos; + +public: + + PairSNAPKokkosHost(class LAMMPS *); + + void coeff(int, char**); + void init_style(); + double init_one(int, int); + void compute(int, int); + double memory_usage(); + +}; +#endif + } #endif diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index bacb5f75d6..194738828c 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -48,8 +48,8 @@ namespace LAMMPS_NS { //static double t7 = 0.0; /* ---------------------------------------------------------------------- */ -template -PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : PairSNAP(lmp) +template +PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : PairSNAP(lmp) { respa_enable = 0; @@ -67,8 +67,8 @@ PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : PairSNAP(lmp) /* ---------------------------------------------------------------------- */ -template -PairSNAPKokkos::~PairSNAPKokkos() +template +PairSNAPKokkos::~PairSNAPKokkos() { if (copymode) return; @@ -81,8 +81,8 @@ PairSNAPKokkos::~PairSNAPKokkos() init specific to this pair style ------------------------------------------------------------------------- */ -template -void PairSNAPKokkos::init_style() +template +void PairSNAPKokkos::init_style() { if (force->newton_pair == 0) error->all(FLERR,"Pair style SNAP requires newton pair on"); @@ -128,8 +128,8 @@ struct FindMaxNumNeighs { This version is a straightforward implementation ---------------------------------------------------------------------- */ -template -void PairSNAPKokkos::compute(int eflag_in, int vflag_in) +template +void PairSNAPKokkos::compute(int eflag_in, int vflag_in) { eflag = eflag_in; vflag = vflag_in; @@ -186,16 +186,15 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) max_neighs = 0; Kokkos::parallel_reduce("PairSNAPKokkos::find_max_neighs",inum, FindMaxNumNeighs(k_list), Kokkos::Max(max_neighs)); - int vector_length_default = 1; int team_size_default = 1; if (!host_flag) team_size_default = 32;//max_neighs; if (beta_max < inum) { beta_max = inum; - d_beta = Kokkos::View("PairSNAPKokkos:beta",ncoeff,inum); + d_beta = Kokkos::View("PairSNAPKokkos:beta",ncoeff,inum); if (!host_flag) - d_beta_pack = Kokkos::View("PairSNAPKokkos:beta_pack",32,ncoeff,(inum+32-1)/32); + d_beta_pack = Kokkos::View("PairSNAPKokkos:beta_pack",vector_length,ncoeff,(inum + vector_length - 1) / vector_length); d_ninside = Kokkos::View("PairSNAPKokkos:ninside",inum); } @@ -213,31 +212,28 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) if (chunk_size > inum - chunk_offset) chunk_size = inum - chunk_offset; - //ComputeNeigh - { - int vector_length = vector_length_default; - int team_size = team_size_default; - check_team_size_for(chunk_size,team_size,vector_length); - typename Kokkos::TeamPolicy policy_neigh(chunk_size,team_size,vector_length); - Kokkos::parallel_for("ComputeNeigh",policy_neigh,*this); - } - if (host_flag) { // Host codepath + //ComputeNeigh + { + int team_size = team_size_default; + check_team_size_for(chunk_size,team_size); + typename Kokkos::TeamPolicy policy_neigh(chunk_size,team_size,vector_length); + Kokkos::parallel_for("ComputeNeighCPU",policy_neigh,*this); + } + //PreUi { - int vector_length = vector_length_default; int team_size = team_size_default; - check_team_size_for(chunk_size,team_size,vector_length); + check_team_size_for(chunk_size,team_size); typename Kokkos::TeamPolicy policy_preui_cpu((chunk_size+team_size-1)/team_size,team_size,vector_length); Kokkos::parallel_for("PreUiCPU",policy_preui_cpu,*this); } // ComputeUi { - int vector_length = vector_length_default; int team_size = team_size_default; // Fused calculation of ulist and accumulation into ulisttot using atomics typename Kokkos::TeamPolicy policy_ui_cpu(((chunk_size+team_size-1)/team_size)*max_neighs,team_size,vector_length); @@ -259,9 +255,8 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) Kokkos::parallel_for("ComputeZiCPU",policy_zi_cpu,*this); //ComputeBi - int vector_length = vector_length_default; int team_size = team_size_default; - check_team_size_for(chunk_size,team_size,vector_length); + check_team_size_for(chunk_size,team_size); typename Kokkos::TeamPolicy policy_bi_cpu(chunk_size,team_size,vector_length); Kokkos::parallel_for("ComputeBiCPU",policy_bi_cpu,*this); } @@ -281,7 +276,6 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) //ComputeDuidrj and Deidrj { int team_size = team_size_default; - int vector_length = vector_length_default; typename Kokkos::TeamPolicy policy_duidrj_cpu(((chunk_size+team_size-1)/team_size)*max_neighs,team_size,vector_length); snaKK.set_dir(-1); // technically doesn't do anything @@ -295,39 +289,65 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) } else { // GPU #ifdef LMP_KOKKOS_GPU + + //ComputeNeigh + { + constexpr int team_size = 4; + + // scratch size: max_neighs * sizeof(int) * number of threads per team + typedef Kokkos::View< int*, + Kokkos::DefaultExecutionSpace::scratch_memory_space, + Kokkos::MemoryTraits > + ScratchViewType; + int scratch_size = ScratchViewType::shmem_size( team_size * max_neighs ); + + typename Kokkos::TeamPolicy policy_neigh(chunk_size,team_size,vector_length); + policy_neigh = policy_neigh.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); + Kokkos::parallel_for("ComputeNeigh",policy_neigh,*this); + } + + //ComputeCayleyKlein + { + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeCayleyKlein> + policy_compute_ck({0,0,0},{vector_length,max_neighs,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); + Kokkos::parallel_for("ComputeCayleyKlein",policy_compute_ck,*this); + } + //PreUi { - int vector_length = vector_length_default; - int team_size = team_size_default; - check_team_size_for(chunk_size,team_size,vector_length); - typename Kokkos::TeamPolicy policy_preui((chunk_size+team_size-1)/team_size,team_size,vector_length); + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPPreUi> + policy_preui({0,0,0},{vector_length,twojmax+1,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); Kokkos::parallel_for("PreUi",policy_preui,*this); + } // ComputeUi w/vector parallelism, shared memory, direct atomicAdd into ulisttot { + // new AoSoA form + constexpr int team_size = sizeof(real) == 4 ? 8 : 4; // shared memory reqs - int vector_length = 32; - int team_size = 4; // need to cap b/c of shared memory reqs - check_team_size_for(chunk_size,team_size,vector_length); - - // scratch size: 2 * team_size * (twojmax+1)^2, to cover all `m1`,`m2` values, div 2 for symmetry - // 2 is for double buffer - - const int tile_size = (twojmax+1)*(twojmax/2+1); - typedef Kokkos::View< SNAcomplex*, + // scratch size: 32 atoms * (twojmax+1) cached values, no double buffer + const int tile_size = vector_length * (twojmax + 1); + typedef Kokkos::View< complex*, Kokkos::DefaultExecutionSpace::scratch_memory_space, Kokkos::MemoryTraits > ScratchViewType; - int scratch_size = ScratchViewType::shmem_size( 2 * team_size * tile_size ); + int scratch_size = ScratchViewType::shmem_size( team_size * tile_size ); - typename Kokkos::TeamPolicy policy_ui(((chunk_size+team_size-1)/team_size)*max_neighs,team_size,vector_length); + // total number of teams needed + int chunk_size_div = (chunk_size + vector_length - 1) / vector_length; + + // (natoms / 32) * (max_neighs) * ("bend" locations) + int n_teams = chunk_size_div * max_neighs * (twojmax + 1); + int n_teams_div = (n_teams + team_size - 1) / team_size; + + typename Kokkos::TeamPolicy policy_ui(n_teams_div,team_size, vector_length); policy_ui = policy_ui.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); Kokkos::parallel_for("ComputeUi",policy_ui,*this); - //Transform data layout of ulisttot to AoSoA, zero ylist - typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPTransformUi> policy_transform_ui({0,0,0},{32,twojmax+1,(chunk_size + 32 - 1) / 32},{32,4,1}); + // un-"fold" ulisttot, zero ylist + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPTransformUi> policy_transform_ui({0,0,0},{vector_length,snaKK.idxu_max,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); Kokkos::parallel_for("TransformUi",policy_transform_ui,*this); } @@ -336,19 +356,19 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) if (quadraticflag || eflag) { //ComputeZi int idxz_max = snaKK.idxz_max; - typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeZi> policy_compute_zi({0,0,0},{32,idxz_max,(chunk_size + 32 - 1) / 32},{32,4,1}); + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeZi> policy_compute_zi({0,0,0},{vector_length,idxz_max,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); Kokkos::parallel_for("ComputeZi",policy_compute_zi,*this); //ComputeBi int idxb_max = snaKK.idxb_max; - typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeBi> policy_compute_bi({0,0,0},{32,idxb_max,(chunk_size + 32 - 1) / 32},{32,4,1}); + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeBi> policy_compute_bi({0,0,0},{vector_length,idxb_max,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); Kokkos::parallel_for("ComputeBi",policy_compute_bi,*this); //Transform data layout of blist out of AoSoA //We need this b/c `blist` gets used in ComputeForce which doesn't //take advantage of AoSoA (which at best would only be beneficial //on the margins) - typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPTransformBi> policy_transform_bi({0,0,0},{32,idxb_max,(chunk_size + 32 - 1) / 32},{32,4,1}); + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPTransformBi> policy_transform_bi({0,0,0},{vector_length,idxb_max,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); Kokkos::parallel_for("TransformBi",policy_transform_bi,*this); } @@ -361,39 +381,39 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) //ComputeYi const int idxz_max = snaKK.idxz_max; - typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeYi> policy_compute_yi({0,0,0},{32,idxz_max,(chunk_size + 32 - 1) / 32},{32,4,1}); + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeYi> policy_compute_yi({0,0,0},{vector_length,idxz_max,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); Kokkos::parallel_for("ComputeYi",policy_compute_yi,*this); - //Transform data layout of ylist out of AoSoA - const int idxu_half_max = snaKK.idxu_half_max; - typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPTransformYi> policy_transform_yi({0,0,0},{32,idxu_half_max,(chunk_size + 32 - 1) / 32},{32,4,1}); - Kokkos::parallel_for("TransformYi",policy_transform_yi,*this); - } // Fused ComputeDuidrj, ComputeDeidrj { - int vector_length = 32; - int team_size = 2; // need to cap b/c of shared memory reqs - check_team_size_for(chunk_size,team_size,vector_length); + // new AoSoA form + constexpr int team_size = sizeof(real) == 4 ? 4 : 2; // shared memory reqs - // scratch size: 2 * 2 * team_size * (twojmax+1)*(twojmax/2+1), to cover half `m1`,`m2` values due to symmetry - // 2 is for double buffer - const int tile_size = (twojmax+1)*(twojmax/2+1); - - typedef Kokkos::View< SNAcomplex*, + // scratch size: 32 atoms * (twojmax+1) cached values * 2 for u, du, no double buffer + const int tile_size = vector_length * (twojmax + 1); + typedef Kokkos::View< complex*, Kokkos::DefaultExecutionSpace::scratch_memory_space, Kokkos::MemoryTraits > ScratchViewType; - int scratch_size = ScratchViewType::shmem_size( 4 * team_size * tile_size); + int scratch_size = ScratchViewType::shmem_size( 2 * team_size * tile_size ); - typename Kokkos::TeamPolicy policy_fused_deidrj(((chunk_size+team_size-1)/team_size)*max_neighs,team_size,vector_length); + // total number of teams needed + int chunk_size_div = (chunk_size + vector_length - 1) / vector_length; + + // (natoms / 32) * (max_neighs) * ("bend" locations) + int n_teams = chunk_size_div * max_neighs * (twojmax + 1); + int n_teams_div = (n_teams + team_size - 1) / team_size; + + typename Kokkos::TeamPolicy policy_fused_deidrj(n_teams_div,team_size,vector_length); policy_fused_deidrj = policy_fused_deidrj.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); for (int k = 0; k < 3; k++) { snaKK.set_dir(k); Kokkos::parallel_for("ComputeFusedDeidrj",policy_fused_deidrj,*this); } + } #endif // LMP_KOKKOS_GPU @@ -403,27 +423,26 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) //ComputeForce { int team_size = team_size_default; - int vector_length = vector_length_default; if (evflag) { if (neighflag == HALF) { - check_team_size_reduce >(chunk_size,team_size,vector_length); + check_team_size_reduce >(chunk_size,team_size); typename Kokkos::TeamPolicy > policy_force(chunk_size,team_size,vector_length); Kokkos::parallel_reduce(policy_force ,*this,ev_tmp); } else if (neighflag == HALFTHREAD) { - check_team_size_reduce >(chunk_size,team_size,vector_length); + check_team_size_reduce >(chunk_size,team_size); typename Kokkos::TeamPolicy > policy_force(chunk_size,team_size,vector_length); Kokkos::parallel_reduce(policy_force ,*this,ev_tmp); } } else { if (neighflag == HALF) { - check_team_size_for >(chunk_size,team_size,vector_length); + check_team_size_for >(chunk_size,team_size); typename Kokkos::TeamPolicy > policy_force(chunk_size,team_size,vector_length); Kokkos::parallel_for(policy_force ,*this); } else if (neighflag == HALFTHREAD) { - check_team_size_for >(chunk_size,team_size,vector_length); + check_team_size_for >(chunk_size,team_size); typename Kokkos::TeamPolicy > policy_force(chunk_size,team_size,vector_length); Kokkos::parallel_for(policy_force ,*this); @@ -478,8 +497,8 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) allocate all arrays ------------------------------------------------------------------------- */ -template -void PairSNAPKokkos::allocate() +template +void PairSNAPKokkos::allocate() { PairSNAP::allocate(); @@ -492,8 +511,8 @@ void PairSNAPKokkos::allocate() init for one type pair i,j and corresponding j,i ------------------------------------------------------------------------- */ -template -double PairSNAPKokkos::init_one(int i, int j) +template +double PairSNAPKokkos::init_one(int i, int j) { double cutone = PairSNAP::init_one(i,j); k_cutsq.h_view(i,j) = k_cutsq.h_view(j,i) = cutone*cutone; @@ -506,16 +525,16 @@ double PairSNAPKokkos::init_one(int i, int j) set coeffs for one or more type pairs ------------------------------------------------------------------------- */ -template -void PairSNAPKokkos::coeff(int narg, char **arg) +template +void PairSNAPKokkos::coeff(int narg, char **arg) { PairSNAP::coeff(narg,arg); // Set up element lists - d_radelem = Kokkos::View("pair:radelem",nelements); - d_wjelem = Kokkos::View("pair:wjelem",nelements); - d_coeffelem = Kokkos::View("pair:coeffelem",nelements,ncoeffall); + d_radelem = Kokkos::View("pair:radelem",nelements); + d_wjelem = Kokkos::View("pair:wjelem",nelements); + d_coeffelem = Kokkos::View("pair:coeffelem",nelements,ncoeffall); auto h_radelem = Kokkos::create_mirror_view(d_radelem); auto h_wjelem = Kokkos::create_mirror_view(d_wjelem); @@ -539,25 +558,382 @@ void PairSNAPKokkos::coeff(int narg, char **arg) Kokkos::deep_copy(d_coeffelem,h_coeffelem); Kokkos::deep_copy(d_map,h_map); - snaKK = SNAKokkos(rfac0,twojmax, + snaKK = SNAKokkos(rfac0,twojmax, rmin0,switchflag,bzeroflag,chemflag,bnormflag,wselfallflag,nelements); snaKK.grow_rij(0,0); snaKK.init(); } /* ---------------------------------------------------------------------- - Begin routines that are called on both CPU and GPU codepaths + Begin routines that are unique to the GPU codepath. These take advantage + of AoSoA data layouts and scratch memory for recursive polynomials ------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- */ - -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeNeigh,const typename Kokkos::TeamPolicy::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPBeta,const int& ii) const { + + if (ii >= chunk_size) return; + + const int iatom_mod = ii % vector_length; + const int iatom_div = ii / vector_length; + + const int i = d_ilist[ii + chunk_offset]; + const int itype = type[i]; + const int ielem = d_map[itype]; + SNAKokkos my_sna = snaKK; + + auto d_coeffi = Kokkos::subview(d_coeffelem, ielem, Kokkos::ALL); + + for (int icoeff = 0; icoeff < ncoeff; icoeff++) { + d_beta_pack(iatom_mod,icoeff,iatom_div) = d_coeffi[icoeff+1]; + } + + if (quadraticflag) { + const auto idxb_max = my_sna.idxb_max; + int k = ncoeff+1; + for (int icoeff = 0; icoeff < ncoeff; icoeff++) { + const auto idxb = icoeff % idxb_max; + const auto idx_chem = icoeff / idxb_max; + auto bveci = my_sna.blist(idxb, idx_chem, ii); + d_beta_pack(iatom_mod,icoeff,iatom_div) += d_coeffi[k]*bveci; + k++; + for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { + const auto jdxb = jcoeff % idxb_max; + const auto jdx_chem = jcoeff / idxb_max; + real bvecj = my_sna.blist(jdxb, jdx_chem, ii); + d_beta_pack(iatom_mod,icoeff,iatom_div) += d_coeffi[k]*bvecj; + d_beta_pack(iatom_mod,jcoeff,iatom_div) += d_coeffi[k]*bveci; + k++; + } + } + } +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeNeigh,const typename Kokkos::TeamPolicy::member_type& team) const { + + SNAKokkos my_sna = snaKK; + + // extract atom number + int ii = team.team_rank() + team.league_rank() * team.team_size(); + if (ii >= chunk_size) return; + + // get a pointer to scratch memory + // This is used to cache whether or not an atom is within the cutoff. + // If it is, type_cache is assigned to the atom type. + // If it's not, it's assigned to -1. + const int tile_size = max_neighs; // number of elements per thread + const int team_rank = team.team_rank(); + const int scratch_shift = team_rank * tile_size; // offset into pointer for entire team + int* type_cache = (int*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(int), 0) + scratch_shift; + + // Load various info about myself up front + const int i = d_ilist[ii + chunk_offset]; + const F_FLOAT xtmp = x(i,0); + const F_FLOAT ytmp = x(i,1); + const F_FLOAT ztmp = x(i,2); + const int itype = type[i]; + const int ielem = d_map[itype]; + const double radi = d_radelem[ielem]; + + const int num_neighs = d_numneigh[i]; + + // rij[][3] = displacements between atom I and those neighbors + // inside = indices of neighbors of I within cutoff + // wj = weights for neighbors of I within cutoff + // rcutij = cutoffs for neighbors of I within cutoff + // note Rij sign convention => dU/dRij = dU/dRj = -dU/dRi + + // Compute the number of neighbors, store rsq + int ninside = 0; + Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,num_neighs), + [&] (const int jj, int& count) { + T_INT j = d_neighbors(i,jj); + const F_FLOAT dx = x(j,0) - xtmp; + const F_FLOAT dy = x(j,1) - ytmp; + const F_FLOAT dz = x(j,2) - ztmp; + + int jtype = type(j); + const F_FLOAT rsq = dx*dx + dy*dy + dz*dz; + + if (rsq >= rnd_cutsq(itype,jtype)) { + jtype = -1; // use -1 to signal it's outside the radius + } + + type_cache[jj] = jtype; + + if ( jtype >= 0 ) + count++; + }, ninside); + + d_ninside(ii) = ninside; + + Kokkos::parallel_scan(Kokkos::ThreadVectorRange(team,num_neighs), + [&] (const int jj, int& offset, bool final) { + + const int jtype = type_cache[jj]; + + if ( jtype >= 0 ) { + if (final) { + T_INT j = d_neighbors(i,jj); + const F_FLOAT dx = x(j,0) - xtmp; + const F_FLOAT dy = x(j,1) - ytmp; + const F_FLOAT dz = x(j,2) - ztmp; + const int elem_j = d_map[jtype]; + my_sna.rij(ii,offset,0) = static_cast(dx); + my_sna.rij(ii,offset,1) = static_cast(dy); + my_sna.rij(ii,offset,2) = static_cast(dz); + my_sna.wj(ii,offset) = static_cast(d_wjelem[elem_j]); + my_sna.rcutij(ii,offset) = static_cast((radi + d_radelem[elem_j])*rcutfac); + my_sna.inside(ii,offset) = j; + if (chemflag) + my_sna.element(ii,offset) = elem_j; + else + my_sna.element(ii,offset) = 0; + } + offset++; + } + }); +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeCayleyKlein,const int iatom_mod, const int jnbor, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int ii = iatom_mod + iatom_div * vector_length; + if (ii >= chunk_size) return; + + const int ninside = d_ninside(ii); + if (jnbor >= ninside) return; + + my_sna.compute_cayley_klein(iatom_mod,jnbor,iatom_div); +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPPreUi, const int iatom_mod, const int j, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int ii = iatom_mod + iatom_div * vector_length; + if (ii >= chunk_size) return; + + int itype = type(ii); + int ielem = d_map[itype]; + + my_sna.pre_ui(iatom_mod, j, ielem, iatom_div); +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeUi,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; + + constexpr int team_size = sizeof(real) == 4 ? 8 : 4; + if (team.team_size() != team_size) return; // error + + // extract flattened atom_div / neighbor number / bend location + int flattened_idx = team.team_rank() + team.league_rank() * team_size; + + // extract neighbor index, iatom_div + const int iatom_div = flattened_idx / (max_neighs * (twojmax + 1)); // plug in int_fastdiv + const int jj_jbend = flattened_idx - iatom_div * (max_neighs * (twojmax + 1)); + const int jbend = jj_jbend / max_neighs; + const int jj = jj_jbend - jbend * max_neighs; + + // check base atom numbers, hopefully this doesn't lead to blocking conditions? + // yep, we can't have a return in here + Kokkos::parallel_for(Kokkos::ThreadVectorRange(team, vector_length), + [&] (const int iatom_mod) { + const int ii = iatom_mod + vector_length * iatom_div; + if (ii >= chunk_size) return; + + const int ninside = d_ninside(ii); + if (jj >= ninside) return; + + my_sna.compute_ui(team,iatom_mod, jbend, jj, iatom_div); + }); + +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPTransformUi,const int iatom_mod, const int idxu, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int iatom = iatom_mod + iatom_div * vector_length; + if (iatom >= chunk_size) return; + + if (idxu > my_sna.idxu_max) return; + + int elem_count = chemflag ? nelements : 1; + + for (int ielem = 0; ielem < elem_count; ielem++) { + + const FullHalfMapper mapper = my_sna.idxu_full_half[idxu]; + + auto utot_re = my_sna.ulisttot_re_pack(iatom_mod, mapper.idxu_half, ielem, iatom_div); + auto utot_im = my_sna.ulisttot_im_pack(iatom_mod, mapper.idxu_half, ielem, iatom_div); + + if (mapper.flip_sign == 1) { + utot_im = -utot_im; + } else if (mapper.flip_sign == -1 ) { + utot_re = -utot_re; + } + + my_sna.ulisttot_pack(iatom_mod, idxu, ielem, iatom_div) = { utot_re, utot_im }; + + if (mapper.flip_sign == 0) { + my_sna.ylist_pack_re(iatom_mod, mapper.idxu_half, ielem, iatom_div) = 0.; + my_sna.ylist_pack_im(iatom_mod, mapper.idxu_half, ielem, iatom_div) = 0.; + } + } +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeYi,const int iatom_mod, const int jjz, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int iatom = iatom_mod + iatom_div * vector_length; + if (iatom >= chunk_size) return; + + if (jjz >= my_sna.idxz_max) return; + + my_sna.compute_yi(iatom_mod,jjz,iatom_div,d_beta_pack); +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeZi,const int iatom_mod, const int jjz, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int iatom = iatom_mod + iatom_div * vector_length; + if (iatom >= chunk_size) return; + + if (jjz >= my_sna.idxz_max) return; + + my_sna.compute_zi(iatom_mod,jjz,iatom_div); +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeBi,const int iatom_mod, const int jjb, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int iatom = iatom_mod + iatom_div * vector_length; + if (iatom >= chunk_size) return; + + if (jjb >= my_sna.idxb_max) return; + + my_sna.compute_bi(iatom_mod,jjb,iatom_div); +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPTransformBi,const int iatom_mod, const int idxb, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int iatom = iatom_mod + iatom_div * vector_length; + if (iatom >= chunk_size) return; + + if (idxb >= my_sna.idxb_max) return; + + const int ntriples = my_sna.ntriples; + + for (int itriple = 0; itriple < ntriples; itriple++) { + + const auto blocal = my_sna.blist_pack(iatom_mod, idxb, itriple, iatom_div); + + my_sna.blist(idxb, itriple, iatom) = blocal; + } + +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeFusedDeidrj,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; + + constexpr int team_size = sizeof(real) == 4 ? 4 : 2; + if (team.team_size() != team_size) return; // error + + // extract flattened atom_div / neighbor number / bend location + int flattened_idx = team.team_rank() + team.league_rank() * team_size; + + // extract neighbor index, iatom_div + const int iatom_div = flattened_idx / (max_neighs * (twojmax + 1)); // plug in int_fastdiv + const int jj_jbend = flattened_idx - iatom_div * (max_neighs * (twojmax + 1)); + const int jbend = jj_jbend / max_neighs; + const int jj = jj_jbend - jbend * max_neighs; + + Kokkos::parallel_for(Kokkos::ThreadVectorRange(team, vector_length), + [&] (const int iatom_mod) { + const int ii = iatom_mod + vector_length * iatom_div; + if (ii >= chunk_size) return; + + const int ninside = d_ninside(ii); + if (jj >= ninside) return; + + my_sna.compute_fused_deidrj(team, iatom_mod, jbend, jj, iatom_div); + + }); + +} + +/* ---------------------------------------------------------------------- + Begin routines that are unique to the CPU codepath. These do not take + advantage of AoSoA data layouts, but that could be a good point of + future optimization and unification with the above kernels. It's unlikely + that scratch memory optimizations will ever be useful for the CPU due to + different arithmetic intensity requirements for the CPU vs GPU. +------------------------------------------------------------------------- */ + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPBetaCPU,const int& ii) const { + + const int i = d_ilist[ii + chunk_offset]; + const int itype = type[i]; + const int ielem = d_map[itype]; + SNAKokkos my_sna = snaKK; + + auto d_coeffi = Kokkos::subview(d_coeffelem, ielem, Kokkos::ALL); + + for (int icoeff = 0; icoeff < ncoeff; icoeff++) + d_beta(icoeff,ii) = d_coeffi[icoeff+1]; + + if (quadraticflag) { + const auto idxb_max = my_sna.idxb_max; + int k = ncoeff+1; + for (int icoeff = 0; icoeff < ncoeff; icoeff++) { + const auto idxb = icoeff % idxb_max; + const auto idx_chem = icoeff / idxb_max; + auto bveci = my_sna.blist(idxb,idx_chem,ii); + d_beta(icoeff,ii) += d_coeffi[k]*bveci; + k++; + for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { + const auto jdxb = jcoeff % idxb_max; + const auto jdx_chem = jcoeff / idxb_max; + auto bvecj = my_sna.blist(jdxb,jdx_chem,ii); + d_beta(icoeff,ii) += d_coeffi[k]*bvecj; + d_beta(jcoeff,ii) += d_coeffi[k]*bveci; + k++; + } + } + } +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeNeighCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + int ii = team.league_rank(); const int i = d_ilist[ii + chunk_offset]; - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; const double xtmp = x(i,0); const double ytmp = x(i,1); const double ztmp = x(i,2); @@ -607,20 +983,11 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeNeigh,const typen if ( rsq < rnd_cutsq(itype,jtype) ) { if (final) { -#ifdef LMP_KOKKOS_GPU - if (!host_flag) { - my_sna.compute_cayley_klein(ii, offset, dx, dy, dz, (radi + d_radelem[elem_j])*rcutfac, - d_wjelem[elem_j]); - } else { -#endif - my_sna.rij(ii,offset,0) = dx; - my_sna.rij(ii,offset,1) = dy; - my_sna.rij(ii,offset,2) = dz; - my_sna.wj(ii,offset) = d_wjelem[elem_j]; - my_sna.rcutij(ii,offset) = (radi + d_radelem[elem_j])*rcutfac; -#ifdef LMP_KOKKOS_GPU - } -#endif + my_sna.rij(ii,offset,0) = static_cast(dx); + my_sna.rij(ii,offset,1) = static_cast(dy); + my_sna.rij(ii,offset,2) = static_cast(dz); + my_sna.wj(ii,offset) = static_cast(d_wjelem[elem_j]); + my_sna.rcutij(ii,offset) = static_cast((radi + d_radelem[elem_j])*rcutfac); my_sna.inside(ii,offset) = j; if (chemflag) my_sna.element(ii,offset) = elem_j; @@ -632,282 +999,11 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeNeigh,const typen }); } -/* ---------------------------------------------------------------------- - Begin routines that are unique to the GPU codepath. These take advantage - of AoSoA data layouts and scratch memory for recursive polynomials -------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPBeta,const int& ii) const { - - if (ii >= chunk_size) return; - - const int iatom_mod = ii % 32; - const int iatom_div = ii / 32; - - const int i = d_ilist[ii + chunk_offset]; - const int itype = type[i]; - const int ielem = d_map[itype]; - SNAKokkos my_sna = snaKK; - - Kokkos::View> - d_coeffi(d_coeffelem,ielem,Kokkos::ALL); - - for (int icoeff = 0; icoeff < ncoeff; icoeff++) { - d_beta_pack(iatom_mod,icoeff,iatom_div) = d_coeffi[icoeff+1]; - } - - if (quadraticflag) { - const auto idxb_max = my_sna.idxb_max; - int k = ncoeff+1; - for (int icoeff = 0; icoeff < ncoeff; icoeff++) { - const auto idxb = icoeff % idxb_max; - const auto idx_chem = icoeff / idxb_max; - double bveci = my_sna.blist(idxb, idx_chem, ii); - d_beta_pack(iatom_mod,icoeff,iatom_div) += d_coeffi[k]*bveci; - k++; - for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { - const auto jdxb = jcoeff % idxb_max; - const auto jdx_chem = jcoeff / idxb_max; - double bvecj = my_sna.blist(jdxb, jdx_chem, ii); - d_beta_pack(iatom_mod,icoeff,iatom_div) += d_coeffi[k]*bvecj; - d_beta_pack(iatom_mod,jcoeff,iatom_div) += d_coeffi[k]*bveci; - k++; - } - } - } -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPPreUi,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; - - // Extract the atom number - const int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); - if (ii >= chunk_size) return; - int itype = type(ii); - int ielem = d_map[itype]; - - my_sna.pre_ui(team,ii,ielem); -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeUi,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; - - // Extract the atom number - int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); - if (ii >= chunk_size) return; - - // Extract the neighbor number - const int jj = team.league_rank() / ((chunk_size+team.team_size()-1)/team.team_size()); - const int ninside = d_ninside(ii); - if (jj >= ninside) return; - - my_sna.compute_ui(team,ii,jj); -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformUi,const int iatom_mod, const int j, const int iatom_div) const { - SNAKokkos my_sna = snaKK; - - const int iatom = iatom_mod + iatom_div * 32; - if (iatom >= chunk_size) return; - - if (j > twojmax) return; - - int elem_count = chemflag ? nelements : 1; - - for (int ielem = 0; ielem < elem_count; ielem++) { - const int jju_half = my_sna.idxu_half_block(j); - const int jju = my_sna.idxu_block(j); - - for (int mb = 0; 2*mb <= j; mb++) { - for (int ma = 0; ma <= j; ma++) { - // Extract top half - - const int idxu_shift = mb * (j + 1) + ma; - const int idxu_half = jju_half + idxu_shift; - const int idxu = jju + idxu_shift; - - auto utot_re = my_sna.ulisttot_re(idxu_half, ielem, iatom); - auto utot_im = my_sna.ulisttot_im(idxu_half, ielem, iatom); - - // Store - my_sna.ulisttot_pack(iatom_mod, idxu, ielem, iatom_div) = { utot_re, utot_im }; - - // Also zero yi - my_sna.ylist_pack_re(iatom_mod, idxu_half, ielem, iatom_div) = 0.; - my_sna.ylist_pack_im(iatom_mod, idxu_half, ielem, iatom_div) = 0.; - - // Symmetric term - const int sign_factor = (((ma+mb)%2==0)?1:-1); - const int idxu_flip = jju + (j + 1 - mb) * (j + 1) - (ma + 1); - - if (sign_factor == 1) { - utot_im = -utot_im; - } else { - utot_re = -utot_re; - } - - my_sna.ulisttot_pack(iatom_mod, idxu_flip, ielem, iatom_div) = { utot_re, utot_im }; - - // No need to zero symmetrized ylist - } - } - } -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeYi,const int iatom_mod, const int jjz, const int iatom_div) const { - SNAKokkos my_sna = snaKK; - - const int iatom = iatom_mod + iatom_div * 32; - if (iatom >= chunk_size) return; - - if (jjz >= my_sna.idxz_max) return; - - my_sna.compute_yi(iatom_mod,jjz,iatom_div,d_beta_pack); -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformYi,const int iatom_mod, const int idxu_half, const int iatom_div) const { - SNAKokkos my_sna = snaKK; - - const int iatom = iatom_mod + iatom_div * 32; - if (iatom >= chunk_size) return; - - if (idxu_half >= my_sna.idxu_half_max) return; - - int elem_count = chemflag ? nelements : 1; - for (int ielem = 0; ielem < elem_count; ielem++) { - const auto y_re = my_sna.ylist_pack_re(iatom_mod, idxu_half, ielem, iatom_div); - const auto y_im = my_sna.ylist_pack_im(iatom_mod, idxu_half, ielem, iatom_div); - - my_sna.ylist(idxu_half, ielem, iatom) = { y_re, y_im }; - } - -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeZi,const int iatom_mod, const int jjz, const int iatom_div) const { - SNAKokkos my_sna = snaKK; - - const int iatom = iatom_mod + iatom_div * 32; - if (iatom >= chunk_size) return; - - if (jjz >= my_sna.idxz_max) return; - - my_sna.compute_zi(iatom_mod,jjz,iatom_div); -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeBi,const int iatom_mod, const int jjb, const int iatom_div) const { - SNAKokkos my_sna = snaKK; - - const int iatom = iatom_mod + iatom_div * 32; - if (iatom >= chunk_size) return; - - if (jjb >= my_sna.idxb_max) return; - - my_sna.compute_bi(iatom_mod,jjb,iatom_div); -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformBi,const int iatom_mod, const int idxb, const int iatom_div) const { - SNAKokkos my_sna = snaKK; - - const int iatom = iatom_mod + iatom_div * 32; - if (iatom >= chunk_size) return; - - if (idxb >= my_sna.idxb_max) return; - - const int ntriples = my_sna.ntriples; - - for (int itriple = 0; itriple < ntriples; itriple++) { - - const auto blocal = my_sna.blist_pack(iatom_mod, idxb, itriple, iatom_div); - - my_sna.blist(idxb, itriple, iatom) = blocal; - } - -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeFusedDeidrj,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; - - // Extract the atom number - int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); - if (ii >= chunk_size) return; - - // Extract the neighbor number - const int jj = team.league_rank() / ((chunk_size+team.team_size()-1)/team.team_size()); - const int ninside = d_ninside(ii); - if (jj >= ninside) return; - - my_sna.compute_fused_deidrj(team,ii,jj); -} - -/* ---------------------------------------------------------------------- - Begin routines that are unique to the CPU codepath. These do not take - advantage of AoSoA data layouts, but that could be a good point of - future optimization and unification with the above kernels. It's unlikely - that scratch memory optimizations will ever be useful for the CPU due to - different arithmetic intensity requirements for the CPU vs GPU. -------------------------------------------------------------------------- */ - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPBetaCPU,const int& ii) const { - - const int i = d_ilist[ii + chunk_offset]; - const int itype = type[i]; - const int ielem = d_map[itype]; - SNAKokkos my_sna = snaKK; - - Kokkos::View> - d_coeffi(d_coeffelem,ielem,Kokkos::ALL); - - for (int icoeff = 0; icoeff < ncoeff; icoeff++) - d_beta(icoeff,ii) = d_coeffi[icoeff+1]; - - if (quadraticflag) { - const auto idxb_max = my_sna.idxb_max; - int k = ncoeff+1; - for (int icoeff = 0; icoeff < ncoeff; icoeff++) { - const auto idxb = icoeff % idxb_max; - const auto idx_chem = icoeff / idxb_max; - double bveci = my_sna.blist(idxb,idx_chem,ii); - d_beta(icoeff,ii) += d_coeffi[k]*bveci; - k++; - for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { - const auto jdxb = jcoeff % idxb_max; - const auto jdx_chem = jcoeff / idxb_max; - double bvecj = my_sna.blist(jdxb,jdx_chem,ii); - d_beta(icoeff,ii) += d_coeffi[k]*bvecj; - d_beta(jcoeff,ii) += d_coeffi[k]*bveci; - k++; - } - } - } -} - - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPPreUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPPreUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number const int ii = team.team_rank() + team.team_size() * team.league_rank(); @@ -920,10 +1016,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPPreUiCPU,const typename -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); @@ -937,10 +1033,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeUiCPU,const typen my_sna.compute_ui_cpu(team,ii,jj); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformUiCPU, const int j, const int iatom) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPTransformUiCPU, const int j, const int iatom) const { + SNAKokkos my_sna = snaKK; if (iatom >= chunk_size) return; @@ -987,32 +1083,32 @@ void PairSNAPKokkos::operator() (TagPairSNAPTransformUiCPU, const in } } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeYiCPU,const int& ii) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeYiCPU,const int& ii) const { + SNAKokkos my_sna = snaKK; my_sna.compute_yi_cpu(ii,d_beta); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeZiCPU,const int& ii) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeZiCPU,const int& ii) const { + SNAKokkos my_sna = snaKK; my_sna.compute_zi_cpu(ii); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeBiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeBiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { int ii = team.league_rank(); - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; my_sna.compute_bi_cpu(team,ii); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeDuidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeDuidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); @@ -1026,10 +1122,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeDuidrjCPU,const t my_sna.compute_duidrj_cpu(team,ii,jj); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeDeidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeDeidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); @@ -1049,10 +1145,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeDeidrjCPU,const t likely not worth it. ------------------------------------------------------------------------- */ -template +template template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team, EV_FLOAT& ev) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team, EV_FLOAT& ev) const { // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial @@ -1061,7 +1157,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeForce my_sna = snaKK; + SNAKokkos my_sna = snaKK; const int ninside = d_ninside(ii); Kokkos::parallel_for (Kokkos::TeamThreadRange(team,ninside), @@ -1102,14 +1198,13 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeForce> - d_coeffi(d_coeffelem,ielem,Kokkos::ALL); + auto d_coeffi = Kokkos::subview(d_coeffelem, ielem, Kokkos::ALL); Kokkos::single(Kokkos::PerTeam(team), [&] () { // evdwl = energy of atom I, sum over coeffs_k * Bi_k - double evdwl = d_coeffi[0]; + auto evdwl = d_coeffi[0]; // E = beta.B + 0.5*B^t.alpha.B @@ -1130,13 +1225,13 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeForce::operator() (TagPairSNAPComputeForce +template template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team) const { EV_FLOAT ev; this->template operator()(TagPairSNAPComputeForce(), team, ev); } /* ---------------------------------------------------------------------- */ -template +template template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::v_tally_xyz(EV_FLOAT &ev, const int &i, const int &j, +void PairSNAPKokkos::v_tally_xyz(EV_FLOAT &ev, const int &i, const int &j, const F_FLOAT &fx, const F_FLOAT &fy, const F_FLOAT &fz, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { @@ -1209,24 +1304,24 @@ void PairSNAPKokkos::v_tally_xyz(EV_FLOAT &ev, const int &i, const i memory usage ------------------------------------------------------------------------- */ -template -double PairSNAPKokkos::memory_usage() +template +double PairSNAPKokkos::memory_usage() { double bytes = Pair::memory_usage(); int n = atom->ntypes+1; bytes += n*n*sizeof(int); - bytes += n*n*sizeof(double); - bytes += (2*ncoeffall)*sizeof(double); - bytes += (ncoeff*3)*sizeof(double); + bytes += n*n*sizeof(real); + bytes += (2*ncoeffall)*sizeof(real); + bytes += (ncoeff*3)*sizeof(real); bytes += snaKK.memory_usage(); return bytes; } /* ---------------------------------------------------------------------- */ -template +template template -void PairSNAPKokkos::check_team_size_for(int inum, int &team_size, int vector_length) { +void PairSNAPKokkos::check_team_size_for(int inum, int &team_size) { int team_size_max; team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelForTag()); @@ -1235,9 +1330,9 @@ void PairSNAPKokkos::check_team_size_for(int inum, int &team_size, i team_size = team_size_max/vector_length; } -template +template template -void PairSNAPKokkos::check_team_size_reduce(int inum, int &team_size, int vector_length) { +void PairSNAPKokkos::check_team_size_reduce(int inum, int &team_size) { int team_size_max; team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelReduceTag()); @@ -1246,4 +1341,79 @@ void PairSNAPKokkos::check_team_size_reduce(int inum, int &team_size team_size = team_size_max/vector_length; } + +/* ---------------------------------------------------------------------- + routines used by template reference classes +------------------------------------------------------------------------- */ + +template +PairSNAPKokkosDevice::PairSNAPKokkosDevice(class LAMMPS *lmp) + : PairSNAPKokkos(lmp) { ; } + +template +void PairSNAPKokkosDevice::coeff(int narg, char **arg) +{ + Base::coeff(narg, arg); +} + +template +void PairSNAPKokkosDevice::init_style() +{ + Base::init_style(); +} + +template +double PairSNAPKokkosDevice::init_one(int i, int j) +{ + return Base::init_one(i, j); +} + +template +void PairSNAPKokkosDevice::compute(int eflag_in, int vflag_in) +{ + Base::compute(eflag_in, vflag_in); +} + +template +double PairSNAPKokkosDevice::memory_usage() +{ + return Base::memory_usage(); +} + +#ifdef LMP_KOKKOS_GPU +template +PairSNAPKokkosHost::PairSNAPKokkosHost(class LAMMPS *lmp) + : PairSNAPKokkos(lmp) { ; } + +template +void PairSNAPKokkosHost::coeff(int narg, char **arg) +{ + Base::coeff(narg, arg); +} + +template +void PairSNAPKokkosHost::init_style() +{ + Base::init_style(); +} + +template +double PairSNAPKokkosHost::init_one(int i, int j) +{ + return Base::init_one(i, j); +} + +template +void PairSNAPKokkosHost::compute(int eflag_in, int vflag_in) +{ + Base::compute(eflag_in, vflag_in); +} + +template +double PairSNAPKokkosHost::memory_usage() +{ + return Base::memory_usage(); +} +#endif + } diff --git a/src/KOKKOS/sna_kokkos.h b/src/KOKKOS/sna_kokkos.h index 7804aaef18..d34e9a9e17 100644 --- a/src/KOKKOS/sna_kokkos.h +++ b/src/KOKKOS/sna_kokkos.h @@ -25,45 +25,78 @@ namespace LAMMPS_NS { -template +template +struct WignerWrapper { + using real = real_; + using complex = SNAComplex; + static constexpr int vector_length = vector_length_; + + const int offset; // my offset into the vector (0, ..., vector_length - 1) + real* buffer; // buffer of real numbers + + KOKKOS_INLINE_FUNCTION + WignerWrapper(complex* buffer_, const int offset_) + : offset(offset_), buffer(reinterpret_cast(buffer_)) + { ; } + + KOKKOS_INLINE_FUNCTION + complex get(const int& ma) { + return complex(buffer[offset + 2 * vector_length * ma], buffer[offset + vector_length + 2 * vector_length * ma]); + } + + KOKKOS_INLINE_FUNCTION + void set(const int& ma, const complex& store) { + buffer[offset + 2 * vector_length * ma] = store.re; + buffer[offset + vector_length + 2 * vector_length * ma] = store.im; + } +}; + +struct alignas(8) FullHalfMapper { + int idxu_half; + int flip_sign; // 0 -> isn't flipped, 1 -> conj, -1 -> -conj +}; + +template class SNAKokkos { public: + using real = real_; + using complex = SNAComplex; + static constexpr int vector_length = vector_length_; + typedef Kokkos::View t_sna_1i; - typedef Kokkos::View t_sna_1d; - typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1d_atomic; + typedef Kokkos::View t_sna_1d; + typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1d_atomic; typedef Kokkos::View t_sna_2i; - typedef Kokkos::View t_sna_2d; - typedef Kokkos::View t_sna_2d_ll; - typedef Kokkos::View t_sna_3d; - typedef Kokkos::View t_sna_3d_ll; - typedef Kokkos::View t_sna_4d; - typedef Kokkos::View t_sna_4d_ll; - typedef Kokkos::View t_sna_3d3; - typedef Kokkos::View t_sna_5d; + typedef Kokkos::View t_sna_2d; + typedef Kokkos::View t_sna_2d_ll; + typedef Kokkos::View t_sna_3d; + typedef Kokkos::View t_sna_3d_ll; + typedef Kokkos::View t_sna_4d; + typedef Kokkos::View t_sna_4d_ll; + typedef Kokkos::View t_sna_3d3; + typedef Kokkos::View t_sna_5d; - typedef Kokkos::View t_sna_1c; - typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1c_atomic; - typedef Kokkos::View t_sna_2c; - typedef Kokkos::View t_sna_2c_ll; - typedef Kokkos::View t_sna_2c_lr; - typedef Kokkos::View t_sna_3c; - typedef Kokkos::View t_sna_3c_ll; - typedef Kokkos::View t_sna_4c; - typedef Kokkos::View t_sna_4c3_ll; - typedef Kokkos::View t_sna_4c_ll; - typedef Kokkos::View t_sna_3c3; - typedef Kokkos::View t_sna_5c; - - typedef Kokkos::View t_sna_2ckp; + typedef Kokkos::View t_sna_1c; + typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1c_atomic; + typedef Kokkos::View t_sna_2c; + typedef Kokkos::View t_sna_2c_ll; + typedef Kokkos::View t_sna_2c_lr; + typedef Kokkos::View t_sna_3c; + typedef Kokkos::View t_sna_3c_ll; + typedef Kokkos::View t_sna_4c; + typedef Kokkos::View t_sna_4c3_ll; + typedef Kokkos::View t_sna_4c_ll; + typedef Kokkos::View t_sna_3c3; + typedef Kokkos::View t_sna_5c; inline SNAKokkos() {}; KOKKOS_INLINE_FUNCTION - SNAKokkos(const SNAKokkos& sna, const typename Kokkos::TeamPolicy::member_type& team); + SNAKokkos(const SNAKokkos& sna, const typename Kokkos::TeamPolicy::member_type& team); inline - SNAKokkos(double, int, double, int, int, int, int, int, int); + SNAKokkos(real, int, real, int, int, int, int, int, int); KOKKOS_INLINE_FUNCTION ~SNAKokkos(); @@ -81,17 +114,16 @@ inline // functions for bispectrum coefficients, GPU only KOKKOS_INLINE_FUNCTION - void compute_cayley_klein(const int&, const int&, const double&, const double&, - const double&, const double&, const double&); + void compute_cayley_klein(const int&, const int&, const int&); KOKKOS_INLINE_FUNCTION - void pre_ui(const typename Kokkos::TeamPolicy::member_type& team,const int&,const int&); // ForceSNAP + void pre_ui(const int&, const int&, const int&, const int&); // ForceSNAP KOKKOS_INLINE_FUNCTION - void compute_ui(const typename Kokkos::TeamPolicy::member_type& team, const int, const int); // ForceSNAP + void compute_ui(const typename Kokkos::TeamPolicy::member_type& team, const int, const int, const int, const int); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_zi(const int&, const int&, const int&); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_yi(int,int,int, - const Kokkos::View &beta_pack); // ForceSNAP + const Kokkos::View &beta_pack); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_bi(const int&, const int&, const int&); // ForceSNAP @@ -104,34 +136,33 @@ inline void compute_zi_cpu(const int&); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_yi_cpu(int, - const Kokkos::View &beta); // ForceSNAP + const Kokkos::View &beta); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_bi_cpu(const typename Kokkos::TeamPolicy::member_type& team, int); // ForceSNAP // functions for derivatives, GPU only KOKKOS_INLINE_FUNCTION - void compute_fused_deidrj(const typename Kokkos::TeamPolicy::member_type& team, const int, const int); //ForceSNAP + void compute_fused_deidrj(const typename Kokkos::TeamPolicy::member_type& team, const int, const int, const int, const int); //ForceSNAP // functions for derivatives, CPU only KOKKOS_INLINE_FUNCTION void compute_duidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int); //ForceSNAP KOKKOS_INLINE_FUNCTION void compute_deidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int); // ForceSNAP - KOKKOS_INLINE_FUNCTION - double compute_sfac(double, double); // add_uarraytot, compute_duarray - KOKKOS_INLINE_FUNCTION - double compute_dsfac(double, double); // compute_duarray - KOKKOS_INLINE_FUNCTION - void compute_s_dsfac(const double, const double, double&, double&); // compute_cayley_klein - // efficient complex FMA - // efficient caxpy (i.e., y += a x) - static KOKKOS_FORCEINLINE_FUNCTION - void caxpy(const SNAcomplex& a, const SNAcomplex& x, SNAcomplex& y); + KOKKOS_INLINE_FUNCTION + real compute_sfac(real, real); // add_uarraytot, compute_duarray + + KOKKOS_INLINE_FUNCTION + real compute_dsfac(real, real); // compute_duarray + + KOKKOS_INLINE_FUNCTION + void compute_s_dsfac(const real, const real, real&, real&); // compute_cayley_klein - // efficient complex FMA, conjugate of scalar static KOKKOS_FORCEINLINE_FUNCTION - void caconjxpy(const SNAcomplex& a, const SNAcomplex& x, SNAcomplex& y); + void sincos_wrapper(double x, double* sin_, double *cos_) { sincos(x, sin_, cos_); } + static KOKKOS_FORCEINLINE_FUNCTION + void sincos_wrapper(float x, float* sin_, float *cos_) { sincosf(x, sin_, cos_); } // Set the direction for split ComputeDuidrj KOKKOS_INLINE_FUNCTION @@ -146,10 +177,6 @@ inline //per sna class instance for OMP use - // Alternative to rij, wj, rcutij... - // just calculate everything up front - t_sna_2ckp cayleyklein; - // Per InFlight Particle t_sna_3d rij; t_sna_2i inside; @@ -175,8 +202,14 @@ inline t_sna_4c3_ll dulist; // Modified structures for GPU backend - t_sna_3d_ll ulisttot_re; // split real, - t_sna_3d_ll ulisttot_im; // imag + t_sna_3c_ll a_pack; // Cayley-Klein `a` + t_sna_3c_ll b_pack; // `b` + t_sna_4c_ll da_pack; // `da` + t_sna_4c_ll db_pack; // `db` + t_sna_4d_ll sfac_pack; // sfac, dsfac_{x,y,z} + + t_sna_4d_ll ulisttot_re_pack; // split real, + t_sna_4d_ll ulisttot_im_pack; // imag, AoSoA, flattened t_sna_4c_ll ulisttot_pack; // AoSoA layout t_sna_4c_ll zlist_pack; // AoSoA layout t_sna_4d_ll blist_pack; @@ -191,7 +224,7 @@ inline int ntriples; private: - double rmin0, rfac0; + real rmin0, rfac0; //use indexlist instead of loops, constructor generates these // Same across all SNAKokkos @@ -203,6 +236,7 @@ public: Kokkos::View idxu_block; Kokkos::View idxu_half_block; Kokkos::View idxu_cache_block; + Kokkos::View idxu_full_half; private: Kokkos::View idxz_block; @@ -231,12 +265,12 @@ inline void init_rootpqarray(); // init() KOKKOS_INLINE_FUNCTION - void add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int, int, double, double, double, int); // compute_ui + void add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int, int, const real&, const real&, const real&, int); // compute_ui KOKKOS_INLINE_FUNCTION void compute_uarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int, - double, double, double, - double, double); // compute_ui_cpu + const real&, const real&, const real&, + const real&, const real&); // compute_ui_cpu inline @@ -246,8 +280,8 @@ inline int compute_ncoeff(); // SNAKokkos() KOKKOS_INLINE_FUNCTION void compute_duarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int, - double, double, double, // compute_duidrj_cpu - double, double, double, double, double); + const real&, const real&, const real&, // compute_duidrj_cpu + const real&, const real&, const real&, const real&, const real&); // Sets the style for the switching function // 0 = none @@ -259,11 +293,11 @@ inline int bnorm_flag; // Self-weight - double wself; + real wself; int wselfall_flag; int bzero_flag; // 1 if bzero subtracted from barray - Kokkos::View bzero; // array of B values for isolated atoms + Kokkos::View bzero; // array of B values for isolated atoms // for per-direction dulist calculation, specify the direction. int dir; diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index 3060aa9527..dc5ab2bcb8 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -25,16 +25,16 @@ namespace LAMMPS_NS { static const double MY_PI = 3.14159265358979323846; // pi -template +template inline -SNAKokkos::SNAKokkos(double rfac0_in, - int twojmax_in, double rmin0_in, int switch_flag_in, int bzero_flag_in, +SNAKokkos::SNAKokkos(real rfac0_in, + int twojmax_in, real rmin0_in, int switch_flag_in, int bzero_flag_in, int chem_flag_in, int bnorm_flag_in, int wselfall_flag_in, int nelements_in) { LAMMPS_NS::ExecutionSpace execution_space = ExecutionSpaceFromDevice::space; host_flag = (execution_space == LAMMPS_NS::Host); - wself = 1.0; + wself = static_cast(1.0); rfac0 = rfac0_in; rmin0 = rmin0_in; @@ -63,7 +63,7 @@ SNAKokkos::SNAKokkos(double rfac0_in, cglist = t_sna_1d("SNAKokkos::cglist",idxcg_max); if (bzero_flag) { - bzero = Kokkos::View("sna:bzero",twojmax+1); + bzero = Kokkos::View("sna:bzero",twojmax+1); auto h_bzero = Kokkos::create_mirror_view(bzero); double www = wself*wself*wself; @@ -78,20 +78,20 @@ SNAKokkos::SNAKokkos(double rfac0_in, /* ---------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -SNAKokkos::~SNAKokkos() +SNAKokkos::~SNAKokkos() { } -template +template inline -void SNAKokkos::build_indexlist() +void SNAKokkos::build_indexlist() { // index list for cglist int jdim = twojmax + 1; - idxcg_block = Kokkos::View("SNAKokkos::idxcg_block",jdim,jdim,jdim); + idxcg_block = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxcg_block"),jdim,jdim,jdim); auto h_idxcg_block = Kokkos::create_mirror_view(idxcg_block); int idxcg_count = 0; @@ -109,7 +109,7 @@ void SNAKokkos::build_indexlist() // index list for uarray // need to include both halves - idxu_block = Kokkos::View("SNAKokkos::idxu_block",jdim); + idxu_block = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxu_block"),jdim); auto h_idxu_block = Kokkos::create_mirror_view(idxu_block); int idxu_count = 0; @@ -124,7 +124,7 @@ void SNAKokkos::build_indexlist() Kokkos::deep_copy(idxu_block,h_idxu_block); // index list for half uarray - idxu_half_block = Kokkos::View("SNAKokkos::idxu_half_block",jdim); + idxu_half_block = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxu_half_block"),jdim); auto h_idxu_half_block = Kokkos::create_mirror_view(idxu_half_block); int idxu_half_count = 0; @@ -137,10 +137,35 @@ void SNAKokkos::build_indexlist() idxu_half_max = idxu_half_count; Kokkos::deep_copy(idxu_half_block, h_idxu_half_block); + // mapping between full and half indexing, encoding flipping + idxu_full_half = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxu_full_half"),idxu_max); + auto h_idxu_full_half = Kokkos::create_mirror_view(idxu_full_half); + + idxu_count = 0; + for(int j = 0; j <= twojmax; j++) { + int jju_half = h_idxu_half_block[j]; + for(int mb = 0; mb <= j; mb++) { + for(int ma = 0; ma <= j; ma++) { + FullHalfMapper mapper; + if (2*mb <= j) { + mapper.idxu_half = jju_half + mb * (j + 1) + ma; + mapper.flip_sign = 0; + } else { + mapper.idxu_half = jju_half + (j + 1 - mb) * (j + 1) - (ma + 1); + mapper.flip_sign = (((ma+mb)%2==0)?1:-1); + } + h_idxu_full_half[idxu_count] = mapper; + idxu_count++; + } + } + } + + Kokkos::deep_copy(idxu_full_half, h_idxu_full_half); + // index list for "cache" uarray // this is the GPU scratch memory requirements // applied the CPU structures - idxu_cache_block = Kokkos::View("SNAKokkos::idxu_cache_block",jdim); + idxu_cache_block = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxu_cache_block"),jdim); auto h_idxu_cache_block = Kokkos::create_mirror_view(idxu_cache_block); int idxu_cache_count = 0; @@ -162,7 +187,7 @@ void SNAKokkos::build_indexlist() if (j >= j1) idxb_count++; idxb_max = idxb_count; - idxb = Kokkos::View("SNAKokkos::idxb",idxb_max); + idxb = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxb"),idxb_max); auto h_idxb = Kokkos::create_mirror_view(idxb); idxb_count = 0; @@ -179,7 +204,7 @@ void SNAKokkos::build_indexlist() // reverse index list for beta and b - idxb_block = Kokkos::View("SNAKokkos::idxb_block",jdim,jdim,jdim); + idxb_block = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxb_block"),jdim,jdim,jdim); auto h_idxb_block = Kokkos::create_mirror_view(idxb_block); idxb_count = 0; @@ -205,10 +230,10 @@ void SNAKokkos::build_indexlist() idxz_count++; idxz_max = idxz_count; - idxz = Kokkos::View("SNAKokkos::idxz",idxz_max); + idxz = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxz"),idxz_max); auto h_idxz = Kokkos::create_mirror_view(idxz); - idxz_block = Kokkos::View("SNAKokkos::idxz_block", jdim,jdim,jdim); + idxz_block = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxz_block"), jdim,jdim,jdim); auto h_idxz_block = Kokkos::create_mirror_view(idxz_block); idxz_count = 0; @@ -249,53 +274,63 @@ void SNAKokkos::build_indexlist() /* ---------------------------------------------------------------------- */ -template +template inline -void SNAKokkos::init() +void SNAKokkos::init() { init_clebsch_gordan(); init_rootpqarray(); } -template +template inline -void SNAKokkos::grow_rij(int newnatom, int newnmax) +void SNAKokkos::grow_rij(int newnatom, int newnmax) { if(newnatom <= natom && newnmax <= nmax) return; natom = newnatom; nmax = newnmax; + int natom_div = (natom + vector_length - 1) / vector_length; + + rij = t_sna_3d(Kokkos::NoInit("sna:rij"),natom,nmax,3); + wj = t_sna_2d(Kokkos::NoInit("sna:wj"),natom,nmax); + rcutij = t_sna_2d(Kokkos::NoInit("sna:rcutij"),natom,nmax); inside = t_sna_2i(Kokkos::NoInit("sna:inside"),natom,nmax); - element = t_sna_2i(Kokkos::NoInit("sna:rcutij"),natom,nmax); + element = t_sna_2i(Kokkos::NoInit("sna:element"),natom,nmax); dedr = t_sna_3d(Kokkos::NoInit("sna:dedr"),natom,nmax,3); #ifdef LMP_KOKKOS_GPU if (!host_flag) { - - cayleyklein = t_sna_2ckp(Kokkos::NoInit("sna:cayleyklein"), natom, nmax); + a_pack = t_sna_3c_ll(Kokkos::NoInit("sna:a_pack"),vector_length,nmax,natom_div); + b_pack = t_sna_3c_ll(Kokkos::NoInit("sna:b_pack"),vector_length,nmax,natom_div); + da_pack = t_sna_4c_ll(Kokkos::NoInit("sna:da_pack"),vector_length,nmax,natom_div,3); + db_pack = t_sna_4c_ll(Kokkos::NoInit("sna:db_pack"),vector_length,nmax,natom_div,3); + sfac_pack = t_sna_4d_ll(Kokkos::NoInit("sna:sfac_pack"),vector_length,nmax,natom_div,4); ulisttot = t_sna_3c_ll(Kokkos::NoInit("sna:ulisttot"),1,1,1); // dummy allocation ulisttot_full = t_sna_3c_ll(Kokkos::NoInit("sna:ulisttot"),1,1,1); - ulisttot_re = t_sna_3d_ll(Kokkos::NoInit("sna:ulisttot_re"),idxu_half_max,nelements,natom); - ulisttot_im = t_sna_3d_ll(Kokkos::NoInit("sna:ulisttot_im"),idxu_half_max,nelements,natom); - ulisttot_pack = t_sna_4c_ll(Kokkos::NoInit("sna:ulisttot_pack"),32,idxu_max,nelements,(natom+32-1)/32); + ulisttot_re_pack = t_sna_4d_ll(Kokkos::NoInit("sna:ulisttot_re_pack"),vector_length,idxu_half_max,nelements,natom_div); + ulisttot_im_pack = t_sna_4d_ll(Kokkos::NoInit("sna:ulisttot_im_pack"),vector_length,idxu_half_max,nelements,natom_div); + ulisttot_pack = t_sna_4c_ll(Kokkos::NoInit("sna:ulisttot_pack"),vector_length,idxu_max,nelements,natom_div); ulist = t_sna_3c_ll(Kokkos::NoInit("sna:ulist"),1,1,1); zlist = t_sna_3c_ll(Kokkos::NoInit("sna:zlist"),1,1,1); - zlist_pack = t_sna_4c_ll(Kokkos::NoInit("sna:zlist_pack"),32,idxz_max,ndoubles,(natom+32-1)/32); + zlist_pack = t_sna_4c_ll(Kokkos::NoInit("sna:zlist_pack"),vector_length,idxz_max,ndoubles,natom_div); blist = t_sna_3d_ll(Kokkos::NoInit("sna:blist"),idxb_max,ntriples,natom); - blist_pack = t_sna_4d_ll(Kokkos::NoInit("sna:blist_pack"),32,idxb_max,ntriples,(natom+32-1)/32); - ylist = t_sna_3c_ll(Kokkos::NoInit("sna:ylist"),idxu_half_max,nelements,natom); - ylist_pack_re = t_sna_4d_ll(Kokkos::NoInit("sna:ylist_pack_re"),32,idxu_half_max,nelements,(natom+32-1)/32); - ylist_pack_im = t_sna_4d_ll(Kokkos::NoInit("sna:ylist_pack_im"),32,idxu_half_max,nelements,(natom+32-1)/32); + blist_pack = t_sna_4d_ll(Kokkos::NoInit("sna:blist_pack"),vector_length,idxb_max,ntriples,natom_div); + ylist = t_sna_3c_ll(Kokkos::NoInit("sna:ylist"),1,1,1); + ylist_pack_re = t_sna_4d_ll(Kokkos::NoInit("sna:ylist_pack_re"),vector_length,idxu_half_max,nelements,natom_div); + ylist_pack_im = t_sna_4d_ll(Kokkos::NoInit("sna:ylist_pack_im"),vector_length,idxu_half_max,nelements,natom_div); dulist = t_sna_4c3_ll(Kokkos::NoInit("sna:dulist"),1,1,1); } else { #endif - rij = t_sna_3d(Kokkos::NoInit("sna:rij"),natom,nmax,3); - wj = t_sna_2d(Kokkos::NoInit("sna:wj"),natom,nmax); - rcutij = t_sna_2d(Kokkos::NoInit("sna:rcutij"),natom,nmax); + a_pack = t_sna_3c_ll(Kokkos::NoInit("sna:a_pack"),1,1,1); + b_pack = t_sna_3c_ll(Kokkos::NoInit("sna:b_pack"),1,1,1); + da_pack = t_sna_4c_ll(Kokkos::NoInit("sna:da_pack"),1,1,1,1); + db_pack = t_sna_4c_ll(Kokkos::NoInit("sna:db_pack"),1,1,1,1); + sfac_pack = t_sna_4d_ll(Kokkos::NoInit("sna:sfac_pack"),1,1,1,1); ulisttot = t_sna_3c_ll(Kokkos::NoInit("sna:ulisttot"),idxu_half_max,nelements,natom); ulisttot_full = t_sna_3c_ll(Kokkos::NoInit("sna:ulisttot_full"),idxu_max,nelements,natom); - ulisttot_re = t_sna_3d_ll(Kokkos::NoInit("sna:ulisttot_re"),1,1,1); - ulisttot_im = t_sna_3d_ll(Kokkos::NoInit("sna:ulisttot_im"),1,1,1); + ulisttot_re_pack = t_sna_4d_ll(Kokkos::NoInit("sna:ulisttot_re"),1,1,1,1); + ulisttot_im_pack = t_sna_4d_ll(Kokkos::NoInit("sna:ulisttot_im"),1,1,1,1); ulisttot_pack = t_sna_4c_ll(Kokkos::NoInit("sna:ulisttot_pack"),1,1,1,1); ulist = t_sna_3c_ll(Kokkos::NoInit("sna:ulist"),idxu_cache_max,natom,nmax); zlist = t_sna_3c_ll(Kokkos::NoInit("sna:zlist"),idxz_max,ndoubles,natom); @@ -323,81 +358,85 @@ void SNAKokkos::grow_rij(int newnatom, int newnmax) ComputeFusedDeidrj, which are one warp per atom-neighbor pair. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_cayley_klein(const int& iatom, const int& jnbor, const double& x, const double& y, - const double& z, const double& rcut, const double& wj_local) +void SNAKokkos::compute_cayley_klein(const int& iatom_mod, const int& jnbor, const int& iatom_div) { - //const double x = rij(iatom,jnbor,0); - //const double y = rij(iatom,jnbor,1); - //const double z = rij(iatom,jnbor,2); - const double rsq = x * x + y * y + z * z; - const double r = sqrt(rsq); - //const double rcut = rcutij(iatom, jnbor); - const double rscale0 = rfac0 * MY_PI / (rcut - rmin0); - const double theta0 = (r - rmin0) * rscale0; - double sn, cs; - sincos(theta0, &sn, &cs); - const double z0 = r * cs / sn; - const double dz0dr = z0 / r - (r*rscale0) * (rsq + z0 * z0) / rsq; + const int iatom = iatom_mod + vector_length * iatom_div; + const auto x = rij(iatom,jnbor,0); + const auto y = rij(iatom,jnbor,1); + const auto z = rij(iatom,jnbor,2); + const auto rsq = x * x + y * y + z * z; + const auto r = sqrt(rsq); + const auto rcut = rcutij(iatom, jnbor); + const auto rscale0 = rfac0 * static_cast(MY_PI) / (rcut - rmin0); + const auto theta0 = (r - rmin0) * rscale0; + real sn, cs; + sincos_wrapper(theta0, &sn, &cs); + const real z0 = r * cs / sn; + const real dz0dr = z0 / r - (r*rscale0) * (rsq + z0 * z0) / rsq; - //const double wj_local = wj(iatom, jnbor); - double sfac, dsfac; + const auto wj_local = wj(iatom, jnbor); + real sfac, dsfac; compute_s_dsfac(r, rcut, sfac, dsfac); sfac *= wj_local; dsfac *= wj_local; - const double rinv = 1.0 / r; - const double ux = x * rinv; - const double uy = y * rinv; - const double uz = z * rinv; + const auto rinv = static_cast(1.0) / r; + const auto ux = x * rinv; + const auto uy = y * rinv; + const auto uz = z * rinv; - const double r0inv = 1.0 / sqrt(r * r + z0 * z0); + const auto r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); - const SNAcomplex a = { z0 * r0inv, -z * r0inv }; - const SNAcomplex b = { r0inv * y, -r0inv * x }; + const complex a = { z0 * r0inv, -z * r0inv }; + const complex b = { r0inv * y, -r0inv * x }; - const double dr0invdr = -r0inv * r0inv * r0inv * (r + z0 * dz0dr); + const auto dr0invdr = -r0inv * r0inv * r0inv * (r + z0 * dz0dr); - const double dr0invx = dr0invdr * ux; - const double dr0invy = dr0invdr * uy; - const double dr0invz = dr0invdr * uz; + const auto dr0invx = dr0invdr * ux; + const auto dr0invy = dr0invdr * uy; + const auto dr0invz = dr0invdr * uz; - const double dz0x = dz0dr * ux; - const double dz0y = dz0dr * uy; - const double dz0z = dz0dr * uz; + const auto dz0x = dz0dr * ux; + const auto dz0y = dz0dr * uy; + const auto dz0z = dz0dr * uz; - const SNAcomplex dax = { dz0x * r0inv + z0 * dr0invx, -z * dr0invx }; - const SNAcomplex day = { dz0y * r0inv + z0 * dr0invy, -z * dr0invy }; - const SNAcomplex daz = { dz0z * r0inv + z0 * dr0invz, -z * dr0invz - r0inv }; + const complex dax = { dz0x * r0inv + z0 * dr0invx, -z * dr0invx }; + const complex day = { dz0y * r0inv + z0 * dr0invy, -z * dr0invy }; + const complex daz = { dz0z * r0inv + z0 * dr0invz, -z * dr0invz - r0inv }; - const SNAcomplex dbx = { y * dr0invx, -x * dr0invx - r0inv }; - const SNAcomplex dby = { y * dr0invy + r0inv, -x * dr0invy }; - const SNAcomplex dbz = { y * dr0invz, -x * dr0invz }; + const complex dbx = { y * dr0invx, -x * dr0invx - r0inv }; + const complex dby = { y * dr0invy + r0inv, -x * dr0invy }; + const complex dbz = { y * dr0invz, -x * dr0invz }; - const double dsfacux = dsfac * ux; - const double dsfacuy = dsfac * uy; - const double dsfacuz = dsfac * uz; + const auto dsfacux = dsfac * ux; + const auto dsfacuy = dsfac * uy; + const auto dsfacuz = dsfac * uz; - CayleyKleinPack ckp{}; - ckp.a = a; - ckp.b = b; - ckp.da[0] = dax; - ckp.db[0] = dbx; - ckp.da[1] = day; - ckp.db[1] = dby; - ckp.da[2] = daz; - ckp.db[2] = dbz; - ckp.sfac = sfac; - ckp.dsfacu[0] = dsfacux; - ckp.dsfacu[1] = dsfacuy; - ckp.dsfacu[2] = dsfacuz; + a_pack(iatom_mod,jnbor,iatom_div) = a; + b_pack(iatom_mod,jnbor,iatom_div) = b; + + da_pack(iatom_mod,jnbor,iatom_div,0) = dax; + db_pack(iatom_mod,jnbor,iatom_div,0) = dbx; + + da_pack(iatom_mod,jnbor,iatom_div,1) = day; + db_pack(iatom_mod,jnbor,iatom_div,1) = dby; + + da_pack(iatom_mod,jnbor,iatom_div,2) = daz; + db_pack(iatom_mod,jnbor,iatom_div,2) = dbz; + + sfac_pack(iatom_mod,jnbor,iatom_div,0) = sfac; + sfac_pack(iatom_mod,jnbor,iatom_div,1) = dsfacux; + sfac_pack(iatom_mod,jnbor,iatom_div,2) = dsfacuy; + sfac_pack(iatom_mod,jnbor,iatom_div,3) = dsfacuz; + + // we need to explicitly zero `dedr` somewhere before hitting + // ComputeFusedDeidrj --- this is just a convenient place to do it. + dedr(iatom_mod + vector_length * iatom_div, jnbor, 0) = static_cast(0.); + dedr(iatom_mod + vector_length * iatom_div, jnbor, 1) = static_cast(0.); + dedr(iatom_mod + vector_length * iatom_div, jnbor, 2) = static_cast(0.); - // Yes, this breaks the standard mantra of using SoA - // instead of AoS, but it's net fine because of the - // one warp per atom/neighbor pair for the recursive - // polynomials. There's good L1 reuse, anyway. - cayleyklein(iatom, jnbor) = ckp; } /* ---------------------------------------------------------------------- @@ -406,30 +445,28 @@ void SNAKokkos::compute_cayley_klein(const int& iatom, const int& jn advantage of the symmetry of the Wigner U matrices. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::pre_ui(const typename Kokkos::TeamPolicy::member_type& team, const int& iatom, const int& ielem) +void SNAKokkos::pre_ui(const int& iatom_mod, const int& j, const int& ielem, const int& iatom_div) { + for (int jelem = 0; jelem < nelements; jelem++) { - for (int j = 0; j <= twojmax; j++) { - const int jju_half = idxu_half_block(j); + int jju_half = idxu_half_block(j); - // Only diagonal elements get initialized - // Top half only: gets symmetrized by TransformUi - // for (int m = 0; m < (j+1)*(j/2+1); m++) - Kokkos::parallel_for(Kokkos::ThreadVectorRange(team, (j+1)*(j/2+1)), - [&] (const int m) { + // Only diagonal elements get initialized + // Top half only: gets symmetrized by TransformUi - const int jjup = jju_half + m; + for (int mb = 0; 2*mb <= j; mb++) { + for (int ma = 0; ma <= j; ma++) { - // if m is on the "diagonal", initialize it with the self energy. - // Otherwise zero it out - double re_part = 0.; - if (m % (j+2) == 0 && (!chem_flag || ielem == jelem || wselfall_flag)) { re_part = wself; } + real re_part = static_cast(0.); + if (ma == mb && (!chem_flag || ielem == jelem || wselfall_flag)) { re_part = wself; } - ulisttot_re(jjup, jelem, iatom) = re_part; - ulisttot_im(jjup, jelem, iatom) = 0.; - }); + ulisttot_re_pack(iatom_mod, jju_half, jelem, iatom_div) = re_part; + ulisttot_im_pack(iatom_mod, jju_half, jelem, iatom_div) = static_cast(0.); + + jju_half++; + } } } @@ -440,9 +477,9 @@ void SNAKokkos::pre_ui(const typename Kokkos::TeamPolicy accumulating to the total. GPU only. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_ui(const typename Kokkos::TeamPolicy::member_type& team, const int iatom, const int jnbor) +void SNAKokkos::compute_ui(const typename Kokkos::TeamPolicy::member_type& team, const int iatom_mod, const int j_bend, const int jnbor, const int iatom_div) { // utot(j,ma,mb) = 0 for all j,ma,ma @@ -452,119 +489,122 @@ void SNAKokkos::compute_ui(const typename Kokkos::TeamPolicy ulist_wrapper((complex*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); - // Each warp is accessing the same pack: take advantage of - // L1 reuse - const CayleyKleinPack& ckp = cayleyklein(iatom, jnbor); - const SNAcomplex a = ckp.a; - const SNAcomplex b = ckp.b; - const double sfac = ckp.sfac; + // load parameters + const auto a = a_pack(iatom_mod, jnbor, iatom_div); + const auto b = b_pack(iatom_mod, jnbor, iatom_div); + const auto sfac = sfac_pack(iatom_mod, jnbor, iatom_div, 0); - const int jelem = element(iatom, jnbor); + const int jelem = element(iatom_mod + vector_length * iatom_div, jnbor); - // VMK Section 4.8.2 + // we need to "choose" when to bend + // this for loop is here for context --- we expose additional + // parallelism over this loop instead + //for (int j_bend = 0; j_bend <= twojmax; j_bend++) { - // All writes go to global memory and shared memory - // so we can avoid all global memory reads - Kokkos::single(Kokkos::PerThread(team), [=]() { - buf1[0] = {1.,0.}; - Kokkos::atomic_add(&(ulisttot_re(0,jelem,iatom)), sfac); - }); + // level 0 is just 1. + ulist_wrapper.set(0, complex::one()); - for (int j = 1; j <= twojmax; j++) { + // j from before the bend, don't store, mb == 0 + // this is "creeping up the side" + for (int j = 1; j <= j_bend; j++) { - const int jju = idxu_half_block[j]; + int jjup = idxu_half_block[j-1]; - // fill in left side of matrix layer from previous layer + constexpr int mb = 0; // intentional for readability, compiler should optimize this out - // Flatten loop over ma, mb - // for (int ma = 0; ma <= j; ma++) - const int n_ma = j+1; - // for (int mb = 0; 2*mb <= j; mb++) - const int n_mb = j/2+1; + complex ulist_accum = complex::zero(); - const int total_iters = n_ma * n_mb; + int ma; + for (ma = 0; ma < j; ma++) { + const int jjup_index = idxu_half_block[j - 1] + mb * j + ma; - //for (int m = 0; m < total_iters; m++) { - Kokkos::parallel_for(Kokkos::ThreadVectorRange(team, total_iters), - [&] (const int m) { + // grab the cached value + const complex ulist_prev = ulist_wrapper.get(ma); - // ma fast, mb slow - // Equivalent to `int ma = m % n_ma; int mb = m / n_ma;` IF everything's positive. - const int mb = m / n_ma; - const int ma = m - mb * n_ma; + // ulist_accum += rootpq * a.conj() * ulist_prev; + real rootpq = rootpqarray(j - ma, j - mb); + ulist_accum.re += rootpq * (a.re * ulist_prev.re + a.im * ulist_prev.im); + ulist_accum.im += rootpq * (a.re * ulist_prev.im - a.im * ulist_prev.re); - // index into global memory array - const int jju_index = jju+m; + // store ulist_accum, we atomic accumulate values after the bend, so no atomic add here + ulist_wrapper.set(ma, ulist_accum); - // index into shared memory buffer for this level - const int jju_shared_idx = m; + // next value + // ulist_accum = -rootpq * b.conj() * ulist_prev; + rootpq = rootpqarray(ma + 1, j - mb); + ulist_accum.re = -rootpq * (b.re * ulist_prev.re + b.im * ulist_prev.im); + ulist_accum.im = -rootpq * (b.re * ulist_prev.im - b.im * ulist_prev.re); - // index into shared memory buffer for next level - const int jjup_shared_idx = jju_shared_idx - mb; - - SNAcomplex u_accum = {0., 0.}; - - // VMK recursion relation: grab contribution which is multiplied by b* - const double rootpq2 = -rootpqarray(ma, j - mb); - const SNAcomplex u_up2 = rootpq2*((ma > 0)?buf1[jjup_shared_idx-1]:SNAcomplex(0.,0.)); - - // u_accum += conj(b) * u_up2 - caconjxpy(b, u_up2, u_accum); - - // VMK recursion relation: grab contribution which is multiplied by a* - const double rootpq1 = rootpqarray(j - ma, j - mb); - const SNAcomplex u_up1 = rootpq1*((ma < j)?buf1[jjup_shared_idx]:SNAcomplex(0.,0.)); - - // u_accum += conj(a) * u_up1 - caconjxpy(a, u_up1, u_accum); - - // back up into shared memory for next iter - buf2[jju_shared_idx] = u_accum; - - Kokkos::atomic_add(&(ulisttot_re(jju_index,jelem,iatom)), sfac * u_accum.re); - Kokkos::atomic_add(&(ulisttot_im(jju_index,jelem,iatom)), sfac * u_accum.im); - - // copy left side to right side with inversion symmetry VMK 4.4(2) - // u[ma-j,mb-j] = (-1)^(ma-mb)*Conj([u[ma,mb)) - // if j is even (-> physical j integer), last element maps to self, skip - - const int sign_factor = (((ma+mb)%2==0)?1:-1); - const int jju_shared_flip = (j+1-mb)*(j+1)-(ma+1); - - if (sign_factor == 1) { - u_accum.im = -u_accum.im; - } else { - u_accum.re = -u_accum.re; } - if (j%2==1 && mb+1==n_mb) { - buf2[jju_shared_flip] = u_accum; + ulist_wrapper.set(ma, ulist_accum); + } + + // now we're after the bend, start storing but only up to the "half way point" + const int j_half_way = MIN(2 * j_bend, twojmax); + + int mb = 1; + int j; //= j_bend + 1; // need this value below + for (j = j_bend + 1; j <= j_half_way; j++) { + + const int jjup = idxu_half_block[j-1] + (mb - 1) * j; + + complex ulist_accum = complex::zero(); + + int ma; + for (ma = 0; ma < j; ma++) { + + // grab the cached value + const complex ulist_prev = ulist_wrapper.get(ma); + + // atomic add the previous level here + Kokkos::atomic_add(&(ulisttot_re_pack(iatom_mod, jjup + ma, jelem, iatom_div)), ulist_prev.re * sfac); + Kokkos::atomic_add(&(ulisttot_im_pack(iatom_mod, jjup + ma, jelem, iatom_div)), ulist_prev.im * sfac); + + // ulist_accum += rootpq * b * ulist_prev; + real rootpq = rootpqarray(j - ma, mb); + ulist_accum.re += rootpq * (b.re * ulist_prev.re - b.im * ulist_prev.im); + ulist_accum.im += rootpq * (b.re * ulist_prev.im + b.im * ulist_prev.re); + + // store ulist_accum + ulist_wrapper.set(ma, ulist_accum); + + // next value + // ulist_accum = rootpq * a * ulist_prev; + rootpq = rootpqarray(ma + 1, mb); + ulist_accum.re = rootpq * (a.re * ulist_prev.re - a.im * ulist_prev.im); + ulist_accum.im = rootpq * (a.re * ulist_prev.im + a.im * ulist_prev.re); } - // symmetric part of ulisttot is generated in TransformUi + ulist_wrapper.set(ma, ulist_accum); - }); - // In CUDA backend, - // ThreadVectorRange has a __syncwarp (appropriately masked for - // vector lengths < 32) implict at the end + mb++; + } - // swap double buffers - auto tmp = buf1; buf1 = buf2; buf2 = tmp; + // atomic add the last level + const int jjup = idxu_half_block[j-1] + (mb - 1) * j; + + for (int ma = 0; ma < j; ma++) { + const complex ulist_prev = ulist_wrapper.get(ma); + + // atomic add the previous level here + Kokkos::atomic_add(&(ulisttot_re_pack(iatom_mod, jjup + ma, jelem, iatom_div)), ulist_prev.re * sfac); + Kokkos::atomic_add(&(ulisttot_im_pack(iatom_mod, jjup + ma, jelem, iatom_div)), ulist_prev.im * sfac); + } + + //} // end of "reference" loop over j_bend - } } @@ -574,9 +614,9 @@ void SNAKokkos::compute_ui(const typename Kokkos::TeamPolicy +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, const int& iatom_div) +void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, const int& iatom_div) { const int j1 = idxz(jjz, 0); @@ -589,14 +629,13 @@ void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, con const int na = idxz(jjz, 7); const int nb = idxz(jjz, 8); - const double* cgblock = cglist.data() + idxcg_block(j1, j2, j); + const real* cgblock = cglist.data() + idxcg_block(j1, j2, j); int idouble = 0; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - double ztmp_r = 0.; - double ztmp_i = 0.; + complex ztmp = complex::zero(); int jju1 = idxu_block[j1] + (j1+1)*mb1min; int jju2 = idxu_block[j2] + (j2+1)*mb2max; @@ -615,12 +654,12 @@ void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, con #pragma unroll #endif for(int ia = 0; ia < na; ia++) { - const SNAcomplex utot1 = ulisttot_pack(iatom_mod, jju1+ma1, elem1, iatom_div); - const SNAcomplex utot2 = ulisttot_pack(iatom_mod, jju2+ma2, elem2, iatom_div); + const auto utot1 = ulisttot_pack(iatom_mod, jju1+ma1, elem1, iatom_div); + const auto utot2 = ulisttot_pack(iatom_mod, jju2+ma2, elem2, iatom_div); const auto cgcoeff_a = cgblock[icga]; const auto cgcoeff_b = cgblock[icgb]; - ztmp_r += cgcoeff_a * cgcoeff_b * (utot1.re * utot2.re - utot1.im * utot2.im); - ztmp_i += cgcoeff_a * cgcoeff_b * (utot1.re * utot2.im + utot1.im * utot2.re); + ztmp.re += cgcoeff_a * cgcoeff_b * (utot1.re * utot2.re - utot1.im * utot2.im); + ztmp.im += cgcoeff_a * cgcoeff_b * (utot1.re * utot2.im + utot1.im * utot2.re); ma1++; ma2--; icga += j2; @@ -632,11 +671,11 @@ void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, con } // end loop over ib if (bnorm_flag) { - ztmp_r /= (j + 1); - ztmp_i /= (j + 1); + ztmp.re /= (j + 1); + ztmp.im /= (j + 1); } - zlist_pack(iatom_mod,jjz,idouble,iatom_div) = { ztmp_r, ztmp_i }; + zlist_pack(iatom_mod,jjz,idouble,iatom_div) = ztmp; idouble++; } @@ -649,9 +688,9 @@ void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, con divergence. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_bi(const int& iatom_mod, const int& jjb, const int& iatom_div) +void SNAKokkos::compute_bi(const int& iatom_mod, const int& jjb, const int& iatom_div) { // for j1 = 0,...,twojmax // for j2 = 0,twojmax @@ -712,10 +751,10 @@ void SNAKokkos::compute_bi(const int& iatom_mod, const int& jjb, con const auto utot = ulisttot_pack(iatom_mod, jju_index, elem3, iatom_div); const auto zloc = zlist_pack(iatom_mod, jjz_index, idouble, iatom_div); - sumzu += 0.5 * (utot.re * zloc.re + utot.im * zloc.im); + sumzu += static_cast(0.5) * (utot.re * zloc.re + utot.im * zloc.im); } // end if jeven - sumzu *= 2.0; + sumzu *= static_cast(2.0); if (bzero_flag) { if (!wselfall_flag) { if (elem1 == elem2 && elem1 == elem3) { @@ -742,12 +781,12 @@ void SNAKokkos::compute_bi(const int& iatom_mod, const int& jjb, con divergence. GPU version. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, - const Kokkos::View &beta_pack) +void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, + const Kokkos::View &beta_pack) { - double betaj; + real betaj; const int j1 = idxz(jjz, 0); const int j2 = idxz(jjz, 1); @@ -760,15 +799,15 @@ void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, const int nb = idxz(jjz, 8); const int jju_half = idxz(jjz, 9); - const double *cgblock = cglist.data() + idxcg_block(j1,j2,j); + const real *cgblock = cglist.data() + idxcg_block(j1,j2,j); //int mb = (2 * (mb1min+mb2max) - j1 - j2 + j) / 2; //int ma = (2 * (ma1min+ma2max) - j1 - j2 + j) / 2; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - double ztmp_r = 0.0; - double ztmp_i = 0.0; + real ztmp_r = 0.0; + real ztmp_i = 0.0; int jju1 = idxu_block[j1] + (j1 + 1) * mb1min; int jju2 = idxu_block[j2] + (j2 + 1) * mb2max; @@ -787,8 +826,8 @@ void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, #pragma unroll #endif for (int ia = 0; ia < na; ia++) { - const SNAcomplex utot1 = ulisttot_pack(iatom_mod,jju1+ma1,elem1,iatom_div); - const SNAcomplex utot2 = ulisttot_pack(iatom_mod,jju2+ma2,elem2,iatom_div); + const auto utot1 = ulisttot_pack(iatom_mod,jju1+ma1,elem1,iatom_div); + const auto utot2 = ulisttot_pack(iatom_mod,jju2+ma2,elem2,iatom_div); const auto cgcoeff_a = cgblock[icga]; const auto cgcoeff_b = cgblock[icgb]; ztmp_r += cgcoeff_a * cgcoeff_b * (utot1.re * utot2.re - utot1.im * utot2.im); @@ -849,169 +888,173 @@ void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, and accumulation into dEidRj. GPU only. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_fused_deidrj(const typename Kokkos::TeamPolicy::member_type& team, const int iatom, const int jnbor) +void SNAKokkos::compute_fused_deidrj(const typename Kokkos::TeamPolicy::member_type& team, const int iatom_mod, const int j_bend, const int jnbor, const int iatom_div) { // get shared memory offset - const int max_m_tile = (twojmax+1)*(twojmax/2+1); + // scratch size: 32 atoms * (twojmax+1) cached values, no double buffer + const int tile_size = vector_length * (twojmax + 1); + const int team_rank = team.team_rank(); - const int scratch_shift = team_rank * max_m_tile; - const int jelem = element(iatom, jnbor); + const int scratch_shift = team_rank * tile_size; - // See notes on data layouts for shared memory caching - // in `compute_ui`. + // extract, wrap shared memory buffer + WignerWrapper ulist_wrapper((complex*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper dulist_wrapper((complex*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); - // double buffer for ulist - SNAcomplex* ulist_buf1 = (SNAcomplex*)team.team_shmem( ).get_shmem(team.team_size()*max_m_tile*sizeof(SNAcomplex), 0) + scratch_shift; - SNAcomplex* ulist_buf2 = (SNAcomplex*)team.team_shmem( ).get_shmem(team.team_size()*max_m_tile*sizeof(SNAcomplex), 0) + scratch_shift; + // load parameters + const auto a = a_pack(iatom_mod, jnbor, iatom_div); + const auto b = b_pack(iatom_mod, jnbor, iatom_div); + const auto da = da_pack(iatom_mod, jnbor, iatom_div, dir); + const auto db = db_pack(iatom_mod, jnbor, iatom_div, dir); + const auto sfac = sfac_pack(iatom_mod, jnbor, iatom_div, 0); + const auto dsfacu = sfac_pack(iatom_mod, jnbor, iatom_div, dir + 1); // dsfac * u - // double buffer for dulist - SNAcomplex* dulist_buf1 = (SNAcomplex*)team.team_shmem( ).get_shmem(team.team_size()*max_m_tile*sizeof(SNAcomplex), 0) + scratch_shift; - SNAcomplex* dulist_buf2 = (SNAcomplex*)team.team_shmem( ).get_shmem(team.team_size()*max_m_tile*sizeof(SNAcomplex), 0) + scratch_shift; + const int jelem = element(iatom_mod + vector_length * iatom_div, jnbor); - const CayleyKleinPack& ckp = cayleyklein(iatom, jnbor); + auto dedr_full_sum = static_cast(0.); - const SNAcomplex a = ckp.a; - const SNAcomplex b = ckp.b; - const SNAcomplex da = ckp.da[dir]; - const SNAcomplex db = ckp.db[dir]; - const double sfac = ckp.sfac; - const double dsfacu = ckp.dsfacu[dir]; // dsfac * u + // we need to "choose" when to bend + // this for loop is here for context --- we expose additional + // parallelism over this loop instead + //for (int j_bend = 0; j_bend <= twojmax; j_bend++) { - // Accumulate the full contribution to dedr on the fly - const SNAcomplex y_local = ylist(0, jelem, iatom); + // level 0 is just 1, 0 + ulist_wrapper.set(0, complex::one()); + dulist_wrapper.set(0, complex::zero()); - // Symmetry factor of 0.5 b/c 0 element is on diagonal for even j==0 - double dedr_full_sum = 0.5 * dsfacu * y_local.re; + // j from before the bend, don't store, mb == 0 + // this is "creeping up the side" + for (int j = 1; j <= j_bend; j++) { - // single has a warp barrier at the end - Kokkos::single(Kokkos::PerThread(team), [=]() { + int jjup = idxu_half_block[j-1]; - ulist_buf1[0] = {1., 0.}; - dulist_buf1[0] = {0., 0.}; - }); + constexpr int mb = 0; // intentional for readability, compiler should optimize this out - for (int j = 1; j <= twojmax; j++) { - int jju_half = idxu_half_block[j]; + complex ulist_accum = complex::zero(); + complex dulist_accum = complex::zero(); - // flatten the loop over ma,mb + int ma; + for (ma = 0; ma < j; ma++) { + const int jjup_index = idxu_half_block[j - 1] + mb * j + ma; - // for (int ma = 0; ma <= j; ma++) - const int n_ma = j+1; - // for (int mb = 0; 2*mb <= j; mb++) - const int n_mb = j/2+1; + // grab the cached value + const complex ulist_prev = ulist_wrapper.get(ma); + const complex dulist_prev = dulist_wrapper.get(ma); - const int total_iters = n_ma * n_mb; + // ulist_accum += rootpq * a.conj() * ulist_prev; + real rootpq = rootpqarray(j - ma, j - mb); + ulist_accum.re += rootpq * (a.re * ulist_prev.re + a.im * ulist_prev.im); + ulist_accum.im += rootpq * (a.re * ulist_prev.im - a.im * ulist_prev.re); - double dedr_sum = 0.; // j-local sum + // product rule of above + dulist_accum.re += rootpq * (da.re * ulist_prev.re + da.im * ulist_prev.im + a.re * dulist_prev.re + a.im * dulist_prev.im); + dulist_accum.im += rootpq * (da.re * ulist_prev.im - da.im * ulist_prev.re + a.re * dulist_prev.im - a.im * dulist_prev.re); - //for (int m = 0; m < total_iters; m++) { - Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team, total_iters), - [&] (const int m, double& sum_tmp) { + // store ulist_accum, we atomic accumulate values after the bend, so no atomic add here + ulist_wrapper.set(ma, ulist_accum); + dulist_wrapper.set(ma, dulist_accum); - // ma fast, mb slow - const int mb = m / n_ma; - const int ma = m - mb * n_ma; + // next value + // ulist_accum = -rootpq * b.conj() * ulist_prev; + rootpq = rootpqarray(ma + 1, j - mb); + ulist_accum.re = -rootpq * (b.re * ulist_prev.re + b.im * ulist_prev.im); + ulist_accum.im = -rootpq * (b.re * ulist_prev.im - b.im * ulist_prev.re); - const int jju_half_index = jju_half+m; + // product rule of above + dulist_accum.re = -rootpq * (db.re * ulist_prev.re + db.im * ulist_prev.im + b.re * dulist_prev.re + b.im * dulist_prev.im); + dulist_accum.im = -rootpq * (db.re * ulist_prev.im - db.im * ulist_prev.re + b.re * dulist_prev.im - b.im * dulist_prev.re); - // Load y_local, apply the symmetry scaling factor - // The "secret" of the shared memory optimization is it eliminates - // all global memory reads to duidrj in lieu of caching values in - // shared memory and otherwise always writing, making the kernel - // ultimately compute bound. We take advantage of that by adding - // some reads back in. - auto y_local = ylist(jju_half_index, jelem, iatom); - if (j % 2 == 0 && 2*mb == j) { - if (ma == mb) { y_local = 0.5*y_local; } - else if (ma > mb) { y_local = { 0., 0. }; } // can probably avoid this outright + } + + ulist_wrapper.set(ma, ulist_accum); + dulist_wrapper.set(ma, dulist_accum); + } + + // now we're after the bend, start storing but only up to the "half way point" + const int j_half_way = MIN(2 * j_bend, twojmax); + + int mb = 1; + int j; //= j_bend + 1; // need this value below + for (j = j_bend + 1; j <= j_half_way; j++) { + + const int jjup = idxu_half_block[j-1] + (mb - 1) * j; + + complex ulist_accum = complex::zero(); + complex dulist_accum = complex::zero(); + + int ma; + for (ma = 0; ma < j; ma++) { + + // grab y_local early + // this will never be the last element of a row, no need to rescale. + auto y_local = complex(ylist_pack_re(iatom_mod, jjup + ma, jelem, iatom_div), ylist_pack_im(iatom_mod, jjup+ma, jelem, iatom_div)); + + // grab the cached value + const complex ulist_prev = ulist_wrapper.get(ma); + const complex dulist_prev = dulist_wrapper.get(ma); + + // ulist_accum += rootpq * b * ulist_prev; + real rootpq = rootpqarray(j - ma, mb); + ulist_accum.re += rootpq * (b.re * ulist_prev.re - b.im * ulist_prev.im); + ulist_accum.im += rootpq * (b.re * ulist_prev.im + b.im * ulist_prev.re); + + // product rule of above + dulist_accum.re += rootpq * (db.re * ulist_prev.re - db.im * ulist_prev.im + b.re * dulist_prev.re - b.im * dulist_prev.im); + dulist_accum.im += rootpq * (db.re * ulist_prev.im + db.im * ulist_prev.re + b.re * dulist_prev.im + b.im * dulist_prev.re); + + // store ulist_accum + ulist_wrapper.set(ma, ulist_accum); + dulist_wrapper.set(ma, dulist_accum); + + // Directly accumulate deidrj into sum_tmp + const complex du_prod = (dsfacu * ulist_prev) + (sfac * dulist_prev); + dedr_full_sum += du_prod.re * y_local.re + du_prod.im * y_local.im; + + // next value + // ulist_accum = rootpq * a * ulist_prev; + rootpq = rootpqarray(ma + 1, mb); + ulist_accum.re = rootpq * (a.re * ulist_prev.re - a.im * ulist_prev.im); + ulist_accum.im = rootpq * (a.re * ulist_prev.im + a.im * ulist_prev.re); + + // product rule of above + dulist_accum.re = rootpq * (da.re * ulist_prev.re - da.im * ulist_prev.im + a.re * dulist_prev.re - a.im * dulist_prev.im); + dulist_accum.im = rootpq * (da.re * ulist_prev.im + da.im * ulist_prev.re + a.re * dulist_prev.im + a.im * dulist_prev.re); + + } + + ulist_wrapper.set(ma, ulist_accum); + dulist_wrapper.set(ma, dulist_accum); + + mb++; + } + + // accumulate the last level + const int jjup = idxu_half_block[j-1] + (mb - 1) * j; + + for (int ma = 0; ma < j; ma++) { + // grab y_local early + auto y_local = complex(ylist_pack_re(iatom_mod, jjup + ma, jelem, iatom_div), ylist_pack_im(iatom_mod, jjup+ma, jelem, iatom_div)); + if (j % 2 == 1 && 2*(mb-1) == j-1) { // double check me... + if (ma == (mb-1)) { y_local = static_cast(0.5)*y_local; } + else if (ma > (mb-1)) { y_local.re = static_cast(0.); y_local.im = static_cast(0.); } // can probably avoid this outright // else the ma < mb gets "double counted", cancelling the 0.5. } - // index into shared memory - const int jju_shared_idx = m; - const int jjup_shared_idx = jju_shared_idx - mb; - - // Need to compute and accumulate both u and du (mayhaps, we could probably - // balance some read and compute by reading u each time). - SNAcomplex u_accum = { 0., 0. }; - SNAcomplex du_accum = { 0., 0. }; - - const double rootpq2 = -rootpqarray(ma, j - mb); - const SNAcomplex u_up2 = rootpq2*((ma > 0) ? ulist_buf1[jjup_shared_idx-1]:SNAcomplex(0.,0.)); - - // u_accum += conj(b) * u_up2 - caconjxpy(b, u_up2, u_accum); - - const double rootpq1 = rootpqarray(j - ma, j - mb); - const SNAcomplex u_up1 = rootpq1*((ma < j) ? ulist_buf1[jjup_shared_idx]:SNAcomplex(0.,0.)); - - // u_accum += conj(a) * u_up1 - caconjxpy(a, u_up1, u_accum); - - // Next, spin up du_accum - const SNAcomplex du_up1 = rootpq1*((ma < j) ? dulist_buf1[jjup_shared_idx] : SNAcomplex(0.,0.)); - - // du_accum += conj(da) * u_up1 + conj(a) * du_up1 - caconjxpy(da, u_up1, du_accum); - caconjxpy(a, du_up1, du_accum); - - const SNAcomplex du_up2 = rootpq2*((ma > 0) ? dulist_buf1[jjup_shared_idx-1] : SNAcomplex(0.,0.)); - - // du_accum += conj(db) * u_up2 + conj(b) * du_up2 - caconjxpy(db, u_up2, du_accum); - caconjxpy(b, du_up2, du_accum); - - // Cache u_accum, du_accum to scratch memory. - ulist_buf2[jju_shared_idx] = u_accum; - dulist_buf2[jju_shared_idx] = du_accum; + const complex ulist_prev = ulist_wrapper.get(ma); + const complex dulist_prev = dulist_wrapper.get(ma); // Directly accumulate deidrj into sum_tmp - const SNAcomplex du_prod = (dsfacu * u_accum) + (sfac * du_accum); - sum_tmp += du_prod.re * y_local.re + du_prod.im * y_local.im; + const complex du_prod = (dsfacu * ulist_prev) + (sfac * dulist_prev); + dedr_full_sum += du_prod.re * y_local.re + du_prod.im * y_local.im; - // copy left side to right side with inversion symmetry VMK 4.4(2) - // u[ma-j][mb-j] = (-1)^(ma-mb)*Conj([u[ma][mb]) - if (j%2==1 && mb+1==n_mb) { - int sign_factor = (((ma+mb)%2==0)?1:-1); + } + //} // end reference loop over j_bend - const int jju_shared_flip = (j+1-mb)*(j+1)-(ma+1); + // dedr gets zeroed out at the start of each iteration in compute_cayley_klein + Kokkos::atomic_add(&(dedr(iatom_mod + vector_length * iatom_div, jnbor, dir)), static_cast(2.0) * dedr_full_sum); - if (sign_factor == 1) { - u_accum.im = -u_accum.im; - du_accum.im = -du_accum.im; - } else { - u_accum.re = -u_accum.re; - du_accum.re = -du_accum.re; - } - - // We don't need the second half of the tile for the deidrj accumulation. - // That's taken care of by the symmetry factor above. - // We do need it for ortho polynomial generation, though - ulist_buf2[jju_shared_flip] = u_accum; - dulist_buf2[jju_shared_flip] = du_accum; - } - - }, dedr_sum); - - // swap buffers - auto tmp = ulist_buf1; ulist_buf1 = ulist_buf2; ulist_buf2 = tmp; - tmp = dulist_buf1; dulist_buf1 = dulist_buf2; dulist_buf2 = tmp; - - // Accumulate dedr. This "should" be in a single, but - // a Kokkos::single call implies a warp sync, and we may - // as well avoid that. This does no harm as long as the - // final assignment is in a single block. - //Kokkos::single(Kokkos::PerThread(team), [=]() { - dedr_full_sum += dedr_sum; - //}); - } - - // Store the accumulated dedr. - Kokkos::single(Kokkos::PerThread(team), [&] () { - dedr(iatom,jnbor,dir) = dedr_full_sum*2.0; - }); } @@ -1025,9 +1068,9 @@ void SNAKokkos::compute_fused_deidrj(const typename Kokkos::TeamPoli advantage of the symmetry of the Wigner U matrices. * ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::pre_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, const int& iatom, const int& ielem) +void SNAKokkos::pre_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, const int& iatom, const int& ielem) { for (int jelem = 0; jelem < nelements; jelem++) { for (int j = 0; j <= twojmax; j++) { @@ -1042,8 +1085,8 @@ void SNAKokkos::pre_ui_cpu(const typename Kokkos::TeamPolicy(0.),static_cast(0.)); + if (m % (j+2) == 0 && (!chem_flag || ielem == jelem || wselfall_flag)) { init.re = wself; } //need to map iatom to element ulisttot(jjup, jelem, iatom) = init; }); @@ -1059,11 +1102,11 @@ void SNAKokkos::pre_ui_cpu(const typename Kokkos::TeamPolicy +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) +void SNAKokkos::compute_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) { - double rsq, r, x, y, z, z0, theta0; + real rsq, r, x, y, z, z0, theta0; // utot(j,ma,mb) = 0 for all j,ma,ma // utot(j,ma,ma) = 1 for all j,ma @@ -1089,9 +1132,9 @@ void SNAKokkos::compute_ui_cpu(const typename Kokkos::TeamPolicy +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_zi_cpu(const int& iter) +void SNAKokkos::compute_zi_cpu(const int& iter) { const int iatom = iter / idxz_max; const int jjz = iter % idxz_max; @@ -1106,22 +1149,22 @@ void SNAKokkos::compute_zi_cpu(const int& iter) const int na = idxz(jjz, 7); const int nb = idxz(jjz, 8); - const double *cgblock = cglist.data() + idxcg_block(j1,j2,j); + const real *cgblock = cglist.data() + idxcg_block(j1,j2,j); int idouble = 0; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - zlist(jjz, idouble, iatom).re = 0.0; - zlist(jjz, idouble, iatom).im = 0.0; + zlist(jjz, idouble, iatom).re = static_cast(0.0); + zlist(jjz, idouble, iatom).im = static_cast(0.0); int jju1 = idxu_block[j1] + (j1+1)*mb1min; int jju2 = idxu_block[j2] + (j2+1)*mb2max; int icgb = mb1min*(j2+1) + mb2max; for(int ib = 0; ib < nb; ib++) { - double suma1_r = 0.0; - double suma1_i = 0.0; + real suma1_r = static_cast(0.0); + real suma1_i = static_cast(0.0); int ma1 = ma1min; int ma2 = ma2max; @@ -1158,9 +1201,9 @@ void SNAKokkos::compute_zi_cpu(const int& iter) compute Bi by summing conj(Ui)*Zi, CPU version ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom) +void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom) { // for j1 = 0,...,twojmax // for j2 = 0,twojmax @@ -1186,11 +1229,11 @@ void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy(0.0); + real sumzu_temp = static_cast(0.0); const int bound = (j+2)/2; Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,(j+1)*bound), - [&] (const int mbma, double& sum) { + [&] (const int mbma, real& sum) { //for(int mb = 0; 2*mb < j; mb++) //for(int ma = 0; ma <= j; ma++) { const int ma = mbma % (j + 1); @@ -1209,7 +1252,7 @@ void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy::compute_bi_cpu(const typename Kokkos::TeamPolicy(0.5)* (ulisttot_full(jju_index, elem3, iatom).re * zlist(jjz_index, jalloy, iatom).re + ulisttot_full(jju_index, elem3, iatom).im * zlist(jjz_index, jalloy, iatom).im); } // end if jeven Kokkos::single(Kokkos::PerThread(team), [&] () { - sumzu *= 2.0; + sumzu *= static_cast(2.0); // apply bzero shift @@ -1260,12 +1303,12 @@ void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_yi_cpu(int iter, - const Kokkos::View &beta) +void SNAKokkos::compute_yi_cpu(int iter, + const Kokkos::View &beta) { - double betaj; + real betaj; const int iatom = iter / idxz_max; const int jjz = iter % idxz_max; @@ -1280,15 +1323,15 @@ void SNAKokkos::compute_yi_cpu(int iter, const int nb = idxz(jjz, 8); const int jju_half = idxz(jjz, 9); - const double *cgblock = cglist.data() + idxcg_block(j1,j2,j); + const real *cgblock = cglist.data() + idxcg_block(j1,j2,j); //int mb = (2 * (mb1min+mb2max) - j1 - j2 + j) / 2; //int ma = (2 * (ma1min+ma2max) - j1 - j2 + j) / 2; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - double ztmp_r = 0.0; - double ztmp_i = 0.0; + real ztmp_r = 0.0; + real ztmp_i = 0.0; int jju1 = idxu_block[j1] + (j1 + 1) * mb1min; int jju2 = idxu_block[j2] + (j2 + 1) * mb2max; @@ -1296,8 +1339,8 @@ void SNAKokkos::compute_yi_cpu(int iter, for (int ib = 0; ib < nb; ib++) { - double suma1_r = 0.0; - double suma1_i = 0.0; + real suma1_r = 0.0; + real suma1_i = 0.0; int ma1 = ma1min; int ma2 = ma2max; @@ -1368,22 +1411,21 @@ void SNAKokkos::compute_yi_cpu(int iter, data layout ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_duidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) +void SNAKokkos::compute_duidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) { - double rsq, r, x, y, z, z0, theta0, cs, sn; - double dz0dr; + real rsq, r, x, y, z, z0, theta0, cs, sn; + real dz0dr; x = rij(iatom,jnbor,0); y = rij(iatom,jnbor,1); z = rij(iatom,jnbor,2); rsq = x * x + y * y + z * z; r = sqrt(rsq); - double rscale0 = rfac0 * MY_PI / (rcutij(iatom,jnbor) - rmin0); + auto rscale0 = rfac0 * static_cast(MY_PI) / (rcutij(iatom,jnbor) - rmin0); theta0 = (r - rmin0) * rscale0; - cs = cos(theta0); - sn = sin(theta0); + sincos_wrapper(theta0, &sn, &cs); z0 = r * cs / sn; dz0dr = z0 / r - (r*rscale0) * (rsq + z0 * z0) / rsq; @@ -1400,16 +1442,16 @@ void SNAKokkos::compute_duidrj_cpu(const typename Kokkos::TeamPolicy ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_deidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) +void SNAKokkos::compute_deidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) { - t_scalar3 final_sum; + t_scalar3 final_sum; const int jelem = element(iatom, jnbor); //for(int j = 0; j <= twojmax; j++) { Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,twojmax+1), - [&] (const int& j, t_scalar3& sum_tmp) { + [&] (const int& j, t_scalar3& sum_tmp) { int jju_half = idxu_half_block[j]; int jju_cache = idxu_cache_block[j]; @@ -1467,12 +1509,12 @@ void SNAKokkos::compute_deidrj_cpu(const typename Kokkos::TeamPolicy of the symmetry of the Wigner U matrices. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, - double r, double wj, double rcut, int jelem) +void SNAKokkos::add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, + const real& r, const real& wj, const real& rcut, int jelem) { - const double sfac = compute_sfac(r, rcut) * wj; + const auto sfac = compute_sfac(r, rcut) * wj; Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,twojmax+1), [&] (const int& j) { @@ -1497,19 +1539,18 @@ void SNAKokkos::add_uarraytot(const typename Kokkos::TeamPolicy +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_uarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, - double x, double y, double z, - double z0, double r) +void SNAKokkos::compute_uarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, + const real& x, const real& y, const real& z, const real& z0, const real& r) { - double r0inv; - double a_r, b_r, a_i, b_i; - double rootpq; + real r0inv; + real a_r, b_r, a_i, b_i; + real rootpq; // compute Cayley-Klein parameters for unit quaternion - r0inv = 1.0 / sqrt(r * r + z0 * z0); + r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); a_r = r0inv * z0; a_i = -r0inv * z; b_r = r0inv * y; @@ -1589,23 +1630,23 @@ void SNAKokkos::compute_uarray_cpu(const typename Kokkos::TeamPolicy Uses same cached data layout of ulist ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_duarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, - double x, double y, double z, - double z0, double r, double dz0dr, - double wj, double rcut) +void SNAKokkos::compute_duarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, + const real& x, const real& y, const real& z, + const real& z0, const real& r, const real& dz0dr, + const real& wj, const real& rcut) { -double r0inv; - double a_r, a_i, b_r, b_i; - double da_r[3], da_i[3], db_r[3], db_i[3]; - double dz0[3], dr0inv[3], dr0invdr; - double rootpq; + real r0inv; + real a_r, a_i, b_r, b_i; + real da_r[3], da_i[3], db_r[3], db_i[3]; + real dz0[3], dr0inv[3], dr0invdr; + real rootpq; - double rinv = 1.0 / r; - double ux = x * rinv; - double uy = y * rinv; - double uz = z * rinv; + real rinv = 1.0 / r; + real ux = x * rinv; + real uy = y * rinv; + real uz = z * rinv; r0inv = 1.0 / sqrt(r * r + z0 * z0); a_r = z0 * r0inv; @@ -1720,8 +1761,8 @@ double r0inv; }); } - double sfac = compute_sfac(r, rcut); - double dsfac = compute_dsfac(r, rcut); + real sfac = compute_sfac(r, rcut); + real dsfac = compute_dsfac(r, rcut); sfac *= wj; dsfac *= wj; @@ -1755,9 +1796,9 @@ double r0inv; factorial n, wrapper for precomputed table ------------------------------------------------------------------------- */ -template +template inline -double SNAKokkos::factorial(int n) +double SNAKokkos::factorial(int n) { //if (n < 0 || n > nmaxfactorial) { // char str[128]; @@ -1772,8 +1813,8 @@ double SNAKokkos::factorial(int n) factorial n table, size SNA::nmaxfactorial+1 ------------------------------------------------------------------------- */ -template -const double SNAKokkos::nfac_table[] = { +template +const double SNAKokkos::nfac_table[] = { 1, 1, 2, @@ -1948,9 +1989,9 @@ const double SNAKokkos::nfac_table[] = { the function delta given by VMK Eq. 8.2(1) ------------------------------------------------------------------------- */ -template +template inline -double SNAKokkos::deltacg(int j1, int j2, int j) +double SNAKokkos::deltacg(int j1, int j2, int j) { double sfaccg = factorial((j1 + j2 + j) / 2 + 1); return sqrt(factorial((j1 + j2 - j) / 2) * @@ -1963,9 +2004,9 @@ double SNAKokkos::deltacg(int j1, int j2, int j) the quasi-binomial formula VMK 8.2.1(3) ------------------------------------------------------------------------- */ -template +template inline -void SNAKokkos::init_clebsch_gordan() +void SNAKokkos::init_clebsch_gordan() { auto h_cglist = Kokkos::create_mirror_view(cglist); @@ -2033,23 +2074,23 @@ void SNAKokkos::init_clebsch_gordan() the p = 0, q = 0 entries are allocated and skipped for convenience. ------------------------------------------------------------------------- */ -template +template inline -void SNAKokkos::init_rootpqarray() +void SNAKokkos::init_rootpqarray() { auto h_rootpqarray = Kokkos::create_mirror_view(rootpqarray); for (int p = 1; p <= twojmax; p++) for (int q = 1; q <= twojmax; q++) - h_rootpqarray(p,q) = sqrt(static_cast(p)/q); + h_rootpqarray(p,q) = static_cast(sqrt(static_cast(p)/q)); Kokkos::deep_copy(rootpqarray,h_rootpqarray); } /* ---------------------------------------------------------------------- */ -template +template inline -int SNAKokkos::compute_ncoeff() +int SNAKokkos::compute_ncoeff() { int ncount; @@ -2070,88 +2111,72 @@ int SNAKokkos::compute_ncoeff() /* ---------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -double SNAKokkos::compute_sfac(double r, double rcut) +real SNAKokkos::compute_sfac(real r, real rcut) { - if (switch_flag == 0) return 1.0; + constexpr real one = static_cast(1.0); + constexpr real zero = static_cast(0.0); + constexpr real onehalf = static_cast(0.5); + if (switch_flag == 0) return one; if (switch_flag == 1) { - if(r <= rmin0) return 1.0; - else if(r > rcut) return 0.0; + if(r <= rmin0) return one; + else if(r > rcut) return zero; else { - double rcutfac = MY_PI / (rcut - rmin0); - return 0.5 * (cos((r - rmin0) * rcutfac) + 1.0); + auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); + return onehalf * (cos((r - rmin0) * rcutfac) + one); } } - return 0.0; + return zero; } /* ---------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -double SNAKokkos::compute_dsfac(double r, double rcut) +real SNAKokkos::compute_dsfac(real r, real rcut) { - if (switch_flag == 0) return 0.0; + constexpr real zero = static_cast(0.0); + constexpr real onehalf = static_cast(0.5); + if (switch_flag == 0) return zero; if (switch_flag == 1) { - if(r <= rmin0) return 0.0; - else if(r > rcut) return 0.0; + if(r <= rmin0) return zero; + else if(r > rcut) return zero; else { - double rcutfac = MY_PI / (rcut - rmin0); - return -0.5 * sin((r - rmin0) * rcutfac) * rcutfac; + auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); + return -onehalf * sin((r - rmin0) * rcutfac) * rcutfac; } } - return 0.0; + return zero; } -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_s_dsfac(const double r, const double rcut, double& sfac, double& dsfac) { - if (switch_flag == 0) { sfac = 0.; dsfac = 0.; } +void SNAKokkos::compute_s_dsfac(const real r, const real rcut, real& sfac, real& dsfac) { + constexpr real one = static_cast(1.0); + constexpr real zero = static_cast(0.0); + constexpr real onehalf = static_cast(0.5); + if (switch_flag == 0) { sfac = zero; dsfac = zero; } else if (switch_flag == 1) { - if (r <= rmin0) { sfac = 1.0; dsfac = 0.0; } - else if (r > rcut) { sfac = 0.; dsfac = 0.; } + if (r <= rmin0) { sfac = one; dsfac = zero; } + else if (r > rcut) { sfac = zero; dsfac = zero; } else { - const double rcutfac = MY_PI / (rcut - rmin0); - double sn, cs; - sincos((r - rmin0) * rcutfac, &sn, &cs); - sfac = 0.5 * (cs + 1.0); - dsfac = -0.5 * sn * rcutfac; + const auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); + real sn, cs; + sincos_wrapper((r - rmin0) * rcutfac, &sn, &cs); // need to create a wrapper + sfac = onehalf * (cs + one); + dsfac = -onehalf * sn * rcutfac; } - } else { sfac = 0.; dsfac = 0.; } -} - -/* ---------------------------------------------------------------------- */ - -// efficient complex FMA (i.e., y += a x) -template -KOKKOS_FORCEINLINE_FUNCTION -void SNAKokkos::caxpy(const SNAcomplex& a, const SNAcomplex& x, SNAcomplex& y) { - y.re += a.re * x.re; - y.re -= a.im * x.im; - y.im += a.im * x.re; - y.im += a.re * x.im; -} - -/* ---------------------------------------------------------------------- */ - -// efficient complex FMA, conjugate of scalar (i.e.) y += (a.re - i a.im) x) -template -KOKKOS_FORCEINLINE_FUNCTION -void SNAKokkos::caconjxpy(const SNAcomplex& a, const SNAcomplex& x, SNAcomplex& y) { - y.re += a.re * x.re; - y.re += a.im * x.im; - y.im -= a.im * x.re; - y.im += a.re * x.im; + } else { sfac = zero; dsfac = zero; } } /* ---------------------------------------------------------------------- */ // set direction of batched Duidrj -template +template KOKKOS_FORCEINLINE_FUNCTION -void SNAKokkos::set_dir(int dir_) { +void SNAKokkos::set_dir(int dir_) { dir = dir_; } @@ -2159,8 +2184,8 @@ void SNAKokkos::set_dir(int dir_) { memory usage of arrays ------------------------------------------------------------------------- */ -template -double SNAKokkos::memory_usage() +template +double SNAKokkos::memory_usage() { int jdimpq = twojmax + 2; int jdim = twojmax + 1; @@ -2168,45 +2193,53 @@ double SNAKokkos::memory_usage() bytes = 0; - bytes += jdimpq*jdimpq * sizeof(double); // pqarray - bytes += idxcg_max * sizeof(double); // cglist + bytes += jdimpq*jdimpq * sizeof(real); // pqarray + bytes += idxcg_max * sizeof(real); // cglist #ifdef LMP_KOKKOS_GPU if (!host_flag) { - auto natom_pad = (natom+32-1)/32; + auto natom_pad = (natom+vector_length-1)/vector_length; - bytes += natom * idxu_half_max * nelements * sizeof(double); // ulisttot_re - bytes += natom * idxu_half_max * nelements * sizeof(double); // ulisttot_im - bytes += natom_pad * idxu_max * nelements * sizeof(double) * 2; // ulisttot_pack + bytes += natom_pad * nmax * sizeof(real) * 2; // a_pack + bytes += natom_pad * nmax * sizeof(real) * 2; // b_pack + bytes += natom_pad * nmax * 3 * sizeof(real) * 2; // da_pack + bytes += natom_pad * nmax * 3 * sizeof(real) * 2; // db_pack + bytes += natom_pad * nmax * 4 * sizeof(real); // sfac_pack - bytes += natom_pad * idxz_max * ndoubles * sizeof(double) * 2; // zlist_pack - bytes += natom_pad * idxb_max * ntriples * sizeof(double); // blist_pack - bytes += natom_pad * idxu_half_max * nelements * sizeof(double); // ylist_pack_re - bytes += natom_pad * idxu_half_max * nelements * sizeof(double); // ylist_pack_im - bytes += natom * idxu_half_max * nelements * sizeof(double) * 2; // ylist + bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ulisttot_re_pack + bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ulisttot_im_pack + bytes += natom_pad * idxu_max * nelements * sizeof(real) * 2; // ulisttot_pack + + bytes += natom_pad * idxz_max * ndoubles * sizeof(real) * 2; // zlist_pack + bytes += natom_pad * idxb_max * ntriples * sizeof(real); // blist_pack + + bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ylist_pack_re + bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ylist_pack_im } else { #endif - bytes += natom * nmax * idxu_cache_max * sizeof(double) * 2; // ulist - bytes += natom * idxu_half_max * nelements * sizeof(double) * 2; // ulisttot + bytes += natom * nmax * idxu_cache_max * sizeof(real) * 2; // ulist + bytes += natom * idxu_half_max * nelements * sizeof(real) * 2; // ulisttot + bytes += natom * idxu_max * nelements * sizeof(real) * 2; // ulisttot_full - bytes += natom * idxz_max * ndoubles * sizeof(double) * 2; // zlist - bytes += natom * idxb_max * ntriples * sizeof(double); // blist + bytes += natom * idxz_max * ndoubles * sizeof(real) * 2; // zlist + bytes += natom * idxb_max * ntriples * sizeof(real); // blist - bytes += natom * idxu_half_max * nelements * sizeof(double) * 2; // ylist + bytes += natom * idxu_half_max * nelements * sizeof(real) * 2; // ylist - bytes += natom * nmax * idxu_cache_max * 3 * sizeof(double) * 2; // dulist + bytes += natom * nmax * idxu_cache_max * 3 * sizeof(real) * 2; // dulist #ifdef LMP_KOKKOS_GPU } #endif - bytes += natom * nmax * 3 * sizeof(double); // dedr + bytes += natom * nmax * 3 * sizeof(real); // dedr bytes += jdim * jdim * jdim * sizeof(int); // idxcg_block bytes += jdim * sizeof(int); // idxu_block bytes += jdim * sizeof(int); // idxu_half_block + bytes += idxu_max * sizeof(FullHalfMapper); // idxu_full_half bytes += jdim * sizeof(int); // idxu_cache_block bytes += jdim * jdim * jdim * sizeof(int); // idxz_block bytes += jdim * jdim * jdim * sizeof(int); // idxb_block @@ -2214,12 +2247,12 @@ double SNAKokkos::memory_usage() bytes += idxz_max * 10 * sizeof(int); // idxz bytes += idxb_max * 3 * sizeof(int); // idxb - bytes += jdim * sizeof(double); // bzero + bytes += jdim * sizeof(real); // bzero - bytes += natom * nmax * 3 * sizeof(double); // rij - bytes += natom * nmax * sizeof(int); // inside - bytes += natom * nmax * sizeof(double); // wj - bytes += natom * nmax * sizeof(double); // rcutij + bytes += natom * nmax * 3 * sizeof(real); // rij + bytes += natom * nmax * sizeof(real); // inside + bytes += natom * nmax * sizeof(real); // wj + bytes += natom * nmax * sizeof(real); // rcutij return bytes; } From bc0b963f98e27c81bd0aedadf87a0de84882bc11 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 29 Dec 2020 20:25:42 -0500 Subject: [PATCH 26/51] remove extra empty line --- doc/src/Build_package.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/src/Build_package.rst b/doc/src/Build_package.rst index 63312d7aa8..f9fc52f8db 100644 --- a/doc/src/Build_package.rst +++ b/doc/src/Build_package.rst @@ -1,5 +1,4 @@ Include packages in build - ========================= In LAMMPS, a package is a group of files that enable a specific set of From 0e83e792d038e34ec26df96601bbb43150112c0c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 29 Dec 2020 20:31:00 -0500 Subject: [PATCH 27/51] add false positives --- doc/utils/sphinx-config/false_positives.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 0dff97459a..200b66bcc1 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -1919,6 +1919,7 @@ mK mkdir mkv mliap +mliappy mlparks Mniszewski mnt @@ -2509,6 +2510,7 @@ Pstart Pstop pstyle Ptarget +pth pthread pthreads ptm @@ -2537,6 +2539,7 @@ pymodule pymol pypar pythonic +pytorch Pyy pz Pz From eef28b58abb68ee0f37630a76bb71a60141e6b69 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Dec 2020 08:55:32 -0500 Subject: [PATCH 28/51] remove extra word --- doc/src/fix_ave_correlate.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/fix_ave_correlate.rst b/doc/src/fix_ave_correlate.rst index 386b16ff9a..58aff114af 100644 --- a/doc/src/fix_ave_correlate.rst +++ b/doc/src/fix_ave_correlate.rst @@ -93,7 +93,7 @@ from a compute, fix, or variable, then see the :doc:`fix ave/chunk ` commands. If you wish to convert a per-atom quantity into a single global value, see the :doc:`compute reduce ` command. -The input values must either be all scalars. What kinds of +The input values must be all scalars. What kinds of correlations between input values are calculated is determined by the *type* keyword as discussed below. From 382ade15fed87947aa17010498e272a64f84ea7d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Dec 2020 09:01:37 -0500 Subject: [PATCH 29/51] more consistent formatting of for/while loops and if statements --- src/COLLOID/pair_brownian.cpp | 18 +- src/COLLOID/pair_brownian_poly.cpp | 18 +- src/COLLOID/pair_lubricate.cpp | 18 +- src/COLLOID/pair_lubricateU.cpp | 50 +- src/COLLOID/pair_lubricateU_poly.cpp | 38 +- src/COLLOID/pair_lubricate_poly.cpp | 20 +- src/COMPRESS/dump_atom_gz.cpp | 2 +- src/COMPRESS/dump_atom_zstd.cpp | 2 +- src/COMPRESS/dump_cfg_gz.cpp | 2 +- src/COMPRESS/dump_cfg_zstd.cpp | 2 +- src/COMPRESS/dump_custom_gz.cpp | 2 +- src/COMPRESS/dump_custom_zstd.cpp | 2 +- src/COMPRESS/dump_local_gz.cpp | 2 +- src/COMPRESS/dump_local_zstd.cpp | 2 +- src/COMPRESS/dump_xyz_gz.cpp | 2 +- src/COMPRESS/dump_xyz_zstd.cpp | 2 +- src/COMPRESS/zstd_file_writer.cpp | 10 +- src/CORESHELL/compute_temp_cs.cpp | 4 +- src/GPU/pair_eam_alloy_gpu.cpp | 2 +- src/GPU/pair_eam_fs_gpu.cpp | 2 +- src/GPU/pair_vashishta_gpu.cpp | 4 +- src/GRANULAR/fix_wall_gran.cpp | 2 +- src/GRANULAR/pair_granular.cpp | 2 +- src/KIM/kim_query.cpp | 2 +- src/KOKKOS/atom_kokkos.cpp | 4 +- src/KOKKOS/atom_vec_angle_kokkos.cpp | 54 +- src/KOKKOS/atom_vec_atomic_kokkos.cpp | 20 +- src/KOKKOS/atom_vec_bond_kokkos.cpp | 20 +- src/KOKKOS/atom_vec_charge_kokkos.cpp | 20 +- src/KOKKOS/atom_vec_dpd_kokkos.cpp | 52 +- src/KOKKOS/atom_vec_full_kokkos.cpp | 20 +- src/KOKKOS/atom_vec_kokkos.cpp | 64 +- src/KOKKOS/atom_vec_molecular_kokkos.cpp | 54 +- src/KOKKOS/atom_vec_sphere_kokkos.cpp | 82 +- src/KOKKOS/comm_kokkos.cpp | 18 +- .../compute_orientorder_atom_kokkos.cpp | 36 +- src/KOKKOS/domain_kokkos.cpp | 2 +- src/KOKKOS/fix_enforce2d_kokkos.cpp | 10 +- src/KOKKOS/fix_eos_table_rx_kokkos.cpp | 32 +- src/KOKKOS/fix_langevin_kokkos.cpp | 38 +- src/KOKKOS/fix_qeq_reax_kokkos.cpp | 54 +- src/KOKKOS/fix_rx_kokkos.cpp | 100 +- src/KOKKOS/fix_shardlow_kokkos.cpp | 20 +- src/KOKKOS/kokkos.cpp | 2 +- src/KOKKOS/nbin_kokkos.cpp | 4 +- src/KOKKOS/nbin_ssa_kokkos.cpp | 2 +- src/KOKKOS/neighbor_kokkos.cpp | 8 +- src/KOKKOS/npair_kokkos.cpp | 242 ++-- src/KOKKOS/npair_ssa_kokkos.cpp | 42 +- src/KOKKOS/pair_buck_coul_cut_kokkos.cpp | 2 +- src/KOKKOS/pair_buck_coul_long_kokkos.cpp | 24 +- src/KOKKOS/pair_buck_kokkos.cpp | 2 +- src/KOKKOS/pair_coul_cut_kokkos.cpp | 2 +- src/KOKKOS/pair_coul_debye_kokkos.cpp | 2 +- src/KOKKOS/pair_coul_long_kokkos.cpp | 24 +- src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp | 6 +- src/KOKKOS/pair_eam_alloy_kokkos.cpp | 4 +- src/KOKKOS/pair_eam_fs_kokkos.cpp | 4 +- src/KOKKOS/pair_eam_kokkos.cpp | 2 +- src/KOKKOS/pair_exp6_rx_kokkos.cpp | 160 +-- ..._lj_charmm_coul_charmm_implicit_kokkos.cpp | 20 +- .../pair_lj_charmm_coul_charmm_kokkos.cpp | 20 +- .../pair_lj_charmm_coul_long_kokkos.cpp | 24 +- src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp | 2 +- .../pair_lj_class2_coul_long_kokkos.cpp | 26 +- src/KOKKOS/pair_lj_class2_kokkos.cpp | 2 +- src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp | 4 +- src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp | 2 +- src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp | 2 +- src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp | 26 +- src/KOKKOS/pair_lj_cut_kokkos.cpp | 2 +- src/KOKKOS/pair_lj_expand_kokkos.cpp | 2 +- .../pair_lj_gromacs_coul_gromacs_kokkos.cpp | 20 +- src/KOKKOS/pair_lj_gromacs_kokkos.cpp | 2 +- src/KOKKOS/pair_lj_sdk_kokkos.cpp | 4 +- src/KOKKOS/pair_morse_kokkos.cpp | 2 +- src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp | 64 +- src/KOKKOS/pair_reaxc_kokkos.cpp | 50 +- src/KOKKOS/pair_table_kokkos.cpp | 48 +- src/KOKKOS/pair_table_rx_kokkos.cpp | 80 +- src/KOKKOS/pair_yukawa_kokkos.cpp | 2 +- src/KOKKOS/pair_zbl_kokkos.cpp | 2 +- src/KOKKOS/verlet_kokkos.cpp | 14 +- src/KSPACE/pair_lj_long_coul_long.cpp | 2 +- src/KSPACE/pppm_disp.cpp | 6 +- src/MANYBODY/fix_qeq_comb.cpp | 4 +- src/MANYBODY/pair_adp.cpp | 2 +- src/MANYBODY/pair_airebo.cpp | 30 +- src/MANYBODY/pair_bop.cpp | 1102 ++++++++--------- src/MANYBODY/pair_comb.cpp | 4 +- src/MANYBODY/pair_comb3.cpp | 154 +-- src/MANYBODY/pair_eam.cpp | 4 +- src/MANYBODY/pair_eam_alloy.cpp | 2 +- src/MANYBODY/pair_eam_fs.cpp | 2 +- src/MANYBODY/pair_eim.cpp | 2 +- src/MANYBODY/pair_gw.cpp | 2 +- src/MANYBODY/pair_gw_zbl.cpp | 2 +- src/MANYBODY/pair_lcbop.cpp | 6 +- src/MANYBODY/pair_nb3b_harmonic.cpp | 2 +- src/MANYBODY/pair_polymorphic.cpp | 2 +- src/MANYBODY/pair_sw.cpp | 2 +- src/MANYBODY/pair_tersoff.cpp | 2 +- src/MANYBODY/pair_tersoff_mod.cpp | 2 +- src/MANYBODY/pair_tersoff_mod_c.cpp | 2 +- src/MANYBODY/pair_tersoff_zbl.cpp | 2 +- src/MANYBODY/pair_vashishta.cpp | 2 +- src/MISC/compute_ti.cpp | 2 +- src/MISC/fix_gld.cpp | 2 +- src/MISC/xdr_compat.cpp | 8 +- src/MLIAP/mliap_descriptor.cpp | 2 +- src/MLIAP/mliap_descriptor_snap.cpp | 8 +- src/MLIAP/mliap_model_linear.cpp | 2 +- src/MLIAP/mliap_model_python.cpp | 2 +- src/MLIAP/mliap_model_quadratic.cpp | 2 +- src/MOLECULE/angle_table.cpp | 2 +- src/MOLECULE/fix_cmap.cpp | 2 +- src/MOLECULE/pair_tip4p_cut.cpp | 2 +- src/OPT/pair_eam_opt.cpp | 10 +- src/OPT/pair_lj_long_coul_long_opt.cpp | 2 +- src/PYTHON/fix_python_move.cpp | 2 +- src/PYTHON/python_impl.cpp | 4 +- src/QEQ/fix_qeq.cpp | 66 +- src/QEQ/fix_qeq_dynamic.cpp | 16 +- src/QEQ/fix_qeq_fire.cpp | 16 +- src/RIGID/fix_ehex.cpp | 2 +- src/SNAP/compute_sna_atom.cpp | 10 +- src/SNAP/compute_snad_atom.cpp | 10 +- src/SNAP/compute_snap.cpp | 10 +- src/SNAP/compute_snav_atom.cpp | 10 +- src/SNAP/pair_snap.cpp | 4 +- src/SNAP/sna.cpp | 120 +- src/SPIN/fix_nve_spin.cpp | 8 +- src/SPIN/min_spin_cg.cpp | 20 +- src/SPIN/min_spin_lbfgs.cpp | 28 +- src/SPIN/neb_spin.cpp | 2 +- src/SRD/fix_srd.cpp | 4 +- src/USER-ADIOS/dump_atom_adios.cpp | 2 +- src/USER-ADIOS/dump_custom_adios.cpp | 2 +- src/USER-ADIOS/reader_adios.cpp | 2 +- src/USER-ATC/fix_atc.cpp | 12 +- src/USER-AWPMD/fix_nve_awpmd.cpp | 4 +- src/USER-AWPMD/pair_awpmd_cut.cpp | 100 +- src/USER-BOCS/fix_bocs.cpp | 4 +- src/USER-COLVARS/group_ndx.cpp | 2 +- src/USER-DIFFRACTION/compute_saed.cpp | 28 +- src/USER-DIFFRACTION/compute_xrd.cpp | 32 +- src/USER-DIFFRACTION/fix_saed_vtk.cpp | 26 +- src/USER-DPD/compute_dpd.cpp | 4 +- src/USER-DPD/compute_dpd_atom.cpp | 4 +- src/USER-DPD/fix_dpd_energy.cpp | 4 +- src/USER-DPD/fix_eos_cv.cpp | 14 +- src/USER-DPD/fix_eos_table.cpp | 16 +- src/USER-DPD/fix_eos_table_rx.cpp | 78 +- src/USER-DPD/fix_rx.cpp | 242 ++-- src/USER-DPD/fix_shardlow.cpp | 18 +- src/USER-DPD/nbin_ssa.cpp | 12 +- src/USER-DPD/pair_dpd_fdt_energy.cpp | 2 +- src/USER-DPD/pair_exp6_rx.cpp | 106 +- src/USER-DPD/pair_multi_lucy.cpp | 4 +- src/USER-DPD/pair_multi_lucy_rx.cpp | 52 +- src/USER-DPD/pair_table_rx.cpp | 36 +- src/USER-DRUDE/compute_temp_drude.cpp | 6 +- src/USER-DRUDE/fix_drude.cpp | 38 +- src/USER-DRUDE/fix_drude_transform.cpp | 10 +- src/USER-DRUDE/fix_langevin_drude.cpp | 4 +- src/USER-DRUDE/fix_tgnh_drude.cpp | 12 +- src/USER-DRUDE/pair_coul_tt.cpp | 2 +- src/USER-DRUDE/pair_lj_cut_thole_long.cpp | 10 +- src/USER-DRUDE/pair_thole.cpp | 2 +- src/USER-FEP/pair_morse_soft.cpp | 12 +- src/USER-INTEL/fix_intel.cpp | 4 +- src/USER-INTEL/nbin_intel.cpp | 2 +- src/USER-INTEL/npair_full_bin_ghost_intel.cpp | 2 +- .../npair_halffull_newton_intel.cpp | 2 +- src/USER-INTEL/npair_intel.cpp | 2 +- src/USER-INTEL/npair_skip_intel.cpp | 2 +- src/USER-INTEL/pair_airebo_intel.cpp | 4 +- src/USER-INTEL/pair_buck_coul_cut_intel.cpp | 8 +- src/USER-INTEL/pair_buck_coul_long_intel.cpp | 4 +- src/USER-INTEL/pair_buck_intel.cpp | 4 +- src/USER-INTEL/pair_dpd_intel.cpp | 2 +- src/USER-INTEL/pair_eam_alloy_intel.cpp | 2 +- src/USER-INTEL/pair_eam_fs_intel.cpp | 2 +- src/USER-INTEL/pair_eam_intel.cpp | 2 +- src/USER-INTEL/pair_gayberne_intel.cpp | 4 +- .../pair_lj_charmm_coul_charmm_intel.cpp | 4 +- .../pair_lj_charmm_coul_long_intel.cpp | 4 +- .../pair_lj_cut_coul_long_intel.cpp | 4 +- src/USER-INTEL/pair_lj_cut_intel.cpp | 2 +- src/USER-INTEL/pair_sw_intel.cpp | 6 +- src/USER-INTEL/pair_tersoff_intel.cpp | 4 +- src/USER-INTEL/pppm_disp_intel.cpp | 84 +- src/USER-INTEL/pppm_intel.cpp | 30 +- src/USER-LB/fix_lb_fluid.cpp | 740 +++++------ src/USER-LB/fix_lb_momentum.cpp | 38 +- src/USER-LB/fix_lb_pc.cpp | 60 +- src/USER-LB/fix_lb_rigid_pc_sphere.cpp | 128 +- src/USER-LB/fix_lb_viscous.cpp | 10 +- src/USER-MANIFOLD/fix_manifoldforce.cpp | 4 +- src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp | 26 +- src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp | 20 +- src/USER-MANIFOLD/manifold_gaussian_bump.cpp | 6 +- src/USER-MANIFOLD/manifold_thylakoid.cpp | 20 +- .../manifold_thylakoid_shared.cpp | 8 +- src/USER-MEAMC/meam_funcs.cpp | 2 +- src/USER-MEAMC/meam_setup_done.cpp | 6 +- src/USER-MESODPD/fix_edpd_source.cpp | 12 +- src/USER-MESODPD/fix_mvv_dpd.cpp | 2 +- src/USER-MESODPD/fix_mvv_edpd.cpp | 2 +- src/USER-MESODPD/fix_mvv_tdpd.cpp | 6 +- src/USER-MESODPD/fix_tdpd_source.cpp | 12 +- src/USER-MESODPD/pair_edpd.cpp | 28 +- src/USER-MESODPD/pair_mdpd.cpp | 4 +- src/USER-MESODPD/pair_tdpd.cpp | 14 +- src/USER-MGPT/mgpt_linalg.cpp | 30 +- src/USER-MGPT/mgpt_readpot.cpp | 98 +- src/USER-MGPT/mgpt_splinetab.cpp | 14 +- src/USER-MGPT/pair_mgpt.cpp | 422 +++---- src/USER-MISC/angle_gaussian.cpp | 8 +- src/USER-MISC/bond_gaussian.cpp | 8 +- src/USER-MISC/compute_basal_atom.cpp | 8 +- src/USER-MISC/compute_entropy_atom.cpp | 8 +- src/USER-MISC/compute_momentum.cpp | 4 +- src/USER-MISC/compute_stress_mop.cpp | 14 +- src/USER-MISC/compute_stress_mop_profile.cpp | 10 +- src/USER-MISC/dihedral_fourier.cpp | 4 +- src/USER-MISC/dihedral_nharmonic.cpp | 6 +- src/USER-MISC/dihedral_spherical.cpp | 4 +- src/USER-MISC/dihedral_table.cpp | 4 +- src/USER-MISC/dihedral_table_cut.cpp | 2 +- src/USER-MISC/fix_ave_correlate_long.cpp | 4 +- src/USER-MISC/fix_filter_corotate.cpp | 18 +- src/USER-MISC/fix_flow_gauss.cpp | 4 +- src/USER-MISC/fix_gle.cpp | 2 +- src/USER-MISC/fix_npt_cauchy.cpp | 24 +- src/USER-MISC/fix_pafi.cpp | 20 +- src/USER-MISC/fix_pimd.cpp | 130 +- src/USER-MISC/fix_propel_self.cpp | 8 +- src/USER-MISC/fix_rhok.cpp | 4 +- src/USER-MISC/fix_smd.cpp | 2 +- src/USER-MISC/fix_srp.cpp | 36 +- src/USER-MISC/fix_ti_spring.cpp | 2 +- src/USER-MISC/fix_ttm_mod.cpp | 24 +- src/USER-MISC/fix_wall_ees.cpp | 14 +- src/USER-MISC/fix_wall_region_ees.cpp | 26 +- src/USER-MISC/pair_agni.cpp | 2 +- src/USER-MISC/pair_e3b.cpp | 2 +- src/USER-MISC/pair_edip_multi.cpp | 8 +- src/USER-MISC/pair_ilp_graphene_hbn.cpp | 70 +- src/USER-MISC/pair_kolmogorov_crespi_full.cpp | 70 +- src/USER-MISC/pair_kolmogorov_crespi_z.cpp | 4 +- src/USER-MISC/pair_lebedeva_z.cpp | 4 +- src/USER-MISC/pair_local_density.cpp | 4 +- src/USER-MISC/pair_meam_spline.cpp | 84 +- src/USER-MISC/pair_meam_sw_spline.cpp | 86 +- src/USER-MISC/pair_srp.cpp | 30 +- src/USER-MISC/pair_tersoff_table.cpp | 2 +- src/USER-OMP/dihedral_table_omp.cpp | 2 +- src/USER-OMP/fix_nve_sphere_omp.cpp | 2 +- src/USER-OMP/fix_qeq_comb_omp.cpp | 2 +- src/USER-OMP/pair_agni_omp.cpp | 2 +- src/USER-OMP/pair_brownian_omp.cpp | 10 +- src/USER-OMP/pair_brownian_poly_omp.cpp | 10 +- src/USER-OMP/pair_comb_omp.cpp | 2 +- src/USER-OMP/pair_eam_alloy_omp.cpp | 2 +- src/USER-OMP/pair_eam_fs_omp.cpp | 2 +- src/USER-OMP/pair_lj_cut_thole_long_omp.cpp | 10 +- src/USER-OMP/pair_lj_long_coul_long_omp.cpp | 2 +- src/USER-OMP/pair_lubricate_omp.cpp | 10 +- src/USER-OMP/pair_lubricate_poly_omp.cpp | 10 +- src/USER-OMP/pair_meam_spline_omp.cpp | 22 +- src/USER-OMP/pair_reaxc_omp.cpp | 18 +- src/USER-OMP/pair_tersoff_zbl_omp.cpp | 2 +- src/USER-OMP/reaxc_bond_orders_omp.cpp | 22 +- src/USER-OMP/reaxc_bonds_omp.cpp | 2 +- src/USER-OMP/reaxc_forces_omp.cpp | 48 +- src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp | 10 +- src/USER-OMP/reaxc_init_md_omp.cpp | 12 +- src/USER-OMP/reaxc_multi_body_omp.cpp | 18 +- src/USER-OMP/reaxc_nonbonded_omp.cpp | 18 +- src/USER-OMP/reaxc_torsion_angles_omp.cpp | 4 +- src/USER-OMP/reaxc_valence_angles_omp.cpp | 38 +- src/USER-PHONON/dynamical_matrix.cpp | 30 +- src/USER-PHONON/fix_phonon.cpp | 128 +- src/USER-PHONON/third_order.cpp | 44 +- src/USER-PLUMED/fix_plumed.cpp | 4 +- src/USER-PTM/ptm_voronoi_cell.cpp | 310 ++--- src/USER-QTB/fix_qbmsst.cpp | 2 +- src/USER-QTB/fix_qtb.cpp | 2 +- src/USER-QUIP/pair_quip.cpp | 10 +- src/USER-REACTION/fix_bond_react.cpp | 2 +- src/USER-REAXC/fix_qeq_reax.cpp | 24 +- src/USER-REAXC/fix_reaxc_bonds.cpp | 4 +- src/USER-REAXC/pair_reaxc.cpp | 28 +- src/USER-REAXC/reaxc_allocate.cpp | 14 +- src/USER-REAXC/reaxc_bond_orders.cpp | 2 +- src/USER-REAXC/reaxc_bonds.cpp | 2 +- src/USER-REAXC/reaxc_control.cpp | 2 +- src/USER-REAXC/reaxc_ffield.cpp | 2 +- src/USER-REAXC/reaxc_forces.cpp | 6 +- src/USER-REAXC/reaxc_hydrogen_bonds.cpp | 2 +- src/USER-REAXC/reaxc_init_md.cpp | 14 +- src/USER-REAXC/reaxc_io_tools.cpp | 10 +- src/USER-REAXC/reaxc_lookup.cpp | 42 +- src/USER-REAXC/reaxc_nonbonded.cpp | 12 +- src/USER-REAXC/reaxc_torsion_angles.cpp | 12 +- src/USER-REAXC/reaxc_traj.cpp | 8 +- src/USER-REAXC/reaxc_valence_angles.cpp | 2 +- src/USER-SCAFACOS/scafacos.cpp | 4 +- .../compute_smd_triangle_vertices.cpp | 2 +- src/USER-SMD/pair_smd_tlsph.cpp | 2 +- src/USER-SMTBQ/pair_smtbq.cpp | 50 +- src/USER-TALLY/compute_pe_mol_tally.cpp | 2 +- src/USER-UEF/dump_cfg_uef.cpp | 2 +- src/USER-UEF/uef_utils.cpp | 6 +- src/USER-VTK/dump_vtk.cpp | 14 +- src/atom.cpp | 4 +- src/comm_tiled.cpp | 2 +- src/compute_hexorder_atom.cpp | 4 +- src/compute_orientorder_atom.cpp | 36 +- src/fix_adapt.cpp | 12 +- src/fix_ave_histo_weight.cpp | 2 +- src/fix_deform.cpp | 2 +- src/fix_nh.cpp | 4 +- src/fix_nh_sphere.cpp | 6 +- src/fix_nve_sphere.cpp | 2 +- src/fix_temp_csvr.cpp | 2 +- src/hashlittle.cpp | 4 +- src/info.cpp | 88 +- src/library.cpp | 48 +- src/modify.cpp | 2 +- src/neighbor.cpp | 6 +- src/pair_coul_streitz.cpp | 6 +- src/potential_file_reader.cpp | 2 +- src/reader_native.cpp | 2 +- src/region.cpp | 6 +- src/region_block.cpp | 4 +- src/region_cone.cpp | 4 +- src/region_cylinder.cpp | 4 +- src/region_intersect.cpp | 2 +- src/region_prism.cpp | 2 +- src/tokenizer.cpp | 22 +- src/update.cpp | 2 +- src/utils.cpp | 12 +- src/variable.cpp | 4 +- 345 files changed, 4259 insertions(+), 4259 deletions(-) diff --git a/src/COLLOID/pair_brownian.cpp b/src/COLLOID/pair_brownian.cpp index ea23478805..cdfb379087 100644 --- a/src/COLLOID/pair_brownian.cpp +++ b/src/COLLOID/pair_brownian.cpp @@ -99,20 +99,20 @@ void PairBrownian::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -494,7 +494,7 @@ void PairBrownian::init_style() // are re-calculated at every step. flagdeform = flagwall = 0; - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) flagdeform = 1; else if (strstr(modify->fix[i]->style,"wall") != nullptr) { @@ -514,14 +514,14 @@ void PairBrownian::init_style() if (!flagwall) vol_T = domain->xprd*domain->yprd*domain->zprd; else { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); // Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_brownian_poly.cpp b/src/COLLOID/pair_brownian_poly.cpp index e25ef37f04..15afd56886 100644 --- a/src/COLLOID/pair_brownian_poly.cpp +++ b/src/COLLOID/pair_brownian_poly.cpp @@ -82,20 +82,20 @@ void PairBrownianPoly::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (j = 0; j < 3; j++){ + for (j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -355,7 +355,7 @@ void PairBrownianPoly::init_style() // are re-calculated at every step. flagdeform = flagwall = 0; - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) flagdeform = 1; else if (strstr(modify->fix[i]->style,"wall") != nullptr) { @@ -375,14 +375,14 @@ void PairBrownianPoly::init_style() if (!flagwall) vol_T = domain->xprd*domain->yprd*domain->zprd; else { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); // Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricate.cpp b/src/COLLOID/pair_lubricate.cpp index d813b794f1..64b7aa2e30 100644 --- a/src/COLLOID/pair_lubricate.cpp +++ b/src/COLLOID/pair_lubricate.cpp @@ -155,20 +155,20 @@ void PairLubricate::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -559,7 +559,7 @@ void PairLubricate::init_style() // are re-calculated at every step. shearing = flagdeform = flagwall = 0; - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) { shearing = flagdeform = 1; if (((FixDeform *) modify->fix[i])->remapflag != Domain::V_REMAP) @@ -584,15 +584,15 @@ void PairLubricate::init_style() if (!flagwall) vol_T = domain->xprd*domain->yprd*domain->zprd; else { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricateU.cpp b/src/COLLOID/pair_lubricateU.cpp index 3974b12b56..c047ce6a07 100644 --- a/src/COLLOID/pair_lubricateU.cpp +++ b/src/COLLOID/pair_lubricateU.cpp @@ -158,8 +158,8 @@ void PairLubricateU::compute(int eflag, int vflag) // store back the saved forces and torques in original arrays - for(i=0;iprd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -813,20 +813,20 @@ void PairLubricateU::compute_RU() double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1013,7 +1013,7 @@ void PairLubricateU::compute_RU() torque[i][1] -= vxmu2f*ty; torque[i][2] -= vxmu2f*tz; - if(newton_pair || j < nlocal) { + if (newton_pair || j < nlocal) { torque[j][0] -= vxmu2f*tx; torque[j][1] -= vxmu2f*ty; torque[j][2] -= vxmu2f*tz; @@ -1084,20 +1084,20 @@ void PairLubricateU::compute_RU(double **x) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1284,7 +1284,7 @@ void PairLubricateU::compute_RU(double **x) torque[i][1] -= vxmu2f*ty; torque[i][2] -= vxmu2f*tz; - if(newton_pair || j < nlocal) { + if (newton_pair || j < nlocal) { torque[j][0] -= vxmu2f*tx; torque[j][1] -= vxmu2f*ty; torque[j][2] -= vxmu2f*tz; @@ -1791,7 +1791,7 @@ void PairLubricateU::init_style() // are re-calculated at every step. flagdeform = flagwall = 0; - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) flagdeform = 1; else if (strstr(modify->fix[i]->style,"wall") != nullptr) { @@ -1811,14 +1811,14 @@ void PairLubricateU::init_style() if (!flagwall) vol_T = domain->xprd*domain->yprd*domain->zprd; else { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricateU_poly.cpp b/src/COLLOID/pair_lubricateU_poly.cpp index 6b44c4e077..49c77e9b60 100644 --- a/src/COLLOID/pair_lubricateU_poly.cpp +++ b/src/COLLOID/pair_lubricateU_poly.cpp @@ -126,8 +126,8 @@ void PairLubricateUPoly::compute(int eflag, int vflag) // Store back the saved forces and torques in original arrays - for(i=0;iprd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -626,20 +626,20 @@ void PairLubricateUPoly::compute_RU(double **x) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (j = 0; j < 3; j++){ + for (j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1155,10 +1155,10 @@ void PairLubricateUPoly::init_style() // are re-calculated at every step. flagdeform = flagwall = 0; - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) flagdeform = 1; - else if (strstr(modify->fix[i]->style,"wall") != nullptr){ + else if (strstr(modify->fix[i]->style,"wall") != nullptr) { if (flagwall) error->all(FLERR, "Cannot use multiple fix wall commands with " @@ -1176,14 +1176,14 @@ void PairLubricateUPoly::init_style() if (!flagwall) vol_T = domain->xprd*domain->yprd*domain->zprd; else { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); @@ -1214,7 +1214,7 @@ void PairLubricateUPoly::init_style() if (!flagVF) vol_f = 0; if (!comm->me) { - if(logfile) + if (logfile) fprintf(logfile, "lubricateU: vol_f = %g, vol_p = %g, vol_T = %g\n", vol_f,vol_P,vol_T); if (screen) diff --git a/src/COLLOID/pair_lubricate_poly.cpp b/src/COLLOID/pair_lubricate_poly.cpp index b35411ab4b..a395f8c67e 100644 --- a/src/COLLOID/pair_lubricate_poly.cpp +++ b/src/COLLOID/pair_lubricate_poly.cpp @@ -137,20 +137,20 @@ void PairLubricatePoly::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -461,7 +461,7 @@ void PairLubricatePoly::init_style() // are re-calculated at every step. shearing = flagdeform = flagwall = 0; - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) { shearing = flagdeform = 1; if (((FixDeform *) modify->fix[i])->remapflag != Domain::V_REMAP) @@ -478,7 +478,7 @@ void PairLubricatePoly::init_style() if (wallfix->xflag) flagwall = 2; // Moving walls exist } - if (strstr(modify->fix[i]->style,"wall") != nullptr){ + if (strstr(modify->fix[i]->style,"wall") != nullptr) { flagwall = 1; // Walls exist if (((FixWall *) modify->fix[i])->xflag ) { flagwall = 2; // Moving walls exist @@ -492,14 +492,14 @@ void PairLubricatePoly::init_style() if (!flagwall) vol_T = domain->xprd*domain->yprd*domain->zprd; else { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COMPRESS/dump_atom_gz.cpp b/src/COMPRESS/dump_atom_gz.cpp index 946ea57bfd..7c30d7c101 100644 --- a/src/COMPRESS/dump_atom_gz.cpp +++ b/src/COMPRESS/dump_atom_gz.cpp @@ -168,7 +168,7 @@ void DumpAtomGZ::write() int DumpAtomGZ::modify_param(int narg, char **arg) { int consumed = DumpAtom::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { if (strcmp(arg[0],"compression_level") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); int min_level = Z_DEFAULT_COMPRESSION; diff --git a/src/COMPRESS/dump_atom_zstd.cpp b/src/COMPRESS/dump_atom_zstd.cpp index 3313b8d78d..f51a8b393b 100644 --- a/src/COMPRESS/dump_atom_zstd.cpp +++ b/src/COMPRESS/dump_atom_zstd.cpp @@ -171,7 +171,7 @@ void DumpAtomZstd::write() int DumpAtomZstd::modify_param(int narg, char **arg) { int consumed = DumpAtom::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { try { if (strcmp(arg[0],"checksum") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); diff --git a/src/COMPRESS/dump_cfg_gz.cpp b/src/COMPRESS/dump_cfg_gz.cpp index e50e13ff4e..9beb606b24 100644 --- a/src/COMPRESS/dump_cfg_gz.cpp +++ b/src/COMPRESS/dump_cfg_gz.cpp @@ -176,7 +176,7 @@ void DumpCFGGZ::write() int DumpCFGGZ::modify_param(int narg, char **arg) { int consumed = DumpCFG::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { if (strcmp(arg[0],"compression_level") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); int min_level = Z_DEFAULT_COMPRESSION; diff --git a/src/COMPRESS/dump_cfg_zstd.cpp b/src/COMPRESS/dump_cfg_zstd.cpp index ff8b7c395a..13890334ba 100644 --- a/src/COMPRESS/dump_cfg_zstd.cpp +++ b/src/COMPRESS/dump_cfg_zstd.cpp @@ -173,7 +173,7 @@ void DumpCFGZstd::write() int DumpCFGZstd::modify_param(int narg, char **arg) { int consumed = DumpCFG::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { try { if (strcmp(arg[0],"checksum") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); diff --git a/src/COMPRESS/dump_custom_gz.cpp b/src/COMPRESS/dump_custom_gz.cpp index e36dea7d21..f345f4b111 100644 --- a/src/COMPRESS/dump_custom_gz.cpp +++ b/src/COMPRESS/dump_custom_gz.cpp @@ -168,7 +168,7 @@ void DumpCustomGZ::write() int DumpCustomGZ::modify_param(int narg, char **arg) { int consumed = DumpCustom::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { if (strcmp(arg[0],"compression_level") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); int min_level = Z_DEFAULT_COMPRESSION; diff --git a/src/COMPRESS/dump_custom_zstd.cpp b/src/COMPRESS/dump_custom_zstd.cpp index 8937ce04c9..81ace6172f 100644 --- a/src/COMPRESS/dump_custom_zstd.cpp +++ b/src/COMPRESS/dump_custom_zstd.cpp @@ -171,7 +171,7 @@ void DumpCustomZstd::write() int DumpCustomZstd::modify_param(int narg, char **arg) { int consumed = DumpCustom::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { try { if (strcmp(arg[0],"checksum") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); diff --git a/src/COMPRESS/dump_local_gz.cpp b/src/COMPRESS/dump_local_gz.cpp index 17eecc95fd..e0d2f0d2dd 100644 --- a/src/COMPRESS/dump_local_gz.cpp +++ b/src/COMPRESS/dump_local_gz.cpp @@ -183,7 +183,7 @@ void DumpLocalGZ::write() int DumpLocalGZ::modify_param(int narg, char **arg) { int consumed = DumpLocal::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { if (strcmp(arg[0],"compression_level") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); int min_level = Z_DEFAULT_COMPRESSION; diff --git a/src/COMPRESS/dump_local_zstd.cpp b/src/COMPRESS/dump_local_zstd.cpp index 8a7a8cf19b..c03670ffba 100644 --- a/src/COMPRESS/dump_local_zstd.cpp +++ b/src/COMPRESS/dump_local_zstd.cpp @@ -171,7 +171,7 @@ void DumpLocalZstd::write() int DumpLocalZstd::modify_param(int narg, char **arg) { int consumed = DumpLocal::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { try { if (strcmp(arg[0],"checksum") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); diff --git a/src/COMPRESS/dump_xyz_gz.cpp b/src/COMPRESS/dump_xyz_gz.cpp index c84c83b9cb..21a55f6b07 100644 --- a/src/COMPRESS/dump_xyz_gz.cpp +++ b/src/COMPRESS/dump_xyz_gz.cpp @@ -147,7 +147,7 @@ void DumpXYZGZ::write() int DumpXYZGZ::modify_param(int narg, char **arg) { int consumed = DumpXYZ::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { if (strcmp(arg[0],"compression_level") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); int min_level = Z_DEFAULT_COMPRESSION; diff --git a/src/COMPRESS/dump_xyz_zstd.cpp b/src/COMPRESS/dump_xyz_zstd.cpp index 0cc65a03b8..9c220bdca7 100644 --- a/src/COMPRESS/dump_xyz_zstd.cpp +++ b/src/COMPRESS/dump_xyz_zstd.cpp @@ -145,7 +145,7 @@ void DumpXYZZstd::write() int DumpXYZZstd::modify_param(int narg, char **arg) { int consumed = DumpXYZ::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { try { if (strcmp(arg[0],"checksum") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); diff --git a/src/COMPRESS/zstd_file_writer.cpp b/src/COMPRESS/zstd_file_writer.cpp index 2631faa4ad..9f69f95395 100644 --- a/src/COMPRESS/zstd_file_writer.cpp +++ b/src/COMPRESS/zstd_file_writer.cpp @@ -48,7 +48,7 @@ ZstdFileWriter::~ZstdFileWriter() void ZstdFileWriter::open(const std::string &path) { - if(isopen()) return; + if (isopen()) return; fp = fopen(path.c_str(), "wb"); @@ -72,7 +72,7 @@ void ZstdFileWriter::open(const std::string &path) size_t ZstdFileWriter::write(const void * buffer, size_t length) { - if(!isopen()) return 0; + if (!isopen()) return 0; ZSTD_inBuffer input = { buffer, length, 0 }; ZSTD_EndDirective mode = ZSTD_e_continue; @@ -90,7 +90,7 @@ size_t ZstdFileWriter::write(const void * buffer, size_t length) void ZstdFileWriter::flush() { - if(!isopen()) return; + if (!isopen()) return; size_t remaining; ZSTD_inBuffer input = { nullptr, 0, 0 }; @@ -109,7 +109,7 @@ void ZstdFileWriter::flush() void ZstdFileWriter::close() { - if(!isopen()) return; + if (!isopen()) return; size_t remaining; ZSTD_inBuffer input = { nullptr, 0, 0 }; @@ -144,7 +144,7 @@ void ZstdFileWriter::setCompressionLevel(int level) const int min_level = ZSTD_minCLevel(); const int max_level = ZSTD_maxCLevel(); - if(level < min_level || level > max_level) + if (level < min_level || level > max_level) throw FileWriterException(fmt::format("Compression level must in the range of [{}, {}]", min_level, max_level)); compression_level = level; diff --git a/src/CORESHELL/compute_temp_cs.cpp b/src/CORESHELL/compute_temp_cs.cpp index 92a9fd04e7..4bf74a3b7e 100644 --- a/src/CORESHELL/compute_temp_cs.cpp +++ b/src/CORESHELL/compute_temp_cs.cpp @@ -232,7 +232,7 @@ double ComputeTempCS::compute_scalar() double t = 0.0; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { vthermal[0] = v[i][0] - vint[i][0]; vthermal[1] = v[i][1] - vint[i][1]; @@ -271,7 +271,7 @@ void ComputeTempCS::compute_vector() double t[6]; for (int i = 0; i < 6; i++) t[i] = 0.0; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (rmass) massone = rmass[i]; else massone = mass[type[i]]; diff --git a/src/GPU/pair_eam_alloy_gpu.cpp b/src/GPU/pair_eam_alloy_gpu.cpp index 7da95cdc11..c1370af307 100644 --- a/src/GPU/pair_eam_alloy_gpu.cpp +++ b/src/GPU/pair_eam_alloy_gpu.cpp @@ -370,7 +370,7 @@ void PairEAMAlloyGPU::read_file(char *filename) Setfl *file = setfl; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(PairEAM::lmp, filename, "eam/alloy", unit_convert_flag); diff --git a/src/GPU/pair_eam_fs_gpu.cpp b/src/GPU/pair_eam_fs_gpu.cpp index d613069a9a..ce3ea8bb0b 100644 --- a/src/GPU/pair_eam_fs_gpu.cpp +++ b/src/GPU/pair_eam_fs_gpu.cpp @@ -370,7 +370,7 @@ void PairEAMFSGPU::read_file(char *filename) Fs *file = fs; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(PairEAM::lmp, filename, "eam/fs", unit_convert_flag); diff --git a/src/GPU/pair_vashishta_gpu.cpp b/src/GPU/pair_vashishta_gpu.cpp index 6a7ea52a54..df17b2091a 100644 --- a/src/GPU/pair_vashishta_gpu.cpp +++ b/src/GPU/pair_vashishta_gpu.cpp @@ -141,7 +141,7 @@ void PairVashishtaGPU::compute(int eflag, int vflag) void PairVashishtaGPU::allocate() { - if(!allocated) { + if (!allocated) { PairVashishta::allocate(); } int n = atom->ntypes; @@ -260,7 +260,7 @@ void PairVashishtaGPU::init_style() double PairVashishtaGPU::init_one(int i, int j) { - if(!gpu_allocated) { + if (!gpu_allocated) { allocate(); } if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set"); diff --git a/src/GRANULAR/fix_wall_gran.cpp b/src/GRANULAR/fix_wall_gran.cpp index 7218149d08..f52b976b63 100644 --- a/src/GRANULAR/fix_wall_gran.cpp +++ b/src/GRANULAR/fix_wall_gran.cpp @@ -1303,7 +1303,7 @@ void FixWallGran::granular(double rsq, double dx, double dy, double dz, relrot2 = omega[1]; relrot3 = omega[2]; } - if (roll_model != ROLL_NONE){ + if (roll_model != ROLL_NONE) { // rolling velocity, see eq. 31 of Wang et al, Particuology v 23, p 49 (2015) // This is different from the Marshall papers, diff --git a/src/GRANULAR/pair_granular.cpp b/src/GRANULAR/pair_granular.cpp index fe88d0755f..215926e23e 100644 --- a/src/GRANULAR/pair_granular.cpp +++ b/src/GRANULAR/pair_granular.cpp @@ -536,7 +536,7 @@ void PairGranular::compute(int eflag, int vflag) } if (roll_model[itype][jtype] != ROLL_NONE || - twist_model[itype][jtype] != TWIST_NONE){ + twist_model[itype][jtype] != TWIST_NONE) { relrot1 = omega[i][0] - omega[j][0]; relrot2 = omega[i][1] - omega[j][1]; relrot3 = omega[i][2] - omega[j][2]; diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index 564f063668..faf1d26909 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -252,7 +252,7 @@ char *do_query(char *qfunction, char * model_name, int narg, char **arg, } } else { query += fmt::format("&{}=[", key); - while (n != std::string::npos){ + while (n != std::string::npos) { std::string sval = val.substr(0, n); if (utils::is_integer(sval) || utils::is_double(sval) || diff --git a/src/KOKKOS/atom_kokkos.cpp b/src/KOKKOS/atom_kokkos.cpp index 0b50f2d3d8..c41a42c99a 100644 --- a/src/KOKKOS/atom_kokkos.cpp +++ b/src/KOKKOS/atom_kokkos.cpp @@ -230,9 +230,9 @@ void AtomKokkos::sort() reallocate memory to the pointer selected by the mask ------------------------------------------------------------------------- */ -void AtomKokkos::grow(unsigned int mask){ +void AtomKokkos::grow(unsigned int mask) { - if (mask & SPECIAL_MASK){ + if (mask & SPECIAL_MASK) { memoryKK->destroy_kokkos(k_special, special); sync(Device, mask); modified(Device, mask); diff --git a/src/KOKKOS/atom_vec_angle_kokkos.cpp b/src/KOKKOS/atom_vec_angle_kokkos.cpp index b15fc2965b..39897018ec 100644 --- a/src/KOKKOS/atom_vec_angle_kokkos.cpp +++ b/src/KOKKOS/atom_vec_angle_kokkos.cpp @@ -281,10 +281,10 @@ int AtomVecAngleKokkos::pack_comm_kokkos(const int &n, // Check whether to always run forward communication on the host // Choose correct forward PackComm kernel - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -296,7 +296,7 @@ int AtomVecAngleKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -310,8 +310,8 @@ int AtomVecAngleKokkos::pack_comm_kokkos(const int &n, } } else { atomKK->sync(Device,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -323,7 +323,7 @@ int AtomVecAngleKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -396,11 +396,11 @@ int AtomVecAngleKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &li const int & iswap, const int nfirst, const int &pbc_flag, const int* const pbc) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); atomKK->modified(Host,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, @@ -414,7 +414,7 @@ int AtomVecAngleKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &li Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, @@ -431,8 +431,8 @@ int AtomVecAngleKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &li } else { atomKK->sync(Device,X_MASK); atomKK->modified(Device,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, @@ -446,7 +446,7 @@ int AtomVecAngleKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &li Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, @@ -492,7 +492,7 @@ struct AtomVecAngleKokkos_UnpackComm { void AtomVecAngleKokkos::unpack_comm_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf ) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); atomKK->modified(Host,X_MASK); struct AtomVecAngleKokkos_UnpackComm f(atomKK->k_x,buf,first); @@ -641,7 +641,7 @@ void AtomVecAngleKokkos::unpack_comm_vel(int n, int first, double *buf) int AtomVecAngleKokkos::pack_reverse(int n, int first, double *buf) { - if(n > 0) + if (n > 0) atomKK->sync(Host,F_MASK); int m = 0; @@ -658,7 +658,7 @@ int AtomVecAngleKokkos::pack_reverse(int n, int first, double *buf) void AtomVecAngleKokkos::unpack_reverse(int n, int *list, double *buf) { - if(n > 0) + if (n > 0) atomKK->modified(Host,F_MASK); int m = 0; @@ -742,7 +742,7 @@ int AtomVecAngleKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecAngleKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); @@ -756,7 +756,7 @@ int AtomVecAngleKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecAngleKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); @@ -939,7 +939,7 @@ struct AtomVecAngleKokkos_UnpackBorder { typename AT::t_tagint_1d &molecule, const int& first): _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_molecule(molecule), - _first(first){ + _first(first) { }; KOKKOS_INLINE_FUNCTION @@ -963,7 +963,7 @@ void AtomVecAngleKokkos::unpack_border_kokkos(const int &n, const int &first, atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK); while (first+n >= nmax) grow(0); atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK); - if(space==Host) { + if (space==Host) { struct AtomVecAngleKokkos_UnpackBorder f(buf.view(),h_x,h_tag,h_type,h_mask,h_molecule,first); Kokkos::parallel_for(n,f); @@ -1129,7 +1129,7 @@ struct AtomVecAngleKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { // 3 comp of x, 3 comp of v, 1 tag, 1 type, 1 mask, 1 image, 1 molecule, 3 nspecial, // maxspecial special, 1 num_bond, bond_per_atom bond_type, bond_per_atom bond_atom, // 1 num_angle, angle_per_atom angle_type, angle_per_atom angle_atom1, angle_atom2, @@ -1178,7 +1178,7 @@ struct AtomVecAngleKokkos_PackExchangeFunctor { const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -1220,12 +1220,12 @@ int AtomVecAngleKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_ X_FLOAT hi ) { const int elements = 17+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom; - if(nsend > (int) (k_buf.view().extent(0)* + if (nsend > (int) (k_buf.view().extent(0)* k_buf.view().extent(1))/elements) { int newsize = nsend*elements/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } - if(space == Host) { + if (space == Host) { AtomVecAngleKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); @@ -1333,7 +1333,7 @@ struct AtomVecAngleKokkos_UnpackExchangeFunctor { _angle_atom2(atom->k_angle_atom2.view()), _angle_atom3(atom->k_angle_atom3.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { elements =17+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom; const int maxsendlist = (buf.template view().extent(0)* buf.template view().extent(1))/elements; @@ -1386,7 +1386,7 @@ int AtomVecAngleKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int n int nlocal,int dim,X_FLOAT lo,X_FLOAT hi, ExecutionSpace space) { const size_t elements = 17+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom; - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecAngleKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); diff --git a/src/KOKKOS/atom_vec_atomic_kokkos.cpp b/src/KOKKOS/atom_vec_atomic_kokkos.cpp index 013b55c959..c1ae398e22 100644 --- a/src/KOKKOS/atom_vec_atomic_kokkos.cpp +++ b/src/KOKKOS/atom_vec_atomic_kokkos.cpp @@ -200,7 +200,7 @@ int AtomVecAtomicKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecAtomicKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,dx,dy,dz); @@ -214,7 +214,7 @@ int AtomVecAtomicKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecAtomicKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,dx,dy,dz); @@ -374,7 +374,7 @@ struct AtomVecAtomicKokkos_UnpackBorder { typename ArrayTypes::t_int_1d &type, typename ArrayTypes::t_int_1d &mask, const int& first): - _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_first(first){ + _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_first(first) { }; KOKKOS_INLINE_FUNCTION @@ -396,7 +396,7 @@ void AtomVecAtomicKokkos::unpack_border_kokkos(const int &n, const int &first, atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK); while (first+n >= nmax) grow(0); atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK); - if(space==Host) { + if (space==Host) { struct AtomVecAtomicKokkos_UnpackBorder f(buf.view(),h_x,h_tag,h_type,h_mask,first); Kokkos::parallel_for(n,f); } else { @@ -504,7 +504,7 @@ struct AtomVecAtomicKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { const size_t elements = 11; const int maxsendlist = (buf.template view().extent(0)*buf.template view().extent(1))/elements; @@ -527,7 +527,7 @@ struct AtomVecAtomicKokkos_PackExchangeFunctor { _buf(mysend,10) = d_ubuf(_image[i]).d; const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -546,11 +546,11 @@ struct AtomVecAtomicKokkos_PackExchangeFunctor { int AtomVecAtomicKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d k_sendlist,DAT::tdual_int_1d k_copylist,ExecutionSpace space,int dim,X_FLOAT lo,X_FLOAT hi ) { - if(nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/11) { + if (nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/11) { int newsize = nsend*11/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } - if(space == Host) { + if (space == Host) { AtomVecAtomicKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); return nsend*11; @@ -615,7 +615,7 @@ struct AtomVecAtomicKokkos_UnpackExchangeFunctor { _mask(atom->k_mask.view()), _image(atom->k_image.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { const size_t elements = 11; const int maxsendlist = (buf.template view().extent(0)*buf.template view().extent(1))/elements; @@ -644,7 +644,7 @@ struct AtomVecAtomicKokkos_UnpackExchangeFunctor { /* ---------------------------------------------------------------------- */ int AtomVecAtomicKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nrecv,int nlocal,int dim,X_FLOAT lo,X_FLOAT hi,ExecutionSpace space) { - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecAtomicKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); Kokkos::parallel_for(nrecv/11,f); diff --git a/src/KOKKOS/atom_vec_bond_kokkos.cpp b/src/KOKKOS/atom_vec_bond_kokkos.cpp index 91d7dbef63..dd973a9369 100644 --- a/src/KOKKOS/atom_vec_bond_kokkos.cpp +++ b/src/KOKKOS/atom_vec_bond_kokkos.cpp @@ -250,7 +250,7 @@ int AtomVecBondKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecBondKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); @@ -264,7 +264,7 @@ int AtomVecBondKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecBondKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); @@ -447,7 +447,7 @@ struct AtomVecBondKokkos_UnpackBorder { typename AT::t_tagint_1d &molecule, const int& first): _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_molecule(molecule), - _first(first){ + _first(first) { }; KOKKOS_INLINE_FUNCTION @@ -471,7 +471,7 @@ void AtomVecBondKokkos::unpack_border_kokkos(const int &n, const int &first, atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK); while (first+n >= nmax) grow(0); atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK); - if(space==Host) { + if (space==Host) { struct AtomVecBondKokkos_UnpackBorder f(buf.view(),h_x,h_tag,h_type,h_mask,h_molecule,first); Kokkos::parallel_for(n,f); @@ -621,7 +621,7 @@ struct AtomVecBondKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { // 3 comp of x, 3 comp of v, 1 tag, 1 type, 1 mask, 1 image, 1 molecule, 3 nspecial, // maxspecial special, 1 num_bond, bond_per_atom bond_type, bond_per_atom bond_atom, // 1 to store buffer length @@ -661,7 +661,7 @@ struct AtomVecBondKokkos_PackExchangeFunctor { const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -696,12 +696,12 @@ int AtomVecBondKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2 X_FLOAT hi ) { const int elements = 16+atomKK->maxspecial+atomKK->bond_per_atom+atomKK->bond_per_atom; - if(nsend > (int) (k_buf.view().extent(0)* + if (nsend > (int) (k_buf.view().extent(0)* k_buf.view().extent(1))/elements) { int newsize = nsend*elements/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } - if(space == Host) { + if (space == Host) { AtomVecBondKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); @@ -794,7 +794,7 @@ struct AtomVecBondKokkos_UnpackExchangeFunctor { _bond_type(atom->k_bond_type.view()), _bond_atom(atom->k_bond_atom.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { elements = 16+atom->maxspecial+atom->bond_per_atom+atom->bond_per_atom; const int maxsendlist = (buf.template view().extent(0)* buf.template view().extent(1))/elements; @@ -840,7 +840,7 @@ int AtomVecBondKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nr int nlocal,int dim,X_FLOAT lo,X_FLOAT hi, ExecutionSpace space) { const size_t elements = 16+atomKK->maxspecial+atomKK->bond_per_atom+atomKK->bond_per_atom; - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecBondKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); diff --git a/src/KOKKOS/atom_vec_charge_kokkos.cpp b/src/KOKKOS/atom_vec_charge_kokkos.cpp index 698703371f..4416ab34b8 100644 --- a/src/KOKKOS/atom_vec_charge_kokkos.cpp +++ b/src/KOKKOS/atom_vec_charge_kokkos.cpp @@ -267,7 +267,7 @@ int AtomVecChargeKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecChargeKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_q,dx,dy,dz); @@ -281,7 +281,7 @@ int AtomVecChargeKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecChargeKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_q,dx,dy,dz); @@ -463,7 +463,7 @@ struct AtomVecChargeKokkos_UnpackBorder { typename ArrayTypes::t_int_1d &mask, typename ArrayTypes::t_float_1d &q, const int& first): - _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_q(q),_first(first){ + _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_q(q),_first(first) { }; KOKKOS_INLINE_FUNCTION @@ -485,7 +485,7 @@ void AtomVecChargeKokkos::unpack_border_kokkos(const int &n, const int &first, if (first+n >= nmax) { grow(first+n+100); } - if(space==Host) { + if (space==Host) { struct AtomVecChargeKokkos_UnpackBorder f(buf.view(),h_x,h_tag,h_type,h_mask,h_q,first); Kokkos::parallel_for(n,f); @@ -618,7 +618,7 @@ struct AtomVecChargeKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { const size_t elements = 12; const int maxsendlist = (buf.template view().extent(0)* buf.template view().extent(1))/elements; @@ -643,7 +643,7 @@ struct AtomVecChargeKokkos_PackExchangeFunctor { _buf(mysend,11) = _q[i]; const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -667,11 +667,11 @@ int AtomVecChargeKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat ExecutionSpace space,int dim, X_FLOAT lo,X_FLOAT hi ) { - if(nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/12) { + if (nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/12) { int newsize = nsend*12/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } - if(space == Host) { + if (space == Host) { AtomVecChargeKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); @@ -740,7 +740,7 @@ struct AtomVecChargeKokkos_UnpackExchangeFunctor { _image(atom->k_image.view()), _q(atom->k_q.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { const size_t elements = 12; const int maxsendlist = (buf.template view().extent(0)*buf.template view().extent(1))/elements; @@ -772,7 +772,7 @@ struct AtomVecChargeKokkos_UnpackExchangeFunctor { int AtomVecChargeKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nrecv, int nlocal,int dim,X_FLOAT lo,X_FLOAT hi, ExecutionSpace space) { - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecChargeKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); Kokkos::parallel_for(nrecv/12,f); diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.cpp b/src/KOKKOS/atom_vec_dpd_kokkos.cpp index 8a733f66e4..26fcda983b 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.cpp +++ b/src/KOKKOS/atom_vec_dpd_kokkos.cpp @@ -267,10 +267,10 @@ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, // Check whether to always run forward communication on the host // Choose correct forward PackComm kernel - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, buf,list,iswap, @@ -286,7 +286,7 @@ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, buf,list,iswap, @@ -304,8 +304,8 @@ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, } } else { atomKK->sync(Device,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, buf,list,iswap, @@ -321,7 +321,7 @@ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, buf,list,iswap, @@ -409,11 +409,11 @@ struct AtomVecDPDKokkos_PackCommSelf { int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, const int & iswap, const int nfirst, const int &pbc_flag, const int* const pbc) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); atomKK->modified(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, nfirst,list,iswap, @@ -429,7 +429,7 @@ int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, nfirst,list,iswap, @@ -448,8 +448,8 @@ int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list } else { atomKK->sync(Device,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); atomKK->modified(Device,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, nfirst,list,iswap, @@ -465,7 +465,7 @@ int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, nfirst,list,iswap, @@ -527,7 +527,7 @@ struct AtomVecDPDKokkos_UnpackComm { void AtomVecDPDKokkos::unpack_comm_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf ) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); atomKK->modified(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); struct AtomVecDPDKokkos_UnpackComm f(atomKK->k_x, @@ -716,7 +716,7 @@ void AtomVecDPDKokkos::unpack_comm_vel(int n, int first, double *buf) int AtomVecDPDKokkos::pack_reverse(int n, int first, double *buf) { - if(n > 0) + if (n > 0) atomKK->sync(Host,F_MASK); int m = 0; @@ -733,7 +733,7 @@ int AtomVecDPDKokkos::pack_reverse(int n, int first, double *buf) void AtomVecDPDKokkos::unpack_reverse(int n, int *list, double *buf) { - if(n > 0) { + if (n > 0) { atomKK->sync(Host,F_MASK); atomKK->modified(Host,F_MASK); } @@ -831,7 +831,7 @@ int AtomVecDPDKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DA dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecDPDKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -849,7 +849,7 @@ int AtomVecDPDKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DA } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecDPDKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -1134,7 +1134,7 @@ void AtomVecDPDKokkos::unpack_border_kokkos(const int &n, const int &first, atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK| DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK| UCG_MASK|UCGNEW_MASK|DVECTOR_MASK); - if(space==Host) { + if (space==Host) { struct AtomVecDPDKokkos_UnpackBorder f(buf.view(), h_x,h_tag,h_type,h_mask, h_dpdTheta,h_uCond,h_uMech,h_uChem,h_uCG,h_uCGnew, @@ -1326,7 +1326,7 @@ struct AtomVecDPDKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { const size_t elements = 17; const int maxsendlist = (buf.template view().extent(0)*buf.template view().extent(1))/elements; @@ -1355,7 +1355,7 @@ struct AtomVecDPDKokkos_PackExchangeFunctor { _buf(mysend,16) = _uCGnew[i]; const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -1380,7 +1380,7 @@ struct AtomVecDPDKokkos_PackExchangeFunctor { int AtomVecDPDKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d k_sendlist,DAT::tdual_int_1d k_copylist,ExecutionSpace space,int dim,X_FLOAT lo,X_FLOAT hi ) { - if(nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/17) { + if (nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/17) { int newsize = nsend*17/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } @@ -1388,7 +1388,7 @@ int AtomVecDPDKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2d MASK_MASK | IMAGE_MASK| DPDTHETA_MASK | UCOND_MASK | UMECH_MASK | UCHEM_MASK | UCG_MASK | UCGNEW_MASK | DVECTOR_MASK); - if(space == Host) { + if (space == Host) { AtomVecDPDKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); } else { @@ -1469,7 +1469,7 @@ struct AtomVecDPDKokkos_UnpackExchangeFunctor { _mask(atom->k_mask.view()), _image(atom->k_image.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { const size_t elements = 17; const int maxsendlist = (buf.template view().extent(0)*buf.template view().extent(1))/elements; @@ -1504,7 +1504,7 @@ struct AtomVecDPDKokkos_UnpackExchangeFunctor { /* ---------------------------------------------------------------------- */ int AtomVecDPDKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nrecv,int nlocal,int dim,X_FLOAT lo,X_FLOAT hi,ExecutionSpace space) { - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecDPDKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); Kokkos::parallel_for(nrecv/17,f); diff --git a/src/KOKKOS/atom_vec_full_kokkos.cpp b/src/KOKKOS/atom_vec_full_kokkos.cpp index 2c85e4129b..6f8673bbc8 100644 --- a/src/KOKKOS/atom_vec_full_kokkos.cpp +++ b/src/KOKKOS/atom_vec_full_kokkos.cpp @@ -381,7 +381,7 @@ int AtomVecFullKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecFullKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_q,h_molecule,dx,dy,dz); @@ -395,7 +395,7 @@ int AtomVecFullKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecFullKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_q,h_molecule,dx,dy,dz); @@ -586,7 +586,7 @@ struct AtomVecFullKokkos_UnpackBorder { typename AT::t_tagint_1d &molecule, const int& first): _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_q(q),_molecule(molecule), - _first(first){ + _first(first) { }; KOKKOS_INLINE_FUNCTION @@ -611,7 +611,7 @@ void AtomVecFullKokkos::unpack_border_kokkos(const int &n, const int &first, atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|Q_MASK|MOLECULE_MASK); while (first+n >= nmax) grow(0); atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|Q_MASK|MOLECULE_MASK); - if(space==Host) { + if (space==Host) { struct AtomVecFullKokkos_UnpackBorder f(buf.view(),h_x,h_tag,h_type,h_mask,h_q,h_molecule,first); Kokkos::parallel_for(n,f); @@ -824,7 +824,7 @@ struct AtomVecFullKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { // 3 comp of x, 3 comp of v, 1 tag, 1 type, 1 mask, 1 image, 1 molecule, 3 nspecial, // maxspecial special, 1 num_bond, bond_per_atom bond_type, bond_per_atom bond_atom, // 1 num_angle, angle_per_atom angle_type, angle_per_atom angle_atom1, angle_atom2, @@ -895,7 +895,7 @@ struct AtomVecFullKokkos_PackExchangeFunctor { const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -955,12 +955,12 @@ int AtomVecFullKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2 { const int elements = 20+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; - if(nsend > (int) (k_buf.view().extent(0)* + if (nsend > (int) (k_buf.view().extent(0)* k_buf.view().extent(1))/elements) { int newsize = nsend*elements/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } - if(space == Host) { + if (space == Host) { AtomVecFullKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); @@ -1106,7 +1106,7 @@ struct AtomVecFullKokkos_UnpackExchangeFunctor { _improper_atom3(atom->k_improper_atom3.view()), _improper_atom4(atom->k_improper_atom4.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { elements = 20+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; @@ -1178,7 +1178,7 @@ int AtomVecFullKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nr ExecutionSpace space) { const size_t elements = 20+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecFullKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index 35ed9160d2..86c79141c0 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -112,10 +112,10 @@ int AtomVecKokkos::pack_comm_kokkos(const int &n, // Check whether to always run forward communication on the host // Choose correct forward PackComm kernel - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { sync(Host,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -127,7 +127,7 @@ int AtomVecKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -141,8 +141,8 @@ int AtomVecKokkos::pack_comm_kokkos(const int &n, } } else { sync(Device,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -154,7 +154,7 @@ int AtomVecKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -225,11 +225,11 @@ struct AtomVecKokkos_PackCommSelf { int AtomVecKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, const int & iswap, const int nfirst, const int &pbc_flag, const int* const pbc) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { sync(Host,X_MASK); modified(Host,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -241,7 +241,7 @@ int AtomVecKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, c Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -256,8 +256,8 @@ int AtomVecKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, c } else { sync(Device,X_MASK); modified(Device,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -269,7 +269,7 @@ int AtomVecKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, c Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -361,10 +361,10 @@ struct AtomVecKokkos_PackCommSelfFused { int AtomVecKokkos::pack_comm_self_fused(const int &n, const DAT::tdual_int_2d &list, const DAT::tdual_int_1d &sendnum_scan, const DAT::tdual_int_1d &firstrecv, const DAT::tdual_int_1d &pbc_flag, const DAT::tdual_int_2d &pbc, const DAT::tdual_int_1d &g2l) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { sync(Host,X_MASK); modified(Host,X_MASK); - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommSelfFused f(atomKK->k_x,list,pbc,pbc_flag,firstrecv,sendnum_scan,g2l, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz); @@ -378,7 +378,7 @@ int AtomVecKokkos::pack_comm_self_fused(const int &n, const DAT::tdual_int_2d &l } else { sync(Device,X_MASK); modified(Device,X_MASK); - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommSelfFused f(atomKK->k_x,list,pbc,pbc_flag,firstrecv,sendnum_scan,g2l, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz); @@ -421,7 +421,7 @@ struct AtomVecKokkos_UnpackComm { void AtomVecKokkos::unpack_comm_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf ) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { sync(Host,X_MASK); modified(Host,X_MASK); struct AtomVecKokkos_UnpackComm f(atomKK->k_x,buf,first); @@ -530,7 +530,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( const int &pbc_flag, const int* const pbc) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { sync(Host,X_MASK|V_MASK); if (pbc_flag) { if (deform_vremap) { @@ -552,7 +552,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, @@ -571,7 +571,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( } } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, @@ -591,9 +591,9 @@ int AtomVecKokkos::pack_comm_vel_kokkos( } } else { sync(Device,X_MASK|V_MASK); - if(pbc_flag) { - if(deform_vremap) { - if(domain->triclinic) { + if (pbc_flag) { + if (deform_vremap) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, @@ -611,7 +611,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, @@ -630,7 +630,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( } } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, @@ -692,7 +692,7 @@ struct AtomVecKokkos_UnpackCommVel { void AtomVecKokkos::unpack_comm_vel_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf ) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { sync(Host,X_MASK|V_MASK); modified(Host,X_MASK|V_MASK); struct AtomVecKokkos_UnpackCommVel f(atomKK->k_x,atomKK->k_v,buf,first); @@ -865,7 +865,7 @@ struct AtomVecKokkos_PackReverse { int AtomVecKokkos::pack_reverse_kokkos(const int &n, const int &first, const DAT::tdual_ffloat_2d &buf ) { - if(commKK->reverse_comm_on_host) { + if (commKK->reverse_comm_on_host) { sync(Host,F_MASK); struct AtomVecKokkos_PackReverse f(atomKK->k_f,buf,first); Kokkos::parallel_for(n,f); @@ -911,7 +911,7 @@ struct AtomVecKokkos_UnPackReverseSelf { int AtomVecKokkos::unpack_reverse_self(const int &n, const DAT::tdual_int_2d &list, const int & iswap, const int nfirst) { - if(commKK->reverse_comm_on_host) { + if (commKK->reverse_comm_on_host) { sync(Host,F_MASK); struct AtomVecKokkos_UnPackReverseSelf f(atomKK->k_f,nfirst,list,iswap); Kokkos::parallel_for(n,f); @@ -966,7 +966,7 @@ void AtomVecKokkos::unpack_reverse_kokkos(const int &n, // Check whether to always run reverse communication on the host // Choose correct reverse UnPackReverse kernel - if(commKK->reverse_comm_on_host) { + if (commKK->reverse_comm_on_host) { struct AtomVecKokkos_UnPackReverse f(atomKK->k_f,buf,list,iswap); Kokkos::parallel_for(n,f); modified(Host,F_MASK); @@ -981,7 +981,7 @@ void AtomVecKokkos::unpack_reverse_kokkos(const int &n, int AtomVecKokkos::pack_reverse(int n, int first, double *buf) { - if(n > 0) + if (n > 0) sync(Host,F_MASK); int m = 0; @@ -1007,7 +1007,7 @@ void AtomVecKokkos::unpack_reverse(int n, int *list, double *buf) h_f(j,2) += buf[m++]; } - if(n > 0) + if (n > 0) modified(Host,F_MASK); } diff --git a/src/KOKKOS/atom_vec_molecular_kokkos.cpp b/src/KOKKOS/atom_vec_molecular_kokkos.cpp index 20a748191c..2fb33e02b7 100644 --- a/src/KOKKOS/atom_vec_molecular_kokkos.cpp +++ b/src/KOKKOS/atom_vec_molecular_kokkos.cpp @@ -360,10 +360,10 @@ int AtomVecMolecularKokkos::pack_comm_kokkos(const int &n, // Check whether to always run forward communication on the host // Choose correct forward PackComm kernel - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackComm f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -375,7 +375,7 @@ int AtomVecMolecularKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackComm f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -389,8 +389,8 @@ int AtomVecMolecularKokkos::pack_comm_kokkos(const int &n, } } else { atomKK->sync(Device,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackComm f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -402,7 +402,7 @@ int AtomVecMolecularKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackComm f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -476,11 +476,11 @@ int AtomVecMolecularKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d const int & iswap, const int nfirst, const int &pbc_flag, const int* const pbc) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); atomKK->modified(Host,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -492,7 +492,7 @@ int AtomVecMolecularKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -507,8 +507,8 @@ int AtomVecMolecularKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d } else { atomKK->sync(Device,X_MASK); atomKK->modified(Device,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -520,7 +520,7 @@ int AtomVecMolecularKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -564,7 +564,7 @@ struct AtomVecMolecularKokkos_UnpackComm { void AtomVecMolecularKokkos::unpack_comm_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf ) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); atomKK->modified(Host,X_MASK); struct AtomVecMolecularKokkos_UnpackComm f(atomKK->k_x,buf,first); @@ -713,7 +713,7 @@ void AtomVecMolecularKokkos::unpack_comm_vel(int n, int first, double *buf) int AtomVecMolecularKokkos::pack_reverse(int n, int first, double *buf) { - if(n > 0) + if (n > 0) atomKK->sync(Host,F_MASK); int m = 0; @@ -730,7 +730,7 @@ int AtomVecMolecularKokkos::pack_reverse(int n, int first, double *buf) void AtomVecMolecularKokkos::unpack_reverse(int n, int *list, double *buf) { - if(n > 0) + if (n > 0) atomKK->modified(Host,F_MASK); int m = 0; @@ -814,7 +814,7 @@ int AtomVecMolecularKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendli dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecMolecularKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); @@ -828,7 +828,7 @@ int AtomVecMolecularKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendli } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecMolecularKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); @@ -1011,7 +1011,7 @@ struct AtomVecMolecularKokkos_UnpackBorder { typename AT::t_tagint_1d &molecule, const int& first): _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_molecule(molecule), - _first(first){ + _first(first) { }; KOKKOS_INLINE_FUNCTION @@ -1035,7 +1035,7 @@ void AtomVecMolecularKokkos::unpack_border_kokkos(const int &n, const int &first atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK); while (first+n >= nmax) grow(0); atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK); - if(space==Host) { + if (space==Host) { struct AtomVecMolecularKokkos_UnpackBorder f(buf.view(),h_x,h_tag,h_type,h_mask,h_molecule,first); Kokkos::parallel_for(n,f); @@ -1240,7 +1240,7 @@ struct AtomVecMolecularKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { // 3 comp of x, 3 comp of v, 1 tag, 1 type, 1 mask, 1 image, 1 molecule, 3 nspecial, // maxspecial special, 1 num_bond, bond_per_atom bond_type, bond_per_atom bond_atom, // 1 num_angle, angle_per_atom angle_type, angle_per_atom angle_atom1, angle_atom2, @@ -1309,7 +1309,7 @@ struct AtomVecMolecularKokkos_PackExchangeFunctor { const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -1368,12 +1368,12 @@ int AtomVecMolecularKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfl { const int elements = 19+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; - if(nsend > (int) (k_buf.view().extent(0)* + if (nsend > (int) (k_buf.view().extent(0)* k_buf.view().extent(1))/elements) { int newsize = nsend*elements/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } - if(space == Host) { + if (space == Host) { AtomVecMolecularKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); @@ -1517,7 +1517,7 @@ struct AtomVecMolecularKokkos_UnpackExchangeFunctor { _improper_atom3(atom->k_improper_atom3.view()), _improper_atom4(atom->k_improper_atom4.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { elements = 19+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; @@ -1589,7 +1589,7 @@ int AtomVecMolecularKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,i ExecutionSpace space) { const size_t elements = 19+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecMolecularKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.cpp b/src/KOKKOS/atom_vec_sphere_kokkos.cpp index 22d10e4632..451e9d737e 100644 --- a/src/KOKKOS/atom_vec_sphere_kokkos.cpp +++ b/src/KOKKOS/atom_vec_sphere_kokkos.cpp @@ -274,10 +274,10 @@ int AtomVecSphereKokkos::pack_comm_kokkos( return AtomVecKokkos::pack_comm_kokkos(n,list,iswap,buf,pbc_flag,pbc); // Check whether to always run forward communication on the host // Choose correct forward PackComm kernel - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|RADIUS_MASK|RMASS_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -295,7 +295,7 @@ int AtomVecSphereKokkos::pack_comm_kokkos( Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -315,8 +315,8 @@ int AtomVecSphereKokkos::pack_comm_kokkos( } } else { atomKK->sync(Device,X_MASK|RADIUS_MASK|RMASS_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -334,7 +334,7 @@ int AtomVecSphereKokkos::pack_comm_kokkos( Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -461,11 +461,11 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( const int &pbc_flag, const int* const pbc) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|RADIUS_MASK|RMASS_MASK|V_MASK|OMEGA_MASK); - if(pbc_flag) { - if(deform_vremap) { - if(domain->triclinic) { + if (pbc_flag) { + if (deform_vremap) { + if (domain->triclinic) { if (radvary == 0) { struct AtomVecSphereKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, @@ -507,7 +507,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( } } } else { - if(domain->triclinic) { + if (domain->triclinic) { if (radvary == 0) { struct AtomVecSphereKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, @@ -550,7 +550,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( } } } else { - if(domain->triclinic) { + if (domain->triclinic) { if (radvary == 0) { struct AtomVecSphereKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, @@ -594,9 +594,9 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( } } else { atomKK->sync(Device,X_MASK|RADIUS_MASK|RMASS_MASK|V_MASK|OMEGA_MASK); - if(pbc_flag) { - if(deform_vremap) { - if(domain->triclinic) { + if (pbc_flag) { + if (deform_vremap) { + if (domain->triclinic) { if (radvary == 0) { struct AtomVecSphereKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, @@ -638,7 +638,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( } } } else { - if(domain->triclinic) { + if (domain->triclinic) { if (radvary == 0) { struct AtomVecSphereKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, @@ -681,7 +681,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( } } } else { - if(domain->triclinic) { + if (domain->triclinic) { if (radvary == 0) { struct AtomVecSphereKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, @@ -792,11 +792,11 @@ int AtomVecSphereKokkos::pack_comm_self( // Fallback to AtomVecKokkos if radvary == 0 if (radvary == 0) return AtomVecKokkos::pack_comm_self(n,list,iswap,nfirst,pbc_flag,pbc); - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|RADIUS_MASK|RMASS_MASK); atomKK->modified(Host,X_MASK|RADIUS_MASK|RMASS_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -814,7 +814,7 @@ int AtomVecSphereKokkos::pack_comm_self( Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -835,8 +835,8 @@ int AtomVecSphereKokkos::pack_comm_self( } else { atomKK->sync(Device,X_MASK|RADIUS_MASK|RMASS_MASK); atomKK->modified(Device,X_MASK|RADIUS_MASK|RMASS_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -854,7 +854,7 @@ int AtomVecSphereKokkos::pack_comm_self( Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -923,7 +923,7 @@ void AtomVecSphereKokkos::unpack_comm_kokkos( AtomVecKokkos::unpack_comm_kokkos(n,first,buf); return; } - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->modified(Host,X_MASK|RADIUS_MASK|RMASS_MASK); struct AtomVecSphereKokkos_UnpackComm f( atomKK->k_x, @@ -995,7 +995,7 @@ struct AtomVecSphereKokkos_UnpackCommVel { void AtomVecSphereKokkos::unpack_comm_vel_kokkos( const int &n, const int &first, const DAT::tdual_xfloat_2d &buf ) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->modified(Host,X_MASK|RADIUS_MASK|RMASS_MASK|V_MASK|OMEGA_MASK); if (radvary == 0) { struct AtomVecSphereKokkos_UnpackCommVel f( @@ -1352,7 +1352,7 @@ int AtomVecSphereKokkos::unpack_comm_hybrid(int n, int first, double *buf) int AtomVecSphereKokkos::pack_reverse(int n, int first, double *buf) { - if(n > 0) + if (n > 0) atomKK->sync(Host,F_MASK|TORQUE_MASK); int m = 0; @@ -1372,7 +1372,7 @@ int AtomVecSphereKokkos::pack_reverse(int n, int first, double *buf) int AtomVecSphereKokkos::pack_reverse_hybrid(int n, int first, double *buf) { - if(n > 0) + if (n > 0) atomKK->sync(Host,TORQUE_MASK); int m = 0; @@ -1389,7 +1389,7 @@ int AtomVecSphereKokkos::pack_reverse_hybrid(int n, int first, double *buf) void AtomVecSphereKokkos::unpack_reverse(int n, int *list, double *buf) { - if(n > 0) { + if (n > 0) { atomKK->modified(Host,F_MASK|TORQUE_MASK); } @@ -1409,7 +1409,7 @@ void AtomVecSphereKokkos::unpack_reverse(int n, int *list, double *buf) int AtomVecSphereKokkos::unpack_reverse_hybrid(int n, int *list, double *buf) { - if(n > 0) { + if (n > 0) { atomKK->modified(Host,TORQUE_MASK); } @@ -1502,7 +1502,7 @@ int AtomVecSphereKokkos::pack_border_kokkos( dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecSphereKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -1519,7 +1519,7 @@ int AtomVecSphereKokkos::pack_border_kokkos( } } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecSphereKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -1697,7 +1697,7 @@ int AtomVecSphereKokkos::pack_border_vel_kokkos( dz = pbc[2]; } if (!deform_vremap) { - if(space==Host) { + if (space==Host) { AtomVecSphereKokkos_PackBorderVel f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -1721,7 +1721,7 @@ int AtomVecSphereKokkos::pack_border_vel_kokkos( dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; dvz = pbc[2]*h_rate[2]; - if(space==Host) { + if (space==Host) { AtomVecSphereKokkos_PackBorderVel f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -1742,7 +1742,7 @@ int AtomVecSphereKokkos::pack_border_vel_kokkos( } } } else { - if(space==Host) { + if (space==Host) { AtomVecSphereKokkos_PackBorderVel f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -1926,7 +1926,7 @@ struct AtomVecSphereKokkos_UnpackBorder { void AtomVecSphereKokkos::unpack_border_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf,ExecutionSpace space) { while (first+n >= nmax) grow(0); - if(space==Host) { + if (space==Host) { struct AtomVecSphereKokkos_UnpackBorder f(buf.view(), h_x,h_tag,h_type,h_mask, h_radius,h_rmass, @@ -2034,7 +2034,7 @@ void AtomVecSphereKokkos::unpack_border_vel_kokkos( const int &n, const int &first, const DAT::tdual_xfloat_2d &buf,ExecutionSpace space) { while (first+n >= nmax) grow(0); - if(space==Host) { + if (space==Host) { struct AtomVecSphereKokkos_UnpackBorderVel f(buf.view(), h_x,h_tag,h_type,h_mask, h_radius,h_rmass, @@ -2212,7 +2212,7 @@ int AtomVecSphereKokkos::pack_exchange_kokkos( DAT::tdual_int_1d k_copylist, ExecutionSpace space,int dim,X_FLOAT lo,X_FLOAT hi) { - if(nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/16) { + if (nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/16) { int newsize = nsend*17/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } @@ -2220,7 +2220,7 @@ int AtomVecSphereKokkos::pack_exchange_kokkos( MASK_MASK | IMAGE_MASK| RADIUS_MASK | RMASS_MASK | OMEGA_MASK); - if(space == Host) { + if (space == Host) { AtomVecSphereKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); } else { @@ -2338,7 +2338,7 @@ struct AtomVecSphereKokkos_UnpackExchangeFunctor { /* ---------------------------------------------------------------------- */ int AtomVecSphereKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nrecv,int nlocal,int dim,X_FLOAT lo,X_FLOAT hi,ExecutionSpace space) { - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecSphereKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); Kokkos::parallel_for(nrecv/16,f); diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index 2ef4b14d4f..ddfa5530b8 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -571,10 +571,10 @@ void CommKokkos::reverse_comm_dump(Dump *dump) void CommKokkos::exchange() { - if(atom->nextra_grow + atom->nextra_border) { - if(!exchange_comm_classic) { + if (atom->nextra_grow + atom->nextra_border) { + if (!exchange_comm_classic) { static int print = 1; - if(print && comm->me==0) { + if (print && comm->me==0) { error->warning(FLERR,"Fixes cannot yet send exchange data in Kokkos communication, " "switching to classic exchange/border communication"); } @@ -625,7 +625,7 @@ struct BuildExchangeListFunctor { void operator() (int i) const { if (_x(i,_dim) < _lo || _x(i,_dim) >= _hi) { const int mysend=Kokkos::atomic_fetch_add(&_nsend(),1); - if(mysend < (int)_sendlist.extent(0)) { + if (mysend < (int)_sendlist.extent(0)) { _sendlist(mysend) = i; _sendflag(i) = 1; } @@ -713,7 +713,7 @@ void CommKokkos::exchange_device() int sendpos = nlocal-1; nlocal -= k_count.h_view(); - for(int i = 0; i < k_count.h_view(); i++) { + for (int i = 0; i < k_count.h_view(); i++) { if (k_exchange_sendlist.h_view(i)= lo && x(i,dim) <= hi) { sendlist(iswap,mysend++) = i; } @@ -979,7 +979,7 @@ void CommKokkos::borders_device() { k_sendlist.modify(); - if(k_total_send.h_view() >= maxsendlist[iswap]) { + if (k_total_send.h_view() >= maxsendlist[iswap]) { grow_list(iswap,k_total_send.h_view()); k_total_send.h_view() = 0; @@ -1227,7 +1227,7 @@ void CommKokkos::grow_send_kokkos(int n, int flag, ExecutionSpace space) maxsend = static_cast (BUFFACTOR * n); int maxsend_border = (maxsend+BUFEXTRA+5)/atom->avec->size_border + 2; if (flag) { - if(space == Device) + if (space == Device) k_buf_send.modify(); else k_buf_send.modify(); @@ -1280,7 +1280,7 @@ void CommKokkos::grow_list(int /*iswap*/, int n) memoryKK->grow_kokkos(k_sendlist,sendlist,maxswap,size,"comm:sendlist"); - for(int i=0;i()(i,0); } } diff --git a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp index 3703769e90..8cac92240f 100644 --- a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp +++ b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp @@ -241,7 +241,7 @@ void ComputeOrientOrderAtomKokkos::operator() (TagComputeOrientOrder int ncount = 0; Kokkos::parallel_reduce(Kokkos::TeamThreadRange(team,jnum), [&] (const int jj, int& count) { - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { int j = d_neighbors(i,jj); j &= NEIGHMASK; const F_FLOAT delx = x(j,0) - xtmp; @@ -439,14 +439,14 @@ void ComputeOrientOrderAtomKokkos::calc_boop1(int /*ncount*/, int ii const double r1 = d_rlist(ii,ineigh,1); const double r2 = d_rlist(ii,ineigh,2); const double rmag = sqrt(r0*r0 + r1*r1 + r2*r2); - if(rmag <= MY_EPSILON) { + if (rmag <= MY_EPSILON) { return; } const double costheta = r2 / rmag; SNAcomplex expphi = {r0,r1}; const double rxymag = sqrt(expphi.re*expphi.re+expphi.im*expphi.im); - if(rxymag <= MY_EPSILON) { + if (rxymag <= MY_EPSILON) { expphi.re = 1.0; expphi.im = 0.0; } else { @@ -466,14 +466,14 @@ void ComputeOrientOrderAtomKokkos::calc_boop1(int /*ncount*/, int ii const double polar_pf = polar_prefactor(l, 0, costheta); Kokkos::atomic_add(&(d_qnm(ii,il,l).re), polar_pf); SNAcomplex expphim = {expphi.re,expphi.im}; - for(int m = 1; m <= +l; m++) { + for (int m = 1; m <= +l; m++) { const double prefactor = polar_prefactor(l, m, costheta); SNAcomplex ylm = {prefactor * expphim.re, prefactor * expphim.im}; //d_qnm(ii,il,m+l).re += ylm.re; //d_qnm(ii,il,m+l).im += ylm.im; Kokkos::atomic_add(&(d_qnm(ii,il,m+l).re), ylm.re); Kokkos::atomic_add(&(d_qnm(ii,il,m+l).im), ylm.im); - if(m & 1) { + if (m & 1) { //d_qnm(ii,il,-m+l).re -= ylm.re; //d_qnm(ii,il,-m+l).im += ylm.im; Kokkos::atomic_add(&(d_qnm(ii,il,-m+l).re), -ylm.re); @@ -508,7 +508,7 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co double facn = 1.0 / ncount; for (int il = 0; il < nqlist; il++) { int l = d_qlist[il]; - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { d_qnm(ii,il,m).re *= facn; d_qnm(ii,il,m).im *= facn; } @@ -522,7 +522,7 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co int l = d_qlist[il]; double qnormfac = sqrt(MY_4PI/(2*l+1)); double qm_sum = 0.0; - for(int m = 0; m < 2*l+1; m++) + for (int m = 0; m < 2*l+1; m++) qm_sum += d_qnm(ii,il,m).re*d_qnm(ii,il,m).re + d_qnm(ii,il,m).im*d_qnm(ii,il,m).im; d_qnarray(i,jj++) = qnormfac * sqrt(qm_sum); } @@ -534,8 +534,8 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co for (int il = 0; il < nqlist; il++) { int l = d_qlist[il]; double wlsum = 0.0; - for(int m1 = 0; m1 < 2*l+1; m1++) { - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { + for (int m1 = 0; m1 < 2*l+1; m1++) { + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { int m = m1 + m2 - l; SNAcomplex qm1qm2; qm1qm2.re = d_qnm(ii,il,m1).re*d_qnm(ii,il,m2).re - d_qnm(ii,il,m1).im*d_qnm(ii,il,m2).im; @@ -555,8 +555,8 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co for (int il = 0; il < nqlist; il++) { int l = d_qlist[il]; double wlsum = 0.0; - for(int m1 = 0; m1 < 2*l+1; m1++) { - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { + for (int m1 = 0; m1 < 2*l+1; m1++) { + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { const int m = m1 + m2 - l; SNAcomplex qm1qm2; qm1qm2.re = d_qnm(ii,il,m1).re*d_qnm(ii,il,m2).re - d_qnm(ii,il,m1).im*d_qnm(ii,il,m2).im; @@ -581,14 +581,14 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co const int il = iqlcomp; const int l = qlcomp; if (d_qnarray(i,il) < QEPSILON) - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { d_qnarray(i,jj++) = 0.0; d_qnarray(i,jj++) = 0.0; } else { const double qnormfac = sqrt(MY_4PI/(2*l+1)); const double qnfac = qnormfac/d_qnarray(i,il); - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { d_qnarray(i,jj++) = d_qnm(ii,il,m).re * qnfac; d_qnarray(i,jj++) = d_qnm(ii,il,m).im * qnfac; } @@ -665,8 +665,8 @@ void ComputeOrientOrderAtomKokkos::init_clebsch_gordan() idxcg_count = 0; for (int il = 0; il < nqlist; il++) { int l = qlist[il]; - for(int m1 = 0; m1 < 2*l+1; m1++) - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) + for (int m1 = 0; m1 < 2*l+1; m1++) + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) idxcg_count++; } idxcg_max = idxcg_count; @@ -676,9 +676,9 @@ void ComputeOrientOrderAtomKokkos::init_clebsch_gordan() idxcg_count = 0; for (int il = 0; il < nqlist; il++) { int l = qlist[il]; - for(int m1 = 0; m1 < 2*l+1; m1++) { + for (int m1 = 0; m1 < 2*l+1; m1++) { aa2 = m1 - l; - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { bb2 = m2 - l; m = aa2 + bb2 + l; @@ -727,7 +727,7 @@ void ComputeOrientOrderAtomKokkos::check_team_size_for(int inum, int team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelForTag()); - if(team_size*vector_length > team_size_max) + if (team_size*vector_length > team_size_max) team_size = team_size_max/vector_length; } diff --git a/src/KOKKOS/domain_kokkos.cpp b/src/KOKKOS/domain_kokkos.cpp index e124d98f7e..0d03f6c910 100644 --- a/src/KOKKOS/domain_kokkos.cpp +++ b/src/KOKKOS/domain_kokkos.cpp @@ -235,7 +235,7 @@ struct DomainPBCFunctor { x(_x.view()), v(_v.view()), mask(_mask.view()), image(_image.view()), deform_groupbit(_deform_groupbit), - xperiodic(_xperiodic), yperiodic(_yperiodic), zperiodic(_zperiodic){ + xperiodic(_xperiodic), yperiodic(_yperiodic), zperiodic(_zperiodic) { lo[0]=_lo[0]; lo[1]=_lo[1]; lo[2]=_lo[2]; hi[0]=_hi[0]; hi[1]=_hi[1]; hi[2]=_hi[2]; period[0]=_period[0]; period[1]=_period[1]; period[2]=_period[2]; diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp index 2294c24b11..8608b90543 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.cpp +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -77,7 +77,7 @@ void FixEnforce2DKokkos::post_force(int /*vflag*/) if (atomKK->torque_flag) flag_mask |= 4; copymode = 1; - switch( flag_mask ){ + switch( flag_mask ) { case 0:{ FixEnforce2DKokkosPostForceFunctor functor(this); Kokkos::parallel_for(nlocal,functor); @@ -139,21 +139,21 @@ template KOKKOS_INLINE_FUNCTION void FixEnforce2DKokkos::post_force_item( int i ) const { - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { v(i,2) = 0.0; f(i,2) = 0.0; - if(omega_flag){ + if (omega_flag) { omega(i,0) = 0.0; omega(i,1) = 0.0; } - if(angmom_flag){ + if (angmom_flag) { angmom(i,0) = 0.0; angmom(i,1) = 0.0; } - if(torque_flag){ + if (torque_flag) { torque(i,0) = 0.0; torque(i,1) = 0.0; } diff --git a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp index 2bf2812e0b..a14e301bfa 100644 --- a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp +++ b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp @@ -193,7 +193,7 @@ KOKKOS_INLINE_FUNCTION void FixEOStableRXKokkos::operator()(TagFixEOStableRXInit, const int &i) const { double tmp; if (mask[i] & groupbit) { - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) k_error_flag.template view()() = 1; energy_lookup(i,dpdTheta[i],tmp); uCond[i] = 0.0; @@ -233,7 +233,7 @@ void FixEOStableRXKokkos::post_integrate() template KOKKOS_INLINE_FUNCTION void FixEOStableRXKokkos::operator()(TagFixEOStableRXTemperatureLookup2, const int &i) const { - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { temperature_lookup(i,uCond[i]+uMech[i]+uChem[i],dpdTheta[i]); if (dpdTheta[i] <= 0.0) k_error_flag.template view()() = 1; @@ -314,7 +314,7 @@ void FixEOStableRXKokkos::energy_lookup(int id, double thetai, doubl nTotal = 1.0; } - for(int ispecies=0;ispecieslo); thetai = MAX(thetai,d_table_const.lo(ispecies)); @@ -364,7 +364,7 @@ void FixEOStableRXKokkos::temperature_lookup(int id, double ui, doub // Store the current thetai in t1 t1 = MAX(thetai,lo); t1 = MIN(t1,hi); - if(t1==hi) delta = -delta; + if (t1==hi) delta = -delta; // Compute u1 at thetai energy_lookup(id,t1,u1); @@ -382,9 +382,9 @@ void FixEOStableRXKokkos::temperature_lookup(int id, double ui, doub f2 = u2 - ui; // Apply the Secant Method - for(it=0; it()() = 2; + for (it=0; it()() = 2; temp = t1; temp = MAX(temp,lo); temp = MIN(temp,hi); @@ -392,15 +392,15 @@ void FixEOStableRXKokkos::temperature_lookup(int id, double ui, doub break; } temp = t2 - f2*(t2-t1)/(f2-f1); - if(fabs(temp-t2) < tolerance) break; + if (fabs(temp-t2) < tolerance) break; f1 = f2; t1 = t2; t2 = temp; energy_lookup(id,t2,u2); f2 = u2 - ui; } - if(it==maxit){ - if(std::isnan(f1) || std::isnan(f2) || std::isnan(ui) || std::isnan(thetai) || std::isnan(t1) || std::isnan(t2)) + if (it==maxit) { + if (std::isnan(f1) || std::isnan(f2) || std::isnan(ui) || std::isnan(thetai) || std::isnan(t1) || std::isnan(t2)) k_error_flag.template view()() = 2; else k_error_flag.template view()() = 3; @@ -440,7 +440,7 @@ void FixEOStableRXKokkos::unpack_forward_comm(int n, int first, doub m = 0; last = first + n ; - for (ii = first; ii < last; ii++){ + for (ii = first; ii < last; ii++) { h_uChem[ii] = buf[m++]; h_uCG[ii] = buf[m++]; h_uCGnew[ii] = buf[m++]; @@ -518,24 +518,24 @@ void FixEOStableRXKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->hi,h_table->hi,ntables,"Table::hi"); memoryKK->create_kokkos(d_table->invdelta,h_table->invdelta,ntables,"Table::invdelta"); - if(tabstyle == LINEAR) { + if (tabstyle == LINEAR) { memoryKK->create_kokkos(d_table->r,h_table->r,ntables,tablength,"Table::r"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tablength,"Table::e"); memoryKK->create_kokkos(d_table->de,h_table->de,ntables,tlm1,"Table::de"); } - for(int i=0; i < ntables; i++) { + for (int i=0; i < ntables; i++) { Table* tb = &tables[i]; h_table->lo[i] = tb->lo; h_table->hi[i] = tb->hi; h_table->invdelta[i] = tb->invdelta; - for(int j = 0; jr.extent(1); j++) + for (int j = 0; jr.extent(1); j++) h_table->r(i,j) = tb->r[j]; - for(int j = 0; je.extent(1); j++) + for (int j = 0; je.extent(1); j++) h_table->e(i,j) = tb->e[j]; - for(int j = 0; jde.extent(1); j++) + for (int j = 0; jde.extent(1); j++) h_table->de(i,j) = tb->de[j]; } diff --git a/src/KOKKOS/fix_langevin_kokkos.cpp b/src/KOKKOS/fix_langevin_kokkos.cpp index b5973e25a0..0dcaabb39c 100644 --- a/src/KOKKOS/fix_langevin_kokkos.cpp +++ b/src/KOKKOS/fix_langevin_kokkos.cpp @@ -61,7 +61,7 @@ FixLangevinKokkos::FixLangevinKokkos(LAMMPS *lmp, int narg, char **a for (int i = 1; i <= ntypes; i++) ratio[i] = 1.0; k_ratio.template modify(); - if(gjfflag){ + if (gjfflag) { grow_arrays(atomKK->nmax); atom->add_callback(Atom::GROW); // initialize franprev to zero @@ -76,7 +76,7 @@ FixLangevinKokkos::FixLangevinKokkos(LAMMPS *lmp, int narg, char **a k_franprev.template modify(); k_lv.template modify(); } - if(zeroflag){ + if (zeroflag) { k_fsumall = tdual_double_1d_3n("langevin:fsumall"); h_fsumall = k_fsumall.template view(); d_fsumall = k_fsumall.template view(); @@ -97,8 +97,8 @@ FixLangevinKokkos::~FixLangevinKokkos() memoryKK->destroy_kokkos(k_gfactor2,gfactor2); memoryKK->destroy_kokkos(k_ratio,ratio); memoryKK->destroy_kokkos(k_flangevin,flangevin); - if(gjfflag) memoryKK->destroy_kokkos(k_franprev,franprev); - if(gjfflag) memoryKK->destroy_kokkos(k_lv,lv); + if (gjfflag) memoryKK->destroy_kokkos(k_franprev,franprev); + if (gjfflag) memoryKK->destroy_kokkos(k_lv,lv); memoryKK->destroy_kokkos(k_tforce,tforce); } @@ -108,13 +108,13 @@ template void FixLangevinKokkos::init() { FixLangevin::init(); - if(oflag) + if (oflag) error->all(FLERR,"Fix langevin omega is not yet implemented with kokkos"); - if(ascale) + if (ascale) error->all(FLERR,"Fix langevin angmom is not yet implemented with kokkos"); - if(gjfflag && tbiasflag) + if (gjfflag && tbiasflag) error->all(FLERR,"Fix langevin gjf + tbias is not yet implemented with kokkos"); - if(gjfflag && tbiasflag) + if (gjfflag && tbiasflag) error->warning(FLERR,"Fix langevin gjf + kokkos is not implemented with random gaussians"); // prefactors are modified in the init @@ -182,8 +182,8 @@ void FixLangevinKokkos::post_force(int /*vflag*/) k_gfactor1.template sync(); k_gfactor2.template sync(); k_ratio.template sync(); - if(gjfflag) k_franprev.template sync(); - if(gjfflag) k_lv.template sync(); + if (gjfflag) k_franprev.template sync(); + if (gjfflag) k_lv.template sync(); boltz = force->boltz; dt = update->dt; @@ -217,7 +217,7 @@ void FixLangevinKokkos::post_force(int /*vflag*/) } // account for bias velocity - if(tbiasflag == BIAS){ + if (tbiasflag == BIAS) { atomKK->sync(temperature->execution_space,temperature->datamask_read); temperature->compute_scalar(); temperature->remove_bias_all(); // modifies velocities @@ -516,7 +516,7 @@ void FixLangevinKokkos::post_force(int /*vflag*/) } - if(tbiasflag == BIAS){ + if (tbiasflag == BIAS) { atomKK->sync(temperature->execution_space,temperature->datamask_read); temperature->restore_bias_all(); // modifies velocities atomKK->modified(temperature->execution_space,temperature->datamask_modify); @@ -566,8 +566,8 @@ FSUM FixLangevinKokkos::post_force_item(int i) const if (mask[i] & groupbit) { rand_type rand_gen = rand_pool.get_state(); - if(Tp_TSTYLEATOM) tsqrt_t = sqrt(d_tforce[i]); - if(Tp_RMASS){ + if (Tp_TSTYLEATOM) tsqrt_t = sqrt(d_tforce[i]); + if (Tp_RMASS) { gamma1 = -rmass[i] / t_period / ftm2v; gamma2 = sqrt(rmass[i]) * fran_prop_const / ftm2v; gamma1 *= 1.0/d_ratio[type[i]]; @@ -581,7 +581,7 @@ FSUM FixLangevinKokkos::post_force_item(int i) const fran[1] = gamma2 * (rand_gen.drand() - 0.5); //(random->uniform()-0.5); fran[2] = gamma2 * (rand_gen.drand() - 0.5); //(random->uniform()-0.5); - if(Tp_BIAS){ + if (Tp_BIAS) { fdrag[0] = gamma1*v(i,0); fdrag[1] = gamma1*v(i,1); fdrag[2] = gamma1*v(i,2); @@ -625,7 +625,7 @@ FSUM FixLangevinKokkos::post_force_item(int i) const f(i,2) += fdrag[2] + fran[2]; if (Tp_TALLY) { - if (Tp_GJF){ + if (Tp_GJF) { fdrag[0] = gamma1*d_lv(i,0)/gjfsib/gjfsib; fdrag[1] = gamma1*d_lv(i,1)/gjfsib/gjfsib; fdrag[2] = gamma1*d_lv(i,2)/gjfsib/gjfsib; @@ -794,7 +794,7 @@ void FixLangevinKokkos::end_of_step() FixLangevinKokkosTallyEnergyFunctor tally_functor(this); Kokkos::parallel_reduce(nlocal,tally_functor,energy_onestep); - if (gjfflag){ + if (gjfflag) { if (rmass.data()) { FixLangevinKokkosEndOfStepFunctor functor(this); Kokkos::parallel_for(nlocal,functor); @@ -817,7 +817,7 @@ void FixLangevinKokkos::end_of_step_item(int i) const { tmp[0] = v(i,0); tmp[1] = v(i,1); tmp[2] = v(i,2); - if (!osflag){ + if (!osflag) { v(i,0) = d_lv(i,0); v(i,1) = d_lv(i,1); v(i,2) = d_lv(i,2); @@ -848,7 +848,7 @@ void FixLangevinKokkos::end_of_step_rmass_item(int i) const tmp[0] = v(i,0); tmp[1] = v(i,1); tmp[2] = v(i,2); - if (!osflag){ + if (!osflag) { v(i,0) = d_lv(i,0); v(i,1) = d_lv(i,1); v(i,2) = d_lv(i,2); diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reax_kokkos.cpp index c96f5ded68..e81579061b 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reax_kokkos.cpp @@ -139,8 +139,8 @@ void FixQEqReaxKokkos::init_shielding_k() k_shield = DAT::tdual_ffloat_2d("qeq/kk:shield",ntypes+1,ntypes+1); d_shield = k_shield.template view(); - for( i = 1; i <= ntypes; ++i ) - for( j = 1; j <= ntypes; ++j ) + for ( i = 1; i <= ntypes; ++i ) + for ( j = 1; j <= ntypes; ++j ) k_shield.h_view(i,j) = pow( gamma[i] * gamma[j], -1.5 ); k_shield.template modify(); @@ -1053,7 +1053,7 @@ void FixQEqReaxKokkos::sparse13_item(int ii) const const int i = d_ilist[ii]; if (mask[i] & groupbit) { F_FLOAT tmp = 0.0; - for(int jj = d_firstnbr[i]; jj < d_firstnbr[i] + d_numnbrs[i]; jj++) { + for (int jj = d_firstnbr[i]; jj < d_firstnbr[i] + d_numnbrs[i]; jj++) { const int j = d_jlist(jj); tmp += d_val(jj) * d_s[j]; a_o[j] += d_val(jj) * d_s[i]; @@ -1106,7 +1106,7 @@ void FixQEqReaxKokkos::sparse23_item(int ii) const const int i = d_ilist[ii]; if (mask[i] & groupbit) { F_FLOAT tmp = 0.0; - for(int jj = d_firstnbr[i]; jj < d_firstnbr[i] + d_numnbrs[i]; jj++) { + for (int jj = d_firstnbr[i]; jj < d_firstnbr[i] + d_numnbrs[i]; jj++) { const int j = d_jlist(jj); tmp += d_val(jj) * d_d[j]; a_o[j] += d_val(jj) * d_d[i]; @@ -1166,7 +1166,7 @@ void FixQEqReaxKokkos::sparse33_item(int ii) const const int i = d_ilist[ii]; if (mask[i] & groupbit) { F_FLOAT tmp = 0.0; - for(int jj = d_firstnbr[i]; jj < d_firstnbr[i] + d_numnbrs[i]; jj++) { + for (int jj = d_firstnbr[i]; jj < d_firstnbr[i] + d_numnbrs[i]; jj++) { const int j = d_jlist(jj); tmp += d_val(jj) * d_t[j]; a_o[j] += d_val(jj) * d_t[i]; @@ -1371,11 +1371,11 @@ void FixQEqReaxKokkos::operator()(TagFixQEqReaxPackForwardComm, cons if (pack_flag == 1) d_buf[i] = d_d[j]; - else if( pack_flag == 2 ) + else if ( pack_flag == 2 ) d_buf[i] = d_s[j]; - else if( pack_flag == 3 ) + else if ( pack_flag == 3 ) d_buf[i] = d_t[j]; - else if( pack_flag == 4 ) + else if ( pack_flag == 4 ) d_buf[i] = q[j]; } @@ -1394,11 +1394,11 @@ KOKKOS_INLINE_FUNCTION void FixQEqReaxKokkos::operator()(TagFixQEqReaxUnpackForwardComm, const int &i) const { if (pack_flag == 1) d_d[i + first] = d_buf[i]; - else if( pack_flag == 2) + else if ( pack_flag == 2) d_s[i + first] = d_buf[i]; - else if( pack_flag == 3) + else if ( pack_flag == 3) d_t[i + first] = d_buf[i]; - else if( pack_flag == 4) + else if ( pack_flag == 4) q[i + first] = d_buf[i]; } @@ -1412,13 +1412,13 @@ int FixQEqReaxKokkos::pack_forward_comm(int n, int *list, double *bu int m; if (pack_flag == 1) - for(m = 0; m < n; m++) buf[m] = h_d[list[m]]; - else if( pack_flag == 2 ) - for(m = 0; m < n; m++) buf[m] = h_s[list[m]]; - else if( pack_flag == 3 ) - for(m = 0; m < n; m++) buf[m] = h_t[list[m]]; - else if( pack_flag == 4 ) - for(m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + for (m = 0; m < n; m++) buf[m] = h_d[list[m]]; + else if ( pack_flag == 2 ) + for (m = 0; m < n; m++) buf[m] = h_s[list[m]]; + else if ( pack_flag == 3 ) + for (m = 0; m < n; m++) buf[m] = h_t[list[m]]; + else if ( pack_flag == 4 ) + for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; return n; } @@ -1431,13 +1431,13 @@ void FixQEqReaxKokkos::unpack_forward_comm(int n, int first, double int i, m; if (pack_flag == 1) - for(m = 0, i = first; m < n; m++, i++) h_d[i] = buf[m]; - else if( pack_flag == 2) - for(m = 0, i = first; m < n; m++, i++) h_s[i] = buf[m]; - else if( pack_flag == 3) - for(m = 0, i = first; m < n; m++, i++) h_t[i] = buf[m]; - else if( pack_flag == 4) - for(m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) h_d[i] = buf[m]; + else if ( pack_flag == 2) + for (m = 0, i = first; m < n; m++, i++) h_s[i] = buf[m]; + else if ( pack_flag == 3) + for (m = 0, i = first; m < n; m++, i++) h_t[i] = buf[m]; + else if ( pack_flag == 4) + for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; } /* ---------------------------------------------------------------------- */ @@ -1446,7 +1446,7 @@ template int FixQEqReaxKokkos::pack_reverse_comm(int n, int first, double *buf) { int i, m; - for(m = 0, i = first; m < n; m++, i++) { + for (m = 0, i = first; m < n; m++, i++) { buf[m] = h_o[i]; } return n; @@ -1457,7 +1457,7 @@ int FixQEqReaxKokkos::pack_reverse_comm(int n, int first, double *bu template void FixQEqReaxKokkos::unpack_reverse_comm(int n, int *list, double *buf) { - for(int m = 0; m < n; m++) { + for (int m = 0; m < n; m++) { h_o[list[m]] += buf[m]; } } diff --git a/src/KOKKOS/fix_rx_kokkos.cpp b/src/KOKKOS/fix_rx_kokkos.cpp index 81ac590471..7a8bfbf9dd 100644 --- a/src/KOKKOS/fix_rx_kokkos.cpp +++ b/src/KOKKOS/fix_rx_kokkos.cpp @@ -130,7 +130,7 @@ void FixRxKokkos::init() bool eos_flag = false; for (int i = 0; i < modify->nfix; i++) if (utils::strmatch(modify->fix[i]->style,"^eos/table/rx")) eos_flag = true; - if(!eos_flag) error->all(FLERR,"fix rx requires fix eos/table/rx to be specified"); + if (!eos_flag) error->all(FLERR,"fix rx requires fix eos/table/rx to be specified"); if (update_kinetics_data) create_kinetics_data(); @@ -322,7 +322,7 @@ void FixRxKokkos::k_rkf45_step (const int neq, const double h, Vecto // 1) k_rhs (0.0, y, f1, userData); - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { f1[k] *= h; ytmp[k] = y[k] + c21 * f1[k]; } @@ -330,7 +330,7 @@ void FixRxKokkos::k_rkf45_step (const int neq, const double h, Vecto // 2) k_rhs(0.0, ytmp, f2, userData); - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { f2[k] *= h; ytmp[k] = y[k] + c31 * f1[k] + c32 * f2[k]; } @@ -429,7 +429,7 @@ int FixRxKokkos::k_rkf45_h0 (const int neq, const double t, const do // Compute WRMS norm of y'' double yddnrm = 0.0; - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { double ydd = (ydot1[k] - ydot[k]) / hg; double wterr = ydd / (relTol * fabs( y[k] ) + absTol); yddnrm += wterr * wterr; @@ -441,7 +441,7 @@ int FixRxKokkos::k_rkf45_h0 (const int neq, const double t, const do //std::cout << "ydot " << ydot[neq-1] << std::endl; // should we accept this? - if (hnew_is_ok || iter == max_iters){ + if (hnew_is_ok || iter == max_iters) { hnew = hg; //if (iter == max_iters) // fprintf(stderr, "ERROR_HIN_MAX_ITERS\n"); @@ -510,7 +510,7 @@ void FixRxKokkos::k_rkf45(const int neq, const double t_stop, Vector double t = 0.0; - if (h < h_min){ + if (h < h_min) { //fprintf(stderr,"hin not implemented yet\n"); //exit(-1); nfe = k_rkf45_h0 (neq, t, t_stop, h_min, h_max, h, y, rwork, userData); @@ -530,7 +530,7 @@ void FixRxKokkos::k_rkf45(const int neq, const double t_stop, Vector // Estimate the solution error. // ... weighted 2-norm of the error. double err2 = 0.0; - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { const double wterr = eout[k] / (relTol * fabs( y[k] ) + absTol); err2 += wterr * wterr; } @@ -538,7 +538,7 @@ void FixRxKokkos::k_rkf45(const int neq, const double t_stop, Vector double err = fmax( uround, sqrt( err2 / double(nspecies) )); // Accept the solution? - if (err <= 1.0 || h <= h_min){ + if (err <= 1.0 || h <= h_min) { t += h; nst++; @@ -571,7 +571,7 @@ void FixRxKokkos::k_rkf45(const int neq, const double t_stop, Vector nit++; nfe += 6; - if (maxIters && nit > maxIters){ + if (maxIters && nit > maxIters) { //fprintf(stderr,"atom[%d] took too many iterations in rkf45 %d %e %e\n", id, nit, t, t_stop); counter.nFails ++; break; @@ -643,7 +643,7 @@ void FixRxKokkos::rkf45_step (const int neq, const double h, double // 1) rhs (0.0, y, f1, v_param); - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { f1[k] *= h; ytmp[k] = y[k] + c21 * f1[k]; } @@ -651,7 +651,7 @@ void FixRxKokkos::rkf45_step (const int neq, const double h, double // 2) rhs(0.0, ytmp, f2, v_param); - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { f2[k] *= h; ytmp[k] = y[k] + c31 * f1[k] + c32 * f2[k]; } @@ -748,7 +748,7 @@ int FixRxKokkos::rkf45_h0(const int neq, const double t, const doubl // Compute WRMS norm of y'' double yddnrm = 0.0; - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { double ydd = (ydot1[k] - ydot[k]) / hg; double wterr = ydd / (relTol * fabs( y[k] ) + absTol); yddnrm += wterr * wterr; @@ -760,7 +760,7 @@ int FixRxKokkos::rkf45_h0(const int neq, const double t, const doubl //std::cout << "ydot " << ydot[neq-1] << std::endl; // should we accept this? - if (hnew_is_ok || iter == max_iters){ + if (hnew_is_ok || iter == max_iters) { hnew = hg; if (iter == max_iters) fprintf(stderr, "ERROR_HIN_MAX_ITERS\n"); @@ -827,7 +827,7 @@ void FixRxKokkos::rkf45(const int neq, const double t_stop, double * double t = 0.0; - if (h < h_min){ + if (h < h_min) { //fprintf(stderr,"hin not implemented yet\n"); //exit(-1); nfe = rkf45_h0 (neq, t, t_stop, h_min, h_max, h, y, rwork, v_param); @@ -836,7 +836,7 @@ void FixRxKokkos::rkf45(const int neq, const double t_stop, double * //printf("t= %e t_stop= %e h= %e\n", t, t_stop, h); // Integrate until we reach the end time. - while (fabs(t - t_stop) > tround){ + while (fabs(t - t_stop) > tround) { double *yout = rwork; double *eout = yout + neq; @@ -846,7 +846,7 @@ void FixRxKokkos::rkf45(const int neq, const double t_stop, double * // Estimate the solution error. // ... weighted 2-norm of the error. double err2 = 0.0; - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { const double wterr = eout[k] / (relTol * fabs( y[k] ) + absTol); err2 += wterr * wterr; } @@ -854,7 +854,7 @@ void FixRxKokkos::rkf45(const int neq, const double t_stop, double * double err = fmax( uround, sqrt( err2 / double(nspecies) )); // Accept the solution? - if (err <= 1.0 || h <= h_min){ + if (err <= 1.0 || h <= h_min) { t += h; nst++; @@ -887,7 +887,7 @@ void FixRxKokkos::rkf45(const int neq, const double t_stop, double * nit++; nfe += 6; - if (maxIters && nit > maxIters){ + if (maxIters && nit > maxIters) { //fprintf(stderr,"atom[%d] took too many iterations in rkf45 %d %e %e\n", id, nit, t, t_stop); counter.nFails ++; break; @@ -928,14 +928,14 @@ int FixRxKokkos::rhs_dense(double /*t*/, const double *y, double *dy //const double VDPD = domain->xprd * domain->yprd * domain->zprd / atom->natoms; //const int nspecies = atom->nspecies_dpd; - for(int ispecies=0; ispecies::rhs_dense(double /*t*/, const double *y, double *dy } // Construct the reaction rates for each species - for(int ispecies=0; ispecies::rhs_sparse(double /*t*/, const double *y, double *d for (int i = 0; i < nreactions; ++i) { double rxnRateLawForward; - if (isIntegral(i)){ + if (isIntegral(i)) { rxnRateLawForward = kFor[i] * powint( conc[ nuk(i,0) ], inu(i,0) ); - for (int kk = 1; kk < maxReactants; ++kk){ + for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -992,7 +992,7 @@ int FixRxKokkos::rhs_sparse(double /*t*/, const double *y, double *d } } else { rxnRateLawForward = kFor[i] * pow( conc[ nuk(i,0) ], nu(i,0) ); - for (int kk = 1; kk < maxReactants; ++kk){ + for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1008,10 +1008,10 @@ int FixRxKokkos::rhs_sparse(double /*t*/, const double *y, double *d for (int k = 0; k < nspecies; ++k) dydt[k] = 0.0; - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { // Reactants ... dydt[ nuk(i,0) ] -= nu(i,0) * rxnRateLaw[i]; - for (int kk = 1; kk < maxReactants; ++kk){ + for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1020,7 +1020,7 @@ int FixRxKokkos::rhs_sparse(double /*t*/, const double *y, double *d // Products ... dydt[ nuk(i,maxReactants) ] += nu(i,maxReactants) * rxnRateLaw[i]; - for (int kk = maxReactants+1; kk < maxSpecies; ++kk){ + for (int kk = maxReactants+1; kk < maxSpecies; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1074,14 +1074,14 @@ int FixRxKokkos::k_rhs_dense(double /*t*/, const VectorType& y, Vect //const double VDPD = domain->xprd * domain->yprd * domain->zprd / atom->natoms; //const int nspecies = atom->nspecies_dpd; - for(int ispecies=0; ispecies::k_rhs_dense(double /*t*/, const VectorType& y, Vect } // Construct the reaction rates for each species - for(int ispecies=0; ispecies::k_rhs_sparse(double /*t*/, const VectorType& y, Vec for (int i = 0; i < nreactions; ++i) { double rxnRateLawForward; - if (isIntegral(i)){ + if (isIntegral(i)) { rxnRateLawForward = kFor[i] * powint( conc[ nuk(i,0) ], inu(i,0) ); - for (int kk = 1; kk < maxReactants; ++kk){ + for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1139,7 +1139,7 @@ int FixRxKokkos::k_rhs_sparse(double /*t*/, const VectorType& y, Vec } } else { rxnRateLawForward = kFor[i] * pow( conc[ nuk(i,0) ], nu(i,0) ); - for (int kk = 1; kk < maxReactants; ++kk){ + for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1155,10 +1155,10 @@ int FixRxKokkos::k_rhs_sparse(double /*t*/, const VectorType& y, Vec for (int k = 0; k < nspecies; ++k) dydt[k] = 0.0; - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { // Reactants ... dydt[ nuk(i,0) ] -= nu(i,0) * rxnRateLaw[i]; - for (int kk = 1; kk < maxReactants; ++kk){ + for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1167,7 +1167,7 @@ int FixRxKokkos::k_rhs_sparse(double /*t*/, const VectorType& y, Vec // Products ... dydt[ nuk(i,maxReactants) ] += nu(i,maxReactants) * rxnRateLaw[i]; - for (int kk = maxReactants+1; kk < maxSpecies; ++kk){ + for (int kk = maxReactants+1; kk < maxSpecies; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1686,7 +1686,7 @@ void FixRxKokkos::solve_reactions(const int /*vflag*/, const bool is // getElapsedTime(timer_ODE, timer_stop), nlocal, TotalCounters.nFuncs, TotalCounters.nSteps); // Warn the user if a failure was detected in the ODE solver. - if (TotalCounters.nFails > 0){ + if (TotalCounters.nFails > 0) { char sbuf[128]; sprintf(sbuf,"in FixRX::pre_force, ODE solver failed for %d atoms.", TotalCounters.nFails); error->warning(FLERR, sbuf); @@ -1752,7 +1752,7 @@ void FixRxKokkos::odeDiagnostics(void) double min_per_proc[numCounters]; // Compute counters per dpd time-step. - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { my_vals[i] = this->diagnosticCounter[i] / nTimes; //printf("my sum[%d] = %f %d\n", i, my_vals[i], comm->me); } @@ -1767,7 +1767,7 @@ void FixRxKokkos::odeDiagnostics(void) double avg_per_atom[numCounters], avg_per_proc[numCounters]; // Averages per-ODE and per-proc per time-step. - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { avg_per_atom[i] = sums[i] / nODEs; avg_per_proc[i] = sums[i] / comm->nprocs; } @@ -1775,7 +1775,7 @@ void FixRxKokkos::odeDiagnostics(void) // Sum up the differences from each task. double sum_sq[2*numCounters]; double my_sum_sq[2*numCounters]; - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { double diff_i = my_vals[i] - avg_per_proc[i]; my_sum_sq[i] = diff_i * diff_i; } @@ -1835,7 +1835,7 @@ void FixRxKokkos::odeDiagnostics(void) TimerType timer_stop = getTimeStamp(); double time_local = getElapsedTime( timer_start, timer_stop ); - if (comm->me == 0){ + if (comm->me == 0) { char smesg[128]; #define print_mesg(smesg) {\ @@ -1849,7 +1849,7 @@ void FixRxKokkos::odeDiagnostics(void) print_mesg(smesg); // only valid for single time-step! - if (diagnosticFrequency == 1){ + if (diagnosticFrequency == 1) { double rms_per_ODE[numCounters]; for (int i = 0; i < numCounters; ++i) rms_per_ODE[i] = sqrt( sum_sq[i+numCounters] / nODEs ); @@ -1867,7 +1867,7 @@ void FixRxKokkos::odeDiagnostics(void) sprintf(smesg, " AVG per Proc : %-12.5g | %-12.5g | %-12.5g | %-12.5g", avg_per_proc[StepSum], avg_per_proc[FuncSum], avg_per_proc[TimeSum], avg_per_proc[AtomSum]); print_mesg(smesg); - if (comm->nprocs > 1){ + if (comm->nprocs > 1) { double rms_per_proc[numCounters]; for (int i = 0; i < numCounters; ++i) rms_per_proc[i] = sqrt( sum_sq[i] / comm->nprocs ); @@ -2206,7 +2206,7 @@ int FixRxKokkos::pack_forward_comm(int n, int *list, double *buf, in int m = 0; for (int ii = 0; ii < n; ii++) { const int jj = list[ii]; - for(int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { buf[m++] = h_dvector(ispecies,jj); buf[m++] = h_dvector(ispecies+nspecies,jj); } @@ -2228,8 +2228,8 @@ void FixRxKokkos::unpack_forward_comm(int n, int first, double *buf) const int last = first + n ; int m = 0; - for (int ii = first; ii < last; ii++){ - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ii = first; ii < last; ii++) { + for (int ispecies = 0; ispecies < nspecies; ispecies++) { h_dvector(ispecies,ii) = buf[m++]; h_dvector(ispecies+nspecies,ii) = buf[m++]; } diff --git a/src/KOKKOS/fix_shardlow_kokkos.cpp b/src/KOKKOS/fix_shardlow_kokkos.cpp index 564c405894..d8c4931e0e 100644 --- a/src/KOKKOS/fix_shardlow_kokkos.cpp +++ b/src/KOKKOS/fix_shardlow_kokkos.cpp @@ -79,7 +79,7 @@ FixShardlowKokkos::FixShardlowKokkos(LAMMPS *lmp, int narg, char **a // k_pairDPD = (PairDPDfdtKokkos *) force->pair_match("dpd/fdt",1); k_pairDPDE = dynamic_cast *>(force->pair_match("dpd/fdt/energy",0)); -// if(k_pairDPDE){ +// if (k_pairDPDE) { comm_forward = 3; comm_reverse = 5; // } else { @@ -88,7 +88,7 @@ FixShardlowKokkos::FixShardlowKokkos(LAMMPS *lmp, int narg, char **a // } - if(/* k_pairDPD == nullptr &&*/ k_pairDPDE == nullptr) + if (/* k_pairDPD == nullptr &&*/ k_pairDPDE == nullptr) error->all(FLERR,"Must use pair_style "/*"dpd/fdt/kk or "*/"dpd/fdt/energy/kk with fix shardlow/kk"); #ifdef DEBUG_SSA_PAIR_CT @@ -160,7 +160,7 @@ void FixShardlowKokkos::init() k_params.h_view(j,i) = k_params.h_view(i,j); - if(ik_cutsq.h_view(i,j); } @@ -196,7 +196,7 @@ void FixShardlowKokkos::pre_neighbor() if (domain->triclinic) error->all(FLERR,"Fix shardlow does not yet support triclinic geometries"); - if(rcut >= bbx || rcut >= bby || rcut>= bbz ) + if (rcut >= bbx || rcut >= bby || rcut>= bbz ) { char fmt[] = {"Shardlow algorithm requires sub-domain length > 2*(rcut+skin). Either reduce the number of processors requested, or change the cutoff/skin: rcut= %e bbx= %e bby= %e bbz= %e\n"}; char *msg = (char *) malloc(sizeof(fmt) + 4*15); @@ -231,7 +231,7 @@ void FixShardlowKokkos::pre_neighbor() massPerI = false; masses = atomKK->k_mass.view(); } -// if(k_pairDPDE){ +// if (k_pairDPDE) { dpdTheta = atomKK->k_dpdTheta.view(); //} else { @@ -632,7 +632,7 @@ void FixShardlowKokkos::initial_integrate(int /*vflag*/) for (workPhase = 0; workPhase < ssa_phaseCt; ++workPhase) { int workItemCt = h_ssa_phaseLen[workPhase]; - if(atom->ntypes > MAX_TYPES_STACKPARAMS) + if (atom->ntypes > MAX_TYPES_STACKPARAMS) Kokkos::parallel_for(Kokkos::RangePolicy >(0,workItemCt),*this); else Kokkos::parallel_for(Kokkos::RangePolicy >(0,workItemCt),*this); @@ -649,7 +649,7 @@ void FixShardlowKokkos::initial_integrate(int /*vflag*/) comm->forward_comm_fix(this); atomKK->modified(Host,V_MASK); - if(k_pairDPDE){ + if (k_pairDPDE) { // Zero out the ghosts' uCond & uMech to be used as delta accumulators // memset(&(atom->uCond[nlocal]), 0, sizeof(double)*nghost); // memset(&(atom->uMech[nlocal]), 0, sizeof(double)*nghost); @@ -667,7 +667,7 @@ void FixShardlowKokkos::initial_integrate(int /*vflag*/) // process neighbors in this AIR atomKK->sync(execution_space,X_MASK | V_MASK | TYPE_MASK | RMASS_MASK | UCOND_MASK | UMECH_MASK | DPDTHETA_MASK); - if(atom->ntypes > MAX_TYPES_STACKPARAMS) + if (atom->ntypes > MAX_TYPES_STACKPARAMS) Kokkos::parallel_for(Kokkos::RangePolicy >(0,workItemCt),*this); else Kokkos::parallel_for(Kokkos::RangePolicy >(0,workItemCt),*this); @@ -759,7 +759,7 @@ int FixShardlowKokkos::pack_reverse_comm(int n, int first, double *b buf[m++] = h_v(i, 0) - h_v_t0(i - nlocal, 0); buf[m++] = h_v(i, 1) - h_v_t0(i - nlocal, 1); buf[m++] = h_v(i, 2) - h_v_t0(i - nlocal, 2); - if(k_pairDPDE){ + if (k_pairDPDE) { buf[m++] = h_uCond(i); // for ghosts, this is an accumulated delta buf[m++] = h_uMech(i); // for ghosts, this is an accumulated delta } @@ -781,7 +781,7 @@ void FixShardlowKokkos::unpack_reverse_comm(int n, int *list, double h_v(j, 0) += buf[m++]; h_v(j, 1) += buf[m++]; h_v(j, 2) += buf[m++]; - if(k_pairDPDE){ + if (k_pairDPDE) { h_uCond(j) += buf[m++]; // add in the accumulated delta h_uMech(j) += buf[m++]; // add in the accumulated delta } diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index ff1b736bf0..6a1059490f 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -237,7 +237,7 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) gpu_aware_flag = 0; char* str; if ((str = getenv("OMPI_MCA_pml_pami_enable_cuda"))) - if((strcmp(str,"1") == 0)) { + if ((strcmp(str,"1") == 0)) { have_gpu_aware = 1; gpu_aware_flag = 1; } diff --git a/src/KOKKOS/nbin_kokkos.cpp b/src/KOKKOS/nbin_kokkos.cpp index 712ea345cf..8234ceea6f 100644 --- a/src/KOKKOS/nbin_kokkos.cpp +++ b/src/KOKKOS/nbin_kokkos.cpp @@ -111,7 +111,7 @@ void NBinKokkos::bin_atoms() Kokkos::parallel_for(atom->nlocal+atom->nghost, f); deep_copy(h_resize, d_resize); - if(h_resize()) { + if (h_resize()) { atoms_per_bin += 16; k_bins = DAT::tdual_int_2d("bins", mbins, atoms_per_bin); @@ -135,7 +135,7 @@ void NBinKokkos::binatomsItem(const int &i) const atom2bin(i) = ibin; const int ac = Kokkos::atomic_fetch_add(&bincount[ibin], (int)1); - if(ac < (int)bins.extent(1)) { + if (ac < (int)bins.extent(1)) { bins(ibin, ac) = i; } else { d_resize() = 1; diff --git a/src/KOKKOS/nbin_ssa_kokkos.cpp b/src/KOKKOS/nbin_ssa_kokkos.cpp index 8c9ccb5f59..276c3bee36 100644 --- a/src/KOKKOS/nbin_ssa_kokkos.cpp +++ b/src/KOKKOS/nbin_ssa_kokkos.cpp @@ -156,7 +156,7 @@ void NBinSSAKokkos::bin_atoms() // actually bin the ghost atoms { - if(ghosts_per_gbin > (int) gbins.extent(1)) { + if (ghosts_per_gbin > (int) gbins.extent(1)) { k_gbins = DAT::tdual_int_2d("gbins", 8, ghosts_per_gbin); gbins = k_gbins.view(); } diff --git a/src/KOKKOS/neighbor_kokkos.cpp b/src/KOKKOS/neighbor_kokkos.cpp index 5417386a17..5394929e73 100644 --- a/src/KOKKOS/neighbor_kokkos.cpp +++ b/src/KOKKOS/neighbor_kokkos.cpp @@ -329,7 +329,7 @@ void NeighborKokkos::operator()(TagNeighborXhold, const int &i) cons /* ---------------------------------------------------------------------- */ -void NeighborKokkos::modify_ex_type_grow_kokkos(){ +void NeighborKokkos::modify_ex_type_grow_kokkos() { memoryKK->grow_kokkos(k_ex1_type,ex1_type,maxex_type,"neigh:ex1_type"); k_ex1_type.modify(); memoryKK->grow_kokkos(k_ex2_type,ex2_type,maxex_type,"neigh:ex2_type"); @@ -337,7 +337,7 @@ void NeighborKokkos::modify_ex_type_grow_kokkos(){ } /* ---------------------------------------------------------------------- */ -void NeighborKokkos::modify_ex_group_grow_kokkos(){ +void NeighborKokkos::modify_ex_group_grow_kokkos() { memoryKK->grow_kokkos(k_ex1_group,ex1_group,maxex_group,"neigh:ex1_group"); k_ex1_group.modify(); memoryKK->grow_kokkos(k_ex2_group,ex2_group,maxex_group,"neigh:ex2_group"); @@ -345,13 +345,13 @@ void NeighborKokkos::modify_ex_group_grow_kokkos(){ } /* ---------------------------------------------------------------------- */ -void NeighborKokkos::modify_mol_group_grow_kokkos(){ +void NeighborKokkos::modify_mol_group_grow_kokkos() { memoryKK->grow_kokkos(k_ex_mol_group,ex_mol_group,maxex_mol,"neigh:ex_mol_group"); k_ex_mol_group.modify(); } /* ---------------------------------------------------------------------- */ -void NeighborKokkos::modify_mol_intra_grow_kokkos(){ +void NeighborKokkos::modify_mol_intra_grow_kokkos() { memoryKK->grow_kokkos(k_ex_mol_intra,ex_mol_intra,maxex_mol,"neigh:ex_mol_intra"); k_ex_mol_intra.modify(); } diff --git a/src/KOKKOS/npair_kokkos.cpp b/src/KOKKOS/npair_kokkos.cpp index f7e8c0e82d..564e1b0b98 100644 --- a/src/KOKKOS/npair_kokkos.cpp +++ b/src/KOKKOS/npair_kokkos.cpp @@ -303,7 +303,7 @@ void NPairKokkos::build(NeighList *list_) } Kokkos::deep_copy(h_scalars, d_scalars); - if(data.h_resize()) { + if (data.h_resize()) { list->maxneighs = data.h_new_maxneighs() * 1.2; list->d_neighbors = typename AT::t_neighbors_2d(Kokkos::NoInit("neighbors"), list->d_neighbors.extent(0), list->maxneighs); data.neigh_list.d_neighbors = list->d_neighbors; @@ -410,24 +410,24 @@ void NeighborKokkosExecute:: = d_stencil; // loop over all bins in neighborhood (includes ibin) - if(HalfNeigh) - for(int m = 0; m < c_bincount(ibin); m++) { + if (HalfNeigh) + for (int m = 0; m < c_bincount(ibin); m++) { const int j = c_bins(ibin,m); const int jtype = type(j); //for same bin as atom i skip j if i==j and skip atoms "below and to the left" if using HalfNeighborlists - if((j == i) || (HalfNeigh && !Newton && (j < i)) || + if ((j == i) || (HalfNeigh && !Newton && (j < i)) || (HalfNeigh && Newton && ((j < i) || ((j >= nlocal) && ((x(j, 2) < ztmp) || (x(j, 2) == ztmp && x(j, 1) < ytmp) || (x(j, 2) == ztmp && x(j, 1) == ytmp && x(j, 0) < xtmp))))) ) continue; - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); const X_FLOAT dely = ytmp - x(j, 1); const X_FLOAT delz = ztmp - x(j, 2); const X_FLOAT rsq = delx * delx + dely * dely + delz * delz; - if(rsq <= cutneighsq(itype,jtype)) { + if (rsq <= cutneighsq(itype,jtype)) { if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(i,j); @@ -436,38 +436,38 @@ void NeighborKokkosExecute:: /* onemols[imol]->nspecial[iatom], */ /* tag[j]-tagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n::t_int_1d_const_um =Kokkos::subview(bins,jbin,ALL); - for(int m = 0; m < c_bincount(jbin); m++) { + for (int m = 0; m < c_bincount(jbin); m++) { const int j = c_bins(jbin,m); const int jtype = type(j); - if(HalfNeigh && !Newton && (j < i)) continue; - if(!HalfNeigh && j==i) continue; - if(Tri) { + if (HalfNeigh && !Newton && (j < i)) continue; + if (!HalfNeigh && j==i) continue; + if (Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -477,14 +477,14 @@ void NeighborKokkosExecute:: } } } - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); const X_FLOAT dely = ytmp - x(j, 1); const X_FLOAT delz = ztmp - x(j, 2); const X_FLOAT rsq = delx * delx + dely * dely + delz * delz; - if(rsq <= cutneighsq(itype,jtype)) { + if (rsq <= cutneighsq(itype,jtype)) { if (molecular != Atom::ATOMIC) { if (!moltemplate) which = NeighborKokkosExecute::find_special(i,j); @@ -493,19 +493,19 @@ void NeighborKokkosExecute:: /* onemols[imol]->nspecial[iatom], */ /* tag[j]-tagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n:: neigh_list.d_numneigh(i) = n; - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop + if (n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop } neigh_list.d_ilist(i) = i; @@ -562,7 +562,7 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli const int ibin = dev.league_rank()*BINS_PER_TEAM+MY_BIN; - if(ibin >= mbins) return; + if (ibin >= mbins) return; X_FLOAT* other_x = sharedmem; other_x = other_x + 5*atoms_per_bin*MY_BIN; @@ -570,7 +570,7 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli int bincount_current = c_bincount[ibin]; - for(int kk = 0; kk < TEAMS_PER_BIN; kk++) { + for (int kk = 0; kk < TEAMS_PER_BIN; kk++) { const int MY_II = dev.team_rank()%atoms_per_bin+kk*dev.team_size(); const int i = MY_II < bincount_current ? c_bins(ibin, MY_II) : -1; /* if necessary, goto next page and add pages */ @@ -583,7 +583,7 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli int itype; const AtomNeighbors neighbors_i = neigh_list.get_neighbors((i>=0&&i= 0) { + if (i >= 0) { xtmp = x(i, 0); ytmp = x(i, 1); ztmp = x(i, 2); @@ -596,23 +596,23 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli other_id[MY_II] = i; int test = (__syncthreads_count(i >= 0 && i <= nlocal) == 0); - if(test) return; + if (test) return; - if(i >= 0 && i < nlocal) { + if (i >= 0 && i < nlocal) { #pragma unroll 4 - for(int m = 0; m < bincount_current; m++) { + for (int m = 0; m < bincount_current; m++) { int j = other_id[m]; const int jtype = other_x[m + 3 * atoms_per_bin]; //for same bin as atom i skip j if i==j and skip atoms "below and to the left" if using halfneighborlists - if((j == i) || + if ((j == i) || (HalfNeigh && !Newton && (j < i)) || (HalfNeigh && Newton && ((j < i) || ((j >= nlocal) && ((x(j, 2) < ztmp) || (x(j, 2) == ztmp && x(j, 1) < ytmp) || (x(j, 2) == ztmp && x(j, 1) == ytmp && x(j, 0) < xtmp))))) ) continue; - if(Tri) { + if (Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -622,13 +622,13 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli } } } - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - other_x[m]; const X_FLOAT dely = ytmp - other_x[m + atoms_per_bin]; const X_FLOAT delz = ztmp - other_x[m + 2 * atoms_per_bin]; const X_FLOAT rsq = delx * delx + dely * dely + delz * delz; - if(rsq <= cutneighsq(itype,jtype)) { + if (rsq <= cutneighsq(itype,jtype)) { if (molecular != Atom::ATOMIC) { int which = 0; if (!moltemplate) @@ -638,19 +638,19 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli /* onemols[imol]->nspecial[iatom], */ /* tag[j]-tagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n::build_ItemCuda(typename Kokkos::TeamPoli const typename ArrayTypes::t_int_1d_const_um stencil = d_stencil; - for(int k = 0; k < nstencil; k++) { + for (int k = 0; k < nstencil; k++) { const int jbin = ibin + stencil[k]; - if(ibin == jbin) continue; + if (ibin == jbin) continue; bincount_current = c_bincount[jbin]; int j = MY_II < bincount_current ? c_bins(jbin, MY_II) : -1; - if(j >= 0) { + if (j >= 0) { other_x[MY_II] = x(j, 0); other_x[MY_II + atoms_per_bin] = x(j, 1); other_x[MY_II + 2 * atoms_per_bin] = x(j, 2); @@ -680,16 +680,16 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli __syncthreads(); - if(i >= 0 && i < nlocal) { + if (i >= 0 && i < nlocal) { #pragma unroll 8 - for(int m = 0; m < bincount_current; m++) { + for (int m = 0; m < bincount_current; m++) { const int j = other_id[m]; const int jtype = other_x[m + 3 * atoms_per_bin]; //if(HalfNeigh && (j < i)) continue; - if(HalfNeigh && !Newton && (j < i)) continue; - if(!HalfNeigh && j==i) continue; - if(Tri) { + if (HalfNeigh && !Newton && (j < i)) continue; + if (!HalfNeigh && j==i) continue; + if (Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -699,14 +699,14 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli } } } - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - other_x[m]; const X_FLOAT dely = ytmp - other_x[m + atoms_per_bin]; const X_FLOAT delz = ztmp - other_x[m + 2 * atoms_per_bin]; const X_FLOAT rsq = delx * delx + dely * dely + delz * delz; - if(rsq <= cutneighsq(itype,jtype)) { + if (rsq <= cutneighsq(itype,jtype)) { if (molecular != Atom::ATOMIC) { int which = 0; if (!moltemplate) @@ -716,19 +716,19 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli /* onemols[imol]->nspecial[iatom], */ /* tag[j]-tagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n::build_ItemCuda(typename Kokkos::TeamPoli __syncthreads(); } - if(i >= 0 && i < nlocal) { + if (i >= 0 && i < nlocal) { neigh_list.d_numneigh(i) = n; neigh_list.d_ilist(i) = i; } - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop + if (n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop } } } @@ -787,14 +787,14 @@ void NeighborKokkosExecute:: const int ibin = c_atom2bin(i); for (int k = 0; k < nstencil; k++) { const int jbin = ibin + stencil[k]; - for(int m = 0; m < c_bincount(jbin); m++) { + for (int m = 0; m < c_bincount(jbin); m++) { const int j = c_bins(jbin,m); if (HalfNeigh && j <= i) continue; else if (j == i) continue; const int jtype = type[j]; - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j,0); const X_FLOAT dely = ytmp - x(j,1); @@ -810,19 +810,19 @@ void NeighborKokkosExecute:: /* onemols[imol]->nspecial[iatom], */ /* tag[j]-tagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n:: ybin2 < 0 || ybin2 >= mbiny || zbin2 < 0 || zbin2 >= mbinz) continue; const int jbin = ibin + stencil[k]; - for(int m = 0; m < c_bincount(jbin); m++) { + for (int m = 0; m < c_bincount(jbin); m++) { const int j = c_bins(jbin,m); if (HalfNeigh && j <= i) continue; else if (j == i) continue; const int jtype = type[j]; - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j,0); const X_FLOAT dely = ytmp - x(j,1); @@ -858,7 +858,7 @@ void NeighborKokkosExecute:: const X_FLOAT rsq = delx*delx + dely*dely + delz*delz; if (rsq <= cutneighsq(itype,jtype)) { - if(n:: neigh_list.d_numneigh(i) = n; - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop + if (n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop } neigh_list.d_ilist(i) = i; } @@ -902,18 +902,18 @@ void NeighborKokkosExecute:: const int mask_history = 3 << SBBITS; // loop over all bins in neighborhood (includes ibin) - if(HalfNeigh) - for(int m = 0; m < c_bincount(ibin); m++) { + if (HalfNeigh) + for (int m = 0; m < c_bincount(ibin); m++) { const int j = c_bins(ibin,m); const int jtype = type(j); //for same bin as atom i skip j if i==j and skip atoms "below and to the left" if using HalfNeighborlists - if((j == i) || (HalfNeigh && !Newton && (j < i)) || + if ((j == i) || (HalfNeigh && !Newton && (j < i)) || (HalfNeigh && Newton && ((j < i) || ((j >= nlocal) && ((x(j, 2) < ztmp) || (x(j, 2) == ztmp && x(j, 1) < ytmp) || (x(j, 2) == ztmp && x(j, 1) == ytmp && x(j, 0) < xtmp))))) ) continue; - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); const X_FLOAT dely = ytmp - x(j, 1); @@ -922,29 +922,29 @@ void NeighborKokkosExecute:: const X_FLOAT radsum = radi + radius(j); const X_FLOAT cutsq = (radsum + skin) * (radsum + skin); - if(rsq <= cutsq) { - if(n::t_int_1d_const_um =Kokkos::subview(bins,jbin,ALL); - for(int m = 0; m < c_bincount(jbin); m++) { + for (int m = 0; m < c_bincount(jbin); m++) { const int j = c_bins(jbin,m); const int jtype = type(j); - if(HalfNeigh && !Newton && (j < i)) continue; - if(!HalfNeigh && j==i) continue; - if(Tri) { + if (HalfNeigh && !Newton && (j < i)) continue; + if (!HalfNeigh && j==i) continue; + if (Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -954,7 +954,7 @@ void NeighborKokkosExecute:: } } } - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); const X_FLOAT dely = ytmp - x(j, 1); @@ -963,9 +963,9 @@ void NeighborKokkosExecute:: const X_FLOAT radsum = radi + radius(j); const X_FLOAT cutsq = (radsum + skin) * (radsum + skin); - if(rsq <= cutsq) { - if(n:: neigh_list.d_numneigh(i) = n; - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop + if (n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop } neigh_list.d_ilist(i) = i; @@ -1005,7 +1005,7 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team const int ibin = dev.league_rank()*BINS_PER_TEAM+MY_BIN; - if(ibin >= mbins) return; + if (ibin >= mbins) return; X_FLOAT* other_x = sharedmem; other_x = other_x + 6*atoms_per_bin*MY_BIN; @@ -1013,7 +1013,7 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team int bincount_current = c_bincount[ibin]; - for(int kk = 0; kk < TEAMS_PER_BIN; kk++) { + for (int kk = 0; kk < TEAMS_PER_BIN; kk++) { const int MY_II = dev.team_rank()%atoms_per_bin+kk*dev.team_size(); const int i = MY_II < bincount_current ? c_bins(ibin, MY_II) : -1; /* if necessary, goto next page and add pages */ @@ -1028,7 +1028,7 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team const AtomNeighbors neighbors_i = neigh_list.get_neighbors((i>=0&&i= 0) { + if (i >= 0) { xtmp = x(i, 0); ytmp = x(i, 1); ztmp = x(i, 2); @@ -1043,23 +1043,23 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team other_id[MY_II] = i; int test = (__syncthreads_count(i >= 0 && i <= nlocal) == 0); - if(test) return; + if (test) return; - if(i >= 0 && i < nlocal) { + if (i >= 0 && i < nlocal) { #pragma unroll 4 - for(int m = 0; m < bincount_current; m++) { + for (int m = 0; m < bincount_current; m++) { int j = other_id[m]; const int jtype = other_x[m + 3 * atoms_per_bin]; //for same bin as atom i skip j if i==j and skip atoms "below and to the left" if using halfneighborlists - if((j == i) || + if ((j == i) || (HalfNeigh && !Newton && (j < i)) || (HalfNeigh && Newton && ((j < i) || ((j >= nlocal) && ((x(j, 2) < ztmp) || (x(j, 2) == ztmp && x(j, 1) < ytmp) || (x(j, 2) == ztmp && x(j, 1) == ytmp && x(j, 0) < xtmp))))) ) continue; - if(Tri) { + if (Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -1069,7 +1069,7 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team } } } - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - other_x[m]; const X_FLOAT dely = ytmp - other_x[m + atoms_per_bin]; const X_FLOAT delz = ztmp - other_x[m + 2 * atoms_per_bin]; @@ -1077,8 +1077,8 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team const X_FLOAT radsum = radi + other_x[m + 4 * atoms_per_bin]; const X_FLOAT cutsq = (radsum + skin) * (radsum + skin); - if(rsq <= cutsq) { - if(n::build_ItemSizeCuda(typename Kokkos::Team const typename ArrayTypes::t_int_1d_const_um stencil = d_stencil; - for(int k = 0; k < nstencil; k++) { + for (int k = 0; k < nstencil; k++) { const int jbin = ibin + stencil[k]; - if(ibin == jbin) continue; + if (ibin == jbin) continue; bincount_current = c_bincount[jbin]; int j = MY_II < bincount_current ? c_bins(jbin, MY_II) : -1; - if(j >= 0) { + if (j >= 0) { other_x[MY_II] = x(j, 0); other_x[MY_II + atoms_per_bin] = x(j, 1); other_x[MY_II + 2 * atoms_per_bin] = x(j, 2); @@ -1110,16 +1110,16 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team __syncthreads(); - if(i >= 0 && i < nlocal) { + if (i >= 0 && i < nlocal) { #pragma unroll 8 - for(int m = 0; m < bincount_current; m++) { + for (int m = 0; m < bincount_current; m++) { const int j = other_id[m]; const int jtype = other_x[m + 3 * atoms_per_bin]; - if(HalfNeigh && (j < i)) continue; - if(HalfNeigh && !Newton && (j < i)) continue; - if(!HalfNeigh && j==i) continue; - if(Tri) { + if (HalfNeigh && (j < i)) continue; + if (HalfNeigh && !Newton && (j < i)) continue; + if (!HalfNeigh && j==i) continue; + if (Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -1129,7 +1129,7 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team } } } - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - other_x[m]; const X_FLOAT dely = ytmp - other_x[m + atoms_per_bin]; @@ -1138,8 +1138,8 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team const X_FLOAT radsum = radi + other_x[m + 4 * atoms_per_bin]; const X_FLOAT cutsq = (radsum + skin) * (radsum + skin); - if(rsq <= cutsq) { - if(n::build_ItemSizeCuda(typename Kokkos::Team __syncthreads(); } - if(i >= 0 && i < nlocal) { + if (i >= 0 && i < nlocal) { neigh_list.d_numneigh(i) = n; neigh_list.d_ilist(i) = i; } - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop + if (n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop } } } diff --git a/src/KOKKOS/npair_ssa_kokkos.cpp b/src/KOKKOS/npair_ssa_kokkos.cpp index 742cfe515d..a3608fd35a 100644 --- a/src/KOKKOS/npair_ssa_kokkos.cpp +++ b/src/KOKKOS/npair_ssa_kokkos.cpp @@ -489,7 +489,7 @@ fprintf(stdout, "tota%03d total %3d could use %6d inums, expected %6d inums. inu deep_copy(data.h_resize, data.resize); - if(data.h_resize()) { + if (data.h_resize()) { deep_copy(data.h_new_maxneighs, data.new_maxneighs); list->maxneighs = data.h_new_maxneighs() * 1.2; list->d_neighbors = typename ArrayTypes::t_neighbors_2d("neighbors", list->d_neighbors.extent(0), list->maxneighs); @@ -571,13 +571,13 @@ void NPairSSAKokkosExecute::build_locals_onePhase(const bool firstTr for (; jl < c_bincount(jbin); ++jl) { const int j = c_bins(jbin, jl); const int jtype = type(j); - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); const X_FLOAT dely = ytmp - x(j, 1); const X_FLOAT delz = ztmp - x(j, 2); const X_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq <= cutneighsq(itype,jtype)) { + if (rsq <= cutneighsq(itype,jtype)) { if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(i,j); @@ -586,19 +586,19 @@ void NPairSSAKokkosExecute::build_locals_onePhase(const bool firstTr /* onemols[imol]->nspecial[iatom], */ /* tag[j]-tagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n::build_locals_onePhase(const bool firstTr if (n > 0) { neigh_list.d_numneigh(inum) = n; neigh_list.d_ilist(inum++) = i; - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) Kokkos::atomic_fetch_max(&new_maxneighs(),n); + if (n > new_maxneighs()) Kokkos::atomic_fetch_max(&new_maxneighs(),n); } } } @@ -699,13 +699,13 @@ void NPairSSAKokkosExecute::build_ghosts_onePhase(int workPhase) con for (int jl = 0; jl < c_bincount(jbin); ++jl) { const int j = c_bins(jbin, jl); const int jtype = type(j); - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); const X_FLOAT dely = ytmp - x(j, 1); const X_FLOAT delz = ztmp - x(j, 2); const X_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq <= cutneighsq(itype,jtype)) { + if (rsq <= cutneighsq(itype,jtype)) { if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(j,i); @@ -714,19 +714,19 @@ void NPairSSAKokkosExecute::build_ghosts_onePhase(int workPhase) con /* onemols[jmol]->nspecial[jatom], */ /* tag[i]-jtagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n::build_ghosts_onePhase(int workPhase) con if (n > 0) { neigh_list.d_numneigh(gNdx) = n; neigh_list.d_ilist(gNdx++) = i; - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) Kokkos::atomic_fetch_max(&new_maxneighs(),n); + if (n > new_maxneighs()) Kokkos::atomic_fetch_max(&new_maxneighs(),n); } } } diff --git a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp index d3b00329d8..eb7b9ffd6e 100644 --- a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp @@ -335,7 +335,7 @@ double PairBuckCoulCutKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag_in) copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -228,7 +228,7 @@ F_FLOAT PairBuckCoulLongKokkos:: compute_fcoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -267,7 +267,7 @@ F_FLOAT PairBuckCoulLongKokkos:: compute_ecoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -335,7 +335,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -345,7 +345,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -357,7 +357,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -368,7 +368,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -380,7 +380,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -391,7 +391,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -403,7 +403,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -414,7 +414,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -497,7 +497,7 @@ double PairBuckCoulLongKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).offset = offset[i][j]; k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag_in) copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -190,7 +190,7 @@ F_FLOAT PairCoulLongKokkos:: compute_fcoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -229,7 +229,7 @@ F_FLOAT PairCoulLongKokkos:: compute_ecoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -293,7 +293,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -303,7 +303,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -315,7 +315,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -326,7 +326,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -338,7 +338,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -349,7 +349,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -361,7 +361,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -372,7 +372,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -447,7 +447,7 @@ double PairCoulLongKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag_in) if (splitFDT_flag) { if (!a0_is_zero) { - if(atom->ntypes > MAX_TYPES_STACKPARAMS) { + if (atom->ntypes > MAX_TYPES_STACKPARAMS) { if (neighflag == HALF) { if (newton_pair) { if (evflag) Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); @@ -287,7 +287,7 @@ void PairDPDfdtEnergyKokkos::compute(int eflag_in, int vflag_in) // loop over neighbors of my atoms - if(atom->ntypes > MAX_TYPES_STACKPARAMS) { + if (atom->ntypes > MAX_TYPES_STACKPARAMS) { if (neighflag == HALF) { if (newton_pair) { if (evflag) Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); @@ -671,7 +671,7 @@ double PairDPDfdtEnergyKokkos::init_one(int i, int j) k_params.h_view(i,j).kappa = kappa[i][j]; k_params.h_view(i,j).alpha = alpha[i][j]; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::operator()(TagPairEAMAlloyKernelC (p); @@ -985,7 +985,7 @@ void PairEAMAlloyKokkos::read_file(char *filename) Setfl *file = setfl; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam/alloy", unit_convert_flag); // transparently convert units for supported conversions diff --git a/src/KOKKOS/pair_eam_fs_kokkos.cpp b/src/KOKKOS/pair_eam_fs_kokkos.cpp index 54397cea51..56a351a1ad 100644 --- a/src/KOKKOS/pair_eam_fs_kokkos.cpp +++ b/src/KOKKOS/pair_eam_fs_kokkos.cpp @@ -725,7 +725,7 @@ void PairEAMFSKokkos::operator()(TagPairEAMFSKernelC (p); @@ -985,7 +985,7 @@ void PairEAMFSKokkos::read_file(char *filename) Fs *file = fs; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam/fs", unit_convert_flag); // transparently convert units for supported conversions diff --git a/src/KOKKOS/pair_eam_kokkos.cpp b/src/KOKKOS/pair_eam_kokkos.cpp index bcbddea28d..e5c9eada71 100644 --- a/src/KOKKOS/pair_eam_kokkos.cpp +++ b/src/KOKKOS/pair_eam_kokkos.cpp @@ -721,7 +721,7 @@ void PairEAMKokkos::operator()(TagPairEAMKernelC (p); diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index bc60bab85c..855d2b259a 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -582,8 +582,8 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute()() = 1; // A3. Compute some convenient quantities for evaluating the force @@ -599,7 +599,7 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute::operator()(TagPairExp6rxCompute::operator()(TagPairExp6rxCompute()() = 1; // A3. Compute some convenient quantities for evaluating the force @@ -694,7 +694,7 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute::operator()(TagPairExp6rxCompute::operator()(TagPairExp6rxComputeNoAtomics()() = 1; // A3. Compute some convenient quantities for evaluating the force @@ -973,7 +973,7 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxComputeNoAtomics::operator()(TagPairExp6rxComputeNoAtomics::operator()(TagPairExp6rxComputeNoAtomics()() = 1; // A3. Compute some convenient quantities for evaluating the force @@ -1068,7 +1068,7 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxComputeNoAtomics::operator()(TagPairExp6rxComputeNoAtomics::vectorized_operator(const int &ii, EV_FLOAT& double fpairOldEXP6_12 = 0.0; double fpairOldEXP6_21 = 0.0; - if(rmOld12_ij!=0.0 && rmOld21_ij!=0.0) + if (rmOld12_ij!=0.0 && rmOld21_ij!=0.0) { hasError |= (alphaOld21_ij == 6.0 || alphaOld12_ij == 6.0); @@ -1387,7 +1387,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& double durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); double rin1 = shift*rmOld12_ij*func_rin(alphaOld12_ij); - if(r < rin1){ + if (r < rin1) { const double rin6 = rin1*rin1*rin1*rin1*rin1*rin1; const double rin6inv = 1.0/rin6; @@ -1427,7 +1427,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rmOld21_ij*func_rin(alphaOld21_ij); - if(r < rin1){ + if (r < rin1) { const double rin6 = rin1*rin1*rin1*rin1*rin1*rin1; const double rin6inv = 1.0/rin6; @@ -1465,7 +1465,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& evdwlOld_j[jlane] = evdwlOld; } - if(rm12_ij!=0.0 && rm21_ij!=0.0) + if (rm12_ij!=0.0 && rm21_ij!=0.0) { hasError |= (alpha21_ij == 6.0 || alpha12_ij == 6.0); @@ -1483,7 +1483,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& double durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); double rin1 = shift*rm12_ij*func_rin(alpha12_ij); - if(r < rin1){ + if (r < rin1) { const double rin6 = rin1*rin1*rin1*rin1*rin1*rin1; const double rin6inv = 1.0/rin6; @@ -1515,7 +1515,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rm21_ij*func_rin(alpha21_ij); - if(r < rin1){ + if (r < rin1) { const double rin6 = rin1*rin1*rin1*rin1*rin1*rin1; const double rin6inv = 1.0/rin6; @@ -1807,7 +1807,7 @@ void PairExp6rxKokkos::read_file(char *file) n = strlen(words[1]) + 1; params[nparams].potential = new char[n]; strcpy(params[nparams].potential,words[1]); - if (strcmp(params[nparams].potential,"exp6") == 0){ + if (strcmp(params[nparams].potential,"exp6") == 0) { params[nparams].alpha = atof(words[2]); params[nparams].epsilon = atof(words[3]); params[nparams].rm = atof(words[4]); @@ -1890,7 +1890,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub nTotalold = 0.0; // Compute the total number of molecules in the old and new CG particle as well as the total number of molecules in the fluid portion of the old and new CG particle - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { nTotal += dvector(ispecies,id); nTotalold += dvector(ispecies+nspecies,id); @@ -1903,7 +1903,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub nMoleculesOFA += dvector(ispecies,id); } } - if(nTotal < MY_EPSILON || nTotalold < MY_EPSILON) + if (nTotal < MY_EPSILON || nTotalold < MY_EPSILON) k_error_flag.template view()() = 1; // Compute the mole fraction of molecules within the fluid portion of the particle (One Fluid Approximation) @@ -1915,7 +1915,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub if (iparam < 0 || d_params[iparam].potentialType != exp6PotentialType ) continue; // If Site1 matches a pure species, then grab the parameters - if (isite1 == d_params[iparam].ispecies){ + if (isite1 == d_params[iparam].ispecies) { rm1_old = d_params[iparam].rm; rm1 = d_params[iparam].rm; epsilon1_old = d_params[iparam].epsilon; @@ -1931,7 +1931,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub } // If Site2 matches a pure species, then grab the parameters - if (isite2 == d_params[iparam].ispecies){ + if (isite2 == d_params[iparam].ispecies) { rm2_old = d_params[iparam].rm; rm2 = d_params[iparam].rm; epsilon2_old = d_params[iparam].epsilon; @@ -1952,9 +1952,9 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub rmi = d_params[iparam].rm; epsiloni = d_params[iparam].epsilon; alphai = d_params[iparam].alpha; - if(nMoleculesOFA::getMixingWeights(int id,double &epsilon1,doub rmj = d_params[jparam].rm; epsilonj = d_params[jparam].epsilon; alphaj = d_params[jparam].alpha; - if(nMoleculesOFA::getMixingWeights(int id,double &epsilon1,doub epsilonij = sqrt(epsiloni*epsilonj); alphaij = sqrt(alphai*alphaj); - if(fractionOFAold > 0.0){ + if (fractionOFAold > 0.0) { rm3_old += xMolei_old*xMolej_old*rm3ij; epsilon_old += xMolei_old*xMolej_old*rm3ij*epsilonij; alpha_old += xMolei_old*xMolej_old*rm3ij*epsilonij*alphaij; } - if(fractionOFA > 0.0){ + if (fractionOFA > 0.0) { rm3 += xMolei*xMolej*rm3ij; epsilon += xMolei*xMolej*rm3ij*epsilonij; alpha += xMolei*xMolej*rm3ij*epsilonij*alphaij; @@ -1988,9 +1988,9 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub } } - if (isOneFluidApprox(isite1)){ + if (isOneFluidApprox(isite1)) { rm1 = cbrt(rm3); - if(rm1 < MY_EPSILON) { + if (rm1 < MY_EPSILON) { rm1 = 0.0; epsilon1 = 0.0; alpha1 = 0.0; @@ -2002,7 +2002,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub fraction1 = fractionOFA; rm1_old = cbrt(rm3_old); - if(rm1_old < MY_EPSILON) { + if (rm1_old < MY_EPSILON) { rm1_old = 0.0; epsilon1_old = 0.0; alpha1_old = 0.0; @@ -2013,18 +2013,18 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub nMoleculesOld1 = 1.0-(nTotalold-nMoleculesOFAold); fractionOld1 = fractionOFAold; - if(scalingFlag == EXPONENT){ + if (scalingFlag == EXPONENT) { exponentScaling(nMoleculesOFA,epsilon1,rm1); exponentScaling(nMoleculesOFAold,epsilon1_old,rm1_old); - } else if(scalingFlag == POLYNOMIAL){ + } else if (scalingFlag == POLYNOMIAL) { polynomialScaling(nMoleculesOFA,alpha1,epsilon1,rm1); polynomialScaling(nMoleculesOFAold,alpha1_old,epsilon1_old,rm1_old); } } - if (isOneFluidApprox(isite2)){ + if (isOneFluidApprox(isite2)) { rm2 = cbrt(rm3); - if(rm2 < MY_EPSILON) { + if (rm2 < MY_EPSILON) { rm2 = 0.0; epsilon2 = 0.0; alpha2 = 0.0; @@ -2036,7 +2036,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub fraction2 = fractionOFA; rm2_old = cbrt(rm3_old); - if(rm2_old < MY_EPSILON) { + if (rm2_old < MY_EPSILON) { rm2_old = 0.0; epsilon2_old = 0.0; alpha2_old = 0.0; @@ -2047,46 +2047,46 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub nMoleculesOld2 = 1.0-(nTotalold-nMoleculesOFAold); fractionOld2 = fractionOFAold; - if(scalingFlag == EXPONENT){ + if (scalingFlag == EXPONENT) { exponentScaling(nMoleculesOFA,epsilon2,rm2); exponentScaling(nMoleculesOFAold,epsilon2_old,rm2_old); - } else if(scalingFlag == POLYNOMIAL){ + } else if (scalingFlag == POLYNOMIAL) { polynomialScaling(nMoleculesOFA,alpha2,epsilon2,rm2); polynomialScaling(nMoleculesOFAold,alpha2_old,epsilon2_old,rm2_old); } } // Check that no fractions are less than zero - if(fraction1 < 0.0 || nMolecules1 < 0.0){ - if(fraction1 < -MY_EPSILON || nMolecules1 < -MY_EPSILON){ + if (fraction1 < 0.0 || nMolecules1 < 0.0) { + if (fraction1 < -MY_EPSILON || nMolecules1 < -MY_EPSILON) { k_error_flag.template view()() = 2; } nMolecules1 = 0.0; fraction1 = 0.0; } - if(fraction2 < 0.0 || nMolecules2 < 0.0){ - if(fraction2 < -MY_EPSILON || nMolecules2 < -MY_EPSILON){ + if (fraction2 < 0.0 || nMolecules2 < 0.0) { + if (fraction2 < -MY_EPSILON || nMolecules2 < -MY_EPSILON) { k_error_flag.template view()() = 2; } nMolecules2 = 0.0; fraction2 = 0.0; } - if(fractionOld1 < 0.0 || nMoleculesOld1 < 0.0){ - if(fractionOld1 < -MY_EPSILON || nMoleculesOld1 < -MY_EPSILON){ + if (fractionOld1 < 0.0 || nMoleculesOld1 < 0.0) { + if (fractionOld1 < -MY_EPSILON || nMoleculesOld1 < -MY_EPSILON) { k_error_flag.template view()() = 2; } nMoleculesOld1 = 0.0; fractionOld1 = 0.0; } - if(fractionOld2 < 0.0 || nMoleculesOld2 < 0.0){ - if(fractionOld2 < -MY_EPSILON || nMoleculesOld2 < -MY_EPSILON){ + if (fractionOld2 < 0.0 || nMoleculesOld2 < 0.0) { + if (fractionOld2 < -MY_EPSILON || nMoleculesOld2 < -MY_EPSILON) { k_error_flag.template view()() = 2; } nMoleculesOld2 = 0.0; fractionOld2 = 0.0; } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old = fractionOld1; mixWtSite1 = fraction1; mixWtSite2old = fractionOld2; @@ -2298,9 +2298,9 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int #endif for (int id = idx_begin; id < idx_end; ++id) { - if(nMoleculesOFA[id]::getMixingWeightsVect(const int np_total, int for (int id = idx_begin; id < idx_end; ++id) { double xMolej, xMolej_old; - if(nMoleculesOFA[id] 0.0){ + if (fractionOFAold[id] > 0.0) { rm3_old[id] += xMolei_old[id]*xMolej_old*rm3ij; epsilon_old[id] += xMolei_old[id]*xMolej_old*rm3ij*epsilonij; alpha_old[id] += xMolei_old[id]*xMolej_old*rm3ij*epsilonij*alphaij; } - if(fractionOFA[id] > 0.0){ + if (fractionOFA[id] > 0.0) { rm3[id] += xMolei[id]*xMolej*rm3ij; epsilon[id] += xMolei[id]*xMolej*rm3ij*epsilonij; alpha[id] += xMolei[id]*xMolej*rm3ij*epsilonij*alphaij; @@ -2352,7 +2352,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int for (int id = idx_begin; id < idx_end; ++id) { rm1[id] = cbrt(rm3[id]); - if(rm1[id] < MY_EPSILON) { + if (rm1[id] < MY_EPSILON) { rm1[id] = 0.0; epsilon1[id] = 0.0; alpha1[id] = 0.0; @@ -2364,7 +2364,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int fraction1[id] = fractionOFA[id]; rm1_old[id] = cbrt(rm3_old[id]); - if(rm1_old[id] < MY_EPSILON) { + if (rm1_old[id] < MY_EPSILON) { rm1_old[id] = 0.0; epsilon1_old[id] = 0.0; alpha1_old[id] = 0.0; @@ -2376,7 +2376,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int fractionOld1[id] = fractionOFAold[id]; } - if(scalingFlag == EXPONENT) { + if (scalingFlag == EXPONENT) { #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP #pragma ivdep #endif @@ -2386,7 +2386,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int exponentScaling(nMoleculesOFAold[id],epsilon1_old[id],rm1_old[id]); } } - else if(scalingFlag == POLYNOMIAL){ + else if (scalingFlag == POLYNOMIAL) { #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP #pragma ivdep #endif @@ -2406,7 +2406,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int for (int id = idx_begin; id < idx_end; ++id) { rm2[id] = cbrt(rm3[id]); - if(rm2[id] < MY_EPSILON) { + if (rm2[id] < MY_EPSILON) { rm2[id] = 0.0; epsilon2[id] = 0.0; alpha2[id] = 0.0; @@ -2418,7 +2418,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int fraction2[id] = fractionOFA[id]; rm2_old[id] = cbrt(rm3_old[id]); - if(rm2_old[id] < MY_EPSILON) { + if (rm2_old[id] < MY_EPSILON) { rm2_old[id] = 0.0; epsilon2_old[id] = 0.0; alpha2_old[id] = 0.0; @@ -2430,7 +2430,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int fractionOld2[id] = fractionOFAold[id]; } - if(scalingFlag == EXPONENT){ + if (scalingFlag == EXPONENT) { #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP #pragma ivdep #endif @@ -2440,7 +2440,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int exponentScaling(nMoleculesOFAold[id],epsilon2_old[id],rm2_old[id]); } } - else if(scalingFlag == POLYNOMIAL){ + else if (scalingFlag == POLYNOMIAL) { #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP #pragma ivdep #endif @@ -2458,36 +2458,36 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int #endif for (int id = idx_begin; id < idx_end; ++id) { - if(fraction1[id] < 0.0 || nMolecules1[id] < 0.0){ - if(fraction1[id] < -MY_EPSILON || nMolecules1[id] < -MY_EPSILON){ + if (fraction1[id] < 0.0 || nMolecules1[id] < 0.0) { + if (fraction1[id] < -MY_EPSILON || nMolecules1[id] < -MY_EPSILON) { errorFlag2 = 2; } nMolecules1[id] = 0.0; fraction1[id] = 0.0; } - if(fraction2[id] < 0.0 || nMolecules2[id] < 0.0){ - if(fraction2[id] < -MY_EPSILON || nMolecules2[id] < -MY_EPSILON){ + if (fraction2[id] < 0.0 || nMolecules2[id] < 0.0) { + if (fraction2[id] < -MY_EPSILON || nMolecules2[id] < -MY_EPSILON) { errorFlag2 = 2; } nMolecules2[id] = 0.0; fraction2[id] = 0.0; } - if(fractionOld1[id] < 0.0 || nMoleculesOld1[id] < 0.0){ - if(fractionOld1[id] < -MY_EPSILON || nMoleculesOld1[id] < -MY_EPSILON){ + if (fractionOld1[id] < 0.0 || nMoleculesOld1[id] < 0.0) { + if (fractionOld1[id] < -MY_EPSILON || nMoleculesOld1[id] < -MY_EPSILON) { errorFlag2 = 2; } nMoleculesOld1[id] = 0.0; fractionOld1[id] = 0.0; } - if(fractionOld2[id] < 0.0 || nMoleculesOld2[id] < 0.0){ - if(fractionOld2[id] < -MY_EPSILON || nMoleculesOld2[id] < -MY_EPSILON){ + if (fractionOld2[id] < 0.0 || nMoleculesOld2[id] < 0.0) { + if (fractionOld2[id] < -MY_EPSILON || nMoleculesOld2[id] < -MY_EPSILON) { errorFlag2 = 2; } nMoleculesOld2[id] = 0.0; fractionOld2[id] = 0.0; } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old[id] = fractionOld1[id]; mixWtSite1[id] = fraction1[id]; mixWtSite2old[id] = fractionOld2[id]; @@ -2518,17 +2518,17 @@ void PairExp6rxKokkos::exponentScaling(double phi, double &epsilon, { double powfuch; - if(exponentEpsilon < 0.0){ + if (exponentEpsilon < 0.0) { powfuch = pow(phi,-exponentEpsilon); - if(powfuch::expValue(double value) const { double returnValue; - if(value < DBL_MIN_EXP) returnValue = 0.0; + if (value < DBL_MIN_EXP) returnValue = 0.0; else returnValue = exp(value); return returnValue; diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp index 208fb8165b..577fac7437 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp @@ -151,7 +151,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::compute(int eflag_in, int copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -338,7 +338,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -348,7 +348,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -360,7 +360,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -371,7 +371,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -383,7 +383,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -394,7 +394,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -406,7 +406,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -417,7 +417,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -499,7 +499,7 @@ double PairLJCharmmCoulCharmmImplicitKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag_i copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -339,7 +339,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -349,7 +349,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -361,7 +361,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -372,7 +372,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -384,7 +384,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -395,7 +395,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -407,7 +407,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -418,7 +418,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -500,7 +500,7 @@ double PairLJCharmmCoulCharmmKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag_in) copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -255,7 +255,7 @@ F_FLOAT PairLJCharmmCoulLongKokkos:: compute_fcoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -292,7 +292,7 @@ KOKKOS_INLINE_FUNCTION F_FLOAT PairLJCharmmCoulLongKokkos:: compute_ecoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -360,7 +360,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -370,7 +370,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -382,7 +382,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -393,7 +393,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -405,7 +405,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -416,7 +416,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -428,7 +428,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -439,7 +439,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -508,7 +508,7 @@ double PairLJCharmmCoulLongKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::PairLJClass2CoulLongKokkos(LAMMPS *lmp): template PairLJClass2CoulLongKokkos::~PairLJClass2CoulLongKokkos() { - if (!copymode){ + if (!copymode) { memoryKK->destroy_kokkos(k_cutsq, cutsq); memoryKK->destroy_kokkos(k_cut_ljsq, cut_ljsq); } @@ -137,7 +137,7 @@ void PairLJClass2CoulLongKokkos::compute(int eflag_in, int vflag_in) copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -206,7 +206,7 @@ F_FLOAT PairLJClass2CoulLongKokkos:: compute_fcoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -265,7 +265,7 @@ F_FLOAT PairLJClass2CoulLongKokkos:: compute_ecoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -330,7 +330,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -340,7 +340,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -352,7 +352,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -363,7 +363,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -375,7 +375,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -386,7 +386,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -398,7 +398,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -409,7 +409,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -491,7 +491,7 @@ double PairLJClass2CoulLongKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).offset = offset[i][j]; k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::PairLJCutCoulCutKokkos(LAMMPS *lmp):PairLJCu template PairLJCutCoulCutKokkos::~PairLJCutCoulCutKokkos() { - if (allocated){ + if (allocated) { memoryKK->destroy_kokkos(k_cutsq, cutsq); memoryKK->destroy_kokkos(k_cut_ljsq, cut_ljsq); memoryKK->destroy_kokkos(k_cut_coulsq, cut_coulsq); @@ -327,7 +327,7 @@ double PairLJCutCoulCutKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::~PairLJCutCoulLongKokkos() memoryKK->destroy_kokkos(k_vatom,vatom); eatom = nullptr; vatom = nullptr; - if (allocated){ + if (allocated) { memoryKK->destroy_kokkos(k_cutsq, cutsq); memoryKK->destroy_kokkos(k_cut_ljsq, cut_ljsq); } @@ -142,7 +142,7 @@ void PairLJCutCoulLongKokkos::compute(int eflag_in, int vflag_in) // loop over neighbors of my atoms EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -206,7 +206,7 @@ KOKKOS_INLINE_FUNCTION F_FLOAT PairLJCutCoulLongKokkos:: compute_fcoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -263,7 +263,7 @@ F_FLOAT PairLJCutCoulLongKokkos:: compute_ecoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -328,7 +328,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -338,7 +338,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -350,7 +350,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -361,7 +361,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -373,7 +373,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -384,7 +384,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -396,7 +396,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -407,7 +407,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -489,7 +489,7 @@ double PairLJCutCoulLongKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).offset = offset[i][j]; k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).shift = shift[i][j]; k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -324,7 +324,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -334,7 +334,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -346,7 +346,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -357,7 +357,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -369,7 +369,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -380,7 +380,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -392,7 +392,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -403,7 +403,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -489,7 +489,7 @@ double PairLJGromacsCoulGromacsKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cut_inner = cut_inner[i][j]; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(i,j).lj_type = lj_type[i][j]; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag_in) if (tabstyle == LOOKUP) compute_style(eflag_in,vflag_in); - else if(tabstyle == LINEAR) + else if (tabstyle == LINEAR) compute_style(eflag_in,vflag_in); copymode = 0; @@ -321,8 +321,8 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXComputeinnersq || rho[j]*rho[j] < tb->innersq){ - if (rho[i]*rho[i] < d_table_const.innersq(tidx) || rho[j]*rho[j] < d_table_const.innersq(tidx)){ + //if (rho[i]*rho[i] < tb->innersq || rho[j]*rho[j] < tb->innersq) { + if (rho[i]*rho[i] < d_table_const.innersq(tidx) || rho[j]*rho[j] < d_table_const.innersq(tidx)) { k_error_flag.template view()() = 1; } @@ -331,7 +331,7 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXCompute (((rho[i]*rho[i]) - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); //jtable = static_cast (((rho[j]*rho[j]) - tb->innersq) * tb->invdelta); jtable = static_cast (((rho[j]*rho[j]) - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - if (itable >= tlm1 || jtable >= tlm1){ + if (itable >= tlm1 || jtable >= tlm1) { k_error_flag.template view()() = 2; } //A_i = tb->f[itable]; @@ -349,22 +349,22 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXCompute ((rho[i]*rho[i] - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); //jtable = static_cast (((rho[j]*rho[j]) - tb->innersq) * tb->invdelta); jtable = static_cast ((rho[j]*rho[j] - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - if (itable >= tlm1 || jtable >= tlm1){ + if (itable >= tlm1 || jtable >= tlm1) { k_error_flag.template view()() = 2; } - if(itable<0) itable=0; - if(itable>=tlm1) itable=tlm1; - if(jtable<0) jtable=0; - if(jtable>=tlm1)jtable=tlm1; + if (itable<0) itable=0; + if (itable>=tlm1) itable=tlm1; + if (jtable<0) jtable=0; + if (jtable>=tlm1)jtable=tlm1; //fraction_i = (((rho[i]*rho[i]) - tb->rsq[itable]) * tb->invdelta); fraction_i = (((rho[i]*rho[i]) - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx)); //fraction_j = (((rho[j]*rho[j]) - tb->rsq[jtable]) * tb->invdelta); fraction_j = (((rho[j]*rho[j]) - d_table_const.rsq(tidx,jtable)) * d_table_const.invdelta(tidx)); - if(itable==0) fraction_i=0.0; - if(itable==tlm1) fraction_i=0.0; - if(jtable==0) fraction_j=0.0; - if(jtable==tlm1) fraction_j=0.0; + if (itable==0) fraction_i=0.0; + if (itable==tlm1) fraction_i=0.0; + if (jtable==0) fraction_j=0.0; + if (jtable==tlm1) fraction_j=0.0; //A_i = tb->f[itable] + fraction_i*tb->df[itable]; A_i = d_table_const.f(tidx,itable) + fraction_i*d_table_const.df(tidx,itable); @@ -405,10 +405,10 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXCompute= tlm1){ + if (itable >= tlm1) { k_error_flag.template view()() = 2; } - if(itable==0) fraction_i=0.0; + if (itable==0) fraction_i=0.0; //else fraction_i = (((rho[i]*rho[i]) - tb->rsq[itable]) * tb->invdelta); else fraction_i = (((rho[i]*rho[i]) - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx)); //evdwl = tb->e[itable] + fraction_i*tb->de[itable]; @@ -547,7 +547,7 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXComputeLoca const double pi = MathConst::MY_PI; - for (int jj = 0; jj < jnum; jj++){ + for (int jj = 0; jj < jnum; jj++) { const int j = (d_neighbors(i,jj) & NEIGHMASK); const int jtype = type[j]; @@ -598,44 +598,44 @@ void PairMultiLucyRXKokkos::getMixingWeights(int id, double &mixWtSi nTotal = 0.0; nTotalOld = 0.0; - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { nTotal += dvector(ispecies,id); nTotalOld += dvector(ispecies+nspecies,id); } - if (isOneFluid(isite1) == false){ + if (isOneFluid(isite1) == false) { nMoleculesOld1 = dvector(isite1+nspecies,id); nMolecules1 = dvector(isite1,id); fractionOld1 = nMoleculesOld1/nTotalOld; fraction1 = nMolecules1/nTotal; } - if (isOneFluid(isite2) == false){ + if (isOneFluid(isite2) == false) { nMoleculesOld2 = dvector(isite2+nspecies,id); nMolecules2 = dvector(isite2,id); fractionOld2 = nMoleculesOld2/nTotalOld; fraction2 = nMolecules2/nTotal; } - if (isOneFluid(isite1) || isOneFluid(isite2)){ + if (isOneFluid(isite1) || isOneFluid(isite2)) { nMoleculesOFAold = 0.0; nMoleculesOFA = 0.0; fractionOFAold = 0.0; fractionOFA = 0.0; - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { if (isite1 == ispecies || isite2 == ispecies) continue; nMoleculesOFAold += dvector(ispecies+nspecies,id); nMoleculesOFA += dvector(ispecies,id); fractionOFAold += dvector(ispecies+nspecies,id) / nTotalOld; fractionOFA += dvector(ispecies,id) / nTotal; } - if (isOneFluid(isite1)){ + if (isOneFluid(isite1)) { nMoleculesOld1 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules1 = 1.0-(nTotal-nMoleculesOFA); fractionOld1 = fractionOFAold; fraction1 = fractionOFA; } - if (isOneFluid(isite2)){ + if (isOneFluid(isite2)) { nMoleculesOld2 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules2 = 1.0-(nTotal-nMoleculesOFA); fractionOld2 = fractionOFAold; @@ -643,7 +643,7 @@ void PairMultiLucyRXKokkos::getMixingWeights(int id, double &mixWtSi } } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old = fractionOld1; mixWtSite1 = fraction1; mixWtSite2old = fractionOld2; @@ -862,12 +862,12 @@ void PairMultiLucyRXKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->innersq,h_table->innersq,ntables,"Table::innersq"); memoryKK->create_kokkos(d_table->invdelta,h_table->invdelta,ntables,"Table::invdelta"); - if(tabstyle == LOOKUP) { + if (tabstyle == LOOKUP) { memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tlm1,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tlm1,"Table::f"); } - if(tabstyle == LINEAR) { + if (tabstyle == LINEAR) { memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,tablength,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tablength,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tablength,"Table::f"); @@ -875,21 +875,21 @@ void PairMultiLucyRXKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->df,h_table->df,ntables,tlm1,"Table::df"); } - for(int i=0; i < ntables; i++) { + for (int i=0; i < ntables; i++) { Table* tb = &tables[i]; h_table->innersq[i] = tb->innersq; h_table->invdelta[i] = tb->invdelta; - for(int j = 0; j < (int)h_table->rsq.extent(1); j++) + for (int j = 0; j < (int)h_table->rsq.extent(1); j++) h_table->rsq(i,j) = tb->rsq[j]; - for(int j = 0; j < (int)h_table->e.extent(1); j++) + for (int j = 0; j < (int)h_table->e.extent(1); j++) h_table->e(i,j) = tb->e[j]; - for(int j = 0; j < (int)h_table->de.extent(1); j++) + for (int j = 0; j < (int)h_table->de.extent(1); j++) h_table->de(i,j) = tb->de[j]; - for(int j = 0; j < (int)h_table->f.extent(1); j++) + for (int j = 0; j < (int)h_table->f.extent(1); j++) h_table->f(i,j) = tb->f[j]; - for(int j = 0; j < (int)h_table->df.extent(1); j++) + for (int j = 0; j < (int)h_table->df.extent(1); j++) h_table->df(i,j) = tb->df[j]; } diff --git a/src/KOKKOS/pair_reaxc_kokkos.cpp b/src/KOKKOS/pair_reaxc_kokkos.cpp index eea397dc69..5d48b429cc 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.cpp +++ b/src/KOKKOS/pair_reaxc_kokkos.cpp @@ -462,12 +462,12 @@ int PairReaxCKokkos::Init_Lookup_Tables() LR = (LR_lookup_table**) scalloc( control->error_ptr, num_atom_types+1, sizeof(LR_lookup_table*), "lookup:LR"); - for( i = 0; i < num_atom_types+1; ++i ) + for ( i = 0; i < num_atom_types+1; ++i ) LR[i] = (LR_lookup_table*) scalloc( control->error_ptr, num_atom_types+1, sizeof(LR_lookup_table), "lookup:LR[i]"); - for( i = 1; i <= num_atom_types; ++i ) { - for( j = i; j <= num_atom_types; ++j ) { + for ( i = 1; i <= num_atom_types; ++i ) { + for ( j = i; j <= num_atom_types; ++j ) { LR[i][j].xmin = 0; LR[i][j].xmax = control->nonb_cut; LR[i][j].n = control->tabulate + 2; @@ -487,7 +487,7 @@ int PairReaxCKokkos::Init_Lookup_Tables() smalloc( control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef), "lookup:LR[i,j].CEclmb"); - for( r = 1; r <= control->tabulate; ++r ) { + for ( r = 1; r <= control->tabulate; ++r ) { LR_vdW_Coulomb(i, j, r * dr, &(LR[i][j].y[r]) ); h[r] = LR[i][j].dx; fh[r] = LR[i][j].y[r].H; @@ -546,9 +546,9 @@ void PairReaxCKokkos::Deallocate_Lookup_Tables() ntypes = atom->ntypes; - for( i = 0; i <= ntypes; ++i ) { + for ( i = 0; i <= ntypes; ++i ) { if (map[i] == -1) continue; - for( j = i; j <= ntypes; ++j ) { + for ( j = i; j <= ntypes; ++j ) { if (map[i] == -1) continue; if (LR[i][j].n) { sfree( control->error_ptr, LR[i][j].y, "LR[i,j].y" ); @@ -601,7 +601,7 @@ void PairReaxCKokkos::LR_vdW_Coulomb( int i, int j, double r_ij, LR_ dTap += k_tap.h_view[1]/r_ij; /*vdWaals Calculations*/ - if(system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) { // shielding powr_vdW1 = pow(r_ij, p_vdW1); powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); @@ -626,7 +626,7 @@ void PairReaxCKokkos::LR_vdW_Coulomb( int i, int j, double r_ij, LR_ Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; } - if(system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) { // inner wall e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); lr->e_vdW += Tap * e_core; @@ -1475,7 +1475,7 @@ void PairReaxCKokkos::operator()(PairReaxBuildListsFull, const int & const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; double cutoffsq; - if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); + if (i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); else cutoffsq = cut_bosq; if (rsq > cutoffsq) continue; @@ -1643,7 +1643,7 @@ void PairReaxCKokkos::operator()(PairReaxBuildListsHalf, const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; double cutoffsq; - if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); + if (i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); else cutoffsq = cut_bosq; if (rsq > cutoffsq) continue; @@ -1928,10 +1928,10 @@ void PairReaxCKokkos::operator()(PairReaxBondOrder2, const int &ii) d_C4dbopi2(i,j_index) = d_BO_pi2(i,j_index) * A3_ji; } - if(d_BO(i,j_index) < 1e-10) d_BO(i,j_index) = 0.0; - if(d_BO_s(i,j_index) < 1e-10) d_BO_s(i,j_index) = 0.0; - if(d_BO_pi(i,j_index) < 1e-10) d_BO_pi(i,j_index) = 0.0; - if(d_BO_pi2(i,j_index) < 1e-10) d_BO_pi2(i,j_index) = 0.0; + if (d_BO(i,j_index) < 1e-10) d_BO(i,j_index) = 0.0; + if (d_BO_s(i,j_index) < 1e-10) d_BO_s(i,j_index) = 0.0; + if (d_BO_pi(i,j_index) < 1e-10) d_BO_pi(i,j_index) = 0.0; + if (d_BO_pi2(i,j_index) < 1e-10) d_BO_pi2(i,j_index) = 0.0; total_bo += d_BO(i,j_index); @@ -2330,7 +2330,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeAngular::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion= 0 && sin_ijk <= 1e-10) tan_ijk_i = cos_ijk / 1e-10; - else if( sin_ijk <= 0 && sin_ijk >= -1e-10 ) + else if ( sin_ijk <= 0 && sin_ijk >= -1e-10 ) tan_ijk_i = -cos_ijk / 1e-10; else tan_ijk_i = cos_ijk / sin_ijk; exp_tor2_ik = exp( -p_tor2 * BOA_ik ); exp_cot2_ik = exp( -p_cot2 * SQR(BOA_ik -1.5) ); - for(int l = 0; l < 3; l++) fktmp[l] = 0.0; + for (int l = 0; l < 3; l++) fktmp[l] = 0.0; for (int ll = l_start; ll < l_end; ll++) { int l = d_bo_list[ll]; @@ -2643,7 +2643,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion= 0 && sin_jil <= 1e-10) tan_jil_i = cos_jil / 1e-10; - else if( sin_jil <= 0 && sin_jil >= -1e-10 ) + else if ( sin_jil <= 0 && sin_jil >= -1e-10 ) tan_jil_i = -cos_jil / 1e-10; else tan_jil_i = cos_jil / sin_jil; @@ -2703,9 +2703,9 @@ void PairReaxCKokkos::operator()(PairReaxComputeTorsion= 0 && sin_ijk <= 1e-10) sin_ijk_rnd = 1e-10; - else if( sin_ijk <= 0 && sin_ijk >= -1e-10 ) sin_ijk_rnd = -1e-10; + else if ( sin_ijk <= 0 && sin_ijk >= -1e-10 ) sin_ijk_rnd = -1e-10; if (sin_jil >= 0 && sin_jil <= 1e-10) sin_jil_rnd = 1e-10; - else if( sin_jil <= 0 && sin_jil >= -1e-10 ) sin_jil_rnd = -1e-10; + else if ( sin_jil <= 0 && sin_jil >= -1e-10 ) sin_jil_rnd = -1e-10; // dcos_omega_di for (int d = 0; d < 3; d++) dcos_omega_dk[d] = ((htra-arg*hnra)/rik) * delik[d] - dellk[d]; @@ -2944,7 +2944,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeHydrogen::~PairTableKokkos() template void PairTableKokkos::compute(int eflag_in, int vflag_in) { - if(update_table) + if (update_table) create_kokkos_tables(); - if(tabstyle == LOOKUP) + if (tabstyle == LOOKUP) compute_style(eflag_in,vflag_in); - if(tabstyle == LINEAR) + if (tabstyle == LINEAR) compute_style(eflag_in,vflag_in); - if(tabstyle == SPLINE) + if (tabstyle == SPLINE) compute_style(eflag_in,vflag_in); - if(tabstyle == BITMAP) + if (tabstyle == BITMAP) compute_style(eflag_in,vflag_in); } @@ -117,7 +117,7 @@ void PairTableKokkos::compute_style(int eflag_in, int vflag_in) // loop over neighbors of my atoms EV_FLOAT ev; - if(atom->ntypes > MAX_TYPES_STACKPARAMS) { + if (atom->ntypes > MAX_TYPES_STACKPARAMS) { if (neighflag == FULL) { PairComputeFunctor,FULL,false,S_TableCompute > ff(this,(NeighListKokkos*) list); @@ -262,12 +262,12 @@ void PairTableKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->invdelta,h_table->invdelta,ntables,"Table::invdelta"); memoryKK->create_kokkos(d_table->deltasq6,h_table->deltasq6,ntables,"Table::deltasq6"); - if(tabstyle == LOOKUP) { + if (tabstyle == LOOKUP) { memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tlm1,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tlm1,"Table::f"); } - if(tabstyle == LINEAR) { + if (tabstyle == LINEAR) { memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,tablength,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tablength,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tablength,"Table::f"); @@ -275,7 +275,7 @@ void PairTableKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->df,h_table->df,ntables,tlm1,"Table::df"); } - if(tabstyle == SPLINE) { + if (tabstyle == SPLINE) { memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,tablength,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tablength,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tablength,"Table::f"); @@ -283,7 +283,7 @@ void PairTableKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->f2,h_table->f2,ntables,tablength,"Table::f2"); } - if(tabstyle == BITMAP) { + if (tabstyle == BITMAP) { int ntable = 1 << tablength; memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,ntable,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,ntable,"Table::e"); @@ -295,7 +295,7 @@ void PairTableKokkos::create_kokkos_tables() - for(int i=0; i < ntables; i++) { + for (int i=0; i < ntables; i++) { Table* tb = &tables[i]; h_table->nshiftbits[i] = tb->nshiftbits; @@ -304,21 +304,21 @@ void PairTableKokkos::create_kokkos_tables() h_table->invdelta[i] = tb->invdelta; h_table->deltasq6[i] = tb->deltasq6; - for(int j = 0; j < (int) h_table->rsq.extent(1); j++) + for (int j = 0; j < (int) h_table->rsq.extent(1); j++) h_table->rsq(i,j) = tb->rsq[j]; - for(int j = 0; j < (int) h_table->drsq.extent(1); j++) + for (int j = 0; j < (int) h_table->drsq.extent(1); j++) h_table->drsq(i,j) = tb->drsq[j]; - for(int j = 0; j < (int) h_table->e.extent(1); j++) + for (int j = 0; j < (int) h_table->e.extent(1); j++) h_table->e(i,j) = tb->e[j]; - for(int j = 0; j < (int) h_table->de.extent(1); j++) + for (int j = 0; j < (int) h_table->de.extent(1); j++) h_table->de(i,j) = tb->de[j]; - for(int j = 0; j < (int) h_table->f.extent(1); j++) + for (int j = 0; j < (int) h_table->f.extent(1); j++) h_table->f(i,j) = tb->f[j]; - for(int j = 0; j < (int) h_table->df.extent(1); j++) + for (int j = 0; j < (int) h_table->df.extent(1); j++) h_table->df(i,j) = tb->df[j]; - for(int j = 0; j < (int) h_table->e2.extent(1); j++) + for (int j = 0; j < (int) h_table->e2.extent(1); j++) h_table->e2(i,j) = tb->e2[j]; - for(int j = 0; j < (int) h_table->f2.extent(1); j++) + for (int j = 0; j < (int) h_table->f2.extent(1); j++) h_table->f2(i,j) = tb->f2[j]; } @@ -334,14 +334,14 @@ void PairTableKokkos::create_kokkos_tables() Kokkos::deep_copy(d_table->deltasq6,h_table->deltasq6); d_table_const.deltasq6 = d_table->deltasq6; - if(tabstyle == LOOKUP) { + if (tabstyle == LOOKUP) { Kokkos::deep_copy(d_table->e,h_table->e); d_table_const.e = d_table->e; Kokkos::deep_copy(d_table->f,h_table->f); d_table_const.f = d_table->f; } - if(tabstyle == LINEAR) { + if (tabstyle == LINEAR) { Kokkos::deep_copy(d_table->rsq,h_table->rsq); d_table_const.rsq = d_table->rsq; Kokkos::deep_copy(d_table->e,h_table->e); @@ -354,7 +354,7 @@ void PairTableKokkos::create_kokkos_tables() d_table_const.df = d_table->df; } - if(tabstyle == SPLINE) { + if (tabstyle == SPLINE) { Kokkos::deep_copy(d_table->rsq,h_table->rsq); d_table_const.rsq = d_table->rsq; Kokkos::deep_copy(d_table->e,h_table->e); @@ -367,7 +367,7 @@ void PairTableKokkos::create_kokkos_tables() d_table_const.f2 = d_table->f2; } - if(tabstyle == BITMAP) { + if (tabstyle == BITMAP) { Kokkos::deep_copy(d_table->rsq,h_table->rsq); d_table_const.rsq = d_table->rsq; Kokkos::deep_copy(d_table->e,h_table->e); @@ -476,7 +476,7 @@ double PairTableKokkos::init_one(int i, int j) tabindex[j][i] = tabindex[i][j]; - if(i= 0); assert(id < (int)dvector.extent(1)); - for (int ispecies = 0; ispecies < nspecies; ++ispecies){ + for (int ispecies = 0; ispecies < nspecies; ++ispecies) { assert(ispecies < (int)dvector.extent(0)); nTotal += dvector(ispecies,id); assert(ispecies+nspecies < (int)dvector.extent(0)); @@ -82,39 +82,39 @@ void getMixingWeights( assert(isite1 < nspecies); assert(isite2 >= 0); assert(isite2 < nspecies); - if (isOneFluid(isite1) == false){ + if (isOneFluid(isite1) == false) { nMoleculesOld1 = dvector(isite1+nspecies,id); nMolecules1 = dvector(isite1,id); fractionOld1 = nMoleculesOld1/nTotalOld; fraction1 = nMolecules1/nTotal; } - if (isOneFluid(isite2) == false){ + if (isOneFluid(isite2) == false) { nMoleculesOld2 = dvector(isite2+nspecies,id); nMolecules2 = dvector(isite2,id); fractionOld2 = nMoleculesOld2/nTotalOld; fraction2 = nMolecules2/nTotal; } - if (isOneFluid(isite1) || isOneFluid(isite2)){ + if (isOneFluid(isite1) || isOneFluid(isite2)) { nMoleculesOFAold = 0.0; nMoleculesOFA = 0.0; fractionOFAold = 0.0; fractionOFA = 0.0; - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { if (isite1 == ispecies || isite2 == ispecies) continue; nMoleculesOFAold += dvector(ispecies+nspecies,id); nMoleculesOFA += dvector(ispecies,id); fractionOFAold += dvector(ispecies+nspecies,id)/nTotalOld; fractionOFA += dvector(ispecies,id)/nTotal; } - if(isOneFluid(isite1)){ + if (isOneFluid(isite1)) { nMoleculesOld1 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules1 = 1.0-(nTotal-nMoleculesOFA); fractionOld1 = fractionOFAold; fraction1 = fractionOFA; } - if(isOneFluid(isite2)){ + if (isOneFluid(isite2)) { nMoleculesOld2 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules2 = 1.0-(nTotal-nMoleculesOFA); fractionOld2 = fractionOFAold; @@ -122,7 +122,7 @@ void getMixingWeights( } } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old = fractionOld1; mixWtSite1 = fraction1; mixWtSite2old = fractionOld2; @@ -183,15 +183,15 @@ PairTableRXKokkos::~PairTableRXKokkos() template void PairTableRXKokkos::compute(int eflag_in, int vflag_in) { - if(update_table) + if (update_table) create_kokkos_tables(); - if(tabstyle == LOOKUP) + if (tabstyle == LOOKUP) compute_style(eflag_in,vflag_in); - if(tabstyle == LINEAR) + if (tabstyle == LINEAR) compute_style(eflag_in,vflag_in); - if(tabstyle == SPLINE) + if (tabstyle == SPLINE) compute_style(eflag_in,vflag_in); - if(tabstyle == BITMAP) + if (tabstyle == BITMAP) compute_style(eflag_in,vflag_in); } @@ -456,7 +456,7 @@ compute_item( auto rsq = delx*delx + dely*dely + delz*delz; auto jtype = type(j); - if(rsq < (STACKPARAMS ? m_cutsq[itype][jtype] : d_cutsq(itype,jtype))) { + if (rsq < (STACKPARAMS ? m_cutsq[itype][jtype] : d_cutsq(itype,jtype))) { auto mixWtSite1old_j = mixWtSite1old(j); auto mixWtSite2old_j = mixWtSite2old(j); auto mixWtSite1_j = mixWtSite1(j); @@ -669,7 +669,7 @@ void PairTableRXKokkos::compute_style(int eflag_in, int vflag_in) dynamic_cast*>(list); EV_FLOAT ev; - if(atom->ntypes > MAX_TYPES_STACKPARAMS) { + if (atom->ntypes > MAX_TYPES_STACKPARAMS) { if (neighflag == HALFTHREAD) { if (newton_pair) { compute_all_items( @@ -805,12 +805,12 @@ void PairTableRXKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->invdelta,h_table->invdelta,ntables,"Table::invdelta"); memoryKK->create_kokkos(d_table->deltasq6,h_table->deltasq6,ntables,"Table::deltasq6"); - if(tabstyle == LOOKUP) { + if (tabstyle == LOOKUP) { memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tlm1,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tlm1,"Table::f"); } - if(tabstyle == LINEAR) { + if (tabstyle == LINEAR) { memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,tablength,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tablength,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tablength,"Table::f"); @@ -818,7 +818,7 @@ void PairTableRXKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->df,h_table->df,ntables,tlm1,"Table::df"); } - if(tabstyle == SPLINE) { + if (tabstyle == SPLINE) { memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,tablength,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tablength,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tablength,"Table::f"); @@ -826,7 +826,7 @@ void PairTableRXKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->f2,h_table->f2,ntables,tablength,"Table::f2"); } - if(tabstyle == BITMAP) { + if (tabstyle == BITMAP) { int ntable = 1 << tablength; memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,ntable,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,ntable,"Table::e"); @@ -838,7 +838,7 @@ void PairTableRXKokkos::create_kokkos_tables() - for(int i=0; i < ntables; i++) { + for (int i=0; i < ntables; i++) { Table* tb = &tables[i]; h_table->nshiftbits[i] = tb->nshiftbits; @@ -847,21 +847,21 @@ void PairTableRXKokkos::create_kokkos_tables() h_table->invdelta[i] = tb->invdelta; h_table->deltasq6[i] = tb->deltasq6; - for(int j = 0; j < (int)h_table->rsq.extent(1); j++) + for (int j = 0; j < (int)h_table->rsq.extent(1); j++) h_table->rsq(i,j) = tb->rsq[j]; - for(int j = 0; j < (int)h_table->drsq.extent(1); j++) + for (int j = 0; j < (int)h_table->drsq.extent(1); j++) h_table->drsq(i,j) = tb->drsq[j]; - for(int j = 0; j < (int)h_table->e.extent(1); j++) + for (int j = 0; j < (int)h_table->e.extent(1); j++) h_table->e(i,j) = tb->e[j]; - for(int j = 0; j < (int)h_table->de.extent(1); j++) + for (int j = 0; j < (int)h_table->de.extent(1); j++) h_table->de(i,j) = tb->de[j]; - for(int j = 0; j < (int)h_table->f.extent(1); j++) + for (int j = 0; j < (int)h_table->f.extent(1); j++) h_table->f(i,j) = tb->f[j]; - for(int j = 0; j < (int)h_table->df.extent(1); j++) + for (int j = 0; j < (int)h_table->df.extent(1); j++) h_table->df(i,j) = tb->df[j]; - for(int j = 0; j < (int)h_table->e2.extent(1); j++) + for (int j = 0; j < (int)h_table->e2.extent(1); j++) h_table->e2(i,j) = tb->e2[j]; - for(int j = 0; j < (int)h_table->f2.extent(1); j++) + for (int j = 0; j < (int)h_table->f2.extent(1); j++) h_table->f2(i,j) = tb->f2[j]; } @@ -877,14 +877,14 @@ void PairTableRXKokkos::create_kokkos_tables() Kokkos::deep_copy(d_table->deltasq6,h_table->deltasq6); d_table_const.deltasq6 = d_table->deltasq6; - if(tabstyle == LOOKUP) { + if (tabstyle == LOOKUP) { Kokkos::deep_copy(d_table->e,h_table->e); d_table_const.e = d_table->e; Kokkos::deep_copy(d_table->f,h_table->f); d_table_const.f = d_table->f; } - if(tabstyle == LINEAR) { + if (tabstyle == LINEAR) { Kokkos::deep_copy(d_table->rsq,h_table->rsq); d_table_const.rsq = d_table->rsq; Kokkos::deep_copy(d_table->e,h_table->e); @@ -897,7 +897,7 @@ void PairTableRXKokkos::create_kokkos_tables() d_table_const.df = d_table->df; } - if(tabstyle == SPLINE) { + if (tabstyle == SPLINE) { Kokkos::deep_copy(d_table->rsq,h_table->rsq); d_table_const.rsq = d_table->rsq; Kokkos::deep_copy(d_table->e,h_table->e); @@ -910,7 +910,7 @@ void PairTableRXKokkos::create_kokkos_tables() d_table_const.f2 = d_table->f2; } - if(tabstyle == BITMAP) { + if (tabstyle == BITMAP) { Kokkos::deep_copy(d_table->rsq,h_table->rsq); d_table_const.rsq = d_table->rsq; Kokkos::deep_copy(d_table->e,h_table->e); @@ -1038,14 +1038,14 @@ void PairTableRXKokkos::coeff(int narg, char **arg) bcast_table(tb); nspecies = atom->nspecies_dpd; - if(nspecies==0) error->all(FLERR,"There are no rx species specified."); + if (nspecies==0) error->all(FLERR,"There are no rx species specified."); int n; n = strlen(arg[4]) + 1; site1 = new char[n]; strcpy(site1,arg[4]); int ispecies; - for (ispecies = 0; ispecies < nspecies; ispecies++){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { if (strcmp(site1,&atom->dname[ispecies][0]) == 0) break; } if (ispecies == nspecies && strcmp(site1,"1fluid") != 0) @@ -1055,7 +1055,7 @@ void PairTableRXKokkos::coeff(int narg, char **arg) site2 = new char[n]; strcpy(site2,arg[5]); - for (ispecies = 0; ispecies < nspecies; ispecies++){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { if (strcmp(site2,&atom->dname[ispecies][0]) == 0) break; } if (ispecies == nspecies && strcmp(site2,"1fluid") != 0) @@ -1122,8 +1122,8 @@ void PairTableRXKokkos::coeff(int narg, char **arg) else { isite1 = nspecies; - for (int k = 0; k < nspecies; k++){ - if (strcmp(site1, atom->dname[k]) == 0){ + for (int k = 0; k < nspecies; k++) { + if (strcmp(site1, atom->dname[k]) == 0) { isite1 = k; break; } @@ -1137,8 +1137,8 @@ void PairTableRXKokkos::coeff(int narg, char **arg) else { isite2 = nspecies; - for (int k = 0; k < nspecies; k++){ - if (strcmp(site2, atom->dname[k]) == 0){ + for (int k = 0; k < nspecies; k++) { + if (strcmp(site2, atom->dname[k]) == 0) { isite2 = ispecies; break; } @@ -1162,7 +1162,7 @@ double PairTableRXKokkos::init_one(int i, int j) tabindex[j][i] = tabindex[i][j]; - if(i::init_one(int i, int j) k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_sw4.modify(); k_sw5.modify(); - if(istamp(Timer::BOND); } - if(force->kspace) { + if (force->kspace) { force->kspace->setup(); if (kspace_compute_flag) { atomKK->sync(force->kspace->execution_space,force->kspace->datamask_read); @@ -271,7 +271,7 @@ void VerletKokkos::setup_minimal(int flag) timer->stamp(Timer::BOND); } - if(force->kspace) { + if (force->kspace) { force->kspace->setup(); if (kspace_compute_flag) { atomKK->sync(force->kspace->execution_space,force->kspace->datamask_read); @@ -480,11 +480,11 @@ void VerletKokkos::run(int n) timer->stamp(Timer::PAIR); } - if(execute_on_host) { - if(pair_compute_flag && force->pair->datamask_modify!=(F_MASK | ENERGY_MASK | VIRIAL_MASK)) + if (execute_on_host) { + if (pair_compute_flag && force->pair->datamask_modify!=(F_MASK | ENERGY_MASK | VIRIAL_MASK)) Kokkos::fence(); atomKK->sync_overlapping_device(Host,~(~datamask_read_host|(F_MASK | ENERGY_MASK | VIRIAL_MASK))); - if(pair_compute_flag && force->pair->execution_space!=Host) { + if (pair_compute_flag && force->pair->execution_space!=Host) { Kokkos::deep_copy(LMPHostType(),atomKK->k_f.h_view,0.0); } } @@ -520,8 +520,8 @@ void VerletKokkos::run(int n) timer->stamp(Timer::KSPACE); } - if(execute_on_host && !std::is_same::value) { - if(f_merge_copy.extent(0)k_f.extent(0)) { + if (execute_on_host && !std::is_same::value) { + if (f_merge_copy.extent(0)k_f.extent(0)) { f_merge_copy = DAT::t_f_array("VerletKokkos::f_merge_copy",atomKK->k_f.extent(0)); } f = atomKK->k_f.d_view; diff --git a/src/KSPACE/pair_lj_long_coul_long.cpp b/src/KSPACE/pair_lj_long_coul_long.cpp index 27f30ab3a8..ffe7de067b 100644 --- a/src/KSPACE/pair_lj_long_coul_long.cpp +++ b/src/KSPACE/pair_lj_long_coul_long.cpp @@ -530,7 +530,7 @@ void PairLJLongCoulLong::compute(int eflag, int vflag) if (rsq < cut_ljsqi[typej]) { // lj if (order6) { // long-range lj - if(!ndisptablebits || rsq <= tabinnerdispsq) { // series real space + if (!ndisptablebits || rsq <= tabinnerdispsq) { // series real space double rn = r2inv*r2inv*r2inv; double x2 = g2*rsq, a2 = 1.0/x2; x2 = a2*exp(-x2)*lj4i[typej]; diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 0c412cc923..2500336e8f 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -1220,7 +1220,7 @@ void PPPMDisp::compute(int eflag, int vflag) for (i = 0; i < 6; i++) virial[i] = 0.5*qscale*volume*virial_all[i]; MPI_Allreduce(virial_6,virial_all,6,MPI_DOUBLE,MPI_SUM,world); for (i = 0; i < 6; i++) virial[i] += 0.5*volume*virial_all[i]; - if (function[1]+function[2]+function[3]){ + if (function[1]+function[2]+function[3]) { double a = MY_PI*MY_PIS/(6*volume)*pow(g_ewald_6,3)*csumij; virial[0] -= a; virial[1] -= a; @@ -8155,7 +8155,7 @@ int PPPMDisp::timing_1d(int n, double &time1d) for (int i = 0; i < n; i++) { fft1->timing1d(work1,nfft_both,1); fft2->timing1d(work1,nfft_both,-1); - if (differentiation_flag != 1){ + if (differentiation_flag != 1) { fft2->timing1d(work1,nfft_both,-1); fft2->timing1d(work1,nfft_both,-1); } @@ -8173,7 +8173,7 @@ int PPPMDisp::timing_1d(int n, double &time1d) for (int i = 0; i < n; i++) { fft1_6->timing1d(work1_6,nfft_both_6,1); fft2_6->timing1d(work1_6,nfft_both_6,-1); - if (differentiation_flag != 1){ + if (differentiation_flag != 1) { fft2_6->timing1d(work1_6,nfft_both_6,-1); fft2_6->timing1d(work1_6,nfft_both_6,-1); } diff --git a/src/MANYBODY/fix_qeq_comb.cpp b/src/MANYBODY/fix_qeq_comb.cpp index 4edc38b112..75abba2f09 100644 --- a/src/MANYBODY/fix_qeq_comb.cpp +++ b/src/MANYBODY/fix_qeq_comb.cpp @@ -227,8 +227,8 @@ void FixQEQComb::post_force(int /*vflag*/) } comm->forward_comm_fix(this); - if(comb) enegtot = comb->yasu_char(qf,igroup); - if(comb3) enegtot = comb3->combqeq(qf,igroup); + if (comb) enegtot = comb->yasu_char(qf,igroup); + if (comb3) enegtot = comb3->combqeq(qf,igroup); enegtot /= ngroup; enegchk = enegmax = 0.0; diff --git a/src/MANYBODY/pair_adp.cpp b/src/MANYBODY/pair_adp.cpp index 401c1f35ad..02af7bf308 100644 --- a/src/MANYBODY/pair_adp.cpp +++ b/src/MANYBODY/pair_adp.cpp @@ -543,7 +543,7 @@ void PairADP::read_file(char *filename) Setfl *file = setfl; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "adp"); try { diff --git a/src/MANYBODY/pair_airebo.cpp b/src/MANYBODY/pair_airebo.cpp index 4a0c2a874d..44042bd133 100644 --- a/src/MANYBODY/pair_airebo.cpp +++ b/src/MANYBODY/pair_airebo.cpp @@ -3489,7 +3489,7 @@ void PairAIREBO::read_file(char *filename) // global parameters current_section = "global parameters"; - for(int i = 0; i < (int)params.size(); i++) { + for (int i = 0; i < (int)params.size(); i++) { *params[i] = reader.next_double(); } @@ -4381,22 +4381,22 @@ void PairAIREBO::spline_init() // make top end of piCC flat instead of zero i = 4; - for (j = 0; j < 4; j++){ - for (k = 1; k < 11; k++){ + for (j = 0; j < 4; j++) { + for (k = 1; k < 11; k++) { piCCf[i][j][k] = piCCf[i-1][j][k]; } } - for (i = 0; i < 4; i++){ // also enforces some symmetry - for (j = i+1; j < 5; j++){ - for (k = 1; k < 11; k++){ + for (i = 0; i < 4; i++) { // also enforces some symmetry + for (j = i+1; j < 5; j++) { + for (k = 1; k < 11; k++) { piCCf[i][j][k] = piCCf[j][i][k]; } } } for (k = 1; k < 11; k++) piCCf[4][4][k] = piCCf[3][4][k]; k = 10; - for (i = 0; i < 5; i++){ - for (j = 0; j < 5; j++){ + for (i = 0; i < 5; i++) { + for (j = 0; j < 5; j++) { piCCf[i][j][k] = piCCf[i][j][k-1]; } } @@ -4424,22 +4424,22 @@ void PairAIREBO::spline_init() // also enforces some symmetry i = 4; - for (j = 0; j < 4; j++){ - for (k = 1; k < 11; k++){ + for (j = 0; j < 4; j++) { + for (k = 1; k < 11; k++) { piCHf[i][j][k] = piCHf[i-1][j][k]; } } - for (i = 0; i < 4; i++){ - for (j = i+1; j < 5; j++){ - for (k = 1; k < 11; k++){ + for (i = 0; i < 4; i++) { + for (j = i+1; j < 5; j++) { + for (k = 1; k < 11; k++) { piCHf[i][j][k] = piCHf[j][i][k]; } } } for (k = 1; k < 11; k++) piCHf[4][4][k] = piCHf[3][4][k]; k = 10; - for (i = 0; i < 5; i++){ - for (j = 0; j < 5; j++){ + for (i = 0; i < 5; i++) { + for (j = 0; j < 5; j++) { piCHf[i][j][k] = piCHf[i][j][k-1]; } } diff --git a/src/MANYBODY/pair_bop.cpp b/src/MANYBODY/pair_bop.cpp index 29fd8b63c6..9f12b0755a 100644 --- a/src/MANYBODY/pair_bop.cpp +++ b/src/MANYBODY/pair_bop.cpp @@ -181,7 +181,7 @@ PairBOP::PairBOP(LAMMPS *lmp) : Pair(lmp) PairBOP::~PairBOP() { - if(allocated) { + if (allocated) { memory_theta_destroy(); if (otfly==0) memory->destroy(cos_index); delete [] map; @@ -319,16 +319,16 @@ void PairBOP::compute(int eflag, int vflag) itype=map[type[i]]+1; iilist=firstneigh[i]; nlisti=BOP_total[i]; - for(jj=0;jj=i_tag) { + if (j_tag>=i_tag) { sigB_0=sigmaBo(ii,jj); piB_0=PiBo(ii,jj); - if(otfly==0) { - if(neigh_flag[temp_ij]) { + if (otfly==0) { + if (neigh_flag[temp_ij]) { dpr1=(dRepul[temp_ij]-2.0*dBetaS[temp_ij]*sigB_0 -2.0*dBetaP[temp_ij]*piB_0)/rij[temp_ij]; ftmp1=dpr1*disij[0][temp_ij]; @@ -345,7 +345,7 @@ void PairBOP::compute(int eflag, int vflag) dE=-2.0*betaS[temp_ij]*sigB_0-2.0*betaP[temp_ij]*piB_0; totE+=dE+repul[temp_ij]; - if(evflag) { + if (evflag) { ev_tally_full(i,repul[temp_ij],dE,0.0,0.0,0.0,0.0); ev_tally_full(j,repul[temp_ij],dE,0.0,0.0,0.0,0.0); ev_tally_xyz(i,j,nlocal,newton_pair,0.0,0.0,-ftmp1,-ftmp2,-ftmp3, @@ -354,9 +354,9 @@ void PairBOP::compute(int eflag, int vflag) } } else { - if(itype==jtype) + if (itype==jtype) iij=itype-1; - else if(itype1.0) + if (ps>1.0) ps=1.0; betaS_ij=((pBetaS3[iij][ks-1]*ps+pBetaS2[iij][ks-1])*ps +pBetaS1[iij][ks-1])*ps+pBetaS[iij][ks-1]; @@ -404,7 +404,7 @@ void PairBOP::compute(int eflag, int vflag) dE=-2.0*betaS_ij*sigB_0-2.0*betaP_ij*piB_0; totE+=dE+repul_ij; - if(evflag) { + if (evflag) { ev_tally_full(i,repul_ij,dE,0.0,0.0,0.0,0.0); ev_tally_full(j,repul_ij,dE,0.0,0.0,0.0,0.0); ev_tally_xyz(i,j,nlocal,newton_pair,0.0,0.0,-ftmp1,-ftmp2,-ftmp3, @@ -423,16 +423,16 @@ void PairBOP::compute(int eflag, int vflag) itype=map[type[i]]+1; iilist=firstneigh[i]; nlisti=BOP_total3[i]; - for(jj=0;jj1.0) + if (ps>1.0) ps=1.0; value=((pLong3[i12][ks-1]*ps+pLong2[i12][ks-1])*ps+ pLong1[i12][ks-1])*ps+pLong[i12][ks-1]; - if(value<=0.0) value=pLong[i12][ks-1]; + if (value<=0.0) value=pLong[i12][ks-1]; dvalue=(pLong6[i12][ks-1]*ps+ pLong5[i12][ks-1])*ps+pLong4[i12][ks-1]; dpr1=-dvalue/r_ij; @@ -469,7 +469,7 @@ void PairBOP::compute(int eflag, int vflag) f[j][1]=f[j][1]-ftmp2; f[j][2]=f[j][2]-ftmp3; totE=totE-value; - if(evflag) { + if (evflag) { ev_tally_full(i,0,-value,0.0,0.0,0.0,0.0); ev_tally_full(j,0,-value,0.0,0.0,0.0,0.0); ev_tally_xyz(i,j,nlocal,newton_pair,0.0,0.0,-ftmp1,-ftmp2,-ftmp3, @@ -717,7 +717,7 @@ double PairBOP::init_one(int i, int j) else ij=jj*bop_types-jj*(jj+1)/2+ii-1; - if(rcut[ij]>rcut3[ij]) { + if (rcut[ij]>rcut3[ij]) { cutghost[i][j] = rcut[ij]; cutghost[j][i] = cutghost[i][j]; cutsq[i][j] = rcut[ij]*rcut[ij]; @@ -759,7 +759,7 @@ void PairBOP::gneigh() double **x = atom->x; int *type = atom->type; - if(allocate_neigh==0) { + if (allocate_neigh==0) { memory->create(BOP_index,nall,"BOP_index"); memory->create(BOP_index3,nall,"BOP_index3"); memory->create(BOP_total,nall,"BOP_total"); @@ -777,7 +777,7 @@ void PairBOP::gneigh() ilist = list->ilist; numneigh = list->numneigh; firstneigh = list->firstneigh; - if(bop_step==0) { + if (bop_step==0) { maxneigh=0; maxneigh3=0; maxnall=0; @@ -786,7 +786,7 @@ void PairBOP::gneigh() neigh_total3=0; cos_total=0; for (ii = 0; ii < nall; ii++) { - if(ii=npairs) { + if (i12>=npairs) { error->one(FLERR,"Too many atom pairs for pair bop"); } dis[0]=x[j][0]-x[i][0]; @@ -814,10 +814,10 @@ void PairBOP::gneigh() +dis[1]*dis[1] +dis[2]*dis[2]; r=sqrt(rsq); - if(r<=rcut[i12]) { + if (r<=rcut[i12]) { max_check++; } - if(r<=rcut3[i12]) { + if (r<=rcut3[i12]) { max_check3++; } } @@ -829,23 +829,23 @@ void PairBOP::gneigh() neigh_total+=max_check; neigh_total3+=max_check3; - if(max_check>maxneigh||max_check3>maxneigh3){ + if (max_check>maxneigh||max_check3>maxneigh3) { maxneigh=max_check; maxneigh3=max_check3; } - if(otfly==0) { + if (otfly==0) { cos_index[i]=cos_total; cos_total+=max_check*(max_check-1)/2; } } maxnall=nall; - if(update_list!=0) + if (update_list!=0) memory_theta_grow(); else memory_theta_create(); neigh_t=0; for (ii = 0; ii < nall; ii++) { - if(ii=npairs) { + if (i12>=npairs) { error->one(FLERR,"Too many atom pairs for pair bop"); } dis[0]=x[j][0]-x[i][0]; @@ -872,15 +872,15 @@ void PairBOP::gneigh() +dis[1]*dis[1] +dis[2]*dis[2]; r=sqrt(rsq); - if(r<=rcut[i12]) { + if (r<=rcut[i12]) { temp_ij=BOP_index[i]+max_check; - if(i==0) { + if (i==0) { } neigh_index[temp_ij]=jj; neigh_flag[temp_ij]=1; max_check++; } - if(r<=rcut3[i12]) { + if (r<=rcut3[i12]) { temp_ij=BOP_index3[i]+max_check3; neigh_index3[temp_ij]=jj; neigh_flag3[temp_ij]=1; @@ -888,9 +888,9 @@ void PairBOP::gneigh() } } } - if(otfly==0) { + if (otfly==0) { for (ii = 0; ii < nall; ii++) { - if(ii=neigh_total) { + if (temp_ij>=neigh_total) { } - if(temp_ij<0) { + if (temp_ij<0) { } jtype = map[type[j]]+1; - if(itype==jtype) + if (itype==jtype) i12=itype-1; - else if(itype=npairs) { + if (i12>=npairs) { error->one(FLERR,"Too many atom pairs for pair bop"); } disij[0][temp_ij]=x[j][0]-x[i][0]; @@ -923,7 +923,7 @@ void PairBOP::gneigh() +disij[1][temp_ij]*disij[1][temp_ij] +disij[2][temp_ij]*disij[2][temp_ij]; rij[temp_ij]=sqrt(rsq); - if(rij[temp_ij]<=rcut[i12]) { + if (rij[temp_ij]<=rcut[i12]) { max_check++; } else @@ -932,7 +932,7 @@ void PairBOP::gneigh() } neigh_t+=max_check; for (ii = 0; ii < nall; ii++) { - if(ii=npairs) { + if (i12>=npairs) { error->one(FLERR,"Too many atom pairs for pair bop"); } ps=rij[temp_ij]*rdr[i12]+1.0; ks=(int)ps; - if(nr-11.0) + if (ps>1.0) ps=1.0; betaS[temp_ij]=((pBetaS3[i12][ks-1]*ps+pBetaS2[i12][ks-1])*ps+pBetaS1[i12][ks-1])*ps+pBetaS[i12][ks-1]; dBetaS[temp_ij]=(pBetaS6[i12][ks-1]*ps+pBetaS5[i12][ks-1])*ps @@ -977,29 +977,29 @@ void PairBOP::gneigh() } for (ii = 0; ii < nall; ii++) { n=0; - if(ii=cos_total) { + for (kk=jj+1;kk=cos_total) { error->one(FLERR,"Too many atom triplets for pair bop"); } temp_ik=BOP_index[i]+kk; temp_ijk=cos_index[i]+n; - if(temp_ijk>=cos_total) { + if (temp_ijk>=cos_total) { error->one(FLERR,"Too many atom triplets for pair bop"); } rk2=rij[temp_ik]*rij[temp_ik]; rj1k1=rij[temp_ij]*rij[temp_ik]; rj2k2=rj1k1*rj1k1; - if(temp_ijk>=cos_total) { + if (temp_ijk>=cos_total) { error->one(FLERR,"Too many atom triplets for pair bop"); } cosAng[temp_ijk]=(disij[0][temp_ij]*disij[0][temp_ik]+disij[1][temp_ij] @@ -1128,12 +1128,12 @@ double PairBOP::sigmaBo(int itmp, int jtmp) ilist = list->ilist; firstneigh = list->firstneigh; - if(nb_sg==0) { + if (nb_sg==0) { nb_sg=(maxneigh)*(maxneigh/2); } create_sigma(nb_sg); sigB=0; - if(itmpnb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -1166,27 +1166,27 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_ij].temp=temp_ij; bt_sg[nb_ij].i=i; bt_sg[nb_ij].j=j; - if(j_tag>=i_tag) { - if(itype==jtype) + if (j_tag>=i_tag) { + if (itype==jtype) iij=itype-1; - else if(itype1.0) + if (ps>1.0) ps=1.0; betaS_ij=((pBetaS3[iij][ks-1]*ps+pBetaS2[iij][ks-1])*ps +pBetaS1[iij][ks-1])*ps+pBetaS[iij][ks-1]; @@ -1209,7 +1209,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) +pBetaS4[iij][ks-1]; } } else { - if(neigh_flag[temp_ij]) { + if (neigh_flag[temp_ij]) { pass_ij=1; dis_ij[0]=disij[0][temp_ij]; dis_ij[1]=disij[1][temp_ij]; @@ -1219,7 +1219,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) dBetaS_ij=dBetaS[temp_ij]; } } - if(pass_ij==1) { + if (pass_ij==1) { nSigBk=0; //AA-EE1 are the components making up Eq. 30 (a) @@ -1249,16 +1249,16 @@ double PairBOP::sigmaBo(int itmp, int jtmp) //k is loop over all neighbors of i again with j neighbor of i nlisti=BOP_total[i]; - for(ktmp=0;ktmp1.0) + if (ps>1.0) ps=1.0; betaS_ik=((pBetaS3[iik][ks-1]*ps+pBetaS2[iik][ks-1])*ps +pBetaS1[iik][ks-1])*ps+pBetaS[iik][ks-1]; @@ -1301,7 +1301,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) +pBetaS4[iik][ks-1]; } } else { - if(neigh_flag[temp_ik]) { + if (neigh_flag[temp_ik]) { pass_ik=1; dis_ik[0]=disij[0][temp_ik]; dis_ik[1]=disij[1][temp_ik]; @@ -1311,17 +1311,17 @@ double PairBOP::sigmaBo(int itmp, int jtmp) dBetaS_ik=dBetaS[temp_ik]; } } - if(pass_ik==1) { + if (pass_ik==1) { //find neighbor of i that is equal to k nlistj=BOP_total[j]; - for(jNeik=0;jNeiknb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -1390,7 +1390,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_ik].j=k; nb_jk=nb_t; nb_t++; - if(nb_t>nb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -1398,7 +1398,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_jk].temp=temp_jk; bt_sg[nb_jk].i=j; bt_sg[nb_jk].j=k; - if(otfly==1) { + if (otfly==1) { cosAng_jik=(dis_ij[0]*dis_ik[0]+dis_ij[1]*dis_ik[1] +dis_ij[2]*dis_ik[2])/(r_ij*r_ik); dcA_jik[0][0]=(dis_ik[0]*r_ij*r_ik-cosAng_jik @@ -1415,8 +1415,8 @@ double PairBOP::sigmaBo(int itmp, int jtmp) dcA_jik[2][1]=(dis_ij[2]*r_ij*r_ik-cosAng_jik *dis_ik[2]*r_ij*r_ij)/(r_ij*r_ij*r_ik*r_ik); } else { - if(ktmp!=jtmp) { - if(jtmp1.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor1=((gfunc3[jtype][itype][ktype][ks]*ps+ @@ -1458,7 +1458,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor1=gpara[jtype-1][itype-1][ktype-1][0]; gprime1=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_jkp=((pBetaS3[ijkp][ks-1]*ps+pBetaS2[ijkp][ks-1])*ps +pBetaS1[ijkp][ks-1])*ps+pBetaS[ijkp][ks-1]; @@ -1600,7 +1600,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) *dis_jk[2]*r_ij*r_ij)/(r_ij*r_ij*r_jk*r_jk); } } else { - if(neigh_flag[temp_jkp]) { + if (neigh_flag[temp_jkp]) { pass_jkp=1; dis_jkp[0]=disij[0][temp_jkp]; dis_jkp[1]=disij[1][temp_jkp]; @@ -1608,7 +1608,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) r_jkp=rij[temp_jkp]; betaS_jkp=betaS[temp_jkp]; dBetaS_jkp=dBetaS[temp_jkp]; - if(ji1.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor2=((gfunc3[itype][jtype][ktype][ks]*ps+ @@ -1651,13 +1651,13 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor2=gpara[itype-1][jtype-1][ktype-1][0]; gprime2=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor3=((gfunc3[itype][jtype][jtype][ks]*ps+ @@ -1715,7 +1715,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor3=gpara[itype-1][ktype-1][jtype-1][0]; gprime3=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_ikp=((pBetaS3[iikp][ks-1]*ps+pBetaS2[iikp][ks-1])*ps +pBetaS1[iikp][ks-1])*ps+pBetaS[iikp][ks-1]; @@ -1824,7 +1824,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) +pBetaS4[iikp][ks-1]; } } else { - if(neigh_flag[temp_ikp]) { + if (neigh_flag[temp_ikp]) { pass_ikp=1; dis_ikp[0]=disij[0][temp_ikp]; dis_ikp[1]=disij[1][temp_ikp]; @@ -1834,10 +1834,10 @@ double PairBOP::sigmaBo(int itmp, int jtmp) dBetaS_ikp=dBetaS[temp_ikp]; } } - if(pass_ikp==1) { + if (pass_ikp==1) { nb_ikp=nb_t; nb_t++; - if(nb_t>nb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -1845,7 +1845,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_ikp].temp=temp_ikp; bt_sg[nb_ikp].i=i; bt_sg[nb_ikp].j=kp; - if(otfly==1) { + if (otfly==1) { cosAng_jikp=(dis_ij[0]*dis_ikp[0]+dis_ij[1]*dis_ikp[1] +dis_ij[2]*dis_ikp[2])/(r_ij*r_ikp); dcA_jikp[0][0]=(dis_ikp[0]*r_ij*r_ikp-cosAng_jikp @@ -1875,7 +1875,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) dcA_kikp[2][1]=(dis_ik[2]*r_ik*r_ikp-cosAng_kikp *dis_ikp[2]*r_ik*r_ik)/(r_ik*r_ik*r_ikp*r_ikp); } else { - if(jtmp1.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor2=((gfunc3[jtype][itype][kptype][ks]*ps+ @@ -1934,21 +1934,21 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor2=gpara[jtype-1][itype-1][kptype-1][0]; gprime2=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor3=((gfunc3[ktype][itype][kptype][ks]*ps+ @@ -1962,7 +1962,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor3=gpara[ktype-1][itype-1][kptype-1][0]; gprime3=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_kkp=((pBetaS3[ikkp][ks-1]*ps+pBetaS2[ikkp][ks-1])*ps +pBetaS1[ikkp][ks-1])*ps+pBetaS[ikkp][ks-1]; @@ -2080,7 +2080,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) +pBetaS4[ikkp][ks-1]; } } else { - if(neigh_flag[temp_kkp]) { + if (neigh_flag[temp_kkp]) { pass_kkp=1; dis_kkp[0]=disij[0][temp_kkp]; dis_kkp[1]=disij[1][temp_kkp]; @@ -2090,13 +2090,13 @@ double PairBOP::sigmaBo(int itmp, int jtmp) dBetaS_kkp=dBetaS[temp_kkp]; } } - if(pass_kkp==1) { + if (pass_kkp==1) { sig_flag=0; - for(nsearch=0;nsearchnb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -2156,14 +2156,14 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_kkp].i=k; bt_sg[nb_kkp].j=kp; amean=cosAng_ikkp; - if(amean<-1.0) amean=-1.0; - if(npower<=2) { + if (amean<-1.0) amean=-1.0; + if (npower<=2) { ps=(amean-1.0)*rdtheta+1.0; ks=(int)ps; - if(ntheta-11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor2=((gfunc3[itype][ktype][kptype][ks]*ps+ @@ -2177,7 +2177,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor2=gpara[itype-1][ktype-1][kptype-1][0]; gprime2=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_jkp=((pBetaS3[ijkp][ks-1]*ps+pBetaS2[ijkp][ks-1])*ps +pBetaS1[ijkp][ks-1])*ps+pBetaS[ijkp][ks-1]; @@ -2350,10 +2350,10 @@ double PairBOP::sigmaBo(int itmp, int jtmp) r_kkp=sqrt(rsq_kkp); ps=r_kkp*rdr[ikkp]+1.0; ks=(int)ps; - if(nr-11.0) + if (ps>1.0) ps=1.0; betaS_kkp=((pBetaS3[ikkp][ks-1]*ps+pBetaS2[ikkp][ks-1])*ps +pBetaS1[ikkp][ks-1])*ps+pBetaS[ikkp][ks-1]; @@ -2414,7 +2414,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) r_kkp=rij[temp_kkp]; betaS_kkp=betaS[temp_kkp]; dBetaS_kkp=dBetaS[temp_kkp]; - if(jinb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -2500,7 +2500,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_jkp].j=kp; nb_kkp=nb_t; nb_t++; - if(nb_t>nb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -2509,14 +2509,14 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_kkp].i=k; bt_sg[nb_kkp].j=kp; amean=cosAng_ijkp; - if(amean<-1.0) amean=-1.0; - if(npower<=2) { + if (amean<-1.0) amean=-1.0; + if (npower<=2) { ps=(amean-1.0)*rdtheta+1.0; ks=(int)ps; - if(ntheta-11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor2=((gfunc3[itype][jtype][kptype][ks]*ps+ @@ -2530,21 +2530,21 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor2=gpara[itype-1][jtype-1][kptype-1][0]; gprime2=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor3=((gfunc3[itype][ktype][kptype][ks]*ps+ @@ -2558,21 +2558,21 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor3=gpara[itype-1][ktype-1][kptype-1][0]; gprime3=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor4=((gfunc3[jtype][kptype][ktype][ks]*ps+ @@ -2586,7 +2586,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor4=gpara[jtype-1][kptype-1][ktype-1][0]; gprime4=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_jk=((pBetaS3[ijk][ks-1]*ps+pBetaS2[ijk][ks-1])*ps +pBetaS1[ijk][ks-1])*ps+pBetaS[ijk][ks-1]; @@ -2753,7 +2753,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) *dis_jk[2]*r_ij*r_ij)/(r_ij*r_ij*r_jk*r_jk); } } else { - if(neigh_flag[temp_jk]) { + if (neigh_flag[temp_jk]) { pass_jk=1; dis_jk[0]=disij[0][temp_jk]; dis_jk[1]=disij[1][temp_jk]; @@ -2761,7 +2761,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) r_jk=rij[temp_jk]; betaS_jk=betaS[temp_jk]; dBetaS_jk=dBetaS[temp_jk]; - if(ktmpnb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -2793,14 +2793,14 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_jk].i=j; bt_sg[nb_jk].j=k; amean=cosAng_ijk; - if(amean<-1.0) amean=-1.0; - if(npower<=2) { + if (amean<-1.0) amean=-1.0; + if (npower<=2) { ps=(amean-1.0)*rdtheta+1.0; ks=(int)ps; - if(ntheta-11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor1=((gfunc3[itype][jtype][ktype][ks]*ps+ @@ -2814,7 +2814,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor1=gpara[itype-1][jtype-1][ktype-1][0]; gprime1=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_jkp=((pBetaS3[ijkp][ks-1]*ps+pBetaS2[ijkp][ks-1])*ps +pBetaS1[ijkp][ks-1])*ps+pBetaS[ijkp][ks-1]; @@ -2947,7 +2947,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) *dis_jkp[2]*r_jk*r_jk)/(r_jk*r_jk*r_jkp*r_jkp); } } else { - if(neigh_flag[temp_jkp]) { + if (neigh_flag[temp_jkp]) { pass_jkp=1; dis_jkp[0]=disij[0][temp_jkp]; dis_jkp[1]=disij[1][temp_jkp]; @@ -2955,7 +2955,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) r_jkp=rij[temp_jkp]; betaS_jkp=betaS[temp_jkp]; dBetaS_jkp=dBetaS[temp_jkp]; - if(jinb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -3005,14 +3005,14 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_jkp].i=j; bt_sg[nb_jkp].j=kp; amean=cosAng_ijkp; - if(amean<-1.0) amean=-1.0; - if(npower<=2) { + if (amean<-1.0) amean=-1.0; + if (npower<=2) { ps=(amean-1.0)*rdtheta+1.0; ks=(int)ps; - if(ntheta-11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor2=((gfunc3[itype][jtype][kptype][ks]*ps+ @@ -3026,21 +3026,21 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor2=gpara[itype-1][jtype-1][kptype-1][0]; gprime2=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor3=((gfunc3[ktype][jtype][kptype][ks]*ps+ @@ -3054,7 +3054,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor3=gpara[ktype-1][jtype-1][kptype-1][0]; gprime3=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_kkp=((pBetaS3[ikkp][ks-1]*ps+pBetaS2[ikkp][ks-1])*ps +pBetaS1[ikkp][ks-1])*ps+pBetaS[ikkp][ks-1]; @@ -3217,7 +3217,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) *dis_kkp[2]*r_jk*r_jk)/(r_jk*r_jk*r_kkp*r_kkp); } } else { - if(neigh_flag[temp_kkp]) { + if (neigh_flag[temp_kkp]) { pass_kkp=1; dis_kkp[0]=disij[0][temp_kkp]; dis_kkp[1]=disij[1][temp_kkp]; @@ -3225,7 +3225,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) r_kkp=rij[temp_kkp]; betaS_kkp=betaS[temp_kkp]; dBetaS_kkp=dBetaS[temp_kkp]; - if(kNeijnb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -3257,14 +3257,14 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_kkp].i=k; bt_sg[nb_kkp].j=kp; amean=cosAng_jkkp; - if(amean<-1.0) amean=-1.0; - if(npower<=2) { + if (amean<-1.0) amean=-1.0; + if (npower<=2) { ps=(amean-1.0)*rdtheta+1.0; ks=(int)ps; - if(ntheta-11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor2=((gfunc3[jtype][ktype][kptype][ks]*ps+ @@ -3278,7 +3278,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor2=gpara[jtype-1][ktype-1][kptype-1][0]; gprime2=0.0; xrun=1.0; - for(lp1=1;lp1-1)&&(bt_sg[m].j>-1)) { + for (m=0;m-1)&&(bt_sg[m].j>-1)) { bt_sg[m].dAAC[0]=bt_sg[m].dAA[0] +bt_sg[m].dBB[0]; bt_sg[m].dAAC[1]=bt_sg[m].dAA[1] @@ -3372,10 +3372,10 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bndtmp1=bndtmp1*dBetaS_ij/r_ij; bndtmp2=betaS_ij*bndtmp*sigma_c[iij]; setting=0; - for(m=0;m-1)&&(bt_sg[m].j>-1)) { + for (m=0;m-1)&&(bt_sg[m].j>-1)) { temp_kk=bt_sg[m].temp; - if(temp_kk==temp_ij&&setting==0) { + if (temp_kk==temp_ij&&setting==0) { bt_sg[m].dSigB1[0]=bndtmp1*dis_ij[0] +bndtmp2*bt_sg[m].dAAC[0]; bt_sg[m].dSigB1[1]=bndtmp1*dis_ij[1] @@ -3384,7 +3384,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) +bndtmp2*bt_sg[m].dAAC[2]; setting=1; } - else if(temp_kk==temp_ji&&setting==0) { + else if (temp_kk==temp_ji&&setting==0) { bt_sg[m].dSigB1[0]=-bndtmp1*dis_ij[0] +bndtmp2*bt_sg[m].dAAC[0]; bt_sg[m].dSigB1[1]=-bndtmp1*dis_ij[1] @@ -3402,14 +3402,14 @@ double PairBOP::sigmaBo(int itmp, int jtmp) } } } else { - if(sig_flag==0) { - if(AA<0.0) + if (sig_flag==0) { + if (AA<0.0) AA=0.0; - if(BB<0.0) + if (BB<0.0) BB=0.0; - if(CC<0.0) + if (CC<0.0) CC=0.0; - if(DD<0.0) + if (DD<0.0) DD=0.0; // AA and BB are the representations of (a) Eq. 34 and (b) Eq. 9 @@ -3421,11 +3421,11 @@ double PairBOP::sigmaBo(int itmp, int jtmp) DDC=CC+DD; //EEC is a modified form of (a) Eq. 33 - if(DDC-1)&&(bt_sg[m].j>-1)) { + for (m=0;m-1)&&(bt_sg[m].j>-1)) { bt_sg[m].dAAC[0]=bt_sg[m].dAA[0] +bt_sg[m].dBB[0]; bt_sg[m].dAAC[1]=bt_sg[m].dAA[1] @@ -3473,8 +3473,8 @@ double PairBOP::sigmaBo(int itmp, int jtmp) *(1.0+sigma_a[iij]*GGC)+sigma_c[iij]*(AAC+sigma_a[iij]*EE +sigma_a[iij]*FFC*(2.0+GGC))+small4; UTcom=-0.5*UT*UT*UT; - for(m=0;m-1)&&(bt_sg[m].j>-1)) { + for (m=0;m-1)&&(bt_sg[m].j>-1)) { bt_sg[m].dUT[0]=UTcom*(bt_sg[m].dEEC[0]*FF +EEC*bt_sg[m].dFF[0]+bt_sg[m].dBBC[0]); bt_sg[m].dUT[1]=UTcom*(bt_sg[m].dEEC[1]*FF @@ -3496,7 +3496,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) } } psign=1.0; - if(1.0+sigma_a[iij]*GGC<0.0) + if (1.0+sigma_a[iij]*GGC<0.0) psign=-1.0; bndtmp0=1.0/sqrt(bndtmp); sigB1=psign*betaS_ij*(1.0+sigma_a[iij]*GGC)*bndtmp0; @@ -3515,10 +3515,10 @@ double PairBOP::sigmaBo(int itmp, int jtmp) *(2.0*(FF+sigma_delta[iij]*sigma_delta[iij])*(1.0 +sigma_a[iij]*GGC)*sigma_a[iij]+sigma_c[iij]*sigma_a[iij]*FFC); setting=0; - for(m=0;m-1)&&(bt_sg[m].j>-1)) { + for (m=0;m-1)&&(bt_sg[m].j>-1)) { temp_kk=bt_sg[m].temp; - if(temp_kk==temp_ij&&setting==0) { + if (temp_kk==temp_ij&&setting==0) { bt_sg[m].dSigB1[0]=bndtmp1*dis_ij[0] +(bndtmp2*bt_sg[m].dAAC[0] +bndtmp3*bt_sg[m].dEE[0] @@ -3536,7 +3536,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) +bndtmp5*bt_sg[m].dGGC[2]); setting=1; } - else if(temp_kk==temp_ji&&setting==0) { + else if (temp_kk==temp_ji&&setting==0) { bt_sg[m].dSigB1[0]=-bndtmp1*dis_ij[0] +(bndtmp2*bt_sg[m].dAAC[0] +bndtmp3*bt_sg[m].dEE[0] @@ -3577,8 +3577,8 @@ double PairBOP::sigmaBo(int itmp, int jtmp) // sigB is the final expression for (a) Eq. 6 and (b) Eq. 11 - if(nb_t==0) { - if(j>i) { + if (nb_t==0) { + if (j>i) { bt_sg[0].dSigB1[0]=bndtmp1*dis_ij[0]; bt_sg[0].dSigB1[1]=bndtmp1*dis_ij[1]; bt_sg[0].dSigB1[2]=bndtmp1*dis_ij[2]; @@ -3588,13 +3588,13 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[0].dSigB1[1]=-bndtmp1*dis_ij[1]; bt_sg[0].dSigB1[2]=-bndtmp1*dis_ij[2]; } - for(pp=0;pp<3;pp++) { + for (pp=0;pp<3;pp++) { bt_sg[0].dAA[pp]=0.0; bt_sg[0].dBB[pp]=0.0; bt_sg[0].dAAC[pp]=0.0; bt_sg[0].dSigB1[pp]=0.0; bt_sg[0].dSigB[pp]=0.0; - if(sigma_f[iij]!=0.5&&sigma_k[iij]!=0.0) { + if (sigma_f[iij]!=0.5&&sigma_k[iij]!=0.0) { bt_sg[0].dCC[pp]=0.0; bt_sg[0].dDD[pp]=0.0; bt_sg[0].dEE[pp]=0.0; @@ -3613,7 +3613,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[0].j=j; bt_sg[0].temp=temp_ij; nb_t++; - if(nb_t>nb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -3621,35 +3621,35 @@ double PairBOP::sigmaBo(int itmp, int jtmp) } ps=sigB1*rdBO+1.0; ks=(int)ps; - if(nBOt-11.0) + if (ps>1.0) ps=1.0; dsigB1=((FsigBO3[iij][ks-1]*ps+FsigBO2[iij][ks-1])*ps +FsigBO1[iij][ks-1])*ps+FsigBO[iij][ks-1]; dsigB2=(FsigBO6[iij][ks-1]*ps+FsigBO5[iij][ks-1])*ps+FsigBO4[iij][ks-1]; - for(m=0;m-1)&&(bt_sg[m].j>-1)) { + for (m=0;m-1)&&(bt_sg[m].j>-1)) { temp_kk=bt_sg[m].temp; bt_i=bt_sg[m].i; bt_j=bt_sg[m].j; - if(sigma_f[iij]==0.5&&sigma_k[iij]==0.0) { + if (sigma_f[iij]==0.5&&sigma_k[iij]==0.0) { sigB=dsigB1; pp1=2.0*betaS_ij; xtmp[0]=x[bt_j][0]-x[bt_i][0]; xtmp[1]=x[bt_j][1]-x[bt_i][1]; xtmp[2]=x[bt_j][2]-x[bt_i][2]; - for(pp=0;pp<3;pp++) { + for (pp=0;pp<3;pp++) { bt_sg[m].dSigB[pp]=dsigB2*bt_sg[m].dSigB1[pp]; } - for(pp=0;pp<3;pp++) { + for (pp=0;pp<3;pp++) { ftmp[pp]=pp1*bt_sg[m].dSigB[pp]; f[bt_i][pp]-=ftmp[pp]; f[bt_j][pp]+=ftmp[pp]; } - if(evflag) { + if (evflag) { ev_tally_xyz(bt_i,bt_j,nlocal,newton_pair,0.0,0.0,ftmp[0],ftmp[1] ,ftmp[2],xtmp[0],xtmp[1],xtmp[2]); } @@ -3668,18 +3668,18 @@ double PairBOP::sigmaBo(int itmp, int jtmp) xtmp[0]=x[bt_j][0]-x[bt_i][0]; xtmp[1]=x[bt_j][1]-x[bt_i][1]; xtmp[2]=x[bt_j][2]-x[bt_i][2]; - for(pp=0;pp<3;pp++) { + for (pp=0;pp<3;pp++) { bt_sg[m].dSigB[pp]=dsigB2*part2*bt_sg[m].dSigB1[pp] -part3*bt_sg[m].dEE1[pp] +part4*(bt_sg[m].dFF[pp] +0.5*bt_sg[m].dAAC[pp]); } - for(pp=0;pp<3;pp++) { + for (pp=0;pp<3;pp++) { ftmp[pp]=pp1*bt_sg[m].dSigB[pp]; f[bt_i][pp]-=ftmp[pp]; f[bt_j][pp]+=ftmp[pp]; } - if(evflag) { + if (evflag) { ev_tally_xyz(bt_i,bt_j,nlocal,newton_pair,0.0,0.0,ftmp[0],ftmp[1] ,ftmp[2],xtmp[0],xtmp[1],xtmp[2]); } @@ -3776,10 +3776,10 @@ double PairBOP::PiBo(int itmp, int jtmp) firstneigh = list->firstneigh; ilist = list->ilist; n=0; - if(nb_pi>16) { + if (nb_pi>16) { nb_pi=16; } - if(nb_pi==0) { + if (nb_pi==0) { nb_pi=(maxneigh)*(maxneigh/2); } @@ -3793,8 +3793,8 @@ double PairBOP::PiBo(int itmp, int jtmp) // j is a loop over all neighbors of i iilist=firstneigh[i]; - for(m=0;m=i_tag) { - if(itype==jtype) + if (j_tag>=i_tag) { + if (itype==jtype) iij=itype-1; - else if(itypenb_pi) { + if (nb_t>nb_pi) { new_n_tot=nb_pi+maxneigh; grow_pi(nb_pi,new_n_tot); nb_pi=new_n_tot; @@ -3849,7 +3849,7 @@ double PairBOP::PiBo(int itmp, int jtmp) bt_pi[nb_ij].j=j; bt_pi[nb_ij].temp=temp_ij; pass_ij=0; - if(otfly==1) { + if (otfly==1) { dis_ij[0]=x[j][0]-x[i][0]; dis_ij[1]=x[j][1]-x[i][1]; dis_ij[2]=x[j][2]-x[i][2]; @@ -3857,14 +3857,14 @@ double PairBOP::PiBo(int itmp, int jtmp) +dis_ij[1]*dis_ij[1] +dis_ij[2]*dis_ij[2]; r_ij=sqrt(rsq_ij); - if(r_ij<=rcut[iij]) { + if (r_ij<=rcut[iij]) { pass_ij=1; ps=r_ij*rdr[iij]+1.0; ks=(int)ps; - if(nr-11.0) + if (ps>1.0) ps=1.0; betaP_ij=((pBetaP3[iij][ks-1]*ps+pBetaP2[iij][ks-1])*ps +pBetaP1[iij][ks-1])*ps+pBetaP[iij][ks-1]; @@ -3872,7 +3872,7 @@ double PairBOP::PiBo(int itmp, int jtmp) +pBetaP4[iij][ks-1]; } } else { - if(neigh_flag[temp_ij]) { + if (neigh_flag[temp_ij]) { pass_ij=1; dis_ij[0]=disij[0][temp_ij]; dis_ij[1]=disij[1][temp_ij]; @@ -3887,23 +3887,23 @@ double PairBOP::PiBo(int itmp, int jtmp) AA=0.0; BB=0.0; - if(pass_ij==1) { + if (pass_ij==1) { nPiBk=0; nlisti=BOP_total[i]; - for(ktmp=0;ktmp1.0) + if (ps>1.0) ps=1.0; betaS_ik=((pBetaS3[iik][ks-1]*ps+pBetaS2[iik][ks-1])*ps +pBetaS1[iik][ks-1])*ps+pBetaS[iik][ks-1]; @@ -3944,7 +3944,7 @@ double PairBOP::PiBo(int itmp, int jtmp) *dis_ik[2]*r_ij*r_ij)/(r_ij*r_ij*r_ik*r_ik); } } else { - if(neigh_flag[temp_ik]) { + if (neigh_flag[temp_ik]) { pass_ik=1; dis_ik[0]=disij[0][temp_ik]; dis_ik[1]=disij[1][temp_ik]; @@ -3954,7 +3954,7 @@ double PairBOP::PiBo(int itmp, int jtmp) dBetaS_ik=dBetaS[temp_ik]; betaP_ik=betaP[temp_ik]; dBetaP_ik=dBetaP[temp_ik]; - if(jtmpnb_pi) { + if (nb_t>nb_pi) { new_n_tot=nb_pi+maxneigh; grow_pi(nb_pi,new_n_tot); nb_pi=new_n_tot; @@ -4043,30 +4043,30 @@ double PairBOP::PiBo(int itmp, int jtmp) // j and k and k' are different neighbors of i - for(ltmp=0;ltmp1.0) + if (ps>1.0) ps=1.0; betaS_ikp=((pBetaS3[iikp][ks-1]*ps+pBetaS2[iikp][ks-1])*ps +pBetaS1[iikp][ks-1])*ps+pBetaS[iikp][ks-1]; @@ -4121,7 +4121,7 @@ double PairBOP::PiBo(int itmp, int jtmp) *dis_ikp[2]*r_ik*r_ik)/(r_ik*r_ik*r_ikp*r_ikp); } } else { - if(neigh_flag[temp_ikp]) { + if (neigh_flag[temp_ikp]) { pass_ikp=1; dis_ikp[0]=disij[0][temp_ikp]; dis_ikp[1]=disij[1][temp_ikp]; @@ -4132,7 +4132,7 @@ double PairBOP::PiBo(int itmp, int jtmp) betaP_ikp=betaP[temp_ikp]; dBetaP_ikp=dBetaP[temp_ikp]; nkikp=ltmp*(2*nlisti-ltmp-1)/2+(ktmp-ltmp)-1; - if(jtmpnb_pi) { + if (nb_t>nb_pi) { new_n_tot=nb_pi+maxneigh; grow_pi(nb_pi,new_n_tot); nb_pi=new_n_tot; @@ -4242,13 +4242,13 @@ double PairBOP::PiBo(int itmp, int jtmp) //j is a neighbor of i and k is a neighbor of j and equal to i - for(ki=0;ki1.0) + if (ps>1.0) ps=1.0; betaS_jk=((pBetaS3[ijk][ks-1]*ps+pBetaS2[ijk][ks-1])*ps +pBetaS1[ijk][ks-1])*ps+pBetaS[ijk][ks-1]; @@ -4325,7 +4325,7 @@ double PairBOP::PiBo(int itmp, int jtmp) *dis_jk[2]*r_ij*r_ij)/(r_ij*r_ij*r_jk*r_jk); } } else { - if(neigh_flag[temp_jk]) { + if (neigh_flag[temp_jk]) { pass_jk=1; dis_jk[0]=disij[0][temp_jk]; dis_jk[1]=disij[1][temp_jk]; @@ -4335,7 +4335,7 @@ double PairBOP::PiBo(int itmp, int jtmp) dBetaS_jk=dBetaS[temp_jk]; betaP_jk=betaP[temp_jk]; dBetaP_jk=dBetaP[temp_jk]; - if(ktmpnb_pi) { + if (nb_t>nb_pi) { new_n_tot=nb_pi+maxneigh; grow_pi(nb_pi,new_n_tot); nb_pi=new_n_tot; @@ -4425,30 +4425,30 @@ double PairBOP::PiBo(int itmp, int jtmp) //j is a neighbor of i and k and k' are different neighbors of j not equal to i - for(ltmp=0;ltmp1.0) + if (ps>1.0) ps=1.0; betaS_jkp=((pBetaS3[ijkp][ks-1]*ps+pBetaS2[ijkp][ks-1])*ps +pBetaS1[ijkp][ks-1])*ps+pBetaS[ijkp][ks-1]; @@ -4503,7 +4503,7 @@ double PairBOP::PiBo(int itmp, int jtmp) *dis_jkp[2]*r_jk*r_jk)/(r_jk*r_jk*r_jkp*r_jkp); } } else { - if(neigh_flag[temp_jkp]) { + if (neigh_flag[temp_jkp]) { pass_jkp=1; dis_jkp[0]=disij[0][temp_jkp]; dis_jkp[1]=disij[1][temp_jkp]; @@ -4514,7 +4514,7 @@ double PairBOP::PiBo(int itmp, int jtmp) betaP_jkp=betaP[temp_jkp]; dBetaP_jkp=dBetaP[temp_jkp]; nkjkp=ltmp*(2*nlistj-ltmp-1)/2+(ktmp-ltmp)-1; - if(kinb_pi) { + if (nb_t>nb_pi) { new_n_tot=nb_pi+maxneigh; grow_pi(nb_pi,new_n_tot); nb_pi=new_n_tot; @@ -4621,30 +4621,30 @@ double PairBOP::PiBo(int itmp, int jtmp) //j and k' are different neighbors of i and k is a neighbor of j not equal to i - for(ltmp=0;ltmp1.0) + if (ps>1.0) ps=1.0; betaS_ikp=((pBetaS3[iikp][ks-1]*ps+pBetaS2[iikp][ks-1])*ps +pBetaS1[iikp][ks-1])*ps+pBetaS[iikp][ks-1]; @@ -4685,7 +4685,7 @@ double PairBOP::PiBo(int itmp, int jtmp) *dis_ikp[2]*r_ij*r_ij)/(r_ij*r_ij*r_ikp*r_ikp); } } else { - if(neigh_flag[temp_ikp]) { + if (neigh_flag[temp_ikp]) { pass_ikp=1; dis_ikp[0]=disij[0][temp_ikp]; dis_ikp[1]=disij[1][temp_ikp]; @@ -4695,7 +4695,7 @@ double PairBOP::PiBo(int itmp, int jtmp) dBetaS_ikp=dBetaS[temp_ikp]; betaP_ikp=betaP[temp_ikp]; dBetaP_ikp=dBetaP[temp_ikp]; - if(ltmpnb_pi) { + if (nb_t>nb_pi) { new_n_tot=nb_pi+maxneigh; grow_pi(nb_pi,new_n_tot); nb_pi=new_n_tot; @@ -4799,14 +4799,14 @@ double PairBOP::PiBo(int itmp, int jtmp) } } } - if(pi_flag==0) + if (pi_flag==0) nPiBk=nPiBk+1; } } } n++; pp2=2.0*betaP_ij; - for(m=0;m cutmax) cutmax = rcut[i]; @@ -4995,67 +4995,67 @@ void _noopt PairBOP::read_table(char *filename) small3[i] = values.next_double(); } - if(format == 3) { - for(int i = 0; i < bop_types; i++) - for(int j = 0; j < bop_types; j++) - for(int k = j; k < bop_types; k++) { - if(npower <= 2) { + if (format == 3) { + for (int i = 0; i < bop_types; i++) + for (int j = 0; j < bop_types; j++) + for (int k = j; k < bop_types; k++) { + if (npower <= 2) { reader.next_dvector(&gfunc[j][i][k][0], ntheta); } else { reader.next_dvector(&gpara[j][i][k][0], npower+1); } } } else { - for(int i = 0; i < bop_types; i++) - for(int j = 0; j < bop_types; j++) - for(int k = 0; k < bop_types; k++) { + for (int i = 0; i < bop_types; i++) + for (int j = 0; j < bop_types; j++) + for (int k = 0; k < bop_types; k++) { reader.next_dvector(&gpara[i][j][k][0], 3); gpara[j][i][k][3] = 0; } } - for(int i = 0; i < npairs; i++) { + for (int i = 0; i < npairs; i++) { reader.next_dvector(&pRepul[i][0], nr); } - for(int i = 0; i < npairs; i++) { + for (int i = 0; i < npairs; i++) { reader.next_dvector(&pBetaS[i][0], nr); } - for(int i = 0; i < npairs; i++) { + for (int i = 0; i < npairs; i++) { reader.next_dvector(&pBetaP[i][0], nr); } - for(int i = 0; i < npairs; i++) { + for (int i = 0; i < npairs; i++) { reader.next_dvector(&FsigBO[i][0], nBOt); } - for(int i = 0; i < bop_types; i++) { + for (int i = 0; i < bop_types; i++) { pro_delta[i] = reader.next_double(); } - for(int i = 0; i < bop_types; i++) { + for (int i = 0; i < bop_types; i++) { pro[i] = reader.next_double(); } - for(int i=0;ircutall) + for (int i=0; i < npairs; i++) { + if (rcut[i]>rcutall) rcutall=rcut[i]; - if(rcut3[i]>rcutall) + if (rcut3[i]>rcutall) rcutall=rcut3[i]; rcutsq[i]=rcut[i]*rcut[i]; dr[i]=rcut[i]/((double)nr-1.0); @@ -5238,7 +5238,7 @@ void _noopt PairBOP::read_table(char *filename) MPI_Bcast(&npairs,1,MPI_INT,0,world); MPI_Bcast(&npower,1,MPI_INT,0,world); - if (comm->me != 0){ + if (comm->me != 0) { allocate_tables(); allocate(); } @@ -5312,7 +5312,7 @@ void _noopt PairBOP::read_table(char *filename) MPI_Bcast(&FsigBO4[0][0],npairs*nBOt,MPI_DOUBLE,0,world); MPI_Bcast(&FsigBO5[0][0],npairs*nBOt,MPI_DOUBLE,0,world); MPI_Bcast(&FsigBO6[0][0],npairs*nBOt,MPI_DOUBLE,0,world); - if(npower<=2){ + if (npower<=2) { MPI_Bcast(&gfunc[0][0][0][0],bop_types*bop_types*bop_types*ntheta,MPI_DOUBLE,0,world); MPI_Bcast(&gfunc1[0][0][0][0],bop_types*bop_types*bop_types*ntheta,MPI_DOUBLE,0,world); MPI_Bcast(&gfunc2[0][0][0][0],bop_types*bop_types*bop_types*ntheta,MPI_DOUBLE,0,world); @@ -5440,7 +5440,7 @@ double PairBOP::memory_usage() bytes += nall * sizeof(double); // BOP_total bytes += nall * sizeof(double); - if(otfly==0) { + if (otfly==0) { // cosAng bytes += cos_total* sizeof(double); // dcAng @@ -5542,7 +5542,7 @@ double PairBOP::memory_usage() bytes += maxneigh*(maxneigh/2) *sizeof(B_PI); // bt_sigma bytes += maxneigh*(maxneigh/2) *sizeof(B_SG); - if(npower<=2) { + if (npower<=2) { // gfunc bytes += bop_types*bop_types*bop_types*ntheta *sizeof(double); // gfunc1 @@ -5568,14 +5568,14 @@ double PairBOP::memory_usage() void PairBOP::memory_theta_create() { neigh_ct=(maxneigh-1)*(maxneigh-1)*(maxneigh-1); - if(neigh_ct<1) neigh_ct=1; + if (neigh_ct<1) neigh_ct=1; memory->create(itypeSigBk,neigh_ct,"itypeSigBk"); memory->create(itypePiBk,neigh_ct,"itypePiBk"); memory->create(neigh_flag,neigh_total,"neigh_flag"); memory->create(neigh_flag3,neigh_total3,"neigh_flag3"); memory->create(neigh_index,neigh_total,"neigh_index"); memory->create(neigh_index3,neigh_total3,"neigh_index3"); - if(otfly==0) { + if (otfly==0) { memory->create(cosAng,cos_total,"BOP:cosAng"); memory->create(dcAng,cos_total,3,2,"BOP:dcAng"); memory->create(disij,3,neigh_total,"disij"); @@ -5595,14 +5595,14 @@ void PairBOP::memory_theta_create() void PairBOP::memory_theta_grow() { neigh_ct=(maxneigh-1)*(maxneigh-1)*(maxneigh-1); - if(neigh_ct<1) neigh_ct=1; + if (neigh_ct<1) neigh_ct=1; memory->grow(itypeSigBk,neigh_ct,"itypeSigBk"); memory->grow(itypePiBk,neigh_ct,"itypePiBk"); memory->grow(neigh_flag,neigh_total,"neigh_flag"); memory->grow(neigh_flag3,neigh_total3,"neigh_flag3"); memory->grow(neigh_index,neigh_total,"neigh_index"); memory->grow(neigh_index3,neigh_total3,"neigh_index3"); - if(otfly==0) { + if (otfly==0) { memory->grow(cosAng,cos_total,"BOP:cosAng"); memory->grow(dcAng,cos_total,3,2,"BOP:dcAng"); memory->grow(disij,3,neigh_total,"disij"); @@ -5634,7 +5634,7 @@ void PairBOP::memory_theta_destroy() neigh_flag3 = nullptr; neigh_index = nullptr; neigh_index3 = nullptr; - if(otfly==0) { + if (otfly==0) { memory->destroy(cosAng); memory->destroy(dcAng); memory->destroy(disij); @@ -5670,11 +5670,11 @@ void PairBOP::grow_pi(int n1, int n2) int i,j; B_PI *bt_temp; bt_temp = (B_PI *) memory->smalloc(n1*sizeof(B_PI),"BOP:b_temp"); - for(i=0;idestroy(bt_pi); bt_pi=nullptr; bt_pi = (B_PI *) memory->smalloc(n2*sizeof(B_PI),"BOP:bt_pi"); - for(i=0;ismalloc(n1*sizeof(B_SG),"BOP:bt_temp"); - for(i=0;idestroy(bt_sg); bt_sg=nullptr; bt_sg = (B_SG *) memory->smalloc(n2*sizeof(B_SG),"BOP:bt_sg"); - for(i=0;i 0.0 ) { + if (params[iparam_ij].hfocor > 0.0 ) { delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; delr1[2] = x[j][2] - ztmp; @@ -727,7 +727,7 @@ void PairComb::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index ddf4695df7..30abb43dfc 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -346,7 +346,7 @@ void PairComb3::read_lib() ntab = reader.next_int(); - for (i = 0; i < (ntab + 1); i++){ + for (i = 0; i < (ntab + 1); i++) { values = reader.next_values(4); values.skip(1); pang[i] = values.next_double(); @@ -381,7 +381,7 @@ void PairComb3::read_lib() jj = values.next_int(); kk = values.next_int(); - for(iii = 0; iii < 2; iii++) { + for (iii = 0; iii < 2; iii++) { mm = iii*32; reader.next_dvector(&pcn_cubs[ll][ii][jj][kk][mm], 32); } @@ -446,7 +446,7 @@ void PairComb3::read_lib() ii = values.next_int(); jj = values.next_int(); kk = values.next_int() - 1; - for(iii=0; iii<2; iii++) { + for (iii=0; iii<2; iii++) { mm=iii*32; reader.next_dvector(&tor_spl[ll][ii][jj][kk][mm], 32); } @@ -672,7 +672,7 @@ void PairComb3::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } @@ -1143,11 +1143,11 @@ void PairComb3::compute(int eflag, int vflag) srmu = vec3_dot(delrj,delrk)/(sqrt(rsq1*rsq2)); srmu = sqrt(1.0-srmu*srmu); - if(srmu > 0.1) { + if (srmu > 0.1) { for (ll = 0; ll < sht_lnum; ll++) { // ll is neighbor of jj l = sht_llist[ll]; - if(l==i || l==j || l==k) continue; + if (l==i || l==j || l==k) continue; ltype = map[type[l]]; @@ -1199,7 +1199,7 @@ void PairComb3::compute(int eflag, int vflag) , rsq1, rsq2, delrl, delrk, j, ycn); // radical initialization: apply only to CC,CO,OC bonds - if(params[iparam_ji].rad_flag > 0 + if (params[iparam_ji].rad_flag > 0 && params[iparam_jl].ielementgp == 1 && params[iparam_jl].jelementgp == 1) { iparam_lj = elem2param[ltype][jtype][jtype]; @@ -1275,7 +1275,7 @@ void PairComb3::compute(int eflag, int vflag) srmu = vec3_dot(delrj,delrk)/(sqrt(rsq1*rsq2)); srmu = sqrt(1.0-srmu*srmu); - if(srmu > 0.1) { + if (srmu > 0.1) { for (ll = 0; ll < sht_lnum; ll++) { // ll is neighbor of jj l = sht_llist[ll]; if (l==i||l==j||l==k) continue; @@ -1304,7 +1304,7 @@ void PairComb3::compute(int eflag, int vflag) } } - if( params[iparam_ijk].rad_flag>=1 && + if ( params[iparam_ijk].rad_flag>=1 && params[iparam_ijk].ielementgp==1 && params[iparam_ijk].kelementgp==1) { iparam_ki = elem2param[ktype][itype][itype]; @@ -1400,7 +1400,7 @@ void PairComb3::compute(int eflag, int vflag) } // radical i-j-l-p: apply to all CC,CO,OC bonds - if( params[iparam_jil].rad_flag >= 1 && + if ( params[iparam_jil].rad_flag >= 1 && params[iparam_jil].ielementgp == 1 && params[iparam_jil].kelementgp == 1 ) { iparam_lj = elem2param[ltype][jtype][jtype]; @@ -1894,7 +1894,7 @@ void PairComb3::comb_bij_d(double zet, Param *param, double r, int i, zeta = pow(zetang,pow_n)+pcorn; tmp_tbij=pow_n*pow(zetang,(pow_n-1.0)); - if ((1.0 + zeta) < 0.1 ){ + if ((1.0 + zeta) < 0.1 ) { zeta=0.1-1.0; tbij = pow(1.0 + zeta, -0.5/pow_n); tbij1=0.0; @@ -1948,22 +1948,22 @@ void PairComb3::coord(Param *param, double r, int i, pcorn = dpcorn = dxccij = dxchij = dxcoij = 0.0; pcorn = 0.0; dpcorn = 0.0; - if(xcntot < 0.0) xcntot = 0.0; + if (xcntot < 0.0) xcntot = 0.0; if (tri_flag>0) { - if(jele_gp==1) xcccn = xcccn-comb_fc(r,param)*param->pcross; - if(jele_gp==2) xchcn = xchcn-comb_fc(r,param)*param->pcross; - if(jele_gp==3) xcocn = xcocn-comb_fc(r,param)*param->pcross; - if(xcccn < 0.0) xcccn = 0.0; - if(xchcn < 0.0) xchcn = 0.0; - if(xcocn < 0.0) xcocn = 0.0; - if(xcccn > maxx) xcccn = maxx; - if(xchcn > maxy) xchcn = maxy; - if(xcocn > maxz) xcocn = maxz; + if (jele_gp==1) xcccn = xcccn-comb_fc(r,param)*param->pcross; + if (jele_gp==2) xchcn = xchcn-comb_fc(r,param)*param->pcross; + if (jele_gp==3) xcocn = xcocn-comb_fc(r,param)*param->pcross; + if (xcccn < 0.0) xcccn = 0.0; + if (xchcn < 0.0) xchcn = 0.0; + if (xcocn < 0.0) xcocn = 0.0; + if (xcccn > maxx) xcccn = maxx; + if (xchcn > maxy) xchcn = maxy; + if (xcocn > maxz) xcocn = maxz; double xcntritot=xcccn+xchcn+xcocn; - if(xcntritot > maxxcn[tri_flag-1]) { + if (xcntritot > maxxcn[tri_flag-1]) { pcorn = vmaxxcn[tri_flag-1]+(xcntot-maxxcn[tri_flag-1])*dvmaxxcn[tri_flag-1]; dxccij = dxchij = dxcoij = dvmaxxcn[tri_flag-1]; } @@ -1998,17 +1998,17 @@ void PairComb3::cntri_int(int tri_flag, double xval, double yval, { double x; vval = 0.0; dvalx = 0.0; dvaly = 0.0; dvalz = 0.0; - if(ixmin >= maxx-1) { ixmin=maxx-1; } - if(iymin >= maxy-1) { iymin=maxy-1; } - if(izmin >= maxz-1) { izmin=maxz-1; } + if (ixmin >= maxx-1) { ixmin=maxx-1; } + if (iymin >= maxy-1) { iymin=maxy-1; } + if (izmin >= maxz-1) { izmin=maxz-1; } for (int j=0; j<64; j++) { x = pcn_cubs[tri_flag-1][ixmin][iymin][izmin][j] *pow(xval,iin3[j][0])*pow(yval,iin3[j][1]) *pow(zval,iin3[j][2]); vval += x; - if(xval>1.0e-8) {dvalx += x*iin3[j][0]/xval;} - if(yval>1.0e-8) {dvaly += x*iin3[j][1]/yval;} - if(zval>1.0e-8) {dvalz += x*iin3[j][2]/zval;} + if (xval>1.0e-8) {dvalx += x*iin3[j][0]/xval;} + if (yval>1.0e-8) {dvaly += x*iin3[j][1]/yval;} + if (zval>1.0e-8) {dvalz += x*iin3[j][2]/zval;} } } @@ -2045,7 +2045,7 @@ double PairComb3::comb_gijk(double costheta, Param *param, double nco_tmp) gmu = gmu2+qtheta*(gmu1-gmu2); return gmu*pcross; - } else if (param->ang_flag==2){ + } else if (param->ang_flag==2) { double qtheta, gmu1, gmu2; double ch6 = ch_a[6]*rmu6; double ch5 = ch_a[5]*rmu5; @@ -2104,7 +2104,7 @@ void PairComb3::comb_gijk_d(double costheta, Param *param, double nco_tmp, dgmu2 = dpang[k]+(dpang[k+1]-dpang[k])*(rrmu-k); gijk_d = pcross*(dgmu2+qtheta*(dgmu1-dgmu2)); com3jk = dqtheta * (gmu1-gmu2); - } else if(param->ang_flag==2) { + } else if (param->ang_flag==2) { double qtheta, dqtheta, gmu1, gmu2, dgmu1,dgmu2; double ch6 = ch_a[6]; double ch5 = ch_a[5]; @@ -2191,11 +2191,11 @@ void PairComb3::comb_zetaterm_d(double prefac_ij1, double prefac_ij2, costheta_d(rij_hat,rij,rik_hat,rik,dcosdri,dcosdrj,dcosdrk); // com6 & com7 - if(icontrol > 0){ - if(parami->kelementgp==1) {com6 = prefac_ij3*pcrossk*dfc_k;} - if(parami->kelementgp==2) {com6 = prefac_ij4*pcrossk*dfc_k;} - if(parami->kelementgp==3) {com6 = prefac_ij5*pcrossk*dfc_k;} - if(parami->rad_flag>=1 || parami->tor_flag!=0) + if (icontrol > 0) { + if (parami->kelementgp==1) {com6 = prefac_ij3*pcrossk*dfc_k;} + if (parami->kelementgp==2) {com6 = prefac_ij4*pcrossk*dfc_k;} + if (parami->kelementgp==3) {com6 = prefac_ij5*pcrossk*dfc_k;} + if (parami->rad_flag>=1 || parami->tor_flag!=0) {com6+=prefac_ij2*pcrossk*dfc_k;} } else { com6 = prefac_ij2*pcrossi*dfc_k; @@ -2475,9 +2475,9 @@ void PairComb3::tables() iparam_ij = elem2param[itype][jtype][jtype]; // parameter check: eps > 0 - if(params[iparam_ij].vdwflag > 0) { + if (params[iparam_ij].vdwflag > 0) { - if(params[iparam_ij].vdwflag==1){ + if (params[iparam_ij].vdwflag==1) { rvdw[0][inty] = params[iparam_ij].bigr + params[iparam_ij].bigd; } else { @@ -2530,8 +2530,8 @@ void PairComb3::tables() vepst = params[iparam_ij].veps; vsigt = vsigt*vsigt*vsigt*vsigt*vsigt*vsigt; - if(params[iparam_ij].vdwflag>0) { - if(r <= rvdw[0][inty]) { + if (params[iparam_ij].vdwflag>0) { + if (r <= rvdw[0][inty]) { vvdw[k][inty] = 0.0; vdvdw[k][inty] = 0.0; } @@ -2656,27 +2656,27 @@ void PairComb3::direct(Param *parami, Param *paramj, int mr1, pot_tmp = for_tmp = 0.0; icurl=jcurl=0; - if(ielegp==2 && curli>curlij0) { + if (ielegp==2 && curli>curlij0) { icurl=1; curlij1=curli; } - if(jelegp==2 && curlj>curlji0) { + if (jelegp==2 && curlj>curlji0) { jcurl=1; curlji1=curlj; } - if(icurl==1 || jcurl ==1) { + if (icurl==1 || jcurl ==1) { xcoij = xcotmp[i]; xcoji = xcotmp[j]; fcp1j = comb_fc_d(r,parami); - if(icurl==1) { + if (icurl==1) { curli=curlij1+(curlij0-curlij1)*comb_fc_curl(xcoij,parami); dcurlij=fcp1j*(curlij0-curlij1)*comb_fc_curl_d(xcoij,parami); } - if(jcurl==1) { + if (jcurl==1) { curlj=curlji1+(curlji0-curlji1)*comb_fc_curl(xcoji,paramj); dcurlji=fcp1j*(curlji0-curlji1)*comb_fc_curl_d(xcoji,paramj); } @@ -2705,10 +2705,10 @@ void PairComb3::direct(Param *parami, Param *paramj, int mr1, smf1n = iq * curlj * (dafbn-dfafbnl)*esucon/r; smf1j = jq * curli * (dafbj-dfafbnl)*esucon/r; - if(jcurl==1 && ielegp == 3 && dcurlji != 0.0){ + if (jcurl==1 && ielegp == 3 && dcurlji != 0.0) { smf1n += dcurlji*iq*(afbn-fafbnl)*esucon/r; } - if(icurl==1 && jelegp == 3 && dcurlij != 0.0){ + if (icurl==1 && jelegp == 3 && dcurlij != 0.0) { smf1j += dcurlij*jq*(afbj-fafbnl)*esucon/r; } @@ -2798,12 +2798,12 @@ void PairComb3::rad_calc(double r, Param *parami, Param *paramj, yrad = -comb_fc(r,paramj)*paramj->pcross + ycn; zcon = 1.0 + pow(kconjug,2) + pow(lconjug,2); - if(xrad < 0.0) xrad = 0.0; - if(yrad < 0.0) yrad = 0.0; - if(zcon < 1.0) zcon = 1.0; - if(xrad > maxxc) xrad = maxxc; - if(yrad > maxyc) yrad = maxyc; - if(zcon > maxconj) zcon = maxconj; + if (xrad < 0.0) xrad = 0.0; + if (yrad < 0.0) yrad = 0.0; + if (zcon < 1.0) zcon = 1.0; + if (xrad > maxxc) xrad = maxxc; + if (yrad > maxyc) yrad = maxyc; + if (zcon > maxconj) zcon = maxconj; ixmin = int(xrad+1.0e-12); iymin = int(yrad+1.0e-12); izmin = int(zcon+1.0e-12); @@ -2835,17 +2835,17 @@ void PairComb3::rad_int(int radindx,double xrad, double yrad, double zcon, int l int j; double x; vrad = pradx = prady = pradz = 0.0; - if(l >= maxxc-1) { l=maxxc-1;} - if(m >= maxyc-1) { m=maxyc-1; } - if(n >= maxconj-1) { n=maxconj-1;} + if (l >= maxxc-1) { l=maxxc-1;} + if (m >= maxyc-1) { m=maxyc-1; } + if (n >= maxconj-1) { n=maxconj-1;} for (j=0; j<64; j++) { x = rad_spl[radindx][l][m][n-1][j] * pow(xrad,iin3[j][0]) * pow(yrad,iin3[j][1]) * pow(zcon,iin3[j][2]); vrad += x; - if(xrad > 1.0e-8) pradx += x*iin3[j][0]/xrad; - if(yrad > 1.0e-8) prady += x*iin3[j][1]/yrad; - if(zcon > 1.0e-8) pradz += x*iin3[j][2]/zcon; + if (xrad > 1.0e-8) pradx += x*iin3[j][0]/xrad; + if (yrad > 1.0e-8) prady += x*iin3[j][1]/yrad; + if (zcon > 1.0e-8) pradz += x*iin3[j][2]/zcon; } } @@ -2933,7 +2933,7 @@ double PairComb3::bbtor1(int torindx, Param *paramk, Param *paraml, vec3_scale(-1.0,delrl,delrl); rmul = sqrt(1.0-rmul*rmul); - if(rmul > 0.1 ) { + if (rmul > 0.1 ) { double fc1k, fc1l, TT1, TT2, rmut, btt, tork[3], torl[3]; fc1k = comb_fc(rik,paramk); @@ -2948,7 +2948,7 @@ double PairComb3::bbtor1(int torindx, Param *paramk, Param *paraml, torl[2] = delrj[0]*delrl[1] - delrj[1]*delrl[0]; TT2 = vec3_dot(tork,torl); rmut = pow((TT2/TT1),2); - if(torindx>=1) { + if (torindx>=1) { btt = 1.0 - rmut; return btt * fc1k * fc1l; } @@ -2976,7 +2976,7 @@ void PairComb3::tor_calc(double r, Param *parami, Param *paramj, vtor = dtorx = dtory = dtorz = 0.0; torindx=parami->tor_flag; - if(torindx<0){ + if (torindx<0) { vtor=1.0; dtorx=0.0; dtory=0.0; @@ -3026,18 +3026,18 @@ void PairComb3::tor_int(int torindx,double xtor, double ytor, double zcon, int l double x; vtor = dtorx = dtory = dtorz = 0.0; - if(l >= maxxc-1) { l=maxxc-1; } //boundary condition changed - if(m >= maxyc-1) { m=maxyc-1; } - if(n >= maxconj-1) { n=maxconj-1; } + if (l >= maxxc-1) { l=maxxc-1; } //boundary condition changed + if (m >= maxyc-1) { m=maxyc-1; } + if (n >= maxconj-1) { n=maxconj-1; } for (j=0; j<64; j++) { x = tor_spl[torindx][l][m][n-1][j] * pow(xtor,iin3[j][0]) * pow(ytor,iin3[j][1]) * pow(zcon,iin3[j][2]); vtor += x; - if(xtor > 1.0e-8 ) dtorx += x*iin3[j][0]/xtor; - if(ytor > 1.0e-8 ) dtory += x*iin3[j][1]/ytor; - if(zcon > 1.0e-8 ) dtorz += x*iin3[j][2]/zcon; + if (xtor > 1.0e-8 ) dtorx += x*iin3[j][0]/xtor; + if (ytor > 1.0e-8 ) dtory += x*iin3[j][1]/ytor; + if (zcon > 1.0e-8 ) dtorz += x*iin3[j][2]/zcon; } } @@ -3063,9 +3063,9 @@ void PairComb3::tor_force(int torindx, Param *paramk, Param *paraml, rmul = vec3_dot(delrj,delrl)/(rij*rjl); vec3_scale(-1.0,delrl,delrl); srmul = sqrt(1.0-rmul*rmul); - if(acos(rmul) > MY_PI) srmul = -srmul; + if (acos(rmul) > MY_PI) srmul = -srmul; - if(srmul > 0.1 ) { + if (srmul > 0.1 ) { double fc1k, fcp1k, fc1l, fcp1l, srmul2, dt1dik, dt1djl; double TT1, TT2, rmut, btt, tork[3], torl[3]; double dt2dik[3], dt2djl[3], dt2dij[3], AA, AA2; @@ -3104,7 +3104,7 @@ void PairComb3::tor_force(int torindx, Param *paramk, Param *paraml, rmut = TT2/TT1; - if(torindx>=1) { + if (torindx>=1) { btt = 1.0 - pow(rmut,2); AA = -2.0 * ptorr * rmut * fc1k * fc1l / TT1; } @@ -3325,7 +3325,7 @@ double PairComb3::combqeq(double *qf_fix, int &igroup) double eneg = 0.0; for (ii = 0; ii < inum; ii++) { i = ilist[ii]; - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { eneg += qf[i]; itag=tag[i]; } @@ -3386,23 +3386,23 @@ void PairComb3::qfo_direct(Param *parami, Param *paramj, int mr1, esucon=force->qqr2e; icurl = jcurl = 0; - if(ielegp==2 && curli>curlij0) { + if (ielegp==2 && curli>curlij0) { icurl=1; curlij1=curli; } - if(jelegp==2 && curlj>curlji0) { + if (jelegp==2 && curlj>curlji0) { jcurl=1; curlji1=curlj; } - if(icurl==1 || jcurl ==1) { + if (icurl==1 || jcurl ==1) { double xcoij= xcotmp[i]; double xcoji= xcotmp[j]; - if(icurl==1) { + if (icurl==1) { curli=curlij1+(curlij0-curlij1)*comb_fc_curl(xcoij,parami); } - if(jcurl==1) { + if (jcurl==1) { curlj=curlji1+(curlji0-curlji1)*comb_fc_curl(xcoji,paramj); } } @@ -3584,7 +3584,7 @@ void PairComb3::dipole_init(Param *parami, Param *paramj, double fac11, int intj = paramj->ielement; int inty = intype[inti][intj]; - for(nm=0; nm<3; nm++) Qext[nm] = 0.0; + for (nm=0; nm<3; nm++) Qext[nm] = 0.0; r = sqrt(rsq); r3 = r * rsq; diff --git a/src/MANYBODY/pair_eam.cpp b/src/MANYBODY/pair_eam.cpp index 343363a691..d8760cd55a 100644 --- a/src/MANYBODY/pair_eam.cpp +++ b/src/MANYBODY/pair_eam.cpp @@ -466,7 +466,7 @@ void PairEAM::read_file(char *filename) Funcfl *file = &funcfl[nfuncfl-1]; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam", unit_convert_flag); // transparently convert units for supported conversions @@ -518,7 +518,7 @@ void PairEAM::read_file(char *filename) MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { memory->create(file->frho, (file->nrho+1), "pair:frho"); memory->create(file->rhor, (file->nr+1), "pair:rhor"); memory->create(file->zr, (file->nr+1), "pair:zr"); diff --git a/src/MANYBODY/pair_eam_alloy.cpp b/src/MANYBODY/pair_eam_alloy.cpp index 50d73f89c2..e1c43b9d99 100644 --- a/src/MANYBODY/pair_eam_alloy.cpp +++ b/src/MANYBODY/pair_eam_alloy.cpp @@ -117,7 +117,7 @@ void PairEAMAlloy::read_file(char *filename) Setfl *file = setfl; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam/alloy", unit_convert_flag); // transparently convert units for supported conversions diff --git a/src/MANYBODY/pair_eam_fs.cpp b/src/MANYBODY/pair_eam_fs.cpp index 463166d22a..05e5e2b323 100644 --- a/src/MANYBODY/pair_eam_fs.cpp +++ b/src/MANYBODY/pair_eam_fs.cpp @@ -117,7 +117,7 @@ void PairEAMFS::read_file(char *filename) Fs *file = fs; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam/fs", unit_convert_flag); // transparently convert units for supported conversions diff --git a/src/MANYBODY/pair_eim.cpp b/src/MANYBODY/pair_eim.cpp index dbb16125c7..f95a43ed67 100644 --- a/src/MANYBODY/pair_eim.cpp +++ b/src/MANYBODY/pair_eim.cpp @@ -476,7 +476,7 @@ void PairEIM::read_file(char *filename) setfl->tp = new int[npair]; // read potential file - if( comm->me == 0) { + if ( comm->me == 0) { EIMPotentialFileReader reader(lmp, filename, unit_convert_flag); reader.get_global(setfl); diff --git a/src/MANYBODY/pair_gw.cpp b/src/MANYBODY/pair_gw.cpp index 675ec1b3fe..32ace05546 100644 --- a/src/MANYBODY/pair_gw.cpp +++ b/src/MANYBODY/pair_gw.cpp @@ -467,7 +467,7 @@ void PairGW::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_gw_zbl.cpp b/src/MANYBODY/pair_gw_zbl.cpp index c8fe598e46..bee8efb692 100644 --- a/src/MANYBODY/pair_gw_zbl.cpp +++ b/src/MANYBODY/pair_gw_zbl.cpp @@ -165,7 +165,7 @@ void PairGWZBL::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_lcbop.cpp b/src/MANYBODY/pair_lcbop.cpp index df43aac9d2..09ea20df52 100644 --- a/src/MANYBODY/pair_lcbop.cpp +++ b/src/MANYBODY/pair_lcbop.cpp @@ -1220,7 +1220,7 @@ void PairLCBOP::spline_init() { // for( double y=0; y<=3.0+0.0001; y+=0.1 ) // file << y << " "; // file << std::endl; -// for( double x=0; x<=3.0+0.0001; x+=0.1 ){ +// for( double x=0; x<=3.0+0.0001; x+=0.1 ) { // file << x << " "; // for( double y=0; y<=3.0+0.0001; y+=0.1 ) // file << F_conj( x, y, 0, &dummy, &dummy, &dummy ) << " "; @@ -1231,7 +1231,7 @@ void PairLCBOP::spline_init() { // for( double y=0; y<=3.0+0.0001; y+=0.1 ) // file << y << " "; // file << std::endl; -// for( double x=0; x<=3.0+0.0001; x+=0.1 ){ +// for( double x=0; x<=3.0+0.0001; x+=0.1 ) { // file << x << " "; // for( double y=0; y<=3.0+0.0001; y+=0.1 ) { // double dF_dx; @@ -1247,7 +1247,7 @@ void PairLCBOP::spline_init() { // for( double y=0; y<=3.0+0.0001; y+=0.1 ) // file << y << " "; // file << std::endl; -// for( double x=0; x<=3.0+0.0001; x+=0.1 ){ +// for( double x=0; x<=3.0+0.0001; x+=0.1 ) { // file << x << " "; // for( double y=0; y<=3.0+0.0001; y+=0.1 ) // file << F_conj( x, y, 0, &dummy, &dummy, &dummy ) << " "; diff --git a/src/MANYBODY/pair_nb3b_harmonic.cpp b/src/MANYBODY/pair_nb3b_harmonic.cpp index 8e1468271e..7e53dcc39c 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.cpp +++ b/src/MANYBODY/pair_nb3b_harmonic.cpp @@ -360,7 +360,7 @@ void PairNb3bHarmonic::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_polymorphic.cpp b/src/MANYBODY/pair_polymorphic.cpp index e256063b73..ee736cfe5b 100644 --- a/src/MANYBODY/pair_polymorphic.cpp +++ b/src/MANYBODY/pair_polymorphic.cpp @@ -646,7 +646,7 @@ void PairPolymorphic::read_file(char *file) MPI_Bcast(&npair, 1, MPI_INT, 0, world); MPI_Bcast(&ntriple, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { delete [] match; match = new int[nelements]; delete [] pairParameters; diff --git a/src/MANYBODY/pair_sw.cpp b/src/MANYBODY/pair_sw.cpp index 708027913c..c94e75b4a2 100644 --- a/src/MANYBODY/pair_sw.cpp +++ b/src/MANYBODY/pair_sw.cpp @@ -437,7 +437,7 @@ void PairSW::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp index dbb7cd2f48..bcfcb149b4 100644 --- a/src/MANYBODY/pair_tersoff.cpp +++ b/src/MANYBODY/pair_tersoff.cpp @@ -496,7 +496,7 @@ void PairTersoff::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_tersoff_mod.cpp b/src/MANYBODY/pair_tersoff_mod.cpp index 6ea7758d61..f5e4d21ffc 100644 --- a/src/MANYBODY/pair_tersoff_mod.cpp +++ b/src/MANYBODY/pair_tersoff_mod.cpp @@ -148,7 +148,7 @@ void PairTersoffMOD::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_tersoff_mod_c.cpp b/src/MANYBODY/pair_tersoff_mod_c.cpp index 8582e39ef1..c2cbcdd2d9 100644 --- a/src/MANYBODY/pair_tersoff_mod_c.cpp +++ b/src/MANYBODY/pair_tersoff_mod_c.cpp @@ -142,7 +142,7 @@ void PairTersoffMODC::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_tersoff_zbl.cpp b/src/MANYBODY/pair_tersoff_zbl.cpp index 0c0c58322a..aee9eda71f 100644 --- a/src/MANYBODY/pair_tersoff_zbl.cpp +++ b/src/MANYBODY/pair_tersoff_zbl.cpp @@ -173,7 +173,7 @@ void PairTersoffZBL::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_vashishta.cpp b/src/MANYBODY/pair_vashishta.cpp index d5a1374a80..32f3212d75 100644 --- a/src/MANYBODY/pair_vashishta.cpp +++ b/src/MANYBODY/pair_vashishta.cpp @@ -452,7 +452,7 @@ void PairVashishta::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MISC/compute_ti.cpp b/src/MISC/compute_ti.cpp index 135e4eab91..e81dd81c86 100644 --- a/src/MISC/compute_ti.cpp +++ b/src/MISC/compute_ti.cpp @@ -216,7 +216,7 @@ double ComputeTI::compute_scalar() eng = force->kspace->energy; else { double *eatom = force->kspace->eatom; - for(int i = 0; i < nlocal; i++) + for (int i = 0; i < nlocal; i++) if ((ilo[m]<=type[i])&(ihi[m]>=type[i])) eng += eatom[i]; MPI_Allreduce(&eng,&engall,1,MPI_DOUBLE,MPI_SUM,world); diff --git a/src/MISC/fix_gld.cpp b/src/MISC/fix_gld.cpp index 282a98b4f8..d78dd67bdb 100644 --- a/src/MISC/fix_gld.cpp +++ b/src/MISC/fix_gld.cpp @@ -67,7 +67,7 @@ FixGLD::FixGLD(LAMMPS *lmp, int narg, char **arg) : int seed = utils::inumeric(FLERR,arg[6],false,lmp); // 7 = series type - if(strcmp(arg[7],"pprony") == 0) { + if (strcmp(arg[7],"pprony") == 0) { series_type = 1; // series type 1 is 'positive Prony series' } else { error->all(FLERR,"Fix gld series type must be pprony for now"); diff --git a/src/MISC/xdr_compat.cpp b/src/MISC/xdr_compat.cpp index 7483b4aa18..675afb835e 100644 --- a/src/MISC/xdr_compat.cpp +++ b/src/MISC/xdr_compat.cpp @@ -60,7 +60,7 @@ static xdr_uint32_t xdr_swapbytes(xdr_uint32_t x) char *px=(char *)&x; char *py=(char *)&y; - for(i=0;i<4;i++) + for (i=0;i<4;i++) py[i]=px[3-i]; return y; @@ -469,7 +469,7 @@ xdr_double(XDR *xdrs, double *dp) int *ip; xdr_int32_t tmp[2]; - if(LSW<0) { + if (LSW<0) { double x=0.987654321; /* Just a number */ /* Possible representations in IEEE double precision: @@ -484,9 +484,9 @@ xdr_double(XDR *xdrs, double *dp) unsigned char ix = *((char *)&x); - if(ix==0xdd || ix==0x3f) + if (ix==0xdd || ix==0x3f) LSW=1; /* Big endian word order */ - else if(ix==0xb8 || ix==0x3c) + else if (ix==0xb8 || ix==0x3c) LSW=0; /* Small endian word order */ else { /* Catch strange errors */ printf("Error when detecting floating-point word order.\n" diff --git a/src/MLIAP/mliap_descriptor.cpp b/src/MLIAP/mliap_descriptor.cpp index ac168dc94b..29b1736f4e 100644 --- a/src/MLIAP/mliap_descriptor.cpp +++ b/src/MLIAP/mliap_descriptor.cpp @@ -26,5 +26,5 @@ MLIAPDescriptor::MLIAPDescriptor(LAMMPS *lmp) : Pointers(lmp) {} /* ---------------------------------------------------------------------- */ -MLIAPDescriptor::~MLIAPDescriptor(){} +MLIAPDescriptor::~MLIAPDescriptor() {} diff --git a/src/MLIAP/mliap_descriptor_snap.cpp b/src/MLIAP/mliap_descriptor_snap.cpp index 2cb88de6b4..275eadd74e 100644 --- a/src/MLIAP/mliap_descriptor_snap.cpp +++ b/src/MLIAP/mliap_descriptor_snap.cpp @@ -171,7 +171,7 @@ void MLIAPDescriptorSNAP::compute_forces(class MLIAPData* data) for (int jj = 0; jj < ninside; jj++) { int j = snaptr->inside[jj]; - if(chemflag) + if (chemflag) snaptr->compute_duidrj(snaptr->rij[jj], snaptr->wj[jj], snaptr->rcutij[jj],jj, snaptr->element[jj]); else @@ -245,7 +245,7 @@ void MLIAPDescriptorSNAP::compute_force_gradients(class MLIAPData* data) for (int jj = 0; jj < ninside; jj++) { const int j = snaptr->inside[jj]; - if(chemflag) + if (chemflag) snaptr->compute_duidrj(snaptr->rij[jj], snaptr->wj[jj], snaptr->rcutij[jj],jj, snaptr->element[jj]); else @@ -318,7 +318,7 @@ void MLIAPDescriptorSNAP::compute_descriptor_gradients(class MLIAPData* data) ij = ij0; for (int jj = 0; jj < ninside; jj++) { - if(chemflag) + if (chemflag) snaptr->compute_duidrj(snaptr->rij[jj], snaptr->wj[jj], snaptr->rcutij[jj],jj, snaptr->element[jj]); else @@ -500,7 +500,7 @@ void MLIAPDescriptorSNAP::read_paramfile(char *paramfilename) cut = 2.0*radelem[ielem]*rcutfac; if (cut > cutmax) cutmax = cut; cutsq[ielem][ielem] = cut*cut; - for(int jelem = ielem+1; jelem < nelements; jelem++) { + for (int jelem = ielem+1; jelem < nelements; jelem++) { cut = (radelem[ielem]+radelem[jelem])*rcutfac; cutsq[ielem][jelem] = cutsq[jelem][ielem] = cut*cut; } diff --git a/src/MLIAP/mliap_model_linear.cpp b/src/MLIAP/mliap_model_linear.cpp index 3c8f9aa39a..9d19dcf381 100644 --- a/src/MLIAP/mliap_model_linear.cpp +++ b/src/MLIAP/mliap_model_linear.cpp @@ -32,7 +32,7 @@ MLIAPModelLinear::MLIAPModelLinear(LAMMPS* lmp, char* coefffilename) : /* ---------------------------------------------------------------------- */ -MLIAPModelLinear::~MLIAPModelLinear(){} +MLIAPModelLinear::~MLIAPModelLinear() {} /* ---------------------------------------------------------------------- get number of parameters diff --git a/src/MLIAP/mliap_model_python.cpp b/src/MLIAP/mliap_model_python.cpp index e47356390f..823cee711f 100644 --- a/src/MLIAP/mliap_model_python.cpp +++ b/src/MLIAP/mliap_model_python.cpp @@ -73,7 +73,7 @@ MLIAPModelPython::MLIAPModelPython(LAMMPS* lmp, char* coefffilename) : /* ---------------------------------------------------------------------- */ -MLIAPModelPython::~MLIAPModelPython(){ +MLIAPModelPython::~MLIAPModelPython() { MLIAPPY_unload_model(this); } diff --git a/src/MLIAP/mliap_model_quadratic.cpp b/src/MLIAP/mliap_model_quadratic.cpp index 915ec30435..0b640189b4 100644 --- a/src/MLIAP/mliap_model_quadratic.cpp +++ b/src/MLIAP/mliap_model_quadratic.cpp @@ -35,7 +35,7 @@ MLIAPModelQuadratic::MLIAPModelQuadratic(LAMMPS* lmp, char* coefffilename) : /* ---------------------------------------------------------------------- */ -MLIAPModelQuadratic::~MLIAPModelQuadratic(){} +MLIAPModelQuadratic::~MLIAPModelQuadratic() {} /* ---------------------------------------------------------------------- get number of parameters diff --git a/src/MOLECULE/angle_table.cpp b/src/MOLECULE/angle_table.cpp index a8c57918b4..4dfb4f0988 100644 --- a/src/MOLECULE/angle_table.cpp +++ b/src/MOLECULE/angle_table.cpp @@ -241,7 +241,7 @@ void AngleTable::coeff(int narg, char **arg) // convert theta from degrees to radians - for (int i = 0; i < tb->ninput; i++){ + for (int i = 0; i < tb->ninput; i++) { tb->afile[i] *= MY_PI/180.0; tb->ffile[i] *= 180.0/MY_PI; } diff --git a/src/MOLECULE/fix_cmap.cpp b/src/MOLECULE/fix_cmap.cpp index f48d5254cf..d8aee3e181 100644 --- a/src/MOLECULE/fix_cmap.cpp +++ b/src/MOLECULE/fix_cmap.cpp @@ -1376,7 +1376,7 @@ void FixCMAP::copy_arrays(int i, int j, int /*delflag*/) { num_crossterm[j] = num_crossterm[i]; - for (int k = 0; k < num_crossterm[j]; k++){ + for (int k = 0; k < num_crossterm[j]; k++) { crossterm_type[j][k] = crossterm_type[i][k]; crossterm_atom1[j][k] = crossterm_atom1[i][k]; crossterm_atom2[j][k] = crossterm_atom2[i][k]; diff --git a/src/MOLECULE/pair_tip4p_cut.cpp b/src/MOLECULE/pair_tip4p_cut.cpp index 055ac539c8..3f30122a65 100644 --- a/src/MOLECULE/pair_tip4p_cut.cpp +++ b/src/MOLECULE/pair_tip4p_cut.cpp @@ -264,7 +264,7 @@ void PairTIP4PCut::compute(int eflag, int vflag) f[iH2][1] += fH[1]; f[iH2][2] += fH[2]; - if(vflag) { + if (vflag) { xH1 = x[iH1]; xH2 = x[iH2]; v[0] = x[i][0]*fO[0] + xH1[0]*fH[0] + xH2[0]*fH[0]; diff --git a/src/OPT/pair_eam_opt.cpp b/src/OPT/pair_eam_opt.cpp index 7238927367..c89afad705 100644 --- a/src/OPT/pair_eam_opt.cpp +++ b/src/OPT/pair_eam_opt.cpp @@ -116,7 +116,7 @@ void PairEAMOpt::eval() for (i = 0; i < ntypes; i++) for (j = 0; j < ntypes; j++) { fast_alpha_t* _noalias tab = &fast_alpha[i*ntypes*nr+j*nr]; if (type2rhor[i+1][j+1] >= 0) { - for(int m = 1; m <= nr; m++) { + for (int m = 1; m <= nr; m++) { tab[m].rhor0i = rhor_spline[type2rhor[i+1][j+1]][m][6]; tab[m].rhor1i = rhor_spline[type2rhor[i+1][j+1]][m][5]; tab[m].rhor2i = rhor_spline[type2rhor[i+1][j+1]][m][4]; @@ -124,7 +124,7 @@ void PairEAMOpt::eval() } } if (type2rhor[j+1][i+1] >= 0) { - for(int m = 1; m <= nr; m++) { + for (int m = 1; m <= nr; m++) { tab[m].rhor0j = rhor_spline[type2rhor[j+1][i+1]][m][6]; tab[m].rhor1j = rhor_spline[type2rhor[j+1][i+1]][m][5]; tab[m].rhor2j = rhor_spline[type2rhor[j+1][i+1]][m][4]; @@ -139,14 +139,14 @@ void PairEAMOpt::eval() for (i = 0; i < ntypes; i++) for (j = 0; j < ntypes; j++) { fast_gamma_t* _noalias tab = &fast_gamma[i*ntypes*nr+j*nr]; if (type2rhor[i+1][j+1] >= 0) { - for(int m = 1; m <= nr; m++) { + for (int m = 1; m <= nr; m++) { tab[m].rhor4i = rhor_spline[type2rhor[i+1][j+1]][m][2]; tab[m].rhor5i = rhor_spline[type2rhor[i+1][j+1]][m][1]; tab[m].rhor6i = rhor_spline[type2rhor[i+1][j+1]][m][0]; } } if (type2rhor[j+1][i+1] >= 0) { - for(int m = 1; m <= nr; m++) { + for (int m = 1; m <= nr; m++) { tab[m].rhor4j = rhor_spline[type2rhor[j+1][i+1]][m][2]; tab[m].rhor5j = rhor_spline[type2rhor[j+1][i+1]][m][1]; tab[m].rhor6j = rhor_spline[type2rhor[j+1][i+1]][m][0]; @@ -154,7 +154,7 @@ void PairEAMOpt::eval() } } if (type2z2r[i+1][j+1] >= 0) { - for(int m = 1; m <= nr; m++) { + for (int m = 1; m <= nr; m++) { tab[m].z2r0 = z2r_spline[type2z2r[i+1][j+1]][m][6]; tab[m].z2r1 = z2r_spline[type2z2r[i+1][j+1]][m][5]; tab[m].z2r2 = z2r_spline[type2z2r[i+1][j+1]][m][4]; diff --git a/src/OPT/pair_lj_long_coul_long_opt.cpp b/src/OPT/pair_lj_long_coul_long_opt.cpp index 592f93a656..0ead71befb 100644 --- a/src/OPT/pair_lj_long_coul_long_opt.cpp +++ b/src/OPT/pair_lj_long_coul_long_opt.cpp @@ -616,7 +616,7 @@ void PairLJLongCoulLongOpt::eval() if (rsq < cut_ljsqi[typej]) { // lj if (ORDER6) { // long-range lj - if(!LJTABLE || rsq <= tabinnerdispsq) { // series real space + if (!LJTABLE || rsq <= tabinnerdispsq) { // series real space double rn = r2inv*r2inv*r2inv; double x2 = g2*rsq, a2 = 1.0/x2; x2 = a2*exp(-x2)*lj4i[typej]; diff --git a/src/PYTHON/fix_python_move.cpp b/src/PYTHON/fix_python_move.cpp index d738d21c5b..18047b794e 100644 --- a/src/PYTHON/fix_python_move.cpp +++ b/src/PYTHON/fix_python_move.cpp @@ -109,7 +109,7 @@ FixPythonMove::FixPythonMove(LAMMPS *lmp, int narg, char **arg) : FixPythonMove::~FixPythonMove() { PyGILState_STATE gstate = PyGILState_Ensure(); - if(py_move) Py_DECREF((PyObject*) py_move); + if (py_move) Py_DECREF((PyObject*) py_move); PyGILState_Release(gstate); } diff --git a/src/PYTHON/python_impl.cpp b/src/PYTHON/python_impl.cpp index 42b1135ceb..260454d150 100644 --- a/src/PYTHON/python_impl.cpp +++ b/src/PYTHON/python_impl.cpp @@ -72,7 +72,7 @@ PythonImpl::PythonImpl(LAMMPS *lmp) : Pointers(lmp) // With Python 3.7 this function is now called by Py_Initialize() // Deprecated since version 3.9, will be removed in version 3.11 #if PY_MAJOR_VERSION < 3 || PY_MINOR_VERSION < 7 - if(!PyEval_ThreadsInitialized()) { + if (!PyEval_ThreadsInitialized()) { PyEval_InitThreads(); } #endif @@ -90,7 +90,7 @@ PythonImpl::PythonImpl(LAMMPS *lmp) : Pointers(lmp) PythonImpl::~PythonImpl() { - if(pyMain) { + if (pyMain) { // clean up PyGILState_STATE gstate = PyGILState_Ensure(); diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index 9f47d89097..555b9d2770 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -103,7 +103,7 @@ FixQEq::FixQEq(LAMMPS *lmp, int narg, char **arg) : grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); - for( int i = 0; i < atom->nmax; i++ ) + for ( int i = 0; i < atom->nmax; i++ ) for (int j = 0; j < nprev; ++j ) s_hist[i][j] = t_hist[i][j] = atom->q[i]; @@ -234,7 +234,7 @@ void FixQEq::allocate_matrix() numneigh = list->numneigh; m = 0; - for( ii = 0; ii < inum; ii++ ) { + for ( ii = 0; ii < inum; ii++ ) { i = ilist[ii]; m += numneigh[i]; } @@ -306,7 +306,7 @@ void FixQEq::init_storage() nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - for( int i = 0; i < nall; i++ ) { + for ( int i = 0; i < nall; i++ ) { Hdia_inv[i] = 1. / eta[atom->type[i]]; b_s[i] = -chi[atom->type[i]]; b_t[i] = -1.0; @@ -352,7 +352,7 @@ int FixQEq::CG( double *b, double *x ) vector_sum( r , 1., b, -1., q, inum ); - for( ii = 0; ii < inum; ++ii ) { + for ( ii = 0; ii < inum; ++ii ) { i = ilist[ii]; if (atom->mask[i] & groupbit) d[i] = r[i] * Hdia_inv[i]; @@ -362,7 +362,7 @@ int FixQEq::CG( double *b, double *x ) b_norm = parallel_norm( b, inum ); sig_new = parallel_dot( r, d, inum); - for( loop = 1; loop < maxiter && sqrt(sig_new)/b_norm > tolerance; ++loop ) { + for ( loop = 1; loop < maxiter && sqrt(sig_new)/b_norm > tolerance; ++loop ) { comm->forward_comm_fix(this); sparse_matvec( &H, d, q ); comm->reverse_comm_fix(this); @@ -373,7 +373,7 @@ int FixQEq::CG( double *b, double *x ) vector_add( x, alfa, d, inum ); vector_add( r, -alfa, q, inum ); - for( ii = 0; ii < inum; ++ii ) { + for ( ii = 0; ii < inum; ++ii ) { i = ilist[ii]; if (atom->mask[i] & groupbit) p[i] = r[i] * Hdia_inv[i]; @@ -406,19 +406,19 @@ void FixQEq::sparse_matvec( sparse_matrix *A, double *x, double *b ) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - for( i = 0; i < nlocal; ++i ) { + for ( i = 0; i < nlocal; ++i ) { if (atom->mask[i] & groupbit) b[i] = eta[ atom->type[i] ] * x[i]; } - for( i = nlocal; i < nall; ++i ) { + for ( i = nlocal; i < nall; ++i ) { if (atom->mask[i] & groupbit) b[i] = 0; } - for( i = 0; i < nlocal; ++i ) { + for ( i = 0; i < nlocal; ++i ) { if (atom->mask[i] & groupbit) { - for( itr_j=A->firstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { + for ( itr_j=A->firstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { j = A->jlist[itr_j]; b[i] += A->val[itr_j] * x[j]; b[j] += A->val[itr_j] * x[i]; @@ -444,12 +444,12 @@ void FixQEq::calculate_Q() t_sum = parallel_vector_acc( t, inum); u = s_sum / t_sum; - for( ii = 0; ii < inum; ++ii ) { + for ( ii = 0; ii < inum; ++ii ) { i = ilist[ii]; if (atom->mask[i] & groupbit) { q[i] = s[i] - u * t[i]; - for( k = 4; k > 0; --k ) { + for ( k = 4; k > 0; --k ) { s_hist[i][k] = s_hist[i][k-1]; t_hist[i][k] = t_hist[i][k-1]; } @@ -470,13 +470,13 @@ int FixQEq::pack_forward_comm(int n, int *list, double *buf, int m; if (pack_flag == 1) - for(m = 0; m < n; m++) buf[m] = d[list[m]]; - else if( pack_flag == 2 ) - for(m = 0; m < n; m++) buf[m] = s[list[m]]; - else if( pack_flag == 3 ) - for(m = 0; m < n; m++) buf[m] = t[list[m]]; - else if( pack_flag == 4 ) - for(m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + for (m = 0; m < n; m++) buf[m] = d[list[m]]; + else if ( pack_flag == 2 ) + for (m = 0; m < n; m++) buf[m] = s[list[m]]; + else if ( pack_flag == 3 ) + for (m = 0; m < n; m++) buf[m] = t[list[m]]; + else if ( pack_flag == 4 ) + for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; else m = 0; return m; @@ -489,13 +489,13 @@ void FixQEq::unpack_forward_comm(int n, int first, double *buf) int i, m; if (pack_flag == 1) - for(m = 0, i = first; m < n; m++, i++) d[i] = buf[m]; - else if( pack_flag == 2) - for(m = 0, i = first; m < n; m++, i++) s[i] = buf[m]; - else if( pack_flag == 3) - for(m = 0, i = first; m < n; m++, i++) t[i] = buf[m]; - else if( pack_flag == 4) - for(m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) d[i] = buf[m]; + else if ( pack_flag == 2) + for (m = 0, i = first; m < n; m++, i++) s[i] = buf[m]; + else if ( pack_flag == 3) + for (m = 0, i = first; m < n; m++, i++) t[i] = buf[m]; + else if ( pack_flag == 4) + for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; } /* ---------------------------------------------------------------------- */ @@ -503,7 +503,7 @@ void FixQEq::unpack_forward_comm(int n, int first, double *buf) int FixQEq::pack_reverse_comm(int n, int first, double *buf) { int i, m; - for(m = 0, i = first; m < n; m++, i++) buf[m] = q[i]; + for (m = 0, i = first; m < n; m++, i++) buf[m] = q[i]; return m; } @@ -513,7 +513,7 @@ void FixQEq::unpack_reverse_comm(int n, int *list, double *buf) { int m; - for(m = 0; m < n; m++) q[list[m]] += buf[m]; + for (m = 0; m < n; m++) q[list[m]] += buf[m]; } /* ---------------------------------------------------------------------- @@ -591,7 +591,7 @@ double FixQEq::parallel_norm( double *v, int n ) my_sum = 0.0; norm_sqr = 0.0; - for( ii = 0; ii < n; ++ii ) { + for ( ii = 0; ii < n; ++ii ) { i = ilist[ii]; if (atom->mask[i] & groupbit) my_sum += v[i]*v[i]; @@ -616,7 +616,7 @@ double FixQEq::parallel_dot( double *v1, double *v2, int n) my_dot = 0.0; res = 0.0; - for( ii = 0; ii < n; ++ii ) { + for ( ii = 0; ii < n; ++ii ) { i = ilist[ii]; if (atom->mask[i] & groupbit) my_dot += v1[i] * v2[i]; @@ -641,7 +641,7 @@ double FixQEq::parallel_vector_acc( double *v, int n ) my_acc = 0.0; res = 0.0; - for( ii = 0; ii < n; ++ii ) { + for ( ii = 0; ii < n; ++ii ) { i = ilist[ii]; if (atom->mask[i] & groupbit) my_acc += v[i]; @@ -662,7 +662,7 @@ void FixQEq::vector_sum( double* dest, double c, double* v, ilist = list->ilist; - for( --k; k>=0; --k ) { + for ( --k; k>=0; --k ) { kk = ilist[k]; if (atom->mask[kk] & groupbit) dest[kk] = c * v[kk] + d * y[kk]; @@ -678,7 +678,7 @@ void FixQEq::vector_add( double* dest, double c, double* v, int k ) ilist = list->ilist; - for( --k; k>=0; --k ) { + for ( --k; k>=0; --k ) { kk = ilist[k]; if (atom->mask[kk] & groupbit) dest[kk] += c * v[kk]; diff --git a/src/QEQ/fix_qeq_dynamic.cpp b/src/QEQ/fix_qeq_dynamic.cpp index da4ef98591..6fc98410eb 100644 --- a/src/QEQ/fix_qeq_dynamic.cpp +++ b/src/QEQ/fix_qeq_dynamic.cpp @@ -249,9 +249,9 @@ int FixQEqDynamic::pack_forward_comm(int n, int *list, double *buf, int m=0; if (pack_flag == 1) - for(m = 0; m < n; m++) buf[m] = atom->q[list[m]]; - else if( pack_flag == 2 ) - for(m = 0; m < n; m++) buf[m] = qf[list[m]]; + for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + else if ( pack_flag == 2 ) + for (m = 0; m < n; m++) buf[m] = qf[list[m]]; return m; } @@ -263,9 +263,9 @@ void FixQEqDynamic::unpack_forward_comm(int n, int first, double *buf) int i, m; if (pack_flag == 1) - for(m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; - else if( pack_flag == 2) - for(m = 0, i = first; m < n; m++, i++) qf[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + else if ( pack_flag == 2) + for (m = 0, i = first; m < n; m++, i++) qf[i] = buf[m]; } /* ---------------------------------------------------------------------- */ @@ -273,7 +273,7 @@ void FixQEqDynamic::unpack_forward_comm(int n, int first, double *buf) int FixQEqDynamic::pack_reverse_comm(int n, int first, double *buf) { int i, m; - for(m = 0, i = first; m < n; m++, i++) buf[m] = qf[i]; + for (m = 0, i = first; m < n; m++, i++) buf[m] = qf[i]; return m; } @@ -283,7 +283,7 @@ void FixQEqDynamic::unpack_reverse_comm(int n, int *list, double *buf) { int m; - for(m = 0; m < n; m++) qf[list[m]] += buf[m]; + for (m = 0; m < n; m++) qf[list[m]] += buf[m]; } /* ---------------------------------------------------------------------- */ diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index 3d0313c789..613d6998aa 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -313,9 +313,9 @@ int FixQEqFire::pack_forward_comm(int n, int *list, double *buf, int m = 0; if (pack_flag == 1) - for(m = 0; m < n; m++) buf[m] = atom->q[list[m]]; - else if( pack_flag == 2 ) - for(m = 0; m < n; m++) buf[m] = qf[list[m]]; + for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + else if ( pack_flag == 2 ) + for (m = 0; m < n; m++) buf[m] = qf[list[m]]; return m; } @@ -327,9 +327,9 @@ void FixQEqFire::unpack_forward_comm(int n, int first, double *buf) int i, m; if (pack_flag == 1) - for(m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; - else if( pack_flag == 2) - for(m = 0, i = first; m < n; m++, i++) qf[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + else if ( pack_flag == 2) + for (m = 0, i = first; m < n; m++, i++) qf[i] = buf[m]; } /* ---------------------------------------------------------------------- */ @@ -337,7 +337,7 @@ void FixQEqFire::unpack_forward_comm(int n, int first, double *buf) int FixQEqFire::pack_reverse_comm(int n, int first, double *buf) { int i, m; - for(m = 0, i = first; m < n; m++, i++) buf[m] = qf[i]; + for (m = 0, i = first; m < n; m++, i++) buf[m] = qf[i]; return m; } @@ -347,7 +347,7 @@ void FixQEqFire::unpack_reverse_comm(int n, int *list, double *buf) { int m; - for(m = 0; m < n; m++) qf[list[m]] += buf[m]; + for (m = 0; m < n; m++) qf[list[m]] += buf[m]; } /* ---------------------------------------------------------------------- */ diff --git a/src/RIGID/fix_ehex.cpp b/src/RIGID/fix_ehex.cpp index 73776d5220..a3346b3d1c 100644 --- a/src/RIGID/fix_ehex.cpp +++ b/src/RIGID/fix_ehex.cpp @@ -273,7 +273,7 @@ void FixEHEX::rescale() { vsub[1] = (scale-1.0) * vcm[1]; vsub[2] = (scale-1.0) * vcm[2]; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (scalingmask[i]) { diff --git a/src/SNAP/compute_sna_atom.cpp b/src/SNAP/compute_sna_atom.cpp index d96849915f..8e26d44f61 100644 --- a/src/SNAP/compute_sna_atom.cpp +++ b/src/SNAP/compute_sna_atom.cpp @@ -64,9 +64,9 @@ ComputeSNAAtom::ComputeSNAAtom(LAMMPS *lmp, int narg, char **arg) : rfac0 = atof(arg[4]); twojmax = atoi(arg[5]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) radelem[i+1] = atof(arg[6+i]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) wjelem[i+1] = atof(arg[6+ntypes+i]); // construct cutsq @@ -74,11 +74,11 @@ ComputeSNAAtom::ComputeSNAAtom(LAMMPS *lmp, int narg, char **arg) : double cut; cutmax = 0.0; memory->create(cutsq,ntypes+1,ntypes+1,"sna/atom:cutsq"); - for(int i = 1; i <= ntypes; i++) { + for (int i = 1; i <= ntypes; i++) { cut = 2.0*radelem[i]*rcutfac; if (cut > cutmax) cutmax = cut; cutsq[i][i] = cut*cut; - for(int j = i+1; j <= ntypes; j++) { + for (int j = i+1; j <= ntypes; j++) { cut = (radelem[i]+radelem[j])*rcutfac; cutsq[i][j] = cutsq[j][i] = cut*cut; } @@ -115,7 +115,7 @@ ComputeSNAAtom::ComputeSNAAtom(LAMMPS *lmp, int narg, char **arg) : chemflag = 1; memory->create(map,ntypes+1,"compute_sna_atom:map"); nelements = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - for(int i = 0; i < ntypes; i++) { + for (int i = 0; i < ntypes; i++) { int jelem = utils::inumeric(FLERR,arg[iarg+2+i],false,lmp); if (jelem < 0 || jelem >= nelements) error->all(FLERR,"Illegal compute sna/atom command"); diff --git a/src/SNAP/compute_snad_atom.cpp b/src/SNAP/compute_snad_atom.cpp index 35cbb9225c..b9ab2f54ae 100644 --- a/src/SNAP/compute_snad_atom.cpp +++ b/src/SNAP/compute_snad_atom.cpp @@ -62,9 +62,9 @@ ComputeSNADAtom::ComputeSNADAtom(LAMMPS *lmp, int narg, char **arg) : rcutfac = atof(arg[3]); rfac0 = atof(arg[4]); twojmax = atoi(arg[5]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) radelem[i+1] = atof(arg[6+i]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) wjelem[i+1] = atof(arg[6+ntypes+i]); // construct cutsq @@ -72,11 +72,11 @@ ComputeSNADAtom::ComputeSNADAtom(LAMMPS *lmp, int narg, char **arg) : double cut; cutmax = 0.0; memory->create(cutsq,ntypes+1,ntypes+1,"sna/atom:cutsq"); - for(int i = 1; i <= ntypes; i++) { + for (int i = 1; i <= ntypes; i++) { cut = 2.0*radelem[i]*rcutfac; if (cut > cutmax) cutmax = cut; cutsq[i][i] = cut*cut; - for(int j = i+1; j <= ntypes; j++) { + for (int j = i+1; j <= ntypes; j++) { cut = (radelem[i]+radelem[j])*rcutfac; cutsq[i][j] = cutsq[j][i] = cut*cut; } @@ -113,7 +113,7 @@ ComputeSNADAtom::ComputeSNADAtom(LAMMPS *lmp, int narg, char **arg) : chemflag = 1; memory->create(map,ntypes+1,"compute_snad_atom:map"); nelements = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - for(int i = 0; i < ntypes; i++) { + for (int i = 0; i < ntypes; i++) { int jelem = utils::inumeric(FLERR,arg[iarg+2+i],false,lmp); if (jelem < 0 || jelem >= nelements) error->all(FLERR,"Illegal compute snad/atom command"); diff --git a/src/SNAP/compute_snap.cpp b/src/SNAP/compute_snap.cpp index 9f25fdbff9..eca832f665 100644 --- a/src/SNAP/compute_snap.cpp +++ b/src/SNAP/compute_snap.cpp @@ -68,9 +68,9 @@ ComputeSnap::ComputeSnap(LAMMPS *lmp, int narg, char **arg) : rcutfac = atof(arg[3]); rfac0 = atof(arg[4]); twojmax = atoi(arg[5]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) radelem[i+1] = atof(arg[6+i]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) wjelem[i+1] = atof(arg[6+ntypes+i]); // construct cutsq @@ -78,11 +78,11 @@ ComputeSnap::ComputeSnap(LAMMPS *lmp, int narg, char **arg) : double cut; cutmax = 0.0; memory->create(cutsq,ntypes+1,ntypes+1,"snap:cutsq"); - for(int i = 1; i <= ntypes; i++) { + for (int i = 1; i <= ntypes; i++) { cut = 2.0*radelem[i]*rcutfac; if (cut > cutmax) cutmax = cut; cutsq[i][i] = cut*cut; - for(int j = i+1; j <= ntypes; j++) { + for (int j = i+1; j <= ntypes; j++) { cut = (radelem[i]+radelem[j])*rcutfac; cutsq[i][j] = cutsq[j][i] = cut*cut; } @@ -119,7 +119,7 @@ ComputeSnap::ComputeSnap(LAMMPS *lmp, int narg, char **arg) : chemflag = 1; memory->create(map,ntypes+1,"compute_snap:map"); nelements = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - for(int i = 0; i < ntypes; i++) { + for (int i = 0; i < ntypes; i++) { int jelem = utils::inumeric(FLERR,arg[iarg+2+i],false,lmp); if (jelem < 0 || jelem >= nelements) error->all(FLERR,"Illegal compute snap command"); diff --git a/src/SNAP/compute_snav_atom.cpp b/src/SNAP/compute_snav_atom.cpp index 3772a92ad7..42a54e6cb1 100644 --- a/src/SNAP/compute_snav_atom.cpp +++ b/src/SNAP/compute_snav_atom.cpp @@ -61,17 +61,17 @@ ComputeSNAVAtom::ComputeSNAVAtom(LAMMPS *lmp, int narg, char **arg) : rcutfac = atof(arg[3]); rfac0 = atof(arg[4]); twojmax = atoi(arg[5]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) radelem[i+1] = atof(arg[6+i]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) wjelem[i+1] = atof(arg[6+ntypes+i]); // construct cutsq double cut; memory->create(cutsq,ntypes+1,ntypes+1,"sna/atom:cutsq"); - for(int i = 1; i <= ntypes; i++) { + for (int i = 1; i <= ntypes; i++) { cut = 2.0*radelem[i]*rcutfac; cutsq[i][i] = cut*cut; - for(int j = i+1; j <= ntypes; j++) { + for (int j = i+1; j <= ntypes; j++) { cut = (radelem[i]+radelem[j])*rcutfac; cutsq[i][j] = cutsq[j][i] = cut*cut; } @@ -108,7 +108,7 @@ ComputeSNAVAtom::ComputeSNAVAtom(LAMMPS *lmp, int narg, char **arg) : chemflag = 1; memory->create(map,ntypes+1,"compute_sna_atom:map"); nelements = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - for(int i = 0; i < ntypes; i++) { + for (int i = 0; i < ntypes; i++) { int jelem = utils::inumeric(FLERR,arg[iarg+2+i],false,lmp); if (jelem < 0 || jelem >= nelements) error->all(FLERR,"Illegal compute snav/atom command"); diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index a7ea6de591..6240059a68 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -177,7 +177,7 @@ void PairSNAP::compute(int eflag, int vflag) for (int jj = 0; jj < ninside; jj++) { int j = snaptr->inside[jj]; - if(chemflag) + if (chemflag) snaptr->compute_duidrj(snaptr->rij[jj], snaptr->wj[jj], snaptr->rcutij[jj],jj, snaptr->element[jj]); else @@ -344,7 +344,7 @@ void PairSNAP::compute_bispectrum() else snaptr->compute_bi(0); - for (int icoeff = 0; icoeff < ncoeff; icoeff++){ + for (int icoeff = 0; icoeff < ncoeff; icoeff++) { bispectrum[ii][icoeff] = snaptr->blist[icoeff]; } } diff --git a/src/SNAP/sna.cpp b/src/SNAP/sna.cpp index 3c7a40c0dc..d2b423d5db 100644 --- a/src/SNAP/sna.cpp +++ b/src/SNAP/sna.cpp @@ -152,7 +152,7 @@ SNA::SNA(LAMMPS* lmp, double rfac0_in, int twojmax_in, if (bzero_flag) { double www = wself*wself*wself; - for(int j = 0; j <= twojmax; j++) + for (int j = 0; j <= twojmax; j++) if (bnorm_flag) bzero[j] = www; else @@ -187,9 +187,9 @@ void SNA::build_indexlist() "sna:idxcg_block"); int idxcg_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { idxcg_block[j1][j2][j] = idxcg_count; for (int m1 = 0; m1 <= j1; m1++) for (int m2 = 0; m2 <= j2; m2++) @@ -205,10 +205,10 @@ void SNA::build_indexlist() int idxu_count = 0; - for(int j = 0; j <= twojmax; j++) { + for (int j = 0; j <= twojmax; j++) { idxu_block[j] = idxu_count; - for(int mb = 0; mb <= j; mb++) - for(int ma = 0; ma <= j; ma++) + for (int mb = 0; mb <= j; mb++) + for (int ma = 0; ma <= j; ma++) idxu_count++; } idxu_max = idxu_count; @@ -216,18 +216,18 @@ void SNA::build_indexlist() // index list for beta and B int idxb_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) if (j >= j1) idxb_count++; idxb_max = idxb_count; idxb = new SNA_BINDICES[idxb_max]; idxb_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) if (j >= j1) { idxb[idxb_count].j1 = j1; idxb[idxb_count].j2 = j2; @@ -240,9 +240,9 @@ void SNA::build_indexlist() memory->create(idxb_block, jdim, jdim, jdim, "sna:idxb_block"); idxb_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { if (j >= j1) { idxb_block[j1][j2][j] = idxb_count; idxb_count++; @@ -253,9 +253,9 @@ void SNA::build_indexlist() int idxz_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) for (int mb = 0; 2*mb <= j; mb++) for (int ma = 0; ma <= j; ma++) idxz_count++; @@ -267,9 +267,9 @@ void SNA::build_indexlist() "sna:idxz_block"); idxz_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { idxz_block[j1][j2][j] = idxz_count; // find right beta[jjb] entry @@ -309,7 +309,7 @@ void SNA::init() void SNA::grow_rij(int newnmax) { - if(newnmax <= nmax) return; + if (newnmax <= nmax) return; nmax = newnmax; @@ -345,7 +345,7 @@ void SNA::compute_ui(int jnum, int ielem) zero_uarraytot(ielem); - for(int j = 0; j < jnum; j++) { + for (int j = 0; j < jnum; j++) { x = rij[j][0]; y = rij[j][1]; z = rij[j][2]; @@ -375,8 +375,8 @@ void SNA::compute_zi() int idouble = 0; double * zptr_r; double * zptr_i; - for(int elem1 = 0; elem1 < nelements; elem1++) - for(int elem2 = 0; elem2 < nelements; elem2++) { + for (int elem1 = 0; elem1 < nelements; elem1++) + for (int elem2 = 0; elem2 < nelements; elem2++) { zptr_r = &zlist_r[idouble*idxz_max]; zptr_i = &zlist_i[idouble*idxz_max]; @@ -448,18 +448,18 @@ void SNA::compute_yi(const double* beta) double betaj; int itriple; - for(int ielem1 = 0; ielem1 < nelements; ielem1++) - for(int j = 0; j <= twojmax; j++) { + for (int ielem1 = 0; ielem1 < nelements; ielem1++) + for (int j = 0; j <= twojmax; j++) { jju = idxu_block[j]; - for(int mb = 0; 2*mb <= j; mb++) - for(int ma = 0; ma <= j; ma++) { + for (int mb = 0; 2*mb <= j; mb++) + for (int ma = 0; ma <= j; ma++) { ylist_r[ielem1*idxu_max+jju] = 0.0; ylist_i[ielem1*idxu_max+jju] = 0.0; jju++; } // end loop over ma, mb } // end loop over j - for(int elem1 = 0; elem1 < nelements; elem1++) + for (int elem1 = 0; elem1 < nelements; elem1++) for (int elem2 = 0; elem2 < nelements; elem2++) { for (int jjz = 0; jjz < idxz_max; jjz++) { const int j1 = idxz[jjz].j1; @@ -522,7 +522,7 @@ void SNA::compute_yi(const double* beta) } jju = idxz[jjz].jju; - for(int elem3 = 0; elem3 < nelements; elem3++) { + for (int elem3 = 0; elem3 < nelements; elem3++) { // pick out right beta value if (j >= j1) { const int jjb = idxb_block[j1][j2][j]; @@ -560,22 +560,22 @@ void SNA::compute_yi(const double* beta) void SNA::compute_deidrj(double* dedr) { - for(int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) dedr[k] = 0.0; int jelem = elem_duarray; - for(int j = 0; j <= twojmax; j++) { + for (int j = 0; j <= twojmax; j++) { int jju = idxu_block[j]; - for(int mb = 0; 2*mb < j; mb++) - for(int ma = 0; ma <= j; ma++) { + for (int mb = 0; 2*mb < j; mb++) + for (int ma = 0; ma <= j; ma++) { double* dudr_r = dulist_r[jju]; double* dudr_i = dulist_i[jju]; double jjjmambyarray_r = ylist_r[jelem*idxu_max+jju]; double jjjmambyarray_i = ylist_i[jelem*idxu_max+jju]; - for(int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) dedr[k] += dudr_r[k] * jjjmambyarray_r + dudr_i[k] * jjjmambyarray_i; @@ -587,13 +587,13 @@ void SNA::compute_deidrj(double* dedr) if (j%2 == 0) { int mb = j/2; - for(int ma = 0; ma < mb; ma++) { + for (int ma = 0; ma < mb; ma++) { double* dudr_r = dulist_r[jju]; double* dudr_i = dulist_i[jju]; double jjjmambyarray_r = ylist_r[jelem*idxu_max+jju]; double jjjmambyarray_i = ylist_i[jelem*idxu_max+jju]; - for(int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) dedr[k] += dudr_r[k] * jjjmambyarray_r + dudr_i[k] * jjjmambyarray_i; @@ -605,7 +605,7 @@ void SNA::compute_deidrj(double* dedr) double jjjmambyarray_r = ylist_r[jelem*idxu_max+jju]; double jjjmambyarray_i = ylist_i[jelem*idxu_max+jju]; - for(int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) dedr[k] += (dudr_r[k] * jjjmambyarray_r + dudr_i[k] * jjjmambyarray_i)*0.5; @@ -615,7 +615,7 @@ void SNA::compute_deidrj(double* dedr) } // end loop over j - for(int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) dedr[k] *= 2.0; } @@ -693,9 +693,9 @@ void SNA::compute_bi(int ielem) { } // end loop over JJ } else { int itriple = 0; - for(int elem1 = 0; elem1 < nelements; elem1++) - for(int elem2 = 0; elem2 < nelements; elem2++) { - for(int elem3 = 0; elem3 < nelements; elem3++) { + for (int elem1 = 0; elem1 < nelements; elem1++) + for (int elem2 = 0; elem2 < nelements; elem2++) { + for (int elem3 = 0; elem3 < nelements; elem3++) { for (int jjb = 0; jjb < idxb_max; jjb++) { const int j = idxb[jjb].j; blist[itriple*idxb_max+jjb] -= bzero[j]; @@ -749,11 +749,11 @@ void SNA::compute_dbidrj() // set all the derivatives to zero once - for(int jjb = 0; jjb < idxb_max; jjb++) { + for (int jjb = 0; jjb < idxb_max; jjb++) { - for(int elem1 = 0; elem1 < nelements; elem1++) - for(int elem2 = 0; elem2 < nelements; elem2++) - for(int elem3 = 0; elem3 < nelements; elem3++) { + for (int elem1 = 0; elem1 < nelements; elem1++) + for (int elem2 = 0; elem2 < nelements; elem2++) + for (int elem3 = 0; elem3 < nelements; elem3++) { itriple = (elem1 * nelements + elem2) * nelements + elem3; @@ -767,7 +767,7 @@ void SNA::compute_dbidrj() int elem3 = elem_duarray; - for(int jjb = 0; jjb < idxb_max; jjb++) { + for (int jjb = 0; jjb < idxb_max; jjb++) { const int j1 = idxb[jjb].j1; const int j2 = idxb[jjb].j2; const int j = idxb[jjb].j; @@ -775,8 +775,8 @@ void SNA::compute_dbidrj() // Sum terms Conj(dudr(j,ma,mb))*z(j1,j2,j,ma,mb) - for(int elem1 = 0; elem1 < nelements; elem1++) - for(int elem2 = 0; elem2 < nelements; elem2++) { + for (int elem1 = 0; elem1 < nelements; elem1++) + for (int elem2 = 0; elem2 < nelements; elem2++) { jjz = idxz_block[j1][j2][j]; jju = idxu_block[j]; @@ -975,7 +975,7 @@ void SNA::compute_duidrj(double* rij, double wj, double rcut, int jj, int jelem) void SNA::zero_uarraytot(int ielem) { - for(int jelem = 0; jelem < nelements; jelem++) + for (int jelem = 0; jelem < nelements; jelem++) for (int j = 0; j <= twojmax; j++) { int jju = idxu_block[j]; for (int mb = 0; mb <= j; mb++) { @@ -1389,9 +1389,9 @@ void SNA::init_clebsch_gordan() int ifac; int idxcg_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { for (int m1 = 0; m1 <= j1; m1++) { aa2 = 2 * m1 - j1; @@ -1402,7 +1402,7 @@ void SNA::init_clebsch_gordan() bb2 = 2 * m2 - j2; m = (aa2 + bb2 + j) / 2; - if(m < 0 || m > j) { + if (m < 0 || m > j) { cglist[idxcg_count] = 0.0; idxcg_count++; continue; @@ -1516,8 +1516,8 @@ double SNA::compute_sfac(double r, double rcut) { if (switch_flag == 0) return 1.0; if (switch_flag == 1) { - if(r <= rmin0) return 1.0; - else if(r > rcut) return 0.0; + if (r <= rmin0) return 1.0; + else if (r > rcut) return 0.0; else { double rcutfac = MY_PI / (rcut - rmin0); return 0.5 * (cos((r - rmin0) * rcutfac) + 1.0); @@ -1532,8 +1532,8 @@ double SNA::compute_dsfac(double r, double rcut) { if (switch_flag == 0) return 0.0; if (switch_flag == 1) { - if(r <= rmin0) return 0.0; - else if(r > rcut) return 0.0; + if (r <= rmin0) return 0.0; + else if (r > rcut) return 0.0; else { double rcutfac = MY_PI / (rcut - rmin0); return -0.5 * sin((r - rmin0) * rcutfac) * rcutfac; diff --git a/src/SPIN/fix_nve_spin.cpp b/src/SPIN/fix_nve_spin.cpp index 6d4ff8bedd..30a18fb301 100644 --- a/src/SPIN/fix_nve_spin.cpp +++ b/src/SPIN/fix_nve_spin.cpp @@ -323,13 +323,13 @@ void FixNVESpin::initial_integrate(int /*vflag*/) } } else if (sector_flag == 0) { // serial seq. update comm->forward_comm(); // comm. positions of ghost atoms - for (int i = 0; i < nlocal; i++){ // advance quarter s for nlocal + for (int i = 0; i < nlocal; i++) { // advance quarter s for nlocal if (mask[i] & groupbit) { ComputeInteractionsSpin(i); AdvanceSingleSpin(i); } } - for (int i = nlocal-1; i >= 0; i--){ // advance quarter s for nlocal + for (int i = nlocal-1; i >= 0; i--) { // advance quarter s for nlocal if (mask[i] & groupbit) { ComputeInteractionsSpin(i); AdvanceSingleSpin(i); @@ -376,13 +376,13 @@ void FixNVESpin::initial_integrate(int /*vflag*/) } } else if (sector_flag == 0) { // serial seq. update comm->forward_comm(); // comm. positions of ghost atoms - for (int i = 0; i < nlocal; i++){ // advance quarter s for nlocal-1 + for (int i = 0; i < nlocal; i++) { // advance quarter s for nlocal-1 if (mask[i] & groupbit) { ComputeInteractionsSpin(i); AdvanceSingleSpin(i); } } - for (int i = nlocal-1; i >= 0; i--){ // advance quarter s for nlocal-1 + for (int i = nlocal-1; i >= 0; i--) { // advance quarter s for nlocal-1 if (mask[i] & groupbit) { ComputeInteractionsSpin(i); AdvanceSingleSpin(i); diff --git a/src/SPIN/min_spin_cg.cpp b/src/SPIN/min_spin_cg.cpp index 094986dc7b..de2bd5c3ae 100644 --- a/src/SPIN/min_spin_cg.cpp +++ b/src/SPIN/min_spin_cg.cpp @@ -103,7 +103,7 @@ void MinSpinCG::init() // set back use_line_search to 0 if more than one replica - if (linestyle == 3 && nreplica == 1){ + if (linestyle == 3 && nreplica == 1) { use_line_search = 1; } else{ @@ -208,7 +208,7 @@ int MinSpinCG::iterate(int maxiter) if (use_line_search) { // here we need to do line search - if (local_iter == 0){ + if (local_iter == 0) { calc_gradient(); } @@ -344,7 +344,7 @@ void MinSpinCG::calc_search_direction() factor = 0.0; - if (local_iter == 0 || local_iter % 5 == 0){ // steepest descent direction + if (local_iter == 0 || local_iter % 5 == 0) { // steepest descent direction for (int i = 0; i < 3 * nlocal; i++) { p_s[i] = -g_cur[i] * factor; g_old[i] = g_cur[i] * factor; @@ -425,12 +425,12 @@ void MinSpinCG::rodrigues_rotation(const double *upp_tr, double *out) if (fabs(upp_tr[0]) < 1.0e-40 && fabs(upp_tr[1]) < 1.0e-40 && - fabs(upp_tr[2]) < 1.0e-40){ + fabs(upp_tr[2]) < 1.0e-40) { // if upp_tr is zero, return unity matrix - for(int k = 0; k < 3; k++){ - for(int m = 0; m < 3; m++){ + for (int k = 0; k < 3; k++) { + for (int m = 0; m < 3; m++) { if (m == k) out[3 * k + m] = 1.0; else out[3 * k + m] = 0.0; } @@ -481,9 +481,9 @@ void MinSpinCG::rodrigues_rotation(const double *upp_tr, double *out) void MinSpinCG::vm3(const double *m, const double *v, double *out) { - for(int i = 0; i < 3; i++){ + for (int i = 0; i < 3; i++) { out[i] = 0.0; - for(int j = 0; j < 3; j++) out[i] += *(m + 3 * j + i) * v[j]; + for (int j = 0; j < 3; j++) out[i] += *(m + 3 * j + i) * v[j]; } } @@ -550,7 +550,7 @@ int MinSpinCG::calc_and_make_step(double a, double b, int index) der_e_cur = e_and_d[1]; index++; - if (adescent(eprevious,e_and_d[0]) || index == 5){ + if (adescent(eprevious,e_and_d[0]) || index == 5) { MPI_Bcast(&b,1,MPI_DOUBLE,0,world); for (int i = 0; i < 3 * nlocal; i++) { p_s[i] = b * p_s[i]; @@ -590,7 +590,7 @@ int MinSpinCG::calc_and_make_step(double a, double b, int index) Approximate descent ------------------------------------------------------------------------- */ -int MinSpinCG::adescent(double phi_0, double phi_j){ +int MinSpinCG::adescent(double phi_0, double phi_j) { double eps = 1.0e-6; diff --git a/src/SPIN/min_spin_lbfgs.cpp b/src/SPIN/min_spin_lbfgs.cpp index b11cdf16f3..1f8d72664d 100644 --- a/src/SPIN/min_spin_lbfgs.cpp +++ b/src/SPIN/min_spin_lbfgs.cpp @@ -108,7 +108,7 @@ void MinSpinLBFGS::init() // set back use_line_search to 0 if more than one replica - if (linestyle == 3 && nreplica == 1){ + if (linestyle == 3 && nreplica == 1) { use_line_search = 1; } else{ @@ -221,7 +221,7 @@ int MinSpinLBFGS::iterate(int maxiter) if (use_line_search) { // here we need to do line search - if (local_iter == 0){ + if (local_iter == 0) { eprevious = ecurrent; ecurrent = energy_force(0); calc_gradient(); @@ -370,7 +370,7 @@ void MinSpinLBFGS::calc_search_direction() factor = 1.0; } - if (local_iter == 0){ // steepest descent direction + if (local_iter == 0) { // steepest descent direction //if no line search then calculate maximum rotation if (use_line_search == 0) @@ -379,7 +379,7 @@ void MinSpinLBFGS::calc_search_direction() for (int i = 0; i < 3 * nlocal; i++) { p_s[i] = -g_cur[i] * factor * scaling;; g_old[i] = g_cur[i] * factor; - for (int k = 0; k < num_mem; k++){ + for (int k = 0; k < num_mem; k++) { ds[k][i] = 0.0; dy[k][i] = 0.0; } @@ -405,7 +405,7 @@ void MinSpinLBFGS::calc_search_direction() if (fabs(dyds_global) > 1.0e-60) rho[m_index] = 1.0 / dyds_global; else rho[m_index] = 1.0e60; - if (rho[m_index] < 0.0){ + if (rho[m_index] < 0.0) { local_iter = 0; return calc_search_direction(); } @@ -418,7 +418,7 @@ void MinSpinLBFGS::calc_search_direction() } // loop over last m indecies - for(int k = num_mem - 1; k > -1; k--) { + for (int k = num_mem - 1; k > -1; k--) { // this loop should run from the newest memory to the oldest one. c_ind = (k + m_index + 1) % num_mem; @@ -473,7 +473,7 @@ void MinSpinLBFGS::calc_search_direction() } } - for (int k = 0; k < num_mem; k++){ + for (int k = 0; k < num_mem; k++) { // this loop should run from the oldest memory to the newest one. if (local_iter < num_mem) c_ind = k; @@ -551,11 +551,11 @@ void MinSpinLBFGS::rodrigues_rotation(const double *upp_tr, double *out) if (fabs(upp_tr[0]) < 1.0e-40 && fabs(upp_tr[1]) < 1.0e-40 && - fabs(upp_tr[2]) < 1.0e-40){ + fabs(upp_tr[2]) < 1.0e-40) { // if upp_tr is zero, return unity matrix - for(int k = 0; k < 3; k++){ - for(int m = 0; m < 3; m++){ + for (int k = 0; k < 3; k++) { + for (int m = 0; m < 3; m++) { if (m == k) out[3 * k + m] = 1.0; else out[3 * k + m] = 0.0; } @@ -606,9 +606,9 @@ void MinSpinLBFGS::rodrigues_rotation(const double *upp_tr, double *out) void MinSpinLBFGS::vm3(const double *m, const double *v, double *out) { - for(int i = 0; i < 3; i++){ + for (int i = 0; i < 3; i++) { out[i] = 0.0; - for(int j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) out[i] += *(m + 3 * j + i) * v[j]; } } @@ -673,7 +673,7 @@ int MinSpinLBFGS::calc_and_make_step(double a, double b, int index) der_e_cur = e_and_d[1]; index++; - if (adescent(eprevious,e_and_d[0]) || index == 5){ + if (adescent(eprevious,e_and_d[0]) || index == 5) { MPI_Bcast(&b,1,MPI_DOUBLE,0,world); for (int i = 0; i < 3 * nlocal; i++) { p_s[i] = b * p_s[i]; @@ -713,7 +713,7 @@ int MinSpinLBFGS::calc_and_make_step(double a, double b, int index) Approximate descent ------------------------------------------------------------------------- */ -int MinSpinLBFGS::adescent(double phi_0, double phi_j){ +int MinSpinLBFGS::adescent(double phi_0, double phi_j) { double eps = 1.0e-6; diff --git a/src/SPIN/neb_spin.cpp b/src/SPIN/neb_spin.cpp index 2aa1b7f84d..cbb495db8e 100644 --- a/src/SPIN/neb_spin.cpp +++ b/src/SPIN/neb_spin.cpp @@ -242,7 +242,7 @@ void NEBSpin::run() timer->init(); timer->barrier_start(); - // if(ireplica != 0 && ireplica != nreplica -1) + // if (ireplica != 0 && ireplica != nreplica -1) while (update->minimize->niter < n1steps) { update->minimize->run(nevery); diff --git a/src/SRD/fix_srd.cpp b/src/SRD/fix_srd.cpp index dfccfe4c92..d8c5ef2cee 100644 --- a/src/SRD/fix_srd.cpp +++ b/src/SRD/fix_srd.cpp @@ -993,7 +993,7 @@ void FixSRD::reset_velocities() if (shifts[shiftflag].commflag) xbin_comm(shiftflag,1); if (tstat) { - for (i = 0; i < nbins; i++){ + for (i = 0; i < nbins; i++) { n = vbin[i].n; if (n <= 1) continue; @@ -1034,7 +1034,7 @@ void FixSRD::reset_velocities() if (shifts[shiftflag].commflag) xbin_comm(shiftflag,1); } - for (i = 0; i < nbins; i++){ + for (i = 0; i < nbins; i++) { if (vbin[i].owner) { if (vbin[i].n > 1) { srd_bin_temp += vbin[i].value[0]/(vbin[i].n-dof_temp); diff --git a/src/USER-ADIOS/dump_atom_adios.cpp b/src/USER-ADIOS/dump_atom_adios.cpp index e08485b0fa..5d4bbd2377 100644 --- a/src/USER-ADIOS/dump_atom_adios.cpp +++ b/src/USER-ADIOS/dump_atom_adios.cpp @@ -39,7 +39,7 @@ class DumpAtomADIOSInternal { public: - DumpAtomADIOSInternal(){}; + DumpAtomADIOSInternal() {}; ~DumpAtomADIOSInternal() = default; // name of adios group, referrable in adios2_config.xml diff --git a/src/USER-ADIOS/dump_custom_adios.cpp b/src/USER-ADIOS/dump_custom_adios.cpp index 8fbce9f847..18a3c7ef9e 100644 --- a/src/USER-ADIOS/dump_custom_adios.cpp +++ b/src/USER-ADIOS/dump_custom_adios.cpp @@ -110,7 +110,7 @@ class DumpCustomADIOSInternal { public: - DumpCustomADIOSInternal(){}; + DumpCustomADIOSInternal() {}; ~DumpCustomADIOSInternal() = default; // name of adios group, referrable in adios2_config.xml diff --git a/src/USER-ADIOS/reader_adios.cpp b/src/USER-ADIOS/reader_adios.cpp index 2acf6dedfa..5cb0cb12ea 100644 --- a/src/USER-ADIOS/reader_adios.cpp +++ b/src/USER-ADIOS/reader_adios.cpp @@ -50,7 +50,7 @@ class ReadADIOSInternal { public: - ReadADIOSInternal(){}; + ReadADIOSInternal() {}; ~ReadADIOSInternal() = default; // name of adios group, referrable in adios2_config.xml diff --git a/src/USER-ATC/fix_atc.cpp b/src/USER-ATC/fix_atc.cpp index cf7339c75d..82fbfcc958 100644 --- a/src/USER-ATC/fix_atc.cpp +++ b/src/USER-ATC/fix_atc.cpp @@ -669,7 +669,7 @@ void FixATC::unpack_forward_comm(int n, int first, double *buf) pack values in local atom-based arrays for restart file ------------------------------------------------------------------------- */ -int FixATC::pack_restart(int /* i */, double * /* buf */){ +int FixATC::pack_restart(int /* i */, double * /* buf */) { return 0; } @@ -677,14 +677,14 @@ int FixATC::pack_restart(int /* i */, double * /* buf */){ unpack values from atom->extra array to restart the fix ------------------------------------------------------------------------- */ -void FixATC::unpack_restart(int /* nlocal */, int /* nth */){ +void FixATC::unpack_restart(int /* nlocal */, int /* nth */) { } /* ---------------------------------------------------------------------- maxsize of any atom's restart data ------------------------------------------------------------------------- */ -int FixATC::maxsize_restart(){ +int FixATC::maxsize_restart() { return 0; } @@ -692,7 +692,7 @@ int FixATC::maxsize_restart(){ size of atom nlocal's restart data ------------------------------------------------------------------------- */ -int FixATC::size_restart(int /* nlocal */){ +int FixATC::size_restart(int /* nlocal */) { return 0; } @@ -700,7 +700,7 @@ int FixATC::size_restart(int /* nlocal */){ pack entire state of Fix into one write ------------------------------------------------------------------------- */ -void FixATC::write_restart(FILE * /* fp */){ +void FixATC::write_restart(FILE * /* fp */) { char ** args = new char*[2]; args[0] = new char[50]; @@ -722,7 +722,7 @@ void FixATC::write_restart(FILE * /* fp */){ use state info from restart file to restart the Fix ------------------------------------------------------------------------- */ -void FixATC::restart(char * /* buf */){ +void FixATC::restart(char * /* buf */) { char ** args = new char*[2]; args[0] = new char[50]; diff --git a/src/USER-AWPMD/fix_nve_awpmd.cpp b/src/USER-AWPMD/fix_nve_awpmd.cpp index 2b837b8905..bd2668da09 100644 --- a/src/USER-AWPMD/fix_nve_awpmd.cpp +++ b/src/USER-AWPMD/fix_nve_awpmd.cpp @@ -96,7 +96,7 @@ void FixNVEAwpmd::initial_integrate(int /* vflag */) if (mask[i] & groupbit) { double dtfm = dtf / mass[type[i]]; double dtfmr=dtfm; - for(int j=0;j<3;j++){ + for (int j=0;j<3;j++) { x[i][j] += dtv*vforce[i][j]; v[i][j] += dtfm*f[i][j]; } @@ -109,7 +109,7 @@ void FixNVEAwpmd::initial_integrate(int /* vflag */) /* ---------------------------------------------------------------------- */ -void FixNVEAwpmd::final_integrate(){} +void FixNVEAwpmd::final_integrate() {} /* ---------------------------------------------------------------------- */ diff --git a/src/USER-AWPMD/pair_awpmd_cut.cpp b/src/USER-AWPMD/pair_awpmd_cut.cpp index c714f4e8ab..19bb06ad87 100644 --- a/src/USER-AWPMD/pair_awpmd_cut.cpp +++ b/src/USER-AWPMD/pair_awpmd_cut.cpp @@ -82,21 +82,21 @@ PairAWPMDCut::~PairAWPMDCut() struct cmp_x{ double **xx; double tol; - cmp_x(double **xx_=nullptr, double tol_=1e-12):xx(xx_),tol(tol_){} + cmp_x(double **xx_=nullptr, double tol_=1e-12):xx(xx_),tol(tol_) {} bool operator()(const pair &left, const pair &right) const { - if(left.first==right.first){ + if (left.first==right.first) { double d=xx[left.second][0]-xx[right.second][0]; - if(d<-tol) + if (d<-tol) return true; - else if(d>tol) + else if (d>tol) return false; d=xx[left.second][1]-xx[right.second][1]; - if(d<-tol) + if (d<-tol) return true; - else if(d>tol) + else if (d>tol) return false; d=xx[left.second][2]-xx[right.second][2]; - if(d<-tol) + if (d<-tol) return true; else return false; @@ -139,7 +139,7 @@ void PairAWPMDCut::compute(int eflag, int vflag) // width pbc - if(width_pbc<0) + if (width_pbc<0) wpmd->Lextra=2*half_box_length; else wpmd->Lextra=width_pbc; @@ -163,7 +163,7 @@ void PairAWPMDCut::compute(int eflag, int vflag) for (int jj = 0; jj < jnum; jj++) { int j = jlist[jj]; j &= NEIGHMASK; - if(j>=nlocal){ // this is a ghost + if (j>=nlocal) { // this is a ghost Vector_3 rj=Vector_3(x[j][0],x[j][1],x[j][2]); int jtype = type[j]; double rsq=(ri-rj).norm2(); @@ -186,9 +186,9 @@ void PairAWPMDCut::compute(int eflag, int vflag) // local particles are all there idmap[make_pair(atom->tag[i],i)]=i; bool i_local= i res=idmap.insert(make_pair(make_pair(atom->tag[j],j),j)); bool have_it=!res.second; - if(have_it){ // the clone of this particle is already listed - if(res.first->second!=j) // check that was not the very same particle + if (have_it) { // the clone of this particle is already listed + if (res.first->second!=j) // check that was not the very same particle gmap[j]=-1; // filter out continue; } bool j_local= jadd_ion(q[i], Vector_3(x[i][0],x[i][1],x[i][2]),itag[i] : -atom->tag[i]); - else if(spin[i]==1 || spin[i]==-1){ // electron, sort them according to the tag + else if (spin[i]==1 || spin[i]==-1) { // electron, sort them according to the tag etmap[etag[i]].push_back(i); } else @@ -242,19 +242,19 @@ void PairAWPMDCut::compute(int eflag, int vflag) } // ion force vector Vector_3 *fi=nullptr; - if(wpmd->ni) + if (wpmd->ni) fi= new Vector_3[wpmd->ni]; // adding electrons - for(map >::iterator it=etmap.begin(); it!= etmap.end(); ++it){ + for (map >::iterator it=etmap.begin(); it!= etmap.end(); ++it) { vector &el=it->second; - if(!el.size()) // should not happen + if (!el.size()) // should not happen continue; int s=spin[el[0]] >0 ? 0 : 1; wpmd->add_electron(s); // starts adding the spits - for(size_t k=0;kall(FLERR,logfmt("WP splits for one electron should have the same spin (at particles %d, %d)!",el[0],i)); double m= atom->mass ? atom->mass[type[i]] : force->e_mass; Vector_3 xx=Vector_3(x[i][0],x[i][1],x[i][2]); @@ -275,7 +275,7 @@ void PairAWPMDCut::compute(int eflag, int vflag) // get forces from the AWPMD solver object for (int ii = 0; ii < inum; ii++) { int i = ilist[ii]; - if(gmap[i]<0) // this particle was filtered out + if (gmap[i]<0) // this particle was filtered out continue; if (spin[i]==0) { // this is an ion, copying forces int ion=gmap[i]; @@ -289,12 +289,12 @@ void PairAWPMDCut::compute(int eflag, int vflag) } } - if(fi) + if (fi) delete [] fi; // update LAMMPS energy if (eflag_either) { - if (eflag_global){ + if (eflag_global) { eng_coul+= wpmd->get_energy(); // pvector = [KE, Pauli, ecoul, radial_restraint] pvector[0] = wpmd->Ee[0]+wpmd->Ee[1]; @@ -405,7 +405,7 @@ void PairAWPMDCut::allocate() // [flex_press] -- set flexible pressure flag // -1 for length means default setting (L/2 for cutoff and L for width PBC) -void PairAWPMDCut::settings(int narg, char **arg){ +void PairAWPMDCut::settings(int narg, char **arg) { if (narg < 1) error->all(FLERR,"Illegal pair_style command"); cut_global = utils::numeric(FLERR,arg[0],false,lmp); @@ -413,46 +413,46 @@ void PairAWPMDCut::settings(int narg, char **arg){ ermscale=1.; width_pbc=0.; - for(int i=1;iapprox=AWPMD::HARTREE; - else if(!strcmp(arg[i],"dproduct")) + else if (!strcmp(arg[i],"dproduct")) wpmd->approx=AWPMD::DPRODUCT; - else if(!strcmp(arg[i],"uhf")) + else if (!strcmp(arg[i],"uhf")) wpmd->approx=AWPMD::UHF; - else if(!strcmp(arg[i],"free")) + else if (!strcmp(arg[i],"free")) wpmd->constraint=AWPMD::NONE; - else if(!strcmp(arg[i],"fix")){ + else if (!strcmp(arg[i],"fix")) { wpmd->constraint=AWPMD::FIX; i++; - if(i>=narg) + if (i>=narg) error->all(FLERR,"Setting 'fix' should be followed by a number in awpmd/cut"); wpmd->w0=utils::numeric(FLERR,arg[i],false,lmp); } - else if(!strcmp(arg[i],"harm")){ + else if (!strcmp(arg[i],"harm")) { wpmd->constraint=AWPMD::HARM; i++; - if(i>=narg) + if (i>=narg) error->all(FLERR,"Setting 'harm' should be followed by a number in awpmd/cut"); wpmd->w0=utils::numeric(FLERR,arg[i],false,lmp); wpmd->set_harm_constr(wpmd->w0); } - else if(!strcmp(arg[i],"pbc")){ + else if (!strcmp(arg[i],"pbc")) { i++; - if(i>=narg) + if (i>=narg) error->all(FLERR,"Setting 'pbc' should be followed by a number in awpmd/cut"); width_pbc=utils::numeric(FLERR,arg[i],false,lmp); } - else if(!strcmp(arg[i],"relax")) + else if (!strcmp(arg[i],"relax")) wpmd->constraint=AWPMD::RELAX; - else if(!strcmp(arg[i],"ermscale")){ + else if (!strcmp(arg[i],"ermscale")) { i++; - if(i>=narg) + if (i>=narg) error->all(FLERR,"Setting 'ermscale' should be followed by a number in awpmd/cut"); ermscale=utils::numeric(FLERR,arg[i],false,lmp); } - else if(!strcmp(arg[i],"flex_press")) + else if (!strcmp(arg[i],"flex_press")) flexible_pressure_flag = 1; } } @@ -472,7 +472,7 @@ void PairAWPMDCut::coeff(int narg, char **arg) double delz = domain->boxhi[2]-domain->boxlo[2]; half_box_length = 0.5 * MIN(delx, MIN(dely, delz)); //} - if(cut_global<0) + if (cut_global<0) cut_global=half_box_length; if (!allocated) { @@ -517,7 +517,7 @@ void PairAWPMDCut::init_style() "q, spin, eradius, erforce"); /* - if(vflag_atom){ // can't compute virial per atom + if (vflag_atom) { // can't compute virial per atom //warning-> error->all(FLERR,"Pair style awpmd can't compute per atom virials"); }*/ @@ -550,7 +550,7 @@ void PairAWPMDCut::init_style() int irequest = neighbor->request(this,instance_me); neighbor->requests[irequest]->newton = 2; - if(force->e_mass==0. || force->hhmrr2e==0. || force->mvh2r==0.) + if (force->e_mass==0. || force->hhmrr2e==0. || force->mvh2r==0.) error->all(FLERR,"Pair style awpmd requires e_mass and conversions hhmrr2e, mvh2r to be properly set for unit system"); wpmd->me=force->e_mass; @@ -685,7 +685,7 @@ void PairAWPMDCut::min_xf_get(int /* ignore */) if (spin[i]) { min_var[7*i] = log(eradius[i]); min_varforce[7*i] = eradius[i]*erforce[i]; - for(int j=0;j<3;j++){ + for (int j=0;j<3;j++) { min_var[7*i+1+3*j] = v[i][j]; min_varforce[7*i+1+3*j] = vforce[i][j]; } @@ -697,7 +697,7 @@ void PairAWPMDCut::min_xf_get(int /* ignore */) min_varforce[7*i+6] = csforce[i][1]; } else { - for(int j=0;j<7;j++) + for (int j=0;j<7;j++) min_var[7*i+j] = min_varforce[7*i+j] = 0.0; } } @@ -717,9 +717,9 @@ void PairAWPMDCut::min_x_set(int /* ignore */) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (spin[i]){ + if (spin[i]) { eradius[i]=exp(min_var[7*i]); - for(int j=0;j<3;j++) + for (int j=0;j<3;j++) v[i][j]=min_var[7*i+1+3*j]; ervel[i]=min_var[7*i+4]; cs[i][0]=min_var[7*i+5]; diff --git a/src/USER-BOCS/fix_bocs.cpp b/src/USER-BOCS/fix_bocs.cpp index b3cf98a8f5..6a984edf60 100644 --- a/src/USER-BOCS/fix_bocs.cpp +++ b/src/USER-BOCS/fix_bocs.cpp @@ -804,7 +804,7 @@ int FixBocs::build_cubic_splines(double **data) double *a, *b, *d, *h, *alpha, *c, *l, *mu, *z; // 2020-07-17 ag: // valgrind says that we read/write a[n] down in the - // for(int j=n-1; j>=0; j--) loop below + // for (int j=n-1; j>=0; j--) loop below // and I agree. // So the size of a must be n+1, not n as was found // in the original code. @@ -858,7 +858,7 @@ int FixBocs::build_cubic_splines(double **data) c[n] = 0.0; d[n] = 0.0; - for(int j=n-1; j>=0; j--) + for (int j=n-1; j>=0; j--) { c[j] = z[j] - mu[j]*c[j+1]; diff --git a/src/USER-COLVARS/group_ndx.cpp b/src/USER-COLVARS/group_ndx.cpp index c5f40c41e5..96c3663ca0 100644 --- a/src/USER-COLVARS/group_ndx.cpp +++ b/src/USER-COLVARS/group_ndx.cpp @@ -115,7 +115,7 @@ static void write_group(FILE *fp, int gid, Atom *atom, Group *group, int me, if (me == 0) { int i, j; - for(i=0, j=0; i < num; ++i) { + for (i=0, j=0; i < num; ++i) { fprintf(fp,fmt,recvlist[i]); ++j; if (j == cols) { diff --git a/src/USER-DIFFRACTION/compute_saed.cpp b/src/USER-DIFFRACTION/compute_saed.cpp index b0c52b06fc..a241d084be 100644 --- a/src/USER-DIFFRACTION/compute_saed.cpp +++ b/src/USER-DIFFRACTION/compute_saed.cpp @@ -79,11 +79,11 @@ ComputeSAED::ComputeSAED(LAMMPS *lmp, int narg, char **arg) : // Define atom types for atomic scattering factor coefficients int iarg = 4; ztype = new int[ntypes]; - for (int i = 0; i < ntypes; i++){ + for (int i = 0; i < ntypes; i++) { ztype[i] = SAEDmaxType + 1; } for (int i=0; iprd; - if (periodicity[0]){ + if (periodicity[0]) { prd_inv[0] = 1 / prd[0]; ave_inv += prd_inv[0]; } - if (periodicity[1]){ + if (periodicity[1]) { prd_inv[1] = 1 / prd[1]; ave_inv += prd_inv[1]; } - if (periodicity[2]){ + if (periodicity[2]) { prd_inv[2] = 1 / prd[2]; ave_inv += prd_inv[2]; } // Using the average inverse dimensions for non-periodic direction ave_inv = ave_inv / (periodicity[0] + periodicity[1] + periodicity[2]); - if (!periodicity[0]){ + if (!periodicity[0]) { prd_inv[0] = ave_inv; } - if (!periodicity[1]){ + if (!periodicity[1]) { prd_inv[1] = ave_inv; } - if (!periodicity[2]){ + if (!periodicity[2]) { prd_inv[2] = ave_inv; } } @@ -213,7 +213,7 @@ ComputeSAED::ComputeSAED(LAMMPS *lmp, int narg, char **arg) : double K[3]; // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ){ + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { for (int k = -Knmax[2]; k <= Knmax[2]; k++) { for (int j = -Knmax[1]; j <= Knmax[1]; j++) { for (int i = -Knmax[0]; i <= Knmax[0]; i++) { @@ -293,7 +293,7 @@ void ComputeSAED::init() int n = 0; // Zone 0 0 0 flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ){ + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { for (int k = -Knmax[2]; k <= Knmax[2]; k++) { for (int j = -Knmax[1]; j <= Knmax[1]; j++) { for (int i = -Knmax[0]; i <= Knmax[0]; i++) { @@ -452,16 +452,16 @@ void ComputeSAED::compute_vector() // Calculate the atomic structure factor by type // determining parameter set to use based on S = sin(theta)/lambda <> 2 - for (int ii = 0; ii < ntypes; ii++){ + for (int ii = 0; ii < ntypes; ii++) { f[ii] = 0; - for (int C = 0; C < 5; C++){ + for (int C = 0; C < 5; C++) { int D = C + offset; f[ii] += ASFSAED[ztype[ii]][D] * exp(-1*ASFSAED[ztype[ii]][5+D] * SinTheta_lambda * SinTheta_lambda); } } // Evaluate the structure factor equation -- looping over all atoms - for (int ii = 0; ii < nlocalgroup; ii++){ + for (int ii = 0; ii < nlocalgroup; ii++) { typei=typelocal[ii]-1; inners = 2 * MY_PI * (K[0] * xlocal[3*ii+0] + K[1] * xlocal[3*ii+1] + K[2] * xlocal[3*ii+2]); diff --git a/src/USER-DIFFRACTION/compute_xrd.cpp b/src/USER-DIFFRACTION/compute_xrd.cpp index c168b032ca..3d3bc17c74 100644 --- a/src/USER-DIFFRACTION/compute_xrd.cpp +++ b/src/USER-DIFFRACTION/compute_xrd.cpp @@ -80,11 +80,11 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) : // Define atom types for atomic scattering factor coefficients int iarg = 4; ztype = new int[ntypes]; - for (int i = 0; i < ntypes; i++){ + for (int i = 0; i < ntypes; i++) { ztype[i] = XRDmaxType + 1; } for (int i = 0; i < ntypes; i++) { - for(int j = 0; j < XRDmaxType; j++){ + for (int j = 0; j < XRDmaxType; j++) { if (strcasecmp(arg[iarg],XRDtypeList[j]) == 0) { ztype[i] = j; } @@ -109,7 +109,7 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) : if (iarg+3 > narg) error->all(FLERR,"Illegal Compute XRD Command"); Min2Theta = atof(arg[iarg+1]) / 2; Max2Theta = atof(arg[iarg+2]) / 2; - if (Max2Theta > MY_PI ){ + if (Max2Theta > MY_PI ) { Min2Theta = Min2Theta * MY_PI / 180; // converting to radians if necessary Max2Theta = Max2Theta * MY_PI / 180; radflag = 0; @@ -162,28 +162,28 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) : double ave_inv = 0.0; prd = domain->prd; - if (periodicity[0]){ + if (periodicity[0]) { prd_inv[0] = 1 / prd[0]; ave_inv += prd_inv[0]; } - if (periodicity[1]){ + if (periodicity[1]) { prd_inv[1] = 1 / prd[1]; ave_inv += prd_inv[1]; } - if (periodicity[2]){ + if (periodicity[2]) { prd_inv[2] = 1 / prd[2]; ave_inv += prd_inv[2]; } // Using the average inverse dimensions for non-periodic direction ave_inv = ave_inv / (periodicity[0] + periodicity[1] + periodicity[2]); - if (!periodicity[0]){ + if (!periodicity[0]) { prd_inv[0] = ave_inv; } - if (!periodicity[1]){ + if (!periodicity[1]) { prd_inv[1] = ave_inv; } - if (!periodicity[2]){ + if (!periodicity[2]) { prd_inv[2] = ave_inv; } } @@ -261,7 +261,7 @@ void ComputeXRD::init() double ang = 0.0; double convf = 360 / MY_PI; - if (radflag ==1){ + if (radflag ==1) { convf = 1; } @@ -400,16 +400,16 @@ void ComputeXRD::compute_array() Fatom2 = 0.0; // Calculate the atomic structure factor by type - for (int ii = 0; ii < ntypes; ii++){ + for (int ii = 0; ii < ntypes; ii++) { f[ii] = 0; - for (int C = 0; C < 8 ; C+=2){ + for (int C = 0; C < 8 ; C+=2) { f[ii] += ASFXRD[ztype[ii]][C] * exp(-1 * ASFXRD[ztype[ii]][C+1] * SinTheta_lambda * SinTheta_lambda ); } f[ii] += ASFXRD[ztype[ii]][8]; } // Evaluate the structure factor equation -- looping over all atoms - for (int ii = 0; ii < nlocalgroup; ii++){ + for (int ii = 0; ii < nlocalgroup; ii++) { typei=typelocal[ii]-1; inners = 2 * MY_PI * (K[0] * xlocal[3*ii] + K[1] * xlocal[3*ii+1] + K[2] * xlocal[3*ii+2]); @@ -456,16 +456,16 @@ void ComputeXRD::compute_array() Fatom2 = 0.0; // Calculate the atomic structure factor by type - for (int ii = 0; ii < ntypes; ii++){ + for (int ii = 0; ii < ntypes; ii++) { f[ii] = 0; - for (int C = 0; C < 8 ; C+=2){ + for (int C = 0; C < 8 ; C+=2) { f[ii] += ASFXRD[ztype[ii]][C] * exp(-1 * ASFXRD[ztype[ii]][C+1] * SinTheta_lambda * SinTheta_lambda ); } f[ii] += ASFXRD[ztype[ii]][8]; } // Evaluate the structure factor equation -- looping over all atoms - for (int ii = 0; ii < nlocalgroup; ii++){ + for (int ii = 0; ii < nlocalgroup; ii++) { typei=typelocal[ii]-1; inners = 2 * MY_PI * (K[0] * xlocal[3*ii] + K[1] * xlocal[3*ii+1] + K[2] * xlocal[3*ii+2]); diff --git a/src/USER-DIFFRACTION/fix_saed_vtk.cpp b/src/USER-DIFFRACTION/fix_saed_vtk.cpp index e5480bfd33..0791b25aaa 100644 --- a/src/USER-DIFFRACTION/fix_saed_vtk.cpp +++ b/src/USER-DIFFRACTION/fix_saed_vtk.cpp @@ -56,7 +56,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : nvalues = 0; int iarg = 6; while (iarg < narg) { - if (strncmp(arg[iarg],"c_",2) == 0){ + if (strncmp(arg[iarg],"c_",2) == 0) { nvalues++; iarg++; } else break; @@ -153,7 +153,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : // SAED specific paramaters needed int *periodicity = domain->periodicity; // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ){ + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { } else { R_Ewald = (1 / lambda); double Rnorm = R_Ewald/ sqrt(Zone[0] * Zone[0] + @@ -167,28 +167,28 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : double ave_inv = 0.0; prd = domain->prd; - if (periodicity[0]){ + if (periodicity[0]) { prd_inv[0] = 1 / prd[0]; ave_inv += prd_inv[0]; } - if (periodicity[1]){ + if (periodicity[1]) { prd_inv[1] = 1 / prd[1]; ave_inv += prd_inv[1]; } - if (periodicity[2]){ + if (periodicity[2]) { prd_inv[2] = 1 / prd[2]; ave_inv += prd_inv[2]; } // Using the average inverse dimensions for non-periodic direction ave_inv = ave_inv / (periodicity[0] + periodicity[1] + periodicity[2]); - if (!periodicity[0]){ + if (!periodicity[0]) { prd_inv[0] = ave_inv; } - if (!periodicity[1]){ + if (!periodicity[1]) { prd_inv[1] = ave_inv; } - if (!periodicity[2]){ + if (!periodicity[2]) { prd_inv[2] = ave_inv; } @@ -200,7 +200,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : } // Find integer dimensions of the reciprocal lattice box bounds - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ){ + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { for (int i=0; i<3; i++) { dK[i] = prd_inv[i]*c[i]; Knmax[i] = ceil(Kmax / dK[i]); @@ -233,7 +233,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : r=0.0; for (int m=0; m<3; m++) r += pow(K[m] - Zone[m],2.0); r = sqrt(r); - if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) ) ){ + if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) ) ) { if ( i < Knmin[0] ) Knmin[0] = i; if ( j < Knmin[1] ) Knmin[1] = j; @@ -251,7 +251,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : // Finding dimensions for vtk files for (int i=0; i<3; i++) { - if ( ( (Knmin[i] > 0) && (Knmax[i] > 0) ) || ( (Knmin[i] < 0) && (Knmax[i] < 0) ) ){ + if ( ( (Knmin[i] > 0) && (Knmax[i] > 0) ) || ( (Knmin[i] < 0) && (Knmax[i] < 0) ) ) { Dim[i] = abs( (int) Knmin[i] ) + abs( (int) Knmax[i] ); } else Dim[i] = abs( (int) Knmin[i] ) + abs( (int) Knmax[i] ) + 1; } @@ -452,7 +452,7 @@ void FixSAEDVTK::invoke_vector(bigint ntimestep) double K[3]; // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ){ + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { for (int k = Knmin[2]; k <= Knmax[2]; k++) { for (int j = Knmin[1]; j <= Knmax[1]; j++) { for (int i = Knmin[0]; i <= Knmax[0]; i++) { @@ -485,7 +485,7 @@ void FixSAEDVTK::invoke_vector(bigint ntimestep) r=0.0; for (int m=0; m<3; m++) r += pow(K[m] - Zone[m],2.0); r = sqrt(r); - if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) ) ){ + if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) ) ) { fprintf(fp,"%g\n",vector_total[NROW1]/norm); fflush(fp); NROW2++; diff --git a/src/USER-DPD/compute_dpd.cpp b/src/USER-DPD/compute_dpd.cpp index e92be891f1..437d4c9bc6 100644 --- a/src/USER-DPD/compute_dpd.cpp +++ b/src/USER-DPD/compute_dpd.cpp @@ -66,8 +66,8 @@ void ComputeDpd::compute_vector() for (int i = 0; i < size_vector; i++) dpdU[i] = 0.0; - for (int i = 0; i < nlocal; i++){ - if (mask[i] & groupbit){ + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { dpdU[0] += uCond[i]; dpdU[1] += uMech[i]; dpdU[2] += uChem[i]; diff --git a/src/USER-DPD/compute_dpd_atom.cpp b/src/USER-DPD/compute_dpd_atom.cpp index ae6b6217a3..8b203b4c0b 100644 --- a/src/USER-DPD/compute_dpd_atom.cpp +++ b/src/USER-DPD/compute_dpd_atom.cpp @@ -81,8 +81,8 @@ void ComputeDpdAtom::compute_peratom() array_atom = dpdAtom; } - for (int i = 0; i < nlocal; i++){ - if (mask[i] & groupbit){ + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { dpdAtom[i][0] = uCond[i]; dpdAtom[i][1] = uMech[i]; dpdAtom[i][2] = uChem[i]; diff --git a/src/USER-DPD/fix_dpd_energy.cpp b/src/USER-DPD/fix_dpd_energy.cpp index 9bbd9f59d8..dae250203d 100644 --- a/src/USER-DPD/fix_dpd_energy.cpp +++ b/src/USER-DPD/fix_dpd_energy.cpp @@ -63,7 +63,7 @@ void FixDPDenergy::initial_integrate(int /*vflag*/) double *duCond = pairDPDE->duCond; double *duMech = pairDPDE->duMech; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { uCond[i] += 0.5*update->dt*duCond[i]; uMech[i] += 0.5*update->dt*duMech[i]; } @@ -81,7 +81,7 @@ void FixDPDenergy::final_integrate() double *duCond = pairDPDE->duCond; double *duMech = pairDPDE->duMech; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { uCond[i] += 0.5*update->dt*duCond[i]; uMech[i] += 0.5*update->dt*duMech[i]; } diff --git a/src/USER-DPD/fix_eos_cv.cpp b/src/USER-DPD/fix_eos_cv.cpp index dabcfec46a..1bcdb9dbc6 100644 --- a/src/USER-DPD/fix_eos_cv.cpp +++ b/src/USER-DPD/fix_eos_cv.cpp @@ -30,7 +30,7 @@ FixEOScv::FixEOScv(LAMMPS *lmp, int narg, char **arg) : { if (narg != 4) error->all(FLERR,"Illegal fix eos/cv command"); cvEOS = utils::numeric(FLERR,arg[3],false,lmp); - if(cvEOS <= 0.0) error->all(FLERR,"EOS cv must be > 0.0"); + if (cvEOS <= 0.0) error->all(FLERR,"EOS cv must be > 0.0"); nevery = 1; @@ -58,14 +58,14 @@ void FixEOScv::init() double *uMech = atom->uMech; double *dpdTheta = atom->dpdTheta; - if(this->restart_reset){ + if (this->restart_reset) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) dpdTheta[i] = (uCond[i]+uMech[i])/cvEOS; } else { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); uCond[i] = 0.0; uMech[i] = cvEOS*dpdTheta[i]; @@ -84,9 +84,9 @@ void FixEOScv::post_integrate() double *dpdTheta = atom->dpdTheta; for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { dpdTheta[i] = (uCond[i]+uMech[i])/cvEOS; - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); } } @@ -102,9 +102,9 @@ void FixEOScv::end_of_step() double *dpdTheta = atom->dpdTheta; for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { dpdTheta[i] = (uCond[i]+uMech[i])/cvEOS; - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); } } diff --git a/src/USER-DPD/fix_eos_table.cpp b/src/USER-DPD/fix_eos_table.cpp index b827c1e42f..0d23f32b4e 100644 --- a/src/USER-DPD/fix_eos_table.cpp +++ b/src/USER-DPD/fix_eos_table.cpp @@ -111,14 +111,14 @@ void FixEOStable::init() double *dpdTheta = atom->dpdTheta; double tmp; - if(this->restart_reset){ + if (this->restart_reset) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) temperature_lookup(uCond[i]+uMech[i],dpdTheta[i]); } else { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); energy_lookup(dpdTheta[i],tmp); uCond[i] = 0.0; @@ -138,9 +138,9 @@ void FixEOStable::post_integrate() double *dpdTheta = atom->dpdTheta; for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { temperature_lookup(uCond[i]+uMech[i],dpdTheta[i]); - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); } } @@ -156,9 +156,9 @@ void FixEOStable::end_of_step() double *dpdTheta = atom->dpdTheta; for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { temperature_lookup(uCond[i]+uMech[i],dpdTheta[i]); - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); } } @@ -406,7 +406,7 @@ void FixEOStable::energy_lookup(double t, double &u) double fraction; Table *tb = &tables[0]; - if(t < tb->lo || t > tb->hi){ + if (t < tb->lo || t > tb->hi) { printf("Temperature=%lf TableMin=%lf TableMax=%lf\n",t,tb->lo,tb->hi); error->one(FLERR,"Temperature is not within table cutoffs"); } @@ -428,7 +428,7 @@ void FixEOStable::temperature_lookup(double u, double &t) double fraction; Table *tb = &tables[1]; - if(u < tb->lo || u > tb->hi){ + if (u < tb->lo || u > tb->hi) { printf("Energy=%lf TableMin=%lf TableMax=%lf\n",u,tb->lo,tb->hi); error->one(FLERR,"Energy is not within table cutoffs"); } diff --git a/src/USER-DPD/fix_eos_table_rx.cpp b/src/USER-DPD/fix_eos_table_rx.cpp index 6193effe62..28cd4eb4c3 100644 --- a/src/USER-DPD/fix_eos_table_rx.cpp +++ b/src/USER-DPD/fix_eos_table_rx.cpp @@ -54,7 +54,7 @@ FixEOStableRX::FixEOStableRX(LAMMPS *lmp, int narg, char **arg) : if (utils::strmatch(modify->fix[i]->style,"^rx")) { rx_flag = true; nspecies = atom->nspecies_dpd; - if(nspecies==0) error->all(FLERR,"There are no rx species specified."); + if (nspecies==0) error->all(FLERR,"There are no rx species specified."); } if (strcmp(arg[3],"linear") == 0) tabstyle = LINEAR; @@ -70,7 +70,7 @@ FixEOStableRX::FixEOStableRX(LAMMPS *lmp, int narg, char **arg) : int me; MPI_Comm_rank(world,&me); - for (int ii=0;iisrealloc(tables,(ntables+1)*sizeof(Table),"eos:table/rx"); tables2 = (Table *) @@ -91,7 +91,7 @@ FixEOStableRX::FixEOStableRX(LAMMPS *lmp, int narg, char **arg) : if (me == 0) read_table(tb,tb2,arg[4],arg[6]); - for (int ii=0;iiuCG; double *uCGnew = atom->uCGnew; - if(!this->restart_reset){ + if (!this->restart_reset) { for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { duChem = uCG[i] - uCGnew[i]; uChem[i] += duChem; uCG[i] = 0.0; @@ -222,14 +222,14 @@ void FixEOStableRX::init() double *dpdTheta = atom->dpdTheta; double tmp; - if(this->restart_reset){ + if (this->restart_reset) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) temperature_lookup(i,uCond[i]+uMech[i]+uChem[i],dpdTheta[i]); } else { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); energy_lookup(i,dpdTheta[i],tmp); uCond[i] = 0.0; @@ -252,9 +252,9 @@ void FixEOStableRX::post_integrate() double *dpdTheta = atom->dpdTheta; for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { temperature_lookup(i,uCond[i]+uMech[i]+uChem[i],dpdTheta[i]); - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); } } @@ -277,7 +277,7 @@ void FixEOStableRX::end_of_step() comm->reverse_comm_fix(this); for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { duChem = uCG[i] - uCGnew[i]; uChem[i] += duChem; uCG[i] = 0.0; @@ -288,9 +288,9 @@ void FixEOStableRX::end_of_step() comm->forward_comm_fix(this); for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { temperature_lookup(i,uCond[i]+uMech[i]+uChem[i],dpdTheta[i]); - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); } } @@ -371,9 +371,9 @@ void FixEOStableRX::read_file(char *file) for (ispecies = 0; ispecies < nspecies; ispecies++) if (strcmp(words[0],&atom->dname[ispecies][0]) == 0) break; - if (ispecies < nspecies){ + if (ispecies < nspecies) { dHf[ispecies] = atof(words[1]); - if(nwords > min_params_per_line+1){ + if (nwords > min_params_per_line+1) { energyCorr[ispecies] = atof(words[2]); tempCorrCoeff[ispecies] = atof(words[3]); moleculeCorrCoeff[ispecies] = atof(words[4]); @@ -451,7 +451,7 @@ void FixEOStableRX::read_table(Table *tb, Table *tb2, char *file, char *keyword) memory->create(tb2->rfile,tb2->ninput,"eos:rfile"); memory->create(tb2->efile,tb2->ninput,"eos:efile"); - for (int ispecies=1;ispeciesninput = tb->ninput; @@ -476,7 +476,7 @@ void FixEOStableRX::read_table(Table *tb, Table *tb2, char *file, char *keyword) utils::sfgets(FLERR,line,MAXLINE,fp,file,error); nwords = utils::count_words(utils::trim_comment(line)); - if(nwords != nspecies+2){ + if (nwords != nspecies+2) { printf("nwords=%d nspecies=%d\n",nwords,nspecies); error->all(FLERR,"Illegal fix eos/table/rx command"); } @@ -485,7 +485,7 @@ void FixEOStableRX::read_table(Table *tb, Table *tb2, char *file, char *keyword) word = strtok(nullptr," \t\n\r\f"); rtmp = atof(word); - for (int icolumn=0;icolumnone(FLERR,"Invalid keyword in fix eos/table/rx parameters"); word = strtok(nullptr," \t\n\r\f"); - if(rx_flag){ + if (rx_flag) { while (word) { for (ispecies = 0; ispecies < nspecies; ispecies++) - if (strcmp(word,&atom->dname[ispecies][0]) == 0){ + if (strcmp(word,&atom->dname[ispecies][0]) == 0) { eosSpecies[ncolumn] = ispecies; ncolumn++; break; } - if (ispecies == nspecies){ + if (ispecies == nspecies) { printf("name=%s not found in species list\n",word); error->one(FLERR,"Invalid keyword in fix eos/table/rx parameters"); } @@ -596,9 +596,9 @@ void FixEOStableRX::param_extract(Table *tb, char *line) } for (int icolumn = 0; icolumn < ncolumn; icolumn++) - if(eosSpecies[icolumn]==-1) + if (eosSpecies[icolumn]==-1) error->one(FLERR,"EOS data is missing from fix eos/table/rx tabe"); - if(ncolumn != nspecies){ + if (ncolumn != nspecies) { printf("ncolumns=%d nspecies=%d\n",ncolumn,nspecies); error->one(FLERR,"The number of columns in fix eos/table/rx does not match the number of species"); } @@ -703,10 +703,10 @@ void FixEOStableRX::energy_lookup(int id, double thetai, double &ui) nTotalPG = 0.0; nPG = 0; - if(rx_flag){ - for(int ispecies=0;ispeciesdvector[ispecies][id]; - if(fabs(moleculeCorrCoeff[ispecies]) > tolerance){ + if (fabs(moleculeCorrCoeff[ispecies]) > tolerance) { nPG++; nTotalPG += atom->dvector[ispecies][id]; } @@ -715,7 +715,7 @@ void FixEOStableRX::energy_lookup(int id, double thetai, double &ui) nTotal = 1.0; } - for(int ispecies=0;ispecieslo); thetai = MIN(thetai,tb->hi); @@ -728,9 +728,9 @@ void FixEOStableRX::energy_lookup(int id, double thetai, double &ui) uTmp += dHf[ispecies]; uTmp += tempCorrCoeff[ispecies]*thetai; // temperature correction uTmp += energyCorr[ispecies]; // energy correction - if(nPG > 0) ui += moleculeCorrCoeff[ispecies]*nTotalPG/double(nPG); // molecule correction + if (nPG > 0) ui += moleculeCorrCoeff[ispecies]*nTotalPG/double(nPG); // molecule correction - if(rx_flag) nMolecules = atom->dvector[ispecies][id]; + if (rx_flag) nMolecules = atom->dvector[ispecies][id]; else nMolecules = 1.0; ui += nMolecules*uTmp; } @@ -756,7 +756,7 @@ void FixEOStableRX::temperature_lookup(int id, double ui, double &thetai) // Store the current thetai in t1 t1 = MAX(thetai,tb->lo); t1 = MIN(t1,tb->hi); - if(t1==tb->hi) delta = -delta; + if (t1==tb->hi) delta = -delta; // Compute u1 at thetai energy_lookup(id,t1,u1); @@ -774,9 +774,9 @@ void FixEOStableRX::temperature_lookup(int id, double ui, double &thetai) f2 = u2 - ui; // Apply the Secant Method - for(it=0; itone(FLERR,"NaN detected in secant solver."); + for (it=0; itone(FLERR,"NaN detected in secant solver."); temp = t1; temp = MAX(temp,tb->lo); temp = MIN(temp,tb->hi); @@ -786,17 +786,17 @@ void FixEOStableRX::temperature_lookup(int id, double ui, double &thetai) break; } temp = t2 - f2*(t2-t1)/(f2-f1); - if(fabs(temp-t2) < tolerance) break; + if (fabs(temp-t2) < tolerance) break; f1 = f2; t1 = t2; t2 = temp; energy_lookup(id,t2,u2); f2 = u2 - ui; } - if(it==maxit){ + if (it==maxit) { char str[256]; sprintf(str,"Maxit exceeded in secant solver: id=%d ui=%lf thetai=%lf t1=%lf t2=%lf f1=%lf f2=%lf\n",id,ui,thetai,t1,t2,f1,f2); - if(std::isnan(f1) || std::isnan(f2) || std::isnan(ui) || std::isnan(thetai) || std::isnan(t1) || std::isnan(t2)) + if (std::isnan(f1) || std::isnan(f2) || std::isnan(ui) || std::isnan(thetai) || std::isnan(t1) || std::isnan(t2)) error->one(FLERR,"NaN detected in secant solver."); error->one(FLERR,str); } @@ -833,7 +833,7 @@ void FixEOStableRX::unpack_forward_comm(int n, int first, double *buf) m = 0; last = first + n ; - for (ii = first; ii < last; ii++){ + for (ii = first; ii < last; ii++) { uChem[ii] = buf[m++]; uCG[ii] = buf[m++]; uCGnew[ii] = buf[m++]; diff --git a/src/USER-DPD/fix_rx.cpp b/src/USER-DPD/fix_rx.cpp index 4f7edfe14a..ad3bf7c30c 100644 --- a/src/USER-DPD/fix_rx.cpp +++ b/src/USER-DPD/fix_rx.cpp @@ -99,11 +99,11 @@ FixRX::FixRX(LAMMPS *lmp, int narg, char **arg) : { char *word = arg[iarg++]; - if (strcmp(word,"none") == 0){ + if (strcmp(word,"none") == 0) { wtFlag = 0; localTempFlag = NONE; } - else if (strcmp(word,"lucy") == 0){ + else if (strcmp(word,"lucy") == 0) { wtFlag = LUCY; localTempFlag = HARMONIC; } @@ -127,7 +127,7 @@ FixRX::FixRX(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR, errmsg); } - if (comm->me == 0 and Verbosity > 1){ + if (comm->me == 0 and Verbosity > 1) { std::string msg = "FixRX: matrix format is "; if (useSparseKinetics) msg += std::string("sparse"); @@ -164,25 +164,25 @@ FixRX::FixRX(LAMMPS *lmp, int narg, char **arg) : absTol = 1.0e-8; diagnosticFrequency = 0; - for (int i = 0; i < numDiagnosticCounters; ++i){ + for (int i = 0; i < numDiagnosticCounters; ++i) { diagnosticCounter[i] = 0; diagnosticCounterPerODE[i] = nullptr; } - if (odeIntegrationFlag == ODE_LAMMPS_RK4 && narg==8){ + if (odeIntegrationFlag == ODE_LAMMPS_RK4 && narg==8) { char *word = arg[iarg++]; minSteps = atoi( word ); - if (comm->me == 0 and Verbosity > 1){ + if (comm->me == 0 and Verbosity > 1) { char msg[128]; sprintf(msg, "FixRX: RK4 numSteps= %d", minSteps); error->message(FLERR, msg); } } - else if (odeIntegrationFlag == ODE_LAMMPS_RK4 && narg>8){ + else if (odeIntegrationFlag == ODE_LAMMPS_RK4 && narg>8) { error->all(FLERR,"Illegal fix rx command. Too many arguments for RK4 solver."); } - else if (odeIntegrationFlag == ODE_LAMMPS_RKF45){ + else if (odeIntegrationFlag == ODE_LAMMPS_RKF45) { // Must have four options. if (narg < 11) error->all(FLERR,"Illegal fix rx command. Too few arguments for RKF45 solver."); @@ -198,7 +198,7 @@ FixRX::FixRX(LAMMPS *lmp, int narg, char **arg) : // maxIters must be at least minSteps. maxIters = std::max( minSteps, maxIters ); - if (comm->me == 0 and Verbosity > 1){ + if (comm->me == 0 and Verbosity > 1) { //printf("FixRX: RKF45 minSteps= %d maxIters= %d absTol= %e relTol= %e\n", minSteps, maxIters, absTol, relTol); char msg[128]; sprintf(msg, "FixRX: RKF45 minSteps= %d maxIters= %d relTol= %.1e absTol= %.1e diagnosticFrequency= %d", minSteps, maxIters, relTol, absTol, diagnosticFrequency); @@ -224,7 +224,7 @@ FixRX::~FixRX() if (copymode) return; // De-Allocate memory to prevent memory leak - for (int ii = 0; ii < nreactions; ii++){ + for (int ii = 0; ii < nreactions; ii++) { delete [] stoich[ii]; delete [] stoichReactants[ii]; delete [] stoichProducts[ii]; @@ -240,7 +240,7 @@ FixRX::~FixRX() delete [] id_fix_species; delete [] id_fix_species_old; - if (useSparseKinetics){ + if (useSparseKinetics) { memory->destroy( sparseKinetics_nu ); memory->destroy( sparseKinetics_nuk ); memory->destroy( sparseKinetics_inu ); @@ -258,7 +258,7 @@ void FixRX::post_constructor() char **tmpspecies = new char*[maxspecies]; int tmpmaxstrlen = 0; - for(int jj=0; jj < maxspecies; jj++) + for (int jj=0; jj < maxspecies; jj++) tmpspecies[jj] = nullptr; // open file on proc 0 @@ -304,17 +304,17 @@ void FixRX::post_constructor() nwords = 0; word = strtok(line," \t\n\r\f"); - while (word != nullptr){ + while (word != nullptr) { word = strtok(nullptr, " \t\n\r\f"); match=false; - for(int jj=0;jj=maxspecies) + if (!match) { + if (nUniqueSpecies+1>=maxspecies) error->all(FLERR,"Exceeded the maximum number of species permitted in fix rx."); tmpspecies[nUniqueSpecies] = new char[strlen(word)+1]; strcpy(tmpspecies[nUniqueSpecies],word); @@ -322,7 +322,7 @@ void FixRX::post_constructor() nUniqueSpecies++; } word = strtok(nullptr, " \t\n\r\f"); - if(strcmp(word,"+") != 0 && strcmp(word,"=") != 0) break; + if (strcmp(word,"+") != 0 && strcmp(word,"=") != 0) break; word = strtok(nullptr, " \t\n\r\f"); } } @@ -355,7 +355,7 @@ void FixRX::post_constructor() newarg2[2] = (char *) "property/atom"; char *str1 = new char[tmpmaxstrlen+3]; char *str2 = new char[tmpmaxstrlen+6]; - for(int ii=0; iiadd_fix(nspecies+5,newarg2,1); fix_species_old = (FixPropertyAtom *) modify->fix[modify->nfix-1]; - if(nspecies==0) error->all(FLERR,"There are no rx species specified."); + if (nspecies==0) error->all(FLERR,"There are no rx species specified."); - for(int jj=0;jjme == 0 and Verbosity > 1){ + if (comm->me == 0 and Verbosity > 1) { for (int k = 0; k < nspecies; ++k) printf("atom->dname[%d]= %s\n", k, atom->dname[k]); printf("stoich[][]\n"); - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { int nreac_i = 0, nprod_i = 0; printf("%d: ", i); - for (int k = 0; k < nspecies; ++k){ + for (int k = 0; k < nspecies; ++k) { printf(" %g", stoich[i][k]); if (stoich[i][k] < 0.0) nreac_i++; else if (stoich[i][k] > 0.0) nprod_i++; @@ -425,10 +425,10 @@ void FixRX::initSparse() } printf("stoichReactants[][]\n"); - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { int nreac_i = 0; printf("%d: ", i); - for (int k = 0; k < nspecies; ++k){ + for (int k = 0; k < nspecies; ++k) { printf(" %g", stoichReactants[i][k]); if (stoichReactants[i][k] > 0.0) nreac_i++; } @@ -436,10 +436,10 @@ void FixRX::initSparse() } printf("stoichProducts[][]\n"); - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { int nprod_i = 0; printf("%d: ", i); - for (int k = 0; k < nspecies; ++k){ + for (int k = 0; k < nspecies; ++k) { printf(" %g", stoichProducts[i][k]); if (stoichProducts[i][k] > 0.0) nprod_i++; } @@ -453,15 +453,15 @@ void FixRX::initSparse() int mxreac = 0; int mxspec = 0; int nIntegral = 0; - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { int nreac_i = 0, nprod_i = 0; std::string pstr, rstr; bool allAreIntegral = true; - for (int k = 0; k < nspecies; ++k){ + for (int k = 0; k < nspecies; ++k) { if (stoichReactants[i][k] == 0 and stoichProducts[i][k] == 0) nzeros++; - if (stoichReactants[i][k] > 0.0){ + if (stoichReactants[i][k] > 0.0) { allAreIntegral &= (std::fmod( stoichReactants[i][k], 1.0 ) == 0.0); nreac_i++; @@ -472,7 +472,7 @@ void FixRX::initSparse() sprintf(digit, "%4.1f ", stoichReactants[i][k]); rstr += digit; rstr += atom->dname[k]; } - if (stoichProducts[i][k] > 0.0){ + if (stoichProducts[i][k] > 0.0) { allAreIntegral &= (std::fmod( stoichProducts[i][k], 1.0 ) == 0.0); nprod_i++; @@ -494,7 +494,7 @@ void FixRX::initSparse() if (allAreIntegral) nIntegral++; } - if (comm->me == 0 and Verbosity > 1){ + if (comm->me == 0 and Verbosity > 1) { char msg[256]; sprintf(msg, "FixRX: Sparsity of Stoichiometric Matrix= %.1f%% non-zeros= %d nspecies= %d nreactions= %d maxReactants= %d maxProducts= %d maxSpecies= %d integralReactions= %d", 100*(double(nzeros) / (nspecies * nreactions)), nzeros, nspecies, nreactions, mxreac, mxprod, (mxreac + mxprod), SparseKinetics_enableIntegralReactions); error->message(FLERR, msg); @@ -510,16 +510,16 @@ void FixRX::initSparse() memory->create( sparseKinetics_nuk, nreactions, sparseKinetics_maxSpecies, "sparseKinetics_nuk"); for (int i = 0; i < nreactions; ++i) - for (int k = 0; k < sparseKinetics_maxSpecies; ++k){ + for (int k = 0; k < sparseKinetics_maxSpecies; ++k) { sparseKinetics_nu [i][k] = 0.0; sparseKinetics_nuk[i][k] = SparseKinetics_invalidIndex; // Initialize with an invalid index. } - if (SparseKinetics_enableIntegralReactions){ + if (SparseKinetics_enableIntegralReactions) { memory->create( sparseKinetics_inu, nreactions, sparseKinetics_maxSpecies, "sparseKinetics_inu"); memory->create( sparseKinetics_isIntegralReaction, nreactions, "sparseKinetics_isIntegralReaction"); - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { sparseKinetics_isIntegralReaction[i] = false; for (int k = 0; k < sparseKinetics_maxSpecies; ++k) sparseKinetics_inu[i][k] = 0; @@ -530,19 +530,19 @@ void FixRX::initSparse() // Measure the distribution of the # of moles for the ::fastpowi function. std::vector nu_bin(10); - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { int nreac_i = 0, nprod_i = 0; bool isIntegral_i = true; - for (int k = 0; k < nspecies; ++k){ - if (stoichReactants[i][k] > 0.0){ + for (int k = 0; k < nspecies; ++k) { + if (stoichReactants[i][k] > 0.0) { const int idx = nreac_i; sparseKinetics_nu [i][idx] = stoichReactants[i][k]; sparseKinetics_nuk[i][idx] = k; isIntegral_i &= (std::fmod( stoichReactants[i][k], 1.0 ) == 0.0); - if (SparseKinetics_enableIntegralReactions){ + if (SparseKinetics_enableIntegralReactions) { sparseKinetics_inu[i][idx] = (int)sparseKinetics_nu[i][idx]; - if (isIntegral_i){ + if (isIntegral_i) { if (sparseKinetics_inu[i][idx] >= (int)nu_bin.size()) nu_bin.resize( sparseKinetics_inu[i][idx] ); @@ -552,15 +552,15 @@ void FixRX::initSparse() nreac_i++; } - if (stoichProducts[i][k] > 0.0){ + if (stoichProducts[i][k] > 0.0) { const int idx = sparseKinetics_maxReactants + nprod_i; sparseKinetics_nu [i][idx] = stoichProducts[i][k]; sparseKinetics_nuk[i][idx] = k; isIntegral_i &= (std::fmod( sparseKinetics_nu[i][idx], 1.0 ) == 0.0); - if (SparseKinetics_enableIntegralReactions){ + if (SparseKinetics_enableIntegralReactions) { sparseKinetics_inu[i][idx] = (int) sparseKinetics_nu[i][idx]; - if (isIntegral_i){ + if (isIntegral_i) { if (sparseKinetics_inu[i][idx] >= (int)nu_bin.size()) nu_bin.resize( sparseKinetics_inu[i][idx] ); @@ -576,17 +576,17 @@ void FixRX::initSparse() sparseKinetics_isIntegralReaction[i] = isIntegral_i; } - if (comm->me == 0 and Verbosity > 1){ + if (comm->me == 0 and Verbosity > 1) { for (int i = 1; i < nu_bin.size(); ++i) if (nu_bin[i] > 0) printf("nu_bin[%d] = %d\n", i, nu_bin[i]); - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { std::string pstr, rstr; - for (int kk = 0; kk < sparseKinetics_maxReactants; kk++){ + for (int kk = 0; kk < sparseKinetics_maxReactants; kk++) { const int k = sparseKinetics_nuk[i][kk]; - if (k != SparseKinetics_invalidIndex){ + if (k != SparseKinetics_invalidIndex) { if (rstr.length() > 0) rstr += " + "; @@ -600,9 +600,9 @@ void FixRX::initSparse() } } - for (int kk = sparseKinetics_maxReactants; kk < sparseKinetics_maxSpecies; kk++){ + for (int kk = sparseKinetics_maxReactants; kk < sparseKinetics_maxSpecies; kk++) { const int k = sparseKinetics_nuk[i][kk]; - if (k != SparseKinetics_invalidIndex){ + if (k != SparseKinetics_invalidIndex) { if (pstr.length() > 0) pstr += " + "; @@ -646,7 +646,7 @@ void FixRX::init() bool eos_flag = false; for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"eos/table/rx") == 0) eos_flag = true; - if(!eos_flag) error->all(FLERR,"fix rx requires fix eos/table/rx to be specified"); + if (!eos_flag) error->all(FLERR,"fix rx requires fix eos/table/rx to be specified"); // need a half neighbor list // built whenever re-neighboring occurs @@ -673,7 +673,7 @@ void FixRX::setup_pre_force(int /*vflag*/) int newton_pair = force->newton_pair; double tmp; - if(restartFlag){ + if (restartFlag) { restartFlag = 0; } else @@ -686,7 +686,7 @@ void FixRX::setup_pre_force(int /*vflag*/) double *rwork = new double[8*nspecies]; - if(localTempFlag){ + if (localTempFlag) { int count = nlocal + (newton_pair ? nghost : 0); dpdThetaLocal = new double[count]; memset(dpdThetaLocal, 0, sizeof(double)*count); @@ -694,16 +694,16 @@ void FixRX::setup_pre_force(int /*vflag*/) } for (int id = 0; id < nlocal; id++) - for (int ispecies=0; ispeciesdvector[ispecies][id]; atom->dvector[ispecies+nspecies][id] = tmp; } for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { // Set the reaction rate constants to zero: no reactions occur at step 0 - for(int irxn=0;irxnforward_comm_fix(this); - if(localTempFlag) delete [] dpdThetaLocal; + if (localTempFlag) delete [] dpdThetaLocal; delete [] userData.kFor; delete [] userData.rxnRateLaw; @@ -734,7 +734,7 @@ void FixRX::pre_force(int /*vflag*/) double *dpdTheta = atom->dpdTheta; int newton_pair = force->newton_pair; - if(localTempFlag){ + if (localTempFlag) { int count = nlocal + (newton_pair ? nghost : 0); dpdThetaLocal = new double[count]; memset(dpdThetaLocal, 0, sizeof(double)*count); @@ -805,7 +805,7 @@ void FixRX::pre_force(int /*vflag*/) // Communicate the updated momenta and velocities to all nodes comm->forward_comm_fix(this); - if(localTempFlag) delete [] dpdThetaLocal; + if (localTempFlag) delete [] dpdThetaLocal; //TimerType timer_stop = getTimeStamp(); @@ -818,14 +818,14 @@ void FixRX::pre_force(int /*vflag*/) // getElapsedTime(timer_ODE, timer_stop), nlocal, nFuncs, nSteps); // Warn the user if a failure was detected in the ODE solver. - if (nFails > 0){ + if (nFails > 0) { char sbuf[128]; sprintf(sbuf,"in FixRX::pre_force, ODE solver failed for %d atoms.", nFails); error->warning(FLERR, sbuf); } // Compute and report ODE diagnostics, if requested. - if (odeIntegrationFlag == ODE_LAMMPS_RKF45 && diagnosticFrequency != 0){ + if (odeIntegrationFlag == ODE_LAMMPS_RKF45 && diagnosticFrequency != 0) { // Update the counters. diagnosticCounter[StepSum] += nSteps; diagnosticCounter[FuncSum] += nFuncs; @@ -907,14 +907,14 @@ void FixRX::read_file(char *file) stoich = new double*[nreactions]; stoichReactants = new double*[nreactions]; stoichProducts = new double*[nreactions]; - for (int ii=0;iidname[ispecies][0]) == 0){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { + if (strcmp(word,&atom->dname[ispecies][0]) == 0) { stoich[nreactions][ispecies] += sign*tmpStoich; - if(sign<0.0) + if (sign<0.0) stoichReactants[nreactions][ispecies] += tmpStoich; else stoichProducts[nreactions][ispecies] += tmpStoich; break; } } - if(ispecies==nspecies){ + if (ispecies==nspecies) { if (comm->me) { fprintf(stderr,"%s mol fraction is not found in data file\n",word); fprintf(stderr,"nspecies=%d ispecies=%d\n",nspecies,ispecies); @@ -966,16 +966,16 @@ void FixRX::read_file(char *file) error->all(FLERR,"Illegal fix rx command"); } word = strtok(nullptr, " \t\n\r\f"); - if(word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); - if(strcmp(word,"=") == 0) sign = 1.0; - if(strcmp(word,"+") != 0 && strcmp(word,"=") != 0){ - if(word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); + if (word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); + if (strcmp(word,"=") == 0) sign = 1.0; + if (strcmp(word,"+") != 0 && strcmp(word,"=") != 0) { + if (word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); Arr[nreactions] = atof(word); word = strtok(nullptr, " \t\n\r\f"); - if(word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); + if (word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); nArr[nreactions] = atof(word); word = strtok(nullptr, " \t\n\r\f"); - if(word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); + if (word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); Ea[nreactions] = atof(word); sign = -1.0; break; @@ -1063,10 +1063,10 @@ void FixRX::rk4(int id, double *rwork, void* v_params) } // end for (int step... // Store the solution back in atom->dvector. - for (int ispecies = 0; ispecies < nspecies; ispecies++){ - if(y[ispecies] < -MY_EPSILON) + for (int ispecies = 0; ispecies < nspecies; ispecies++) { + if (y[ispecies] < -MY_EPSILON) error->one(FLERR,"Computed concentration in RK4 solver is < -10*DBL_EPSILON"); - else if(y[ispecies] < MY_EPSILON) + else if (y[ispecies] < MY_EPSILON) y[ispecies] = 0.0; atom->dvector[ispecies][id] = y[ispecies]; } @@ -1128,7 +1128,7 @@ void FixRX::rkf45_step (const int neq, const double h, double y[], double y_out[ // 1) rhs (0.0, y, f1, v_param); - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { f1[k] *= h; ytmp[k] = y[k] + c21 * f1[k]; } @@ -1136,7 +1136,7 @@ void FixRX::rkf45_step (const int neq, const double h, double y[], double y_out[ // 2) rhs(0.0, ytmp, f2, v_param); - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { f2[k] *= h; ytmp[k] = y[k] + c31 * f1[k] + c32 * f2[k]; } @@ -1232,7 +1232,7 @@ int FixRX::rkf45_h0 (const int neq, const double t, const double /*t_stop*/, // Compute WRMS norm of y'' double yddnrm = 0.0; - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { double ydd = (ydot1[k] - ydot[k]) / hg; double wterr = ydd / (relTol * fabs( y[k] ) + absTol); yddnrm += wterr * wterr; @@ -1244,7 +1244,7 @@ int FixRX::rkf45_h0 (const int neq, const double t, const double /*t_stop*/, //std::cout << "ydot " << ydot[neq-1] << std::endl; // should we accept this? - if (hnew_is_ok || iter == max_iters){ + if (hnew_is_ok || iter == max_iters) { hnew = hg; if (iter == max_iters) fprintf(stderr, "ERROR_HIN_MAX_ITERS\n"); @@ -1319,7 +1319,7 @@ void FixRX::odeDiagnostics(void) double max_per_proc[numCounters]; double min_per_proc[numCounters]; - if(1) + if (1) { static bool firstStep = true; @@ -1392,7 +1392,7 @@ void FixRX::odeDiagnostics(void) } // Compute counters per dpd time-step. - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { my_vals[i] = this->diagnosticCounter[i] / nTimes; //printf("my sum[%d] = %f %d\n", i, my_vals[i], comm->me); } @@ -1407,7 +1407,7 @@ void FixRX::odeDiagnostics(void) double avg_per_atom[numCounters], avg_per_proc[numCounters]; // Averages per-ODE and per-proc per time-step. - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { avg_per_atom[i] = sums[i] / nODEs; avg_per_proc[i] = sums[i] / comm->nprocs; } @@ -1415,7 +1415,7 @@ void FixRX::odeDiagnostics(void) // Sum up the differences from each task. double sum_sq[2*numCounters]; double my_sum_sq[2*numCounters]; - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { double diff_i = my_vals[i] - avg_per_proc[i]; my_sum_sq[i] = diff_i * diff_i; } @@ -1423,20 +1423,20 @@ void FixRX::odeDiagnostics(void) double max_per_ODE[numCounters], min_per_ODE[numCounters]; // Process the per-ODE RMS of the # of steps/funcs - if (diagnosticFrequency == 1){ + if (diagnosticFrequency == 1) { double my_max[numCounters], my_min[numCounters]; const int nlocal = atom->nlocal; const int *mask = atom->mask; - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { my_sum_sq[i+numCounters] = 0; my_max[i] = 0; my_min[i] = DBL_MAX; - if (diagnosticCounterPerODE[i] != nullptr){ + if (diagnosticCounterPerODE[i] != nullptr) { for (int j = 0; j < nlocal; ++j) - if (mask[j] & groupbit){ + if (mask[j] & groupbit) { double diff = double(diagnosticCounterPerODE[i][j]) - avg_per_atom[i]; my_sum_sq[i+numCounters] += diff*diff; @@ -1457,7 +1457,7 @@ void FixRX::odeDiagnostics(void) TimerType timer_stop = getTimeStamp(); double time_local = getElapsedTime( timer_start, timer_stop ); - if (comm->me == 0){ + if (comm->me == 0) { char smesg[128]; #define print_mesg(smesg) {\ @@ -1471,7 +1471,7 @@ void FixRX::odeDiagnostics(void) print_mesg(smesg); // only valid for single time-step! - if (diagnosticFrequency == 1){ + if (diagnosticFrequency == 1) { double rms_per_ODE[numCounters]; for (int i = 0; i < numCounters; ++i) rms_per_ODE[i] = sqrt( sum_sq[i+numCounters] / nODEs ); @@ -1489,7 +1489,7 @@ void FixRX::odeDiagnostics(void) sprintf(smesg, " AVG per Proc : %-12.5g | %-12.5g | %-12.5g | %-12.5g", avg_per_proc[StepSum], avg_per_proc[FuncSum], avg_per_proc[TimeSum], avg_per_proc[AtomSum]); print_mesg(smesg); - if (comm->nprocs > 1){ + if (comm->nprocs > 1) { double rms_per_proc[numCounters]; for (int i = 0; i < numCounters; ++i) rms_per_proc[i] = sqrt( sum_sq[i] / comm->nprocs ); @@ -1534,7 +1534,7 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) const int neq = nspecies; // Update ConcOld and initialize the ODE solution vector y[]. - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { const double tmp = atom->dvector[ispecies][id]; atom->dvector[ispecies+nspecies][id] = tmp; y[ispecies] = tmp; @@ -1563,7 +1563,7 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) double t = 0.0; - if (h < h_min){ + if (h < h_min) { //fprintf(stderr,"hin not implemented yet\n"); //exit(-1); nfe = rkf45_h0 (neq, t, t_stop, h_min, h_max, h, y, y + neq, v_param); @@ -1572,7 +1572,7 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) //printf("t= %e t_stop= %e h= %e\n", t, t_stop, h); // Integrate until we reach the end time. - while (fabs(t - t_stop) > tround){ + while (fabs(t - t_stop) > tround) { double *yout = y + neq; double *eout = yout + neq; @@ -1582,7 +1582,7 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) // Estimate the solution error. // ... weighted 2-norm of the error. double err2 = 0.0; - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { const double wterr = eout[k] / (relTol * fabs( y[k] ) + absTol); err2 += wterr * wterr; } @@ -1590,7 +1590,7 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) double err = fmax( uround, sqrt( err2 / double(nspecies) )); // Accept the solution? - if (err <= 1.0 || h <= h_min){ + if (err <= 1.0 || h <= h_min) { t += h; nst++; @@ -1623,7 +1623,7 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) nit++; nfe += 6; - if (maxIters && nit > maxIters){ + if (maxIters && nit > maxIters) { //fprintf(stderr,"atom[%d] took too many iterations in rkf45 %d %e %e\n", id, nit, t, t_stop); //nFails ++; ode_counter[3] ++; @@ -1638,17 +1638,17 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) ode_counter[2] += nfe; //if (diagnosticFrequency == 1 && diagnosticCounterPerODE[StepSum] != nullptr) - if (diagnosticCounterPerODE[StepSum] != nullptr){ + if (diagnosticCounterPerODE[StepSum] != nullptr) { diagnosticCounterPerODE[StepSum][id] = nst; diagnosticCounterPerODE[FuncSum][id] = nfe; } //printf("id= %d nst= %d nit= %d\n", id, nst, nit); // Store the solution back in atom->dvector. - for (int ispecies = 0; ispecies < nspecies; ispecies++){ - if(y[ispecies] < -1.0e-10) + for (int ispecies = 0; ispecies < nspecies; ispecies++) { + if (y[ispecies] < -1.0e-10) error->one(FLERR,"Computed concentration in RKF45 solver is < -1.0e-10"); - else if(y[ispecies] < MY_EPSILON) + else if (y[ispecies] < MY_EPSILON) y[ispecies] = 0.0; atom->dvector[ispecies][id] = y[ispecies]; } @@ -1677,14 +1677,14 @@ int FixRX::rhs_dense(double /*t*/, const double *y, double *dydt, void *params) const double VDPD = domain->xprd * domain->yprd * domain->zprd / atom->natoms; const int nspecies = atom->nspecies_dpd; - for(int ispecies=0; ispeciesreverse_comm_fix(this); // self-interaction for local temperature - for (i = 0; i < nlocal; i++){ + for (i = 0; i < nlocal; i++) { // Lucy Weight Function - if(wtFlag==LUCY){ + if (wtFlag==LUCY) { wij = 1.0; dpdThetaLocal[i] += wij / dpdTheta[i]; } @@ -1874,7 +1874,7 @@ void FixRX::computeLocalTemperature() // Normalized local temperature dpdThetaLocal[i] = dpdThetaLocal[i] / sumWeights[i]; - if(localTempFlag == HARMONIC) + if (localTempFlag == HARMONIC) dpdThetaLocal[i] = 1.0 / dpdThetaLocal[i]; } @@ -1892,7 +1892,7 @@ int FixRX::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, in m = 0; for (ii = 0; ii < n; ii++) { jj = list[ii]; - for(int ispecies=0;ispeciesdvector[ispecies][jj]; buf[m++] = tmp; tmp = atom->dvector[ispecies+nspecies][jj]; @@ -1911,8 +1911,8 @@ void FixRX::unpack_forward_comm(int n, int first, double *buf) m = 0; last = first + n ; - for (ii = first; ii < last; ii++){ - for(int ispecies=0;ispeciesdvector[ispecies][ii] = tmp; tmp = buf[m++]; diff --git a/src/USER-DPD/fix_shardlow.cpp b/src/USER-DPD/fix_shardlow.cpp index 98e043fe08..e5bccf4192 100644 --- a/src/USER-DPD/fix_shardlow.cpp +++ b/src/USER-DPD/fix_shardlow.cpp @@ -99,7 +99,7 @@ FixShardlow::FixShardlow(LAMMPS *lmp, int narg, char **arg) : pairDPDE = (PairDPDfdtEnergy *) force->pair_match("dpd/fdt/energy/kk",1); maxRNG = 0; - if(pairDPDE){ + if (pairDPDE) { comm_forward = 3; comm_reverse = 5; } else { @@ -107,7 +107,7 @@ FixShardlow::FixShardlow(LAMMPS *lmp, int narg, char **arg) : comm_reverse = 3; } - if(pairDPD == nullptr && pairDPDE == nullptr) + if (pairDPD == nullptr && pairDPDE == nullptr) error->all(FLERR,"Must use pair_style dpd/fdt or dpd/fdt/energy with fix shardlow"); } @@ -159,10 +159,10 @@ void FixShardlow::setup(int /*vflag*/) strstr(modify->fix[i]->style,"gle") || strstr(modify->fix[i]->style,"gld")) error->all(FLERR,"Cannot use constant temperature integration routines with USER-DPD."); - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (utils::strmatch(modify->fix[i]->style,"^shardlow")) fixShardlow = true; - if (utils::strmatch(modify->fix[i]->style,"^nve") || utils::strmatch(modify->fix[i]->style,"^nph")){ - if(fixShardlow) break; + if (utils::strmatch(modify->fix[i]->style,"^nve") || utils::strmatch(modify->fix[i]->style,"^nph")) { + if (fixShardlow) break; else error->all(FLERR,"The deterministic integrator must follow fix shardlow in the input file."); } if (i == modify->nfix-1) error->all(FLERR,"A deterministic integrator (e.g. fix nve or fix nph) is required when using fix shardlow."); @@ -547,7 +547,7 @@ void FixShardlow::initial_integrate(int /*vflag*/) if (domain->triclinic) error->all(FLERR,"Fix shardlow does not yet support triclinic geometries"); - if(rcut >= bbx || rcut >= bby || rcut>= bbz ) + if (rcut >= bbx || rcut >= bby || rcut>= bbz ) { char fmt[] = {"Shardlow algorithm requires sub-domain length > 2*(rcut+skin). Either reduce the number of processors requested, or change the cutoff/skin: rcut= %e bbx= %e bby= %e bbz= %e\n"}; char *msg = (char *) malloc(sizeof(fmt) + 4*15); @@ -611,7 +611,7 @@ void FixShardlow::initial_integrate(int /*vflag*/) // Communicate the updated velocities to all nodes comm->forward_comm_fix(this); - if(useDPDE){ + if (useDPDE) { // Zero out the ghosts' uCond & uMech to be used as delta accumulators memset(&(atom->uCond[nlocal]), 0, sizeof(double)*nghost); memset(&(atom->uMech[nlocal]), 0, sizeof(double)*nghost); @@ -693,7 +693,7 @@ int FixShardlow::pack_reverse_comm(int n, int first, double *buf) buf[m++] = v[i][0] - v_t0[i - nlocal][0]; buf[m++] = v[i][1] - v_t0[i - nlocal][1]; buf[m++] = v[i][2] - v_t0[i - nlocal][2]; - if(pairDPDE){ + if (pairDPDE) { buf[m++] = uCond[i]; // for ghosts, this is an accumulated delta buf[m++] = uMech[i]; // for ghosts, this is an accumulated delta } @@ -717,7 +717,7 @@ void FixShardlow::unpack_reverse_comm(int n, int *list, double *buf) v[j][0] += buf[m++]; v[j][1] += buf[m++]; v[j][2] += buf[m++]; - if(pairDPDE){ + if (pairDPDE) { uCond[j] += buf[m++]; // add in the accumulated delta uMech[j] += buf[m++]; // add in the accumulated delta } diff --git a/src/USER-DPD/nbin_ssa.cpp b/src/USER-DPD/nbin_ssa.cpp index 81eeb68ceb..db3425c259 100644 --- a/src/USER-DPD/nbin_ssa.cpp +++ b/src/USER-DPD/nbin_ssa.cpp @@ -142,9 +142,9 @@ int NBinSSA::coord2ssaAIR(const double *x) if (x[0] < domain->sublo[0]) ix = -1; if (x[0] >= domain->subhi[0]) ix = 1; - if(iz < 0){ + if (iz < 0) { return -1; - } else if(iz == 0){ + } else if (iz == 0) { if (iy<0) return -1; // bottom left/middle/right if ((iy==0) && (ix<0) ) return -1; // left atoms if ((iy==0) && (ix==0)) return 0; // Locally owned atoms @@ -152,10 +152,10 @@ int NBinSSA::coord2ssaAIR(const double *x) if ((iy>0) && (ix==0)) return 1; // Top-middle atoms if ((iy>0) && (ix!=0)) return 3; // Top-right and top-left atoms } else { // iz > 0 - if((ix==0) && (iy==0)) return 4; // Back atoms - if((ix==0) && (iy!=0)) return 5; // Top-back and bottom-back atoms - if((ix!=0) && (iy==0)) return 6; // Left-back and right-back atoms - if((ix!=0) && (iy!=0)) return 7; // Back corner atoms + if ((ix==0) && (iy==0)) return 4; // Back atoms + if ((ix==0) && (iy!=0)) return 5; // Top-back and bottom-back atoms + if ((ix!=0) && (iy==0)) return 6; // Left-back and right-back atoms + if ((ix!=0) && (iy!=0)) return 7; // Back corner atoms } return -2; diff --git a/src/USER-DPD/pair_dpd_fdt_energy.cpp b/src/USER-DPD/pair_dpd_fdt_energy.cpp index 98eb4e8315..a97abcc84c 100644 --- a/src/USER-DPD/pair_dpd_fdt_energy.cpp +++ b/src/USER-DPD/pair_dpd_fdt_energy.cpp @@ -420,7 +420,7 @@ void PairDPDfdtEnergy::init_style() bool eos_flag = false; for (int i = 0; i < modify->nfix; i++) if (utils::strmatch(modify->fix[i]->style,"^eos")) eos_flag = true; - if(!eos_flag) error->all(FLERR,"pair_style dpd/fdt/energy requires an EOS fix to be specified"); + if (!eos_flag) error->all(FLERR,"pair_style dpd/fdt/energy requires an EOS fix to be specified"); } /* ---------------------------------------------------------------------- diff --git a/src/USER-DPD/pair_exp6_rx.cpp b/src/USER-DPD/pair_exp6_rx.cpp index fa28c75f6c..d387ffa3c5 100644 --- a/src/USER-DPD/pair_exp6_rx.cpp +++ b/src/USER-DPD/pair_exp6_rx.cpp @@ -99,7 +99,7 @@ PairExp6rx::~PairExp6rx() memory->destroy(cutsq); memory->destroy(cut); } - if(scalingFlag == POLYNOMIAL){ + if (scalingFlag == POLYNOMIAL) { memory->destroy(coeffAlpha); memory->destroy(coeffEps); memory->destroy(coeffRm); @@ -306,8 +306,8 @@ void PairExp6rx::compute(int eflag, int vflag) fpairOldEXP6_12 = 0.0; fpairOldEXP6_21 = 0.0; - if(rmOld12_ij!=0.0 && rmOld21_ij!=0.0){ - if(alphaOld21_ij == 6.0 || alphaOld12_ij == 6.0) + if (rmOld12_ij!=0.0 && rmOld21_ij!=0.0) { + if (alphaOld21_ij == 6.0 || alphaOld12_ij == 6.0) error->all(FLERR,"alpha_ij is 6.0 in pair exp6"); // A3. Compute some convenient quantities for evaluating the force @@ -323,7 +323,7 @@ void PairExp6rx::compute(int eflag, int vflag) urc = buck1*(6.0*rCutExp - alphaOld12_ij*rm6ij*rCut6inv); durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rmOld12_ij*func_rin(alphaOld12_ij); - if(r < rin1){ + if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; rin6inv = 1.0/rin6; @@ -363,7 +363,7 @@ void PairExp6rx::compute(int eflag, int vflag) durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rmOld21_ij*func_rin(alphaOld21_ij); - if(r < rin1){ + if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; rin6inv = 1.0/rin6; @@ -400,8 +400,8 @@ void PairExp6rx::compute(int eflag, int vflag) uCG[j] += 0.5*evdwlOld; } - if(rm12_ij!=0.0 && rm21_ij!=0.0){ - if(alpha21_ij == 6.0 || alpha12_ij == 6.0) + if (rm12_ij!=0.0 && rm21_ij!=0.0) { + if (alpha21_ij == 6.0 || alpha12_ij == 6.0) error->all(FLERR,"alpha_ij is 6.0 in pair exp6"); // A3. Compute some convenient quantities for evaluating the force @@ -418,7 +418,7 @@ void PairExp6rx::compute(int eflag, int vflag) durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rm12_ij*func_rin(alpha12_ij); - if(r < rin1){ + if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; rin6inv = 1.0/rin6; @@ -450,7 +450,7 @@ void PairExp6rx::compute(int eflag, int vflag) durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rm21_ij*func_rin(alpha21_ij); - if(r < rin1){ + if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; rin6inv = 1.0/rin6; @@ -593,7 +593,7 @@ void PairExp6rx::coeff(int narg, char **arg) utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error); nspecies = atom->nspecies_dpd; - if(nspecies==0) error->all(FLERR,"There are no rx species specified."); + if (nspecies==0) error->all(FLERR,"There are no rx species specified."); read_file(arg[2]); n = strlen(arg[3]) + 1; @@ -601,7 +601,7 @@ void PairExp6rx::coeff(int narg, char **arg) strcpy(site1,arg[3]); int ispecies; - for (ispecies = 0; ispecies < nspecies; ispecies++){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { if (strcmp(site1,&atom->dname[ispecies][0]) == 0) break; } if (ispecies == nspecies && strcmp(site1,"1fluid") != 0) @@ -611,7 +611,7 @@ void PairExp6rx::coeff(int narg, char **arg) site2 = new char[n]; strcpy(site2,arg[4]); - for (ispecies = 0; ispecies < nspecies; ispecies++){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { if (strcmp(site2,&atom->dname[ispecies][0]) == 0) break; } if (ispecies == nspecies && strcmp(site2,"1fluid") != 0) @@ -664,13 +664,13 @@ void PairExp6rx::coeff(int narg, char **arg) setup(); double cut_one = cut_global; - if (strcmp(arg[5],"exponent") == 0){ + if (strcmp(arg[5],"exponent") == 0) { scalingFlag = EXPONENT; exponentR = utils::numeric(FLERR,arg[6],false,lmp); exponentEpsilon = utils::numeric(FLERR,arg[7],false,lmp); if (narg > 9) error->all(FLERR,"Incorrect args for pair coefficients"); if (narg == 9) cut_one = utils::numeric(FLERR,arg[8],false,lmp); - } else if (strcmp(arg[5],"polynomial") == 0){ + } else if (strcmp(arg[5],"polynomial") == 0) { scalingFlag = POLYNOMIAL; memory->create(coeffAlpha,6,"pair:coeffAlpha"); memory->create(coeffEps,6,"pair:coeffEps"); @@ -678,7 +678,7 @@ void PairExp6rx::coeff(int narg, char **arg) read_file2(arg[6]); if (narg > 8) error->all(FLERR,"Incorrect args for pair coefficients"); if (narg == 8) cut_one = utils::numeric(FLERR,arg[7],false,lmp); - } else if (strcmp(arg[5],"none") == 0){ + } else if (strcmp(arg[5],"none") == 0) { scalingFlag = NONE; if (narg > 7) error->all(FLERR,"Incorrect args for pair coefficients"); if (narg == 7) cut_one = utils::numeric(FLERR,arg[6],false,lmp); @@ -813,7 +813,7 @@ void PairExp6rx::read_file(char *file) n = strlen(words[1]) + 1; params[nparams].potential = new char[n]; strcpy(params[nparams].potential,words[1]); - if (strcmp(params[nparams].potential,"exp6") == 0){ + if (strcmp(params[nparams].potential,"exp6") == 0) { params[nparams].alpha = atof(words[2]); params[nparams].epsilon = atof(words[3]); params[nparams].rm = atof(words[4]); @@ -901,15 +901,15 @@ void PairExp6rx::read_file2(char *file) words[nwords++] = strtok(line," \t\n\r\f"); while ((words[nwords++] = strtok(nullptr," \t\n\r\f"))) continue; - if (strcmp(words[0],"alpha") == 0){ + if (strcmp(words[0],"alpha") == 0) { for (int ii=1; iidvector[ispecies][id]; nTotalOld += atom->dvector[ispecies+nspecies][id]; @@ -1062,7 +1062,7 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double nMoleculesOFA += atom->dvector[ispecies][id]; } } - if(nTotal < MY_EPSILON || nTotalOld < MY_EPSILON) + if (nTotal < MY_EPSILON || nTotalOld < MY_EPSILON) error->all(FLERR,"The number of molecules in CG particle is less than 10*DBL_EPSILON."); // Compute the mole fraction of molecules within the fluid portion of the particle (One Fluid Approximation) @@ -1074,7 +1074,7 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double if (iparam < 0 || params[iparam].potentialType != exp6PotentialType ) continue; // If Site1 matches a pure species, then grab the parameters - if (isite1 == params[iparam].ispecies){ + if (isite1 == params[iparam].ispecies) { rm1_old = params[iparam].rm; rm1 = params[iparam].rm; epsilon1_old = params[iparam].epsilon; @@ -1090,7 +1090,7 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double } // If Site2 matches a pure species, then grab the parameters - if (isite2 == params[iparam].ispecies){ + if (isite2 == params[iparam].ispecies) { rm2_old = params[iparam].rm; rm2 = params[iparam].rm; epsilon2_old = params[iparam].epsilon; @@ -1111,9 +1111,9 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double rmi = params[iparam].rm; epsiloni = params[iparam].epsilon; alphai = params[iparam].alpha; - if(nMoleculesOFAdvector[ispecies][id]/nMoleculesOFA; - if(nMoleculesOFAolddvector[ispecies+nspecies][id]/nMoleculesOFAold; for (int jspecies = 0; jspecies < nspecies; jspecies++) { @@ -1123,9 +1123,9 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double rmj = params[jparam].rm; epsilonj = params[jparam].epsilon; alphaj = params[jparam].alpha; - if(nMoleculesOFAdvector[jspecies][id]/nMoleculesOFA; - if(nMoleculesOFAolddvector[jspecies+nspecies][id]/nMoleculesOFAold; rmij = (rmi+rmj)/2.0; @@ -1133,12 +1133,12 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double epsilonij = sqrt(epsiloni*epsilonj); alphaij = sqrt(alphai*alphaj); - if(fractionOFAold > 0.0){ + if (fractionOFAold > 0.0) { rm3_old += xMolei_old*xMolej_old*rm3ij; epsilon_old += xMolei_old*xMolej_old*rm3ij*epsilonij; alpha_old += xMolei_old*xMolej_old*rm3ij*epsilonij*alphaij; } - if(fractionOFA > 0.0){ + if (fractionOFA > 0.0) { rm3 += xMolei*xMolej*rm3ij; epsilon += xMolei*xMolej*rm3ij*epsilonij; alpha += xMolei*xMolej*rm3ij*epsilonij*alphaij; @@ -1147,9 +1147,9 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double } } - if (isOneFluidApprox(isite1)){ + if (isOneFluidApprox(isite1)) { rm1 = cbrt(rm3); - if(rm1 < MY_EPSILON) { + if (rm1 < MY_EPSILON) { rm1 = 0.0; epsilon1 = 0.0; alpha1 = 0.0; @@ -1161,7 +1161,7 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double fraction1 = fractionOFA; rm1_old = cbrt(rm3_old); - if(rm1_old < MY_EPSILON) { + if (rm1_old < MY_EPSILON) { rm1_old = 0.0; epsilon1_old = 0.0; alpha1_old = 0.0; @@ -1172,18 +1172,18 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double nMoleculesOld1 = 1.0-(nTotalOld-nMoleculesOFAold); fractionOld1 = fractionOFAold; - if(scalingFlag == EXPONENT){ + if (scalingFlag == EXPONENT) { exponentScaling(nMoleculesOFA,epsilon1,rm1); exponentScaling(nMoleculesOFAold,epsilon1_old,rm1_old); - } else if(scalingFlag == POLYNOMIAL){ + } else if (scalingFlag == POLYNOMIAL) { polynomialScaling(nMoleculesOFA,alpha1,epsilon1,rm1); polynomialScaling(nMoleculesOFAold,alpha1_old,epsilon1_old,rm1_old); } } - if (isOneFluidApprox(isite2)){ + if (isOneFluidApprox(isite2)) { rm2 = cbrt(rm3); - if(rm2 < MY_EPSILON) { + if (rm2 < MY_EPSILON) { rm2 = 0.0; epsilon2 = 0.0; alpha2 = 0.0; @@ -1195,7 +1195,7 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double fraction2 = fractionOFA; rm2_old = cbrt(rm3_old); - if(rm2_old < MY_EPSILON) { + if (rm2_old < MY_EPSILON) { rm2_old = 0.0; epsilon2_old = 0.0; alpha2_old = 0.0; @@ -1206,46 +1206,46 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double nMoleculesOld2 = 1.0-(nTotalOld-nMoleculesOFAold); fractionOld2 = fractionOFAold; - if(scalingFlag == EXPONENT){ + if (scalingFlag == EXPONENT) { exponentScaling(nMoleculesOFA,epsilon2,rm2); exponentScaling(nMoleculesOFAold,epsilon2_old,rm2_old); - } else if(scalingFlag == POLYNOMIAL){ + } else if (scalingFlag == POLYNOMIAL) { polynomialScaling(nMoleculesOFA,alpha2,epsilon2,rm2); polynomialScaling(nMoleculesOFAold,alpha2_old,epsilon2_old,rm2_old); } } // Check that no fractions are less than zero - if(fraction1 < 0.0 || nMolecules1 < 0.0){ - if(fraction1 < -MY_EPSILON || nMolecules1 < -MY_EPSILON){ + if (fraction1 < 0.0 || nMolecules1 < 0.0) { + if (fraction1 < -MY_EPSILON || nMolecules1 < -MY_EPSILON) { error->all(FLERR,"Computed fraction less than -10*DBL_EPSILON"); } nMolecules1 = 0.0; fraction1 = 0.0; } - if(fraction2 < 0.0 || nMolecules2 < 0.0){ - if(fraction2 < -MY_EPSILON || nMolecules2 < -MY_EPSILON){ + if (fraction2 < 0.0 || nMolecules2 < 0.0) { + if (fraction2 < -MY_EPSILON || nMolecules2 < -MY_EPSILON) { error->all(FLERR,"Computed fraction less than -10*DBL_EPSILON"); } nMolecules2 = 0.0; fraction2 = 0.0; } - if(fractionOld1 < 0.0 || nMoleculesOld1 < 0.0){ - if(fractionOld1 < -MY_EPSILON || nMoleculesOld1 < -MY_EPSILON){ + if (fractionOld1 < 0.0 || nMoleculesOld1 < 0.0) { + if (fractionOld1 < -MY_EPSILON || nMoleculesOld1 < -MY_EPSILON) { error->all(FLERR,"Computed fraction less than -10*DBL_EPSILON"); } nMoleculesOld1 = 0.0; fractionOld1 = 0.0; } - if(fractionOld2 < 0.0 || nMoleculesOld2 < 0.0){ - if(fractionOld2 < -MY_EPSILON || nMoleculesOld2 < -MY_EPSILON){ + if (fractionOld2 < 0.0 || nMoleculesOld2 < 0.0) { + if (fractionOld2 < -MY_EPSILON || nMoleculesOld2 < -MY_EPSILON) { error->all(FLERR,"Computed fraction less than -10*DBL_EPSILON"); } nMoleculesOld2 = 0.0; fractionOld2 = 0.0; } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old = fractionOld1; mixWtSite1 = fraction1; mixWtSite2old = fractionOld2; @@ -1264,17 +1264,17 @@ void PairExp6rx::exponentScaling(double phi, double &epsilon, double &rm) const { double powfuch; - if(exponentEpsilon < 0.0){ + if (exponentEpsilon < 0.0) { powfuch = pow(phi,-exponentEpsilon); - if(powfuchone(FLERR,"Density < table inner cutoff"); itable = static_cast (((rho[i]*rho[i]) - tb->innersq) * tb->invdelta); if (tabstyle == LOOKUP) evdwl = tb->e[itable]; - else if (tabstyle == LINEAR){ + else if (tabstyle == LINEAR) { if (itable >= tlm1) error->one(FLERR,"Density > table outer cutoff"); - if(itable==0) fraction_i=0.0; + if (itable==0) fraction_i=0.0; else fraction_i = (((rho[i]*rho[i]) - tb->rsq[itable]) * tb->invdelta); evdwl = tb->e[itable] + fraction_i*tb->de[itable]; } else error->one(FLERR,"Only LOOKUP and LINEAR table styles have been implemented for pair multi/lucy"); diff --git a/src/USER-DPD/pair_multi_lucy_rx.cpp b/src/USER-DPD/pair_multi_lucy_rx.cpp index c4cc537b18..e1a263b7dc 100644 --- a/src/USER-DPD/pair_multi_lucy_rx.cpp +++ b/src/USER-DPD/pair_multi_lucy_rx.cpp @@ -193,7 +193,7 @@ void PairMultiLucyRX::compute(int eflag, int vflag) mixWtSite2old_j = mixWtSite2old[j]; tb = &tables[tabindex[itype][jtype]]; - if (rho[i]*rho[i] < tb->innersq || rho[j]*rho[j] < tb->innersq){ + if (rho[i]*rho[i] < tb->innersq || rho[j]*rho[j] < tb->innersq) { printf("Table inner cutoff = %lf\n",sqrt(tb->innersq)); printf("rho[%d]=%lf\n",i,rho[i]); printf("rho[%d]=%lf\n",j,rho[j]); @@ -202,7 +202,7 @@ void PairMultiLucyRX::compute(int eflag, int vflag) if (tabstyle == LOOKUP) { itable = static_cast (((rho[i]*rho[i]) - tb->innersq) * tb->invdelta); jtable = static_cast (((rho[j]*rho[j]) - tb->innersq) * tb->invdelta); - if (itable >= tlm1 || jtable >= tlm1){ + if (itable >= tlm1 || jtable >= tlm1) { printf("Table outer index = %d\n",tlm1); printf("itableIndex=%d rho[%d]=%lf\n",itable,i,rho[i]); printf("jtableIndex=%d rho[%d]=%lf\n",jtable,j,rho[j]); @@ -218,23 +218,23 @@ void PairMultiLucyRX::compute(int eflag, int vflag) } else if (tabstyle == LINEAR) { itable = static_cast ((rho[i]*rho[i] - tb->innersq) * tb->invdelta); jtable = static_cast (((rho[j]*rho[j]) - tb->innersq) * tb->invdelta); - if (itable >= tlm1 || jtable >= tlm1){ + if (itable >= tlm1 || jtable >= tlm1) { printf("Table outer index = %d\n",tlm1); printf("itableIndex=%d rho[%d]=%lf\n",itable,i,rho[i]); printf("jtableIndex=%d rho[%d]=%lf\n",jtable,j,rho[j]); error->one(FLERR,"Density > table outer cutoff"); } - if(itable<0) itable=0; - if(itable>=tlm1) itable=tlm1; - if(jtable<0) jtable=0; - if(jtable>=tlm1)jtable=tlm1; + if (itable<0) itable=0; + if (itable>=tlm1) itable=tlm1; + if (jtable<0) jtable=0; + if (jtable>=tlm1)jtable=tlm1; fraction_i = (((rho[i]*rho[i]) - tb->rsq[itable]) * tb->invdelta); fraction_j = (((rho[j]*rho[j]) - tb->rsq[jtable]) * tb->invdelta); - if(itable==0) fraction_i=0.0; - if(itable==tlm1) fraction_i=0.0; - if(jtable==0) fraction_j=0.0; - if(jtable==tlm1) fraction_j=0.0; + if (itable==0) fraction_i=0.0; + if (itable==tlm1) fraction_i=0.0; + if (jtable==0) fraction_j=0.0; + if (jtable==tlm1) fraction_j=0.0; A_i = tb->f[itable] + fraction_i*tb->df[itable]; A_j = tb->f[jtable] + fraction_j*tb->df[jtable]; @@ -267,12 +267,12 @@ void PairMultiLucyRX::compute(int eflag, int vflag) tb = &tables[tabindex[itype][itype]]; itable = static_cast (((rho[i]*rho[i]) - tb->innersq) * tb->invdelta); if (tabstyle == LOOKUP) evdwl = tb->e[itable]; - else if (tabstyle == LINEAR){ - if (itable >= tlm1){ + else if (tabstyle == LINEAR) { + if (itable >= tlm1) { printf("itableIndex=%d rho[%d]=%lf\n",itable,i,rho[i]); error->one(FLERR,"Density > table outer cutoff"); } - if(itable==0) fraction_i=0.0; + if (itable==0) fraction_i=0.0; else fraction_i = (((rho[i]*rho[i]) - tb->rsq[itable]) * tb->invdelta); evdwl = tb->e[itable] + fraction_i*tb->de[itable]; } else error->one(FLERR,"Only LOOKUP and LINEAR table styles have been implemented for pair multi/lucy/rx"); @@ -442,7 +442,7 @@ void PairMultiLucyRX::coeff(int narg, char **arg) else { isite1 = nspecies; for (int ispecies = 0; ispecies < nspecies; ++ispecies) - if (strcmp(site1, atom->dname[ispecies]) == 0){ + if (strcmp(site1, atom->dname[ispecies]) == 0) { isite1 = ispecies; break; } @@ -456,7 +456,7 @@ void PairMultiLucyRX::coeff(int narg, char **arg) else { isite2 = nspecies; for (int ispecies = 0; ispecies < nspecies; ++ispecies) - if (strcmp(site2, atom->dname[ispecies]) == 0){ + if (strcmp(site2, atom->dname[ispecies]) == 0) { isite2 = ispecies; break; } @@ -894,7 +894,7 @@ void PairMultiLucyRX::computeLocalDensity() // rho = density at each atom // loop over neighbors of my atoms - for (int ii = 0; ii < inum; ii++){ + for (int ii = 0; ii < inum; ii++) { const int i = ilist[ii]; const double xtmp = x[i][0]; @@ -907,7 +907,7 @@ void PairMultiLucyRX::computeLocalDensity() const int *jlist = firstneigh[i]; const int jnum = numneigh[i]; - for (int jj = 0; jj < jnum; jj++){ + for (int jj = 0; jj < jnum; jj++) { const int j = (jlist[jj] & NEIGHMASK); const int jtype = type[j]; @@ -960,44 +960,44 @@ void PairMultiLucyRX::getMixingWeights(int id, double &mixWtSite1old, double &mi nTotal = 0.0; nTotalOld = 0.0; - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { nTotal += atom->dvector[ispecies][id]; nTotalOld += atom->dvector[ispecies+nspecies][id]; } - if (isOneFluid(isite1) == false){ + if (isOneFluid(isite1) == false) { nMoleculesOld1 = atom->dvector[isite1+nspecies][id]; nMolecules1 = atom->dvector[isite1][id]; fractionOld1 = nMoleculesOld1/nTotalOld; fraction1 = nMolecules1/nTotal; } - if (isOneFluid(isite2) == false){ + if (isOneFluid(isite2) == false) { nMoleculesOld2 = atom->dvector[isite2+nspecies][id]; nMolecules2 = atom->dvector[isite2][id]; fractionOld2 = nMoleculesOld2/nTotalOld; fraction2 = nMolecules2/nTotal; } - if (isOneFluid(isite1) || isOneFluid(isite2)){ + if (isOneFluid(isite1) || isOneFluid(isite2)) { nMoleculesOFAold = 0.0; nMoleculesOFA = 0.0; fractionOFAold = 0.0; fractionOFA = 0.0; - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { if (isite1 == ispecies || isite2 == ispecies) continue; nMoleculesOFAold += atom->dvector[ispecies+nspecies][id]; nMoleculesOFA += atom->dvector[ispecies][id]; fractionOFAold += atom->dvector[ispecies+nspecies][id] / nTotalOld; fractionOFA += atom->dvector[ispecies][id] / nTotal; } - if (isOneFluid(isite1)){ + if (isOneFluid(isite1)) { nMoleculesOld1 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules1 = 1.0-(nTotal-nMoleculesOFA); fractionOld1 = fractionOFAold; fraction1 = fractionOFA; } - if (isOneFluid(isite2)){ + if (isOneFluid(isite2)) { nMoleculesOld2 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules2 = 1.0-(nTotal-nMoleculesOFA); fractionOld2 = fractionOFAold; @@ -1005,7 +1005,7 @@ void PairMultiLucyRX::getMixingWeights(int id, double &mixWtSite1old, double &mi } } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old = fractionOld1; mixWtSite1 = fraction1; mixWtSite2old = fractionOld2; diff --git a/src/USER-DPD/pair_table_rx.cpp b/src/USER-DPD/pair_table_rx.cpp index c418ebd4b3..6c975c97f3 100644 --- a/src/USER-DPD/pair_table_rx.cpp +++ b/src/USER-DPD/pair_table_rx.cpp @@ -198,14 +198,14 @@ void PairTableRX::compute(int eflag, int vflag) if (tabstyle == LOOKUP) evdwl = tb->e[itable]; - else if (tabstyle == LINEAR || tabstyle == BITMAP){ + else if (tabstyle == LINEAR || tabstyle == BITMAP) { evdwl = tb->e[itable] + fraction*tb->de[itable]; } else evdwl = a * tb->e[itable] + b * tb->e[itable+1] + ((a*a*a-a)*tb->e2[itable] + (b*b*b-b)*tb->e2[itable+1]) * tb->deltasq6; - if (isite1 == isite2){ + if (isite1 == isite2) { evdwlOld = sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwl; evdwl = sqrt(mixWtSite1_i*mixWtSite2_j)*evdwl; } else { @@ -321,14 +321,14 @@ void PairTableRX::coeff(int narg, char **arg) bcast_table(tb); nspecies = atom->nspecies_dpd; - if(nspecies==0) error->all(FLERR,"There are no rx species specified."); + if (nspecies==0) error->all(FLERR,"There are no rx species specified."); int n; n = strlen(arg[4]) + 1; site1 = new char[n]; strcpy(site1,arg[4]); int ispecies; - for (ispecies = 0; ispecies < nspecies; ispecies++){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { if (strcmp(site1,&atom->dname[ispecies][0]) == 0) break; } if (ispecies == nspecies && strcmp(site1,"1fluid") != 0) @@ -338,7 +338,7 @@ void PairTableRX::coeff(int narg, char **arg) site2 = new char[n]; strcpy(site2,arg[5]); - for (ispecies = 0; ispecies < nspecies; ispecies++){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { if (strcmp(site2,&atom->dname[ispecies][0]) == 0) break; } if (ispecies == nspecies && strcmp(site2,"1fluid") != 0) @@ -405,8 +405,8 @@ void PairTableRX::coeff(int narg, char **arg) else { isite1 = nspecies; - for (int k = 0; k < nspecies; k++){ - if (strcmp(site1, atom->dname[k]) == 0){ + for (int k = 0; k < nspecies; k++) { + if (strcmp(site1, atom->dname[k]) == 0) { isite1 = k; break; } @@ -420,8 +420,8 @@ void PairTableRX::coeff(int narg, char **arg) else { isite2 = nspecies; - for (int k = 0; k < nspecies; k++){ - if (strcmp(site2, atom->dname[k]) == 0){ + for (int k = 0; k < nspecies; k++) { + if (strcmp(site2, atom->dname[k]) == 0) { isite2 = ispecies; break; } @@ -519,46 +519,46 @@ void PairTableRX::getMixingWeights(int id, double &mixWtSite1old, double &mixWtS nTotal = 0.0; nTotalOld = 0.0; - for (int ispecies = 0; ispecies < nspecies; ++ispecies){ + for (int ispecies = 0; ispecies < nspecies; ++ispecies) { nTotal += atom->dvector[ispecies][id]; nTotalOld += atom->dvector[ispecies+nspecies][id]; } - if(nTotal < MY_EPSILON || nTotalOld < MY_EPSILON) + if (nTotal < MY_EPSILON || nTotalOld < MY_EPSILON) error->all(FLERR,"The number of molecules in CG particle is less than 10*DBL_EPSILON."); - if (isOneFluid(isite1) == false){ + if (isOneFluid(isite1) == false) { nMoleculesOld1 = atom->dvector[isite1+nspecies][id]; nMolecules1 = atom->dvector[isite1][id]; fractionOld1 = nMoleculesOld1/nTotalOld; fraction1 = nMolecules1/nTotal; } - if (isOneFluid(isite2) == false){ + if (isOneFluid(isite2) == false) { nMoleculesOld2 = atom->dvector[isite2+nspecies][id]; nMolecules2 = atom->dvector[isite2][id]; fractionOld2 = nMoleculesOld2/nTotalOld; fraction2 = nMolecules2/nTotal; } - if (isOneFluid(isite1) || isOneFluid(isite2)){ + if (isOneFluid(isite1) || isOneFluid(isite2)) { nMoleculesOFAold = 0.0; nMoleculesOFA = 0.0; fractionOFAold = 0.0; fractionOFA = 0.0; - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { if (isite1 == ispecies || isite2 == ispecies) continue; nMoleculesOFAold += atom->dvector[ispecies+nspecies][id]; nMoleculesOFA += atom->dvector[ispecies][id]; fractionOFAold += atom->dvector[ispecies+nspecies][id]/nTotalOld; fractionOFA += atom->dvector[ispecies][id]/nTotal; } - if(isOneFluid(isite1)){ + if (isOneFluid(isite1)) { nMoleculesOld1 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules1 = 1.0-(nTotal-nMoleculesOFA); fractionOld1 = fractionOFAold; fraction1 = fractionOFA; } - if(isOneFluid(isite2)){ + if (isOneFluid(isite2)) { nMoleculesOld2 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules2 = 1.0-(nTotal-nMoleculesOFA); fractionOld2 = fractionOFAold; @@ -566,7 +566,7 @@ void PairTableRX::getMixingWeights(int id, double &mixWtSite1old, double &mixWtS } } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old = fractionOld1; mixWtSite1 = fraction1; mixWtSite2old = fractionOld2; diff --git a/src/USER-DRUDE/compute_temp_drude.cpp b/src/USER-DRUDE/compute_temp_drude.cpp index b2e07bd68d..fe75c10fe3 100644 --- a/src/USER-DRUDE/compute_temp_drude.cpp +++ b/src/USER-DRUDE/compute_temp_drude.cpp @@ -155,8 +155,8 @@ void ComputeTempDrude::compute_vector() double ecore, edrude; double *vcore, *vdrude; double kineng_core_loc = 0., kineng_drude_loc = 0.; - for (int i=0; inlocal; int *type = atom->type; @@ -113,10 +113,10 @@ void FixDrude::build_drudeid(){ if (atom->molecular == Atom::MOLECULAR) { // Build list of my atoms' bond partners - for (int i=0; inum_bond[i]; k++){ + for (int k=0; knum_bond[i]; k++) { core_drude_vec.push_back(atom->tag[i]); core_drude_vec.push_back(atom->bond_atom[i][k]); } @@ -129,7 +129,7 @@ void FixDrude::build_drudeid(){ atommols = atom->avec->onemols; // Build list of my atoms' bond partners - for (int i=0; imolindex[i]; int iatom = atom->molatom[i]; tagint *batom = atommols[imol]->bond_atom[iatom]; @@ -138,7 +138,7 @@ void FixDrude::build_drudeid(){ if (drudetype[type[i]] == NOPOL_TYPE) continue; drudeid[i] = 0; - for (int k=0; ktag[i]); core_drude_vec.push_back(batom[k]+tagprev); } @@ -152,8 +152,8 @@ void FixDrude::build_drudeid(){ // Build the list of my Drudes' tags // The only bond partners of a Drude particle is its core, // so fill drudeid for my Drudes. - for (int i=0; itag[i]); drudeid[i] = *partner_set[i].begin(); // only one 1-2 neighbor, the core } @@ -172,7 +172,7 @@ void FixDrude::build_drudeid(){ * Look in my cores' bond partner tags if there is a Drude tag. * If so fill this core's dureid. ------------------------------------------------------------------------- */ -void FixDrude::ring_search_drudeid(int size, char *cbuf, void *ptr){ +void FixDrude::ring_search_drudeid(int size, char *cbuf, void *ptr) { // Search for the drude partner of my cores FixDrude *fdptr = (FixDrude *) ptr; Atom *atom = fdptr->atom; @@ -190,7 +190,7 @@ void FixDrude::ring_search_drudeid(int size, char *cbuf, void *ptr){ for (int i=0; i 0) continue; for (it = partner_set[i].begin(); it != partner_set[i].end(); it++) { // Drude-core are 1-2 neighbors - if (drude_set.count(*it) > 0){ + if (drude_set.count(*it) > 0) { drudeid[i] = *it; break; } @@ -202,7 +202,7 @@ void FixDrude::ring_search_drudeid(int size, char *cbuf, void *ptr){ * buffer contains bond partners. Look for my atoms and add their partner's * tag in its set of bond partners. ------------------------------------------------------------------------- */ -void FixDrude::ring_build_partner(int size, char *cbuf, void *ptr){ +void FixDrude::ring_build_partner(int size, char *cbuf, void *ptr) { // Add partners from incoming list FixDrude *fdptr = (FixDrude *) ptr; Atom *atom = fdptr->atom; @@ -270,7 +270,7 @@ int FixDrude::unpack_exchange(int nlocal, double *buf) int FixDrude::pack_border(int n, int *list, double *buf) { int m = 0; - for (int i=0; inlocal; @@ -330,7 +330,7 @@ void FixDrude::rebuild_special(){ for (int i=0; itag[i]); - } else if (drudetype[type[i]] == CORE_TYPE){ + } else if (drudetype[type[i]] == CORE_TYPE) { core_drude_vec.push_back(atom->tag[i]); core_drude_vec.push_back(drudeid[i]); } @@ -380,7 +380,7 @@ void FixDrude::rebuild_special(){ * When receive buffer, build a set of drude tags, look into my atoms' * special list if some tags are drude particles. If so, remove it. ------------------------------------------------------------------------- */ -void FixDrude::ring_remove_drude(int size, char *cbuf, void *ptr){ +void FixDrude::ring_remove_drude(int size, char *cbuf, void *ptr) { // Remove all drude particles from special list FixDrude *fdptr = (FixDrude *) ptr; Atom *atom = fdptr->atom; @@ -416,7 +416,7 @@ void FixDrude::ring_remove_drude(int size, char *cbuf, void *ptr){ * Loop on my atoms' special list to find core tags. Insert their Drude * particle if they have one. ------------------------------------------------------------------------- */ -void FixDrude::ring_add_drude(int size, char *cbuf, void *ptr){ +void FixDrude::ring_add_drude(int size, char *cbuf, void *ptr) { // Assume special array size is big enough // Add all particle just after their core in the special list FixDrude *fdptr = (FixDrude *) ptr; @@ -473,7 +473,7 @@ void FixDrude::ring_add_drude(int size, char *cbuf, void *ptr){ * in the buffer. Loop on my Drude particles and copy their special * info from that of their core if the latter is found in the map. ------------------------------------------------------------------------- */ -void FixDrude::ring_copy_drude(int size, char *cbuf, void *ptr){ +void FixDrude::ring_copy_drude(int size, char *cbuf, void *ptr) { // Copy special list of drude from its core (except itself) FixDrude *fdptr = (FixDrude *) ptr; Atom *atom = fdptr->atom; @@ -520,8 +520,8 @@ void FixDrude::ring_copy_drude(int size, char *cbuf, void *ptr){ * Set drudeid when a new atom is created, * special list must be up-to-date * ----------------------------------------------------------------------*/ -void FixDrude::set_arrays(int i){ - if (drudetype[atom->type[i]] != NOPOL_TYPE){ +void FixDrude::set_arrays(int i) { + if (drudetype[atom->type[i]] != NOPOL_TYPE) { if (atom->nspecial[i] ==0) error->all(FLERR, "Polarizable atoms cannot be inserted with special lists info from the molecule template"); drudeid[i] = atom->special[i][0]; // Drude partner should be at first place in the special list } else { diff --git a/src/USER-DRUDE/fix_drude_transform.cpp b/src/USER-DRUDE/fix_drude_transform.cpp index 659984131c..d75481c2c8 100644 --- a/src/USER-DRUDE/fix_drude_transform.cpp +++ b/src/USER-DRUDE/fix_drude_transform.cpp @@ -83,7 +83,7 @@ void FixDrudeTransform::setup(int) { int j = atom->map(drudeid[i]); // i is drude, j is core if (mcoeff_loc[type[i]] < 1.5) { // already done - if (mcoeff_loc[type[j]] > 1.5){ // not yet done ?? + if (mcoeff_loc[type[j]] > 1.5) { // not yet done ?? error->all(FLERR,"There must be one Drude type per core type");} continue; } @@ -103,28 +103,28 @@ void FixDrudeTransform::setup(int) { /* ---------------------------------------------------------------------- */ namespace LAMMPS_NS { // required for specialization template <> -void FixDrudeTransform::initial_integrate(int){ +void FixDrudeTransform::initial_integrate(int) { comm->forward_comm_fix(this); real_to_reduced(); //comm->forward_comm_fix(this); // Normally not needed } template <> -void FixDrudeTransform::final_integrate(){ +void FixDrudeTransform::final_integrate() { comm->forward_comm_fix(this); real_to_reduced(); //comm->forward_comm_fix(this); // Normally not needed } template <> -void FixDrudeTransform::initial_integrate(int){ +void FixDrudeTransform::initial_integrate(int) { comm->forward_comm_fix(this); reduced_to_real(); //comm->forward_comm_fix(this); // Normally not needed } template <> -void FixDrudeTransform::final_integrate(){ +void FixDrudeTransform::final_integrate() { comm->forward_comm_fix(this); reduced_to_real(); //comm->forward_comm_fix(this); // Normally not needed diff --git a/src/USER-DRUDE/fix_langevin_drude.cpp b/src/USER-DRUDE/fix_langevin_drude.cpp index 2b45862868..4e905d16d3 100644 --- a/src/USER-DRUDE/fix_langevin_drude.cpp +++ b/src/USER-DRUDE/fix_langevin_drude.cpp @@ -271,7 +271,7 @@ void FixLangevinDrude::post_force(int /*vflag*/) Gcore = mi / t_period_core / ftm2v; Ccore = sqrt(2.0 * Gcore * kb * t_target_core / dt / ftm2v / mvv2e); if (temperature) temperature->remove_bias(i, v[i]); - for(int k = 0; k < dim; k++){ + for (int k = 0; k < dim; k++) { fcore[k] = Ccore * random_core->gaussian() - Gcore * v[i][k]; if (zero) fcoreloc[k] += fcore[k]; f[i][k] += fcore[k]; @@ -326,7 +326,7 @@ void FixLangevinDrude::post_force(int /*vflag*/) } } - if(zero) { // Remove the drift + if (zero) { // Remove the drift MPI_Allreduce(fcoreloc, fcoresum, dim, MPI_DOUBLE, MPI_SUM, world); for (int k=0; k (list[n++]); if (tstat_flag && m == mtchain) { - for (int ich = 0; ich < mtchain; ich++){ + for (int ich = 0; ich < mtchain; ich++) { etamol[ich] = list[n++]; etaint[ich] = list[n++]; etadrude[ich] = list[n++]; } - for (int ich = 0; ich < mtchain; ich++){ + for (int ich = 0; ich < mtchain; ich++) { etamol_dot[ich] = list[n++]; etaint_dot[ich] = list[n++]; etadrude_dot[ich] = list[n++]; @@ -1509,7 +1509,7 @@ double FixTGNHDrude::compute_scalar() energy += ke2mol_target * etamol[0] + 0.5 * etamol_mass[0] * etamol_dot[0] * etamol_dot[0]; energy += ke2int_target * etaint[0] + 0.5 * etaint_mass[0] * etaint_dot[0] * etaint_dot[0]; energy += ke2drude_target * etadrude[0] + 0.5 * etadrude_mass[0] * etadrude_dot[0] * etadrude_dot[0]; - for (ich = 1; ich < mtchain; ich++){ + for (ich = 1; ich < mtchain; ich++) { energy += kt * etamol[ich] + 0.5*etamol_mass[ich]*etamol_dot[ich]*etamol_dot[ich]; energy += kt * etaint[ich] + 0.5*etaint_mass[ich]*etaint_dot[ich]*etaint_dot[ich]; energy += kt_drude * etadrude[ich] + 0.5*etadrude_mass[ich]*etadrude_dot[ich]*etadrude_dot[ich]; @@ -1565,7 +1565,7 @@ double FixTGNHDrude::compute_vector(int n) { if (!temp_computed_end_of_step) compute_temp_mol_int_drude(true); - switch (n){ + switch (n) { case 0: return t_mol; case 1: @@ -1711,7 +1711,7 @@ void FixTGNHDrude::nhc_temp_integrate() // update masses of thermostat in case target temperature changes etamol_mass[0] = ke2mol_target / (t_freq*t_freq); etaint_mass[0] = ke2int_target / (t_freq*t_freq); - for (int ich = 1; ich < mtchain; ich++){ + for (int ich = 1; ich < mtchain; ich++) { etamol_mass[ich] = boltz * t_target / (t_freq*t_freq); etaint_mass[ich] = boltz * t_target / (t_freq*t_freq); } diff --git a/src/USER-DRUDE/pair_coul_tt.cpp b/src/USER-DRUDE/pair_coul_tt.cpp index a051b6e3c6..a807ea3c16 100644 --- a/src/USER-DRUDE/pair_coul_tt.cpp +++ b/src/USER-DRUDE/pair_coul_tt.cpp @@ -163,7 +163,7 @@ void PairCoulTT::compute(int eflag, int vflag) dcoul = qqrd2e * qi * qj *scale[itype][jtype] * rinv; factor_f = (-beta*gamma + r*betaprime*gamma + r*beta*gammaprime)*factor_coul; - if(eflag) factor_e = - beta*gamma*factor_coul; + if (eflag) factor_e = - beta*gamma*factor_coul; fpair = factor_f * dcoul * r2inv; f[i][0] += delx*fpair; diff --git a/src/USER-DRUDE/pair_lj_cut_thole_long.cpp b/src/USER-DRUDE/pair_lj_cut_thole_long.cpp index 6046061aa5..84437f408a 100644 --- a/src/USER-DRUDE/pair_lj_cut_thole_long.cpp +++ b/src/USER-DRUDE/pair_lj_cut_thole_long.cpp @@ -131,7 +131,7 @@ void PairLJCutTholeLong::compute(int eflag, int vflag) jlist = firstneigh[i]; jnum = numneigh[i]; - if (drudetype[type[i]] != NOPOL_TYPE){ + if (drudetype[type[i]] != NOPOL_TYPE) { di = atom->map(drudeid[i]); if (di < 0) error->all(FLERR, "Drude partner not found"); di_closest = domain->closest_image(i, di); @@ -187,9 +187,9 @@ void PairLJCutTholeLong::compute(int eflag, int vflag) } if (drudetype[type[i]] != NOPOL_TYPE && - drudetype[type[j]] != NOPOL_TYPE){ - if (j != di_closest){ - if (drudetype[type[j]] == CORE_TYPE){ + drudetype[type[j]] != NOPOL_TYPE) { + if (j != di_closest) { + if (drudetype[type[j]] == CORE_TYPE) { dj = atom->map(drudeid[j]); dqj = -q[dj]; } else dqj = qj; @@ -231,7 +231,7 @@ void PairLJCutTholeLong::compute(int eflag, int vflag) } if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; if (drudetype[type[i]] != NOPOL_TYPE && - drudetype[type[j]] != NOPOL_TYPE && j != di_closest){ + drudetype[type[j]] != NOPOL_TYPE && j != di_closest) { ecoul += factor_e * dcoul; } } else ecoul = 0.0; diff --git a/src/USER-DRUDE/pair_thole.cpp b/src/USER-DRUDE/pair_thole.cpp index d95309406a..418705e0a3 100644 --- a/src/USER-DRUDE/pair_thole.cpp +++ b/src/USER-DRUDE/pair_thole.cpp @@ -137,7 +137,7 @@ void PairThole::compute(int eflag, int vflag) exp_asr = exp(-asr); dcoul = qqrd2e * qi * qj *scale[itype][jtype] * rinv; factor_f = 0.5*(2. + (exp_asr * (-2. - asr * (2. + asr)))) - factor_coul; - if(eflag) factor_e = 0.5*(2. - (exp_asr * (2. + asr))) - factor_coul; + if (eflag) factor_e = 0.5*(2. - (exp_asr * (2. + asr))) - factor_coul; fpair = factor_f * dcoul * r2inv; f[i][0] += delx*fpair; diff --git a/src/USER-FEP/pair_morse_soft.cpp b/src/USER-FEP/pair_morse_soft.cpp index f7216829d6..d429503237 100644 --- a/src/USER-FEP/pair_morse_soft.cpp +++ b/src/USER-FEP/pair_morse_soft.cpp @@ -35,7 +35,7 @@ using namespace MathSpecial; PairMorseSoft::~PairMorseSoft() { - if(allocated){ + if (allocated) { memory->destroy(lambda); } } @@ -108,7 +108,7 @@ void PairMorseSoft::compute(int eflag, int vflag) V0 = D * dexp * ( dexp - 2.0 ); B = -2.0 * D * iea2 * ( ea - 1.0 ) / 3.0; - if (l >= shift_range){ + if (l >= shift_range) { s1 = (l - 1.0) / (shift_range - 1.0); phi = V0 + B*dexp3 * s1; @@ -121,7 +121,7 @@ void PairMorseSoft::compute(int eflag, int vflag) phi *= llf; // Force computation: - if (r == 0.0){ + if (r == 0.0) { fpair = 0.0; } else { fpair = 3.0*a*B*dexp3 + 2.0*a*D*(dexp2 - dexp); @@ -256,7 +256,7 @@ double PairMorseSoft::init_one(int i, int j) V0 = D * dexp * ( dexp - 2.0 ); B = -2.0 * D * iea2 * ( ea - 1.0 ) / 3.0; - if (l >= shift_range){ + if (l >= shift_range) { s1 = (l - 1.0) / (shift_range - 1.0); offset[i][j] = V0 + B*dexp3 * s1; } else { @@ -415,7 +415,7 @@ double PairMorseSoft::single(int /*i*/, int /*j*/, int itype, int jtype, double V0 = D * dexp * ( dexp - 2.0 ); B = -2.0 * D * iea2 * ( ea - 1.0 ) / 3.0; - if (l >= shift_range){ + if (l >= shift_range) { s1 = (l - 1.0) / (shift_range - 1.0); phi = V0 + B*dexp3 * s1; @@ -428,7 +428,7 @@ double PairMorseSoft::single(int /*i*/, int /*j*/, int itype, int jtype, double phi *= llf; // Force computation: - if (r == 0.0){ + if (r == 0.0) { fforce = 0.0; } else { fforce = 3.0*a*B*dexp3 + 2.0*a*D*(dexp2 - dexp); diff --git a/src/USER-INTEL/fix_intel.cpp b/src/USER-INTEL/fix_intel.cpp index 95c2ec320a..ea65a91953 100644 --- a/src/USER-INTEL/fix_intel.cpp +++ b/src/USER-INTEL/fix_intel.cpp @@ -783,7 +783,7 @@ void FixIntel::add_oresults(const ft * _noalias const f_in, if (_nthreads > INTEL_HTHREADS) packthreads = _nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { #if defined(_OPENMP) @@ -1266,7 +1266,7 @@ int FixIntel::set_host_affinity(const int nomp) if (nlwp <= plwp) continue; CPU_ZERO(&cpuset); - for(int i=0; i * buffers) { if (comm->nthreads > INTEL_HTHREADS) nthreads = comm->nthreads; else nthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(nthreads > INTEL_HTHREADS) + #pragma omp parallel if (nthreads > INTEL_HTHREADS) #endif { int ifrom, ito, tid; diff --git a/src/USER-INTEL/npair_full_bin_ghost_intel.cpp b/src/USER-INTEL/npair_full_bin_ghost_intel.cpp index 2475b69b8f..d15c5d9d4e 100644 --- a/src/USER-INTEL/npair_full_bin_ghost_intel.cpp +++ b/src/USER-INTEL/npair_full_bin_ghost_intel.cpp @@ -216,7 +216,7 @@ void NPairFullBinGhostIntel::fbi(const int offload, NeighList * list, const int * _noalias const bins = this->bins; const int cop = _fix->coprocessor_number(); const int separate_buffers = _fix->separate_buffers(); - #pragma offload target(mic:cop) if(offload) \ + #pragma offload target(mic:cop) if (offload) \ in(x:length(e_nall+1) alloc_if(0) free_if(0)) \ in(tag:length(tag_size) alloc_if(0) free_if(0)) \ in(special:length(special_size*maxspecial) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/npair_halffull_newton_intel.cpp b/src/USER-INTEL/npair_halffull_newton_intel.cpp index de0fa9c17d..b45c1a8023 100644 --- a/src/USER-INTEL/npair_halffull_newton_intel.cpp +++ b/src/USER-INTEL/npair_halffull_newton_intel.cpp @@ -151,7 +151,7 @@ void NPairHalffullNewtonIntel::build_t3(NeighList *list, int *numhalf) if (comm->nthreads > INTEL_HTHREADS) packthreads = comm->nthreads; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int tid, ifrom, ito; diff --git a/src/USER-INTEL/npair_intel.cpp b/src/USER-INTEL/npair_intel.cpp index 5c6a0cf1b5..c224775a26 100644 --- a/src/USER-INTEL/npair_intel.cpp +++ b/src/USER-INTEL/npair_intel.cpp @@ -211,7 +211,7 @@ void NPairIntel::bin_newton(const int offload, NeighList *list, const int * _noalias const bins = this->bins; const int cop = _fix->coprocessor_number(); const int separate_buffers = _fix->separate_buffers(); - #pragma offload target(mic:cop) if(offload) \ + #pragma offload target(mic:cop) if (offload) \ in(x:length(e_nall+1) alloc_if(0) free_if(0)) \ in(tag:length(tag_size) alloc_if(0) free_if(0)) \ in(special:length(special_size*maxspecial) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/npair_skip_intel.cpp b/src/USER-INTEL/npair_skip_intel.cpp index 5d88fe511d..4f6648ddc1 100644 --- a/src/USER-INTEL/npair_skip_intel.cpp +++ b/src/USER-INTEL/npair_skip_intel.cpp @@ -95,7 +95,7 @@ void NPairSkipIntel::build_t(NeighList *list, int *numhalf, int *cnumneigh, packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int tid, ifrom, ito; diff --git a/src/USER-INTEL/pair_airebo_intel.cpp b/src/USER-INTEL/pair_airebo_intel.cpp index a25a2d403d..f8f094ec9f 100644 --- a/src/USER-INTEL/pair_airebo_intel.cpp +++ b/src/USER-INTEL/pair_airebo_intel.cpp @@ -308,7 +308,7 @@ void PairAIREBOIntel::compute( if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -450,7 +450,7 @@ void PairAIREBOIntel::eval( if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ in(numneigh:length(0) alloc_if(0) free_if(0)) \ in(numneighhalf:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_buck_coul_cut_intel.cpp b/src/USER-INTEL/pair_buck_coul_cut_intel.cpp index 3da131684c..1aec1dcbf7 100644 --- a/src/USER-INTEL/pair_buck_coul_cut_intel.cpp +++ b/src/USER-INTEL/pair_buck_coul_cut_intel.cpp @@ -90,7 +90,7 @@ void PairBuckCoulCutIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -177,7 +177,7 @@ void PairBuckCoulCutIntel::eval(const int offload, const int vflag, const int ncoulshiftbits = this->ncoulshiftbits; if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj,special_coul:length(0) alloc_if(0) free_if(0)) \ in(c_force, c_energy, c_cut:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ @@ -273,10 +273,10 @@ void PairBuckCoulCutIntel::eval(const int offload, const int vflag, forcecoul = qqrd2e * qtmp*q[j]/r; if (EFLAG) ecoul = forcecoul; - if (sbindex){ + if (sbindex) { const flt_t factor_coul = special_coul[sbindex]; forcecoul *= factor_coul; - if(EFLAG) + if (EFLAG) ecoul *= factor_coul; } diff --git a/src/USER-INTEL/pair_buck_coul_long_intel.cpp b/src/USER-INTEL/pair_buck_coul_long_intel.cpp index 6ab255d5d7..d56b0dfd24 100644 --- a/src/USER-INTEL/pair_buck_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_buck_coul_long_intel.cpp @@ -90,7 +90,7 @@ void PairBuckCoulLongIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -200,7 +200,7 @@ void PairBuckCoulLongIntel::eval(const int offload, const int vflag, #endif if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj,special_coul:length(0) alloc_if(0) free_if(0)) \ in(c_force, c_energy:length(0) alloc_if(0) free_if(0)) \ in(rho_inv:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_buck_intel.cpp b/src/USER-INTEL/pair_buck_intel.cpp index afa9b448b5..77f6a1136c 100644 --- a/src/USER-INTEL/pair_buck_intel.cpp +++ b/src/USER-INTEL/pair_buck_intel.cpp @@ -83,7 +83,7 @@ void PairBuckIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -162,7 +162,7 @@ void PairBuckIntel::eval(const int offload, const int vflag, // Redeclare as local variables for offload if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj:length(0) alloc_if(0) free_if(0)) \ in(c_force, c_energy:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_dpd_intel.cpp b/src/USER-INTEL/pair_dpd_intel.cpp index a0a71e4a37..45da3cccd7 100644 --- a/src/USER-INTEL/pair_dpd_intel.cpp +++ b/src/USER-INTEL/pair_dpd_intel.cpp @@ -99,7 +99,7 @@ void PairDPDIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; diff --git a/src/USER-INTEL/pair_eam_alloy_intel.cpp b/src/USER-INTEL/pair_eam_alloy_intel.cpp index 0da792b4e0..04ee07ca82 100644 --- a/src/USER-INTEL/pair_eam_alloy_intel.cpp +++ b/src/USER-INTEL/pair_eam_alloy_intel.cpp @@ -116,7 +116,7 @@ void PairEAMAlloyIntel::read_file(char *filename) Setfl *file = setfl; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam/alloy", unit_convert_flag); // transparently convert units for supported conversions diff --git a/src/USER-INTEL/pair_eam_fs_intel.cpp b/src/USER-INTEL/pair_eam_fs_intel.cpp index 8b1437203f..0eb2cda43d 100644 --- a/src/USER-INTEL/pair_eam_fs_intel.cpp +++ b/src/USER-INTEL/pair_eam_fs_intel.cpp @@ -116,7 +116,7 @@ void PairEAMFSIntel::read_file(char *filename) Fs *file = fs; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam/fs", unit_convert_flag); // transparently convert units for supported conversions diff --git a/src/USER-INTEL/pair_eam_intel.cpp b/src/USER-INTEL/pair_eam_intel.cpp index a25d588ecf..206bdd5ee6 100644 --- a/src/USER-INTEL/pair_eam_intel.cpp +++ b/src/USER-INTEL/pair_eam_intel.cpp @@ -95,7 +95,7 @@ void PairEAMIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; diff --git a/src/USER-INTEL/pair_gayberne_intel.cpp b/src/USER-INTEL/pair_gayberne_intel.cpp index c34c6965de..fd79b5812b 100644 --- a/src/USER-INTEL/pair_gayberne_intel.cpp +++ b/src/USER-INTEL/pair_gayberne_intel.cpp @@ -93,7 +93,7 @@ void PairGayBerneIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -276,7 +276,7 @@ void PairGayBerneIntel::eval(const int offload, const int vflag, double *timer_compute = fix->off_watch_pair(); if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj:length(0) alloc_if(0) free_if(0)) \ in(ijc,lj34,ic:length(0) alloc_if(0) free_if(0)) \ in(rsq_formi, delx_formi, dely_formi: length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp b/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp index 8f4dba4a24..850af0de6f 100644 --- a/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp +++ b/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp @@ -86,7 +86,7 @@ void PairLJCharmmCoulCharmmIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -184,7 +184,7 @@ void PairLJCharmmCoulCharmmIntel::eval(const int offload, const int vflag, double *timer_compute = fix->off_watch_pair(); if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj,special_coul:length(0) alloc_if(0) free_if(0)) \ in(cutsq,lj:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp b/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp index ffed4853ba..ad15c045ab 100644 --- a/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp @@ -87,7 +87,7 @@ void PairLJCharmmCoulLongIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -202,7 +202,7 @@ void PairLJCharmmCoulLongIntel::eval(const int offload, const int vflag, #endif if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj,special_coul:length(0) alloc_if(0) free_if(0)) \ in(cutsq,lj:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp b/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp index c1d85ad37f..d6d763677c 100644 --- a/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp @@ -88,7 +88,7 @@ void PairLJCutCoulLongIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -197,7 +197,7 @@ void PairLJCutCoulLongIntel::eval(const int offload, const int vflag, #endif if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj,special_coul:length(0) alloc_if(0) free_if(0)) \ in(c_force, c_energy:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_lj_cut_intel.cpp b/src/USER-INTEL/pair_lj_cut_intel.cpp index 8697a4f548..6499f1cec8 100644 --- a/src/USER-INTEL/pair_lj_cut_intel.cpp +++ b/src/USER-INTEL/pair_lj_cut_intel.cpp @@ -79,7 +79,7 @@ void PairLJCutIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; diff --git a/src/USER-INTEL/pair_sw_intel.cpp b/src/USER-INTEL/pair_sw_intel.cpp index 1af8d3e972..984b2100a3 100644 --- a/src/USER-INTEL/pair_sw_intel.cpp +++ b/src/USER-INTEL/pair_sw_intel.cpp @@ -110,7 +110,7 @@ void PairSWIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -227,7 +227,7 @@ void PairSWIntel::eval(const int offload, const int vflag, int *overflow = fix->get_off_overflow_flag(); if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(p2,p2f,p2f2,p2e,p3:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ in(cnumneigh:length(0) alloc_if(0) free_if(0)) \ @@ -646,7 +646,7 @@ void PairSWIntel::eval(const int offload, const int vflag, int *overflow = fix->get_off_overflow_flag(); if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(p2,p2f,p2f2,p2e,p3:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ in(cnumneigh:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_tersoff_intel.cpp b/src/USER-INTEL/pair_tersoff_intel.cpp index b86be522bf..bce2045f26 100644 --- a/src/USER-INTEL/pair_tersoff_intel.cpp +++ b/src/USER-INTEL/pair_tersoff_intel.cpp @@ -123,7 +123,7 @@ void PairTersoffIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -309,7 +309,7 @@ void PairTersoffIntel::eval(const int offload, const int vflag, int *overflow = fix->get_off_overflow_flag(); double *timer_compute = fix->off_watch_pair(); if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(c_inner, c_outer :length(0) alloc_if(0) free_if(0)) \ in(c_inner_cutoff :length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pppm_disp_intel.cpp b/src/USER-INTEL/pppm_disp_intel.cpp index 5a119e4470..88fb6374ab 100644 --- a/src/USER-INTEL/pppm_disp_intel.cpp +++ b/src/USER-INTEL/pppm_disp_intel.cpp @@ -148,7 +148,7 @@ void PPPMDispIntel::init() memory->create(rho6_lookup, rho_points, INTEL_P3M_ALIGNED_MAXORDER, "pppmdispintel:rho6_lookup"); - if(differentiation_flag == 1) { + if (differentiation_flag == 1) { memory->destroy(drho_lookup); memory->create(drho_lookup, rho_points, INTEL_P3M_ALIGNED_MAXORDER, "pppmdispintel:drho_lookup"); @@ -198,7 +198,7 @@ void PPPMDispIntel::compute(int eflag, int vflag) memory->destroy(particle_ekx); memory->destroy(particle_eky); memory->destroy(particle_ekz); - if (function[2] == 1){ + if (function[2] == 1) { memory->destroy(particle_ekx0); memory->destroy(particle_eky0); memory->destroy(particle_ekz0); @@ -231,7 +231,7 @@ void PPPMDispIntel::compute(int eflag, int vflag) memory->create(particle_ekx, nmax, "pppmdispintel:pekx"); memory->create(particle_eky, nmax, "pppmdispintel:peky"); memory->create(particle_ekz, nmax, "pppmdispintel:pekz"); - if (function[2] == 1){ + if (function[2] == 1) { memory->create(particle_ekx0, nmax, "pppmdispintel:pekx0"); memory->create(particle_eky0, nmax, "pppmdispintel:peky0"); memory->create(particle_ekz0, nmax, "pppmdispintel:pekz0"); @@ -752,7 +752,7 @@ void PPPMDispIntel::particle_map(double delx, double dely, double delz, #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ shared(nlocal, nthr, delx, dely, delz, sft, p2g, nup, nlow, nxlo,\ - nylo, nzlo, nxhi, nyhi, nzhi) reduction(+:flag) if(!_use_lrt) + nylo, nzlo, nxhi, nyhi, nzhi) reduction(+:flag) if (!_use_lrt) #endif { double **x = atom->x; @@ -825,7 +825,7 @@ void PPPMDispIntel::make_rho_c(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, nlocal, global_density) if(!_use_lrt) + shared(nthr, nlocal, global_density) if (!_use_lrt) #endif { double *q = atom->q; @@ -877,7 +877,7 @@ void PPPMDispIntel::make_rho_c(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho_lookup[idx][k]; rho[1][k] = rho_lookup[idy][k]; rho[2][k] = rho_lookup[idz][k]; @@ -931,7 +931,7 @@ void PPPMDispIntel::make_rho_c(IntelBuffers * /*buffers*/) // reduce all the perthread_densities into global_density #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, global_density) if(!_use_lrt) + shared(nthr, global_density) if (!_use_lrt) #endif { int ifrom, ito, tid; @@ -941,7 +941,7 @@ void PPPMDispIntel::make_rho_c(IntelBuffers * /*buffers*/) #pragma simd #endif for (int i = ifrom; i < ito; i++) { - for(int j = 1; j < nthr; j++) { + for (int j = 1; j < nthr; j++) { global_density[i] += perthread_density[j-1][i]; } } @@ -973,7 +973,7 @@ void PPPMDispIntel::make_rho_g(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, nlocal, global_density) if(!_use_lrt) + shared(nthr, nlocal, global_density) if (!_use_lrt) #endif { int type; @@ -1026,7 +1026,7 @@ void PPPMDispIntel::make_rho_g(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho6_lookup[idx][k]; rho[1][k] = rho6_lookup[idy][k]; rho[2][k] = rho6_lookup[idz][k]; @@ -1081,7 +1081,7 @@ void PPPMDispIntel::make_rho_g(IntelBuffers * /*buffers*/) // reduce all the perthread_densities into global_density #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, global_density) if(!_use_lrt) + shared(nthr, global_density) if (!_use_lrt) #endif { int ifrom, ito, tid; @@ -1091,7 +1091,7 @@ void PPPMDispIntel::make_rho_g(IntelBuffers * /*buffers*/) #pragma simd #endif for (int i = ifrom; i < ito; i++) { - for(int j = 1; j < nthr; j++) { + for (int j = 1; j < nthr; j++) { global_density[i] += perthread_density[j-1][i]; } } @@ -1174,7 +1174,7 @@ void PPPMDispIntel::make_rho_a(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho6_lookup[idx][k]; rho[1][k] = rho6_lookup[idy][k]; rho[2][k] = rho6_lookup[idz][k]; @@ -1256,7 +1256,7 @@ void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, nlocal, global_density) if(!_use_lrt) + shared(nthr, nlocal, global_density) if (!_use_lrt) #endif { int type; @@ -1308,7 +1308,7 @@ void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho6_lookup[idx][k]; rho[1][k] = rho6_lookup[idy][k]; rho[2][k] = rho6_lookup[idz][k]; @@ -1354,7 +1354,7 @@ void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) for (int l = 0; l < order; l++) { int mzyx = l + mzy; FFT_SCALAR w0 = x0*rho[0][l]; - for(int k = 0; k < nsplit; k++) + for (int k = 0; k < nsplit; k++) my_density[mzyx + k*ngrid_6] += x0*rho[0][l]; } } @@ -1365,7 +1365,7 @@ void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) // reduce all the perthread_densities into global_density #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, global_density) if(!_use_lrt) + shared(nthr, global_density) if (!_use_lrt) #endif { int ifrom, ito, tid; @@ -1375,7 +1375,7 @@ void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) #pragma simd #endif for (int i = ifrom; i < ito; i++) { - for(int j = 1; j < nthr; j++) { + for (int j = 1; j < nthr; j++) { global_density[i] += perthread_density[j-1][i]; } } @@ -1408,7 +1408,7 @@ void PPPMDispIntel::fieldforce_c_ik(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -1558,7 +1558,7 @@ void PPPMDispIntel::fieldforce_c_ad(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -1625,7 +1625,7 @@ void PPPMDispIntel::fieldforce_c_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho_lookup[idx][k]; rho[1][k] = rho_lookup[idy][k]; rho[2][k] = rho_lookup[idz][k]; @@ -1694,7 +1694,7 @@ void PPPMDispIntel::fieldforce_c_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma loop_count min(2), max(INTEL_P3M_ALIGNED_MAXORDER), avg(7) #endif - for (int l = 0; l < order; l++){ + for (int l = 0; l < order; l++) { particle_ekx[i] += ekx[l]; particle_eky[i] += eky[l]; particle_ekz[i] += ekz[l]; @@ -1756,7 +1756,7 @@ void PPPMDispIntel::fieldforce_g_ik(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -1903,7 +1903,7 @@ void PPPMDispIntel::fieldforce_g_ad(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -1968,7 +1968,7 @@ void PPPMDispIntel::fieldforce_g_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho6_lookup[idx][k]; rho[1][k] = rho6_lookup[idy][k]; rho[2][k] = rho6_lookup[idz][k]; @@ -2037,7 +2037,7 @@ void PPPMDispIntel::fieldforce_g_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma loop_count min(2), max(INTEL_P3M_ALIGNED_MAXORDER), avg(7) #endif - for (int l = 0; l < order; l++){ + for (int l = 0; l < order; l++) { particle_ekx[i] += ekx[l]; particle_eky[i] += eky[l]; particle_ekz[i] += ekz[l]; @@ -2100,7 +2100,7 @@ void PPPMDispIntel::fieldforce_a_ik(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { double **x = atom->x; @@ -2334,7 +2334,7 @@ void PPPMDispIntel::fieldforce_a_ad(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -2399,7 +2399,7 @@ void PPPMDispIntel::fieldforce_a_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho6_lookup[idx][k]; rho[1][k] = rho6_lookup[idy][k]; rho[2][k] = rho6_lookup[idz][k]; @@ -2515,7 +2515,7 @@ void PPPMDispIntel::fieldforce_a_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma loop_count min(2), max(INTEL_P3M_ALIGNED_MAXORDER), avg(7) #endif - for (int l = 0; l < order; l++){ + for (int l = 0; l < order; l++) { particle_ekx0[i] += ekx0[l]; particle_eky0[i] += eky0[l]; particle_ekz0[i] += ekz0[l]; @@ -2625,7 +2625,7 @@ void PPPMDispIntel::fieldforce_none_ik(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -2784,7 +2784,7 @@ void PPPMDispIntel::fieldforce_none_ad(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -2849,7 +2849,7 @@ void PPPMDispIntel::fieldforce_none_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho6_lookup[idx][k]; rho[1][k] = rho6_lookup[idy][k]; rho[2][k] = rho6_lookup[idz][k]; @@ -2934,7 +2934,7 @@ void PPPMDispIntel::fieldforce_none_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma loop_count min(2), max(INTEL_P3M_ALIGNED_MAXORDER), avg(7) #endif - for (int l = 0; l < order; l++){ + for (int l = 0; l < order; l++) { for (int k = 0; k < nsplit; k++) { ekx_tot[k] += ekx[k*INTEL_P3M_ALIGNED_MAXORDER+l]; eky_tot[k] += eky[k*INTEL_P3M_ALIGNED_MAXORDER+l]; @@ -2993,9 +2993,9 @@ void PPPMDispIntel::precompute_rho() #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for (int k=nlower; k<=nupper;k++){ + for (int k=nlower; k<=nupper;k++) { FFT_SCALAR r1 = ZEROF; - for(int l=order-1; l>=0; l--){ + for (int l=order-1; l>=0; l--) { r1 = rho_coeff[l][k] + r1*dx; } rho_lookup[i][k-nlower] = r1; @@ -3007,9 +3007,9 @@ void PPPMDispIntel::precompute_rho() #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k=nlower; k<=nupper;k++){ + for (int k=nlower; k<=nupper;k++) { FFT_SCALAR r1 = ZEROF; - for(int l=order-2; l>=0; l--){ + for (int l=order-2; l>=0; l--) { r1 = drho_coeff[l][k] + r1*dx; } drho_lookup[i][k-nlower] = r1; @@ -3027,9 +3027,9 @@ void PPPMDispIntel::precompute_rho() #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for (int k=nlower_6; k<=nupper_6;k++){ + for (int k=nlower_6; k<=nupper_6;k++) { FFT_SCALAR r1 = ZEROF; - for(int l=order_6-1; l>=0; l--){ + for (int l=order_6-1; l>=0; l--) { r1 = rho_coeff_6[l][k] + r1*dx; } rho6_lookup[i][k-nlower_6] = r1; @@ -3041,9 +3041,9 @@ void PPPMDispIntel::precompute_rho() #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k=nlower_6; k<=nupper_6;k++){ + for (int k=nlower_6; k<=nupper_6;k++) { FFT_SCALAR r1 = ZEROF; - for(int l=order_6-2; l>=0; l--){ + for (int l=order_6-2; l>=0; l--) { r1 = drho_coeff_6[l][k] + r1*dx; } drho6_lookup[i][k-nlower_6] = r1; diff --git a/src/USER-INTEL/pppm_intel.cpp b/src/USER-INTEL/pppm_intel.cpp index bf55dc3d2e..6e836dd3b3 100644 --- a/src/USER-INTEL/pppm_intel.cpp +++ b/src/USER-INTEL/pppm_intel.cpp @@ -125,7 +125,7 @@ void PPPMIntel::init() memory->destroy(rho_lookup); memory->create(rho_lookup, rho_points, INTEL_P3M_ALIGNED_MAXORDER, "pppmintel:rho_lookup"); - if(differentiation_flag == 1) { + if (differentiation_flag == 1) { memory->destroy(drho_lookup); memory->create(drho_lookup, rho_points, INTEL_P3M_ALIGNED_MAXORDER, "pppmintel:drho_lookup"); @@ -378,7 +378,7 @@ void PPPMIntel::particle_map(IntelBuffers *buffers) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) reduction(+:flag) if(!_use_lrt) + shared(nlocal, nthr) reduction(+:flag) if (!_use_lrt) #endif { const flt_t lo0 = boxlo[0]; @@ -452,7 +452,7 @@ void PPPMIntel::make_rho(IntelBuffers *buffers) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, nlocal, global_density) if(!_use_lrt) + shared(nthr, nlocal, global_density) if (!_use_lrt) #endif { const int nix = nxhi_out - nxlo_out + 1; @@ -501,7 +501,7 @@ void PPPMIntel::make_rho(IntelBuffers *buffers) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho_lookup[idx][k]; rho[1][k] = rho_lookup[idy][k]; rho[2][k] = rho_lookup[idz][k]; @@ -555,7 +555,7 @@ void PPPMIntel::make_rho(IntelBuffers *buffers) if (nthr > 1) { #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, global_density) if(!_use_lrt) + shared(nthr, global_density) if (!_use_lrt) #endif { int ifrom, ito, tid; @@ -565,7 +565,7 @@ void PPPMIntel::make_rho(IntelBuffers *buffers) #pragma simd #endif for (int i = ifrom; i < ito; i++) { - for(int j = 1; j < nthr; j++) { + for (int j = 1; j < nthr; j++) { global_density[i] += perthread_density[j-1][i]; } } @@ -604,7 +604,7 @@ void PPPMIntel::fieldforce_ik(IntelBuffers *buffers) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { const flt_t lo0 = boxlo[0]; @@ -755,7 +755,7 @@ void PPPMIntel::fieldforce_ad(IntelBuffers *buffers) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { const flt_t ftwo_pi = MY_PI * 2.0; @@ -814,7 +814,7 @@ void PPPMIntel::fieldforce_ad(IntelBuffers *buffers) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho_lookup[idx][k]; rho[1][k] = rho_lookup[idy][k]; rho[2][k] = rho_lookup[idz][k]; @@ -884,7 +884,7 @@ void PPPMIntel::fieldforce_ad(IntelBuffers *buffers) #if defined(LMP_SIMD_COMPILER) #pragma loop_count min(2), max(INTEL_P3M_ALIGNED_MAXORDER), avg(7) #endif - for (int l = 0; l < order; l++){ + for (int l = 0; l < order; l++) { particle_ekx[i] += ekx[l]; particle_eky[i] += eky[l]; particle_ekz[i] += ekz[l]; @@ -943,9 +943,9 @@ void PPPMIntel::precompute_rho() #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for (int k=nlower; k<=nupper;k++){ + for (int k=nlower; k<=nupper;k++) { FFT_SCALAR r1 = ZEROF; - for(int l=order-1; l>=0; l--){ + for (int l=order-1; l>=0; l--) { r1 = rho_coeff[l][k] + r1*dx; } rho_lookup[i][k-nlower] = r1; @@ -957,9 +957,9 @@ void PPPMIntel::precompute_rho() #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k=nlower; k<=nupper;k++){ + for (int k=nlower; k<=nupper;k++) { FFT_SCALAR r1 = ZEROF; - for(int l=order-2; l>=0; l--){ + for (int l=order-2; l>=0; l--) { r1 = drho_coeff[l][k] + r1*dx; } drho_lookup[i][k-nlower] = r1; @@ -1005,7 +1005,7 @@ void PPPMIntel::pack_buffers() if (comm->nthreads > INTEL_HTHREADS) packthreads = comm->nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; diff --git a/src/USER-LB/fix_lb_fluid.cpp b/src/USER-LB/fix_lb_fluid.cpp index bf67502759..351e078dad 100644 --- a/src/USER-LB/fix_lb_fluid.cpp +++ b/src/USER-LB/fix_lb_fluid.cpp @@ -84,7 +84,7 @@ FixLbFluid::FixLbFluid(LAMMPS *lmp, int narg, char **arg) : // the 15 velocity D3Q15 model is used. //===================================================================================================== - if(narg <7) error->all(FLERR,"Illegal fix lb/fluid command"); + if (narg <7) error->all(FLERR,"Illegal fix lb/fluid command"); if (comm->style != 0) error->universe_all(FLERR,"Fix lb/fluid can only currently be used with " @@ -120,73 +120,73 @@ FixLbFluid::FixLbFluid(LAMMPS *lmp, int narg, char **arg) : NodeArea = nullptr; int iarg = 7; - while (iarg < narg){ - if(strcmp(arg[iarg],"setArea")==0){ - if(setGamma == 1) + while (iarg < narg) { + if (strcmp(arg[iarg],"setArea")==0) { + if (setGamma == 1) error->all(FLERR,"Illegal fix lb/fluid command: cannot use a combination of default and user-specified gamma values"); setArea = 1; int itype = atoi(arg[iarg+1]); double areafactor = atof(arg[iarg+2]); - if(itype <= 0 || itype > atom->ntypes || areafactor < 0.0) + if (itype <= 0 || itype > atom->ntypes || areafactor < 0.0) error->all(FLERR,"Illegal fix lb/fluid command: setArea"); - if(NodeArea == nullptr){ + if (NodeArea == nullptr) { NodeArea = new double[atom->ntypes+1]; - for(int i=0; i<=atom->ntypes; i++) NodeArea[i] = -1.0; + for (int i=0; i<=atom->ntypes; i++) NodeArea[i] = -1.0; } NodeArea[itype] = areafactor; iarg += 3; } - else if(strcmp(arg[iarg],"setGamma")==0){ - if(setArea == 1) + else if (strcmp(arg[iarg],"setGamma")==0) { + if (setArea == 1) error->all(FLERR,"Illegal fix lb/fluid command: cannot use a combination of default and user-specified gamma values"); setGamma = 1; double Gammaone; Gammaone = atof(arg[iarg+1]); - if(Gamma == nullptr) + if (Gamma == nullptr) Gamma = new double[atom->ntypes+1]; - for(int i=0; i<=atom->ntypes; i++) Gamma[i] = Gammaone; + for (int i=0; i<=atom->ntypes; i++) Gamma[i] = Gammaone; iarg += 2; } - else if(strcmp(arg[iarg],"scaleGamma")==0){ - if(setGamma == 0) + else if (strcmp(arg[iarg],"scaleGamma")==0) { + if (setGamma == 0) error->all(FLERR,"Illegal fix lb/fluid command: must set a value for Gamma before scaling it"); int itype = atoi(arg[iarg+1]); double scalefactor = atof(arg[iarg+2]); - if(itype <= 0 || itype > atom->ntypes || scalefactor < 0.0) + if (itype <= 0 || itype > atom->ntypes || scalefactor < 0.0) error->all(FLERR,"Illegal fix lb/fluid command: scaleGamma"); Gamma[itype] *= scalefactor; iarg += 3; } - else if(strcmp(arg[iarg],"dx")==0){ + else if (strcmp(arg[iarg],"dx")==0) { dx_lb = atof(arg[iarg+1]); iarg += 2; setdx = 0; } - else if(strcmp(arg[iarg],"dm")==0){ + else if (strcmp(arg[iarg],"dm")==0) { dm_lb = atof(arg[iarg+1]); iarg += 2; } - else if(strcmp(arg[iarg],"a0")==0){ + else if (strcmp(arg[iarg],"a0")==0) { a_0_real = atof(arg[iarg+1]); iarg += 2; seta0 = 0; } - else if(strcmp(arg[iarg],"noise")== 0){ + else if (strcmp(arg[iarg],"noise")== 0) { noisestress = 1; T = atof(arg[iarg+1]); seed = atoi(arg[iarg+2]); iarg += 3; } - else if(strcmp(arg[iarg],"calcforce")==0){ + else if (strcmp(arg[iarg],"calcforce")==0) { force_diagnostic = atoi(arg[iarg+1]); igroupforce=group->find(arg[iarg+2]); iarg += 3; } - else if(strcmp(arg[iarg],"trilinear")==0){ + else if (strcmp(arg[iarg],"trilinear")==0) { trilinear_stencil = 1; iarg += 1; } - else if(strcmp(arg[iarg],"read_restart")==0){ + else if (strcmp(arg[iarg],"read_restart")==0) { readrestart = 1; int nlength = strlen(arg[iarg+1]) + 16; char *filename = new char[nlength]; @@ -195,28 +195,28 @@ FixLbFluid::FixLbFluid(LAMMPS *lmp, int narg, char **arg) : delete [] filename; iarg += 2; } - else if(strcmp(arg[iarg],"write_restart")==0){ + else if (strcmp(arg[iarg],"write_restart")==0) { printrestart = atoi(arg[iarg+1]); iarg += 2; } - else if(strcmp(arg[iarg],"zwall_velocity")==0){ - if(domain->periodicity[2]!=0) error->all(FLERR,"fix lb/fluid error: setting \ + else if (strcmp(arg[iarg],"zwall_velocity")==0) { + if (domain->periodicity[2]!=0) error->all(FLERR,"fix lb/fluid error: setting \ a z wall velocity without implementing fixed BCs in z"); vwbt = atof(arg[iarg+1]); vwtp = atof(arg[iarg+2]); iarg += 3; } - else if(strcmp(arg[iarg],"bodyforce")==0){ + else if (strcmp(arg[iarg],"bodyforce")==0) { bodyforcex = atof(arg[iarg+1]); bodyforcey = atof(arg[iarg+2]); bodyforcez = atof(arg[iarg+3]); iarg += 4; } - else if(strcmp(arg[iarg],"printfluid")==0){ + else if (strcmp(arg[iarg],"printfluid")==0) { printfluid = atoi(arg[iarg+1]); iarg += 2; } - else if(strcmp(arg[iarg],"D3Q19")==0){ + else if (strcmp(arg[iarg],"D3Q19")==0) { numvel = 19; iarg += 1; } @@ -226,7 +226,7 @@ a z wall velocity without implementing fixed BCs in z"); //-------------------------------------------------------------------------- //Choose between D3Q15 and D3Q19 functions: //-------------------------------------------------------------------------- - if(numvel == 15){ + if (numvel == 15) { initializeLB = &FixLbFluid::initializeLB15; equilibriumdist = &FixLbFluid::equilibriumdist15; update_full = &FixLbFluid::update_full15; @@ -244,8 +244,8 @@ a z wall velocity without implementing fixed BCs in z"); grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); - for(int i=0; inmax; i++) - for(int j=0; j<3; j++) + for (int i=0; inmax; i++) + for (int j=0; j<3; j++) hydroF[i][j] = 0.0; Ng_lb = nullptr; @@ -276,12 +276,12 @@ a z wall velocity without implementing fixed BCs in z"); // Set the lattice Boltzmann dx if it wasn't specified in the // input. //-------------------------------------------------------------------------- - if(setdx == 1){ + if (setdx == 1) { double dx_lb1 = sqrt(3.0*viscosity*dt_lb/densityinit_real); double mindomain = std::min(std::min(domain->xprd/comm->procgrid[0],domain->yprd/comm->procgrid[1]),domain->zprd/comm->procgrid[2]); dx_lb = mindomain/floor(mindomain/dx_lb1); - if(comm->me==0){ + if (comm->me==0) { char str[128]; sprintf(str,"Setting the lattice-Boltzmann dx to %10.6f",dx_lb); error->message(FLERR,str); @@ -291,21 +291,21 @@ a z wall velocity without implementing fixed BCs in z"); // If the area per node has not been set by the user, set to the // default value of dx_lb*dx_lb. //-------------------------------------------------------------------------- - if(setGamma == 0){ - if(setArea == 0){ - if(comm->me==0){ + if (setGamma == 0) { + if (setArea == 0) { + if (comm->me==0) { error->message(FLERR,"Assuming an area per node of dx*dx for all of the MD particles. This should only be used if these all correspond to point particles; otherwise, change using the setArea keyword"); } NodeArea = new double[atom->ntypes+1]; - for(int i=0; i<=atom->ntypes; i++) NodeArea[i] = -1.0; + for (int i=0; i<=atom->ntypes; i++) NodeArea[i] = -1.0; } - for(int i=0; i<=atom->ntypes; i++) - if(NodeArea[i] < 0.0) NodeArea[i] = dx_lb*dx_lb; + for (int i=0; i<=atom->ntypes; i++) + if (NodeArea[i] < 0.0) NodeArea[i] = dx_lb*dx_lb; } //-------------------------------------------------------------------------- // Set a0 if it wasn't specified in the input //-------------------------------------------------------------------------- - if(seta0 == 1) + if (seta0 == 1) a_0_real = 0.33333333*dx_lb*dx_lb/dt_lb/dt_lb; //-------------------------------------------------------------------------- @@ -319,8 +319,8 @@ a z wall velocity without implementing fixed BCs in z"); double aa; double eps=1.0e-8; aa = (domain->xprd/comm->procgrid[0])/dx_lb; - if(fabs(aa - floor(aa+0.5)) > eps){ - if(domain->boundary[0][0] != 0){ + if (fabs(aa - floor(aa+0.5)) > eps) { + if (domain->boundary[0][0] != 0) { error->all(FLERR,"the x-direction must be periodic"); } char errormessage[200]; @@ -328,8 +328,8 @@ a z wall velocity without implementing fixed BCs in z"); error->all(FLERR,errormessage); } aa = (domain->yprd/comm->procgrid[1])/dx_lb; - if(fabs(aa - floor(aa+0.5)) > eps){ - if(domain->boundary[1][0] != 0){ + if (fabs(aa - floor(aa+0.5)) > eps) { + if (domain->boundary[1][0] != 0) { error->all(FLERR,"the y-direction must be periodic"); } char errormessage[200]; @@ -337,8 +337,8 @@ a z wall velocity without implementing fixed BCs in z"); error->all(FLERR,errormessage); } aa = (domain->zprd/comm->procgrid[2])/dx_lb; - if(fabs(aa - floor(aa+0.5)) > eps){ - if(domain->boundary[2][0] == 2 || domain->boundary[2][0] == 3){ + if (fabs(aa - floor(aa+0.5)) > eps) { + if (domain->boundary[2][0] == 2 || domain->boundary[2][0] == 3) { error->all(FLERR,"the z-direction can not have shrink-wrap boundary conditions"); } char errormessage[200]; @@ -364,19 +364,19 @@ a z wall velocity without implementing fixed BCs in z"); // In order to calculate the fluid forces correctly, need to have atleast // 5 grid points in each direction per processor. //-------------------------------------------------------------------------- - if(subNbx<7 || subNby < 7 || subNbz<7) + if (subNbx<7 || subNby < 7 || subNbz<7) error->all(FLERR,"Need at least 5 grid points in each direction per processor"); // If there are walls in the z-direction add an extra grid point. - if(domain->periodicity[2]==0){ + if (domain->periodicity[2]==0) { Nbz += 1; - if(comm->myloc[2]==comm->procgrid[2]-1) + if (comm->myloc[2]==comm->procgrid[2]-1) subNbz += 1; } - if(comm->me==0){ + if (comm->me==0) { char str[128]; - if(setdx == 1){ + if (setdx == 1) { sprintf(str,"Using a lattice-Boltzmann grid of %i by %i by %i total grid points. To change, use the dx keyword",Nbx,Nby,Nbz); } else { sprintf(str,"Using a lattice-Boltzmann grid of %i by %i by %i total grid points.",Nbx,Nby,Nbz); @@ -471,7 +471,7 @@ a z wall velocity without implementing fixed BCs in z"); memory->create(mg_lb,numvel,numvel,"FixLbFluid:mg_lb"); memory->create(e,numvel,3,"FixLbFluid:e"); memory->create(feq,subNbx,subNby,subNbz,numvel,"FixLbFluid:feq"); - if(typeLB == 2){ + if (typeLB == 2) { memory->create(feqold,subNbx,subNby,subNbz,numvel,"FixLbFluid:feqold"); memory->create(feqn,subNbx,subNby,subNbz,numvel,"FixLbFluid:feqn"); memory->create(feqoldn,subNbx,subNby,subNbz,numvel,"FixLbFluid:feqoldn"); @@ -480,9 +480,9 @@ a z wall velocity without implementing fixed BCs in z"); memory->create(fnew,subNbx,subNby,subNbz,numvel,"FixLbFluid:fnew"); memory->create(density_lb,subNbx+3,subNby+3,subNbz+3,"FixLbFluid:density_lb"); memory->create(u_lb,subNbx+3,subNby+3,subNbz+3,3,"FixLbFluid:u_lb"); - if(printfluid > 0){ + if (printfluid > 0) { memory->create(buf,subNbx,subNby,subNbzmax,4,"FixLbFluid:buf"); - if(me==0) + if (me==0) memory->create(altogether,Nbx,Nby,Nbz,4,"FixLbFluid:altogether"); } memory->create(Ff,subNbx+3,subNby+3,subNbz+3,3,"FixLbFluid:Ff"); @@ -490,7 +490,7 @@ a z wall velocity without implementing fixed BCs in z"); memory->create(Fftempy,subNbx+3,5,subNbz+3,3,"FixLbFluid:Fftempy"); memory->create(Fftempz,subNbx+3,subNby+3,5,3,"FixLbFluid:Fftempz"); - if(noisestress==1){ + if (noisestress==1) { random = new RanMars(lmp,seed + comm->me); } @@ -518,7 +518,7 @@ FixLbFluid::~FixLbFluid() memory->destroy(mg_lb); memory->destroy(e); memory->destroy(feq); - if(typeLB == 2){ + if (typeLB == 2) { memory->destroy(feqold); memory->destroy(feqn); memory->destroy(feqoldn); @@ -527,8 +527,8 @@ FixLbFluid::~FixLbFluid() memory->destroy(fnew); memory->destroy(density_lb); memory->destroy(u_lb); - if(printfluid>0){ - if(me==0) + if (printfluid>0) { + if (me==0) memory->destroy(altogether); memory->destroy(buf); } @@ -537,11 +537,11 @@ FixLbFluid::~FixLbFluid() memory->destroy(Fftempy); memory->destroy(Fftempz); - if(noisestress==1){ + if (noisestress==1) { delete random; } - if(setGamma == 1){ + if (setGamma == 1) { delete [] Gamma; } else { delete [] NodeArea; @@ -583,7 +583,7 @@ void FixLbFluid::init(void) double dt_lb_now; dt_lb_now=nevery*(update->dt); - if(fabs(dt_lb_now - dt_lb) > 1.0e-12){ + if (fabs(dt_lb_now - dt_lb) > 1.0e-12) { error->warning(FLERR,"Timestep has changed between runs with the same lb/fluid. Unphysical results may occur"); } @@ -596,11 +596,11 @@ void FixLbFluid::init(void) Nby_now = (int)(domain->yprd/dx_lb + 0.5); Nbz_now = (int)(domain->zprd/dx_lb + 0.5); // If there are walls in the z-direction add an extra grid point. - if(domain->periodicity[2]==0){ + if (domain->periodicity[2]==0) { Nbz_now += 1; } - if(Nbx_now != Nbx || Nby_now != Nby || Nbz_now != Nbz){ + if (Nbx_now != Nbx || Nby_now != Nby || Nbz_now != Nbz) { error->all(FLERR,"the simulation domain can not change shape between runs with the same lb/fluid"); } @@ -610,13 +610,13 @@ void FixLbFluid::init(void) // shrink-wrap is not compatible in any dimension. // fixed only works in the z-direction. //-------------------------------------------------------------------------- - if(domain->boundary[0][0] != 0){ + if (domain->boundary[0][0] != 0) { error->all(FLERR,"the x-direction must be periodic"); } - if(domain->boundary[1][0] != 0){ + if (domain->boundary[1][0] != 0) { error->all(FLERR,"the y-direction must be periodic"); } - if(domain->boundary[2][0] == 2 || domain->boundary[2][0] == 3){ + if (domain->boundary[2][0] == 2 || domain->boundary[2][0] == 3) { error->all(FLERR,"the z-direction can not have shrink-wrap boundary conditions"); } @@ -624,33 +624,33 @@ void FixLbFluid::init(void) // Check if the lb/viscous fix is also called: //-------------------------------------------------------------------------- groupbit_viscouslb = groupbit_pc = groupbit_rigid_pc_sphere = 0; - for (i = 0; i < modify->nfix; i++){ - if (strcmp(modify->fix[i]->style,"lb/viscous") == 0){ + for (i = 0; i < modify->nfix; i++) { + if (strcmp(modify->fix[i]->style,"lb/viscous") == 0) { fixviscouslb = 1; groupbit_viscouslb = group->bitmask[modify->fix[i]->igroup]; } - if(strcmp(modify->fix[i]->style,"lb/pc")==0){ + if (strcmp(modify->fix[i]->style,"lb/pc")==0) { groupbit_pc = group->bitmask[modify->fix[i]->igroup]; } - if(strcmp(modify->fix[i]->style,"lb/rigid/pc/sphere")==0){ + if (strcmp(modify->fix[i]->style,"lb/rigid/pc/sphere")==0) { groupbit_rigid_pc_sphere = group->bitmask[modify->fix[i]->igroup]; } } // Warn if the fluid force is not applied to any of the particles. - if(!(groupbit_viscouslb || groupbit_pc || groupbit_rigid_pc_sphere) && comm->me==0){ + if (!(groupbit_viscouslb || groupbit_pc || groupbit_rigid_pc_sphere) && comm->me==0) { error->message(FLERR,"Not adding the fluid force to any of the MD particles. To add this force use one of the lb/viscous, lb/pc, or lb/rigid/pc/sphere fixes"); } // If fix lb/viscous is called for a particular atom, make sure // lb/pc or lb/rigid/pc/sphere are not: - if(fixviscouslb == 1){ + if (fixviscouslb == 1) { int *mask = atom->mask; int nlocal = atom->nlocal; - for(j=0; jone(FLERR,"should not use the lb/viscous command when integrating with the lb/pc fix"); - if((mask[j] & groupbit) && (mask[j] & groupbit_viscouslb) && (mask[j] & groupbit_rigid_pc_sphere)) + if ((mask[j] & groupbit) && (mask[j] & groupbit_viscouslb) && (mask[j] & groupbit_rigid_pc_sphere)) error->one(FLERR,"should not use the lb/viscous command when integrating with the lb/rigid/pc/sphere fix"); } } @@ -662,7 +662,7 @@ void FixLbFluid::setup(int /*vflag*/) //-------------------------------------------------------------------------- // Need to calculate the force on the fluid for a restart run. //-------------------------------------------------------------------------- - if(step > 0) + if (step > 0) calc_fluidforce(); } @@ -673,14 +673,14 @@ void FixLbFluid::initial_integrate(int /*vflag*/) //-------------------------------------------------------------------------- static int printheader = 1; - if(printheader == 1){ - if(force_diagnostic > 0 && me == 0){ + if (printheader == 1) { + if (force_diagnostic > 0 && me == 0) { printf("-------------------------------------------------------------------------------\n"); printf(" F_x F_y F_z T_x T_y T_z\n"); printf("-------------------------------------------------------------------------------\n"); } - if(printfluid > 0 && me == 0){ + if (printfluid > 0 && me == 0) { printf("---------------------------------------------------------------------\n"); printf(" density u_x u_y u_z \n"); printf("---------------------------------------------------------------------\n"); @@ -710,7 +710,7 @@ void FixLbFluid::initial_integrate(int /*vflag*/) // Store the equilibrium distribution function, it is needed in // the next time step by the update routine. //-------------------------------------------------------------------------- - if(typeLB == 2){ + if (typeLB == 2) { std::swap(feqold,feq); std::swap(feqoldn,feqn); } @@ -718,23 +718,23 @@ void FixLbFluid::initial_integrate(int /*vflag*/) //-------------------------------------------------------------------------- // Perform diagnostics, and print output for the graphics program //-------------------------------------------------------------------------- - if(printfluid > 0 && update->ntimestep > 0 && (update->ntimestep % printfluid == 0)) + if (printfluid > 0 && update->ntimestep > 0 && (update->ntimestep % printfluid == 0)) streamout(); } void FixLbFluid::post_force(int /*vflag*/) { - if(fixviscouslb==1) + if (fixviscouslb==1) calc_fluidforce(); } void FixLbFluid::end_of_step() { - if(fixviscouslb==0) + if (fixviscouslb==0) calc_fluidforce(); - if(printrestart>0){ - if((update->ntimestep)%printrestart == 0){ + if (printrestart>0) { + if ((update->ntimestep)%printrestart == 0) { write_restartfile(); } } @@ -807,8 +807,8 @@ void FixLbFluid::calc_fluidforce(void) forceloc[0] = forceloc[1] = forceloc[2] = 0.0; torqueloc[0] = torqueloc[1] = torqueloc[2] = 0.0; - for(i=0; inmax; i++) - for(j=0; j<3; j++) + for (i=0; inmax; i++) + for (j=0; j<3; j++) hydroF[i][j] = 0.0; @@ -821,16 +821,16 @@ void FixLbFluid::calc_fluidforce(void) int *type = atom->type; double sum[4],xcm[4]; - if(force_diagnostic > 0 && update->ntimestep > 0 && (update->ntimestep % force_diagnostic == 0)){ + if (force_diagnostic > 0 && update->ntimestep > 0 && (update->ntimestep % force_diagnostic == 0)) { //Calculate the center of mass of the particle group //(needed to calculate the torque). sum[0] = sum[1] = sum[2] = sum[3] = 0.0; - for(i=0; ibitmask[igroupforce]){ + for (i=0; ibitmask[igroupforce]) { domain->unmap(x[i],image[i],unwrap); - if(rmass) massone = rmass[i]; + if (rmass) massone = rmass[i]; else massone = mass[type[i]]; sum[0] += unwrap[0]*massone; @@ -848,16 +848,16 @@ void FixLbFluid::calc_fluidforce(void) //-------------------------------------------------------------------------- //Calculate the contribution to the force on the fluid. //-------------------------------------------------------------------------- - for(i=0; i 0 && update->ntimestep > 0 && (update->ntimestep % force_diagnostic == 0)){ - if(mask[i] & group->bitmask[igroupforce]){ + if (force_diagnostic > 0 && update->ntimestep > 0 && (update->ntimestep % force_diagnostic == 0)) { + if (mask[i] & group->bitmask[igroupforce]) { domain->unmap(x[i],image[i],unwrap); dx = unwrap[0] - xcm[0]; @@ -879,7 +879,7 @@ void FixLbFluid::calc_fluidforce(void) //Communicate the force contributions which lie outside the local processor //sub domain. //-------------------------------------------------------------------------- - for(i=0; i<10; i++) + for (i=0; i<10; i++) requests[i]=MPI_REQUEST_NULL; MPI_Isend(&Ff[0][0][0][0],1,passxu,comm->procneigh[0][0],10,world,&requests[0]); MPI_Isend(&Ff[subNbx+2][0][0][0],1,passxu,comm->procneigh[0][0],20,world,&requests[1]); @@ -893,9 +893,9 @@ void FixLbFluid::calc_fluidforce(void) MPI_Irecv(&Fftempx[4][0][0][0],1,passxtemp,comm->procneigh[0][0],50,world,&requests[9]); MPI_Waitall(10,requests,MPI_STATUS_IGNORE); - for(j=0; jprocneigh[1][0],10,world,&requests[0]); MPI_Isend(&Ff[0][subNby+2][0][0],1,passyu,comm->procneigh[1][0],20,world,&requests[1]); @@ -919,9 +919,9 @@ void FixLbFluid::calc_fluidforce(void) MPI_Irecv(&Fftempy[0][4][0][0],1,passytemp,comm->procneigh[1][0],50,world,&requests[9]); MPI_Waitall(10,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[2][0],10,world,&requests[0]); MPI_Isend(&Ff[0][0][subNbz+2][0],1,passzu,comm->procneigh[2][0],20,world,&requests[1]); @@ -945,9 +945,9 @@ void FixLbFluid::calc_fluidforce(void) MPI_Irecv(&Fftempz[0][0][4][0],1,passztemp,comm->procneigh[2][0],50,world,&requests[9]); MPI_Waitall(10,requests,MPI_STATUS_IGNORE); - for(i=0; i 0 && update->ntimestep > 0 && (update->ntimestep % force_diagnostic == 0)){ + if (force_diagnostic > 0 && update->ntimestep > 0 && (update->ntimestep % force_diagnostic == 0)) { force[0] = force[1] = force[2] = 0.0; torque[0] = torque[1] = torque[2] =0.0; MPI_Allreduce(&forceloc[0],&force[0],3,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(&torqueloc[0],&torque[0],3,MPI_DOUBLE,MPI_SUM,world); - if(me==0){ + if (me==0) { printf("%E %E %E %E %E %E\n",force[0],force[1],force[2], torque[0],torque[1],torque[2]); @@ -1025,38 +1025,38 @@ void FixLbFluid::peskin_interpolation(int i) // Calculate the interpolation weights, and interpolated values of // the fluid velocity, and density. //-------------------------------------------------------------------------- - for(ii=-1; ii<3; ii++){ + for (ii=-1; ii<3; ii++) { rsq=(-dx1+ii)*(-dx1+ii); - if(rsq>=4) { + if (rsq>=4) { weightx=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weightx=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weightx=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; } } - for(jj=-1; jj<3; jj++){ + for (jj=-1; jj<3; jj++) { rsq=(-dy1+jj)*(-dy1+jj); - if(rsq>=4) { + if (rsq>=4) { weighty=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weighty=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weighty=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; } } - for(kk=-1; kk<3; kk++){ + for (kk=-1; kk<3; kk++) { rsq=(-dz1+kk)*(-dz1+kk); - if(rsq>=4) { + if (rsq>=4) { weightz=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weightz=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weightz=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; @@ -1068,35 +1068,35 @@ void FixLbFluid::peskin_interpolation(int i) //The atom is allowed to be within one lattice grid point outside the //local processor sub-domain. - if(ixp < -1 || ixp > (subNbx+1) || iyp < -1 || iyp > (subNby+1) || izp < -1 || izp > (subNbz+1)) + if (ixp < -1 || ixp > (subNbx+1) || iyp < -1 || iyp > (subNby+1) || izp < -1 || izp > (subNbz+1)) error->one(FLERR,"Atom outside local processor simulation domain. Either unstable fluid pararmeters, or \ require more frequent neighborlist rebuilds"); - if(domain->periodicity[2] == 0 && comm->myloc[2] == 0 && izp < 1) + if (domain->periodicity[2] == 0 && comm->myloc[2] == 0 && izp < 1) error->warning(FLERR,"Atom too close to lower z wall. Unphysical results may occur"); - if(domain->periodicity[2] == 0 && comm->myloc[2] == (comm->procgrid[2]-1) && (izp > (subNbz-2) )) + if (domain->periodicity[2] == 0 && comm->myloc[2] == (comm->procgrid[2]-1) && (izp > (subNbz-2) )) error->warning(FLERR,"Atom too close to upper z wall. Unphysical results may occur"); - if(ixp==-1) ixp=subNbx+2; - if(iyp==-1) iyp=subNby+2; - if(izp==-1) izp=subNbz+2; + if (ixp==-1) ixp=subNbx+2; + if (iyp==-1) iyp=subNby+2; + if (izp==-1) izp=subNbz+2; FfP[isten] = weightx*weighty*weightz; // interpolated velocity based on delta function. - for(k=0; k<3; k++){ + for (k=0; k<3; k++) { unode[k] += u_lb[ixp][iyp][izp][k]*FfP[isten]; } - if(setGamma==0) + if (setGamma==0) mnode += density_lb[ixp][iyp][izp]*FfP[isten]; isten++; } } } - if(setGamma==0){ + if (setGamma==0) { mnode *= NodeArea[type[i]]; - if(rmass) massone = rmass[i]; + if (rmass) massone = rmass[i]; else massone = mass[type[i]]; massone = massone/dm_lb; @@ -1106,25 +1106,25 @@ require more frequent neighborlist rebuilds"); } isten=0; - for(ii=-1; ii<3; ii++) - for(jj=-1; jj<3; jj++) - for(kk=-1; kk<3; kk++){ + for (ii=-1; ii<3; ii++) + for (jj=-1; jj<3; jj++) + for (kk=-1; kk<3; kk++) { ixp = ix+ii; iyp = iy+jj; izp = iz+kk; - if(ixp==-1) ixp=subNbx+2; - if(iyp==-1) iyp=subNby+2; - if(izp==-1) izp=subNbz+2; + if (ixp==-1) ixp=subNbx+2; + if (iyp==-1) iyp=subNby+2; + if (izp==-1) izp=subNbz+2; // Compute the force on the fluid. Need to convert the velocity from // LAMMPS units to LB units. - for(k=0; k<3; k++){ + for (k=0; k<3; k++) { Ff[ixp][iyp][izp][k] += gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*FfP[isten]; } isten++; } - for(k=0; k<3; k++) + for (k=0; k<3; k++) hydroF[i][k] = -1.0*gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*dm_lb*dx_lb/dt_lb/dt_lb; } @@ -1191,13 +1191,13 @@ void FixLbFluid::trilinear_interpolation(int i) //The atom is allowed to be within one lattice grid point outside the //local processor sub-domain. - if(ix < 0 || ixp > (subNbx+1) || iy < 0 || iyp > (subNby+1) || iz < 0 || izp > (subNbz+1)) + if (ix < 0 || ixp > (subNbx+1) || iy < 0 || iyp > (subNby+1) || iz < 0 || izp > (subNbz+1)) error->one(FLERR,"Atom outside local processor simulation domain. Either unstable fluid pararmeters, or \ require more frequent neighborlist rebuilds"); - if(domain->periodicity[2] == 0 && comm->myloc[2] == 0 && (iz < 1 || izp < 1)) + if (domain->periodicity[2] == 0 && comm->myloc[2] == 0 && (iz < 1 || izp < 1)) error->warning(FLERR,"Atom too close to lower z wall. Unphysical results may occur"); - if(domain->periodicity[2] == 0 && comm->myloc[2] == (comm->procgrid[2]-1) && (izp > (subNbz-2) || iz > (subNbz-2))) + if (domain->periodicity[2] == 0 && comm->myloc[2] == (comm->procgrid[2]-1) && (izp > (subNbz-2) || iz > (subNbz-2))) error->warning(FLERR,"Atom too close to upper z wall. Unphysical results may occur"); @@ -1212,7 +1212,7 @@ require more frequent neighborlist rebuilds"); + u_lb[ixp][iyp][izp][k]*FfP[7]; } - if(setGamma==0){ + if (setGamma==0) { mnode = density_lb[ix][iy][iz]*FfP[0] + density_lb[ix][iy][izp]*FfP[1] + density_lb[ix][iyp][iz]*FfP[2] @@ -1224,7 +1224,7 @@ require more frequent neighborlist rebuilds"); mnode *= NodeArea[type[i]]; - if(rmass) massone = rmass[i]; + if (rmass) massone = rmass[i]; else massone = mass[type[i]]; massone = massone/dm_lb; @@ -1234,7 +1234,7 @@ require more frequent neighborlist rebuilds"); } - for(k=0; k<3; k++){ + for (k=0; k<3; k++) { Ff[ix][iy][iz][k] += gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*FfP[0]; Ff[ix][iy][izp][k] += gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*FfP[1]; Ff[ix][iyp][iz][k] += gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*FfP[2]; @@ -1245,7 +1245,7 @@ require more frequent neighborlist rebuilds"); Ff[ixp][iyp][izp][k] += gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*FfP[7]; } - for(k=0; k<3; k++) + for (k=0; k<3; k++) hydroF[i][k] = -1.0*gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*dm_lb*dx_lb/dt_lb/dt_lb; } @@ -1266,7 +1266,7 @@ void FixLbFluid::read_restartfile(void) int gsizes[4] = {Nbx,Nby,Nbz,numvel}; int lsizes[4] = {subNbx-2,subNby-2,subNbz-2,numvel}; int starts[4] = {comm->myloc[0]*(subNbx-2),comm->myloc[1]*(subNby-2),comm->myloc[2]*(subNbz-2),0}; - if(domain->periodicity[2]==0 && comm->myloc[2]==comm->procgrid[2]-1){ + if (domain->periodicity[2]==0 && comm->myloc[2]==comm->procgrid[2]-1) { starts[2] = comm->myloc[2]*(subNbz-3); } @@ -1280,7 +1280,7 @@ void FixLbFluid::read_restartfile(void) MPI_INFO_NULL); MPI_File_seek(pFileRead,0,MPI_SEEK_SET); MPI_File_read_all(pFileRead,&f_lb[0][0][0][0],1,realtype,&status); - if(typeLB == 2){ + if (typeLB == 2) { MPI_File_read_all(pFileRead,&feqold[0][0][0][0],1,realtype,&status); MPI_File_read_all(pFileRead,&feqoldn[0][0][0][0],1,realtype,&status); } @@ -1313,7 +1313,7 @@ void FixLbFluid::write_restartfile(void) int gsizes[4] = {Nbx,Nby,Nbz,numvel}; int lsizes[4] = {subNbx-2,subNby-2,subNbz-2,numvel}; int starts[4] = {comm->myloc[0]*(subNbx-2),comm->myloc[1]*(subNby-2),comm->myloc[2]*(subNbz-2),0}; - if(domain->periodicity[2]==0 && comm->myloc[2]==comm->procgrid[2]-1){ + if (domain->periodicity[2]==0 && comm->myloc[2]==comm->procgrid[2]-1) { starts[2] = comm->myloc[2]*(subNbz-3); } @@ -1325,7 +1325,7 @@ void FixLbFluid::write_restartfile(void) MPI_File_set_view(fh,0,MPI_DOUBLE,filetype,(char *) "native",MPI_INFO_NULL); MPI_File_write_all(fh,&f_lb[0][0][0][0],1,realtype,&status); - if(typeLB == 2){ + if (typeLB == 2) { MPI_File_write_all(fh,&feqold[0][0][0][0],1,realtype,&status); MPI_File_write_all(fh,&feqoldn[0][0][0][0],1,realtype,&status); } @@ -1353,15 +1353,15 @@ void FixLbFluid::rescale(void) tau=(3.0*viscosity/densityinit_real)*dt_lb*dt_lb/dx_lb/dx_lb; tau /= dt_lb; - if(typeLB==1) + if (typeLB==1) tau = tau + 0.5; - if(setGamma == 0){ - for(int i=0; i<= atom->ntypes; i++){ + if (setGamma == 0) { + for (int i=0; i<= atom->ntypes; i++) { NodeArea[i] = NodeArea[i]/dx_lb/dx_lb; } } else { - for(int i=0; i<= atom->ntypes; i++){ + for (int i=0; i<= atom->ntypes; i++) { Gamma[i] = Gamma[i]*dt_lb/dm_lb; } } @@ -1371,38 +1371,38 @@ void FixLbFluid::rescale(void) a_0 = a_0_real*dt_lb*dt_lb/(dx_lb*dx_lb); // Warn if using the D3Q19 model with noise, and a0 is too small. - if(numvel==19 && noisestress==1 && a_0 < 0.2){ + if (numvel==19 && noisestress==1 && a_0 < 0.2) { error->warning(FLERR,"Fix lb/fluid WARNING: Chosen value for a0 may be too small. \ Check temperature reproduction.\n"); } - if(noisestress==1){ - if(a_0>0.5555555){ + if (noisestress==1) { + if (a_0>0.5555555) { error->all(FLERR,"Fix lb/fluid ERROR: the Lattice Boltzmann dx and dt need \ to be chosen such that the scaled a_0 < 5/9\n"); } } // Courant Condition: - if(a_0 >= 1.0){ + if (a_0 >= 1.0) { error->all(FLERR,"Fix lb/fluid ERROR: the lattice Boltzmann dx and dt do not \ satisfy the Courant condition.\n"); } kB = (force->boltz/force->mvv2e)*dt_lb*dt_lb/dx_lb/dx_lb/dm_lb; - if(typeLB==1){ + if (typeLB==1) { expminusdtovertau = 0.0; Dcoeff = 0.0; namp = 2.0*kB*T*(tau-0.5)/3.0; noisefactor = 1.0; - if(a_0 <= 0.333333333333333){ + if (a_0 <= 0.333333333333333) { K_0 = 5.17*(0.333333333333333 - a_0); } else { K_0 = 2.57*(a_0 - 0.333333333333333); } dtoverdtcollision = dt_lb*6.0*viscosity/densityinit_real/dx_lb/dx_lb; - } else if(typeLB==2){ + } else if (typeLB==2) { expminusdtovertau=exp(-1.0/tau); Dcoeff=(1.0-(1.0-expminusdtovertau)*tau); namp = 2.0*kB*T/3.; @@ -1565,18 +1565,18 @@ void FixLbFluid::initializeLB15(void) mg_lb[14][10]=sqrt(2.);mg_lb[14][11]=sqrt(2.);mg_lb[14][12]=sqrt(2.); mg_lb[14][13]=sqrt(2.);mg_lb[14][14]=sqrt(2.); - for(i=0; iprocneigh[0][0],15,world,&requests[0]); MPI_Irecv(&feq[0][1][1][0],1,passxf,comm->procneigh[0][0],25,world,&requests[1]); MPI_Isend(&feq[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],25,world,&requests[2]); MPI_Irecv(&feq[subNbx-1][1][1][0],1,passxf,comm->procneigh[0][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[1][1][1][0],1,passxf,comm->procneigh[0][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][1][1][0],1,passxf,comm->procneigh[0][0],20,world,&requests[5]); MPI_Isend(&feqn[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],20,world,&requests[6]); @@ -1860,13 +1860,13 @@ void FixLbFluid::initialize_feq(void) } MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[1][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][1][0],1,passyf,comm->procneigh[1][0],25,world,&requests[1]); MPI_Isend(&feq[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],25,world,&requests[2]); MPI_Irecv(&feq[0][subNby-1][1][0],1,passyf,comm->procneigh[1][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][1][1][0],1,passyf,comm->procneigh[1][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][1][0],1,passyf,comm->procneigh[1][0],20,world,&requests[5]); MPI_Isend(&feqn[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],20,world,&requests[6]); @@ -1874,13 +1874,13 @@ void FixLbFluid::initialize_feq(void) } MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[2][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&requests[1]); MPI_Isend(&feq[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&requests[2]); MPI_Irecv(&feq[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][0][1][0],1,passzf,comm->procneigh[2][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][0][0],1,passzf,comm->procneigh[2][0],20,world,&requests[5]); MPI_Isend(&feqn[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],20,world,&requests[6]); @@ -1889,11 +1889,11 @@ void FixLbFluid::initialize_feq(void) MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); //Save feqold. - if(typeLB == 2){ - for(i=0; iprocneigh[0][0],15,world,&requests[0]); MPI_Irecv(&feqold[0][1][1][0],1,passxf,comm->procneigh[0][0],25,world,&requests[1]); @@ -1916,7 +1916,7 @@ void FixLbFluid::initialize_feq(void) MPI_Irecv(&feqoldn[subNbx-1][1][1][0],1,passxf,comm->procneigh[0][1],10,world,&requests[7]); MPI_Waitall(8,requests,MPI_STATUS_IGNORE); - for(i=0; i<8; i++) + for (i=0; i<8; i++) requests[i]=MPI_REQUEST_NULL; MPI_Isend(&feqold[0][1][1][0],1,passyf,comm->procneigh[1][0],15,world,&requests[0]); MPI_Irecv(&feqold[0][0][1][0],1,passyf,comm->procneigh[1][0],25,world,&requests[1]); @@ -1928,7 +1928,7 @@ void FixLbFluid::initialize_feq(void) MPI_Irecv(&feqoldn[0][subNby-1][1][0],1,passyf,comm->procneigh[1][1],10,world,&requests[7]); MPI_Waitall(8,requests,MPI_STATUS_IGNORE); - for(i=0; i<8; i++) + for (i=0; i<8; i++) requests[i]=MPI_REQUEST_NULL; MPI_Isend(&feqold[0][0][1][0],1,passzf,comm->procneigh[2][0],15,world,&requests[0]); MPI_Irecv(&feqold[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&requests[1]); @@ -1994,14 +1994,14 @@ void FixLbFluid::equilibriumdist15(int xstart, int xend, int ystart, int yend, i // Need one-sided derivatives for the boundary of the domain, if fixed boundary // conditions are used. - if(domain->periodicity[2]==0){ - if(comm->myloc[2]==0 && k==1){ + if (domain->periodicity[2]==0) { + if (comm->myloc[2]==0 && k==1) { drhoz = (-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k+1] - density_lb[i][j][k+2])/2.0; drhozz = (-density_lb[i][j][k+3] + 4.0*density_lb[i][j][k+2] - 5.0*density_lb[i][j][k+1] + 2.0*rho); } - if(comm->myloc[2]==comm->procgrid[2]-1 && k==subNbz-2){ + if (comm->myloc[2]==comm->procgrid[2]-1 && k==subNbz-2) { drhoz = -(-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k-1] - density_lb[i][j][k-2])/2.0; drhozz = (-density_lb[i][j][k-3] + 4.0*density_lb[i][j][k-2] - @@ -2017,7 +2017,7 @@ void FixLbFluid::equilibriumdist15(int xstart, int xend, int ystart, int yend, i dPdrho = a_0; //assuming here that kappa_lb = 0. - if(typeLB==1){ + if (typeLB==1) { Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* @@ -2030,7 +2030,7 @@ void FixLbFluid::equilibriumdist15(int xstart, int xend, int ystart, int yend, i (u_lb[i][j][k][0]*drhoz+u_lb[i][j][k][2]*drhox); Pyz = kappa_lb*drhoy*drhoz+(tau-0.5)*(1.0/3.0-dPdrho)* (u_lb[i][j][k][1]*drhoz+u_lb[i][j][k][2]*drhoy); - } else if(typeLB==2){ + } else if (typeLB==2) { Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+tau*(1.0/3.0-dPdrho)* (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+tau*(1.0/3.0-dPdrho)* @@ -2079,17 +2079,17 @@ void FixLbFluid::equilibriumdist15(int xstart, int xend, int ystart, int yend, i for (int ii=0; ii<15; ii++) feq[i][j][k][l] += w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; - if(typeLB == 2){ + if (typeLB == 2) { feqn[i][j][k][l] = feq[i][j][k][l]; } } - if(noisestress==1){ + if (noisestress==1) { std = sqrt(namp*rho); - for(jj=0; jj<3; jj++) + for (jj=0; jj<3; jj++) S[0][jj] = std*random->gaussian(); - for(jj=0; jj<3; jj++) + for (jj=0; jj<3; jj++) S[1][jj] = std*random->gaussian(); etacov[4] = (S[0][0]*sqrt(3.0-3.0*a_0)); @@ -2172,14 +2172,14 @@ void FixLbFluid::equilibriumdist19(int xstart, int xend, int ystart, int yend, i // Need one-sided derivatives for the boundary of the domain, if fixed boundary // conditions are used. - if(domain->periodicity[2]==0){ - if(comm->myloc[2]==0 && k==1){ + if (domain->periodicity[2]==0) { + if (comm->myloc[2]==0 && k==1) { drhoz = (-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k+1] - density_lb[i][j][k+2])/2.0; drhozz = (-density_lb[i][j][k+3] + 4.0*density_lb[i][j][k+2] - 5.0*density_lb[i][j][k+1] + 2.0*rho); } - if(comm->myloc[2]==comm->procgrid[2]-1 && k==subNbz-2){ + if (comm->myloc[2]==comm->procgrid[2]-1 && k==subNbz-2) { drhoz = -(-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k-1] - density_lb[i][j][k-2])/2.0; drhozz = (-density_lb[i][j][k-3] + 4.0*density_lb[i][j][k-2] - @@ -2195,7 +2195,7 @@ void FixLbFluid::equilibriumdist19(int xstart, int xend, int ystart, int yend, i dPdrho = a_0; //assuming here that kappa_lb = 0. - if(typeLB==1){ + if (typeLB==1) { Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* @@ -2208,7 +2208,7 @@ void FixLbFluid::equilibriumdist19(int xstart, int xend, int ystart, int yend, i (u_lb[i][j][k][0]*drhoz+u_lb[i][j][k][2]*drhox); Pyz = kappa_lb*drhoy*drhoz+(tau-0.5)*(1.0/3.0-dPdrho)* (u_lb[i][j][k][1]*drhoz+u_lb[i][j][k][2]*drhoy); - } else if(typeLB==2){ + } else if (typeLB==2) { Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+tau*(1.0/3.0-dPdrho)* (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+tau*(1.0/3.0-dPdrho)* @@ -2260,17 +2260,17 @@ void FixLbFluid::equilibriumdist19(int xstart, int xend, int ystart, int yend, i for (int ii=0; ii<19; ii++) feq[i][j][k][l] += w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; - if(typeLB == 2){ + if (typeLB == 2) { feqn[i][j][k][l] = feq[i][j][k][l]; } } - if(noisestress==1){ + if (noisestress==1) { std = sqrt(namp*rho); - for(jj=0; jj<3; jj++) + for (jj=0; jj<3; jj++) S[0][jj] = std*random->gaussian(); - for(jj=0; jj<3; jj++) + for (jj=0; jj<3; jj++) S[1][jj] = std*random->gaussian(); etacov[4] = (S[0][0]*sqrt(3.0-3.0*a_0)); @@ -2322,7 +2322,7 @@ void FixLbFluid::parametercalc_full(void) // routine, and use these to calculate the density and velocity on the // boundary. //-------------------------------------------------------------------------- - for(i=0; i<4; i++) + for (i=0; i<4; i++) requests[i]=MPI_REQUEST_NULL; MPI_Isend(&f_lb[1][1][1][0],1,passxf,comm->procneigh[0][0],10,world,&requests[0]); MPI_Irecv(&f_lb[0][1][1][0],1,passxf,comm->procneigh[0][0],20,world,&requests[1]); @@ -2331,7 +2331,7 @@ void FixLbFluid::parametercalc_full(void) parametercalc_part(1,subNbx-1,1,subNby-1,1,subNbz-1); MPI_Waitall(4,requests,MPI_STATUS_IGNORE); - for(i=0; i<4; i++) + for (i=0; i<4; i++) requests[i]=MPI_REQUEST_NULL; MPI_Isend(&f_lb[0][1][1][0],1,passyf,comm->procneigh[1][0],10,world,&requests[0]); MPI_Irecv(&f_lb[0][0][1][0],1,passyf,comm->procneigh[1][0],20,world,&requests[1]); @@ -2341,7 +2341,7 @@ void FixLbFluid::parametercalc_full(void) parametercalc_part(subNbx-1,subNbx,1,subNby-1,1,subNbz-1); MPI_Waitall(4,requests,MPI_STATUS_IGNORE); - for(i=0; i<4; i++) + for (i=0; i<4; i++) requests[i]=MPI_REQUEST_NULL; MPI_Isend(&f_lb[0][0][1][0],1,passzf,comm->procneigh[2][0],10,world,&requests[0]); MPI_Irecv(&f_lb[0][0][0][0],1,passzf,comm->procneigh[2][0],20,world,&requests[1]); @@ -2358,10 +2358,10 @@ void FixLbFluid::parametercalc_full(void) // Send the remaining portions of the u array (and density array if Gamma // is set the default way). //-------------------------------------------------------------------------- - if(setGamma == 0) numrequests = 12; + if (setGamma == 0) numrequests = 12; else numrequests = 6; - for(i=0; iprocneigh[0][0],10,world,&requests2[0]); MPI_Isend(&u_lb[3][0][0][0],1,passxu,comm->procneigh[0][0],20,world,&requests2[1]); @@ -2369,7 +2369,7 @@ void FixLbFluid::parametercalc_full(void) MPI_Irecv(&u_lb[subNbx][0][0][0],1,passxu,comm->procneigh[0][1],10,world,&requests2[3]); MPI_Irecv(&u_lb[subNbx+1][0][0][0],1,passxu,comm->procneigh[0][1],20,world,&requests2[4]); MPI_Irecv(&u_lb[subNbx+2][0][0][0],1,passxu,comm->procneigh[0][0],30,world,&requests2[5]); - if(setGamma==0){ + if (setGamma==0) { MPI_Isend(&density_lb[2][0][0],1,passxrho,comm->procneigh[0][0],40,world,&requests2[6]); MPI_Isend(&density_lb[3][0][0],1,passxrho,comm->procneigh[0][0],50,world,&requests2[7]); MPI_Isend(&density_lb[subNbx-3][0][0],1,passxrho,comm->procneigh[0][1],60,world,&requests2[8]); @@ -2379,7 +2379,7 @@ void FixLbFluid::parametercalc_full(void) } MPI_Waitall(numrequests,requests2,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[1][0],10,world,&requests2[0]); MPI_Isend(&u_lb[0][3][0][0],1,passyu,comm->procneigh[1][0],20,world,&requests2[1]); @@ -2387,7 +2387,7 @@ void FixLbFluid::parametercalc_full(void) MPI_Irecv(&u_lb[0][subNby][0][0],1,passyu,comm->procneigh[1][1],10,world,&requests2[3]); MPI_Irecv(&u_lb[0][subNby+1][0][0],1,passyu,comm->procneigh[1][1],20,world,&requests2[4]); MPI_Irecv(&u_lb[0][subNby+2][0][0],1,passyu,comm->procneigh[1][0],30,world,&requests2[5]); - if(setGamma==0){ + if (setGamma==0) { MPI_Isend(&density_lb[0][2][0],1,passyrho,comm->procneigh[1][0],40,world,&requests2[6]); MPI_Isend(&density_lb[0][3][0],1,passyrho,comm->procneigh[1][0],50,world,&requests2[7]); MPI_Isend(&density_lb[0][subNby-3][0],1,passyrho,comm->procneigh[1][1],60,world,&requests2[8]); @@ -2397,27 +2397,27 @@ void FixLbFluid::parametercalc_full(void) } MPI_Waitall(numrequests,requests2,MPI_STATUS_IGNORE); - for(i=0; i<12; i++) + for (i=0; i<12; i++) requests2[i]=MPI_REQUEST_NULL; int requestcount=0; - if(domain->periodicity[2]!=0 || comm->myloc[2] != 0){ + if (domain->periodicity[2]!=0 || comm->myloc[2] != 0) { MPI_Isend(&u_lb[0][0][2][0],1,passzu,comm->procneigh[2][0],10,world,&requests2[requestcount]); MPI_Isend(&u_lb[0][0][3][0],1,passzu,comm->procneigh[2][0],20,world,&requests2[requestcount+1]); MPI_Irecv(&u_lb[0][0][subNbz+2][0],1,passzu,comm->procneigh[2][0],30,world,&requests2[requestcount+2]); requestcount=requestcount+3; - if(setGamma==0){ + if (setGamma==0) { MPI_Isend(&density_lb[0][0][2],1,passzrho,comm->procneigh[2][0],40,world,&requests2[requestcount]); MPI_Isend(&density_lb[0][0][3],1,passzrho,comm->procneigh[2][0],50,world,&requests2[requestcount+1]); MPI_Irecv(&density_lb[0][0][subNbz+2],1,passzrho,comm->procneigh[2][0],60,world,&requests2[requestcount+2]); requestcount=requestcount+3; } } - if(domain->periodicity[2]!=0 || comm->myloc[2] != (comm->procgrid[2]-1)){ + if (domain->periodicity[2]!=0 || comm->myloc[2] != (comm->procgrid[2]-1)) { MPI_Isend(&u_lb[0][0][subNbz-3][0],1,passzu,comm->procneigh[2][1],30,world,&requests2[requestcount]); MPI_Irecv(&u_lb[0][0][subNbz][0],1,passzu,comm->procneigh[2][1],10,world,&requests2[requestcount+1]); MPI_Irecv(&u_lb[0][0][subNbz+1][0],1,passzu,comm->procneigh[2][1],20,world,&requests2[requestcount+2]); requestcount=requestcount+3; - if(setGamma==0){ + if (setGamma==0) { MPI_Isend(&density_lb[0][0][subNbz-3],1,passzrho,comm->procneigh[2][1],60,world,&requests2[requestcount]); MPI_Irecv(&density_lb[0][0][subNbz],1,passzrho,comm->procneigh[2][1],40,world,&requests2[requestcount+1]); MPI_Irecv(&density_lb[0][0][subNbz+1],1,passzrho,comm->procneigh[2][1],50,world,&requests2[requestcount+2]); @@ -2436,9 +2436,9 @@ void FixLbFluid::parametercalc_part(int xstart, int xend, int ystart, int yend, { int i,j,k,m; - for(i=xstart; iperiodicity[2]==0){ - if(comm->myloc[2]==0){ - if(k==1){ + if (domain->periodicity[2]==0) { + if (comm->myloc[2]==0) { + if (k==1) { u_lb[i][j][k][2]=0.0; } } - if(comm->myloc[2]==comm->procgrid[2]-1){ - if(k==subNbz-2){ + if (comm->myloc[2]==comm->procgrid[2]-1) { + if (k==subNbz-2) { u_lb[i][j][k][2]=0.0; } } @@ -2487,20 +2487,20 @@ void FixLbFluid::update_periodic(int xstart, int xend, int ystart, int yend, int int i,j,k,m; int imod,jmod,kmod,imodm,jmodm,kmodm; - for(i=xstart; ime==0){ + // if (comm->me==0) { // printf("%16.12f %16.12f %16.12f %16.12f\n",mass*dm_lb,momentum[0]*dm_lb*dx_lb/dt_lb,momentum[1]*dm_lb*dx_lb/dt_lb,momentum[2]*dm_lb*dx_lb/dt_lb); // } sizeloc=(subNbx*subNby*subNbz*4); MPI_Allreduce(&sizeloc,&size,1,MPI_INT,MPI_MAX,world); - if(me==0){ - for(iproc=0; iproc < comm->nprocs; iproc++){ - if(iproc){ + if (me==0) { + for (iproc=0; iproc < comm->nprocs; iproc++) { + if (iproc) { MPI_Irecv(&buf[0][0][0][0],size,MPI_DOUBLE,iproc,0,world,&request_recv); MPI_Wait(&request_recv,&status); @@ -2577,19 +2577,19 @@ void FixLbFluid::streamout(void) jend=static_cast (buf[0][0][1][1]); kend=static_cast (buf[0][0][1][2]); - for(i=istart; imyloc[0]*(subNbx-2); jstart=comm->myloc[1]*(subNby-2); - if(domain->periodicity[2]==0){ - if(comm->myloc[2]==comm->procgrid[2]-1){ + if (domain->periodicity[2]==0) { + if (comm->myloc[2]==comm->procgrid[2]-1) { kstart=comm->myloc[2]*(subNbz-3); } else { kstart=comm->myloc[2]*(subNbz-2); @@ -2623,9 +2623,9 @@ void FixLbFluid::streamout(void) iend=istart+subNbx-2; jend=jstart+subNby-2; kend=kstart+subNbz-2; - for(i=0; iperiodicity[2]==0){ + if (domain->periodicity[2]==0) { - for(i=0; iprocneigh[0][0],15,world,&requests[0]); MPI_Irecv(&feq[0][1][1][0],1,passxf,comm->procneigh[0][0],25,world,&requests[1]); MPI_Isend(&feq[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],25,world,&requests[2]); MPI_Irecv(&feq[subNbx-1][1][1][0],1,passxf,comm->procneigh[0][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[1][1][1][0],1,passxf,comm->procneigh[0][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][1][1][0],1,passxf,comm->procneigh[0][0],20,world,&requests[5]); MPI_Isend(&feqn[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],20,world,&requests[6]); @@ -2694,13 +2694,13 @@ void FixLbFluid::update_full15(void) MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[1][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][1][0],1,passyf,comm->procneigh[1][0],25,world,&requests[1]); MPI_Isend(&feq[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],25,world,&requests[2]); MPI_Irecv(&feq[0][subNby-1][1][0],1,passyf,comm->procneigh[1][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][1][1][0],1,passyf,comm->procneigh[1][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][1][0],1,passyf,comm->procneigh[1][0],20,world,&requests[5]); MPI_Isend(&feqn[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],20,world,&requests[6]); @@ -2710,13 +2710,13 @@ void FixLbFluid::update_full15(void) update_periodic(subNbx-2,subNbx-1,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[2][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&requests[1]); MPI_Isend(&feq[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&requests[2]); MPI_Irecv(&feq[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][0][1][0],1,passzf,comm->procneigh[2][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][0][0],1,passzf,comm->procneigh[2][0],20,world,&requests[5]); MPI_Isend(&feqn[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],20,world,&requests[6]); @@ -2726,15 +2726,15 @@ void FixLbFluid::update_full15(void) update_periodic(1,subNbx-1,subNby-2,subNby-1,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - if(typeLB==1){ + if (typeLB==1) { update_periodic(1,subNbx-1,1,subNby-1,1,2); update_periodic(1,subNbx-1,1,subNby-1,subNbz-2,subNbz-1); - } else if(typeLB==2){ - if(comm->myloc[2]==0){ - for(i=1; imyloc[2]==0) { + for (i=1; imyloc[2]==comm->procgrid[2]-1){ - for(i=1;imyloc[2]==comm->procgrid[2]-1) { + for (i=1;imyloc[2]==0){ + if (comm->myloc[2]==0) { MPI_Isend(&fnew[0][0][1][0],1,passzf,comm->procneigh[2][0],15,world,&req_send15); MPI_Irecv(&fnew[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&req_recv25); } - if(comm->myloc[2]==comm->procgrid[2]-1){ + if (comm->myloc[2]==comm->procgrid[2]-1) { MPI_Isend(&fnew[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&req_send25); MPI_Irecv(&fnew[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&req_recv15); } - if(comm->myloc[2]==0){ + if (comm->myloc[2]==0) { MPI_Wait(&req_send15,&status); MPI_Wait(&req_recv25,&status); - for(i=1;imyloc[2]==comm->procgrid[2]-1){ + if (comm->myloc[2]==comm->procgrid[2]-1) { MPI_Wait(&req_send25,&status); MPI_Wait(&req_recv15,&status); - for(i=1;iprocneigh[0][0],15,world,&requests[0]); MPI_Irecv(&feq[0][1][1][0],1,passxf,comm->procneigh[0][0],25,world,&requests[1]); MPI_Isend(&feq[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],25,world,&requests[2]); MPI_Irecv(&feq[subNbx-1][1][1][0],1,passxf,comm->procneigh[0][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[1][1][1][0],1,passxf,comm->procneigh[0][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][1][1][0],1,passxf,comm->procneigh[0][0],20,world,&requests[5]); MPI_Isend(&feqn[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],20,world,&requests[6]); @@ -2965,13 +2965,13 @@ void FixLbFluid::update_full15(void) update_periodic(2,subNbx-2,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[1][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][1][0],1,passyf,comm->procneigh[1][0],25,world,&requests[1]); MPI_Isend(&feq[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],25,world,&requests[2]); MPI_Irecv(&feq[0][subNby-1][1][0],1,passyf,comm->procneigh[1][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][1][1][0],1,passyf,comm->procneigh[1][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][1][0],1,passyf,comm->procneigh[1][0],20,world,&requests[5]); MPI_Isend(&feqn[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],20,world,&requests[6]); @@ -2981,13 +2981,13 @@ void FixLbFluid::update_full15(void) update_periodic(subNbx-2,subNbx-1,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[2][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&requests[1]); MPI_Isend(&feq[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&requests[2]); MPI_Irecv(&feq[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][0][1][0],1,passzf,comm->procneigh[2][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][0][0],1,passzf,comm->procneigh[2][0],20,world,&requests[5]); MPI_Isend(&feqn[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],20,world,&requests[6]); @@ -3024,7 +3024,7 @@ void FixLbFluid::update_full19(void) //-------------------------------------------------------------------------- // If using the standard LB integrator, do not need to send info about feqn. //-------------------------------------------------------------------------- - if(typeLB == 1){ + if (typeLB == 1) { numrequests = 4; } else { numrequests = 8; @@ -3033,15 +3033,15 @@ void FixLbFluid::update_full19(void) //-------------------------------------------------------------------------- // Fixed z boundary conditions. //-------------------------------------------------------------------------- - if(domain->periodicity[2]==0){ + if (domain->periodicity[2]==0) { - for(i=0; iprocneigh[0][0],15,world,&requests[0]); MPI_Irecv(&feq[0][1][1][0],1,passxf,comm->procneigh[0][0],25,world,&requests[1]); MPI_Isend(&feq[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],25,world,&requests[2]); MPI_Irecv(&feq[subNbx-1][1][1][0],1,passxf,comm->procneigh[0][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[1][1][1][0],1,passxf,comm->procneigh[0][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][1][1][0],1,passxf,comm->procneigh[0][0],20,world,&requests[5]); MPI_Isend(&feqn[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],20,world,&requests[6]); @@ -3050,13 +3050,13 @@ void FixLbFluid::update_full19(void) update_periodic(2,subNbx-2,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[1][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][1][0],1,passyf,comm->procneigh[1][0],25,world,&requests[1]); MPI_Isend(&feq[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],25,world,&requests[2]); MPI_Irecv(&feq[0][subNby-1][1][0],1,passyf,comm->procneigh[1][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][1][1][0],1,passyf,comm->procneigh[1][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][1][0],1,passyf,comm->procneigh[1][0],20,world,&requests[5]); MPI_Isend(&feqn[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],20,world,&requests[6]); @@ -3066,13 +3066,13 @@ void FixLbFluid::update_full19(void) update_periodic(subNbx-2,subNbx-1,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[2][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&requests[1]); MPI_Isend(&feq[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&requests[2]); MPI_Irecv(&feq[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][0][1][0],1,passzf,comm->procneigh[2][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][0][0],1,passzf,comm->procneigh[2][0],20,world,&requests[5]); MPI_Isend(&feqn[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],20,world,&requests[6]); @@ -3082,15 +3082,15 @@ void FixLbFluid::update_full19(void) update_periodic(1,subNbx-1,subNby-2,subNby-1,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - if(typeLB==1){ + if (typeLB==1) { update_periodic(1,subNbx-1,1,subNby-1,1,2); update_periodic(1,subNbx-1,1,subNby-1,subNbz-2,subNbz-1); - } else if(typeLB==2){ - if(comm->myloc[2]==0){ - for(i=1; imyloc[2]==0) { + for (i=1; imyloc[2]==comm->procgrid[2]-1){ - for(i=1;imyloc[2]==comm->procgrid[2]-1) { + for (i=1;imyloc[2]==0){ + if (comm->myloc[2]==0) { MPI_Isend(&fnew[0][0][1][0],1,passzf,comm->procneigh[2][0],15,world,&req_send15); MPI_Irecv(&fnew[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&req_recv25); } - if(comm->myloc[2]==comm->procgrid[2]-1){ + if (comm->myloc[2]==comm->procgrid[2]-1) { MPI_Isend(&fnew[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&req_send25); MPI_Irecv(&fnew[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&req_recv15); } - if(comm->myloc[2]==0){ + if (comm->myloc[2]==0) { MPI_Wait(&req_send15,&status); MPI_Wait(&req_recv25,&status); - for(i=1;imyloc[2]==comm->procgrid[2]-1){ + if (comm->myloc[2]==comm->procgrid[2]-1) { MPI_Wait(&req_send25,&status); MPI_Wait(&req_recv15,&status); - for(i=1;iprocneigh[0][0],15,world,&requests[0]); MPI_Irecv(&feq[0][1][1][0],1,passxf,comm->procneigh[0][0],25,world,&requests[1]); MPI_Isend(&feq[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],25,world,&requests[2]); MPI_Irecv(&feq[subNbx-1][1][1][0],1,passxf,comm->procneigh[0][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[1][1][1][0],1,passxf,comm->procneigh[0][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][1][1][0],1,passxf,comm->procneigh[0][0],20,world,&requests[5]); MPI_Isend(&feqn[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],20,world,&requests[6]); @@ -3311,13 +3311,13 @@ void FixLbFluid::update_full19(void) update_periodic(2,subNbx-2,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[1][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][1][0],1,passyf,comm->procneigh[1][0],25,world,&requests[1]); MPI_Isend(&feq[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],25,world,&requests[2]); MPI_Irecv(&feq[0][subNby-1][1][0],1,passyf,comm->procneigh[1][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][1][1][0],1,passyf,comm->procneigh[1][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][1][0],1,passyf,comm->procneigh[1][0],20,world,&requests[5]); MPI_Isend(&feqn[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],20,world,&requests[6]); @@ -3327,13 +3327,13 @@ void FixLbFluid::update_full19(void) update_periodic(subNbx-2,subNbx-1,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[2][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&requests[1]); MPI_Isend(&feq[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&requests[2]); MPI_Irecv(&feq[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][0][1][0],1,passzf,comm->procneigh[2][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][0][0],1,passzf,comm->procneigh[2][0],20,world,&requests[5]); MPI_Isend(&feqn[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],20,world,&requests[6]); diff --git a/src/USER-LB/fix_lb_momentum.cpp b/src/USER-LB/fix_lb_momentum.cpp index 81acdbef45..9a305f6fe1 100644 --- a/src/USER-LB/fix_lb_momentum.cpp +++ b/src/USER-LB/fix_lb_momentum.cpp @@ -70,8 +70,8 @@ FixLbMomentum::FixLbMomentum(LAMMPS *lmp, int narg, char **arg) : if (group->count(igroup) == 0.0) error->all(FLERR,"Fix lb/momentum group has no atoms"); - for(int ifix=0; ifixnfix; ifix++) - if(strcmp(modify->fix[ifix]->style,"lb/fluid")==0) + for (int ifix=0; ifixnfix; ifix++) + if (strcmp(modify->fix[ifix]->style,"lb/fluid")==0) fix_lb_fluid = (FixLbFluid *)modify->fix[ifix]; @@ -135,9 +135,9 @@ void FixLbMomentum::end_of_step() masslbloc = 0.0; momentumlbloc[0] = momentumlbloc[1] = momentumlbloc[2] = 0.0; - for(int i = 1; ie; //Subtract vcm from the fluid. - for(int i=0; ifeqold; double ****feqoldn = fix_lb_fluid->feqoldn; density_old = 0.0; u_old[0] = u_old[1] = u_old[2] = 0.0; - for(int l=0; lntypes+1]; int groupbit_lb_fluid = 0; - for(int ifix=0; ifixnfix; ifix++) - if(strcmp(modify->fix[ifix]->style,"lb/fluid")==0){ + for (int ifix=0; ifixnfix; ifix++) + if (strcmp(modify->fix[ifix]->style,"lb/fluid")==0) { fix_lb_fluid = (FixLbFluid *)modify->fix[ifix]; groupbit_lb_fluid = group->bitmask[modify->fix[ifix]->igroup]; } - if(groupbit_lb_fluid == 0) + if (groupbit_lb_fluid == 0) error->all(FLERR,"the lb/fluid fix must also be used if using the lb/pc fix"); int *mask = atom->mask; int nlocal = atom->nlocal; - for(int j=0; jone(FLERR,"can only use the lb/pc fix for an atom if also using the lb/fluid fix for that atom"); } @@ -109,7 +109,7 @@ void FixLbPC::init() dtv = update->dt; dtf = update->dt * force->ftm2v; - for(int i=0; i<=atom->ntypes; i++) + for (int i=0; i<=atom->ntypes; i++) Gamma_MD[i] = Gamma[i]*dm_lb/dt_lb; } @@ -132,7 +132,7 @@ void FixLbPC::initial_integrate(int /*vflag*/) { compute_up(); - for(int i=0; itrilinear_stencil; - for(i=0; i=4) { + if (rsq>=4) { weightx=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weightx=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weightx=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; } } - for(jj=-1; jj<3; jj++){ + for (jj=-1; jj<3; jj++) { rsq=(-dy1+jj)*(-dy1+jj); - if(rsq>=4) { + if (rsq>=4) { weighty=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weighty=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weighty=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; } } - for(kk=-1; kk<3; kk++){ + for (kk=-1; kk<3; kk++) { rsq=(-dz1+kk)*(-dz1+kk); - if(rsq>=4) { + if (rsq>=4) { weightz=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weightz=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weightz=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; @@ -423,13 +423,13 @@ int FixLbPC::unpack_exchange(int nlocal, double *buf) izp = iz+kk; - if(ixp==-1) ixp=subNbx+2; - if(iyp==-1) iyp=subNby+2; - if(izp==-1) izp=subNbz+2; + if (ixp==-1) ixp=subNbx+2; + if (iyp==-1) iyp=subNby+2; + if (izp==-1) izp=subNbz+2; FfP[isten] = weightx*weighty*weightz; // interpolated velocity based on delta function. - for(k=0; k<3; k++){ + for (k=0; k<3; k++) { up[i][k] += u_lb[ixp][iyp][izp][k]*FfP[isten]; } } @@ -460,7 +460,7 @@ int FixLbPC::unpack_exchange(int nlocal, double *buf) + u_lb[ixp][iyp][izp][k]*FfP[7]; } } - for(k=0; k<3; k++) + for (k=0; k<3; k++) up[i][k] = up[i][k]*dx_lb/dt_lb; } diff --git a/src/USER-LB/fix_lb_rigid_pc_sphere.cpp b/src/USER-LB/fix_lb_rigid_pc_sphere.cpp index dd4b7b8647..88eb54593a 100644 --- a/src/USER-LB/fix_lb_rigid_pc_sphere.cpp +++ b/src/USER-LB/fix_lb_rigid_pc_sphere.cpp @@ -286,10 +286,10 @@ FixLbRigidPCSphere::FixLbRigidPCSphere(LAMMPS *lmp, int narg, char **arg) : iarg += 5; // specify if certain particles are inside the rigid spherical body, // and therefore should not - } else if(strcmp(arg[iarg],"innerNodes")==0){ + } else if (strcmp(arg[iarg],"innerNodes")==0) { inner_nodes = 1; igroupinner = group->find(arg[iarg+1]); - if(igroupinner == -1) + if (igroupinner == -1) error->all(FLERR,"Could not find fix lb/rigid/pc/sphere innerNodes group ID"); iarg += 2; } else error->all(FLERR,"Illegal fix lb/rigid/pc/sphere command"); @@ -328,16 +328,16 @@ FixLbRigidPCSphere::FixLbRigidPCSphere(LAMMPS *lmp, int narg, char **arg) : //count the number of atoms in the shell. if (inner_nodes == 1) { int *mask = atom->mask; - for(ibody=0; ibodybitmask[igroupinner])){ - if(body[i] >= 0) ncount[body[i]]++; + for (ibody=0; ibodybitmask[igroupinner])) { + if (body[i] >= 0) ncount[body[i]]++; } } MPI_Allreduce(ncount,nrigid_shell,nbody,MPI_INT,MPI_SUM,world); } else { - for(ibody=0; ibody < nbody; ibody++) nrigid_shell[ibody]=nrigid[ibody]; + for (ibody=0; ibody < nbody; ibody++) nrigid_shell[ibody]=nrigid[ibody]; } delete [] ncount; @@ -365,29 +365,29 @@ FixLbRigidPCSphere::FixLbRigidPCSphere(LAMMPS *lmp, int narg, char **arg) : int groupbit_lb_fluid = 0; - for(int ifix=0; ifixnfix; ifix++) - if(strcmp(modify->fix[ifix]->style,"lb/fluid")==0){ + for (int ifix=0; ifixnfix; ifix++) + if (strcmp(modify->fix[ifix]->style,"lb/fluid")==0) { fix_lb_fluid = (FixLbFluid *)modify->fix[ifix]; groupbit_lb_fluid = group->bitmask[modify->fix[ifix]->igroup]; } - if(groupbit_lb_fluid == 0) + if (groupbit_lb_fluid == 0) error->all(FLERR,"the lb/fluid fix must also be used if using the lb/rigid/pc/sphere fix"); int *mask = atom->mask; - if(inner_nodes == 1){ - for(int j=0; jbitmask[igroupinner]) && !(mask[j] & groupbit_lb_fluid)) + if (inner_nodes == 1) { + for (int j=0; jbitmask[igroupinner]) && !(mask[j] & groupbit_lb_fluid)) error->one(FLERR,"use the innerNodes keyword in the lb/rigid/pc/sphere fix for atoms which do not interact with the lb/fluid"); // If inner nodes are present, which should not interact with the fluid, make // sure these are not used by the lb/fluid fix to apply a force to the fluid. - if((mask[j] & groupbit) && (mask[j] & groupbit_lb_fluid) && (mask[j] & group->bitmask[igroupinner])) + if ((mask[j] & groupbit) && (mask[j] & groupbit_lb_fluid) && (mask[j] & group->bitmask[igroupinner])) error->one(FLERR,"the inner nodes specified in lb/rigid/pc/sphere should not be included in the lb/fluid fix"); } } else { - for(int j=0; jone(FLERR,"use the innerNodes keyword in the lb/rigid/pc/sphere fix for atoms which do not interact with the lb/fluid"); } } @@ -497,7 +497,7 @@ void FixLbRigidPCSphere::init() MPI_Allreduce(&flag,&extended,1,MPI_INT,MPI_MAX,world); } - if(extended) + if (extended) error->warning(FLERR,"Fix lb/rigid/pc/sphere assumes point particles"); // compute masstotal & center-of-mass of each rigid body @@ -530,8 +530,8 @@ void FixLbRigidPCSphere::init() sum[ibody][1] += yunwrap * massone; sum[ibody][2] += zunwrap * massone; sum[ibody][3] += massone; - if(inner_nodes == 1){ - if(!(mask[i] & group->bitmask[igroupinner])){ + if (inner_nodes == 1) { + if (!(mask[i] & group->bitmask[igroupinner])) { sum[ibody][4] += massone; } } else { @@ -558,10 +558,10 @@ void FixLbRigidPCSphere::init() for (ibody = 0; ibody < nbody; ibody++) for (i = 0; i < 6; i++) sum[ibody][i] = 0.0; - for (i=0; ibitmask[igroupinner])){ + for (i=0; ibitmask[igroupinner])) { ibody = body[i]; xbox = (image[i] & IMGMASK) - IMGMAX; @@ -601,26 +601,26 @@ void FixLbRigidPCSphere::init() MPI_Allreduce(sum[0],all[0],6*nbody,MPI_DOUBLE,MPI_SUM,world); - for(ibody=0; ibody < nbody; ibody++){ + for (ibody=0; ibody < nbody; ibody++) { sphereradius[ibody] = sqrt(all[ibody][0]/nrigid_shell[ibody]); Gamma_MD[ibody] = all[ibody][1]*dm_lb/dt_lb/nrigid_shell[ibody]; } // Check that all atoms in the rigid body have the same value of gamma. double eps = 1.0e-7; - for (i=0; ibitmask[igroupinner])){ + for (i=0; ibitmask[igroupinner])) { ibody = body[i]; - if(Gamma_MD[ibody]*dt_lb/dm_lb - Gamma[type[i]] > eps) + if (Gamma_MD[ibody]*dt_lb/dm_lb - Gamma[type[i]] > eps) error->one(FLERR,"All atoms in a rigid body must have the same gamma value"); } } else { ibody = body[i]; - if(Gamma_MD[ibody]*dt_lb/dm_lb - Gamma[type[i]] > eps) + if (Gamma_MD[ibody]*dt_lb/dm_lb - Gamma[type[i]] > eps) error->one(FLERR,"All atoms in a rigid body must have the same gamma value"); } } @@ -790,8 +790,8 @@ void FixLbRigidPCSphere::initial_integrate(int vflag) if (rmass) massone = rmass[i]; else massone = mass[type[i]]; - if(inner_nodes == 1){ - if(!(mask[i] & group->bitmask[igroupinner])){ + if (inner_nodes == 1) { + if (!(mask[i] & group->bitmask[igroupinner])) { sum[ibody][0] += up[i][0]*massone; sum[ibody][1] += up[i][1]*massone; sum[ibody][2] += up[i][2]*massone; @@ -812,10 +812,10 @@ void FixLbRigidPCSphere::initial_integrate(int vflag) //Store the total torque due to the fluid. for (ibody = 0; ibody < nbody; ibody++) - for(i = 0; i < 6; i++) sum[ibody][i] = 0.0; + for (i = 0; i < 6; i++) sum[ibody][i] = 0.0; - for(i = 0; iunmap(x[i],image[i],unwrap); @@ -827,8 +827,8 @@ void FixLbRigidPCSphere::initial_integrate(int vflag) if (rmass) massone = rmass[i]; else massone = mass[type[i]]; - if(inner_nodes == 1){ - if(!(mask[i] & group->bitmask[igroupinner])){ + if (inner_nodes == 1) { + if (!(mask[i] & group->bitmask[igroupinner])) { sum[ibody][0] += Gamma_MD[ibody]*(dy * ((up[i][2]-vcm[ibody][2])) - dz * ((up[i][1]-vcm[ibody][1]))); sum[ibody][1] += Gamma_MD[ibody]*(dz * ((up[i][0]-vcm[ibody][0])) - @@ -898,15 +898,15 @@ void FixLbRigidPCSphere::initial_integrate(int vflag) expminusdttimesgamma = exp(-Gamma_MD[ibody]*dtv*nrigid_shell[ibody]/masstotal[ibody]); force_factor = force->ftm2v/Gamma_MD[ibody]/nrigid_shell[ibody]; - if(fflag[ibody][0]==1){ + if (fflag[ibody][0]==1) { vcm[ibody][0] = expminusdttimesgamma*(vcm[ibody][0] - ucm[ibody][0] - fcm[ibody][0]*force_factor) + ucm[ibody][0] + fcm[ibody][0]*force_factor; } - if(fflag[ibody][1]==1){ + if (fflag[ibody][1]==1) { vcm[ibody][1] = expminusdttimesgamma*(vcm[ibody][1] - ucm[ibody][1] - fcm[ibody][1]*force_factor) + ucm[ibody][1] + fcm[ibody][1]*force_factor; } - if(fflag[ibody][2]==1){ + if (fflag[ibody][2]==1) { vcm[ibody][2] = expminusdttimesgamma*(vcm[ibody][2] - ucm[ibody][2] - fcm[ibody][2]*force_factor) + ucm[ibody][2] + fcm[ibody][2]*force_factor; } @@ -916,19 +916,19 @@ void FixLbRigidPCSphere::initial_integrate(int vflag) expminusdttimesgamma = exp(-dtv*torque_factor); - if(tflag[ibody][0]==1){ + if (tflag[ibody][0]==1) { omega[ibody][0] = expminusdttimesgamma*(omega[ibody][0] - (3.0/(2.0*nrigid_shell[ibody]*sphereradius[ibody]*sphereradius[ibody]*Gamma_MD[ibody]))* (force->ftm2v*torque[ibody][0] + torque_fluid[ibody][0])) + (3.0/(2.0*nrigid_shell[ibody]*sphereradius[ibody]*sphereradius[ibody]*Gamma_MD[ibody]))* (force->ftm2v*torque[ibody][0] + torque_fluid[ibody][0]); } - if(tflag[ibody][1]==1){ + if (tflag[ibody][1]==1) { omega[ibody][1] = expminusdttimesgamma*(omega[ibody][1] - (3.0/(2.0*nrigid_shell[ibody]*sphereradius[ibody]*sphereradius[ibody]*Gamma_MD[ibody]))* (force->ftm2v*torque[ibody][1] + torque_fluid[ibody][1])) + (3.0/(2.0*nrigid_shell[ibody]*sphereradius[ibody]*sphereradius[ibody]*Gamma_MD[ibody]))* (force->ftm2v*torque[ibody][1] + torque_fluid[ibody][1]); } - if(tflag[ibody][2]==1){ + if (tflag[ibody][2]==1) { omega[ibody][2] = expminusdttimesgamma*(omega[ibody][2] - (3.0/(2.0*nrigid_shell[ibody]*sphereradius[ibody]*sphereradius[ibody]*Gamma_MD[ibody]))* (force->ftm2v*torque[ibody][2] + torque_fluid[ibody][2])) + (3.0/(2.0*nrigid_shell[ibody]*sphereradius[ibody]*sphereradius[ibody]*Gamma_MD[ibody]))* @@ -1040,8 +1040,8 @@ void FixLbRigidPCSphere::final_integrate() dy = unwrap[1] - xcm[ibody][1]; dz = unwrap[2] - xcm[ibody][2]; - if(inner_nodes == 1){ - if(!(mask[i] & group->bitmask[igroupinner])){ + if (inner_nodes == 1) { + if (!(mask[i] & group->bitmask[igroupinner])) { sum[ibody][0] += up[i][0]*massone; sum[ibody][1] += up[i][1]*massone; sum[ibody][2] += up[i][2]*massone; @@ -1148,7 +1148,7 @@ void FixLbRigidPCSphere::set_v() dz = zunwrap - xcm[ibody][2]; // save old velocities for virial. - if(evflag){ + if (evflag) { v0 = v[i][0]; v1 = v[i][1]; v2 = v[i][2]; @@ -1242,7 +1242,7 @@ void FixLbRigidPCSphere::set_xv() dz = zunwrap - xcm_old[ibody][2]; // save old positions and velocities for virial - if(evflag){ + if (evflag) { x0 = xunwrap; x1 = yunwrap; x2 = zunwrap; @@ -1578,8 +1578,8 @@ double FixLbRigidPCSphere::compute_array(int i, int j) double FfP[64]; - for(i=0; i=4) { + if (rsq>=4) { weightx=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weightx=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weightx=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; } } - for(jj=-1; jj<3; jj++){ + for (jj=-1; jj<3; jj++) { rsq=(-dy1+jj)*(-dy1+jj); - if(rsq>=4) { + if (rsq>=4) { weighty=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weighty=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weighty=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; } } - for(kk=-1; kk<3; kk++){ + for (kk=-1; kk<3; kk++) { rsq=(-dz1+kk)*(-dz1+kk); - if(rsq>=4) { + if (rsq>=4) { weightz=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weightz=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weightz=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; @@ -1646,13 +1646,13 @@ double FixLbRigidPCSphere::compute_array(int i, int j) izp = iz+kk; - if(ixp==-1) ixp=subNbx+2; - if(iyp==-1) iyp=subNby+2; - if(izp==-1) izp=subNbz+2; + if (ixp==-1) ixp=subNbx+2; + if (iyp==-1) iyp=subNby+2; + if (izp==-1) izp=subNbz+2; FfP[isten] = weightx*weighty*weightz; // interpolated velocity based on delta function. - for(k=0; k<3; k++){ + for (k=0; k<3; k++) { up[i][k] += u_lb[ixp][iyp][izp][k]*FfP[isten]; } } @@ -1683,7 +1683,7 @@ double FixLbRigidPCSphere::compute_array(int i, int j) + u_lb[ixp][iyp][izp][k]*FfP[7]; } } - for(k=0; k<3; k++) + for (k=0; k<3; k++) up[i][k] = up[i][k]*dx_lb/dt_lb; } diff --git a/src/USER-LB/fix_lb_viscous.cpp b/src/USER-LB/fix_lb_viscous.cpp index d796942941..08a0a10356 100644 --- a/src/USER-LB/fix_lb_viscous.cpp +++ b/src/USER-LB/fix_lb_viscous.cpp @@ -37,19 +37,19 @@ FixLbViscous::FixLbViscous(LAMMPS *lmp, int narg, char **arg) : int groupbit_lb_fluid = 0; - for(int ifix=0; ifixnfix; ifix++) - if(strcmp(modify->fix[ifix]->style,"lb/fluid")==0){ + for (int ifix=0; ifixnfix; ifix++) + if (strcmp(modify->fix[ifix]->style,"lb/fluid")==0) { fix_lb_fluid = (FixLbFluid *)modify->fix[ifix]; groupbit_lb_fluid = group->bitmask[modify->fix[ifix]->igroup]; } - if(groupbit_lb_fluid == 0) + if (groupbit_lb_fluid == 0) error->all(FLERR,"the lb/fluid fix must also be used if using the lb/viscous fix"); int *mask = atom->mask; int nlocal = atom->nlocal; - for(int j=0; jone(FLERR,"to apply a fluid force onto an atom, the lb/fluid fix must be used for that atom."); } diff --git a/src/USER-MANIFOLD/fix_manifoldforce.cpp b/src/USER-MANIFOLD/fix_manifoldforce.cpp index 37f9fac522..bcb14ce1f9 100644 --- a/src/USER-MANIFOLD/fix_manifoldforce.cpp +++ b/src/USER-MANIFOLD/fix_manifoldforce.cpp @@ -86,7 +86,7 @@ FixManifoldForce::FixManifoldForce(LAMMPS *lmp, int narg, char **arg) : // equal style vars (so that they are not overwritten each time step). double *params = ptr_m->params; - for( int i = 0; i < nvars; ++i ){ + for( int i = 0; i < nvars; ++i ) { if (was_var( arg[i+4] )) error->all(FLERR,"Equal-style variables not allowed with fix manifoldforce"); @@ -157,7 +157,7 @@ void FixManifoldForce::post_force(int /*vflag*/) double n[3]; double invn2; double dot; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { // Determine normal of particle: ptr_m->n(x[i],n); diff --git a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp index 49f24fb5b6..bea7955d33 100644 --- a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp +++ b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp @@ -117,7 +117,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, error->all(FLERR, msg); } // Loop over manifold args: - for( int i = 0; i < nvars; ++i ){ + for( int i = 0; i < nvars; ++i ) { int len = 0, offset = 0; if (was_var( arg[i+6] )) { len = strlen(arg[i+6]) - 1; // -1 because -2 for v_, +1 for \0. @@ -135,7 +135,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, ptr_m->params = new double[nvars]; if (!ptr_m->params ) error->all(FLERR,"Failed to allocate params!"); - for( int i = 0; i < nvars; ++i ){ + for( int i = 0; i < nvars; ++i ) { // If param i was variable type, it will be set later... ptr_m->params[i] = is_var[i] ? 0.0 : utils::numeric( FLERR, arg[i+6] ,false,lmp); } @@ -144,7 +144,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, // Loop over rest of args: int argi = 6 + nvars; - while( argi < narg ){ + while( argi < narg ) { if (strcmp(arg[argi], "every") == 0) { nevery = utils::inumeric(FLERR,arg[argi+1],false,lmp); next_output = update->ntimestep + nevery; @@ -170,7 +170,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, FixNVEManifoldRattle::~FixNVEManifoldRattle() { if (tstrs) { - for( int i = 0; i < nvars; ++i ){ + for( int i = 0; i < nvars; ++i ) { delete [] tstrs[i]; } delete [] tstrs; @@ -277,7 +277,7 @@ void FixNVEManifoldRattle::update_var_params() double *ptr_params = ptr_m->params; - for( int i = 0; i < nvars; ++i ){ + for( int i = 0; i < nvars; ++i ) { if (is_var[i]) { tvars[i] = input->variable->find(tstrs[i]); if (tvars[i] < 0) { @@ -306,8 +306,8 @@ int FixNVEManifoldRattle::dof(int /*igroup*/) int *mask = atom->mask; int nlocal = atom->nlocal; int natoms = 0; - for( int i = 0; i < nlocal; ++i ){ - if(mask[i] & groupbit) ++natoms; + for( int i = 0; i < nlocal; ++i ) { + if (mask[i] & groupbit) ++natoms; } int dofs; @@ -362,7 +362,7 @@ void FixNVEManifoldRattle::final_integrate() ---------------------------------------------------------------------------*/ void FixNVEManifoldRattle::end_of_step() { - if (nevery && (update->ntimestep == next_output)){ + if (nevery && (update->ntimestep == next_output)) { if (comm->me == 0) { print_stats( "nve/manifold/rattle" ); next_output += nevery; @@ -386,21 +386,21 @@ void FixNVEManifoldRattle::nve_x_rattle(int igroup, int groupbit) int nlocal = atom->nlocal; int natoms = 0; - if (igroup == atom->firstgroup){ + if (igroup == atom->firstgroup) { nlocal = atom->nfirst; } if (rmass) { - for (int i = 0; i < nlocal; i++){ - if (mask[i] & groupbit){ + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { natoms++; dtfm = dtf / rmass[i]; rattle_manifold_x( x[i], v[i], f[i], dtv, dtfm, atom->tag[i] ); } } } else { - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { natoms++; dtfm = dtf / mass[type[i]]; @@ -442,7 +442,7 @@ void FixNVEManifoldRattle::nve_v_rattle(int igroup, int groupbit) } } } else { - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { dtfm = dtf / mass[type[i]]; rattle_manifold_v( v[i], f[i], x[i], dtfm, atom->tag[i] ); diff --git a/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp b/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp index 76f6ddb3df..d8a5360506 100644 --- a/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp +++ b/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp @@ -165,7 +165,7 @@ FixNVTManifoldRattle::FixNVTManifoldRattle(LAMMPS *lmp, int narg, char **arg, eta_dot[mtchain] = 0.0; eta_dot[mtchain] = 0.0; - for( int ich = 0; ich < mtchain; ++ich ){ + for( int ich = 0; ich < mtchain; ++ich ) { eta[ich] = eta_dot[ich] = eta_dotdot[ich] = 0.0; } @@ -232,11 +232,11 @@ void FixNVTManifoldRattle::setup(int /*vflag*/) // Compute/set eta-masses: double inv_t_freq2 = 1.0 / (t_freq*t_freq); eta_mass[0] = tdof * boltz * t_target * inv_t_freq2; - for( int ich = 1; ich < mtchain; ++ich ){ + for( int ich = 1; ich < mtchain; ++ich ) { eta_mass[ich] = boltz * t_target * inv_t_freq2; } - for( int ich = 1; ich < mtchain; ++ich ){ + for( int ich = 1; ich < mtchain; ++ich ) { eta_dotdot[ich] = (eta_mass[ich-1]*eta_dot[ich-1]*eta_dot[ich-1] - boltz * t_target ) / eta_mass[ich]; } @@ -249,7 +249,7 @@ void FixNVTManifoldRattle::compute_temp_target() tdof = temperature->dof; double delta = update->ntimestep - update->beginstep; - if (delta != 0.0){ + if (delta != 0.0) { delta /= update->endstep - update->beginstep; } @@ -268,7 +268,7 @@ void FixNVTManifoldRattle::nhc_temp_integrate() double expfac, kecurrent = tdof * boltz * t_current; double inv_t_freq2 = 1.0 / (t_freq*t_freq); eta_mass[0] = tdof * boltz * t_target * inv_t_freq2; - for( int ich = 1; ich < mtchain; ++ich ){ + for( int ich = 1; ich < mtchain; ++ich ) { eta_mass[ich] = boltz * t_target * inv_t_freq2; } @@ -278,7 +278,7 @@ void FixNVTManifoldRattle::nhc_temp_integrate() eta_dotdot[0] = 0; } - for( ich = mtchain-1; ich > 0; --ich ){ + for( ich = mtchain-1; ich > 0; --ich ) { expfac = exp(-dt8*eta_dot[ich+1]); eta_dot[ich] *= expfac; eta_dot[ich] += eta_dotdot[ich] * dt4; @@ -311,14 +311,14 @@ void FixNVTManifoldRattle::nhc_temp_integrate() eta_dotdot[0] = 0.0; } - for( int ich = 1; ich < mtchain; ++ich ){ + for( int ich = 1; ich < mtchain; ++ich ) { eta[ich] += dthalf*eta_dot[ich]; } eta_dot[0] *= expfac; eta_dot[0] += eta_dotdot[0]*dt4; eta_dot[0] *= expfac; - for( int ich = 1; ich < mtchain; ++ich ){ + for( int ich = 1; ich < mtchain; ++ich ) { expfac = exp(-dt8*eta_dot[ich+1]); eta_dot[ich] *= expfac; eta_dotdot[ich] = (eta_mass[ich-1]*eta_dot[ich-1]*eta_dot[ich-1] @@ -340,7 +340,7 @@ void FixNVTManifoldRattle::nh_v_temp() if (which == NOBIAS) { - for( int i = 0; i < nlocal; ++i ){ + for( int i = 0; i < nlocal; ++i ) { if (mask[i] & groupbit) { v[i][0] *= factor_eta; v[i][1] *= factor_eta; @@ -348,7 +348,7 @@ void FixNVTManifoldRattle::nh_v_temp() } } } else if (which == BIAS) { - for( int i = 0; i < nlocal; ++i ){ + for( int i = 0; i < nlocal; ++i ) { if (mask[i] & groupbit) { temperature->remove_bias(i,v[i]); v[i][0] *= factor_eta; diff --git a/src/USER-MANIFOLD/manifold_gaussian_bump.cpp b/src/USER-MANIFOLD/manifold_gaussian_bump.cpp index 7b0d7d4d3a..0864e1e2f2 100644 --- a/src/USER-MANIFOLD/manifold_gaussian_bump.cpp +++ b/src/USER-MANIFOLD/manifold_gaussian_bump.cpp @@ -69,7 +69,7 @@ public: double ff = x(t) - xx; double ffp = xp(t); // double l = 1.0 / ( 1 + res*res ); - for( int i = 0; i < maxit; ++i ){ + for( int i = 0; i < maxit; ++i ) { t -= ff / ffp; ff = x(t) - xx; ffp = xp(t); @@ -294,7 +294,7 @@ void manifold_gaussian_bump::make_lut() cubic_hermite pchip( lut_x0, lut_x1, f_at_rc, 0.0, fp_at_rc, 0.0, error ); double xx = lut_x0; - for( int i = 0; i <= lut_Nbins; ++i ){ + for( int i = 0; i <= lut_Nbins; ++i ) { lut_z[i] = pchip.y_from_x( xx ); lut_zp[i] = pchip.yp_from_x( xx ); xx += lut_dx; @@ -355,7 +355,7 @@ void manifold_gaussian_bump::test_lut() FILE *fp = fopen( "test_lut_gaussian.dat", "w" ); double dx = 0.1; - for( double xx = 0; xx < 20; xx += dx ){ + for( double xx = 0; xx < 20; xx += dx ) { x[0] = xx; x[1] = 0.0; x[2] = 0.0; diff --git a/src/USER-MANIFOLD/manifold_thylakoid.cpp b/src/USER-MANIFOLD/manifold_thylakoid.cpp index a1d2c7a62f..c4dfd33c30 100644 --- a/src/USER-MANIFOLD/manifold_thylakoid.cpp +++ b/src/USER-MANIFOLD/manifold_thylakoid.cpp @@ -25,7 +25,7 @@ manifold_thylakoid::manifold_thylakoid( LAMMPS *lmp, int /*narg*/, char ** /*arg manifold_thylakoid::~manifold_thylakoid() { - for(std::size_t i = 0; i < parts.size(); ++i) { + for (std::size_t i = 0; i < parts.size(); ++i) { delete parts[i]; } } @@ -60,14 +60,14 @@ void manifold_thylakoid::checkup() if (comm->me == 0 ) { fprintf(screen,"This is checkup of thylakoid %p\n", this); fprintf(screen,"I have %ld parts. They are:\n", parts.size()); - for( int i = 0; i < (int)parts.size(); ++i ){ + for ( int i = 0; i < (int)parts.size(); ++i ) { fprintf(screen, "[%f, %f] x [%f, %f] x [%f, %f]\n", parts[i]->xlo, parts[i]->xhi, parts[i]->ylo, parts[i]->yhi, parts[i]->zlo, parts[i]->zhi ); } fprintf(screen,"My params are:\n"); - for( int i = 0; i < NPARAMS; ++i ){ + for ( int i = 0; i < NPARAMS; ++i ) { fprintf(screen,"%f\n", params[i]); } } @@ -79,7 +79,7 @@ double manifold_thylakoid::g( const double *x ) int err = 0; std::size_t idx; thyla_part *p = get_thyla_part(x,&err,&idx); - if(err){ + if (err) { char msg[2048]; sprintf(msg,"Error getting thyla_part for x = (%f, %f, %f)",x[0],x[1],x[2]); error->one(FLERR,msg); @@ -101,7 +101,7 @@ void manifold_thylakoid::n( const double *x, double *n ) int err = 0; std::size_t idx; thyla_part *p = get_thyla_part(x,&err,&idx); - if(err){ + if (err) { char msg[2048]; sprintf(msg,"Error getting thyla_part for x = (%f, %f, %f)",x[0],x[1],x[2]); error->one(FLERR,msg); @@ -120,7 +120,7 @@ void manifold_thylakoid::n( const double *x, double *n ) thyla_part *manifold_thylakoid::get_thyla_part( const double *x, int * /*err_flag*/, std::size_t *idx ) { - for( std::size_t i = 0; i < parts.size(); ++i ){ + for ( std::size_t i = 0; i < parts.size(); ++i ) { thyla_part *p = parts[i]; if (is_in_domain(p,x)) { if (idx != nullptr) *idx = i; @@ -185,17 +185,17 @@ void manifold_thylakoid::init_domains() #ifndef USE_PHONY_LAMMPS char msg[2048]; - if(x1 > domain->boxhi[0]){ + if (x1 > domain->boxhi[0]) { sprintf(msg,"Expected xhi larger than current box has: %f > %f", x1, domain->boxhi[0]); error->one(FLERR,msg); } - if(y1 > domain->boxhi[1]){ + if (y1 > domain->boxhi[1]) { sprintf(msg,"Expected yhi larger than current box has: %f > %f", y1, domain->boxhi[1]); error->one(FLERR,msg); } - // if(z1 > domain->boxhi[2]){ + // if (z1 > domain->boxhi[2]) { // sprintf(msg,"Expected zhi larger than current box has: %f > %f", // z1, domain->boxhi[2]); // error->one(FLERR,msg); @@ -604,7 +604,7 @@ thyla_part *manifold_thylakoid::make_cyl_to_plane_part(double X0, double R0, dou void manifold_thylakoid::print_part_data( FILE *fp_doms, FILE *fp_coms ) { - for( std::size_t i = 0; i < parts.size(); ++i ){ + for ( std::size_t i = 0; i < parts.size(); ++i ) { thyla_part *p = parts[i]; fprintf(fp_doms, "%f %f\n", p->xlo, p->ylo); fprintf(fp_doms, "%f %f\n", p->xlo, p->yhi); diff --git a/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp b/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp index 1c6b4dd06a..c0b6871ea8 100644 --- a/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp +++ b/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp @@ -10,7 +10,7 @@ thyla_part::thyla_part( int type, double *args, double xlo, double ylo, double z : type(type), xlo(xlo), xhi(xhi), ylo(ylo), yhi(yhi), zlo(zlo), zhi(zhi) { - switch(type){ + switch(type) { case THYLA_TYPE_PLANE: // a*(x-x0) + b*(y-y0) + c*(z-z0) = 0 params[0] = args[0]; // a params[1] = args[1]; // b @@ -40,7 +40,7 @@ thyla_part::thyla_part( int type, double *args, double xlo, double ylo, double z // The others should be 1. if ( (args[0] != 1.0) && (args[0] != 0.0) && (args[1] != 1.0) && (args[1] != 0.0) && - (args[2] != 1.0) && (args[2] != 0.0) ){ + (args[2] != 1.0) && (args[2] != 0.0) ) { err_flag = -1; } break; @@ -83,7 +83,7 @@ thyla_part::~thyla_part() double thyla_part::g(const double *x) { - switch(type){ + switch(type) { case THYLA_TYPE_PLANE:{ // a*(x-x0) + b*(y-y0) + c*(z-z0) = 0 double a = params[0]; double b = params[1]; @@ -144,7 +144,7 @@ double thyla_part::g(const double *x) void thyla_part::n( const double *x, double *n ) { - switch(type){ + switch(type) { case THYLA_TYPE_PLANE:{ // a*(x-x0) + b*(y-y0) + c*(z-z0) = 0 double a = params[0]; double b = params[1]; diff --git a/src/USER-MEAMC/meam_funcs.cpp b/src/USER-MEAMC/meam_funcs.cpp index 7f4067a1e5..7292dd64b0 100644 --- a/src/USER-MEAMC/meam_funcs.cpp +++ b/src/USER-MEAMC/meam_funcs.cpp @@ -383,7 +383,7 @@ MEAM::get_Zij2(const lattice_t latt, const double cmin, const double cmax, } // Compute screening for each first neighbor - if (latt==DIA3){ // special case for 3NN diamond structure + if (latt==DIA3) { // special case for 3NN diamond structure C = 1.0; } else { C = 4.0 / (a * a) - 1.0; diff --git a/src/USER-MEAMC/meam_setup_done.cpp b/src/USER-MEAMC/meam_setup_done.cpp index 84a11c607b..3a62bf0942 100644 --- a/src/USER-MEAMC/meam_setup_done.cpp +++ b/src/USER-MEAMC/meam_setup_done.cpp @@ -488,8 +488,8 @@ MEAM::phi_meam(double r, int a, int b) } else if (this->lattce_meam[a][b] == CH4) { phi_m = (5 * Eu - F1 - 4*F2)/4; - } else if (this->lattce_meam[a][b] == ZIG){ - if (a==b){ + } else if (this->lattce_meam[a][b] == ZIG) { + if (a==b) { phi_m = (2 * Eu - F1 - F2) / Z12; } else{ Z1 = get_Zij(this->lattce_meam[a][b]); @@ -504,7 +504,7 @@ MEAM::phi_meam(double r, int a, int b) } } else if (this->lattce_meam[a][b] == TRI) { - if (a==b){ + if (a==b) { phi_m = (3.0*Eu - 2.0*F1 - F2) / Z12; } else { Z1 = get_Zij(this->lattce_meam[a][b]); diff --git a/src/USER-MESODPD/fix_edpd_source.cpp b/src/USER-MESODPD/fix_edpd_source.cpp index 39c250141e..98a36e589a 100644 --- a/src/USER-MESODPD/fix_edpd_source.cpp +++ b/src/USER-MESODPD/fix_edpd_source.cpp @@ -37,7 +37,7 @@ FixEDPDSource::FixEDPDSource(LAMMPS *lmp, int narg, char **arg) : else error->all(FLERR,"Illegal fix edpd/source command"); iarg++; - if(option == 0){ + if (option == 0) { if (narg != 9 ) error->all(FLERR,"Illegal fix edpd/source command (5 args for sphere)"); center[0] = utils::numeric(FLERR,arg[iarg++],false,lmp); center[1] = utils::numeric(FLERR,arg[iarg++],false,lmp); @@ -45,7 +45,7 @@ FixEDPDSource::FixEDPDSource(LAMMPS *lmp, int narg, char **arg) : radius = utils::numeric(FLERR,arg[iarg++],false,lmp); value = utils::numeric(FLERR,arg[iarg++],false,lmp); } - else if(option == 1){ + else if (option == 1) { if (narg != 11 ) error->all(FLERR,"Illegal fix edpd/edpd command (7 args for cuboid)"); center[0] = utils::numeric(FLERR,arg[iarg++],false,lmp); center[1] = utils::numeric(FLERR,arg[iarg++],false,lmp); @@ -94,19 +94,19 @@ void FixEDPDSource::post_force(int /*vflag*/) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if(option == 0){ + if (option == 0) { drx = x[i][0] - center[0]; dry = x[i][1] - center[1]; drz = x[i][2] - center[2]; rsq = drx*drx + dry*dry + drz*drz; - if(rsq < radius_sq) + if (rsq < radius_sq) edpd_flux[i] += value*edpd_cv[i]; } - else if(option == 1){ + else if (option == 1) { drx = x[i][0] - center[0]; dry = x[i][1] - center[1]; drz = x[i][2] - center[2]; - if(fabs(drx) <= 0.5*dLx && fabs(dry) <= 0.5*dLy && fabs(drz) <= 0.5*dLz) + if (fabs(drx) <= 0.5*dLx && fabs(dry) <= 0.5*dLy && fabs(drz) <= 0.5*dLz) edpd_flux[i] += value*edpd_cv[i]; } } diff --git a/src/USER-MESODPD/fix_mvv_dpd.cpp b/src/USER-MESODPD/fix_mvv_dpd.cpp index d8b36e12f4..7d8658a065 100644 --- a/src/USER-MESODPD/fix_mvv_dpd.cpp +++ b/src/USER-MESODPD/fix_mvv_dpd.cpp @@ -39,7 +39,7 @@ FixMvvDPD::FixMvvDPD(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Illegal fix mvv/dpd command"); verlet = 0.5; - if(narg > 3) verlet = utils::numeric(FLERR,arg[3],false,lmp); + if (narg > 3) verlet = utils::numeric(FLERR,arg[3],false,lmp); dynamic_group_allow = 1; time_integrate = 1; diff --git a/src/USER-MESODPD/fix_mvv_edpd.cpp b/src/USER-MESODPD/fix_mvv_edpd.cpp index 9cb4b86d85..200ab2564e 100644 --- a/src/USER-MESODPD/fix_mvv_edpd.cpp +++ b/src/USER-MESODPD/fix_mvv_edpd.cpp @@ -48,7 +48,7 @@ FixMvvEDPD::FixMvvEDPD(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Illegal fix mvv/edpd command"); verlet = 0.5; - if(narg > 3) verlet = utils::numeric(FLERR,arg[3],false,lmp); + if (narg > 3) verlet = utils::numeric(FLERR,arg[3],false,lmp); dynamic_group_allow = 1; time_integrate = 1; diff --git a/src/USER-MESODPD/fix_mvv_tdpd.cpp b/src/USER-MESODPD/fix_mvv_tdpd.cpp index 84a7fdbaf9..8819595174 100644 --- a/src/USER-MESODPD/fix_mvv_tdpd.cpp +++ b/src/USER-MESODPD/fix_mvv_tdpd.cpp @@ -44,7 +44,7 @@ FixMvvTDPD::FixMvvTDPD(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Illegal fix mvv/tdpd command"); verlet = 0.5; - if(narg > 3) verlet = utils::numeric(FLERR,arg[3],false,lmp); + if (narg > 3) verlet = utils::numeric(FLERR,arg[3],false,lmp); cc_species = atom->cc_species; @@ -107,7 +107,7 @@ void FixMvvTDPD::initial_integrate(int /*vflag*/) v[i][0] += 2.0 * verlet * dtfm * f[i][0]; v[i][1] += 2.0 * verlet * dtfm * f[i][1]; v[i][2] += 2.0 * verlet * dtfm * f[i][2]; - for(int k = 0; k < cc_species; k++) + for (int k = 0; k < cc_species; k++) cc[i][k] += 0.5 * dtv * cc_flux[i][k]; } } @@ -140,7 +140,7 @@ void FixMvvTDPD::final_integrate() v[i][0] = vest[i][0] + dtfm * f[i][0]; v[i][1] = vest[i][1] + dtfm * f[i][1]; v[i][2] = vest[i][2] + dtfm * f[i][2]; - for(int k = 0; k < cc_species; k++) + for (int k = 0; k < cc_species; k++) cc[i][k] += 0.5 * dtv * cc_flux[i][k]; } } diff --git a/src/USER-MESODPD/fix_tdpd_source.cpp b/src/USER-MESODPD/fix_tdpd_source.cpp index 25a8332e9f..c0669552ff 100644 --- a/src/USER-MESODPD/fix_tdpd_source.cpp +++ b/src/USER-MESODPD/fix_tdpd_source.cpp @@ -38,7 +38,7 @@ FixTDPDSource::FixTDPDSource(LAMMPS *lmp, int narg, char **arg) : else error->all(FLERR,"Illegal fix tdpd/source command"); iarg++; - if(option == 0){ + if (option == 0) { if (narg != 10 ) error->all(FLERR,"Illegal fix tdpd/source command (5 args for sphere)"); center[0] = utils::numeric(FLERR,arg[iarg++],false,lmp); center[1] = utils::numeric(FLERR,arg[iarg++],false,lmp); @@ -46,7 +46,7 @@ FixTDPDSource::FixTDPDSource(LAMMPS *lmp, int narg, char **arg) : radius = utils::numeric(FLERR,arg[iarg++],false,lmp); value = utils::numeric(FLERR,arg[iarg++],false,lmp); } - else if(option == 1){ + else if (option == 1) { if (narg != 12 ) error->all(FLERR,"Illegal fix tdpd/edpd command (7 args for cuboid)"); center[0] = utils::numeric(FLERR,arg[iarg++],false,lmp); center[1] = utils::numeric(FLERR,arg[iarg++],false,lmp); @@ -94,19 +94,19 @@ void FixTDPDSource::post_force(int /*vflag*/) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if(option == 0){ + if (option == 0) { drx = x[i][0] - center[0]; dry = x[i][1] - center[1]; drz = x[i][2] - center[2]; rsq = drx*drx + dry*dry + drz*drz; - if(rsq < radius_sq) + if (rsq < radius_sq) cc_flux[i][cc_index-1] += value; } - else if(option == 1){ + else if (option == 1) { drx = x[i][0] - center[0]; dry = x[i][1] - center[1]; drz = x[i][2] - center[2]; - if(fabs(drx) <= 0.5*dLx && fabs(dry) <= 0.5*dLy && fabs(drz) <= 0.5*dLz) + if (fabs(drx) <= 0.5*dLx && fabs(dry) <= 0.5*dLy && fabs(drz) <= 0.5*dLz) cc_flux[i][cc_index-1] += value; } } diff --git a/src/USER-MESODPD/pair_edpd.cpp b/src/USER-MESODPD/pair_edpd.cpp index c3b4d3b1fe..f7201052ff 100644 --- a/src/USER-MESODPD/pair_edpd.cpp +++ b/src/USER-MESODPD/pair_edpd.cpp @@ -162,9 +162,9 @@ void PairEDPD::compute(int eflag, int vflag) T_pow[3] = T_pow[0]*T_pow[2]; double power_d = power[itype][jtype]; - if(power_flag){ + if (power_flag) { double factor = 1.0; - for(int k = 0; k < 4; k++) + for (int k = 0; k < 4; k++) factor += sc[itype][jtype][k]*T_pow[k]; power_d *= factor; } @@ -197,9 +197,9 @@ void PairEDPD::compute(int eflag, int vflag) randnumT = MAX(-5.0,MIN(randnum,5.0)); double kappaT = kappa[itype][jtype]; - if(kappa_flag) { + if (kappa_flag) { double factor = 1.0; - for(int k = 0; k < 4; k++) + for (int k = 0; k < 4; k++) factor += kc[itype][jtype][k]*T_pow[k]; kappaT *= factor; } @@ -350,11 +350,11 @@ void PairEDPD::coeff(int narg, char **arg) powerT[i][j]= powerT_one; cutT[i][j] = cutT_one; - if(power_flag) + if (power_flag) for (int k = 0; k < 4; k++) sc[i][j][k] = sc_one[k]; - if(kappa_flag) + if (kappa_flag) for (int k = 0; k < 4; k++) kc[i][j][k] = kc_one[k]; @@ -399,11 +399,11 @@ double PairEDPD::init_one(int i, int j) kappa[j][i] = kappa[i][j]; powerT[j][i]= powerT[i][j]; - if(power_flag) + if (power_flag) for (int k = 0; k < 4; k++) sc[j][i][k] = sc[i][j][k]; - if(kappa_flag) + if (kappa_flag) for (int k = 0; k < 4; k++) kc[j][i][k] = kc[i][j][k]; @@ -429,11 +429,11 @@ void PairEDPD::write_restart(FILE *fp) fwrite(&kappa[i][j],sizeof(double),1,fp); fwrite(&powerT[i][j],sizeof(double),1,fp); fwrite(&cutT[i][j],sizeof(double),1,fp); - if(power_flag) + if (power_flag) for (int k = 0; k < 4; k++) fwrite(&sc[i][j][k],sizeof(double),1,fp); - if(kappa_flag) + if (kappa_flag) for (int k = 0; k < 4; k++) fwrite(&kc[i][j][k],sizeof(double),1,fp); } @@ -464,11 +464,11 @@ void PairEDPD::read_restart(FILE *fp) utils::sfread(FLERR,&kappa[i][j],sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR,&powerT[i][j],sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR,&cutT[i][j],sizeof(double),1,fp,nullptr,error); - if(power_flag) + if (power_flag) for (int k = 0; k < 4; k++) utils::sfread(FLERR,&sc[i][j][k],sizeof(double),1,fp,nullptr,error); - if(kappa_flag) + if (kappa_flag) for (int k = 0; k < 4; k++) utils::sfread(FLERR,&kc[i][j][k],sizeof(double),1,fp,nullptr,error); } @@ -479,11 +479,11 @@ void PairEDPD::read_restart(FILE *fp) MPI_Bcast(&kappa[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&powerT[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&cutT[i][j],1,MPI_DOUBLE,0,world); - if(power_flag) + if (power_flag) for (int k = 0; k < 4; k++) MPI_Bcast(&sc[i][j][k],1,MPI_DOUBLE,0,world); - if(kappa_flag) + if (kappa_flag) for (int k = 0; k < 4; k++) MPI_Bcast(&kc[i][j][k],1,MPI_DOUBLE,0,world); } diff --git a/src/USER-MESODPD/pair_mdpd.cpp b/src/USER-MESODPD/pair_mdpd.cpp index 0506886861..4dc42eb56a 100644 --- a/src/USER-MESODPD/pair_mdpd.cpp +++ b/src/USER-MESODPD/pair_mdpd.cpp @@ -241,7 +241,7 @@ void PairMDPD::settings(int narg, char **arg) void PairMDPD::coeff(int narg, char **arg) { - if(narg != 7 ) error->all(FLERR,"Incorrect args for pair coefficients\n itype jtype A B gamma cutA cutB"); + if (narg != 7 ) error->all(FLERR,"Incorrect args for pair coefficients\n itype jtype A B gamma cutA cutB"); if (!allocated) allocate(); int ilo,ihi,jlo,jhi; @@ -254,7 +254,7 @@ void PairMDPD::coeff(int narg, char **arg) double cut_one = utils::numeric(FLERR,arg[5],false,lmp); double cut_two = utils::numeric(FLERR,arg[6],false,lmp); - if(cut_one < cut_two) error->all(FLERR,"Incorrect args for pair coefficients\n cutA should be larger than cutB."); + if (cut_one < cut_two) error->all(FLERR,"Incorrect args for pair coefficients\n cutA should be larger than cutB."); int count = 0; for (int i = ilo; i <= ihi; i++) { diff --git a/src/USER-MESODPD/pair_tdpd.cpp b/src/USER-MESODPD/pair_tdpd.cpp index 88d89a860d..a416d94a00 100644 --- a/src/USER-MESODPD/pair_tdpd.cpp +++ b/src/USER-MESODPD/pair_tdpd.cpp @@ -159,7 +159,7 @@ void PairTDPD::compute(int eflag, int vflag) // chemical concentration transport if (r < cutcc[itype][jtype]) { - for(int k=0; k b) + else if (a > b) return 1; else return 0; @@ -66,7 +66,7 @@ static void getparmindata(const char *potin_file,int nvol[1],double vol0[1],doub FILE *in = fopen(potin_file,"r"); char line[1024]; - if(in == nullptr) { + if (in == nullptr) { fprintf(stderr,"@%s:%d: Error reading potin file. Can not open file \'%s\'.\n", __FILE__,__LINE__,potin_file); exit(1); @@ -80,22 +80,22 @@ static void getparmindata(const char *potin_file,int nvol[1],double vol0[1],doub double r0x,r1x,drx; int nrx,i; - if(line[strspn(line," \t")] == '#') continue; + if (line[strspn(line," \t")] == '#') continue; - if(n == 0) { + if (n == 0) { metal[0] = 0; - if(sscanf(line,"%s %d %d",metal,&ipot,&mode) != 3) { + if (sscanf(line,"%s %d %d",metal,&ipot,&mode) != 3) { fprintf(stderr,"@%s:%d: Error on potin file. line = %s\n", __FILE__,__LINE__,line); exit(1); } } else { metalx[0] = 0; - if(sscanf(line,"%s %d %d",metalx,&ipotx,&modex) != 3) { + if (sscanf(line,"%s %d %d",metalx,&ipotx,&modex) != 3) { fprintf(stderr,"@%s:%d: Error on potin file. line = %s\n", __FILE__,__LINE__,line); exit(1); - } else if(strcmp(metal,metalx) != 0 || ipot != ipotx || mode != modex) { + } else if (strcmp(metal,metalx) != 0 || ipot != ipotx || mode != modex) { fprintf(stderr,"@%s:%d: Error on potin file, parameter mismatch:\n" " metal = \'%s\' ipot = %d mode = %d\n" " metalx = \'%s\' ipotx = %d modex = %d\n", @@ -108,39 +108,39 @@ static void getparmindata(const char *potin_file,int nvol[1],double vol0[1],doub fgets(line,sizeof(line),in); sscanf(line,"%lf %lf %lf %lf",&zval,&ivol,&rws,&mass); - if(n >= vsize) { + if (n >= vsize) { vsize = 2*vsize; volarr = (double *) realloc(volarr,sizeof(double) * vsize); } volarr[n] = ivol; n = n + 1; - for(i = 0; i<5; i++) + for (i = 0; i<5; i++) fgets(line,sizeof(line),in); sscanf(line,"%lf %lf %lf",&r0x,&r1x,&drx); nrx = (int) ((r1x-r0x)/drx + 1.1); /* Really: 1+round((r1-r0)/dr) */ - for(i = 0; i nvol = %d, vol0 = %.6f, x0= %.6f, x1 = %.6f, dx = %.6f\n", nvol,vol0,x0,x1,dx); } @@ -214,8 +214,8 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl anorm3 = s*ss + 2.0*( p*pp + d*dd + f*ff); anorm4 = ss*ss + 2.0*(pp*pp + dd*dd + ff*ff); /* - for(i = 1; i<=lmax; i++) { - for(j = 1; j<=lmax; j++) + for (i = 1; i<=lmax; i++) { + for (j = 1; j<=lmax; j++) del0.m[i][j] = 0.0; del0[i][i] = 1.0; } @@ -237,10 +237,10 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl in = fopen(potin_file,"r"); int *tag = new int[nx]; - for(i = 0; i 1e-3) + if (fabs(volguess/ivol - 1.0) > 1e-3) printf("Wrong volume guess, i=%d volgues=%15.5e ivol=%15.5e\n", i,volguess,ivol); }*/ double ifrac = (pow(ivol/vol0,1.0/3.0) - x0)/((x1-x0)/(nx-1)); i = (int) (ifrac + 0.1); - if(fabs(i - ifrac) > 0.01) { + if (fabs(i - ifrac) > 0.01) { printf("Volume point not in table... ii=%d i=%d ifrac=%15.5e vol=%15.5e\n", ii,i,ifrac,ivol); printf("vol0 = %15.5e zval = %15.5e mass = %15.5e\n",vol0,zval,mass); exit(1); - } else if(tag[i] == 1) { + } else if (tag[i] == 1) { printf("Duplicate volume point in table.... ii=%d i=%d ifrac=%15.5e vol=%15.5e\n", ii,i,ifrac,ivol); exit(1); @@ -334,7 +334,7 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl fgets(line,sizeof(line),in); sscanf(line,"%lf %lf %lf %lf %lf", &vatab[i],&vbtab[i],&vctab[i],&vdtab[i],&vetab[i]); - if(ipot == 1) { + if (ipot == 1) { vatab[i] *= vdtab[i]; vctab[i] *= vctab[i]; vetab[i] *= vetab[i]; @@ -346,14 +346,14 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl sscanf(line,"%lf %lf %lf",&r0x,&r1x,&drx); nrx = (int) ((r1x-r0x)/drx + 1.1); /* Really: 1+round((r1-r0)/dr) */ - if(ii == 0) { + if (ii == 0) { r0 = r0x; r1 = r1x; dr = drx; nr = nrx; vpairtab = new double[nx*nr]; } else { /* Check that {r0,r1,dr,nr}x == {r0,r1,dr,nr} */ } - for(j = 0; j= r0rws) { + if (bscreen == 1 && rrws >= r0rws) { double arg = rrws/r0rwstab[i]; double arg1 = arg - 1.0; double arg12 = arg1*arg1; double f,dp; - if(mode <= 2) { + if (mode <= 2) { f = fgauss(arg,al); dp=2.*al*arg*arg1; } @@ -407,16 +407,16 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl double vpair_tmp = vpairtab[i*nr+j]; vpairtab[i*nr+j] = vpairtab[i*nr+j]*fscr + v2a - v2b; - if(0) if(fabs(vol-ivol) < 0.01) { + if (0) if (fabs(vol-ivol) < 0.01) { static FILE *xfile = nullptr; - if(j == 0) { + if (j == 0) { xfile = fopen("mgpt5-pot.dat","w"); fprintf(xfile,"%%%% vol = %15.5e ivol = %15.5e i = %d ii = %d\n", vol,ivol,i,ii); } fprintf(xfile,"%15.5e %15.5e %15.5e %15.5e %15.5e %20.10e\n", r,vpair_tmp,fscr,v2a,v2b,flr); - if(j == nr-1) fclose(xfile); + if (j == nr-1) fclose(xfile); } @@ -426,8 +426,8 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl } fclose(in); - for(i = 0; i0; i--) { + for (int i = n-1; i>0; i--) { double q = A[i-1][2] / A[i][1]; A[i-1][1] = A[i-1][1] - q*A[i][0]; y[i-1] = y[i-1] - q*y[i]; @@ -28,7 +28,7 @@ static void trisolve(int n,double A[][3],double y[]) { /* Forward substitution */ y[0] = y[0] / A[0][1]; - for(int i = 1; i n-1) idx = n-1; + if (idx < 0) idx = 0; + if (idx > n-1) idx = n-1; xhat = xhat - idx; p = C[idx]; - if(0) { + if (0) { *y = p[0] + xhat*(p[1] + xhat*(p[2] + xhat*p[3])); *dy = p[1] + xhat*(2*p[2] + xhat*3*p[3]); diff --git a/src/USER-MGPT/pair_mgpt.cpp b/src/USER-MGPT/pair_mgpt.cpp index c056258127..b358b12857 100644 --- a/src/USER-MGPT/pair_mgpt.cpp +++ b/src/USER-MGPT/pair_mgpt.cpp @@ -51,7 +51,7 @@ using namespace LAMMPS_NS; #endif static double gettime(int x = 0) { - if(1) { + if (1) { /* struct timeval tv; gettimeofday(&tv,nullptr); @@ -93,7 +93,7 @@ PairMGPT::PairMGPT(LAMMPS *lmp) : Pair(lmp) PairMGPT::~PairMGPT() { - if(allocated) { + if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); memory->destroy(cutghost); @@ -107,8 +107,8 @@ static double t_make_b2 = 0.0,n_make_b2 = 0.0; template void fmatconv(intype *array) { outtype *cast = (outtype *) array; - for(int i = 0; iHz.m)) & 31) == 0 ); rij = 0.0; - for(p = 0; p<3; p++) { + for (p = 0; p<3; p++) { rrij[p] = xx[i][p] - xx[j][p]; rij = rij + rrij[p]*rrij[p]; } /* Zero all matrix elements */ - for(i = 0; i<8; i++) - for(j = 0; j<8; j++) { + for (i = 0; i<8; i++) + for (j = 0; j<8; j++) { bptr->H.m[i][j] = 0.0; bptr->Hx.m[i][j] = 0.0; bptr->Hy.m[i][j] = 0.0; @@ -140,9 +140,9 @@ void PairMGPT::make_bond(const double xx[][3],int i,int j,bond_data *bptr) { bptr->Hz.m[j][i] = 0.0; } - if(rij <= rcrit*rcrit) { + if (rij <= rcrit*rcrit) { t0 = gettime(); - if(lang == 3) { + if (lang == 3) { hamltn_5_raw(rrij[0],rrij[1],rrij[2], bptr->H.m ,bptr->Hx.m, bptr->Hy.m,bptr->Hz.m,&bptr->fl_deriv_sum); @@ -159,7 +159,7 @@ void PairMGPT::make_bond(const double xx[][3],int i,int j,bond_data *bptr) { bptr->fl_deriv_sum = 0.0; } - if(linalg.single) { + if (linalg.single) { fmatconv(&(bptr->H.m[1][0])); fmatconv(&(bptr->Hx.m[1][0])); fmatconv(&(bptr->Hy.m[1][0])); @@ -174,12 +174,12 @@ static inline double mtrace(int n,double A[8][8],double B[8][8]) { double s; t0 = gettime(); - if(n == 5) s = mtrace_5(A,B); - else if(n == 7) s = mtrace_7(A,B); + if (n == 5) s = mtrace_5(A,B); + else if (n == 7) s = mtrace_7(A,B); else { s = 0.0; - for(int i = 1; i<=n; i++) - for(int j = 1; j<=n; j++) + for (int i = 1; i<=n; i++) + for (int j = 1; j<=n; j++) s = s + A[i][j]*B[i][j]; } t1 = gettime(); @@ -192,7 +192,7 @@ static inline double mtrace(int n,double A[8][8],double B[8][8]) { void PairMGPT::make_triplet(bond_data *ij_bond,bond_data *ik_bond, triplet_data *triptr) { - if(1) { + if (1) { const trmul_fun tr_mul = linalg.tr_mul; tr_mul(&(ij_bond->H.m[1][0]), &(ik_bond->H.m[1][0]) ,&(triptr->H1H2.m[1][0]) ); tr_mul(&(ij_bond->Hx.m[1][0]),&(ik_bond->H.m[1][0]) ,&(triptr->H1xH2.m[1][0])); @@ -227,28 +227,28 @@ PairMGPT::triplet_data *PairMGPT::get_triplet(const double xx[][3],int i,int j,i triplet_data *tptr = 0; t0 = gettime(); - if(recompute == 0) { + if (recompute == 0) { bij = bhash->Lookup(Doublet(i,j)); bik = bhash->Lookup(Doublet(i,k)); } - if(bij == 0) { - if(recompute == 0) + if (bij == 0) { + if (recompute == 0) bij = bhash->Insert(Doublet(i,j)); else bij = &bij_work; - if(i < j) + if (i < j) make_bond(xx,i,j,bij); else make_bond(xx,j,i,bij); } - if(bik == 0) { - if(recompute == 0) + if (bik == 0) { + if (recompute == 0) bik = bhash->Insert(Doublet(i,k)); else bik = &bik_work; - if(i < k) + if (i < k) make_bond(xx,i,k,bik); else make_bond(xx,k,i,bik); @@ -257,7 +257,7 @@ PairMGPT::triplet_data *PairMGPT::get_triplet(const double xx[][3],int i,int j,i t_make_b += t1-t0; t0 = gettime(); - if(bij != 0 && bij != 0) { + if (bij != 0 && bij != 0) { tptr = twork; make_triplet(bij,bik,tptr); *dvir_ij_p = bij->fl_deriv_sum; @@ -290,7 +290,7 @@ double PairMGPT::numderiv3t(double xx[][3],int i,int j,int k,int p) { xx[i][p] = xsave - delta; make_bond(xx,i,j,&Bij); - if(0) { /* This bond doesn't change when i is perturbed */ + if (0) { /* This bond doesn't change when i is perturbed */ make_bond(xx,j,k,&Bjk); } make_bond(xx,k,i,&Bki); @@ -342,7 +342,7 @@ double PairMGPT::numderiv4(double xx[][3],int i,int j,int k,int m,int p) { xx[i][p] = xsave - delta; make_bond(xx,i,j,&Bij); - if(0) { /* Only the i coordinates changed... */ + if (0) { /* Only the i coordinates changed... */ make_bond(xx,j,k,&Bjk); make_bond(xx,k,m,&Bkm); } @@ -365,14 +365,14 @@ void PairMGPT::force_debug_3t(double xx[][3], dfj[0] = dfjx; dfj[1] = dfjy; dfj[2] = dfjz; dfk[0] = dfkx; dfk[1] = dfky; dfk[2] = dfkz; - for(int p = 0; p<3; p++) { + for (int p = 0; p<3; p++) { /* Compute numerical derivatives by displacing atoms i,j,k */ double ndfi,ndfj,ndfk; ndfi = -numderiv3t(xx,i,j,k,p); ndfj = -numderiv3t(xx,j,k,i,p); ndfk = -numderiv3t(xx,k,i,j,p); - if((fabs(dfi[p] - ndfi) > dtol && + if ((fabs(dfi[p] - ndfi) > dtol && fabs(dfi[p] - ndfi) > dtol*fabs(ndfi)) || (fabs(dfj[p] - ndfj) > dtol && fabs(dfj[p] - ndfj) > dtol*fabs(ndfj)) || @@ -398,14 +398,14 @@ void PairMGPT::force_debug_3v(double xx[][3], dfj[0] = dfjx; dfj[1] = dfjy; dfj[2] = dfjz; dfk[0] = dfkx; dfk[1] = dfky; dfk[2] = dfkz; - for(int p = 0; p<3; p++) { + for (int p = 0; p<3; p++) { /* Compute numerical derivatives by displacing atoms i,j,k */ double ndfi,ndfj,ndfk; ndfi = -numderiv3v(xx,i,j,k,p,i0); ndfj = -numderiv3v(xx,i,j,k,p,j0); ndfk = -numderiv3v(xx,i,j,k,p,k0); - if((fabs(dfi[p] - ndfi) > dtol && + if ((fabs(dfi[p] - ndfi) > dtol && fabs(dfi[p] - ndfi) > dtol*fabs(ndfi)) || (fabs(dfj[p] - ndfj) > dtol && fabs(dfj[p] - ndfj) > dtol*fabs(ndfj)) || @@ -436,14 +436,14 @@ void PairMGPT::force_debug_4(double xx[][3], const int ii0[] = {i0,j0,k0,m0},ii[] = {i,j,k,m,i,j,k}; - for(int p = 0; p<3; p++) { + for (int p = 0; p<3; p++) { /* Compute numerical derivatives by displacing atoms i,j,k,m */ double ndfi,ndfj,ndfk,ndfm; - if(1) { + if (1) { double ndf[] = {0.0,0.0,0.0,0.0}; - for(int s = 0; s<4; s++) - for(int t = 0; t<4; t++) - if(ii[s] == ii0[t]) + for (int s = 0; s<4; s++) + for (int t = 0; t<4; t++) + if (ii[s] == ii0[t]) ndf[t] = -numderiv4(xx,ii[s],ii[s+1],ii[s+2],ii[s+3],p); ndfi = ndf[0]; ndfj = ndf[1]; ndfk = ndf[2]; ndfm = ndf[3]; @@ -454,7 +454,7 @@ void PairMGPT::force_debug_4(double xx[][3], ndfm = -numderiv4(xx,m,i,j,k,p); } - if((fabs(dfi[p] - ndfi) > dtol && + if ((fabs(dfi[p] - ndfi) > dtol && fabs(dfi[p] - ndfi) > dtol*fabs(ndfi)) || (fabs(dfj[p] - ndfj) > dtol && fabs(dfj[p] - ndfj) > dtol*fabs(ndfj)) || @@ -501,7 +501,7 @@ void PairMGPT::force_debug_4(double xx[][3], &(T45->H1H2x.m[1][0]),&utr4x.d, \ &(T45->H1H2y.m[1][0]),&utr4y.d, \ &(T45->H1H2z.m[1][0]),&utr4z.d); \ - if(linalg.single) { \ + if (linalg.single) { \ trd1x = utr1x.f; trd2x = utr2x.f; trd3x = utr3x.f; trd4x = utr4x.f; \ trd1y = utr1y.f; trd2y = utr2y.f; trd3y = utr3y.f; trd4y = utr4y.f; \ trd1z = utr1z.f; trd2z = utr2z.f; trd3z = utr3z.f; trd4z = utr4z.f; \ @@ -679,7 +679,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, { double vtot = 1.0; double ntot = atom->natoms; - for(i = 0; i<3; i++) + for (i = 0; i<3; i++) vtot = vtot * (domain->boxhi[i] - domain->boxlo[i]); rhoinv = vtot / ntot; } @@ -705,47 +705,47 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, const int triclinic = domain->triclinic; double alpha[3] = {0.0,0.0,0.0}; - if(triclinic) { + if (triclinic) { double E[3][3],EX[3][3]; int cyc[] = {0,1,2,0,1}; ss = (double (*)[3]) memory->smalloc(sizeof(double [3]) * ntot, "mgpt: local reduced coordinate vector."); - for(i = 0; i<3; i++) { - for(j = 0; j<3; j++) + for (i = 0; i<3; i++) { + for (j = 0; j<3; j++) E[i][j] = 0.0; E[i][i] = domain->subhi_lamda[i] - domain->sublo_lamda[i]; domain->lamda2x(E[i],EX[i]); } - for(i = 0; i<3; i++) { + for (i = 0; i<3; i++) { int i1 = cyc[i+1],i2 = cyc[i+2]; double dot = 0.0,ns2 = 0.0; - for(j = 0; j<3; j++) { + for (j = 0; j<3; j++) { int j1 = cyc[j+1],j2 = cyc[j+2]; double cj = EX[i1][j1]*EX[i2][j2] - EX[i1][j2]*EX[i2][j1]; ns2 = ns2 + cj*cj; dot = dot + EX[i][j]*cj; } alpha[i] = E[i][i] / (dot/sqrt(ns2)); - if(comm->me == 0) { + if (comm->me == 0) { static int count = 0; - if(count < 3) + if (count < 3) printf("@@@ alpha(%d) = %15.5e\n",i+1,alpha[i]); count++; } - if(alpha[i] < 0.0) alpha[i] = -alpha[i]; + if (alpha[i] < 0.0) alpha[i] = -alpha[i]; } } else ss = xx; nneitot = 0; - for(ix = 0; ixx[ix][p]; ff[ix][p] = 0.0; } - if(triclinic) + if (triclinic) domain->x2lamda(xx[ix],ss[ix]); nneitot = nneitot + nnei[ix]; } @@ -766,22 +766,22 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, int c_p = 0, c_t = 0, c_q = 0; - if(0) - if(domain->triclinic) { - if(comm->me == 0) + if (0) + if (domain->triclinic) { + if (comm->me == 0) printf("Can not handle triclinic box yet\n"); error->all(__FILE__,__LINE__,"Can not handle triclinic cell with mgpt yet."); } /* - for(i = 0; i 0.0) { + if (w2 > 0.0) { /* Compute pair energy/force */ @@ -814,20 +814,20 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, df = df / rij * w2; - if(pair_energies == 0) de_pair = 0.0; + if (pair_energies == 0) de_pair = 0.0; e_pair = e_pair + de_pair; c_p++; - if(pair_forces == 0) df = 0.0; + if (pair_forces == 0) df = 0.0; - if(volpres_flag && pair_energies) { + if (volpres_flag && pair_energies) { double dvir; splinepot.eval_vir(rij,&dvir); volvir2 = volvir2 - dvir * w2; /* Per-atom virial contribution of volumetric energy term */ - if(vflag_atom) - for(int pp = 0; pp<3; pp++) { + if (vflag_atom) + for (int pp = 0; pp<3; pp++) { //virial[i] = virial[i] + rhoinv*e_scale*volvir2; vatom[i][pp] -= 0.5 * rhoinv*e_scale*dvir*w2; vatom[j][pp] -= 0.5 * rhoinv*e_scale*dvir*w2; @@ -847,7 +847,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, fiz = fiz + df*drijz; fjz = fjz - df*drijz; - if(evflag) { + if (evflag) { //ev_tally(i,j,nloc,newton_pair,de_pair,0.0,df,-drijx,-drijy,-drijz); /* To fix stress-per-atom scaling, and sign */ ev_tally(i,j,nloc,newton_pair,de_pair,0.0,-df * e_scale,-drijx,-drijy,-drijz); @@ -861,7 +861,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } } - if(rij2 < rcut2_bond && c2_outside(ss[i],ss[j],triclinic,alpha) == 0) { + if (rij2 < rcut2_bond && c2_outside(ss[i],ss[j],triclinic,alpha) == 0) { /* Add j to short neighbor list for i. Insert j to keep list sorted. @@ -874,7 +874,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } nlist_short[p+1] = j; first[i+1] = first[i+1] + 1; - if(first[i+1] > nneitot) { + if (first[i+1] > nneitot) { printf("nneitot = %d, short list full. i=%d\n", nneitot,i); error->one(__FILE__,__LINE__,"Shit! Short list full\n"); @@ -892,7 +892,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, ntpair += nnei[i]; } - for(i = 0; i i) continue; /* Require k i) continue; /* Require k 0.0) { + if (w3 > 0.0) { triplet_defer = 0; dvir_ij = dvir_jk = dvir_ki = 0.0; - if(c_ij && c_jk) + if (c_ij && c_jk) T12 = get_triplet(xx,j,i,k,&bond_hash,&T12work,&dvir_ij,&dvir_jk); - if(c_ki && c_jk) + if (c_ki && c_jk) T23 = get_triplet(xx,k,i,j,&bond_hash,&T23work,&dvir_ki,&dvir_jk); - if(c_ij && c_ki) + if (c_ij && c_ki) T31 = get_triplet(xx,i,j,k,&bond_hash,&T31work,&dvir_ij,&dvir_ki); - if(evflag) { + if (evflag) { fsave[0][0] = fix; fsave[0][1] = fiy; fsave[0][2] = fiz; fsave[1][0] = fjx; fsave[1][1] = fjy; fsave[1][2] = fjz; fsave[2][0] = fkx; fsave[2][1] = fky; fsave[2][2] = fkz; @@ -981,10 +981,10 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, double xvir3t,xvir3v; xvir3t = xvir3v = 0.0; - if(T12 && T23) { + if (T12 && T23) { bond_data *bki = bond_hash.Lookup(Doublet(k,i)); - if(three_body_energies && evflag) { + if (three_body_energies && evflag) { tr0 = transtrace(T12->H1H2,bki->H); double dvir = ((dvir_ij + dvir_jk + bki->fl_deriv_sum)*splinepot.vc + splinepot.dvc)*tr0*w3/anorm3; @@ -1010,7 +1010,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, &(bki->Hy.m[1][0]),&utr3y.d, &(bki->Hz.m[1][0]),&utr3z.d); - if(linalg.single) { + if (linalg.single) { trd1x = utr1x.f; trd2x = utr2x.f; trd3x = utr3x.f; trd1y = utr1y.f; trd2y = utr2y.f; trd3y = utr3y.f; trd1z = utr1z.f; trd2z = utr2z.f; trd3z = utr3z.f; @@ -1033,20 +1033,20 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dfkz = ( ( sjk)*trd2z + (-ski)*trd3z ) * (vc / anorm3); } - if(triplet_debug) + if (triplet_debug) force_debug_3t(xx,i,j,k, i,j,k, dfix,dfiy,dfiz, dfjx,dfjy,dfjz, dfkx,dfky,dfkz); - if(three_body_forces) + if (three_body_forces) accumulate_forces_3(w3); } - if(T12 != 0) { + if (T12 != 0) { //printf("T12 i,j,k = %d,%d,%d\n",i,j,k); mcount++; - if(three_body_energies && evflag) { + if (three_body_energies && evflag) { tr1 = transtrace(T12->H1H2,T12->H1H2); double dvir = (2.0*(dvir_ij + dvir_jk)*splinepot.vd + splinepot.dvd)*tr1*w3/anorm4; @@ -1065,7 +1065,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, &(T12->H1H2x.m[1][0]),&utr2x.d, &(T12->H1H2y.m[1][0]),&utr2y.d, &(T12->H1H2z.m[1][0]),&utr2z.d); - if(linalg.single) { + if (linalg.single) { trd1x = utr1x.f; trd2x = utr2x.f; trd1y = utr1y.f; trd2y = utr2y.f; trd1z = utr1z.f; trd2z = utr2z.f; @@ -1088,21 +1088,21 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dfjz = -(dfiz + dfkz); } - if(triplet_debug) /* Compare forces to numerical derivatives */ + if (triplet_debug) /* Compare forces to numerical derivatives */ force_debug_3v(xx,i,j,k, j,i,k, dfix,dfiy,dfiz, dfjx,dfjy,dfjz, dfkx,dfky,dfkz); - if(three_body_forces) + if (three_body_forces) accumulate_forces_3(w3); } - if(T23 != 0) { + if (T23 != 0) { //printf("T23 i,j,k = %d,%d,%d\n",i,j,k); mcount++; - if(three_body_energies && evflag) { + if (three_body_energies && evflag) { tr2 = transtrace(T23->H1H2,T23->H1H2); double dvir = (2.0*(dvir_jk + dvir_ki)*splinepot.vd + splinepot.dvd)*tr2*w3/anorm4; @@ -1121,7 +1121,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, &(T23->H1H2x.m[1][0]),&utr2x.d, &(T23->H1H2y.m[1][0]),&utr2y.d, &(T23->H1H2z.m[1][0]),&utr2z.d); - if(linalg.single) { + if (linalg.single) { trd1x = utr1x.f; trd2x = utr2x.f; trd1y = utr1y.f; trd2y = utr2y.f; trd1z = utr1z.f; trd2z = utr2z.f; @@ -1144,21 +1144,21 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dfkz = -(dfiz + dfjz); } - if(triplet_debug) /* Compare forces to numerical derivatives */ + if (triplet_debug) /* Compare forces to numerical derivatives */ force_debug_3v(xx,i,j,k, k,i,j, dfix,dfiy,dfiz, dfjx,dfjy,dfjz, dfkx,dfky,dfkz); - if(three_body_forces) + if (three_body_forces) accumulate_forces_3(w3); } - if(T31 != 0) { + if (T31 != 0) { //printf("T31 i,j,k = %d,%d,%d\n",i,j,k); mcount++; - if(three_body_energies && evflag) { + if (three_body_energies && evflag) { tr3 = transtrace(T31->H1H2,T31->H1H2); double dvir = (2.0*(dvir_ki + dvir_ij)*splinepot.vd + splinepot.dvd)*tr3*w3/anorm4; @@ -1177,7 +1177,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, &(T31->H1H2x.m[1][0]),&utr2x.d, &(T31->H1H2y.m[1][0]),&utr2y.d, &(T31->H1H2z.m[1][0]),&utr2z.d); - if(linalg.single) { + if (linalg.single) { trd1x = utr1x.f; trd2x = utr2x.f; trd1y = utr1y.f; trd2y = utr2y.f; trd1z = utr1z.f; trd2z = utr2z.f; @@ -1201,13 +1201,13 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } - if(triplet_debug) /* Compare forces to numerical derivatives */ + if (triplet_debug) /* Compare forces to numerical derivatives */ force_debug_3v(xx,i,j,k, i,j,k, dfix,dfiy,dfiz, dfjx,dfjy,dfjz, dfkx,dfky,dfkz); - if(three_body_forces) + if (three_body_forces) accumulate_forces_3(w3); } @@ -1220,10 +1220,10 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, //printf("xxxx %6d %6d %6d :: %20.10e\n",1,2,3,de_triplet); - if(evflag) { + if (evflag) { double drji[3],drki[3]; double fj[3] = {fjx,fjy,fjz},fk[3] = {fkx,fky,fkz}; - for(int p = 0; p<3; p++) { + for (int p = 0; p<3; p++) { drji[p] = xx[j][p] - xx[i][p]; drki[p] = xx[k][p] - xx[i][p]; /* To fix stress-per-atom scaling. */ @@ -1233,10 +1233,10 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, ev_tally3(i,j,k,de_triplet,0.0,fj,fk,drji,drki); - if(volpres_flag && vflag_atom) { + if (volpres_flag && vflag_atom) { //virial[i] = virial[i] - (vir3v + vir3t) * rhoinv*e_scale; double dvir = -(xvir3v + xvir3t) * rhoinv*e_scale * (1.0/3.0); - for(int pp = 0; pp<3; pp++) { + for (int pp = 0; pp<3; pp++) { vatom[i][pp] += dvir; vatom[j][pp] += dvir; vatom[k][pp] += dvir; @@ -1255,8 +1255,8 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, triplet_defer = 1; } - if(four_body_energies || four_body_forces) - if(j < i) { /* Search for quadruplet */ + if (four_body_energies || four_body_forces) + if (j < i) { /* Search for quadruplet */ tx0 = gettime(); mj = first[j]; @@ -1267,7 +1267,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, */ while(nlist_short[mj] < i && nlist_short[mk] < i) { - if(mj >= first[j+1] || mk >= first[k+1]) { + if (mj >= first[j+1] || mk >= first[k+1]) { printf("Illegal quad...\n" " j=%d first[j]=%d first[j+1]=%d mj=%d\n" " k=%d first[k]=%d first[k+1]=%d mk=%d\n", @@ -1276,7 +1276,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, error->one(__FILE__,__LINE__,"Shit, brkoen quad loop"); } - if(nlist_short[mj] == nlist_short[mk]) { + if (nlist_short[mj] == nlist_short[mk]) { /* Closed quadruplet */ m = nlist_short[mj]; c_jm = c_km = 1; @@ -1287,25 +1287,25 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, w4 = get_weight(triclinic,ss[i],ss[j],ss[k],ss[m]); - if(w4 > 0.0) { + if (w4 > 0.0) { /* Alrady know ij,jk,ki,jm,km bonds. Look for im bond. */ mi = first[i]; while(mi < first[i+1] && nlist_short[mi] < m) mi = mi + 1; - if(mi < first[i+1] && nlist_short[mi] == m) + if (mi < first[i+1] && nlist_short[mi] == m) c_im = 1; else c_im = 0; - if(c_im == 0 || c_jk == 0 || (c_jk && c_im && m < k)) { + if (c_im == 0 || c_jk == 0 || (c_jk && c_im && m < k)) { - if(triplet_defer) { + if (triplet_defer) { dvir_ij = dvir_jk = dvir_ki = 0.0; - if(c_ij && c_jk) + if (c_ij && c_jk) T12 = get_triplet(xx,j,i,k,&bond_hash,&T12work,&dvir_ij,&dvir_jk); - if(c_ki && c_jk) + if (c_ki && c_jk) T23 = get_triplet(xx,k,i,j,&bond_hash,&T23work,&dvir_ki,&dvir_jk); - if(c_ij && c_ki) + if (c_ij && c_ki) T31 = get_triplet(xx,i,j,k,&bond_hash,&T31work,&dvir_ij,&dvir_ki); triplet_defer = 0; } @@ -1314,7 +1314,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, fmx = fmy = fmz = 0.0; double xvir4 = 0.0; - if(evflag) { + if (evflag) { fsave[0][0] = fix; fsave[0][1] = fiy; fsave[0][2] = fiz; fsave[1][0] = fjx; fsave[1][1] = fjy; fsave[1][2] = fjz; fsave[2][0] = fkx; fsave[2][1] = fky; fsave[2][2] = fkz; @@ -1329,15 +1329,15 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dvir_im = dvir_jm = dvir_km = 0.0; T45 = T56 = T64 = 0; - if(T12 != 0 && c_km && c_im) + if (T12 != 0 && c_km && c_im) T45 = get_triplet(xx,m,i,k,&bond_hash,&T45work,&dvir_im,&dvir_km); - if(T23 != 0 && c_im && c_jm) + if (T23 != 0 && c_im && c_jm) T56 = get_triplet(xx,m,i,j,&bond_hash,&T56work,&dvir_im,&dvir_jm); - if(T31 != 0 && c_jm && c_km) + if (T31 != 0 && c_jm && c_km) T64 = get_triplet(xx,m,j,k,&bond_hash,&T64work,&dvir_jm,&dvir_km); - if(T12 != 0 && T45 != 0) { - if(four_body_energies && evflag) { + if (T12 != 0 && T45 != 0) { + if (four_body_energies && evflag) { tr1 = transtrace(T12->H1H2,T45->H1H2); double dvir = ( (dvir_ij + dvir_jk + dvir_im + dvir_km)*splinepot.ve + splinepot.dve )*tr1*w4/anorm4; @@ -1356,17 +1356,17 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dfix_update_4a(z); } - if(quad_debug) /* Compare forces to numerical derivatives */ + if (quad_debug) /* Compare forces to numerical derivatives */ force_debug_4(xx,i,j,k,m, i,j,k,m, dfix,dfiy,dfiz , dfjx,dfjy,dfjz, dfkx,dfky,dfkz , dfmx,dfmy,dfmz); - if(four_body_forces) + if (four_body_forces) accumulate_forces_4(w4); } - if(T23 != 0 && T56 != 0) { - if(four_body_energies && evflag) { + if (T23 != 0 && T56 != 0) { + if (four_body_energies && evflag) { tr2 = transtrace(T23->H1H2,T56->H1H2); double dvir = ( (dvir_ki + dvir_jk + dvir_im + dvir_jm)*splinepot.ve + splinepot.dve )*tr2*w4/anorm4; @@ -1385,18 +1385,18 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dfix_update_4b(z); } - if(quad_debug) /* Compare forces to numerical derivatives */ + if (quad_debug) /* Compare forces to numerical derivatives */ force_debug_4(xx,i,j,k,m, i,m,j,k, dfix,dfiy,dfiz , dfjx,dfjy,dfjz, dfkx,dfky,dfkz , dfmx,dfmy,dfmz); - if(four_body_forces) + if (four_body_forces) accumulate_forces_4(w4); } - if(T31 != 0 && T64 != 0) { - if(four_body_energies && evflag) { + if (T31 != 0 && T64 != 0) { + if (four_body_energies && evflag) { tr3 = transtrace(T31->H1H2,T64->H1H2); double dvir = ( (dvir_ki + dvir_ij + dvir_jm + dvir_km)*splinepot.ve + splinepot.dve )*tr3*w4/anorm4; @@ -1416,29 +1416,29 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dfix_update_4c(z); } - if(quad_debug) /* Compare forces to numerical derivatives */ + if (quad_debug) /* Compare forces to numerical derivatives */ force_debug_4(xx,i,j,k,m, i,j,m,k, dfix,dfiy,dfiz , dfjx,dfjy,dfjz, dfkx,dfky,dfkz , dfmx,dfmy,dfmz); - if(four_body_forces) + if (four_body_forces) accumulate_forces_4(w4); } double de_quad = splinepot.ve*(tr1 + tr2 + tr3)/anorm4 * e_scale * w4; e_quad = e_quad + de_quad; - if((T12 && T45) || + if ((T12 && T45) || (T23 && T56) || (T31 && T64)) { c_q++; } - if(evflag) { + if (evflag) { double drim[3],drjm[3],drkm[3]; double fi[3] = {fix,fiy,fiz}; double fj[3] = {fjx,fjy,fjz}; double fk[3] = {fkx,fky,fkz}; - for(int p = 0; p<3; p++) { + for (int p = 0; p<3; p++) { drim[p] = xx[i][p] - xx[m][p]; drjm[p] = xx[j][p] - xx[m][p]; drkm[p] = xx[k][p] - xx[m][p]; @@ -1449,10 +1449,10 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, ev_tally4(i,j,k,m,de_quad,fi,fj,fk,drim,drjm,drkm); - if(volpres_flag && vflag_atom) { + if (volpres_flag && vflag_atom) { //virial[i] = virial[i] - vir4 * rhoinv*e_scale; double dvir = -xvir4 * rhoinv*e_scale * (1.0/4.0); - for(int pp = 0; pp<3; pp++) { + for (int pp = 0; pp<3; pp++) { vatom[i][pp] += dvir; vatom[j][pp] += dvir; vatom[k][pp] += dvir; @@ -1474,7 +1474,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } mj = mj + 1; mk = mk + 1; - } else if(nlist_short[mj] < nlist_short[mk]) { + } else if (nlist_short[mj] < nlist_short[mk]) { mj = mj + 1; } else { mk = mk + 1; @@ -1505,15 +1505,15 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, ff[i][1] += fiy * e_scale; ff[i][2] += fiz * e_scale; - if(single_energies == 1 && i < nloc) { + if (single_energies == 1 && i < nloc) { const double evol0 = splinepot.evol0; - if(eflag_global) { + if (eflag_global) { e_single = e_single + evol0 * e_scale; eng_vdwl = eng_vdwl + evol0 * e_scale; } - if(eflag_atom) eatom[i] = eatom[i] + evol0 * e_scale; - if(volpres_flag && vflag_atom) { - for(int pp = 0; pp<3; pp++) + if (eflag_atom) eatom[i] = eatom[i] + evol0 * e_scale; + if (volpres_flag && vflag_atom) { + for (int pp = 0; pp<3; pp++) vatom[i][pp] = vatom[i][pp] - rhoinv*splinepot.devol0*e_scale; } @@ -1522,13 +1522,13 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } tx0 = gettime(); - for(i = 0; if[i][p] = atom->f[i][p] + ff[i][p]; memory->sfree(nlist_short); memory->sfree(first); - if(ss != xx) memory->sfree(ss); + if (ss != xx) memory->sfree(ss); memory->sfree(ff); memory->sfree(xx); tx1 = gettime(); @@ -1541,7 +1541,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, #ifdef TIMING_ON - if(comm->me == 0) { + if (comm->me == 0) { double tsum = (tmem+tsort+tpair+tlookup+ttriplet+tquad); double nsum = (ntmem+ntsort+ntpair+ntlookup+nttriplet+ntquad); //double adj = ((t1-t0)-tsum)/nsum; @@ -1624,7 +1624,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } #endif - if(volpres_flag) { + if (volpres_flag) { /* Include contributions to the pressure due to derivatines of the energy with respect to the potential input volume. @@ -1635,29 +1635,29 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, /* double vtot = 1.0; double ntot = atom->natoms; - for(i = 0; i<3; i++) + for (i = 0; i<3; i++) vtot = vtot * (domain->boxhi[i] - domain->boxlo[i]); double rhoinv = vtot / ntot; */ - if(single_energies) // Virial correction for self energy - for(i = 0; i<3; i++) { + if (single_energies) // Virial correction for self energy + for (i = 0; i<3; i++) { //virial[i] = virial[i] + nloc*pot_input_vol*pvol0*e_scale; virial[i] = virial[i] - nloc*rhoinv*splinepot.devol0*e_scale; } - if(pair_energies) // Virial correction for pair energy - for(i = 0; i<3; i++) + if (pair_energies) // Virial correction for pair energy + for (i = 0; i<3; i++) virial[i] = virial[i] + rhoinv*e_scale*volvir2; - if(three_body_energies) // Virial correction for three body enegries - for(i = 0; i<3; i++) { + if (three_body_energies) // Virial correction for three body enegries + for (i = 0; i<3; i++) { //virial[i] = virial[i] - pot_input_vol*(e_triplet_c*pc + (e_triplet-e_triplet_c)*pd); virial[i] = virial[i] - (vir3v + vir3t) * rhoinv*e_scale; } - if(four_body_energies) // Virial correction for four body enegries - for(i = 0; i<3; i++) { + if (four_body_energies) // Virial correction for four body enegries + for (i = 0; i<3; i++) { //virial[i] = virial[i] - pot_input_vol*e_quad*pe; virial[i] = virial[i] - vir4 * rhoinv*e_scale; } @@ -1679,66 +1679,66 @@ void PairMGPT::compute(int eflag, int vflag) //printf("newton_pair = %d, newton = %d, tag_enable = %d\n",force->newton_pair,force->newton,atom->tag_enable); - if(newton_pair == 0) { + if (newton_pair == 0) { printf("This is a problem. MGPT requires newton_pair flag to be on. Exiting...\n"); exit(1); } - if(atom->tag_enable == 0) { + if (atom->tag_enable == 0) { printf("This is a problem. MGPT requires tag_enable flag to be on. Exiting...\n"); exit(1); } compute_x(listfull->numneigh,listfull->firstneigh,&e_s,&e_p,&e_t,&e_q,evflag,newton_pair); - if(0) { // Stupid force calculation / verification + if (0) { // Stupid force calculation / verification int ii,nmax=-1; - for(ii = 0; iiinum + listfull->gnum; ii++) { + for (ii = 0; iiinum + listfull->gnum; ii++) { int i = listfull->ilist[ii]; - if(i > nmax) nmax = i; + if (i > nmax) nmax = i; } nmax++; double *ffwork = new double[3*nmax]; double *ffloc = new double[3*listfull->inum]; double *ffloc2 = new double[3*listfull->inum]; double **ffptr = new double *[nmax]; - for(ii = 0; iiinum + listfull->gnum; ii++) + for (ii = 0; iiinum + listfull->gnum; ii++) ffptr[ii] = &ffwork[3*ii]; printf("Computing boundary forces\n"); - for(ii = 0; iiinum; ii++) { + for (ii = 0; iiinum; ii++) { ffloc2[3*ii] = 0.0; ffloc2[3*ii+1] = 0.0; ffloc2[3*ii+2] = 0.0; int i = listfull->ilist[ii]; - for(int jj = 0; jjinum+listfull->gnum; jj++) { + for (int jj = 0; jjinum+listfull->gnum; jj++) { int j = listfull->ilist[jj]; - if(atom->tag[i] == atom->tag[j]) - for(int p = 0; p<3; p++) + if (atom->tag[i] == atom->tag[j]) + for (int p = 0; p<3; p++) ffloc2[3*ii+p] += atom->f[j][p]; } } printf("Starting main displacement force calculation\n"); - for(ii = 0; iiinum; ii++) { + for (ii = 0; iiinum; ii++) { int i = listfull->ilist[ii]; double **atom_f_save = atom->f; atom->f = ffptr; - for(int p = 0; p<3; p++) { + for (int p = 0; p<3; p++) { double xsave = atom->x[i][p]; const double delta = 1e-3; atom->x[i][p] = xsave + delta; - for(int jj = 0; jj<3*nmax; jj++) ffwork[jj] = 0.0; + for (int jj = 0; jj<3*nmax; jj++) ffwork[jj] = 0.0; compute_x(listfull->numneigh, listfull->firstneigh, &e_s,&e_p,&e_t,&e_q,evflag,newton_pair); double e1 = e_s + e_p + e_t + e_q; atom->x[i][p] = xsave - delta; - for(int jj = 0; jj<3*nmax; jj++) ffwork[jj] = 0.0; + for (int jj = 0; jj<3*nmax; jj++) ffwork[jj] = 0.0; compute_x(listfull->numneigh, listfull->firstneigh, &e_s,&e_p,&e_t,&e_q,evflag,newton_pair); @@ -1769,10 +1769,10 @@ void PairMGPT::compute(int eflag, int vflag) } - if(0) { + if (0) { printf("\nForces MGPT:\n"); const int iimax = (listfull->inum < 10) ? listfull->inum : 10; - for(int ii = 0; iiilist[ii]; printf("%4d = %20.10e %20.10e %20.10e\n", i,atom->f[i][0],atom->f[i][1],atom->f[i][2]); @@ -1780,7 +1780,7 @@ void PairMGPT::compute(int eflag, int vflag) printf("\n\n"); } - if(vflag_fdotr) { + if (vflag_fdotr) { //printf("##### Using virial_compute!!!\n"); virial_fdotr_compute(); } @@ -1792,8 +1792,8 @@ void PairMGPT::allocate() int n = atom->ntypes; memory->create(setflag,n+1,n+1,"pair:setflag"); - for(int i = 0; i <= n; i++) - for(int j = 0; j <= n; j++) + for (int i = 0; i <= n; i++) + for (int j = 0; j <= n; j++) setflag[i][j] = 0; memory->create(cutsq,n+1,n+1,"pair:cutsq"); @@ -1805,7 +1805,7 @@ void PairMGPT::allocate() ------------------------------------------------------------------------- */ void PairMGPT::settings(int narg, char **/*arg*/) { - if(narg != 0) error->all(__FILE__,__LINE__,"Illegal pair_style command"); + if (narg != 0) error->all(__FILE__,__LINE__,"Illegal pair_style command"); } /* ---------------------------------------------------------------------- @@ -1816,18 +1816,18 @@ void PairMGPT::coeff(int narg, char **arg) { int single_precision = 0; - if(narg < 5) + if (narg < 5) error->all(__FILE__,__LINE__, "Not enough arguments for mgpt (MGPT) pair coefficients."); - if(!allocated) allocate(); + if (!allocated) allocate(); // Make sure I,J args are * * - if(strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) + if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) error->all(__FILE__,__LINE__,"Incorrect args for pair coefficients"); double vol; - if(sscanf(arg[4], "%lg", &vol) != 1 || vol <= 0.0) + if (sscanf(arg[4], "%lg", &vol) != 1 || vol <= 0.0) error->all(__FILE__,__LINE__,"Invalid volume in mgpt (MGPT) pair coefficients."); volpres_flag = 1; @@ -1838,11 +1838,11 @@ void PairMGPT::coeff(int narg, char **arg) int iarg = 5; while (iarg < narg) { - if(strcmp(arg[iarg],"volpress") == 0) { /* Volumetric pressure flag */ + if (strcmp(arg[iarg],"volpress") == 0) { /* Volumetric pressure flag */ if (iarg+2 > narg) error->all(FLERR,"Incorrect args for pair coefficients"); - if(strcmp(arg[iarg+1],"yes") == 0) volpres_flag = 1; - else if(strcmp(arg[iarg+1],"no") == 0) volpres_flag = 0; + if (strcmp(arg[iarg+1],"yes") == 0) volpres_flag = 1; + else if (strcmp(arg[iarg+1],"no") == 0) volpres_flag = 0; else { char line[1024]; sprintf(line,"(In %s:%d) Invalid value for volumetric pressure argument.\n" @@ -1852,16 +1852,16 @@ void PairMGPT::coeff(int narg, char **arg) } volpres_tag = 1; iarg += 2; - if(comm->me == 0) printf("* volpress: volpres_flag = %d [%s %s]\n",volpres_flag,arg[iarg-2],arg[iarg-1]); - } else if(strcmp(arg[iarg],"nbody") == 0) { + if (comm->me == 0) printf("* volpress: volpres_flag = %d [%s %s]\n",volpres_flag,arg[iarg-2],arg[iarg-1]); + } else if (strcmp(arg[iarg],"nbody") == 0) { if (iarg+2 > narg) error->all(FLERR,"Incorrect args for pair coefficients"); - if(strspn(arg[iarg+1],"1234") == strlen(arg[iarg+1])) { + if (strspn(arg[iarg+1],"1234") == strlen(arg[iarg+1])) { nbody_flag = 0; - for(int i = 0; i<4; i++) - if(strchr(arg[iarg+1],'1'+i) != nullptr) { + for (int i = 0; i<4; i++) + if (strchr(arg[iarg+1],'1'+i) != nullptr) { nbody_flag = nbody_flag + (1<me == 0) printf("Explicitly adding %d-tuple forces.\n",i+1); + if (comm->me == 0) printf("Explicitly adding %d-tuple forces.\n",i+1); } } else { char line[1024]; @@ -1874,11 +1874,11 @@ void PairMGPT::coeff(int narg, char **arg) } nbody_tag = 1; iarg += 2; - } else if(strcmp(arg[iarg],"precision") == 0) { + } else if (strcmp(arg[iarg],"precision") == 0) { if (iarg+2 > narg) error->all(FLERR,"Incorrect args for pair coefficients"); - if(strcmp(arg[iarg+1],"single") == 0) single_precision = 1; - else if(strcmp(arg[iarg+1],"double") == 0) single_precision = 0; + if (strcmp(arg[iarg+1],"single") == 0) single_precision = 1; + else if (strcmp(arg[iarg+1],"double") == 0) single_precision = 0; else { char line[1024]; sprintf(line,"(In %s:%d) Invalid value for precision argument.\n" @@ -1888,7 +1888,7 @@ void PairMGPT::coeff(int narg, char **arg) } precision_tag = 1; iarg += 2; - if(comm->me == 0) printf("* precision: single_flag = %d [%s %s]\n",single_precision,arg[iarg-2],arg[iarg-1]); + if (comm->me == 0) printf("* precision: single_flag = %d [%s %s]\n",single_precision,arg[iarg-2],arg[iarg-1]); } else { char line[1024]; sprintf(line,"(In %s:%d) Invalid argument. Allowed arguments are:\n" @@ -1900,10 +1900,10 @@ void PairMGPT::coeff(int narg, char **arg) } } - if(comm->me == 0) + if (comm->me == 0) printf("Volumetric pressure is %s.\n",volpres_flag ? "on" : "off"); - if(comm->me == 0) { + if (comm->me == 0) { FILE *parmin_fp = utils::open_potential(arg[2],lmp,nullptr); FILE *potin_fp = utils::open_potential(arg[3],lmp,nullptr); if (parmin_fp == nullptr || potin_fp == nullptr) { @@ -1920,14 +1920,14 @@ void PairMGPT::coeff(int narg, char **arg) /* Set up default and requested nbody forces to include */ { int nbody_default = (1<<0) + (1<<1) + (1<<2) + (1<<3); - if(splinepot.vd == 0.0 && splinepot.dvd == 0.0) + if (splinepot.vd == 0.0 && splinepot.dvd == 0.0) nbody_default -= (1<<2); // No 3-body contributions - if(splinepot.ve == 0.0 && splinepot.dve == 0.0) + if (splinepot.ve == 0.0 && splinepot.dve == 0.0) nbody_default -= (1<<3); // No 4-body contributions - if(nbody_tag == 0) nbody_flag = nbody_default; + if (nbody_tag == 0) nbody_flag = nbody_default; - if(nbody_flag != nbody_default) { + if (nbody_flag != nbody_default) { printf("Warning: nbody=%d (suggested=%d) set to disregard multibody-forces in potential.\n", nbody_flag,nbody_default); } @@ -1943,7 +1943,7 @@ void PairMGPT::coeff(int narg, char **arg) memory, and then broadcast contents of arrays. */ MPI_Bcast(&splinepot,sizeof(splinepot),MPI_BYTE,0,world); - if(comm->me != 0) { + if (comm->me != 0) { splinepot.vpair_spline = new double[splinepot.nr-1][4]; splinepot.dvpair_spline = new double[splinepot.nr-1][4]; } @@ -1954,10 +1954,10 @@ void PairMGPT::coeff(int narg, char **arg) lmax = splinepot.lmax; lang = splinepot.lang; //ipot = splinepot.ipot; - for(int i = 0; i<(int) (sizeof(ddl)/sizeof(double)); i++) + for (int i = 0; i<(int) (sizeof(ddl)/sizeof(double)); i++) ddl[i] = splinepot.ddl[i]; - for(int i = 0; i rmax) cutoff = rcrit; + if (rcrit > rmax) cutoff = rcrit; // Set LAMMPS pair interaction flags. - for(int i = 1; i <= atom->ntypes; i++) { - for(int j = 1; j <= atom->ntypes; j++) { + for (int i = 1; i <= atom->ntypes; i++) { + for (int j = 1; j <= atom->ntypes; j++) { setflag[i][j] = 1; cutsq[i][j] = cutoff; cutghost[i][j] = cutoff; @@ -1980,12 +1980,12 @@ void PairMGPT::coeff(int narg, char **arg) } // Set atomic mass. - for(int i = 1; i <= atom->ntypes; i++) + for (int i = 1; i <= atom->ntypes; i++) atom->set_mass(FLERR,i, splinepot.mass); // Initialize linear algebra routines. linalg = mgpt_linalg(lmax,single_precision); - if(comm->me == 0) + if (comm->me == 0) printf("%s",linalg.msg); } @@ -1995,7 +1995,7 @@ void PairMGPT::coeff(int narg, char **arg) ------------------------------------------------------------------------- */ void PairMGPT::init_style() { - if(force->newton_pair == 0) + if (force->newton_pair == 0) error->all(__FILE__,__LINE__,"Pair style mgpt requires newton pair on."); // Need full neighbor list. @@ -2016,8 +2016,8 @@ void PairMGPT::init_style() ------------------------------------------------------------------------- */ void PairMGPT::init_list(int id, NeighList *ptr) { - if(id == 1) listfull = ptr; - else if(id == 2) listhalf = ptr; + if (id == 1) listfull = ptr; + else if (id == 2) listhalf = ptr; } /* ---------------------------------------------------------------------- @@ -2056,13 +2056,13 @@ void PairMGPT::fl_deriv_new(double r,double ri,double xhat,double yhat,double zh */ double rpi = 1.0/rp; - if(mode <= 4) { + if (mode <= 4) { t = pow(rp*ri,p1); s = -p1 * t * ri; t_rp_ti = p1*rpi; t_p1_ti = log(rp*ri); } else { - if(pn == 1.0) { + if (pn == 1.0) { double p1_rpi = -p1*rpi; t = exp(p1 + r*p1_rpi); s = p1_rpi * t; @@ -2107,7 +2107,7 @@ void PairMGPT::fl_deriv_new(double r,double ri,double xhat,double yhat,double zh q_al = u*u; exp_q = exp(-q); - if(mode <= 2) { + if (mode <= 2) { fl_0 = exp_q * t; fl_x = exp_q*(tx - t*qx); fl_y = exp_q*(ty - t*qy); diff --git a/src/USER-MISC/angle_gaussian.cpp b/src/USER-MISC/angle_gaussian.cpp index 554b19cfb5..66da9e792e 100644 --- a/src/USER-MISC/angle_gaussian.cpp +++ b/src/USER-MISC/angle_gaussian.cpp @@ -244,7 +244,7 @@ void AngleGaussian::write_restart(FILE *fp) { fwrite(&angle_temperature[1],sizeof(double),atom->nangletypes,fp); fwrite(&nterms[1],sizeof(int),atom->nangletypes,fp); - for(int i = 1; i <= atom->nangletypes; i++) { + for (int i = 1; i <= atom->nangletypes; i++) { fwrite(alpha[i],sizeof(double),nterms[i],fp); fwrite(width[i],sizeof(double),nterms[i],fp); fwrite(theta0[i],sizeof(double),nterms[i],fp); @@ -267,21 +267,21 @@ void AngleGaussian::read_restart(FILE *fp) MPI_Bcast(&nterms[1],atom->nangletypes,MPI_INT,0,world); // allocate - for(int i = 1; i <= atom->nangletypes; i++) { + for (int i = 1; i <= atom->nangletypes; i++) { alpha[i] = new double [nterms[i]]; width[i] = new double [nterms[i]]; theta0[i] = new double [nterms[i]]; } if (comm->me == 0) { - for(int i = 1; i <= atom->nangletypes; i++) { + for (int i = 1; i <= atom->nangletypes; i++) { utils::sfread(FLERR,alpha[i],sizeof(double),nterms[i],fp,nullptr,error); utils::sfread(FLERR,width[i],sizeof(double),nterms[i],fp,nullptr,error); utils::sfread(FLERR,theta0[i],sizeof(double),nterms[i],fp,nullptr,error); } } - for(int i = 1; i <= atom->nangletypes; i++) { + for (int i = 1; i <= atom->nangletypes; i++) { MPI_Bcast(alpha[i],nterms[i],MPI_DOUBLE,0,world); MPI_Bcast(width[i],nterms[i],MPI_DOUBLE,0,world); MPI_Bcast(theta0[i],nterms[i],MPI_DOUBLE,0,world); diff --git a/src/USER-MISC/bond_gaussian.cpp b/src/USER-MISC/bond_gaussian.cpp index b1e9d3d66b..42f76eda75 100644 --- a/src/USER-MISC/bond_gaussian.cpp +++ b/src/USER-MISC/bond_gaussian.cpp @@ -200,7 +200,7 @@ void BondGaussian::write_restart(FILE *fp) { fwrite(&bond_temperature[1],sizeof(double),atom->nbondtypes,fp); fwrite(&nterms[1],sizeof(int),atom->nbondtypes,fp); - for(int i = 1; i <= atom->nbondtypes; i++) { + for (int i = 1; i <= atom->nbondtypes; i++) { fwrite(alpha[i],sizeof(double),nterms[i],fp); fwrite(width[i],sizeof(double),nterms[i],fp); fwrite(r0[i],sizeof(double),nterms[i],fp); @@ -223,21 +223,21 @@ void BondGaussian::read_restart(FILE *fp) MPI_Bcast(&nterms[1],atom->nbondtypes,MPI_INT,0,world); // allocate - for(int i = 1; i <= atom->nbondtypes; i++) { + for (int i = 1; i <= atom->nbondtypes; i++) { alpha[i] = new double [nterms[i]]; width[i] = new double [nterms[i]]; r0[i] = new double [nterms[i]]; } if (comm->me == 0) { - for(int i = 1; i <= atom->nbondtypes; i++) { + for (int i = 1; i <= atom->nbondtypes; i++) { utils::sfread(FLERR,alpha[i],sizeof(double),nterms[i],fp,nullptr,error); utils::sfread(FLERR,width[i],sizeof(double),nterms[i],fp,nullptr,error); utils::sfread(FLERR,r0[i],sizeof(double),nterms[i],fp,nullptr,error); } } - for(int i = 1; i <= atom->nbondtypes; i++) { + for (int i = 1; i <= atom->nbondtypes; i++) { MPI_Bcast(alpha[i],nterms[i],MPI_DOUBLE,0,world); MPI_Bcast(width[i],nterms[i],MPI_DOUBLE,0,world); MPI_Bcast(r0[i],nterms[i],MPI_DOUBLE,0,world); diff --git a/src/USER-MISC/compute_basal_atom.cpp b/src/USER-MISC/compute_basal_atom.cpp index 01a623b4a9..a73f401120 100644 --- a/src/USER-MISC/compute_basal_atom.cpp +++ b/src/USER-MISC/compute_basal_atom.cpp @@ -289,7 +289,7 @@ void ComputeBasalAtom::compute_peratom() } var5 = var6 = var7 = 0.0; //find standard deviations - for (j=0;j 0){ + if (Mag > 0) { BPV[i][0] = BPV[i][0]/Mag; BPV[i][1] = BPV[i][1]/Mag; BPV[i][2] = BPV[i][2]/Mag; diff --git a/src/USER-MISC/compute_entropy_atom.cpp b/src/USER-MISC/compute_entropy_atom.cpp index cc1b81fc97..1362da447b 100644 --- a/src/USER-MISC/compute_entropy_atom.cpp +++ b/src/USER-MISC/compute_entropy_atom.cpp @@ -247,7 +247,7 @@ void ComputeEntropyAtom::compute_peratom() // loop over list of all neighbors within force cutoff // initialize gofr - for(int k=0;k (nbin-1)) minbin=nbin-1; maxbin=bin + deltabin; if (maxbin > (nbin-1)) maxbin=nbin-1; - for(int k=minbin;kprd[i]; } @@ -180,7 +180,7 @@ void ComputeStressMop::init() // Warnings - if (me==0){ + if (me==0) { //Compute stress/mop only accounts for pair interactions. // issue a warning if any intramolecular potential or Kspace is defined. @@ -327,7 +327,7 @@ void ComputeStressMop::compute_pairs() values_local[m+1] += fpair*(xi[1]-xj[1])/area*nktv2p; values_local[m+2] += fpair*(xi[2]-xj[2])/area*nktv2p; } - else if ( ((xi[dir]pos)) || ((xi[dir]pos1)) ){ + else if ( ((xi[dir]pos)) || ((xi[dir]pos1)) ) { pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); @@ -359,13 +359,13 @@ void ComputeStressMop::compute_pairs() // Compute kinetic contribution to pressure // counts local particles transfers across the plane - if (which[m] == KIN || which[m] == TOTAL){ + if (which[m] == KIN || which[m] == TOTAL) { double sgn; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { // skip if I is not in group - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { itype = type[i]; @@ -402,7 +402,7 @@ void ComputeStressMop::compute_pairs() double pos_temp = pos+copysign(1.0,domain->prd_half[dir]-pos)*domain->prd[dir]; if (fabs(xi[dir]-pos)ndihedraltypes,fp); - for(int i = 1; i <= atom->ndihedraltypes; i++) { + for (int i = 1; i <= atom->ndihedraltypes; i++) { fwrite(k[i],sizeof(double),nterms[i],fp); fwrite(multiplicity[i],sizeof(int),nterms[i],fp); fwrite(shift[i],sizeof(double),nterms[i],fp); @@ -410,7 +410,7 @@ void DihedralFourier::write_data(FILE *fp) for (int i = 1; i <= atom->ndihedraltypes; i++) { fprintf(fp,"%d %d",i,nterms[i]); - for(int j = 0; j < nterms[i]; j++) + for (int j = 0; j < nterms[i]; j++) fprintf(fp," %g %d %g",k[i][j],multiplicity[i][j],shift[i][j]); fprintf(fp,"\n"); } diff --git a/src/USER-MISC/dihedral_nharmonic.cpp b/src/USER-MISC/dihedral_nharmonic.cpp index f1b01d031f..1041062530 100644 --- a/src/USER-MISC/dihedral_nharmonic.cpp +++ b/src/USER-MISC/dihedral_nharmonic.cpp @@ -307,7 +307,7 @@ void DihedralNHarmonic::coeff(int narg, char **arg) void DihedralNHarmonic::write_restart(FILE *fp) { fwrite(&nterms[1],sizeof(int),atom->ndihedraltypes,fp); - for(int i = 1; i <= atom->ndihedraltypes; i++) + for (int i = 1; i <= atom->ndihedraltypes; i++) fwrite(a[i],sizeof(double),nterms[i],fp); } @@ -325,11 +325,11 @@ void DihedralNHarmonic::read_restart(FILE *fp) MPI_Bcast(&nterms[1],atom->ndihedraltypes,MPI_INT,0,world); // allocate - for(int i = 1; i <= atom->ndihedraltypes; i++) + for (int i = 1; i <= atom->ndihedraltypes; i++) a[i] = new double [nterms[i]]; if (comm->me == 0) { - for(int i = 1; i <= atom->ndihedraltypes; i++) + for (int i = 1; i <= atom->ndihedraltypes; i++) utils::sfread(FLERR,a[i],sizeof(double),nterms[i],fp,nullptr,error); } diff --git a/src/USER-MISC/dihedral_spherical.cpp b/src/USER-MISC/dihedral_spherical.cpp index 2c12266d85..2f77887de9 100644 --- a/src/USER-MISC/dihedral_spherical.cpp +++ b/src/USER-MISC/dihedral_spherical.cpp @@ -479,7 +479,7 @@ void DihedralSpherical::compute(int eflag, int vflag) // d U d U d phi d U d theta1 d U d theta2 // -f = ----- = ----- * ----- + -------*------- + --------*-------- // d x d phi d x d theta1 d X d theta2 d X - for(int d=0; d < g_dim; ++d) { + for (int d=0; d < g_dim; ++d) { f1[d] = m_du_dphi*dphi_dx1[d]+m_du_dth1*dth1_dx1[d]; //note: dth2_dx1[d]=0 f2[d] = m_du_dphi*dphi_dx2[d]+m_du_dth1*dth1_dx2[d]+m_du_dth2*dth2_dx2[d]; @@ -731,7 +731,7 @@ void DihedralSpherical::write_restart(FILE *fp) { fwrite(&nterms[1],sizeof(int),atom->ndihedraltypes,fp); - for(int i = 1; i <= atom->ndihedraltypes; i++) { + for (int i = 1; i <= atom->ndihedraltypes; i++) { fwrite(Ccoeff[i],sizeof(double),nterms[i],fp); fwrite(phi_mult[i],sizeof(double),nterms[i],fp); fwrite(phi_shift[i],sizeof(double),nterms[i],fp); diff --git a/src/USER-MISC/dihedral_table.cpp b/src/USER-MISC/dihedral_table.cpp index 11b5016a9a..30e6192275 100644 --- a/src/USER-MISC/dihedral_table.cpp +++ b/src/USER-MISC/dihedral_table.cpp @@ -204,7 +204,7 @@ static int cyc_spline(double const *xa, // The for loop sets up the equations we need to solve. // Later we invoke the GSL tridiagonal matrix solver to solve them. - for(int i=0; i < n; i++) { + for (int i=0; i < n; i++) { // I have to lookup xa[i+1] and xa[i-1]. This gets tricky because of // periodic boundary conditions. We handle that now. @@ -675,7 +675,7 @@ void DihedralTable::compute(int eflag, int vflag) // d U d U d phi // -f = ----- = ----- * ----- // d x d phi d x - for(int d=0; d < g_dim; ++d) { + for (int d=0; d < g_dim; ++d) { f1[d] = m_du_dphi * dphi_dx1[d]; f2[d] = m_du_dphi * dphi_dx2[d]; f3[d] = m_du_dphi * dphi_dx3[d]; diff --git a/src/USER-MISC/dihedral_table_cut.cpp b/src/USER-MISC/dihedral_table_cut.cpp index 4c008bed6d..ed7b3ac0d6 100644 --- a/src/USER-MISC/dihedral_table_cut.cpp +++ b/src/USER-MISC/dihedral_table_cut.cpp @@ -221,7 +221,7 @@ static int cyc_spline(double const *xa, // The for loop sets up the equations we need to solve. // Later we invoke the GSL tridiagonal matrix solver to solve them. - for(int i=0; i < n; i++) { + for (int i=0; i < n; i++) { // I have to lookup xa[i+1] and xa[i-1]. This gets tricky because of // periodic boundary conditions. We handle that now. diff --git a/src/USER-MISC/fix_ave_correlate_long.cpp b/src/USER-MISC/fix_ave_correlate_long.cpp index bbf106e68a..a9c8228871 100644 --- a/src/USER-MISC/fix_ave_correlate_long.cpp +++ b/src/USER-MISC/fix_ave_correlate_long.cpp @@ -491,7 +491,7 @@ void FixAveCorrelateLong::end_of_step() evaluate(); if (fp && me == 0) { - if(overwrite) fseek(fp,filepos,SEEK_SET); + if (overwrite) fseek(fp,filepos,SEEK_SET); fprintf(fp,"# Timestep: " BIGINT_FORMAT "\n", ntimestep); for (unsigned int i=0;idt*nevery); @@ -590,7 +590,7 @@ void FixAveCorrelateLong::accumulate() /* ---------------------------------------------------------------------- Add a scalar value to the autocorrelator k of pair i ------------------------------------------------------------------------- */ -void FixAveCorrelateLong::add(const int i, const double w, const int k){ +void FixAveCorrelateLong::add(const int i, const double w, const int k) { // If we exceed the correlator side, the value is discarded if (k == numcorrelators) return; if (k > kmax) kmax=k; diff --git a/src/USER-MISC/fix_filter_corotate.cpp b/src/USER-MISC/fix_filter_corotate.cpp index 1bcf3cee21..4f1feeaa6c 100644 --- a/src/USER-MISC/fix_filter_corotate.cpp +++ b/src/USER-MISC/fix_filter_corotate.cpp @@ -260,14 +260,14 @@ void FixFilterCorotate::init() int i; // error if more than one filter int count = 0; - for (i = 0; i < modify->nfix; i++){ + for (i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"filter/corotate") == 0) count++; } if (count > 1) error->all(FLERR,"More than one fix filter/corotate"); // check for fix shake: count = 0; - for (i = 0; i < modify->nfix; i++){ + for (i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"shake") == 0) count++; } if (count > 1) @@ -353,7 +353,7 @@ void FixFilterCorotate::pre_neighbor() nlist = 0; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (shake_flag[i]) { if (shake_flag[i] == 2) { atom1 = atom->map(shake_atom[i][0]); @@ -682,11 +682,11 @@ void FixFilterCorotate::setup(int vflag) ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); } -void FixFilterCorotate::setup_pre_force_respa(int vflag,int ilevel){ +void FixFilterCorotate::setup_pre_force_respa(int vflag,int ilevel) { pre_force_respa(vflag,ilevel,0); } -//void FixFilterCorotate::setup_post_force_respa(int vflag,int ilevel){ +//void FixFilterCorotate::setup_post_force_respa(int vflag,int ilevel) { // post_force_respa(vflag,ilevel,0); //} @@ -944,7 +944,7 @@ void FixFilterCorotate::find_clusters() m = 0; while (m < size) { i = atom->map(buf[m]); - for (j = 0; j < npartner[i]; j++){ + for (j = 0; j < npartner[i]; j++) { if (buf[m+1] == partner_tag[i][j]) break; } partner_mask[i][j] = buf[m+2]; @@ -965,7 +965,7 @@ void FixFilterCorotate::find_clusters() // else it's an error flag = 0; - for (i = 0; i < nlocal; i++){ + for (i = 0; i < nlocal; i++) { for (j = 0; j < npartner[i]; j++) { if (partner_type[i][j] == 0) flag = 1; if (!(mask[i] & groupbit)) continue; @@ -1072,7 +1072,7 @@ void FixFilterCorotate::find_clusters() m = 0; while (m < size) { i = atom->map(buf[m]); - for (j = 0; j < npartner[i]; j++){ + for (j = 0; j < npartner[i]; j++) { if (buf[m+1] == partner_tag[i][j]) break; } partner_nshake[i][j] = buf[m+2]; @@ -1132,7 +1132,7 @@ void FixFilterCorotate::find_clusters() shake_type[i][3] = 0; if (nshake[i] == 1) { - for (j = 0; j < npartner[i]; j++){ + for (j = 0; j < npartner[i]; j++) { if (partner_shake[i][j]) break; } if (partner_nshake[i][j] == 1 && tag[i] < partner_tag[i][j]) { diff --git a/src/USER-MISC/fix_flow_gauss.cpp b/src/USER-MISC/fix_flow_gauss.cpp index 422c002158..0dabf82436 100644 --- a/src/USER-MISC/fix_flow_gauss.cpp +++ b/src/USER-MISC/fix_flow_gauss.cpp @@ -175,7 +175,7 @@ void FixFlowGauss::post_force(int /*vflag*/) f_thisProc[ii]=0.0; //add all forces on each processor - for(ii=0; iinarg) error->all(FLERR,"Did not specify C matrix for non-equilibrium GLE"); diff --git a/src/USER-MISC/fix_npt_cauchy.cpp b/src/USER-MISC/fix_npt_cauchy.cpp index a28363ff8e..cb7ca713a1 100644 --- a/src/USER-MISC/fix_npt_cauchy.cpp +++ b/src/USER-MISC/fix_npt_cauchy.cpp @@ -2754,23 +2754,23 @@ void FixNPTCauchy::CauchyStat_Step(double (&Fi)[3][3], double (&Fdot)[3][3], uv(5,1)=1; uv(5,2)=3; uv(6,1)=1; uv(6,2)=2; - for(int ii = 1;ii <= 6;ii++) { + for (int ii = 1;ii <= 6;ii++) { i=uv(ii,1); j=uv(ii,2); deltastress(ii)=setcauchy(i,j)-cauchy(i,j); - if(ii>3) deltastress(ii)=deltastress(ii)*2.0; + if (ii>3) deltastress(ii)=deltastress(ii)*2.0; fdotvec(ii)=Fdot(i,j)*deltat; } - for(int ii = 1;ii <= 6;ii++) { + for (int ii = 1;ii <= 6;ii++) { i=uv(ii,1); j=uv(ii,2); - for(int jj = 1;jj <= 6;jj++) { + for (int jj = 1;jj <= 6;jj++) { m=uv(jj,1); n=uv(jj,2); dsds(ii,jj) = Fi(i,m)*Fi(j,n) + Fi(i,n)*Fi(j,m) + Fi(j,m)*Fi(i,n) + Fi(j,n)*Fi(i,m); - for(int l = 1;l <= 3;l++) { - for(int k = 1;k <= 3;k++) { + for (int l = 1;l <= 3;l++) { + for (int k = 1;k <= 3;k++) { dsdf(ii,jj) = dsdf(ii,jj) + cauchy(k,l)* ( Fi(i,k)*Fi(j,l)*Fi(n,m) - Fi(i,m)*Fi(j,l)*Fi(n,k) - Fi(i,k)*Fi(j,m)*Fi(n,l) ); } @@ -2779,21 +2779,21 @@ void FixNPTCauchy::CauchyStat_Step(double (&Fi)[3][3], double (&Fdot)[3][3], } jac=volume/volume0; - for(int ii = 1;ii <= 6;ii++) { - for(int jj = 1;jj <= 6;jj++) { + for (int ii = 1;ii <= 6;ii++) { + for (int jj = 1;jj <= 6;jj++) { dsds(ii,jj)=dsds(ii,jj)*jac/4.0; dsdf(ii,jj)=dsdf(ii,jj)*jac; } } - for(int ii = 1;ii <= 6;ii++) { - for(int jj = 1;jj <= 6;jj++) { + for (int ii = 1;ii <= 6;ii++) { + for (int jj = 1;jj <= 6;jj++) { deltaF(ii)=deltaF(ii)+dsdf(ii,jj)*fdotvec(jj); } } - for(int ii = 1;ii <= 6;ii++) { - for(int jj = 1;jj <= 6;jj++) { + for (int ii = 1;ii <= 6;ii++) { + for (int jj = 1;jj <= 6;jj++) { deltaPK(ii)=deltaPK(ii)+alpha*dsds(ii,jj)*deltastress(jj); } deltaPK(ii)=deltaPK(ii)+alpha*deltaF(ii); diff --git a/src/USER-MISC/fix_pafi.cpp b/src/USER-MISC/fix_pafi.cpp index 2d229062de..ec0733657a 100644 --- a/src/USER-MISC/fix_pafi.cpp +++ b/src/USER-MISC/fix_pafi.cpp @@ -286,7 +286,7 @@ void FixPAFI::post_force(int /*vflag*/) } } - if (com_flag == 0){ + if (com_flag == 0) { c_v[9] += 1.0; } else { for (int i = 0; i < nlocal; i++) @@ -318,7 +318,7 @@ void FixPAFI::post_force(int /*vflag*/) results_all[4] = proj_all[5]; // dX.f force_flag = 1; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { f[i][0] -= proj_all[0] * path[i][3] + c_v_all[0]/c_v_all[9]; @@ -336,7 +336,7 @@ void FixPAFI::post_force(int /*vflag*/) } if (od_flag == 0) { - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (rmass) mass_f = sqrt(rmass[i]); else mass_f = sqrt(mass[type[i]]); @@ -351,7 +351,7 @@ void FixPAFI::post_force(int /*vflag*/) } } } else { - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (rmass) mass_f = sqrt(rmass[i]); @@ -449,7 +449,7 @@ void FixPAFI::min_post_force(int /*vflag*/) } } - if (com_flag == 0){ + if (com_flag == 0) { c_v[9] += 1.0; } else { for (int i = 0; i < nlocal; i++) @@ -482,7 +482,7 @@ void FixPAFI::min_post_force(int /*vflag*/) MPI_Bcast(results_all,5,MPI_DOUBLE,0,world); force_flag = 1; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { f[i][0] -= proj_all[0] * path[i][3] + c_v_all[0]/c_v_all[9]; @@ -544,7 +544,7 @@ void FixPAFI::initial_integrate(int /*vflag*/) proj[1] += v[i][2] * path[i][5]; // v.n } } - if (com_flag == 0){ + if (com_flag == 0) { c_v[9] += 1.0; } else { for (int i = 0; i < nlocal; i++) @@ -566,7 +566,7 @@ void FixPAFI::initial_integrate(int /*vflag*/) MPI_Allreduce(proj,proj_all,5,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(c_v,c_v_all,10,MPI_DOUBLE,MPI_SUM,world); - if (od_flag == 0){ + if (od_flag == 0) { if (rmass) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { @@ -650,7 +650,7 @@ void FixPAFI::final_integrate() proj[0] += f[i][1] * path[i][4]; // f.n proj[0] += f[i][2] * path[i][5]; // f.n } - if (com_flag == 0){ + if (com_flag == 0) { c_v[9] += 1.0; } else { for (int i = 0; i < nlocal; i++) @@ -665,7 +665,7 @@ void FixPAFI::final_integrate() MPI_Allreduce(proj,proj_all,5,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(c_v,c_v_all,10,MPI_DOUBLE,MPI_SUM,world); - if (od_flag == 0){ + if (od_flag == 0) { if (rmass) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { diff --git a/src/USER-MISC/fix_pimd.cpp b/src/USER-MISC/fix_pimd.cpp index 020799a943..5571f1cf35 100644 --- a/src/USER-MISC/fix_pimd.cpp +++ b/src/USER-MISC/fix_pimd.cpp @@ -52,34 +52,34 @@ FixPIMD::FixPIMD(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) nhc_nchain = 2; sp = 1.0; - for(int i=3; iuniverse_all(FLERR,"Unknown method parameter for fix pimd"); } - else if(strcmp(arg[i],"fmass")==0) + else if (strcmp(arg[i],"fmass")==0) { fmass = atof(arg[i+1]); - if(fmass<0.0 || fmass>1.0) error->universe_all(FLERR,"Invalid fmass value for fix pimd"); + if (fmass<0.0 || fmass>1.0) error->universe_all(FLERR,"Invalid fmass value for fix pimd"); } - else if(strcmp(arg[i],"sp")==0) + else if (strcmp(arg[i],"sp")==0) { sp = atof(arg[i+1]); - if(fmass<0.0) error->universe_all(FLERR,"Invalid sp value for fix pimd"); + if (fmass<0.0) error->universe_all(FLERR,"Invalid sp value for fix pimd"); } - else if(strcmp(arg[i],"temp")==0) + else if (strcmp(arg[i],"temp")==0) { nhc_temp = atof(arg[i+1]); - if(nhc_temp<0.0) error->universe_all(FLERR,"Invalid temp value for fix pimd"); + if (nhc_temp<0.0) error->universe_all(FLERR,"Invalid temp value for fix pimd"); } - else if(strcmp(arg[i],"nhc")==0) + else if (strcmp(arg[i],"nhc")==0) { nhc_nchain = atoi(arg[i+1]); - if(nhc_nchain<2) error->universe_all(FLERR,"Invalid nhc value for fix pimd"); + if (nhc_nchain<2) error->universe_all(FLERR,"Invalid nhc value for fix pimd"); } else error->universe_all(arg[i],i+1,"Unknown keyword for fix pimd"); } @@ -155,7 +155,7 @@ void FixPIMD::init() if (atom->map_style == Atom::MAP_NONE) error->all(FLERR,"Fix pimd requires an atom map, see atom_modify"); - if(universe->me==0 && screen) fprintf(screen,"Fix pimd initializing Path-Integral ...\n"); + if (universe->me==0 && screen) fprintf(screen,"Fix pimd initializing Path-Integral ...\n"); // prepare the constants @@ -190,7 +190,7 @@ void FixPIMD::init() omega_np = sqrt(np) / (hbar * beta) * sqrt(force->mvv2e); fbond = - _fbond * force->mvv2e; - if(universe->me==0) + if (universe->me==0) printf("Fix pimd -P/(beta^2 * hbar^2) = %20.7lE (kcal/mol/A^2)\n\n", fbond); dtv = update->dt; @@ -200,17 +200,17 @@ void FixPIMD::init() mass = new double [atom->ntypes+1]; - if(method==CMD || method==NMPIMD) nmpimd_init(); - else for(int i=1; i<=atom->ntypes; i++) mass[i] = atom->mass[i] / np * fmass; + if (method==CMD || method==NMPIMD) nmpimd_init(); + else for (int i=1; i<=atom->ntypes; i++) mass[i] = atom->mass[i] / np * fmass; - if(!nhc_ready) nhc_init(); + if (!nhc_ready) nhc_init(); } /* ---------------------------------------------------------------------- */ void FixPIMD::setup(int vflag) { - if(universe->me==0 && screen) fprintf(screen,"Setting up Path-Integral ...\n"); + if (universe->me==0 && screen) fprintf(screen,"Setting up Path-Integral ...\n"); post_force(vflag); } @@ -234,12 +234,12 @@ void FixPIMD::final_integrate() void FixPIMD::post_force(int /*flag*/) { - for(int i=0; inlocal; i++) for(int j=0; j<3; j++) atom->f[i][j] /= np; + for (int i=0; inlocal; i++) for(int j=0; j<3; j++) atom->f[i][j] /= np; comm_exec(atom->x); spring_force(); - if(method==CMD || method==NMPIMD) + if (method==CMD || method==NMPIMD) { /* forward comm for the force on ghost atoms */ @@ -267,29 +267,29 @@ void FixPIMD::nhc_init() double mass0 = KT * tau * tau; int max = 3 * atom->nlocal; - for(int i=0; iiworld==0) ; else nhc_eta_mass[i][ichain] *= fmass; + if ((method==CMD || method==NMPIMD) && universe->iworld==0) ; else nhc_eta_mass[i][ichain] *= fmass; } nhc_eta_dot[i][nhc_nchain] = 0.0; - for(int ichain=1; ichainmvv2e - KT) / nhc_eta_mass[i][ichain]; } // Zero NH acceleration for CMD - if(method==CMD && universe->iworld==0) for(int i=0; iiworld==0) for (int i=0; ix; double **v = atom->v; - if(method==CMD || method==NMPIMD) + if (method==CMD || method==NMPIMD) { nmpimd_fill(atom->v); comm_exec(atom->v); @@ -313,7 +313,7 @@ void FixPIMD::nhc_update_x() nmpimd_transform(buf_beads, v, M_xp2x[universe->iworld]); } - for(int i=0; iv; double **f = atom->f; - for(int i=0; iiworld==0) return; + if (method==CMD && universe->iworld==0) return; double expfac; int nmax = 3 * atom->nlocal; @@ -350,7 +350,7 @@ void FixPIMD::nhc_update_v() double dt4 = 0.25 * update->dt; double dt8 = 0.125 * update->dt; - for(int i=0; i0; ichain--) + for (int ichain=nhc_nchain-1; ichain>0; ichain--) { expfac = exp(-dt8 * eta_dot[ichain+1]); eta_dot[ichain] *= expfac; @@ -388,14 +388,14 @@ void FixPIMD::nhc_update_v() kecurrent = force->boltz * t_current; eta_dotdot[0] = (kecurrent - KT) / nhc_eta_mass[i][0]; - for(int ichain=0; ichainiworld; - for(int i=1; i<=atom->ntypes; i++) + for (int i=1; i<=atom->ntypes; i++) { mass[i] = atom->mass[i]; - if(iworld) + if (iworld) { mass[i] *= lam[iworld]; mass[i] *= fmass; @@ -491,10 +491,10 @@ void FixPIMD::nmpimd_transform(double** src, double** des, double *vector) int n = atom->nlocal; int m = 0; - for(int i=0; ime - comm->nprocs; int rank_next = universe->me + comm->nprocs; - if(rank_last<0) rank_last += universe->nprocs; - if(rank_next>=universe->nprocs) rank_next -= universe->nprocs; + if (rank_last<0) rank_last += universe->nprocs; + if (rank_next>=universe->nprocs) rank_next -= universe->nprocs; plan_send[0] = rank_next; plan_send[1] = rank_last; plan_recv[0] = rank_last; plan_recv[1] = rank_next; @@ -579,13 +579,13 @@ void FixPIMD::comm_init() plan_recv = new int [size_plan]; mode_index = new int [size_plan]; - for(int i=0; ime + comm->nprocs * (i+1); - if(plan_send[i]>=universe->nprocs) plan_send[i] -= universe->nprocs; + if (plan_send[i]>=universe->nprocs) plan_send[i] -= universe->nprocs; plan_recv[i] = universe->me - comm->nprocs * (i+1); - if(plan_recv[i]<0) plan_recv[i] += universe->nprocs; + if (plan_recv[i]<0) plan_recv[i] += universe->nprocs; mode_index[i]=(universe->iworld+i+1)%(universe->nworlds); } @@ -594,14 +594,14 @@ void FixPIMD::comm_init() x_last = (universe->iworld-1+universe->nworlds)%(universe->nworlds); } - if(buf_beads) + if (buf_beads) { - for(int i=0; inlocal; - if(nlocal > max_nlocal) + if (nlocal > max_nlocal) { max_nlocal = nlocal+200; int size = sizeof(double) * max_nlocal * 3; buf_recv = (double*) memory->srealloc(buf_recv, size, "FixPIMD:x_recv"); - for(int i=0; isrealloc(buf_beads[i], size, "FixPIMD:x_beads[i]"); } @@ -626,7 +626,7 @@ void FixPIMD::comm_exec(double **ptr) // go over comm plans - for(int iplan = 0; iplan max_nsend) + if (nsend > max_nsend) { max_nsend = nsend+200; tag_send = (tagint*) memory->srealloc(tag_send, sizeof(tagint)*max_nsend, "FixPIMD:tag_send"); @@ -654,11 +654,11 @@ void FixPIMD::comm_exec(double **ptr) double *wrap_ptr = buf_send; int ncpy = sizeof(double)*3; - for(int i=0; imap(tag_send[i]); - if(index<0) + if (index<0) { char error_line[256]; @@ -846,7 +846,7 @@ int FixPIMD::size_restart(int /*nlocal*/) double FixPIMD::compute_vector(int n) { - if(n==0) { return spring_energy; } - if(n==1) { return t_sys; } + if (n==0) { return spring_energy; } + if (n==1) { return t_sys; } return 0.0; } diff --git a/src/USER-MISC/fix_propel_self.cpp b/src/USER-MISC/fix_propel_self.cpp index 9299f4d23b..8617fb0d3d 100644 --- a/src/USER-MISC/fix_propel_self.cpp +++ b/src/USER-MISC/fix_propel_self.cpp @@ -171,8 +171,8 @@ void FixPropelSelf::post_force_quaternion(int /* vflag */ ) // Add the active force to the atom force: - for( int i = 0; i < nlocal; ++i ){ - if( mask[i] & groupbit ){ + for ( int i = 0; i < nlocal; ++i ) { + if ( mask[i] & groupbit ) { if (filter_by_type && !apply_to_type[type[i]]) { continue; } @@ -206,8 +206,8 @@ void FixPropelSelf::post_force_velocity(int /*vflag*/) // Add the active force to the atom force: - for(int i = 0; i < nlocal; ++i) { - if( mask[i] & groupbit ){ + for (int i = 0; i < nlocal; ++i) { + if ( mask[i] & groupbit ) { if (filter_by_type && !apply_to_type[type[i]]) { continue; } diff --git a/src/USER-MISC/fix_rhok.cpp b/src/USER-MISC/fix_rhok.cpp index e63ba88b93..a84d9dae4d 100644 --- a/src/USER-MISC/fix_rhok.cpp +++ b/src/USER-MISC/fix_rhok.cpp @@ -235,9 +235,9 @@ FixRhok::compute_vector( int inI ) { if (inI == 0) return mRhoKGlobal[0]; // Real part - else if( inI == 1 ) + else if ( inI == 1 ) return mRhoKGlobal[1]; // Imagniary part - else if( inI == 2 ) + else if ( inI == 2 ) return sqrt( mRhoKGlobal[0]*mRhoKGlobal[0] + mRhoKGlobal[1]*mRhoKGlobal[1] ); else diff --git a/src/USER-MISC/fix_smd.cpp b/src/USER-MISC/fix_smd.cpp index 2d6117608a..828ceda0ed 100644 --- a/src/USER-MISC/fix_smd.cpp +++ b/src/USER-MISC/fix_smd.cpp @@ -223,7 +223,7 @@ void FixSMD::smd_tether() if (!zflag) dz = 0.0; r = sqrt(dx*dx + dy*dy + dz*dz); if (styleflag & SMD_CVEL) { - if(r > SMALL) { + if (r > SMALL) { dr = r - r0 - r_old; fx = k_smd*dx*dr/r; fy = k_smd*dy*dr/r; diff --git a/src/USER-MISC/fix_srp.cpp b/src/USER-MISC/fix_srp.cpp index 70398711d9..254a66f2f2 100644 --- a/src/USER-MISC/fix_srp.cpp +++ b/src/USER-MISC/fix_srp.cpp @@ -134,8 +134,8 @@ void FixSRP::init() char c0[20]; char c1[20]; - for(int z = 1; z < atom->ntypes; z++) { - if(z == bptype) + for (int z = 1; z < atom->ntypes; z++) { + if (z == bptype) continue; sprintf(c0, "%d", z); arg1[2] = c0; @@ -175,7 +175,7 @@ void FixSRP::setup_pre_force(int /*zz*/) memory->create(tagold,nall,"fix_srp:tagold"); memory->create(dlist,nall,"fix_srp:dlist"); - for (i = 0; i < nall; i++){ + for (i = 0; i < nall; i++) { xold[i][0] = x[i][0]; xold[i][1] = x[i][1]; xold[i][2] = x[i][2]; @@ -209,7 +209,7 @@ void FixSRP::setup_pre_force(int /*zz*/) // consider only the user defined bond type // btype of zero considers all bonds - if(btype > 0 && bondlist[n][2] != btype) + if (btype > 0 && bondlist[n][2] != btype) continue; i = bondlist[n][0]; @@ -226,7 +226,7 @@ void FixSRP::setup_pre_force(int /*zz*/) dely = xold[j][1] - xold[i][1]; delz = xold[j][2] - xold[i][2]; rsq = delx*delx + dely*dely + delz*delz; - if(rsq > rsqold) rsqold = rsq; + if (rsq > rsqold) rsqold = rsq; // make one particle for each bond // i is local @@ -255,7 +255,7 @@ void FixSRP::setup_pre_force(int /*zz*/) int nadd_all = 0, ndel_all = 0; MPI_Allreduce(&ndel,&ndel_all,1,MPI_INT,MPI_SUM,world); MPI_Allreduce(&nadd,&nadd_all,1,MPI_INT,MPI_SUM,world); - if(comm->me == 0){ + if (comm->me == 0) { sprintf(str, "Removed/inserted %d/%d bond particles.", ndel_all,nadd_all); error->message(FLERR,str); } @@ -285,7 +285,7 @@ void FixSRP::setup_pre_force(int /*zz*/) cutghostmin = comm->cutghost[2]/length2; // stop if cutghost is insufficient - if (cutneighmax_srp > cutghostmin){ + if (cutneighmax_srp > cutghostmin) { sprintf(str, "Communication cutoff too small for fix srp. " "Need %f, current %f.", cutneighmax_srp, cutghostmin); error->all(FLERR,str); @@ -327,14 +327,14 @@ void FixSRP::setup_pre_force(int /*zz*/) // zero all forces - for(i = 0; i < nall; i++) + for (i = 0; i < nall; i++) atom->f[i][0] = atom->f[i][1] = atom->f[i][2] = 0.0; // do not include bond particles in thermo output // remove them from all groups. set their velocity to zero. - for(i=0; i< nlocal; i++) - if(atom->type[i] == bptype) { + for (i=0; i< nlocal; i++) + if (atom->type[i] == bptype) { atom->mask[i] = 0; atom->v[i][0] = atom->v[i][1] = atom->v[i][2] = 0.0; } @@ -355,15 +355,15 @@ void FixSRP::pre_exchange() int i,j; int nlocal = atom->nlocal; - for(int ii = 0; ii < nlocal; ii++){ - if(atom->type[ii] != bptype) continue; + for (int ii = 0; ii < nlocal; ii++) { + if (atom->type[ii] != bptype) continue; i = atom->map(static_cast(array[ii][0])); - if(i < 0) error->all(FLERR,"Fix SRP failed to map atom"); + if (i < 0) error->all(FLERR,"Fix SRP failed to map atom"); i = domain->closest_image(ii,i); j = atom->map(static_cast(array[ii][1])); - if(j < 0) error->all(FLERR,"Fix SRP failed to map atom"); + if (j < 0) error->all(FLERR,"Fix SRP failed to map atom"); j = domain->closest_image(ii,j); // position of bond particle ii @@ -462,7 +462,7 @@ int FixSRP::unpack_border(int n, int first, double *buf) int m = 0; last = first + n; - for (i = first; i < last; i++){ + for (i = first; i < last; i++) { array[i][0] = buf[m++]; array[i][1] = buf[m++]; } @@ -484,8 +484,8 @@ void FixSRP::post_run() int* dlist; memory->create(dlist,nlocal,"fix_srp:dlist"); - for (int i = 0; i < nlocal; i++){ - if(atom->type[i] == bptype) + for (int i = 0; i < nlocal; i++) { + if (atom->type[i] == bptype) dlist[i] = 1; else dlist[i] = 0; @@ -574,7 +574,7 @@ void FixSRP::unpack_restart(int nlocal, int nth) // unpack the Nth first values this way because other fixes pack them int m = 0; - for (int i = 0; i < nth; i++){ + for (int i = 0; i < nth; i++) { m += static_cast (extra[nlocal][m]); } diff --git a/src/USER-MISC/fix_ti_spring.cpp b/src/USER-MISC/fix_ti_spring.cpp index 88219a66cb..3a87dfa96d 100644 --- a/src/USER-MISC/fix_ti_spring.cpp +++ b/src/USER-MISC/fix_ti_spring.cpp @@ -380,7 +380,7 @@ double FixTISpring::switch_func(double t) double FixTISpring::dswitch_func(double t) { - if(sf == 1) return 1.0/t_switch; + if (sf == 1) return 1.0/t_switch; double t2 = t*t; double t4 = t2*t2; diff --git a/src/USER-MISC/fix_ttm_mod.cpp b/src/USER-MISC/fix_ttm_mod.cpp index e6aa062b39..a776e7e1da 100644 --- a/src/USER-MISC/fix_ttm_mod.cpp +++ b/src/USER-MISC/fix_ttm_mod.cpp @@ -290,8 +290,8 @@ void FixTTMMod::post_force(int /*vflag*/) double vsq = v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]; if (vsq > v_0_sq) gamma1 *= (gamma_p + gamma_s)/gamma_p; gamma2 = gfactor2[type[i]] * tsqrt; - if (ixnode >= surface_l){ - if (ixnode < surface_r){ + if (ixnode >= surface_l) { + if (ixnode < surface_r) { flangevin[i][0] = gamma1*v[i][0] + gamma2*(random->uniform()-0.5); flangevin[i][1] = gamma1*v[i][1] + gamma2*(random->uniform()-0.5); flangevin[i][2] = gamma1*v[i][2] + gamma2*(random->uniform()-0.5); @@ -320,8 +320,8 @@ void FixTTMMod::post_force(int /*vflag*/) double diff_x = (x_at - x_surf)*(x_at - x_surf); diff_x = pow(diff_x,0.5); double len_factor = diff_x/(diff_x+free_path); - if (movsur == 1){ - if (x_at >= x_surf){ + if (movsur == 1) { + if (x_at >= x_surf) { flangevin[i][0] -= pres_factor/ionic_density*((C_ir*T_ir*free_path/(diff_x+free_path)/(diff_x+free_path)) + (len_factor/dx)*(C_ir*T_ir-C_i*T_i)); flangevin[i][1] -= pres_factor/ionic_density/dy*(C_iu*T_iu-C_i*T_i); @@ -337,8 +337,8 @@ void FixTTMMod::post_force(int /*vflag*/) f[i][2] += flangevin[i][2]; } } - if (movsur == 1){ - if (ixnode < surface_l){ + if (movsur == 1) { + if (ixnode < surface_l) { t_surface_l = ixnode; } } @@ -629,12 +629,12 @@ void FixTTMMod::end_of_step() int *mask = atom->mask; int nlocal = atom->nlocal; - if (movsur == 1){ + if (movsur == 1) { for (int ixnode = 0; ixnode < nxnodes; ixnode++) for (int iynode = 0; iynode < nynodes; iynode++) - for (int iznode = 0; iznode < nznodes; iznode++){ + for (int iznode = 0; iznode < nznodes; iznode++) { double TTT = T_electron[ixnode][iynode][iznode]; - if (TTT > 0){ + if (TTT > 0) { if (ixnode < t_surface_l) t_surface_l = ixnode; } @@ -659,7 +659,7 @@ void FixTTMMod::end_of_step() while (ixnode < 0) ixnode += nxnodes; while (iynode < 0) iynode += nynodes; while (iznode < 0) iznode += nznodes; - if (ixnode >= t_surface_l){ + if (ixnode >= t_surface_l) { if (ixnode < surface_r) net_energy_transfer[ixnode][iynode][iznode] += (flangevin[i][0]*v[i][0] + flangevin[i][1]*v[i][1] + @@ -748,7 +748,7 @@ void FixTTMMod::end_of_step() double ixnode_d = double(ixnode); double surface_d = double(t_surface_l); mult_factor = 0.0; - if (duration < width){ + if (duration < width) { if (ixnode >= t_surface_l) mult_factor = (intensity/(dx*skin_layer_d))*exp((-1.0)*(ixnode_d - surface_d)/skin_layer_d); } if (ixnode < t_surface_l) net_energy_transfer_all[ixnode][iynode][iznode] = 0.0; @@ -862,7 +862,7 @@ void FixTTMMod::end_of_step() if (nsum_all[ixnode][iynode][iznode] > 0) { T_a = sum_mass_vsq_all[ixnode][iynode][iznode]/ (3.0*force->boltz*nsum_all[ixnode][iynode][iznode]/force->mvv2e); - if (movsur == 1){ + if (movsur == 1) { if (T_electron[ixnode][iynode][iznode]==0.0) T_electron[ixnode][iynode][iznode] = electron_temperature_min; } } diff --git a/src/USER-MISC/fix_wall_ees.cpp b/src/USER-MISC/fix_wall_ees.cpp index 554d8870a0..e8e307224f 100644 --- a/src/USER-MISC/fix_wall_ees.cpp +++ b/src/USER-MISC/fix_wall_ees.cpp @@ -122,8 +122,8 @@ void FixWallEES::wall_particle(int m, int which, double coord) double* shape = bonus[ellipsoid[i]].shape;; MathExtra::quat_to_mat(bonus[ellipsoid[i]].quat,A); MathExtra::transpose_matvec(A,nhat,tempvec); - for(int k = 0; k<3; k++) tempvec[k] *= shape[k]; - for(int k = 0; k<3 ; k++) sigman2 += tempvec[k]*tempvec[k]; + for (int k = 0; k<3; k++) tempvec[k] *= shape[k]; + for (int k = 0; k<3 ; k++) sigman2 += tempvec[k]*tempvec[k]; sigman = sqrt(sigman2); if (delta <= sigman) { @@ -149,7 +149,7 @@ void FixWallEES::wall_particle(int m, int which, double coord) double Lz[3][3] = {{0,-1,0},{1,0,0},{0,0,0}}; - for(int k = 0; k<3; k++) SAn[k] = tempvec[k]; + for (int k = 0; k<3; k++) SAn[k] = tempvec[k]; sigman3 = sigman2 * sigman; sigman4 = sigman2 * sigman2; @@ -189,21 +189,21 @@ void FixWallEES::wall_particle(int m, int which, double coord) MathExtra::matvec(Lx,nhat,tempvec); MathExtra::transpose_matvec(A,tempvec,tempvec2); - for(int k = 0; k<3; k++) tempvec2[k] *= shape[k]; + for (int k = 0; k<3; k++) tempvec2[k] *= shape[k]; that[0] = MathExtra::dot3(SAn,tempvec2); MathExtra::matvec(Ly,nhat,tempvec); MathExtra::transpose_matvec(A,tempvec,tempvec2); - for(int k = 0; k<3; k++) tempvec2[k] *= shape[k]; + for (int k = 0; k<3; k++) tempvec2[k] *= shape[k]; that[1] = MathExtra::dot3(SAn,tempvec2); MathExtra::matvec(Lz,nhat,tempvec); MathExtra::transpose_matvec(A,tempvec,tempvec2); - for(int k = 0; k < 3; k++) tempvec2[k] *= shape[k]; + for (int k = 0; k < 3; k++) tempvec2[k] *= shape[k]; that[2] = MathExtra::dot3(SAn,tempvec2); - for(int j = 0; j<3 ; j++) + for (int j = 0; j<3 ; j++) tor[i][j] += twall * that[j]; } diff --git a/src/USER-MISC/fix_wall_region_ees.cpp b/src/USER-MISC/fix_wall_region_ees.cpp index f88ec3f0b2..ab475ffb9b 100644 --- a/src/USER-MISC/fix_wall_region_ees.cpp +++ b/src/USER-MISC/fix_wall_region_ees.cpp @@ -190,14 +190,14 @@ void FixWallRegionEES::post_force(int /*vflag*/) double* shape = bonus[ellipsoid[i]].shape;; MathExtra::quat_to_mat(bonus[ellipsoid[i]].quat,A); - for(int which = 0 ; which < 3; which ++){//me + for (int which = 0 ; which < 3; which ++) {//me nhat[which]=1; nhat[(which+1)%3] = 0 ; nhat[(which+2)%3] = 0 ; sn2 = 0 ; MathExtra::transpose_matvec(A,nhat,tempvec); - for(int k = 0; k<3; k++) tempvec[k] *= shape[k]; - for(int k = 0; k<3 ; k++) sn2 += tempvec[k]*tempvec[k]; + for (int k = 0; k<3; k++) tempvec[k] *= shape[k]; + for (int k = 0; k<3 ; k++) sn2 += tempvec[k]*tempvec[k]; sn = sqrt(sn2); tooclose[which] = sn; } @@ -206,13 +206,13 @@ void FixWallRegionEES::post_force(int /*vflag*/) for (m = 0; m < n; m++) { - if (region->contact[m].delx != 0 && region->contact[m].r <= tooclose[0]){ + if (region->contact[m].delx != 0 && region->contact[m].r <= tooclose[0]) { onflag = 1; continue; - } else if (region->contact[m].dely != 0 && region->contact[m].r <= tooclose[1]){ + } else if (region->contact[m].dely != 0 && region->contact[m].r <= tooclose[1]) { onflag = 1; continue; - } else if (region->contact[m].delz !=0 && region->contact[m].r <= tooclose[2]){ + } else if (region->contact[m].delz !=0 && region->contact[m].r <= tooclose[2]) { onflag = 1; continue; } else rinv = 1.0/region->contact[m].r; @@ -323,9 +323,9 @@ void FixWallRegionEES::ees(int m, int i) sigman2 = 0.0; MathExtra::transpose_matvec(A,nhat,tempvec); - for(int k = 0; k<3; k++) tempvec[k] *= shape[k]; - for(int k = 0; k<3; k++) sigman2 += tempvec[k]*tempvec[k]; - for(int k = 0; k<3; k++) SAn[k] = tempvec[k]; + for (int k = 0; k<3; k++) tempvec[k] *= shape[k]; + for (int k = 0; k<3; k++) sigman2 += tempvec[k]*tempvec[k]; + for (int k = 0; k<3; k++) SAn[k] = tempvec[k]; sigman = sqrt(sigman2); delta = fabs(region->contact[m].r); @@ -362,19 +362,19 @@ void FixWallRegionEES::ees(int m, int i) MathExtra::matvec(Lx,nhat,tempvec); MathExtra::transpose_matvec(A,tempvec,tempvec2); - for(int k = 0; k<3; k++) tempvec2[k] *= shape[k]; + for (int k = 0; k<3; k++) tempvec2[k] *= shape[k]; that[0] = MathExtra::dot3(SAn,tempvec2); MathExtra::matvec(Ly,nhat,tempvec); MathExtra::transpose_matvec(A,tempvec,tempvec2); - for(int k = 0; k<3; k++) tempvec2[k] *= shape[k]; + for (int k = 0; k<3; k++) tempvec2[k] *= shape[k]; that[1] = MathExtra::dot3(SAn,tempvec2); MathExtra::matvec(Lz,nhat,tempvec); MathExtra::transpose_matvec(A,tempvec,tempvec2); - for(int k = 0; k < 3; k++) tempvec2[k] *= shape[k]; + for (int k = 0; k < 3; k++) tempvec2[k] *= shape[k]; that[2] = MathExtra::dot3(SAn,tempvec2); - for(int j = 0; j<3 ; j++) + for (int j = 0; j<3 ; j++) torque[j] = twall * that[j]; } diff --git a/src/USER-MISC/pair_agni.cpp b/src/USER-MISC/pair_agni.cpp index afb457d9e4..c6cd44871e 100644 --- a/src/USER-MISC/pair_agni.cpp +++ b/src/USER-MISC/pair_agni.cpp @@ -200,7 +200,7 @@ void PairAGNI::compute(int eflag, int vflag) double ky = 0.0; double kz = 0.0; - for(int k = 0; k < iparam.numeta; ++k) { + for (int k = 0; k < iparam.numeta; ++k) { const double xu = iparam.xU[k][j]; kx += square(Vx[k] - xu); ky += square(Vy[k] - xu); diff --git a/src/USER-MISC/pair_e3b.cpp b/src/USER-MISC/pair_e3b.cpp index 49c483ca1f..dceed1fc57 100644 --- a/src/USER-MISC/pair_e3b.cpp +++ b/src/USER-MISC/pair_e3b.cpp @@ -630,7 +630,7 @@ double PairE3B::init_one(int i, int j) bool PairE3B::checkKeyword(const char *thiskey,const char *test,const int nVal, const int nRem) { if (strcmp(thiskey,test) == 0) { - if(nRemall(FLERR,str); diff --git a/src/USER-MISC/pair_edip_multi.cpp b/src/USER-MISC/pair_edip_multi.cpp index 9d36db7041..6aedc863a8 100644 --- a/src/USER-MISC/pair_edip_multi.cpp +++ b/src/USER-MISC/pair_edip_multi.cpp @@ -365,14 +365,14 @@ void PairEDIPMulti::edip_fc(double r, Param *param, double &f, double &fdr) double x; double v1, v2; - if(r < c + 1E-6) + if (r < c + 1E-6) { f=1.0; fdr=0.0; return; } - if(r > a - 1E-6) + if (r > a - 1E-6) { f=0.0; fdr=0.0; @@ -394,7 +394,7 @@ void PairEDIPMulti::edip_fcut2(double r, Param *param, double &f, double &fdr) double a = param->cutoffA; double v1; - if(r > a - 1E-6) + if (r > a - 1E-6) { f=0.0; fdr=0.0; @@ -466,7 +466,7 @@ void PairEDIPMulti::edip_fcut3(double r, Param *param, double &f, double &fdr) double a = param->cutoffA; double v1; - if(r > a - 1E-6) + if (r > a - 1E-6) { f=0.0; fdr=0.0; diff --git a/src/USER-MISC/pair_ilp_graphene_hbn.cpp b/src/USER-MISC/pair_ilp_graphene_hbn.cpp index f3718834fa..58d9f39dcb 100644 --- a/src/USER-MISC/pair_ilp_graphene_hbn.cpp +++ b/src/USER-MISC/pair_ilp_graphene_hbn.cpp @@ -782,19 +782,19 @@ void PairILPGrapheneHBN::calc_normal() i = ilist[ii]; // Initialize the arrays - for (id = 0; id < 3; id++){ + for (id = 0; id < 3; id++) { pv12[id] = 0.0; pv31[id] = 0.0; pv23[id] = 0.0; n1[id] = 0.0; dni[id] = 0.0; normal[i][id] = 0.0; - for (ip = 0; ip < 3; ip++){ + for (ip = 0; ip < 3; ip++) { vet[ip][id] = 0.0; dnn[ip][id] = 0.0; dpvdri[ip][id] = 0.0; dnormdri[ip][id][i] = 0.0; - for (m = 0; m < 3; m++){ + for (m = 0; m < 3; m++) { dpv12[ip][id][m] = 0.0; dpv31[ip][id][m] = 0.0; dpv23[ip][id][m] = 0.0; @@ -828,10 +828,10 @@ void PairILPGrapheneHBN::calc_normal() normal[i][0] = 0.0; normal[i][1] = 0.0; normal[i][2] = 1.0; - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormdri[id][ip][i] = 0.0; - for (m = 0; m < 3; m++){ + for (m = 0; m < 3; m++) { dnormal[id][ip][m][i] = 0.0; } } @@ -877,8 +877,8 @@ void PairILPGrapheneHBN::calc_normal() // derivatives respect to the third neighbor, atom n // derivatives of pv12 to rn is zero - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv12[id][ip][2] = 0.0; } } @@ -899,15 +899,15 @@ void PairILPGrapheneHBN::calc_normal() dni[1] = (n1[0]*dpvdri[0][1] + n1[1]*dpvdri[1][1] + n1[2]*dpvdri[2][1])/nn; dni[2] = (n1[0]*dpvdri[0][2] + n1[1]*dpvdri[1][2] + n1[2]*dpvdri[2][2])/nn; // derivatives of unit vector ni respect to ri, the result is 3x3 matrix - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormdri[id][ip][i] = dpvdri[id][ip]/nn - n1[id]*dni[ip]/nn2; } } // derivatives of non-normalized normal vector, dn1:3x3x3 array - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ - for (m = 0; m < 3; m++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { + for (m = 0; m < 3; m++) { dn1[id][ip][m] = dpv12[id][ip][m]; } } @@ -915,16 +915,16 @@ void PairILPGrapheneHBN::calc_normal() // derivatives of nn, dnn:3x3 vector // dnn[id][m]: the derivative of nn respect to r[id][m], id,m=0,1,2 // r[id][m]: the id's component of atom m - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { dnn[id][m] = (n1[0]*dn1[0][id][m] + n1[1]*dn1[1][id][m] + n1[2]*dn1[2][id][m])/nn; } } // dnormal[id][ip][m][i]: the derivative of normal[id] respect to r[ip][m], id,ip=0,1,2 // for atom m, which is a neighbor atom of atom i, m=0,jnum-1 - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormal[id][ip][m][i] = dn1[id][ip][m]/nn - n1[id]*dnn[ip][m]/nn2; } } @@ -932,7 +932,7 @@ void PairILPGrapheneHBN::calc_normal() } //############################################################################################## - else if(cont == 3) { + else if (cont == 3) { pv12[0] = vet[0][1]*vet[1][2] - vet[1][1]*vet[0][2]; pv12[1] = vet[0][2]*vet[1][0] - vet[1][2]*vet[0][0]; pv12[2] = vet[0][0]*vet[1][1] - vet[1][0]*vet[0][1]; @@ -958,8 +958,8 @@ void PairILPGrapheneHBN::calc_normal() dpv12[2][2][1] = 0.0; // derivatives respect to the third neighbor, atom n - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv12[id][ip][2] = 0.0; } } @@ -988,8 +988,8 @@ void PairILPGrapheneHBN::calc_normal() dpv31[2][1][2] = -vet[0][0]; dpv31[2][2][2] = 0.0; // derivatives respect to the second neighbor, atom l - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv31[id][ip][1] = 0.0; } } @@ -998,8 +998,8 @@ void PairILPGrapheneHBN::calc_normal() pv23[1] = vet[1][2]*vet[2][0] - vet[2][2]*vet[1][0]; pv23[2] = vet[1][0]*vet[2][1] - vet[2][0]*vet[1][1]; // derivatives respect to the second neighbor, atom k - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv23[id][ip][0] = 0.0; } } @@ -1039,16 +1039,16 @@ void PairILPGrapheneHBN::calc_normal() normal[i][2] = n1[2]/nn; // for the central atoms, dnormdri is always zero - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormdri[id][ip][i] = 0.0; } } // derivatives of non-normalized normal vector, dn1:3x3x3 array - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ - for (m = 0; m < 3; m++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { + for (m = 0; m < 3; m++) { dn1[id][ip][m] = (dpv12[id][ip][m] + dpv23[id][ip][m] + dpv31[id][ip][m])/cont; } } @@ -1056,16 +1056,16 @@ void PairILPGrapheneHBN::calc_normal() // derivatives of nn, dnn:3x3 vector // dnn[id][m]: the derivative of nn respect to r[id][m], id,m=0,1,2 // r[id][m]: the id's component of atom m - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { dnn[id][m] = (n1[0]*dn1[0][id][m] + n1[1]*dn1[1][id][m] + n1[2]*dn1[2][id][m])/nn; } } // dnormal[id][ip][m][i]: the derivative of normal[id] respect to r[ip][m], id,ip=0,1,2 // for atom m, which is a neighbor atom of atom i, m=0,jnum-1 - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormal[id][ip][m][i] = dn1[id][ip][m]/nn - n1[id]*dnn[ip][m]/nn2; } } diff --git a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp index 93bfa8414f..d18d372b8b 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp @@ -787,19 +787,19 @@ void PairKolmogorovCrespiFull::calc_normal() i = ilist[ii]; // Initialize the arrays - for (id = 0; id < 3; id++){ + for (id = 0; id < 3; id++) { pv12[id] = 0.0; pv31[id] = 0.0; pv23[id] = 0.0; n1[id] = 0.0; dni[id] = 0.0; normal[i][id] = 0.0; - for (ip = 0; ip < 3; ip++){ + for (ip = 0; ip < 3; ip++) { vet[ip][id] = 0.0; dnn[ip][id] = 0.0; dpvdri[ip][id] = 0.0; dnormdri[ip][id][i] = 0.0; - for (m = 0; m < 3; m++){ + for (m = 0; m < 3; m++) { dpv12[ip][id][m] = 0.0; dpv31[ip][id][m] = 0.0; dpv23[ip][id][m] = 0.0; @@ -834,10 +834,10 @@ void PairKolmogorovCrespiFull::calc_normal() normal[i][1] = 0.0; normal[i][2] = 1.0; // derivatives of normal vector is zero - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormdri[id][ip][i] = 0.0; - for (m = 0; m < 3; m++){ + for (m = 0; m < 3; m++) { dnormal[id][ip][m][i] = 0.0; } } @@ -881,8 +881,8 @@ void PairKolmogorovCrespiFull::calc_normal() dpv12[2][2][1] = 0.0; // derivatives respect to the third neighbor, atom n - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv12[id][ip][2] = 0.0; } } @@ -903,16 +903,16 @@ void PairKolmogorovCrespiFull::calc_normal() dni[1] = (n1[0]*dpvdri[0][1] + n1[1]*dpvdri[1][1] + n1[2]*dpvdri[2][1])/nn; dni[2] = (n1[0]*dpvdri[0][2] + n1[1]*dpvdri[1][2] + n1[2]*dpvdri[2][2])/nn; // derivatives of unit vector ni respect to ri, the result is 3x3 matrix - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormdri[id][ip][i] = dpvdri[id][ip]/nn - n1[id]*dni[ip]/nn2; } } // derivatives of non-normalized normal vector, dn1:3x3x3 array - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ - for (m = 0; m < 3; m++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { + for (m = 0; m < 3; m++) { dn1[id][ip][m] = dpv12[id][ip][m]; } } @@ -920,16 +920,16 @@ void PairKolmogorovCrespiFull::calc_normal() // derivatives of nn, dnn:3x3 vector // dnn[id][m]: the derivative of nn respect to r[id][m], id,m=0,1,2 // r[id][m]: the id's component of atom m - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { dnn[id][m] = (n1[0]*dn1[0][id][m] + n1[1]*dn1[1][id][m] + n1[2]*dn1[2][id][m])/nn; } } // dnormal[id][ip][m][i]: the derivative of normal[id] respect to r[ip][m], id,ip=0,1,2 // for atom m, which is a neighbor atom of atom i, m=0,jnum-1 - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormal[id][ip][m][i] = dn1[id][ip][m]/nn - n1[id]*dnn[ip][m]/nn2; } } @@ -937,7 +937,7 @@ void PairKolmogorovCrespiFull::calc_normal() } //############################################################################################## - else if(cont == 3) { + else if (cont == 3) { // for the atoms at the edge who has only two neighbor atoms pv12[0] = vet[0][1]*vet[1][2] - vet[1][1]*vet[0][2]; pv12[1] = vet[0][2]*vet[1][0] - vet[1][2]*vet[0][0]; @@ -964,8 +964,8 @@ void PairKolmogorovCrespiFull::calc_normal() dpv12[2][2][1] = 0.0; // derivatives respect to the third neighbor, atom n - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv12[id][ip][2] = 0.0; } } @@ -997,8 +997,8 @@ void PairKolmogorovCrespiFull::calc_normal() dpv31[2][2][2] = 0.0; // derivatives respect to the second neighbor, atom l - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv31[id][ip][1] = 0.0; } } @@ -1007,8 +1007,8 @@ void PairKolmogorovCrespiFull::calc_normal() pv23[1] = vet[1][2]*vet[2][0] - vet[2][2]*vet[1][0]; pv23[2] = vet[1][0]*vet[2][1] - vet[2][0]*vet[1][1]; // derivatives respect to the second neighbor, atom k - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv23[id][ip][0] = 0.0; } } @@ -1048,16 +1048,16 @@ void PairKolmogorovCrespiFull::calc_normal() normal[i][2] = n1[2]/nn; // for the central atoms, dnormdri is always zero - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormdri[id][ip][i] = 0.0; } } // end of derivatives of normals respect to atom i // derivatives of non-normalized normal vector, dn1:3x3x3 array - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ - for (m = 0; m < 3; m++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { + for (m = 0; m < 3; m++) { dn1[id][ip][m] = (dpv12[id][ip][m] + dpv23[id][ip][m] + dpv31[id][ip][m])/cont; } } @@ -1065,16 +1065,16 @@ void PairKolmogorovCrespiFull::calc_normal() // derivatives of nn, dnn:3x3 vector // dnn[id][m]: the derivative of nn respect to r[id][m], id,m=0,1,2 // r[id][m]: the id's component of atom m - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { dnn[id][m] = (n1[0]*dn1[0][id][m] + n1[1]*dn1[1][id][m] + n1[2]*dn1[2][id][m])/nn; } } // dnormal[id][ip][m][i]: the derivative of normal[id] respect to r[ip][m], id,ip=0,1,2 // for atom m, which is a neighbor atom of atom i, m=0,jnum-1 - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormal[id][ip][m][i] = dn1[id][ip][m]/nn - n1[id]*dnn[ip][m]/nn2; } } diff --git a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp index 85c154e103..1bea688be5 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp @@ -162,7 +162,7 @@ void PairKolmogorovCrespiZ::compute(int eflag, int vflag) evdwl = -p.A*p.z06/r6+ exp1*sumCff - offset[itype][jtype]; } - if (evflag){ + if (evflag) { ev_tally_xyz(i,j,nlocal,newton_pair,evdwl,0, fsum,fsum,fpair,delx,dely,delz); } @@ -427,7 +427,7 @@ void PairKolmogorovCrespiZ::read_file(char *filename) params[nparams].z06 = pow(params[nparams].z0,6); nparams++; - if(nparams >= pow(atom->ntypes,3)) break; + if (nparams >= pow(atom->ntypes,3)) break; } memory->destroy(elem2param); memory->create(elem2param,nelements,nelements,"pair:elem2param"); diff --git a/src/USER-MISC/pair_lebedeva_z.cpp b/src/USER-MISC/pair_lebedeva_z.cpp index 4a85ecc60d..a600f5b761 100644 --- a/src/USER-MISC/pair_lebedeva_z.cpp +++ b/src/USER-MISC/pair_lebedeva_z.cpp @@ -158,7 +158,7 @@ void PairLebedevaZ::compute(int eflag, int vflag) evdwl = Ulm - offset[itype][jtype]; } - if (evflag){ + if (evflag) { ev_tally_xyz(i,j,nlocal,newton_pair,evdwl,0, -fxy,-fxy,-fz,delx,dely,delz); } @@ -421,7 +421,7 @@ void PairLebedevaZ::read_file(char *filename) params[nparams].z06 = pow(params[nparams].z0,6); nparams++; - if(nparams >= pow(atom->ntypes,3)) break; + if (nparams >= pow(atom->ntypes,3)) break; } memory->destroy(elem2param); memory->create(elem2param,nelements,nelements,"pair:elem2param"); diff --git a/src/USER-MISC/pair_local_density.cpp b/src/USER-MISC/pair_local_density.cpp index e16892c446..3da1fcbed2 100644 --- a/src/USER-MISC/pair_local_density.cpp +++ b/src/USER-MISC/pair_local_density.cpp @@ -182,7 +182,7 @@ void PairLocalDensity::compute(int eflag, int vflag) } } else { - for (k = 0; k < nLD; k++){ + for (k = 0; k < nLD; k++) { for (i = 0; i < nlocal; i++) { localrho[k][i] = 0.0; fp[k][i] = 0.0; @@ -710,7 +710,7 @@ void PairLocalDensity::parse_file(char *filename) { memory->create(a, nLD, atom->ntypes+1 , "pairLD:a"); memory->create(b, nLD, atom->ntypes+1, "pairLD:b"); if (me == 0) { - for (n = 1; n <= atom->ntypes; n++){ + for (n = 1; n <= atom->ntypes; n++) { for (k = 0; k < nLD; k++) { a[k][n] = 0; b[k][n] = 0; diff --git a/src/USER-MISC/pair_meam_spline.cpp b/src/USER-MISC/pair_meam_spline.cpp index e6071ff592..57981e8922 100644 --- a/src/USER-MISC/pair_meam_spline.cpp +++ b/src/USER-MISC/pair_meam_spline.cpp @@ -87,7 +87,7 @@ PairMEAMSpline::~PairMEAMSpline() delete[] twoBodyInfo; memory->destroy(Uprime_values); - if(allocated) { + if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); @@ -124,15 +124,15 @@ void PairMEAMSpline::compute(int eflag, int vflag) // Determine the maximum number of neighbors a single atom has int newMaxNeighbors = 0; - for(int ii = 0; ii < listfull->inum; ii++) { + for (int ii = 0; ii < listfull->inum; ii++) { int jnum = listfull->numneigh[listfull->ilist[ii]]; - if(jnum > newMaxNeighbors) + if (jnum > newMaxNeighbors) newMaxNeighbors = jnum; } // Allocate array for temporary bond info - if(newMaxNeighbors > maxNeighbors) { + if (newMaxNeighbors > maxNeighbors) { maxNeighbors = newMaxNeighbors; delete[] twoBodyInfo; twoBodyInfo = new MEAM2Body[maxNeighbors]; @@ -141,7 +141,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) // Sum three-body contributions to charge density and // the embedding energy - for(int ii = 0; ii < listfull->inum; ii++) { + for (int ii = 0; ii < listfull->inum; ii++) { int i = listfull->ilist[ii]; int numBonds = 0; @@ -151,7 +151,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) const int ntypes = atom->ntypes; const int itype = atom->type[i]; - for(int jj = 0; jj < listfull->numneigh[i]; jj++) { + for (int jj = 0; jj < listfull->numneigh[i]; jj++) { int j = listfull->firstneigh[i][jj]; j &= NEIGHMASK; @@ -160,7 +160,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) double jdelz = x[j][2] - x[i][2]; double rij_sq = jdelx*jdelx + jdely*jdely + jdelz*jdelz; - if(rij_sq < cutoff*cutoff) { + if (rij_sq < cutoff*cutoff) { double rij = sqrt(rij_sq); double partial_sum = 0; const int jtype = atom->type[j]; @@ -172,7 +172,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) nextTwoBodyInfo->del[1] = jdely / rij; nextTwoBodyInfo->del[2] = jdelz / rij; - for(int kk = 0; kk < numBonds; kk++) { + for (int kk = 0; kk < numBonds; kk++) { const MEAM2Body& bondk = twoBodyInfo[kk]; double cos_theta = (nextTwoBodyInfo->del[0]*bondk.del[0] + nextTwoBodyInfo->del[1]*bondk.del[1] + @@ -194,16 +194,16 @@ void PairMEAMSpline::compute(int eflag, int vflag) - zero_atom_energies[i_to_potl(itype)]; Uprime_values[i] = Uprime_i; - if(eflag) { - if(eflag_global) + if (eflag) { + if (eflag_global) eng_vdwl += embeddingEnergy; - if(eflag_atom) + if (eflag_atom) eatom[i] += embeddingEnergy; } // Compute three-body contributions to force double forces_i[3] = {0, 0, 0}; - for(int jj = 0; jj < numBonds; jj++) { + for (int jj = 0; jj < numBonds; jj++) { const MEAM2Body bondj = twoBodyInfo[jj]; double rij = bondj.r; int j = bondj.tag; @@ -215,7 +215,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) const int jtype = atom->type[j]; MEAM2Body const* bondk = twoBodyInfo; - for(int kk = 0; kk < jj; kk++, ++bondk) { + for (int kk = 0; kk < jj; kk++, ++bondk) { double rik = bondk->r; double cos_theta = (bondj.del[0]*bondk->del[0] + @@ -256,7 +256,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) forces[k][1] += fk[1]; forces[k][2] += fk[2]; - if(evflag) { + if (evflag) { double delta_ij[3]; double delta_ik[3]; delta_ij[0] = bondj.del[0] * rij; @@ -287,11 +287,11 @@ void PairMEAMSpline::compute(int eflag, int vflag) comm->forward_comm_pair(this); // Compute two-body pair interactions - for(int ii = 0; ii < listhalf->inum; ii++) { + for (int ii = 0; ii < listhalf->inum; ii++) { int i = listhalf->ilist[ii]; const int itype = atom->type[i]; - for(int jj = 0; jj < listhalf->numneigh[i]; jj++) { + for (int jj = 0; jj < listhalf->numneigh[i]; jj++) { int j = listhalf->firstneigh[i][jj]; j &= NEIGHMASK; @@ -301,7 +301,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) jdel[2] = x[j][2] - x[i][2]; double rij_sq = jdel[0]*jdel[0] + jdel[1]*jdel[1] + jdel[2]*jdel[2]; - if(rij_sq < cutoff*cutoff) { + if (rij_sq < cutoff*cutoff) { double rij = sqrt(rij_sq); const int jtype = atom->type[j]; @@ -330,7 +330,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) } } - if(vflag_fdotr) + if (vflag_fdotr) virial_fdotr_compute(); } @@ -375,7 +375,7 @@ void PairMEAMSpline::allocate() void PairMEAMSpline::settings(int narg, char **/*arg*/) { - if(narg != 0) error->all(FLERR,"Illegal pair_style command"); + if (narg != 0) error->all(FLERR,"Illegal pair_style command"); } /* ---------------------------------------------------------------------- @@ -457,9 +457,9 @@ void PairMEAMSpline::read_file(const char* filename) { int nmultichoose2; // = (n+1)*n/2; - if(comm->me == 0) { + if (comm->me == 0) { FILE *fp = utils::open_potential(filename,lmp,nullptr); - if(fp == nullptr) { + if (fp == nullptr) { char str[1024]; snprintf(str,128,"Cannot open spline MEAM potential file %s", filename); error->one(FLERR,str); @@ -568,18 +568,18 @@ void PairMEAMSpline::read_file(const char* filename) // Determine maximum cutoff radius of all relevant spline functions. cutoff = 0.0; for (int i = 0; i < nmultichoose2; i++) - if(phis[i].cutoff() > cutoff) + if (phis[i].cutoff() > cutoff) cutoff = phis[i].cutoff(); for (int i = 0; i < nelements; i++) - if(rhos[i].cutoff() > cutoff) + if (rhos[i].cutoff() > cutoff) cutoff = rhos[i].cutoff(); for (int i = 0; i < nelements; i++) - if(fs[i].cutoff() > cutoff) + if (fs[i].cutoff() > cutoff) cutoff = fs[i].cutoff(); // Set LAMMPS pair interaction flags. - for(int i = 1; i <= atom->ntypes; i++) { - for(int j = 1; j <= atom->ntypes; j++) { + for (int i = 1; i <= atom->ntypes; i++) { + for (int j = 1; j <= atom->ntypes; j++) { // setflag[i][j] = 1; cutsq[i][j] = cutoff; } @@ -592,7 +592,7 @@ void PairMEAMSpline::read_file(const char* filename) ------------------------------------------------------------------------- */ void PairMEAMSpline::init_style() { - if(force->newton_pair == 0) + if (force->newton_pair == 0) error->all(FLERR,"Pair style meam/spline requires newton pair on"); // Need both full and half neighbor list. @@ -613,8 +613,8 @@ void PairMEAMSpline::init_style() ------------------------------------------------------------------------- */ void PairMEAMSpline::init_list(int id, NeighList *ptr) { - if(id == 1) listfull = ptr; - else if(id == 2) listhalf = ptr; + if (id == 1) listfull = ptr; + else if (id == 2) listhalf = ptr; } /* ---------------------------------------------------------------------- @@ -679,7 +679,7 @@ void PairMEAMSpline::SplineFunction::parse(FILE* fp, Error* error, // Parse number of spline knots. utils::sfgets(FLERR,line,MAXLINE,fp,nullptr,error); int n = atoi(line); - if(n < 2) + if (n < 2) error->one(FLERR,"Invalid number of spline knots in MEAM potential file"); // Parse first derivatives at beginning and end of spline. @@ -693,10 +693,10 @@ void PairMEAMSpline::SplineFunction::parse(FILE* fp, Error* error, utils::sfgets(FLERR,line,MAXLINE,fp,nullptr,error); // Parse knot coordinates. - for(int i=0; ione(FLERR,"Invalid knot line in MEAM potential file"); } setKnot(i, x, y); @@ -718,36 +718,36 @@ void PairMEAMSpline::SplineFunction::prepareSpline(Error* error) double* u = new double[N]; Y2[0] = -0.5; u[0] = (3.0/(X[1]-X[0])) * ((Y[1]-Y[0])/(X[1]-X[0]) - deriv0); - for(int i = 1; i <= N-2; i++) { + for (int i = 1; i <= N-2; i++) { double sig = (X[i]-X[i-1]) / (X[i+1]-X[i-1]); double p = sig * Y2[i-1] + 2.0; Y2[i] = (sig - 1.0) / p; u[i] = (Y[i+1]-Y[i]) / (X[i+1]-X[i]) - (Y[i]-Y[i-1])/(X[i]-X[i-1]); u[i] = (6.0 * u[i]/(X[i+1]-X[i-1]) - sig*u[i-1])/p; - if(fabs(h*i+xmin - X[i]) > 1e-8) + if (fabs(h*i+xmin - X[i]) > 1e-8) isGridSpline = false; } double qn = 0.5; double un = (3.0/(X[N-1]-X[N-2])) * (derivN - (Y[N-1]-Y[N-2])/(X[N-1]-X[N-2])); Y2[N-1] = (un - qn*u[N-2]) / (qn * Y2[N-2] + 1.0); - for(int k = N-2; k >= 0; k--) { + for (int k = N-2; k >= 0; k--) { Y2[k] = Y2[k] * Y2[k+1] + u[k]; } delete[] u; #if !SPLINE_MEAM_SUPPORT_NON_GRID_SPLINES - if(!isGridSpline) + if (!isGridSpline) error->one(FLERR,"Support for MEAM potentials with non-uniform cubic splines has not been enabled in the MEAM potential code. Set SPLINE_MEAM_SUPPORT_NON_GRID_SPLINES in pair_spline_meam.h to 1 to enable it"); #endif // Shift the spline to X=0 to speed up interpolation. - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { Xs[i] = X[i] - xmin; #if !SPLINE_MEAM_SUPPORT_NON_GRID_SPLINES - if(i < N-1) Ydelta[i] = (Y[i+1]-Y[i])/h; + if (i < N-1) Ydelta[i] = (Y[i+1]-Y[i])/h; Y2[i] /= h*6.0; #endif } @@ -768,7 +768,7 @@ void PairMEAMSpline::SplineFunction::communicate(MPI_Comm& world, int me) MPI_Bcast(&h, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&hsq, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&inv_h, 1, MPI_DOUBLE, 0, world); - if(me != 0) { + if (me != 0) { X = new double[N]; Xs = new double[N]; Y = new double[N]; @@ -790,18 +790,18 @@ void PairMEAMSpline::SplineFunction::writeGnuplot(const char* filename, { FILE* fp = fopen(filename, "w"); fprintf(fp, "#!/usr/bin/env gnuplot\n"); - if(title) fprintf(fp, "set title \"%s\"\n", title); + if (title) fprintf(fp, "set title \"%s\"\n", title); double tmin = X[0] - (X[N-1] - X[0]) * 0.05; double tmax = X[N-1] + (X[N-1] - X[0]) * 0.05; double delta = (tmax - tmin) / (N*200); fprintf(fp, "set xrange [%f:%f]\n", tmin, tmax); fprintf(fp, "plot '-' with lines notitle, '-' with points notitle pt 3 lc 3\n"); - for(double x = tmin; x <= tmax+1e-8; x += delta) { + for (double x = tmin; x <= tmax+1e-8; x += delta) { double y = eval(x); fprintf(fp, "%f %f\n", x, y); } fprintf(fp, "e\n"); - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { fprintf(fp, "%f %f\n", X[i], Y[i]); } fprintf(fp, "e\n"); diff --git a/src/USER-MISC/pair_meam_sw_spline.cpp b/src/USER-MISC/pair_meam_sw_spline.cpp index 17511e90b8..09f5fa436d 100644 --- a/src/USER-MISC/pair_meam_sw_spline.cpp +++ b/src/USER-MISC/pair_meam_sw_spline.cpp @@ -74,7 +74,7 @@ PairMEAMSWSpline::~PairMEAMSWSpline() memory->destroy(Uprime_values); //memory->destroy(ESWprime_values); - if(allocated) { + if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); delete [] map; @@ -112,14 +112,14 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) // Determine the maximum number of neighbors a single atom has int newMaxNeighbors = 0; - for(int ii = 0; ii < inum_full; ii++) { + for (int ii = 0; ii < inum_full; ii++) { int jnum = numneigh_full[ilist_full[ii]]; - if(jnum > newMaxNeighbors) newMaxNeighbors = jnum; + if (jnum > newMaxNeighbors) newMaxNeighbors = jnum; } // Allocate array for temporary bond info - if(newMaxNeighbors > maxNeighbors) { + if (newMaxNeighbors > maxNeighbors) { maxNeighbors = newMaxNeighbors; delete[] twoBodyInfo; twoBodyInfo = new MEAM2Body[maxNeighbors]; @@ -128,7 +128,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) // Sum three-body contributions to charge density and // compute embedding energies - for(int ii = 0; ii < inum_full; ii++) { + for (int ii = 0; ii < inum_full; ii++) { int i = ilist_full[ii]; double xtmp = x[i][0]; double ytmp = x[i][1]; @@ -140,7 +140,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) int numBonds = 0; MEAM2Body* nextTwoBodyInfo = twoBodyInfo; - for(int jj = 0; jj < jnum; jj++) { + for (int jj = 0; jj < jnum; jj++) { int j = jlist[jj]; j &= NEIGHMASK; @@ -149,7 +149,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) double jdelz = x[j][2] - ztmp; double rij_sq = jdelx*jdelx + jdely*jdely + jdelz*jdelz; - if(rij_sq < cutforcesq) { + if (rij_sq < cutforcesq) { double rij = sqrt(rij_sq); double partial_sum = 0; double partial_sum2 = 0; @@ -162,7 +162,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) nextTwoBodyInfo->del[1] = jdely / rij; nextTwoBodyInfo->del[2] = jdelz / rij; - for(int kk = 0; kk < numBonds; kk++) { + for (int kk = 0; kk < numBonds; kk++) { const MEAM2Body& bondk = twoBodyInfo[kk]; double cos_theta = (nextTwoBodyInfo->del[0]*bondk.del[0] + nextTwoBodyInfo->del[1]*bondk.del[1] + @@ -188,16 +188,16 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) double ESWprime_i = 1.0; Uprime_values[i] = Uprime_i; // ESWprime_values[i] = ESWprime_i; - if(eflag) { - if(eflag_global) eng_vdwl += embeddingEnergy + SWEnergy; - if(eflag_atom) eatom[i] += embeddingEnergy + SWEnergy; + if (eflag) { + if (eflag_global) eng_vdwl += embeddingEnergy + SWEnergy; + if (eflag_atom) eatom[i] += embeddingEnergy + SWEnergy; } double forces_i[3] = {0, 0, 0}; // Compute three-body contributions to force - for(int jj = 0; jj < numBonds; jj++) { + for (int jj = 0; jj < numBonds; jj++) { const MEAM2Body bondj = twoBodyInfo[jj]; double rij = bondj.r; int j = bondj.tag; @@ -210,7 +210,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) double forces_j[3] = {0, 0, 0}; MEAM2Body const* bondk = twoBodyInfo; - for(int kk = 0; kk < jj; kk++, ++bondk) { + for (int kk = 0; kk < jj; kk++, ++bondk) { double rik = bondk->r; double cos_theta = (bondj.del[0]*bondk->del[0] + @@ -268,7 +268,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) forces[k][1] += fk[1]; forces[k][2] += fk[2]; - if(evflag) { + if (evflag) { double delta_ij[3]; double delta_ik[3]; delta_ij[0] = bondj.del[0] * rij; @@ -305,7 +305,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) // Compute two-body pair interactions - for(int ii = 0; ii < inum_half; ii++) { + for (int ii = 0; ii < inum_half; ii++) { int i = ilist_half[ii]; double xtmp = x[i][0]; double ytmp = x[i][1]; @@ -313,7 +313,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) int* jlist = firstneigh_half[i]; int jnum = numneigh_half[i]; - for(int jj = 0; jj < jnum; jj++) { + for (int jj = 0; jj < jnum; jj++) { int j = jlist[jj]; j &= NEIGHMASK; @@ -323,7 +323,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) jdel[2] = x[j][2] - ztmp; double rij_sq = jdel[0]*jdel[0] + jdel[1]*jdel[1] + jdel[2]*jdel[2]; - if(rij_sq < cutforcesq) { + if (rij_sq < cutforcesq) { double rij = sqrt(rij_sq); double rho_prime; @@ -350,7 +350,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) } } - if(vflag_fdotr) virial_fdotr_compute(); + if (vflag_fdotr) virial_fdotr_compute(); } /* ---------------------------------------------------------------------- */ @@ -372,7 +372,7 @@ void PairMEAMSWSpline::allocate() void PairMEAMSWSpline::settings(int narg, char **/*arg*/) { - if(narg != 0) error->all(FLERR,"Illegal pair_style command"); + if (narg != 0) error->all(FLERR,"Illegal pair_style command"); } /* ---------------------------------------------------------------------- @@ -460,9 +460,9 @@ void PairMEAMSWSpline::coeff(int narg, char **arg) void PairMEAMSWSpline::read_file(const char* filename) { - if(comm->me == 0) { + if (comm->me == 0) { FILE *fp = utils::open_potential(filename,lmp,nullptr); - if(fp == nullptr) { + if (fp == nullptr) { char str[1024]; snprintf(str,1024,"Cannot open spline MEAM potential file %s", filename); error->one(FLERR,str); @@ -498,14 +498,14 @@ void PairMEAMSWSpline::read_file(const char* filename) // Determine maximum cutoff radius of all relevant spline functions. cutoff = 0.0; - if(phi.cutoff() > cutoff) cutoff = phi.cutoff(); - if(rho.cutoff() > cutoff) cutoff = rho.cutoff(); - if(f.cutoff() > cutoff) cutoff = f.cutoff(); - if(F.cutoff() > cutoff) cutoff = F.cutoff(); + if (phi.cutoff() > cutoff) cutoff = phi.cutoff(); + if (rho.cutoff() > cutoff) cutoff = rho.cutoff(); + if (f.cutoff() > cutoff) cutoff = f.cutoff(); + if (F.cutoff() > cutoff) cutoff = F.cutoff(); // Set LAMMPS pair interaction flags. - for(int i = 1; i <= atom->ntypes; i++) { - for(int j = 1; j <= atom->ntypes; j++) { + for (int i = 1; i <= atom->ntypes; i++) { + for (int j = 1; j <= atom->ntypes; j++) { setflag[i][j] = 1; cutsq[i][j] = cutoff; } @@ -525,7 +525,7 @@ void PairMEAMSWSpline::read_file(const char* filename) ------------------------------------------------------------------------- */ void PairMEAMSWSpline::init_style() { - if(force->newton_pair == 0) + if (force->newton_pair == 0) error->all(FLERR,"Pair style meam/sw/spline requires newton pair on"); // Need both full and half neighbor list. @@ -543,8 +543,8 @@ void PairMEAMSWSpline::init_style() ------------------------------------------------------------------------- */ void PairMEAMSWSpline::init_list(int id, NeighList *ptr) { - if(id == 1) listfull = ptr; - else if(id == 2) listhalf = ptr; + if (id == 1) listfull = ptr; + else if (id == 2) listhalf = ptr; } /* ---------------------------------------------------------------------- @@ -604,7 +604,7 @@ void PairMEAMSWSpline::SplineFunction::parse(FILE* fp, Error* error) // Parse number of spline knots. utils::sfgets(FLERR,line,MAXLINE,fp,nullptr,error); int n = atoi(line); - if(n < 2) + if (n < 2) error->one(FLERR,"Invalid number of spline knots in MEAM potential file"); // Parse first derivatives at beginning and end of spline. @@ -617,10 +617,10 @@ void PairMEAMSWSpline::SplineFunction::parse(FILE* fp, Error* error) utils::sfgets(FLERR,line,MAXLINE,fp,nullptr,error); // Parse knot coordinates. - for(int i=0; ione(FLERR,"Invalid knot line in MEAM potential file"); } setKnot(i, x, y); @@ -642,36 +642,36 @@ void PairMEAMSWSpline::SplineFunction::prepareSpline(Error* error) double* u = new double[N]; Y2[0] = -0.5; u[0] = (3.0/(X[1]-X[0])) * ((Y[1]-Y[0])/(X[1]-X[0]) - deriv0); - for(int i = 1; i <= N-2; i++) { + for (int i = 1; i <= N-2; i++) { double sig = (X[i]-X[i-1]) / (X[i+1]-X[i-1]); double p = sig * Y2[i-1] + 2.0; Y2[i] = (sig - 1.0) / p; u[i] = (Y[i+1]-Y[i]) / (X[i+1]-X[i]) - (Y[i]-Y[i-1])/(X[i]-X[i-1]); u[i] = (6.0 * u[i]/(X[i+1]-X[i-1]) - sig*u[i-1])/p; - if(fabs(h*i+xmin - X[i]) > 1e-8) + if (fabs(h*i+xmin - X[i]) > 1e-8) isGridSpline = false; } double qn = 0.5; double un = (3.0/(X[N-1]-X[N-2])) * (derivN - (Y[N-1]-Y[N-2])/(X[N-1]-X[N-2])); Y2[N-1] = (un - qn*u[N-2]) / (qn * Y2[N-2] + 1.0); - for(int k = N-2; k >= 0; k--) { + for (int k = N-2; k >= 0; k--) { Y2[k] = Y2[k] * Y2[k+1] + u[k]; } delete[] u; #if !SPLINE_MEAM_SUPPORT_NON_GRID_SPLINES - if(!isGridSpline) + if (!isGridSpline) error->one(FLERR,"Support for MEAM potentials with non-uniform cubic splines has not been enabled in the MEAM potential code. Set SPLINE_MEAM_SUPPORT_NON_GRID_SPLINES in pair_spline_meam.h to 1 to enable it"); #endif // Shift the spline to X=0 to speed up interpolation. - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { Xs[i] = X[i] - xmin; #if !SPLINE_MEAM_SUPPORT_NON_GRID_SPLINES - if(i < N-1) Ydelta[i] = (Y[i+1]-Y[i])/h; + if (i < N-1) Ydelta[i] = (Y[i+1]-Y[i])/h; Y2[i] /= h*6.0; #endif } @@ -692,7 +692,7 @@ void PairMEAMSWSpline::SplineFunction::communicate(MPI_Comm& world, int me) MPI_Bcast(&h, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&hsq, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&inv_h, 1, MPI_DOUBLE, 0, world); - if(me != 0) { + if (me != 0) { X = new double[N]; Xs = new double[N]; Y = new double[N]; @@ -713,18 +713,18 @@ void PairMEAMSWSpline::SplineFunction::writeGnuplot(const char* filename, const { FILE* fp = fopen(filename, "w"); fprintf(fp, "#!/usr/bin/env gnuplot\n"); - if(title) fprintf(fp, "set title \"%s\"\n", title); + if (title) fprintf(fp, "set title \"%s\"\n", title); double tmin = X[0] - (X[N-1] - X[0]) * 0.05; double tmax = X[N-1] + (X[N-1] - X[0]) * 0.05; double delta = (tmax - tmin) / (N*200); fprintf(fp, "set xrange [%f:%f]\n", tmin, tmax); fprintf(fp, "plot '-' with lines notitle, '-' with points notitle pt 3 lc 3\n"); - for(double x = tmin; x <= tmax+1e-8; x += delta) { + for (double x = tmin; x <= tmax+1e-8; x += delta) { double y = eval(x); fprintf(fp, "%f %f\n", x, y); } fprintf(fp, "e\n"); - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { fprintf(fp, "%f %f\n", X[i], Y[i]); } fprintf(fp, "e\n"); diff --git a/src/USER-MISC/pair_srp.cpp b/src/USER-MISC/pair_srp.cpp index 2dd8a675ab..d32d56f5b7 100644 --- a/src/USER-MISC/pair_srp.cpp +++ b/src/USER-MISC/pair_srp.cpp @@ -174,9 +174,9 @@ void PairSRP::compute(int eflag, int vflag) // mapping global to local for atoms inside bond particles // exclude 1-2 neighs if requested - if (neighbor->ago == 0){ + if (neighbor->ago == 0) { remapBonds(nall); - if(exclude) onetwoexclude(ilist, inum, jlist, numneigh, firstneigh); + if (exclude) onetwoexclude(ilist, inum, jlist, numneigh, firstneigh); } // this pair style only used with hybrid @@ -185,7 +185,7 @@ void PairSRP::compute(int eflag, int vflag) // each neigh j is type bptype // using midpoint distance option - if(midpoint){ + if (midpoint) { for (ii = 0; ii < inum; ii++) { @@ -215,7 +215,7 @@ void PairSRP::compute(int eflag, int vflag) dz = 0.5*(x[i0][2] - x[i1][2] + x[j0][2] - x[j1][2]); dijsq = dx*dx + dy*dy + dz*dz; - if (dijsq < cutsq[bptype][bptype]){ + if (dijsq < cutsq[bptype][bptype]) { dij = sqrt(dijsq); if (dij < SMALL) @@ -248,11 +248,11 @@ void PairSRP::compute(int eflag, int vflag) // ************************************************* // - if (eflag){ + if (eflag) { evdwl = 0.5 * a0[bptype][bptype] * cut[bptype][bptype] * wd * wd; } - if (evflag){ + if (evflag) { ev_tally(i0,i1,nlocal,1,0.5*evdwl,0.0,fpair,dx,dy,dz); ev_tally(j0,j1,nlocal,1,0.5*evdwl,0.0,fpair,dx,dy,dz); } @@ -289,7 +289,7 @@ void PairSRP::compute(int eflag, int vflag) getMinDist(x, dx, dy, dz, ti, tj, i0, j0, i1, j1); dijsq = dx*dx + dy*dy + dz*dz; - if (dijsq < cutsq[bptype][bptype]){ + if (dijsq < cutsq[bptype][bptype]) { dij = sqrt(dijsq); @@ -333,11 +333,11 @@ void PairSRP::compute(int eflag, int vflag) // ************************************************* // - if (eflag){ + if (eflag) { evdwl = 0.5 * a0[bptype][bptype] * cut[bptype][bptype] * wd * wd; } - if (evflag){ + if (evflag) { ev_tally(i0,i1,nlocal,1,0.5*evdwl,0.0,0.5*fpair,dx,dy,dz); ev_tally(j0,j1,nlocal,1,0.5*evdwl,0.0,0.5*fpair,dx,dy,dz); } @@ -394,7 +394,7 @@ void PairSRP::settings(int narg, char **arg) if (iarg+2 > narg) error->all(FLERR,"Illegal pair srp command"); if (strcmp(arg[iarg+1],"yes") == 0) exclude = 1; - if (strcmp(arg[iarg+1],"no") == 0){ + if (strcmp(arg[iarg+1],"no") == 0) { if (min) error->all(FLERR,"Illegal exclude option in pair srp command"); exclude = 0; } @@ -552,8 +552,8 @@ inline void PairSRP::getMinDist(double** &x, double &dx, double &dy, double &dz, // handle case of parallel lines // reduce to midpt distance - if (fabs(denom) < SMALL){ - if(denom < 0) denom = -BIG; + if (fabs(denom) < SMALL) { + if (denom < 0) denom = -BIG; else denom = BIG; } @@ -586,7 +586,7 @@ map global id of atoms in stored by each bond particle ------------------------------------------------------- */ inline void PairSRP::remapBonds(int &nall) { - if(nall > maxcount){ + if (nall > maxcount) { memory->grow(segment, nall, 2, "pair:segment"); maxcount = nall; } @@ -600,7 +600,7 @@ inline void PairSRP::remapBonds(int &nall) srp = f_srp->array_atom; for (int i = 0; i < nall; i++) { - if(atom->type[i] == bptype){ + if (atom->type[i] == bptype) { // tmp is local id // tmp == -1 is ok tmp = atom->map((int)srp[i][0]); @@ -643,7 +643,7 @@ inline void PairSRP::onetwoexclude(int* &ilist, int &inum, int* &jlist, int* &nu j1 = segment[j][1]; // check for a 1-2 neigh - if(i0 == i1 || i0 == j1 || i1 == j0 || j0 == j1){ + if (i0 == i1 || i0 == j1 || i1 == j0 || j0 == j1) { j |= ONETWOBIT; jlist[jj] = j; } diff --git a/src/USER-MISC/pair_tersoff_table.cpp b/src/USER-MISC/pair_tersoff_table.cpp index c4e2d2c993..9eae918128 100644 --- a/src/USER-MISC/pair_tersoff_table.cpp +++ b/src/USER-MISC/pair_tersoff_table.cpp @@ -953,7 +953,7 @@ void PairTersoffTable::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/USER-OMP/dihedral_table_omp.cpp b/src/USER-OMP/dihedral_table_omp.cpp index 158f350b6d..6d6acc27e6 100644 --- a/src/USER-OMP/dihedral_table_omp.cpp +++ b/src/USER-OMP/dihedral_table_omp.cpp @@ -344,7 +344,7 @@ void DihedralTableOMP::eval(int nfrom, int nto, ThrData * const thr) // d U d U d phi // -f = ----- = ----- * ----- // d x d phi d x - for(int d=0; d < g_dim; ++d) { + for (int d=0; d < g_dim; ++d) { f1[d] = m_du_dphi * dphi_dx1[d]; f2[d] = m_du_dphi * dphi_dx2[d]; f3[d] = m_du_dphi * dphi_dx3[d]; diff --git a/src/USER-OMP/fix_nve_sphere_omp.cpp b/src/USER-OMP/fix_nve_sphere_omp.cpp index aba966b71d..5e66d0f2c7 100644 --- a/src/USER-OMP/fix_nve_sphere_omp.cpp +++ b/src/USER-OMP/fix_nve_sphere_omp.cpp @@ -126,7 +126,7 @@ void FixNVESphereOMP::initial_integrate(int /* vflag */) // Q = I + vx + vx^2 * (1-c)/s^2 const double s2 = a[0]*a[0] + a[1]*a[1]; - if (s2 != 0.0){ // i.e. the vectors are not parallel + if (s2 != 0.0) { // i.e. the vectors are not parallel const double scale = (1.0 - a[2])/s2; Q[0][0] = 1.0 - scale*a[0]*a[0]; Q[0][1] = -scale*a[0]*a[1]; Q[0][2] = -a[0]; diff --git a/src/USER-OMP/fix_qeq_comb_omp.cpp b/src/USER-OMP/fix_qeq_comb_omp.cpp index a0fb934bf8..957c49abe6 100644 --- a/src/USER-OMP/fix_qeq_comb_omp.cpp +++ b/src/USER-OMP/fix_qeq_comb_omp.cpp @@ -135,7 +135,7 @@ void FixQEQCombOMP::post_force(int /* vflag */) } comm->forward_comm_fix(this); - if(comb) enegtot = comb->yasu_char(qf,igroup); + if (comb) enegtot = comb->yasu_char(qf,igroup); enegtot /= ngroup; enegchk = enegmax = 0.0; diff --git a/src/USER-OMP/pair_agni_omp.cpp b/src/USER-OMP/pair_agni_omp.cpp index 0582133d6c..393503badb 100644 --- a/src/USER-OMP/pair_agni_omp.cpp +++ b/src/USER-OMP/pair_agni_omp.cpp @@ -137,7 +137,7 @@ void PairAGNIOMP::eval(int iifrom, int iito, ThrData * const thr) double ky = 0.0; double kz = 0.0; - for(int k = 0; k < iparam.numeta; ++k) { + for (int k = 0; k < iparam.numeta; ++k) { const double xu = iparam.xU[k][j]; kx += square(Vx[k] - xu); ky += square(Vy[k] - xu); diff --git a/src/USER-OMP/pair_brownian_omp.cpp b/src/USER-OMP/pair_brownian_omp.cpp index b7405a2605..2841c5e840 100644 --- a/src/USER-OMP/pair_brownian_omp.cpp +++ b/src/USER-OMP/pair_brownian_omp.cpp @@ -79,20 +79,20 @@ void PairBrownianOMP::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (int j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/USER-OMP/pair_brownian_poly_omp.cpp b/src/USER-OMP/pair_brownian_poly_omp.cpp index d7aef4b8b9..d02d13a74e 100644 --- a/src/USER-OMP/pair_brownian_poly_omp.cpp +++ b/src/USER-OMP/pair_brownian_poly_omp.cpp @@ -79,20 +79,20 @@ void PairBrownianPolyOMP::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (int j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/USER-OMP/pair_comb_omp.cpp b/src/USER-OMP/pair_comb_omp.cpp index e535a3529e..045db5d402 100644 --- a/src/USER-OMP/pair_comb_omp.cpp +++ b/src/USER-OMP/pair_comb_omp.cpp @@ -242,7 +242,7 @@ void PairCombOMP::eval(int iifrom, int iito, ThrData * const thr) jtype = map[type[j]]; iparam_ij = elem2param[itype][jtype][jtype]; - if(params[iparam_ij].hfocor > 0.0 ) { + if (params[iparam_ij].hfocor > 0.0 ) { delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; delr1[2] = x[j][2] - ztmp; diff --git a/src/USER-OMP/pair_eam_alloy_omp.cpp b/src/USER-OMP/pair_eam_alloy_omp.cpp index 81bd6474d0..37cc1aa6f1 100644 --- a/src/USER-OMP/pair_eam_alloy_omp.cpp +++ b/src/USER-OMP/pair_eam_alloy_omp.cpp @@ -116,7 +116,7 @@ void PairEAMAlloyOMP::read_file(char *filename) Setfl *file = setfl; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(PairEAM::lmp, filename, "eam/alloy", unit_convert_flag); diff --git a/src/USER-OMP/pair_eam_fs_omp.cpp b/src/USER-OMP/pair_eam_fs_omp.cpp index c7cd02ba4b..41a2a2eeba 100644 --- a/src/USER-OMP/pair_eam_fs_omp.cpp +++ b/src/USER-OMP/pair_eam_fs_omp.cpp @@ -116,7 +116,7 @@ void PairEAMFSOMP::read_file(char *filename) Fs *file = fs; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(PairEAM::lmp, filename, "eam/fs", unit_convert_flag); diff --git a/src/USER-OMP/pair_lj_cut_thole_long_omp.cpp b/src/USER-OMP/pair_lj_cut_thole_long_omp.cpp index ab84b374cb..33968f1710 100644 --- a/src/USER-OMP/pair_lj_cut_thole_long_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_thole_long_omp.cpp @@ -146,7 +146,7 @@ void PairLJCutTholeLongOMP::eval(int iifrom, int iito, ThrData * const thr) jnum = numneigh[i]; fxtmp=fytmp=fztmp=0.; - if (drudetype[type[i]] != NOPOL_TYPE){ + if (drudetype[type[i]] != NOPOL_TYPE) { di = atom->map(drudeid[i]); if (di < 0) error->all(FLERR, "Drude partner not found"); di_closest = domain->closest_image(i, di); @@ -202,9 +202,9 @@ void PairLJCutTholeLongOMP::eval(int iifrom, int iito, ThrData * const thr) } if (drudetype[type[i]] != NOPOL_TYPE && - drudetype[type[j]] != NOPOL_TYPE){ - if (j != di_closest){ - if (drudetype[type[j]] == CORE_TYPE){ + drudetype[type[j]] != NOPOL_TYPE) { + if (j != di_closest) { + if (drudetype[type[j]] == CORE_TYPE) { dj = atom->map(drudeid[j]); dqj = -q[dj]; } else dqj = qj; @@ -246,7 +246,7 @@ void PairLJCutTholeLongOMP::eval(int iifrom, int iito, ThrData * const thr) } if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; if (drudetype[type[i]] != NOPOL_TYPE && - drudetype[type[j]] != NOPOL_TYPE && j != di_closest){ + drudetype[type[j]] != NOPOL_TYPE && j != di_closest) { ecoul += factor_e * dcoul; } } else ecoul = 0.0; diff --git a/src/USER-OMP/pair_lj_long_coul_long_omp.cpp b/src/USER-OMP/pair_lj_long_coul_long_omp.cpp index f2c8799415..7c258fb94c 100644 --- a/src/USER-OMP/pair_lj_long_coul_long_omp.cpp +++ b/src/USER-OMP/pair_lj_long_coul_long_omp.cpp @@ -718,7 +718,7 @@ void PairLJLongCoulLongOMP::eval(int iifrom, int iito, ThrData * const thr) if (rsq < cut_ljsqi[typej]) { // lj if (ORDER6) { // long-range lj - if(!LJTABLE || rsq <= tabinnerdispsq) { //series real space + if (!LJTABLE || rsq <= tabinnerdispsq) { //series real space double rn = r2inv*r2inv*r2inv; double x2 = g2*rsq, a2 = 1.0/x2; x2 = a2*exp(-x2)*lj4i[typej]; diff --git a/src/USER-OMP/pair_lubricate_omp.cpp b/src/USER-OMP/pair_lubricate_omp.cpp index d78bda9b42..4291850820 100644 --- a/src/USER-OMP/pair_lubricate_omp.cpp +++ b/src/USER-OMP/pair_lubricate_omp.cpp @@ -65,20 +65,20 @@ void PairLubricateOMP::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (int j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/USER-OMP/pair_lubricate_poly_omp.cpp b/src/USER-OMP/pair_lubricate_poly_omp.cpp index 10738be70a..4226c96e1b 100644 --- a/src/USER-OMP/pair_lubricate_poly_omp.cpp +++ b/src/USER-OMP/pair_lubricate_poly_omp.cpp @@ -65,20 +65,20 @@ void PairLubricatePolyOMP::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (int j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/USER-OMP/pair_meam_spline_omp.cpp b/src/USER-OMP/pair_meam_spline_omp.cpp index 500a3d17c7..bb8ab8af7c 100644 --- a/src/USER-OMP/pair_meam_spline_omp.cpp +++ b/src/USER-OMP/pair_meam_spline_omp.cpp @@ -93,9 +93,9 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) // Determine the maximum number of neighbors a single atom has. int myMaxNeighbors = 0; - for(int ii = iifrom; ii < iito; ii++) { + for (int ii = iifrom; ii < iito; ii++) { int jnum = numneigh_full[ilist_full[ii]]; - if(jnum > myMaxNeighbors) myMaxNeighbors = jnum; + if (jnum > myMaxNeighbors) myMaxNeighbors = jnum; } // Allocate array for temporary bond info. @@ -113,7 +113,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) const double cutforcesq = cutoff*cutoff; // Sum three-body contributions to charge density and compute embedding energies. - for(int ii = iifrom; ii < iito; ii++) { + for (int ii = iifrom; ii < iito; ii++) { const int i = ilist_full[ii]; const double xtmp = x[i][0]; @@ -125,7 +125,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) int numBonds = 0; MEAM2Body* nextTwoBodyInfo = myTwoBodyInfo; - for(int jj = 0; jj < jnum; jj++) { + for (int jj = 0; jj < jnum; jj++) { const int j = jlist[jj] & NEIGHMASK; const double jdelx = x[j][0] - xtmp; @@ -145,7 +145,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) nextTwoBodyInfo->del[1] = jdely / rij; nextTwoBodyInfo->del[2] = jdelz / rij; - for(int kk = 0; kk < numBonds; kk++) { + for (int kk = 0; kk < numBonds; kk++) { const MEAM2Body& bondk = myTwoBodyInfo[kk]; double cos_theta = (nextTwoBodyInfo->del[0]*bondk.del[0] + nextTwoBodyInfo->del[1]*bondk.del[1] + @@ -173,7 +173,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) double forces_i[3] = {0.0, 0.0, 0.0}; // Compute three-body contributions to force. - for(int jj = 0; jj < numBonds; jj++) { + for (int jj = 0; jj < numBonds; jj++) { const MEAM2Body bondj = myTwoBodyInfo[jj]; const double rij = bondj.r; const int j = bondj.tag; @@ -185,7 +185,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) double forces_j[3] = {0.0, 0.0, 0.0}; MEAM2Body const* bondk = myTwoBodyInfo; - for(int kk = 0; kk < jj; kk++, ++bondk) { + for (int kk = 0; kk < jj; kk++, ++bondk) { const double rik = bondk->r; const double cos_theta = (bondj.del[0]*bondk->del[0] @@ -226,7 +226,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) forces[k][1] += fk[1]; forces[k][2] += fk[2]; - if(EVFLAG) { + if (EVFLAG) { double delta_ij[3]; double delta_ik[3]; delta_ij[0] = bondj.del[0] * rij; @@ -277,7 +277,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) const int* const * const firstneigh_half = listhalf->firstneigh; // Compute two-body pair interactions. - for(int ii = iifrom; ii < iito; ii++) { + for (int ii = iifrom; ii < iito; ii++) { const int i = ilist_half[ii]; const double xtmp = x[i][0]; const double ytmp = x[i][1]; @@ -286,7 +286,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) const int jnum = numneigh_half[i]; const int itype = atom->type[i]; - for(int jj = 0; jj < jnum; jj++) { + for (int jj = 0; jj < jnum; jj++) { const int j = jlist[jj] & NEIGHMASK; double jdel[3]; @@ -295,7 +295,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) jdel[2] = x[j][2] - ztmp; double rij_sq = jdel[0]*jdel[0] + jdel[1]*jdel[1] + jdel[2]*jdel[2]; - if(rij_sq < cutforcesq) { + if (rij_sq < cutforcesq) { double rij = sqrt(rij_sq); const int jtype = atom->type[j]; diff --git a/src/USER-OMP/pair_reaxc_omp.cpp b/src/USER-OMP/pair_reaxc_omp.cpp index 459113bfb8..b717f87d0f 100644 --- a/src/USER-OMP/pair_reaxc_omp.cpp +++ b/src/USER-OMP/pair_reaxc_omp.cpp @@ -241,7 +241,7 @@ void PairReaxCOMP::compute(int eflag, int vflag) #if defined(_OPENMP) #pragma omp parallel for schedule(static) #endif - for(int k = 0; k < system->N; ++k) { + for (int k = 0; k < system->N; ++k) { num_bonds[k] = system->my_atoms[k].num_bonds; num_hbonds[k] = system->my_atoms[k].num_hbonds; } @@ -293,7 +293,7 @@ void PairReaxCOMP::compute(int eflag, int vflag) // populate tmpid and tmpbo arrays for fix reax/c/species - if(fixspecies_flag) { + if (fixspecies_flag) { if (system->N > nmax) { memory->destroy(tmpid); memory->destroy(tmpbo); @@ -365,7 +365,7 @@ void PairReaxCOMP::init_style( ) error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an " "increased neighbor list skin."); - for( int i = 0; i < LIST_N; ++i ) + for ( int i = 0; i < LIST_N; ++i ) lists[i].allocated = 0; if (fix_reax == nullptr) { @@ -424,7 +424,7 @@ void PairReaxCOMP::setup( ) write_reax_atoms(); int num_nbrs = estimate_reax_lists(); - if(!Make_List(system->total_cap, num_nbrs, TYP_FAR_NEIGHBOR, + if (!Make_List(system->total_cap, num_nbrs, TYP_FAR_NEIGHBOR, lists+FAR_NBRS)) error->all(FLERR,"Pair reax/c problem in far neighbor list"); @@ -433,7 +433,7 @@ void PairReaxCOMP::setup( ) InitializeOMP( system, control, data, workspace, &lists, out_control, mpi_data, world ); - for( int k = 0; k < system->N; ++k ) { + for ( int k = 0; k < system->N; ++k ) { num_bonds[k] = system->my_atoms[k].num_bonds; num_hbonds[k] = system->my_atoms[k].num_hbonds; } @@ -446,7 +446,7 @@ void PairReaxCOMP::setup( ) // reset the bond list info for new atoms - for(int k = oldN; k < system->N; ++k) + for (int k = oldN; k < system->N; ++k) Set_End_Index( k, Start_Index( k, lists+BONDS ), lists+BONDS ); // estimate far neighbor list size @@ -472,7 +472,7 @@ void PairReaxCOMP::write_reax_atoms() #if defined(_OPENMP) #pragma omp parallel for schedule(static) default(shared) #endif - for( int i = 0; i < system->N; ++i ){ + for ( int i = 0; i < system->N; ++i ) { system->my_atoms[i].orig_id = atom->tag[i]; system->my_atoms[i].type = map[atom->type[i]]; system->my_atoms[i].x[0] = atom->x[i][0]; @@ -596,7 +596,7 @@ void PairReaxCOMP::read_reax_forces(int /* vflag */) #if defined(_OPENMP) #pragma omp parallel for schedule(static) default(shared) #endif - for( int i = 0; i < system->N; ++i ) { + for ( int i = 0; i < system->N; ++i ) { system->my_atoms[i].f[0] = workspace->f[i][0]; system->my_atoms[i].f[1] = workspace->f[i][1]; system->my_atoms[i].f[2] = workspace->f[i][2]; @@ -622,7 +622,7 @@ void PairReaxCOMP::FindBond() bond_data *bo_ij; nj = 0; - for( pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj ) { + for ( pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj ) { bo_ij = &( lists->select.bond_list[pj] ); j = bo_ij->nbr; if (j < i) continue; diff --git a/src/USER-OMP/pair_tersoff_zbl_omp.cpp b/src/USER-OMP/pair_tersoff_zbl_omp.cpp index d721565d99..44d7994c9e 100644 --- a/src/USER-OMP/pair_tersoff_zbl_omp.cpp +++ b/src/USER-OMP/pair_tersoff_zbl_omp.cpp @@ -190,7 +190,7 @@ void PairTersoffZBLOMP::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/USER-OMP/reaxc_bond_orders_omp.cpp b/src/USER-OMP/reaxc_bond_orders_omp.cpp index 6253df7fe7..ec93d9478d 100644 --- a/src/USER-OMP/reaxc_bond_orders_omp.cpp +++ b/src/USER-OMP/reaxc_bond_orders_omp.cpp @@ -164,7 +164,7 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, } // forces on k: i neighbor - for( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { + for ( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -194,7 +194,7 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, } // forces on k: j neighbor - for( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { + for ( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -274,7 +274,7 @@ void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, * forces related to atom i * * first neighbors of atom i * ************************************/ - for( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { + for ( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -307,7 +307,7 @@ void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, /* force */ rvec_Add(workspace->forceReduction[reductionOffset+i],temp ); - for( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { + for ( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -463,7 +463,7 @@ void BOOMP( reax_system *system, control_params * /* control */, simulation_data #endif for (i = 0; i < system->N; ++i) { type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[type_i]); workspace->Deltap[i] = workspace->total_bond_order[i] - sbp_i->valency; workspace->Deltap_boc[i] = @@ -483,7 +483,7 @@ void BOOMP( reax_system *system, control_params * /* control */, simulation_data #endif for (i = 0; i < system->N; ++i) { type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[type_i]); val_i = sbp_i->valency; Deltap_i = workspace->Deltap[i]; @@ -494,7 +494,7 @@ void BOOMP( reax_system *system, control_params * /* control */, simulation_data for (pj = start_i; pj < end_i; ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; bo_ij = &( bonds->select.bond_list[pj].bo_data ); if (i < j || workspace->bond_mark[j] > 3) { @@ -652,14 +652,14 @@ void BOOMP( reax_system *system, control_params * /* control */, simulation_data #endif for (i = 0; i < system->N; ++i) { type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; start_i = Start_Index(i, bonds); end_i = End_Index(i, bonds); for (pj = start_i; pj < end_i; ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; if (i < j || workspace->bond_mark[j] > 3) { // Computed in previous for-loop @@ -692,9 +692,9 @@ void BOOMP( reax_system *system, control_params * /* control */, simulation_data #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for(j = 0; j < system->N; ++j ) { + for (j = 0; j < system->N; ++j ) { type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; sbp_j = &(system->reax_param.sbp[ type_j ]); workspace->Delta[j] = workspace->total_bond_order[j] - sbp_j->valency; diff --git a/src/USER-OMP/reaxc_bonds_omp.cpp b/src/USER-OMP/reaxc_bonds_omp.cpp index 413d50d0f9..30d50a4e70 100644 --- a/src/USER-OMP/reaxc_bonds_omp.cpp +++ b/src/USER-OMP/reaxc_bonds_omp.cpp @@ -174,7 +174,7 @@ void BondsOMP( reax_system *system, control_params * /* control */, } } } - } // for(i) + } // for (i) } // omp diff --git a/src/USER-OMP/reaxc_forces_omp.cpp b/src/USER-OMP/reaxc_forces_omp.cpp index 849c239ed0..68ab6f933d 100644 --- a/src/USER-OMP/reaxc_forces_omp.cpp +++ b/src/USER-OMP/reaxc_forces_omp.cpp @@ -92,7 +92,7 @@ void Compute_Bonded_ForcesOMP( reax_system *system, control_params *control, #endif /* Implement all force calls as function pointers */ - for( i = 0; i < NUM_INTRS; i++ ) { + for ( i = 0; i < NUM_INTRS; i++ ) { (Interaction_Functions[i])( system, control, data, workspace, lists, out_control ); } @@ -199,7 +199,7 @@ void Compute_Total_ForceOMP( reax_system *system, control_params *control, // Add_dBond_to_Forces_NPTOMP(system, i, pj, data, workspace, lists ); // } - if(control->virial == 0) { + if (control->virial == 0) { #if defined(_OPENMP) #pragma omp for schedule(dynamic,50) @@ -225,7 +225,7 @@ void Compute_Total_ForceOMP( reax_system *system, control_params *control, Add_dBond_to_Forces_NPTOMP(system, i, pj, data, workspace, lists ); } - } // if(virial == 0) + } // if (virial == 0) pair_reax_ptr->reduce_thr_proxy(system->pair_ptr, 0, 1, thr); @@ -284,7 +284,7 @@ void Validate_ListsOMP(reax_system *system, storage * /*workspace*/, reax_list * #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for(int i = 0; i < N; ++i ) { + for (int i = 0; i < N; ++i ) { system->my_atoms[i].num_bonds = MAX(Num_Entries(i,bonds)*2, MIN_BONDS); if (i < N-1) @@ -308,7 +308,7 @@ void Validate_ListsOMP(reax_system *system, storage * /*workspace*/, reax_list * #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for(int i = 0; i < n; ++i ) { + for (int i = 0; i < n; ++i ) { Hindex = system->my_atoms[i].Hindex; if (Hindex > -1) { system->my_atoms[i].num_hbonds = @@ -395,7 +395,7 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, start_i = Start_Index(i, far_nbrs); end_i = End_Index(i, far_nbrs); - for( pj = start_i; pj < end_i; ++pj ) { + for ( pj = start_i; pj < end_i; ++pj ) { nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); if (nbr_pj->d <= cutoff) { int j = nbr_pj->nbr; @@ -445,7 +445,7 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, BO = BO_s + BO_pi + BO_pi2; // End top portion of BOp() - if(BO >= bo_cut) { + if (BO >= bo_cut) { int btop_j; // Update indices in critical section @@ -478,12 +478,12 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, btop_i++; num_bonds++; - } // if(BO>=bo_cut) + } // if (BO>=bo_cut) - } // if(cutoff) + } // if (cutoff) - } // for(pj) - } // for(i) + } // for (pj) + } // for (i) // Need to wait for all indices and tmp arrays accumulated. #if defined(_OPENMP) @@ -493,8 +493,8 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, #if defined(_OPENMP) #pragma omp for schedule(dynamic,50) #endif - for(int i=0; iN; i++) - for(int t=0; tN; i++) + for (int t=0; tN + i; workspace->dDeltap_self[i][0] += tmp_ddelta[indx][0]; workspace->dDeltap_self[i][1] += tmp_ddelta[indx][1]; @@ -529,7 +529,7 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, j = nbr_pj->nbr; atom_j = &(system->my_atoms[j]); type_j = atom_j->type; - if(type_j < 0) continue; + if (type_j < 0) continue; sbp_j = &(system->reax_param.sbp[type_j]); jhb = sbp_j->p_hbond; @@ -537,30 +537,30 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, int iflag = 0; int jflag = 0; - if(ihb==1 && jhb==2) iflag = 1; - else if(jn && ihb == 2 && jhb == 1) jflag = 1; + if (ihb==1 && jhb==2) iflag = 1; + else if (jn && ihb == 2 && jhb == 1) jflag = 1; - if(iflag || jflag) { - if(iflag) { + if (iflag || jflag) { + if (iflag) { ihb_top = End_Index(atom_i->Hindex, hbonds); Set_End_Index(atom_i->Hindex, ihb_top+1, hbonds); - } else if(jflag) { + } else if (jflag) { jhb_top = End_Index(atom_j->Hindex, hbonds); Set_End_Index(atom_j->Hindex, jhb_top+1, hbonds); } - if(iflag) { + if (iflag) { hbonds->select.hbond_list[ihb_top].nbr = j; hbonds->select.hbond_list[ihb_top].scl = 1; hbonds->select.hbond_list[ihb_top].ptr = nbr_pj; - } else if(jflag) { + } else if (jflag) { hbonds->select.hbond_list[jhb_top].nbr = i; hbonds->select.hbond_list[jhb_top].scl = -1; hbonds->select.hbond_list[jhb_top].ptr = nbr_pj; } num_hbonds++; - } // if(iflag || jflag) + } // if (iflag || jflag) } } @@ -569,13 +569,13 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, } // omp critical } - } // if(control->hbond > 0) + } // if (control->hbond > 0) // Zero buffers for others to use as intended. #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for(int i=0; imy_atoms[j].Hindex, hbonds ); hb_end_j = End_Index( system->my_atoms[j].Hindex, hbonds ); - if(type_j < 0) continue; + if (type_j < 0) continue; top = 0; for( pi = start_j; pi < end_j; ++pi ) { pbond_ij = &( bond_list[pi] ); i = pbond_ij->nbr; type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; bo_ij = &(pbond_ij->bo_data); - if( system->reax_param.sbp[type_i].p_hbond == 2 && + if ( system->reax_param.sbp[type_i].p_hbond == 2 && bo_ij->BO >= HB_THRESHOLD ) hblist[top++] = pi; } @@ -140,7 +140,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, /* set k's varibles */ k = hbond_list[pk].nbr; type_k = system->my_atoms[k].type; - if(type_k < 0) continue; + if (type_k < 0) continue; nbr_jk = hbond_list[pk].ptr; r_jk = nbr_jk->d; rvec_Scale( dvec_jk, hbond_list[pk].scl, nbr_jk->dvec ); @@ -153,7 +153,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, if (system->my_atoms[i].orig_id != system->my_atoms[k].orig_id) { bo_ij = &(pbond_ij->bo_data); type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; hbp = &(system->reax_param.hbp[ type_i ][ type_j ][ type_k ]); ++num_hb_intrs; diff --git a/src/USER-OMP/reaxc_init_md_omp.cpp b/src/USER-OMP/reaxc_init_md_omp.cpp index af982443cb..1312953180 100644 --- a/src/USER-OMP/reaxc_init_md_omp.cpp +++ b/src/USER-OMP/reaxc_init_md_omp.cpp @@ -68,26 +68,26 @@ int Init_ListsOMP(reax_system *system, control_params *control, if (control->hbond_cut > 0) { /* init H indexes */ total_hbonds = 0; - for(i = 0; i < system->n; ++i) { + for (i = 0; i < system->n; ++i) { system->my_atoms[i].num_hbonds = hb_top[i]; total_hbonds += hb_top[i]; } total_hbonds = (int)(MAX(total_hbonds*saferzone,mincap*system->minhbonds)); - if(!Make_List(system->Hcap, total_hbonds, TYP_HBOND, + if (!Make_List(system->Hcap, total_hbonds, TYP_HBOND, *lists+HBONDS)) { error->one(FLERR, "Not enough space for hbonds list. Terminating!"); } } total_bonds = 0; - for(i = 0; i < system->N; ++i) { + for (i = 0; i < system->N; ++i) { system->my_atoms[i].num_bonds = bond_top[i]; total_bonds += bond_top[i]; } bond_cap = (int)(MAX(total_bonds*safezone, mincap*MIN_BONDS)); - if(!Make_List(system->total_cap, bond_cap, TYP_BOND, + if (!Make_List(system->total_cap, bond_cap, TYP_BOND, *lists+BONDS)) { error->one(FLERR, "Not enough space for bonds list. Terminating!\n"); } @@ -101,8 +101,8 @@ int Init_ListsOMP(reax_system *system, control_params *control, /* 3bodies list */ cap_3body = (int)(MAX(num_3body*safezone, MIN_3BODIES)); - if(!Make_List(bond_cap, cap_3body, TYP_THREE_BODY, - *lists+THREE_BODIES)){ + if (!Make_List(bond_cap, cap_3body, TYP_THREE_BODY, + *lists+THREE_BODIES)) { error->one(FLERR, "Problem in initializing angles list. Terminating!"); } diff --git a/src/USER-OMP/reaxc_multi_body_omp.cpp b/src/USER-OMP/reaxc_multi_body_omp.cpp index 86ba98631a..52ef7048d6 100644 --- a/src/USER-OMP/reaxc_multi_body_omp.cpp +++ b/src/USER-OMP/reaxc_multi_body_omp.cpp @@ -106,7 +106,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, #endif for ( i = 0; i < system->n; ++i) { type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[ type_i ]); /* lone-pair Energy */ @@ -120,7 +120,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, numbonds ++; /* calculate the energy */ - if(numbonds > 0) + if (numbonds > 0) total_Elp += e_lp = p_lp2 * workspace->Delta_lp[i] * inv_expvd2; @@ -128,7 +128,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, 75 * p_lp2 * workspace->Delta_lp[i] * expvd2 * SQR(inv_expvd2); CElp = dElp * workspace->dDelta_lp[i]; - if(numbonds > 0) workspace->CdDelta[i] += CElp; // lp - 1st term + if (numbonds > 0) workspace->CdDelta[i] += CElp; // lp - 1st term /* tally into per-atom energy */ if (system->pair_ptr->evflag) @@ -140,7 +140,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; if (!strcmp( system->reax_param.sbp[type_j].name, "C" )) { twbp = &( system->reax_param.tbp[type_i][type_j]); @@ -171,7 +171,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, #endif for (i = 0; i < system->n; ++i) { type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[ type_i ]); /* over-coordination energy */ @@ -184,7 +184,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; bo_ij = &(bonds->select.bond_list[pj].bo_data); twbp = &(system->reax_param.tbp[ type_i ][ type_j ]); @@ -230,7 +230,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) numbonds ++; - if(numbonds > 0) total_Eun += e_un = + if (numbonds > 0) total_Eun += e_un = -p_ovun5 * (1.0 - exp_ovun6) * inv_exp_ovun2n * inv_exp_ovun8; CEunder1 = inv_exp_ovun2n * @@ -244,14 +244,14 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, /* tally into per-atom energy */ if (system->pair_ptr->evflag) { eng_tmp = e_ov; - if(numbonds > 0) eng_tmp+= e_un; + if (numbonds > 0) eng_tmp+= e_un; pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, i, system->n, 1, eng_tmp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); } /* forces */ workspace->CdDelta[i] += CEover3; // OvCoor - 2nd term - if(numbonds > 0) workspace->CdDelta[i] += CEunder3; // UnCoor - 1st term + if (numbonds > 0) workspace->CdDelta[i] += CEunder3; // UnCoor - 1st term for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { pbond = &(bonds->select.bond_list[pj]); diff --git a/src/USER-OMP/reaxc_nonbonded_omp.cpp b/src/USER-OMP/reaxc_nonbonded_omp.cpp index 301dbe8479..ce463c39ff 100644 --- a/src/USER-OMP/reaxc_nonbonded_omp.cpp +++ b/src/USER-OMP/reaxc_nonbonded_omp.cpp @@ -97,7 +97,7 @@ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, #pragma omp for schedule(guided) #endif for( i = 0; i < natoms; ++i ) { - if(system->my_atoms[i].type < 0) continue; + if (system->my_atoms[i].type < 0) continue; start_i = Start_Index(i, far_nbrs); end_i = End_Index(i, far_nbrs); orig_i = system->my_atoms[i].orig_id; @@ -108,8 +108,8 @@ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, orig_j = system->my_atoms[j].orig_id; flag = 0; - if(nbr_pj->d <= control->nonb_cut) { - if(j < natoms) flag = 1; + if (nbr_pj->d <= control->nonb_cut) { + if (j < natoms) flag = 1; else if (orig_i < orig_j) flag = 1; else if (orig_i == orig_j) { if (nbr_pj->dvec[2] > SMALL) flag = 1; @@ -145,7 +145,7 @@ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, dTap += workspace->Tap[1]/r_ij; /*vdWaals Calculations*/ - if(system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) { // shielding powr_vdW1 = pow(r_ij, p_vdW1); powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); @@ -174,7 +174,7 @@ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; } - if(system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) { // innner wall e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); total_EvdW += Tap * e_core; @@ -293,7 +293,7 @@ void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *system,control_params *contro #endif for (i = 0; i < natoms; ++i) { type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; start_i = Start_Index(i,far_nbrs); end_i = End_Index(i,far_nbrs); orig_i = system->my_atoms[i].orig_id; @@ -302,12 +302,12 @@ void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *system,control_params *contro nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); j = nbr_pj->nbr; type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; orig_j = system->my_atoms[j].orig_id; flag = 0; - if(nbr_pj->d <= control->nonb_cut) { - if(j < natoms) flag = 1; + if (nbr_pj->d <= control->nonb_cut) { + if (j < natoms) flag = 1; else if (orig_i < orig_j) flag = 1; else if (orig_i == orig_j) { if (nbr_pj->dvec[2] > SMALL) flag = 1; diff --git a/src/USER-OMP/reaxc_torsion_angles_omp.cpp b/src/USER-OMP/reaxc_torsion_angles_omp.cpp index 2b9afae341..79fa9e0f47 100644 --- a/src/USER-OMP/reaxc_torsion_angles_omp.cpp +++ b/src/USER-OMP/reaxc_torsion_angles_omp.cpp @@ -202,7 +202,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, //tan_ijk_i = 1. / tan( theta_ijk ); if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) tan_ijk_i = cos_ijk / MIN_SINE; - else if( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) + else if ( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) tan_ijk_i = cos_ijk / -MIN_SINE; else tan_ijk_i = cos_ijk / sin_ijk; @@ -241,7 +241,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, //tan_jkl_i = 1. / tan( theta_jkl ); if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) tan_jkl_i = cos_jkl / MIN_SINE; - else if( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) + else if ( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) tan_jkl_i = cos_jkl / -MIN_SINE; else tan_jkl_i = cos_jkl /sin_jkl; diff --git a/src/USER-OMP/reaxc_valence_angles_omp.cpp b/src/USER-OMP/reaxc_valence_angles_omp.cpp index c42b97958f..8b6f1e7617 100644 --- a/src/USER-OMP/reaxc_valence_angles_omp.cpp +++ b/src/USER-OMP/reaxc_valence_angles_omp.cpp @@ -177,7 +177,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, pair_reax_ptr = static_cast(system->pair_ptr); class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); - // Run through a minimal for(jnum_intrs / nthreads; @@ -187,7 +187,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, for (j = 0; j < system->N; ++j) { type_j = system->my_atoms[j].type; _my_offset[j] = 0; - if(type_j < 0) continue; + if (type_j < 0) continue; start_j = Start_Index(j, bonds); end_j = End_Index(j, bonds); @@ -220,7 +220,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, ++my_offset; break; } - } // for(pk) + } // for (pk) /* and this is the second for loop mentioned above */ for (pk = pi+1; pk < end_j; ++pk) { @@ -233,14 +233,14 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, p_ijk->thb = k; ++my_offset; // add this to the list of 3-body interactions - } // for(pk) - } // if() + } // for (pk) + } // if () Set_End_Index(pi, my_offset, thb_intrs ); - } // for(pi) + } // for (pi) // Confirm that thb_intrs->num_intrs / nthreads is enough to hold all angles from a single atom - if(my_offset >= (tid+1)*per_thread) { + if (my_offset >= (tid+1)*per_thread) { char errmsg[512]; snprintf( errmsg, 512, "step%d-ran out of space on angle_list for atom %i:\n" " nthreads= %d, tid=%d, my_offset=%d, per_thread=%d\n" @@ -251,7 +251,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, // Number of angles owned by this atom _my_offset[j] = my_offset - tid * per_thread; - } // for(j) + } // for (j) // Wait for all threads to finish counting angles #if defined(_OPENMP) && !defined(__NVCC__) @@ -266,7 +266,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, int current_count = 0; int m = _my_offset[0]; _my_offset[0] = current_count; - for(j=1; jN; j++) { + for (j=1; jN; j++) { current_count+= m; m = _my_offset[j]; _my_offset[j] = current_count; @@ -286,10 +286,10 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, #endif for (j = 0; j < system->N; ++j) { // Ray: the first one with system->N type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; // Skip if no angles for this atom - if(_my_offset[j] == _my_offset[j+1]) continue; + if (_my_offset[j] == _my_offset[j+1]) continue; start_j = Start_Index(j, bonds); end_j = End_Index(j, bonds); @@ -373,7 +373,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, ++num_thb_intrs; break; } - } // for(pk) + } // for (pk) /* and this is the second for loop mentioned above */ @@ -587,15 +587,15 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, system->pair_ptr->v_tally3( i, j, k, fi_tmp, fk_tmp, delij, delkj); } - } // if(p_val1>0.001) - } // for(cnt) - } // if(j0) - } // for(pk) - } // if(BOA_ij>0) + } // if (p_val1>0.001) + } // for (cnt) + } // if (j0) + } // for (pk) + } // if (BOA_ij>0) Set_End_Index(pi, my_offset, thb_intrs ); - } // for(pi) - } // for(j) + } // for (pi) + } // for (j) } // end omp parallel data->my_en.e_ang = total_Eang; diff --git a/src/USER-PHONON/dynamical_matrix.cpp b/src/USER-PHONON/dynamical_matrix.cpp index b9c42b45d0..798b50fdf7 100644 --- a/src/USER-PHONON/dynamical_matrix.cpp +++ b/src/USER-PHONON/dynamical_matrix.cpp @@ -266,29 +266,29 @@ void DynamicalMatrix::calculateMatrix() update->nsteps = 0; int prog = 0; - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { local_idx = atom->map(i); if (gm[i-1] < 0) continue; - for (int alpha=0; alpha<3; alpha++){ + for (int alpha=0; alpha<3; alpha++) { displace_atom(local_idx, alpha, 1); update_force(); - for (bigint j=1; j<=natoms; j++){ + for (bigint j=1; j<=natoms; j++) { local_jdx = atom->map(j); if (local_idx >= 0 && local_jdx >= 0 && local_jdx < nlocal - && gm[j-1] >= 0){ - for (int beta=0; beta<3; beta++){ + && gm[j-1] >= 0) { + for (int beta=0; beta<3; beta++) { dynmat[alpha][gm[j-1]*3+beta] -= f[local_jdx][beta]; } } } displace_atom(local_idx,alpha,-2); update_force(); - for (bigint j=1; j<=natoms; j++){ + for (bigint j=1; j<=natoms; j++) { local_jdx = atom->map(j); if (local_idx >= 0 && local_jdx >= 0 && local_jdx < nlocal - && gm[j-1] >= 0){ - for (int beta=0; beta<3; beta++){ + && gm[j-1] >= 0) { + for (int beta=0; beta<3; beta++) { if (atom->rmass_flag == 1) imass = sqrt(m[local_idx] * m[local_jdx]); else @@ -369,7 +369,7 @@ void DynamicalMatrix::displace_atom(int local_idx, int direction, int magnitude) x[local_idx][direction] += del*magnitude; - while (sametag[j] >= 0){ + while (sametag[j] >= 0) { j = sametag[j]; x[j][direction] += del*magnitude; } @@ -524,7 +524,7 @@ void DynamicalMatrix::create_groupmap() bigint *temp_groupmap = new bigint[natoms]; //find number of local atoms in the group (final_gid) - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { local_idx = atom->map(i); if ((local_idx >= 0) && (local_idx < nlocal) && mask[local_idx] & groupbit) gid += 1; // gid at the end of loop is final_Gid @@ -534,21 +534,21 @@ void DynamicalMatrix::create_groupmap() gid = 0; //create a map between global atom id and group atom id for each proc - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { local_idx = atom->map(i); - if ((local_idx >= 0) && (local_idx < nlocal) && mask[local_idx] & groupbit){ + if ((local_idx >= 0) && (local_idx < nlocal) && mask[local_idx] & groupbit) { sub_groupmap[gid] = i; gid += 1; } } //populate arrays for Allgatherv - for (int i=0; inprocs; i++){ + for (int i=0; inprocs; i++) { recv[i] = 0; } recv[comm->me] = gid; MPI_Allreduce(recv,displs,comm->nprocs,MPI_INT,MPI_SUM,world); - for (int i=0; inprocs; i++){ + for (int i=0; inprocs; i++) { recv[i]=displs[i]; if (i>0) displs[i] = displs[i-1]+recv[i-1]; else displs[i] = 0; @@ -560,7 +560,7 @@ void DynamicalMatrix::create_groupmap() //populate member groupmap based on temp groupmap bigint j = 0; - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { // flag groupmap contents that are in temp_groupmap if (j < gcount && i == temp_groupmap[j]) groupmap[i-1] = j++; diff --git a/src/USER-PHONON/fix_phonon.cpp b/src/USER-PHONON/fix_phonon.cpp index a4915d6930..013b18948a 100644 --- a/src/USER-PHONON/fix_phonon.cpp +++ b/src/USER-PHONON/fix_phonon.cpp @@ -92,13 +92,13 @@ FixPhonon::FixPhonon(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) nasr = 20; // other command line options - while (iarg < narg){ - if (strcmp(arg[iarg],"sysdim") == 0){ + while (iarg < narg) { + if (strcmp(arg[iarg],"sysdim") == 0) { if (++iarg >= narg) error->all(FLERR,"Illegal fix phonon command: incomplete command line options."); sdim = utils::inumeric(FLERR, arg[iarg],false,lmp); if (sdim < 1) error->all(FLERR,"Illegal fix phonon command: sysdim should not be less than 1."); - } else if (strcmp(arg[iarg],"nasr") == 0){ + } else if (strcmp(arg[iarg],"nasr") == 0) { if (++iarg >= narg) error->all(FLERR,"Illegal fix phonon command: incomplete command line options."); nasr = utils::inumeric(FLERR, arg[iarg],false,lmp); @@ -139,7 +139,7 @@ FixPhonon::FixPhonon(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) // here the parallization is done on the x direction only nxlo = 0; int *nx_loc = new int [nprocs]; - for (int i = 0; i < nprocs; ++i){ + for (int i = 0; i < nprocs; ++i) { nx_loc[i] = nx / nprocs; if (i < nx%nprocs) ++nx_loc[i]; } @@ -182,7 +182,7 @@ FixPhonon::FixPhonon(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) else memory->create(Phi_all,1,1,"fix_phonon:Phi_all"); // output some information on the system to log file - if (me == 0){ + if (me == 0) { flog = fopen(logfile, "w"); if (flog == nullptr) { char str[MAXLINE]; @@ -205,7 +205,7 @@ FixPhonon::FixPhonon(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) fprintf(flog,"%d %d %d %d\n", nx, ny, nz, nucell); fprintf(flog,"# l1 l2 l3 k atom_id\n"); int ix, iy, iz, iu; - for (idx = 0; idx < ngroup; ++idx){ + for (idx = 0; idx < ngroup; ++idx) { itag = surf2tag[idx]; iu = idx%nucell; iz = (idx/nucell)%nz; @@ -341,8 +341,8 @@ void FixPhonon::end_of_step() // evaluate R(r) on local proc nfind = 0; - for (i = 0; i < nlocal; ++i){ - if (mask[i] & groupbit){ + for (i = 0; i < nlocal; ++i) { + if (mask[i] & groupbit) { itag = tag[i]; idx = tag2surf[itag]; @@ -361,8 +361,8 @@ void FixPhonon::end_of_step() for (i = 1; i < nprocs; ++i) displs[i] = displs[i-1] + recvcnts[i-1]; MPI_Gatherv(RIloc[0],nfind,MPI_DOUBLE,RIall[0],recvcnts,displs,MPI_DOUBLE,0,world); - if (me == 0){ - for (i = 0; i < ngroup; ++i){ + if (me == 0) { + for (i = 0; i < ngroup; ++i) { idx = static_cast(RIall[i][sysdim]); for (idim = 0; idim < sysdim; ++idim) Rsort[idx][idim] = RIall[i][idim]; } @@ -374,9 +374,9 @@ void FixPhonon::end_of_step() for (idim = 0; idim < fft_dim; ++idim) Rsum[idx][idim] += Rnow[idx][idim]; // FFT R(r) to get R(q) - for (idim = 0; idim < fft_dim; ++idim){ + for (idim = 0; idim < fft_dim; ++idim) { int m = 0; - for (idx = 0; idx < mynpt; ++idx){ + for (idx = 0; idx < mynpt; ++idx) { fft_data[m++] = static_cast(Rnow[idx][idim]); fft_data[m++] = static_cast(0.); } @@ -384,25 +384,25 @@ void FixPhonon::end_of_step() fft->compute(fft_data, fft_data, -1); m = 0; - for (idq = 0; idq < mynq; ++idq){ + for (idq = 0; idq < mynq; ++idq) { Rqnow[idq][idim] = std::complex(static_cast(fft_data[m]), static_cast(fft_data[m+1])); m += 2; } } // to get sum(R(q).R(q)*) - for (idq = 0; idq < mynq; ++idq){ + for (idq = 0; idq < mynq; ++idq) { ndim = 0; for (idim = 0; idim < fft_dim; ++idim) for (jdim = 0; jdim < fft_dim; ++jdim) Rqsum[idq][ndim++] += Rqnow[idq][idim] * std::conj(Rqnow[idq][jdim]); } // get basis info - if (fft_dim > sysdim){ + if (fft_dim > sysdim) { double dist2orig[3]; - for (idx = 0; idx < mynpt; ++idx){ + for (idx = 0; idx < mynpt; ++idx) { ndim = sysdim; - for (i = 1; i < nucell; ++i){ + for (i = 1; i < nucell; ++i) { for (idim = 0; idim < sysdim; ++idim) dist2orig[idim] = Rnow[idx][ndim++] - Rnow[idx][idim]; domain->minimum_image(dist2orig); for (idim = 0; idim < sysdim; ++idim) basis[i][idim] += dist2orig[idim]; @@ -477,9 +477,9 @@ void FixPhonon::getmass() type_all = new double[nucell]; for (int i = 0; i < nucell; ++i) mass_one[i] = type_one[i] = 0.; - if (rmass){ - for (int i = 0; i < nlocal; ++i){ - if (mask[i] & groupbit){ + if (rmass) { + for (int i = 0; i < nlocal; ++i) { + if (mask[i] & groupbit) { itag = tag[i]; idx = tag2surf[itag]; int iu = idx%nucell; @@ -488,8 +488,8 @@ void FixPhonon::getmass() } } } else { - for (int i = 0; i < nlocal; ++i){ - if (mask[i] & groupbit){ + for (int i = 0; i < nlocal; ++i) { + if (mask[i] & groupbit) { itag = tag[i]; idx = tag2surf[itag]; int iu = idx%nucell; @@ -506,7 +506,7 @@ void FixPhonon::getmass() basetype = new int[nucell]; double inv_total = 1./double(ntotal); - for (int i = 0; i < nucell; ++i){ + for (int i = 0; i < nucell; ++i) { mass_all[i] *= inv_total; M_inv_sqrt[i] = sqrt(1./mass_all[i]); @@ -528,7 +528,7 @@ void FixPhonon::readmap() int info = 0; // auto-generate mapfile for "cluster" (gamma only system) - if (strcmp(mapfile, "GAMMA") == 0){ + if (strcmp(mapfile, "GAMMA") == 0) { nx = ny = nz = ntotal = 1; nucell = ngroup; @@ -538,7 +538,7 @@ void FixPhonon::readmap() // get atom IDs on local proc int nfind = 0; - for (int i = 0; i < atom->nlocal; ++i){ + for (int i = 0; i < atom->nlocal; ++i) { if (atom->mask[i] & groupbit) tag_loc[nfind++] = atom->tag[i]; } @@ -549,7 +549,7 @@ void FixPhonon::readmap() for (int i = 1; i < nprocs; ++i) displs[i] = displs[i-1] + recvcnts[i-1]; MPI_Allgatherv(tag_loc,nfind,MPI_LMP_TAGINT,tag_all,recvcnts,displs,MPI_LMP_TAGINT,world); - for (int i = 0; i < ngroup; ++i){ + for (int i = 0; i < ngroup; ++i) { itag = tag_all[i]; tag2surf[itag] = i; surf2tag[i] = itag; @@ -563,7 +563,7 @@ void FixPhonon::readmap() // read from map file for others char line[MAXLINE]; FILE *fp = fopen(mapfile, "r"); - if (fp == nullptr){ + if (fp == nullptr) { sprintf(line,"Cannot open input map file %s", mapfile); error->all(FLERR,line); } @@ -584,7 +584,7 @@ void FixPhonon::readmap() int ix, iy, iz, iu; // the remaining lines carry the mapping info - for (int i = 0; i < ngroup; ++i){ + for (int i = 0; i < ngroup; ++i) { if (fgets(line,MAXLINE,fp) == nullptr) {info = 1; break;} ix = utils::inumeric(FLERR, strtok(line, " \n\t\r\f"),false,lmp); iy = utils::inumeric(FLERR, strtok(nullptr, " \n\t\r\f"),false,lmp); @@ -614,7 +614,7 @@ void FixPhonon::readmap() int nlocal = atom->nlocal; for (int i = 0; i < nlocal; ++i) { - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { itag = tag[i]; idx = tag2surf[itag]; if (itag != surf2tag[idx]) @@ -643,9 +643,9 @@ void FixPhonon::postprocess( ) for (idim = 0; idim < fft_dim; ++idim) Rnow[idx][idim] = Rsum[idx][idim] * inv_neval; // to get q - for (idim = 0; idim < fft_dim; ++idim){ + for (idim = 0; idim < fft_dim; ++idim) { int m = 0; - for (idx = 0; idx < mynpt; ++idx){ + for (idx = 0; idx < mynpt; ++idx) { fft_data[m++] = static_cast(Rnow[idx][idim]); fft_data[m++] = static_cast(0.); } @@ -653,14 +653,14 @@ void FixPhonon::postprocess( ) fft->compute(fft_data,fft_data,-1); m = 0; - for (idq = 0; idq < mynq; ++idq){ + for (idq = 0; idq < mynq; ++idq) { Rqnow[idq][idim] = std::complex(static_cast(fft_data[m]), static_cast(fft_data[m+1])); m += 2; } } // to get G(q) = - q.q - for (idq = 0; idq < mynq; ++idq){ + for (idq = 0; idq < mynq; ++idq) { ndim = 0; for (idim = 0; idim < fft_dim; ++idim) for (jdim = 0; jdim < fft_dim; ++jdim) Phi_q[idq][ndim++] -= Rqnow[idq][idim] * std::conj(Rqnow[idq][jdim]); @@ -672,13 +672,13 @@ void FixPhonon::postprocess( ) double TempFac = inv_neval * inv_nTemp; double NormFac = TempFac * double(ntotal); - for (idim = 0; idim < sysdim; ++idim){ + for (idim = 0; idim < sysdim; ++idim) { kbtsqrt[idim] = sqrt(TempSum[idim] * NormFac); TempAve += TempSum[idim] * TempFac; } TempAve /= sysdim*boltz; - for (idq = 0; idq < mynq; ++idq){ + for (idq = 0; idq < mynq; ++idq) { GaussJordan(fft_dim, Phi_q[idq]); ndim =0; for (idim = 0; idim < fft_dim; ++idim) @@ -695,7 +695,7 @@ void FixPhonon::postprocess( ) double *basis_root = new double[fft_dim]; if (fft_dim > sysdim) MPI_Reduce(&basis[1][0], &basis_root[sysdim], fft_dim-sysdim, MPI_DOUBLE, MPI_SUM, 0, world); - if (me == 0){ // output dynamic matrix by root + if (me == 0) { // output dynamic matrix by root // get basis info for (idim = 0; idim < sysdim; ++idim) basis_root[idim] = 0.; @@ -748,18 +748,18 @@ void FixPhonon::postprocess( ) EnforceASR(); // to get D = 1/M x Phi - for (idq = 0; idq < ntotal; ++idq){ + for (idq = 0; idq < ntotal; ++idq) { ndim =0; for (idim = 0; idim < fft_dim; ++idim) for (jdim = 0; jdim < fft_dim; ++jdim) Phi_all[idq][ndim++] *= M_inv_sqrt[idim/sysdim]*M_inv_sqrt[jdim/sysdim]; } idq =0; - for (int ix = 0; ix < nx; ++ix){ + for (int ix = 0; ix < nx; ++ix) { double qx = double(ix)/double(nx); - for (int iy = 0; iy < ny; ++iy){ + for (int iy = 0; iy < ny; ++iy) { double qy = double(iy)/double(ny); - for (int iz = 0; iz < nz; ++iz){ + for (int iz = 0; iz < nz; ++iz) { double qz = double(iz)/double(nz); fprintf(flog,"%lg %lg %lg", qx, qy, qz); for (idim = 0; idim < fft_dim2; ++idim) @@ -794,15 +794,15 @@ void FixPhonon::GaussJordan(int n, std::complex *Mat) ipiv = new int[n]; for (i = 0; i < n; ++i) ipiv[i] = 0; - for (i = 0; i < n; ++i){ + for (i = 0; i < n; ++i) { big = 0.; - for (j = 0; j < n; ++j){ - if (ipiv[j] != 1){ - for (k = 0; k < n; ++k){ - if (ipiv[k] == 0){ + for (j = 0; j < n; ++j) { + if (ipiv[j] != 1) { + for (k = 0; k < n; ++k) { + if (ipiv[k] == 0) { idr = j*n+k; nmjk = norm(Mat[idr]); - if (nmjk >= big){ + if (nmjk >= big) { big = nmjk; irow = j; icol = k; @@ -812,8 +812,8 @@ void FixPhonon::GaussJordan(int n, std::complex *Mat) } } ipiv[icol] += 1; - if (irow != icol){ - for (l = 0; l < n; ++l){ + if (irow != icol) { + for (l = 0; l < n; ++l) { idr = irow*n+l; idc = icol*n+l; dum = Mat[idr]; @@ -830,8 +830,8 @@ void FixPhonon::GaussJordan(int n, std::complex *Mat) Mat[idr] = std::complex(1.,0.); idr = icol*n; for (l = 0; l < n; ++l) Mat[idr+l] *= pivinv; - for (ll = 0; ll < n; ++ll){ - if (ll != icol){ + for (ll = 0; ll < n; ++ll) { + if (ll != icol) { idc = ll*n + icol; dum = Mat[idc]; Mat[idc] = 0.; @@ -841,11 +841,11 @@ void FixPhonon::GaussJordan(int n, std::complex *Mat) } } - for (l = n-1; l >= 0; --l){ + for (l = n-1; l >= 0; --l) { int rl = indxr[l]; int cl = indxc[l]; - if (rl != cl){ - for (k = 0; k < n; ++k){ + if (rl != cl) { + for (k = 0; k < n; ++k) { idr = k*n + rl; idc = k*n + cl; dum = Mat[idr]; @@ -867,18 +867,18 @@ void FixPhonon::EnforceASR() { if (nasr < 1) return; - for (int iit = 0; iit < nasr; ++iit){ + for (int iit = 0; iit < nasr; ++iit) { // simple ASR; the resultant matrix might not be symmetric for (int a = 0; a < sysdim; ++a) - for (int b = 0; b < sysdim; ++b){ - for (int k = 0; k < nucell; ++k){ + for (int b = 0; b < sysdim; ++b) { + for (int k = 0; k < nucell; ++k) { double sum = 0.; - for (int kp = 0; kp < nucell; ++kp){ + for (int kp = 0; kp < nucell; ++kp) { int idx = (k*sysdim+a)*fft_dim + kp*sysdim + b; sum += std::real(Phi_all[0][idx]); } sum /= double(nucell); - for (int kp = 0; kp < nucell; ++kp){ + for (int kp = 0; kp < nucell; ++kp) { int idx = (k*sysdim+a)*fft_dim + kp*sysdim + b; Phi_all[0][idx] -= sum; } @@ -887,10 +887,10 @@ void FixPhonon::EnforceASR() // symmetrize for (int k = 0; k < nucell; ++k) - for (int kp = k; kp < nucell; ++kp){ + for (int kp = k; kp < nucell; ++kp) { double csum = 0.; for (int a = 0; a < sysdim; ++a) - for (int b = 0; b < sysdim; ++b){ + for (int b = 0; b < sysdim; ++b) { int idx = (k*sysdim+a)*fft_dim + kp*sysdim + b; int jdx = (kp*sysdim+b)*fft_dim + k*sysdim + a; csum = (std::real(Phi_all[0][idx])+std::real(Phi_all[0][jdx]))*0.5; @@ -902,15 +902,15 @@ void FixPhonon::EnforceASR() // symmetric ASR for (int a = 0; a < sysdim; ++a) - for (int b = 0; b < sysdim; ++b){ - for (int k = 0; k < nucell; ++k){ + for (int b = 0; b < sysdim; ++b) { + for (int k = 0; k < nucell; ++k) { double sum = 0.; - for (int kp = 0; kp < nucell; ++kp){ + for (int kp = 0; kp < nucell; ++kp) { int idx = (k*sysdim+a)*fft_dim + kp*sysdim + b; sum += std::real(Phi_all[0][idx]); } sum /= double(nucell-k); - for (int kp = k; kp < nucell; ++kp){ + for (int kp = k; kp < nucell; ++kp) { int idx = (k*sysdim+a)*fft_dim + kp*sysdim + b; int jdx = (kp*sysdim+b)*fft_dim + k*sysdim + a; Phi_all[0][idx] -= sum; diff --git a/src/USER-PHONON/third_order.cpp b/src/USER-PHONON/third_order.cpp index 32ced74cad..875490d643 100644 --- a/src/USER-PHONON/third_order.cpp +++ b/src/USER-PHONON/third_order.cpp @@ -254,18 +254,18 @@ void ThirdOrder::calculateMatrix() update->nsteps = 0; int prog = 0; - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { local_idx = atom->map(i); - for (int alpha=0; alpha<3; alpha++){ - for (bigint j=1; j<=natoms; j++){ + for (int alpha=0; alpha<3; alpha++) { + for (bigint j=1; j<=natoms; j++) { local_jdx = atom->map(j); - for (int beta=0; beta<3; beta++){ + for (int beta=0; beta<3; beta++) { displace_atom(local_idx, alpha, 1); displace_atom(local_jdx, beta, 1); update_force(); - for (bigint k=1; k<=natoms; k++){ + for (bigint k=1; k<=natoms; k++) { local_kdx = atom->map(k); - for (int gamma=0; gamma<3; gamma++){ + for (int gamma=0; gamma<3; gamma++) { if (local_idx >= 0 && local_jdx >= 0 && local_kdx >= 0 && gm[i-1] >= 0 && gm[j-1] >= 0 && gm[k-1] >= 0 && local_kdx < nlocal) { @@ -275,9 +275,9 @@ void ThirdOrder::calculateMatrix() } displace_atom(local_jdx, beta, -2); update_force(); - for (bigint k=1; k<=natoms; k++){ + for (bigint k=1; k<=natoms; k++) { local_kdx = atom->map(k); - for (int gamma=0; gamma<3; gamma++){ + for (int gamma=0; gamma<3; gamma++) { if (local_idx >= 0 && local_jdx >= 0 && local_kdx >= 0 && gm[i-1] >= 0 && gm[j-1] >= 0 && gm[k-1] >= 0 && local_kdx < nlocal) { @@ -289,9 +289,9 @@ void ThirdOrder::calculateMatrix() displace_atom(local_idx,alpha,-2); displace_atom(local_jdx, beta, 1); update_force(); - for (bigint k=1; k<=natoms; k++){ + for (bigint k=1; k<=natoms; k++) { local_kdx = atom->map(k); - for (int gamma=0; gamma<3; gamma++){ + for (int gamma=0; gamma<3; gamma++) { if (local_idx >= 0 && local_jdx >= 0 && local_kdx >= 0 && gm[i-1] >= 0 && gm[j-1] >= 0 && gm[k-1] >= 0 && local_kdx < nlocal) { @@ -301,9 +301,9 @@ void ThirdOrder::calculateMatrix() } displace_atom(local_jdx, beta, -2); update_force(); - for (bigint k=1; k<=natoms; k++){ + for (bigint k=1; k<=natoms; k++) { local_kdx = atom->map(k); - for (int gamma=0; gamma<3; gamma++){ + for (int gamma=0; gamma<3; gamma++) { if (local_idx >= 0 && local_jdx >= 0 && local_kdx >= 0 && gm[i-1] >= 0 && gm[j-1] >= 0 && gm[k-1] >= 0 && local_kdx < nlocal) { @@ -315,7 +315,7 @@ void ThirdOrder::calculateMatrix() displace_atom(local_jdx, beta, 1); displace_atom(local_idx, alpha, 1); MPI_Reduce(dynmat,fdynmat,3*dynlen,MPI_DOUBLE,MPI_SUM,0,world); - if (me == 0){ + if (me == 0) { writeMatrix(fdynmat, gm[i-1], alpha, gm[j-1], beta); } memset(&dynmat[0],0,dynlen*sizeof(double)); @@ -351,7 +351,7 @@ void ThirdOrder::writeMatrix(double *dynmat, bigint i, int a, bigint j, int b) double norm; if (!binaryflag && fp) { clearerr(fp); - for (int k = 0; k < gcount; k++){ + for (int k = 0; k < gcount; k++) { norm = square(dynmat[k*3])+ square(dynmat[k*3+1])+ square(dynmat[k*3+2]); @@ -364,7 +364,7 @@ void ThirdOrder::writeMatrix(double *dynmat, bigint i, int a, bigint j, int b) dynmat[k*3+1] * conversion, dynmat[k*3+2] * conversion); } - } else if (binaryflag && fp){ + } else if (binaryflag && fp) { clearerr(fp); fwrite(&dynmat[0], sizeof(double), dynlen, fp); } @@ -386,7 +386,7 @@ void ThirdOrder::displace_atom(int local_idx, int direction, int magnitude) x[local_idx][direction] += del*magnitude; - while (sametag[j] >= 0){ + while (sametag[j] >= 0) { j = sametag[j]; x[j][direction] += del*magnitude; } @@ -518,7 +518,7 @@ void ThirdOrder::create_groupmap() bigint *temp_groupmap = new bigint[natoms]; //find number of local atoms in the group (final_gid) - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { local_idx = atom->map(i); if ((local_idx >= 0) && (local_idx < nlocal) && mask[local_idx] & groupbit) gid += 1; // gid at the end of loop is final_Gid @@ -528,22 +528,22 @@ void ThirdOrder::create_groupmap() gid = 0; //create a map between global atom id and group atom id for each proc - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { local_idx = atom->map(i); if ((local_idx >= 0) && (local_idx < nlocal) - && (mask[local_idx] & groupbit)){ + && (mask[local_idx] & groupbit)) { sub_groupmap[gid] = i; gid += 1; } } //populate arrays for Allgatherv - for (int i=0; inprocs; i++){ + for (int i=0; inprocs; i++) { recv[i] = 0; } recv[comm->me] = gid; MPI_Allreduce(recv,displs,comm->nprocs,MPI_INT,MPI_SUM,world); - for (int i=0; inprocs; i++){ + for (int i=0; inprocs; i++) { recv[i]=displs[i]; if (i>0) displs[i] = displs[i-1]+recv[i-1]; else displs[i] = 0; @@ -556,7 +556,7 @@ void ThirdOrder::create_groupmap() //populate member groupmap based on temp groupmap bigint j = 0; - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { // flag groupmap contents that are in temp_groupmap if (j < gcount && i == temp_groupmap[j]) groupmap[i-1] = j++; diff --git a/src/USER-PLUMED/fix_plumed.cpp b/src/USER-PLUMED/fix_plumed.cpp index 1fc19a7724..e2246adcd9 100644 --- a/src/USER-PLUMED/fix_plumed.cpp +++ b/src/USER-PLUMED/fix_plumed.cpp @@ -118,7 +118,7 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) : // LAMMPS units wrt kj/mol - nm - ps // Set up units - if(strcmp(update->unit_style,"lj") == 0) { + if (strcmp(update->unit_style,"lj") == 0) { // LAMMPS units lj p->cmd("setNaturalUnits"); } else { @@ -486,7 +486,7 @@ void FixPlumed::post_force(int /* vflag */) // do the real calculation: p->cmd("performCalc"); - if(plumedStopCondition) timer->force_timeout(); + if (plumedStopCondition) timer->force_timeout(); // retransform virial to lammps representation and assign it to this // fix's virial. If the energy is biased, Plumed is giving back the full diff --git a/src/USER-PTM/ptm_voronoi_cell.cpp b/src/USER-PTM/ptm_voronoi_cell.cpp index 60ef4cf87b..5b29706b82 100644 --- a/src/USER-PTM/ptm_voronoi_cell.cpp +++ b/src/USER-PTM/ptm_voronoi_cell.cpp @@ -76,13 +76,13 @@ voronoicell_base::voronoicell_base() : ds2(new int[current_delete2_size]), stacke2(ds2+current_delete_size), current_marginal(init_marginal), marg(new int[current_marginal]) { int i; - for(i=0;i<3;i++) { + for (i=0;i<3;i++) { mem[i]=init_n_vertices;mec[i]=0; mep[i]=new int[init_n_vertices*((i<<1)+1)]; } mem[3]=init_3_vertices;mec[3]=0; mep[3]=new int[init_3_vertices*7]; - for(i=4;i=0;i--) if(mem[i]>0) delete [] mep[i]; + for (int i=current_vertex_order-1;i>=0;i--) if (mem[i]>0) delete [] mep[i]; delete [] marg; delete [] ds2;delete [] ds; delete [] mep;delete [] mec; @@ -104,7 +104,7 @@ voronoicell_base::~voronoicell_base() { template void voronoicell_base::check_memory_for_copy(vc_class &vc,voronoicell_base* vb) { while(current_vertex_ordercurrent_vertex_order) add_memory_vorder(vc); - for(int i=0;imec[i]) add_memory(vc,i,ds2); + for (int i=0;imec[i]) add_memory(vc,i,ds2); while(current_verticesp) add_memory_vertices(vc); } @@ -122,7 +122,7 @@ void voronoicell_base::check_memory_for_copy(vc_class &vc,voronoicell_base* vb) template void voronoicell_base::add_memory(vc_class &vc,int i,int *stackp2) { int s=(i<<1)+1; - if(mem[i]==0) { + if (mem[i]==0) { vc.n_allocate(i,init_n_vertices); mep[i]=new int[init_n_vertices*s]; mem[i]=init_n_vertices; @@ -132,7 +132,7 @@ void voronoicell_base::add_memory(vc_class &vc,int i,int *stackp2) { } else { int j=0,k,*l; mem[i]<<=1; - if(mem[i]>max_n_vertices) voro_fatal_error("Point memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); + if (mem[i]>max_n_vertices) voro_fatal_error("Point memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); #if VOROPP_VERBOSE >=2 fprintf(stderr,"Order %d vertex memory scaled up to %d\n",i,mem[i]); #endif @@ -141,25 +141,25 @@ void voronoicell_base::add_memory(vc_class &vc,int i,int *stackp2) { vc.n_allocate_aux1(i); while(j=0) { + if (k>=0) { ed[k]=l+j; vc.n_set_to_aux1_offset(k,m); } else { int *dsp; - for(dsp=ds2;dsp=3 fputs("Relocated dangling pointer",stderr); #endif } - for(k=0;kmax_vertices) voro_fatal_error("Vertex memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); + if (i>max_vertices) voro_fatal_error("Vertex memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); #if VOROPP_VERBOSE >=2 fprintf(stderr,"Vertex memory scaled up to %d\n",i); #endif double *ppts; pp=new int*[i]; - for(j=0;j void voronoicell_base::add_memory_vorder(vc_class &vc) { int i=(current_vertex_order<<1),j,*p1,**p2; - if(i>max_vertex_order) voro_fatal_error("Vertex order memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); + if (i>max_vertex_order) voro_fatal_error("Vertex order memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); #if VOROPP_VERBOSE >=2 fprintf(stderr,"Vertex order memory scaled up to %d\n",i); #endif p1=new int[i]; - for(j=0;jmax_delete_size) voro_fatal_error("Delete stack 1 memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); + if (current_delete_size>max_delete_size) voro_fatal_error("Delete stack 1 memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); #if VOROPP_VERBOSE >=2 fprintf(stderr,"Delete stack 1 memory scaled up to %d\n",current_delete_size); #endif @@ -244,7 +244,7 @@ void voronoicell_base::add_memory_ds(int *&stackp) { * routine causes a fatal error. */ void voronoicell_base::add_memory_ds2(int *&stackp2) { current_delete2_size<<=1; - if(current_delete2_size>max_delete2_size) voro_fatal_error("Delete stack 2 memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); + if (current_delete2_size>max_delete2_size) voro_fatal_error("Delete stack 2 memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); #if VOROPP_VERBOSE >=2 fprintf(stderr,"Delete stack 2 memory scaled up to %d\n",current_delete2_size); #endif @@ -259,7 +259,7 @@ void voronoicell_base::add_memory_ds2(int *&stackp2) { * \param[in] (ymin,ymax) the minimum and maximum y coordinates. * \param[in] (zmin,zmax) the minimum and maximum z coordinates. */ void voronoicell_base::init_base(double xmin,double xmax,double ymin,double ymax,double zmin,double zmax) { - for(int i=0;i inline void voronoicell_base::add_to_stack(vc_class &vc,int lp,int *&stackp2) { (void)vc; - for(int *k(ds2);k=p) throw true; + if (++count>=p) throw true; u=l;up=lp; - for(us=0;us=p) throw true; + if (++count>=p) throw true; u=q;up=qp; - for(us=0;us=current_vertex_order) add_memory_vorder(vc); - if(mec[nu[p]]==mem[nu[p]]) add_memory(vc,nu[p],stackp2); + if (mec[nu[p]]==mem[nu[p]]) add_memory(vc,nu[p],stackp2); vc.n_set_pointer(p,nu[p]); ed[p]=mep[nu[p]]+((nu[p]<<1)+1)*mec[nu[p]]++; ed[p][nu[p]<<1]=p; @@ -609,7 +609,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // If i reaches zero, then we have a point in // the plane all of whose edges are outside // the cutting space, so we just exit - if(i==0) return true; + if (i==0) return true; lp=ed[up][i]; lw=m_test(lp,l); } @@ -631,7 +631,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // the remaining one is on the plane. For that case we // have to reduce the edge count by one to prevent // doubling up. - if(i==j&&qw==0) { + if (i==j&&qw==0) { double_edge=true; nu[p]=nu[up]; } else { @@ -642,7 +642,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // already k=1; while(nu[p]>=current_vertex_order) add_memory_vorder(vc); - if(mec[nu[p]]==mem[nu[p]]) add_memory(vc,nu[p],stackp2); + if (mec[nu[p]]==mem[nu[p]]) add_memory(vc,nu[p],stackp2); // Copy the edges of the original vertex into the new // one. Delete the edges of the original vertex, and @@ -676,13 +676,13 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq } qs=j; } - if(!double_edge) { + if (!double_edge) { vc.n_copy(p,k,up,qs); vc.n_set(p,0,p_id); } else vc.n_copy(p,0,up,qs); // Add this point to the auxiliary delete stack - if(stackp2==stacke2) add_memory_ds2(stackp2); + if (stackp2==stacke2) add_memory_ds2(stackp2); *(stackp2++)=up; // Look at the edges on either side of the group that was @@ -702,7 +702,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // points lp and up. Create a new vertex between them which // lies on the cutting plane. Since u and l differ by at least // the tolerance, this division should never screw up. - if(stackp==stacke) add_memory_ds(stackp); + if (stackp==stacke) add_memory_ds(stackp); *(stackp++)=up; r=u/(u-l);l=1-r; pts[3*p]=pts[3*lp]*r+pts[3*up]*l; @@ -712,7 +712,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // This point will always have three edges. Connect one of them // to lp. nu[p]=3; - if(mec[3]==mem[3]) add_memory(vc,3,stackp2); + if (mec[3]==mem[3]) add_memory(vc,3,stackp2); vc.n_set_pointer(p,3); vc.n_set(p,0,p_id); vc.n_copy(p,1,up,us); @@ -742,30 +742,30 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq lp=ed[qp][qs]; lw=m_test(lp,l); - if(lw==1) { + if (lw==1) { // The point is still in the cutting space. Just add it // to the delete stack and keep moving. qs=cycle_up(ed[qp][nu[qp]+qs],lp); qp=lp; q=l; - if(stackp==stacke) add_memory_ds(stackp); + if (stackp==stacke) add_memory_ds(stackp); *(stackp++)=qp; - } else if(lw==-1) { + } else if (lw==-1) { // The point is outside of the cutting space, so we've // found an intersected edge. Introduce a regular point // at the point of intersection. Connect it to the // point we just tested. Also connect it to the previous // new point in the facet we're constructing. - if(p==current_vertices) add_memory_vertices(vc); + if (p==current_vertices) add_memory_vertices(vc); r=q/(q-l);l=1-r; pts[3*p]=pts[3*lp]*r+pts[3*qp]*l; pts[3*p+1]=pts[3*lp+1]*r+pts[3*qp+1]*l; pts[3*p+2]=pts[3*lp+2]*r+pts[3*qp+2]*l; nu[p]=3; - if(mec[3]==mem[3]) add_memory(vc,3,stackp2); + if (mec[3]==mem[3]) add_memory(vc,3,stackp2); ls=ed[qp][qs+nu[qp]]; vc.n_set_pointer(p,3); vc.n_set(p,0,p_id); @@ -791,7 +791,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // We're going to introduce a new point right here, but // first we need to figure out the number of edges it // has. - if(p==current_vertices) add_memory_vertices(vc); + if (p==current_vertices) add_memory_vertices(vc); // If the previous vertex detected a double edge, our // new vertex will have one less edge. @@ -816,15 +816,15 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // need to figure out whether we're in a case where we // might be creating a duplicate edge. j=-ed[qp][nu[qp]<<1]; - if(qp==up&&qs==us) { + if (qp==up&&qs==us) { // If we're heading into the final part of the // new facet, then we never worry about the // duplicate edge calculation. new_double_edge=false; - if(j>0) k+=nu[j]; + if (j>0) k+=nu[j]; } else { - if(j>0) { + if (j>0) { // This vertex was visited before, so // count those vertices to the ones we @@ -836,16 +836,16 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // going to move to next is also a // marginal point, so test for that // first. - if(lw==0) { + if (lw==0) { // Now see whether this marginal point // has been visited before. i=-ed[lp][nu[lp]<<1]; - if(i>0) { + if (i>0) { // Now see if the last edge of that other // marginal point actually ends up here. - if(ed[i][nu[i]-1]==j) { + if (ed[i][nu[i]-1]==j) { new_double_edge=true; k-=1; } else new_double_edge=false; @@ -857,7 +857,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // case when that's the way into the end // of the facet, because that way always creates // an edge. - if(j==rp&&lp==up&&ed[qp][nu[qp]+qs]==us) { + if (j==rp&&lp==up&&ed[qp][nu[qp]+qs]==us) { new_double_edge=true; k-=1; } else new_double_edge=false; @@ -868,7 +868,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // The vertex hasn't been visited // before, but let's see if it's // marginal - if(lw==0) { + if (lw==0) { // If it is, we need to check // for the case that it's a @@ -876,7 +876,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // heading right back to where // we came from i=-ed[lp][nu[lp]<<1]; - if(i==cp) { + if (i==cp) { new_double_edge=true; k-=1; } else new_double_edge=false; @@ -888,16 +888,16 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // we are forming. Add memory for it if it doesn't exist // already. while(k>=current_vertex_order) add_memory_vorder(vc); - if(mec[k]==mem[k]) add_memory(vc,k,stackp2); + if (mec[k]==mem[k]) add_memory(vc,k,stackp2); // Now create a new vertex with order k, or augment // the existing one - if(j>0) { + if (j>0) { // If we're augmenting a vertex but we don't // actually need any more edges, just skip this // routine to avoid memory confusion - if(nu[j]!=k) { + if (nu[j]!=k) { // Allocate memory and copy the edges // of the previous instance into it vc.n_set_aux1(k); @@ -915,8 +915,8 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // fewer vertices from the memory // structure edd=mep[nu[j]]+((nu[j]<<1)+1)*--mec[nu[j]]; - if(edd!=ed[j]) { - for(lw=0;lw<=(nu[j]<<1);lw++) ed[j][lw]=edd[lw]; + if (edd!=ed[j]) { + for (lw=0;lw<=(nu[j]<<1);lw++) ed[j][lw]=edd[lw]; vc.n_set_aux2_copy(j,nu[j]); vc.n_copy_pointer(edd[nu[j]<<1],j); ed[edd[nu[j]<<1]]=ed[j]; @@ -930,7 +930,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq vc.n_set_pointer(p,k); ed[p]=mep[k]+((k<<1)+1)*mec[k]++; ed[p][k<<1]=p; - if(stackp2==stacke2) add_memory_ds2(stackp2); + if (stackp2==stacke2) add_memory_ds2(stackp2); *(stackp2++)=qp; pts[3*p]=pts[3*qp]; pts[3*p+1]=pts[3*qp+1]; @@ -944,7 +944,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // Unless the previous case was a double edge, connect // the first available edge of the new vertex to the // last one in the facet - if(!double_edge) { + if (!double_edge) { ed[j][i]=cp; ed[j][nu[j]+i]=cs; vc.n_set(j,i,p_id); @@ -988,7 +988,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq dsp=ds; while(dsp0) voro_fatal_error("Zero order vertex formed",VOROPP_INTERNAL_ERROR); + if (*mec>0) voro_fatal_error("Zero order vertex formed",VOROPP_INTERNAL_ERROR); // Collapse any order 2 vertices and exit return collapse_order2(vc); @@ -1080,14 +1080,14 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq * was successful. */ template inline bool voronoicell_base::collapse_order2(vc_class &vc) { - if(!collapse_order1(vc)) return false; + if (!collapse_order1(vc)) return false; int a,b,i,j,k,l; while(mec[2]>0) { // Pick a order 2 vertex and read in its edges i=--mec[2]; j=mep[2][5*i];k=mep[2][5*i+1]; - if(j==k) { + if (j==k) { #if VOROPP_VERBOSE >=1 fputs("Order two vertex joins itself",stderr); #endif @@ -1095,33 +1095,33 @@ inline bool voronoicell_base::collapse_order2(vc_class &vc) { } // Scan the edges of j to see if joins k - for(l=0;l=1 - if(i<1) { + if (i<1) { fputs("Zero order vertex formed\n",stderr); return false; } #endif - if(mec[i]==mem[i]) add_memory(vc,i,ds2); + if (mec[i]==mem[i]) add_memory(vc,i,ds2); vc.n_set_aux1(i); - for(l=0;l &v) { v.clear(); int i,j,k,l,m,n; double ux,uy,uz,vx,vy,vz,wx,wy,wz; - for(i=1;i=0) { + if (k>=0) { area=0; ed[i][j]=-1-k; l=cycle_up(ed[i][nu[i]+j],k); @@ -1261,8 +1261,8 @@ void voronoicell_base::face_areas(std::vector &v) { * internal error if it encounters a positive edge. */ inline void voronoicell_base::reset_edges() { int i,j; - for(i=0;i=0) voro_fatal_error("Edge reset routine found a previously untested edge",VOROPP_INTERNAL_ERROR); + for (i=0;i=0) voro_fatal_error("Edge reset routine found a previously untested edge",VOROPP_INTERNAL_ERROR); ed[i][j]=-1-ed[i][j]; } } @@ -1282,9 +1282,9 @@ inline int voronoicell_base::m_test(int n,double &ans) { ans=*(pp++)*px; ans+=*(pp++)*py; ans+=*pp*pz-prsq; - if(ans<-tolerance2) { + if (ans<-tolerance2) { return -1; - } else if(ans>tolerance2) { + } else if (ans>tolerance2) { return 1; } return check_marginal(n,ans); @@ -1304,16 +1304,16 @@ inline int voronoicell_base::m_test(int n,double &ans) { * plane, or 0 if the point is within the plane. */ int voronoicell_base::check_marginal(int n,double &ans) { int i; - for(i=0;imax_marginal) + if (current_marginal>max_marginal) voro_fatal_error("Marginal case buffer allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); #if VOROPP_VERBOSE >=2 fprintf(stderr,"Marginal cases buffer scaled up to %d\n",i); #endif int *pmarg=new int[current_marginal]; - for(int j=0;j=0) { + if (k>=0) { ed[i][j]=-1-k; q=ne[i][j]; l=cycle_up(ed[i][nu[i]+j],k); do { m=ed[k][l]; ed[k][l]=-1-m; - if(ne[k][l]!=q) fprintf(stderr,"Facet error at (%d,%d)=%d, started from (%d,%d)=%d\n",k,l,ne[k][l],i,j,q); + if (ne[k][l]!=q) fprintf(stderr,"Facet error at (%d,%d)=%d, started from (%d,%d)=%d\n",k,l,ne[k][l],i,j,q); l=cycle_up(ed[k][nu[k]+l],m); k=m; } while (k!=i); @@ -1371,15 +1371,15 @@ voronoicell_neighbor::voronoicell_neighbor() { int i; mne=new int*[current_vertex_order]; ne=new int*[current_vertices]; - for(i=0;i<3;i++) mne[i]=new int[init_n_vertices*i]; + for (i=0;i<3;i++) mne[i]=new int[init_n_vertices*i]; mne[3]=new int[init_3_vertices*3]; - for(i=4;i=0;i--) if(mem[i]>0) delete [] mne[i]; + for (int i=current_vertex_order-1;i>=0;i--) if (mem[i]>0) delete [] mne[i]; delete [] mne; delete [] ne; } @@ -1388,9 +1388,9 @@ voronoicell_neighbor::~voronoicell_neighbor() { void voronoicell_neighbor::neighbors(std::vector &v) { v.clear(); int i,j,k,l,m; - for(i=1;i=0) { + if (k>=0) { v.push_back(ne[i][j]); ed[i][j]=-1-k; l=cycle_up(ed[i][nu[i]+j],k); @@ -1409,9 +1409,9 @@ void voronoicell_neighbor::neighbors(std::vector &v) { * \return The number of faces. */ int voronoicell_base::number_of_faces() { int i,j,k,l,m,s=0; - for(i=1;i=0) { + if (k>=0) { s++; ed[i][j]=-1-k; l=cycle_up(ed[i][nu[i]+j],k); @@ -1435,7 +1435,7 @@ int voronoicell_base::number_of_faces() { void voronoicell_base::vertices(double x,double y,double z,std::vector &v) { v.resize(3*p); double *ptsp=pts; - for(int i=0;i<3*p;i+=3) { + for (int i=0;i<3*p;i+=3) { v[i]=x+*(ptsp++)*0.5; v[i+1]=y+*(ptsp++)*0.5; v[i+2]=z+*(ptsp++)*0.5; @@ -1448,9 +1448,9 @@ void voronoicell_base::vertices(double x,double y,double z,std::vector & void voronoicell_base::face_vertices(std::vector &v) { int i,j,k,l,m,vp(0),vn; v.clear(); - for(i=1;i=0) { + if (k>=0) { v.push_back(0); v.push_back(i); ed[i][j]=-1-k; diff --git a/src/USER-QTB/fix_qbmsst.cpp b/src/USER-QTB/fix_qbmsst.cpp index 26a4716704..82dd76a1b5 100644 --- a/src/USER-QTB/fix_qbmsst.cpp +++ b/src/USER-QTB/fix_qbmsst.cpp @@ -526,7 +526,7 @@ void FixQBMSST::initial_integrate(int /*vflag*/) // load omega_H with calculated spectrum at a specific temperature (corrected spectrum), omega_H is the Fourier transformation of time_H for (int k = 0; k < 2*N_f; k++) { double f_k=(k-N_f)/(2*N_f*h_timestep); //\omega_k=\frac{2\pi}{\delta{}h}\frac{k}{2N_f} for k from -N_f to N_f-1 - if(k == N_f) { + if (k == N_f) { omega_H[k]=sqrt(force->boltz * t_current); } else { double energy_k= force->hplanck * fabs(f_k); diff --git a/src/USER-QTB/fix_qtb.cpp b/src/USER-QTB/fix_qtb.cpp index 16e01faa54..31f0808ca7 100644 --- a/src/USER-QTB/fix_qtb.cpp +++ b/src/USER-QTB/fix_qtb.cpp @@ -201,7 +201,7 @@ void FixQTB::init() // load omega_H with calculated spectrum at a specific temperature (corrected spectrum), omega_H is the Fourier transformation of time_H for (int k = 0; k < 2*N_f; k++) { double f_k=(k-N_f)/(2*N_f*h_timestep); //\omega_k=\frac{2\pi}{\delta{}h}\frac{k}{2N_f} for k from -N_f to N_f-1 - if(k == N_f) { + if (k == N_f) { omega_H[k]=sqrt(force->boltz * t_target); } else { double energy_k= force->hplanck * fabs(f_k); diff --git a/src/USER-QUIP/pair_quip.cpp b/src/USER-QUIP/pair_quip.cpp index 0cbc71e564..3ca19285f6 100644 --- a/src/USER-QUIP/pair_quip.cpp +++ b/src/USER-QUIP/pair_quip.cpp @@ -162,17 +162,17 @@ void PairQUIP::compute(int eflag, int vflag) iquip = 0; for (ii = 0; ii < ntotal; ii++) { - for( jj = 0; jj < 3; jj++ ) { + for ( jj = 0; jj < 3; jj++ ) { f[ii][jj] += quip_force[iquip]; iquip++; } } - if(eflag_global) { + if (eflag_global) { eng_vdwl = quip_energy; } - if(eflag_atom) { + if (eflag_atom) { for (ii = 0; ii < ntotal; ii++) { eatom[ii] = quip_local_e[ii]; } @@ -187,9 +187,9 @@ void PairQUIP::compute(int eflag, int vflag) virial[5] = (quip_virial[5] + quip_virial[7])*0.5; } - if(vflag_atom) { + if (vflag_atom) { int iatom = 0; - for(ii = 0; ii < ntotal; ii++) { + for (ii = 0; ii < ntotal; ii++) { vatom[ii][0] += quip_local_virial[iatom+0]; vatom[ii][1] += quip_local_virial[iatom+4]; vatom[ii][2] += quip_local_virial[iatom+8]; diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 2bfc7714be..e5413c6af7 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -3400,7 +3400,7 @@ void FixBondReact::ReadConstraints(char *line, int myrxn) } else if (ptr = strstr(line,"||")) { strcat(constraintstr[myrxn],"||"); *ptr = '\0'; - } else if (i+1 < nconstraints[myrxn]){ + } else if (i+1 < nconstraints[myrxn]) { strcat(constraintstr[myrxn],"&&"); } if (ptr = strchr(line,')')) diff --git a/src/USER-REAXC/fix_qeq_reax.cpp b/src/USER-REAXC/fix_qeq_reax.cpp index 6db17d4d61..abe6f26081 100644 --- a/src/USER-REAXC/fix_qeq_reax.cpp +++ b/src/USER-REAXC/fix_qeq_reax.cpp @@ -811,16 +811,16 @@ int FixQEqReax::pack_forward_comm(int n, int *list, double *buf, int m; if (pack_flag == 1) - for(m = 0; m < n; m++) buf[m] = d[list[m]]; + for (m = 0; m < n; m++) buf[m] = d[list[m]]; else if (pack_flag == 2) - for(m = 0; m < n; m++) buf[m] = s[list[m]]; + for (m = 0; m < n; m++) buf[m] = s[list[m]]; else if (pack_flag == 3) - for(m = 0; m < n; m++) buf[m] = t[list[m]]; + for (m = 0; m < n; m++) buf[m] = t[list[m]]; else if (pack_flag == 4) - for(m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; else if (pack_flag == 5) { m = 0; - for(int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) { int j = 2 * list[i]; buf[m++] = d[j ]; buf[m++] = d[j+1]; @@ -837,17 +837,17 @@ void FixQEqReax::unpack_forward_comm(int n, int first, double *buf) int i, m; if (pack_flag == 1) - for(m = 0, i = first; m < n; m++, i++) d[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) d[i] = buf[m]; else if (pack_flag == 2) - for(m = 0, i = first; m < n; m++, i++) s[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) s[i] = buf[m]; else if (pack_flag == 3) - for(m = 0, i = first; m < n; m++, i++) t[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) t[i] = buf[m]; else if (pack_flag == 4) - for(m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; else if (pack_flag == 5) { int last = first + n; m = 0; - for(i = first; i < last; i++) { + for (i = first; i < last; i++) { int j = 2 * i; d[j ] = buf[m++]; d[j+1] = buf[m++]; @@ -863,7 +863,7 @@ int FixQEqReax::pack_reverse_comm(int n, int first, double *buf) if (pack_flag == 5) { m = 0; int last = first + n; - for(i = first; i < last; i++) { + for (i = first; i < last; i++) { int indxI = 2 * i; buf[m++] = q[indxI ]; buf[m++] = q[indxI+1]; @@ -881,7 +881,7 @@ void FixQEqReax::unpack_reverse_comm(int n, int *list, double *buf) { if (pack_flag == 5) { int m = 0; - for(int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) { int indxI = 2 * list[i]; q[indxI ] += buf[m++]; q[indxI+1] += buf[m++]; diff --git a/src/USER-REAXC/fix_reaxc_bonds.cpp b/src/USER-REAXC/fix_reaxc_bonds.cpp index 91f7f52ccc..fa115e343e 100644 --- a/src/USER-REAXC/fix_reaxc_bonds.cpp +++ b/src/USER-REAXC/fix_reaxc_bonds.cpp @@ -262,7 +262,7 @@ void FixReaxCBonds::RecvBuffer(double *buf, int nbuf, int nbuf_local, double cutof3 = reaxc->control->bg_cut; MPI_Request irequest, irequest2; - if (me == 0 ){ + if (me == 0 ) { fprintf(fp,"# Timestep " BIGINT_FORMAT " \n",ntimestep); fprintf(fp,"# \n"); fprintf(fp,"# Number of particles %d \n",natoms); @@ -315,7 +315,7 @@ void FixReaxCBonds::RecvBuffer(double *buf, int nbuf, int nbuf_local, MPI_Isend(&buf[0],nbuf_local,MPI_DOUBLE,0,0,world,&irequest2); MPI_Wait(&irequest2,MPI_STATUS_IGNORE); } - if(me ==0) fprintf(fp,"# \n"); + if (me ==0) fprintf(fp,"# \n"); } diff --git a/src/USER-REAXC/pair_reaxc.cpp b/src/USER-REAXC/pair_reaxc.cpp index d3507bdf85..1fb6eb9005 100644 --- a/src/USER-REAXC/pair_reaxc.cpp +++ b/src/USER-REAXC/pair_reaxc.cpp @@ -420,7 +420,7 @@ void PairReaxC::init_style( ) error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an " "increased neighbor list skin."); - for( int i = 0; i < LIST_N; ++i ) + for ( int i = 0; i < LIST_N; ++i ) if (lists[i].allocated != 1) lists[i].allocated = 0; @@ -470,7 +470,7 @@ void PairReaxC::setup( ) int num_nbrs = estimate_reax_lists(); if (num_nbrs < 0) error->all(FLERR,"Too many neighbors for pair style reax/c"); - if(!Make_List(system->total_cap, num_nbrs, TYP_FAR_NEIGHBOR, + if (!Make_List(system->total_cap, num_nbrs, TYP_FAR_NEIGHBOR, lists+FAR_NBRS)) error->all(FLERR,"Pair reax/c problem in far neighbor list"); (lists+FAR_NBRS)->error_ptr=error; @@ -478,7 +478,7 @@ void PairReaxC::setup( ) write_reax_lists(); Initialize( system, control, data, workspace, &lists, out_control, mpi_data, world ); - for( int k = 0; k < system->N; ++k ) { + for ( int k = 0; k < system->N; ++k ) { num_bonds[k] = system->my_atoms[k].num_bonds; num_hbonds[k] = system->my_atoms[k].num_hbonds; } @@ -491,7 +491,7 @@ void PairReaxC::setup( ) // reset the bond list info for new atoms - for(int k = oldN; k < system->N; ++k) + for (int k = oldN; k < system->N; ++k) Set_End_Index( k, Start_Index( k, lists+BONDS ), lists+BONDS ); // check if I need to shrink/extend my data-structs @@ -560,7 +560,7 @@ void PairReaxC::compute(int eflag, int vflag) Compute_Forces(system,control,data,workspace,&lists,out_control,mpi_data); read_reax_forces(vflag); - for(int k = 0; k < system->N; ++k) { + for (int k = 0; k < system->N; ++k) { num_bonds[k] = system->my_atoms[k].num_bonds; num_hbonds[k] = system->my_atoms[k].num_hbonds; } @@ -616,7 +616,7 @@ void PairReaxC::compute(int eflag, int vflag) // populate tmpid and tmpbo arrays for fix reax/c/species int i, j; - if(fixspecies_flag) { + if (fixspecies_flag) { if (system->N > nmax) { memory->destroy(tmpid); memory->destroy(tmpbo); @@ -645,7 +645,7 @@ void PairReaxC::write_reax_atoms() if (system->N > system->total_cap) error->all(FLERR,"Too many ghost atoms"); - for( int i = 0; i < system->N; ++i ){ + for ( int i = 0; i < system->N; ++i ) { system->my_atoms[i].orig_id = atom->tag[i]; system->my_atoms[i].type = map[atom->type[i]]; system->my_atoms[i].x[0] = atom->x[i][0]; @@ -703,13 +703,13 @@ int PairReaxC::estimate_reax_lists() int numall = list->inum + list->gnum; - for( itr_i = 0; itr_i < numall; ++itr_i ){ + for ( itr_i = 0; itr_i < numall; ++itr_i ) { i = ilist[itr_i]; marked[i] = 1; ++num_marked; jlist = firstneigh[i]; - for( itr_j = 0; itr_j < numneigh[i]; ++itr_j ){ + for ( itr_j = 0; itr_j < numneigh[i]; ++itr_j ) { j = jlist[itr_j]; j &= NEIGHMASK; get_distance( x[j], x[i], &d_sqr, &dvec ); @@ -751,7 +751,7 @@ int PairReaxC::write_reax_lists() int numall = list->inum + list->gnum; - for( itr_i = 0; itr_i < numall; ++itr_i ){ + for ( itr_i = 0; itr_i < numall; ++itr_i ) { i = ilist[itr_i]; jlist = firstneigh[i]; Set_Start_Index( i, num_nbrs, far_nbrs ); @@ -761,7 +761,7 @@ int PairReaxC::write_reax_lists() else cutoff_sqr = control->bond_cut*control->bond_cut; - for( itr_j = 0; itr_j < numneigh[i]; ++itr_j ){ + for ( itr_j = 0; itr_j < numneigh[i]; ++itr_j ) { j = jlist[itr_j]; j &= NEIGHMASK; get_distance( x[j], x[i], &d_sqr, &dvec ); @@ -784,7 +784,7 @@ int PairReaxC::write_reax_lists() void PairReaxC::read_reax_forces(int /*vflag*/) { - for( int i = 0; i < system->N; ++i ) { + for ( int i = 0; i < system->N; ++i ) { system->my_atoms[i].f[0] = workspace->f[i][0]; system->my_atoms[i].f[1] = workspace->f[i][1]; system->my_atoms[i].f[2] = workspace->f[i][2]; @@ -846,7 +846,7 @@ double PairReaxC::memory_usage() bytes += lists->num_intrs * sizeof(far_neighbor_data); bytes += lists->num_intrs * sizeof(hbond_data); - if(fixspecies_flag) + if (fixspecies_flag) bytes += 2 * nmax * MAXSPECBOND * sizeof(double); return bytes; @@ -864,7 +864,7 @@ void PairReaxC::FindBond() for (i = 0; i < system->n; i++) { nj = 0; - for( pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj ) { + for ( pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj ) { bo_ij = &( lists->select.bond_list[pj] ); j = bo_ij->nbr; if (j < i) continue; diff --git a/src/USER-REAXC/reaxc_allocate.cpp b/src/USER-REAXC/reaxc_allocate.cpp index 8e7c8b2b23..f017eae41e 100644 --- a/src/USER-REAXC/reaxc_allocate.cpp +++ b/src/USER-REAXC/reaxc_allocate.cpp @@ -322,7 +322,7 @@ static void Reallocate_Neighbor_List( reax_list *far_nbrs, int n, int num_intrs ) { Delete_List( far_nbrs); - if(!Make_List( n, num_intrs, TYP_FAR_NEIGHBOR, far_nbrs )){ + if (!Make_List( n, num_intrs, TYP_FAR_NEIGHBOR, far_nbrs )) { far_nbrs->error_ptr->one(FLERR,"Problem in initializing far neighbors list"); } } @@ -361,7 +361,7 @@ static int Reallocate_Bonds_List( reax_system *system, reax_list *bonds, *total_bonds = 0; *est_3body = 0; - for( i = 0; i < system->N; ++i ){ + for( i = 0; i < system->N; ++i ) { *est_3body += SQR(system->my_atoms[i].num_bonds); *total_bonds += system->my_atoms[i].num_bonds; } @@ -374,7 +374,7 @@ static int Reallocate_Bonds_List( reax_system *system, reax_list *bonds, #endif Delete_List( bonds); - if(!Make_List(system->total_cap, *total_bonds, TYP_BOND, bonds)) { + if (!Make_List(system->total_cap, *total_bonds, TYP_BOND, bonds)) { bonds->error_ptr->one(FLERR, "Not enough space for bonds list"); } @@ -410,13 +410,13 @@ void ReAllocate( reax_system *system, control_params *control, realloc = &(workspace->realloc); - if( system->n >= DANGER_ZONE * system->local_cap || + if ( system->n >= DANGER_ZONE * system->local_cap || (0 && system->n <= LOOSE_ZONE * system->local_cap) ) { system->local_cap = MAX( (int)(system->n * safezone), mincap ); } int Nflag = 0; - if( system->N >= DANGER_ZONE * system->total_cap || + if ( system->N >= DANGER_ZONE * system->total_cap || (0 && system->N <= LOOSE_ZONE * system->total_cap) ) { Nflag = 1; system->total_cap = MAX( (int)(system->N * safezone), mincap ); @@ -466,7 +466,7 @@ void ReAllocate( reax_system *system, control_params *control, /* hydrogen bonds list */ if (control->hbond_cut > 0) { Hflag = 0; - if( system->numH >= DANGER_ZONE * system->Hcap || + if ( system->numH >= DANGER_ZONE * system->Hcap || (0 && system->numH <= LOOSE_ZONE * system->Hcap) ) { Hflag = 1; system->Hcap = int(MAX( system->numH * saferzone, mincap )); @@ -496,7 +496,7 @@ void ReAllocate( reax_system *system, control_params *control, realloc->num_3body = (int)(MAX(realloc->num_3body*safezone, MIN_3BODIES)); - if( !Make_List( num_bonds, realloc->num_3body, TYP_THREE_BODY, + if ( !Make_List( num_bonds, realloc->num_3body, TYP_THREE_BODY, (*lists)+THREE_BODIES ) ) { system->error_ptr->one(FLERR, "Problem in initializing angles list"); } diff --git a/src/USER-REAXC/reaxc_bond_orders.cpp b/src/USER-REAXC/reaxc_bond_orders.cpp index afa6c0ba5e..a9985d79f3 100644 --- a/src/USER-REAXC/reaxc_bond_orders.cpp +++ b/src/USER-REAXC/reaxc_bond_orders.cpp @@ -558,7 +558,7 @@ void BO( reax_system *system, control_params * /*control*/, simulation_data * /* } p_lp1 = system->reax_param.gp.l[15]; - for( j = 0; j < system->N; ++j ){ + for( j = 0; j < system->N; ++j ) { type_j = system->my_atoms[j].type; if (type_j < 0) continue; sbp_j = &(system->reax_param.sbp[ type_j ]); diff --git a/src/USER-REAXC/reaxc_bonds.cpp b/src/USER-REAXC/reaxc_bonds.cpp index dd5b8ad89e..91dc38d56d 100644 --- a/src/USER-REAXC/reaxc_bonds.cpp +++ b/src/USER-REAXC/reaxc_bonds.cpp @@ -104,7 +104,7 @@ void Bonds( reax_system *system, control_params * /*control*/, /* Stabilisation terminal triple bond */ if (bo_ij->BO >= 1.00) { - if( gp37 == 2 || + if ( gp37 == 2 || (sbp_i->mass == 12.0000 && sbp_j->mass == 15.9990) || (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990) ) { exphu = exp( -gp7 * SQR(bo_ij->BO - 2.50) ); diff --git a/src/USER-REAXC/reaxc_control.cpp b/src/USER-REAXC/reaxc_control.cpp index b805e46bf9..ab183bdaa4 100644 --- a/src/USER-REAXC/reaxc_control.cpp +++ b/src/USER-REAXC/reaxc_control.cpp @@ -134,7 +134,7 @@ char Read_Control_File( char *control_file, control_params* control, ival = atoi(tmp[1]); control->nsteps = ival; } - else if( strcmp(tmp[0], "dt") == 0) { + else if ( strcmp(tmp[0], "dt") == 0) { val = atof(tmp[1]); control->dt = val * 1.e-3; // convert dt from fs to ps! } diff --git a/src/USER-REAXC/reaxc_ffield.cpp b/src/USER-REAXC/reaxc_ffield.cpp index 5181415a9f..13e01c3a53 100644 --- a/src/USER-REAXC/reaxc_ffield.cpp +++ b/src/USER-REAXC/reaxc_ffield.cpp @@ -303,7 +303,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, /* Equate vval3 to valf for first-row elements (25/10/2004) */ for( i = 0; i < reax->num_atom_types; i++ ) - if( reax->sbp[i].mass < 21 && + if ( reax->sbp[i].mass < 21 && reax->sbp[i].valency_val != reax->sbp[i].valency_boc ) { if (me == 0) { char errmsg[256]; diff --git a/src/USER-REAXC/reaxc_forces.cpp b/src/USER-REAXC/reaxc_forces.cpp index 2ebffed25e..3cc66b7530 100644 --- a/src/USER-REAXC/reaxc_forces.cpp +++ b/src/USER-REAXC/reaxc_forces.cpp @@ -155,7 +155,7 @@ void Validate_Lists( reax_system *system, storage * /*workspace*/, reax_list **l (int)(MAX(Num_Entries(Hindex, hbonds)*saferzone, system->minhbonds)); //if( Num_Entries(i, hbonds) >= - //(Start_Index(i+1,hbonds)-Start_Index(i,hbonds))*0.90/*DANGER_ZONE*/){ + //(Start_Index(i+1,hbonds)-Start_Index(i,hbonds))*0.90/*DANGER_ZONE*/) { // workspace->realloc.hbonds = 1; if (Hindex < numH-1) @@ -367,7 +367,7 @@ void Estimate_Storages( reax_system *system, control_params *control, j = nbr_pj->nbr; atom_j = &(system->my_atoms[j]); - if(nbr_pj->d <= cutoff) { + if (nbr_pj->d <= cutoff) { type_j = system->my_atoms[j].type; if (type_j < 0) continue; r_ij = nbr_pj->d; @@ -384,7 +384,7 @@ void Estimate_Storages( reax_system *system, control_params *control, jhb = sbp_j->p_hbond; if (ihb == 1 && jhb == 2) ++hb_top[i]; - else if( j < system->n && ihb == 2 && jhb == 1 ) + else if ( j < system->n && ihb == 2 && jhb == 1 ) ++hb_top[j]; } } diff --git a/src/USER-REAXC/reaxc_hydrogen_bonds.cpp b/src/USER-REAXC/reaxc_hydrogen_bonds.cpp index 780b5f04a4..680f069bab 100644 --- a/src/USER-REAXC/reaxc_hydrogen_bonds.cpp +++ b/src/USER-REAXC/reaxc_hydrogen_bonds.cpp @@ -80,7 +80,7 @@ void Hydrogen_Bonds( reax_system *system, control_params *control, if (type_i < 0) continue; bo_ij = &(pbond_ij->bo_data); - if( system->reax_param.sbp[type_i].p_hbond == 2 && + if ( system->reax_param.sbp[type_i].p_hbond == 2 && bo_ij->BO >= HB_THRESHOLD ) hblist[top++] = pi; } diff --git a/src/USER-REAXC/reaxc_init_md.cpp b/src/USER-REAXC/reaxc_init_md.cpp index e651f272ac..e7d46fa742 100644 --- a/src/USER-REAXC/reaxc_init_md.cpp +++ b/src/USER-REAXC/reaxc_init_md.cpp @@ -58,7 +58,7 @@ int Init_System(reax_system *system, control_params *control, char * /*msg*/) /* estimate numH and Hcap */ system->numH = 0; if (control->hbond_cut > 0) - for(i = 0; i < system->n; ++i) { + for (i = 0; i < system->n; ++i) { atom = &(system->my_atoms[i]); if (system->reax_param.sbp[ atom->type ].p_hbond == 1 && atom->type >= 0) atom->Hindex = system->numH++; @@ -101,7 +101,7 @@ void Init_Taper(control_params *control, storage *workspace) if (swb < 0) { error->all(FLERR,"Negative upper Taper-radius cutoff"); } - else if(swb < 5 && control->me == 0) { + else if (swb < 5 && control->me == 0) { char errmsg[256]; snprintf(errmsg, 256, "Very low Taper-radius cutoff: %f", swb); error->warning(FLERR, errmsg); @@ -178,13 +178,13 @@ int Init_Lists(reax_system *system, control_params *control, if (control->hbond_cut > 0) { /* init H indexes */ total_hbonds = 0; - for(i = 0; i < system->n; ++i) { + for (i = 0; i < system->n; ++i) { system->my_atoms[i].num_hbonds = hb_top[i]; total_hbonds += hb_top[i]; } total_hbonds = (int)(MAX(total_hbonds*saferzone,mincap*system->minhbonds)); - if(!Make_List(system->Hcap, total_hbonds, TYP_HBOND, + if (!Make_List(system->Hcap, total_hbonds, TYP_HBOND, *lists+HBONDS)) error->one(FLERR, "Not enough space for hbonds list."); @@ -192,13 +192,13 @@ int Init_Lists(reax_system *system, control_params *control, } total_bonds = 0; - for(i = 0; i < system->N; ++i) { + for (i = 0; i < system->N; ++i) { system->my_atoms[i].num_bonds = bond_top[i]; total_bonds += bond_top[i]; } bond_cap = (int)(MAX(total_bonds*safezone, mincap*MIN_BONDS)); - if(!Make_List(system->total_cap, bond_cap, TYP_BOND, + if (!Make_List(system->total_cap, bond_cap, TYP_BOND, *lists+BONDS)) error->one(FLERR, "Not enough space for bonds list."); @@ -206,7 +206,7 @@ int Init_Lists(reax_system *system, control_params *control, /* 3bodies list */ cap_3body = (int)(MAX(num_3body*safezone, MIN_3BODIES)); - if(!Make_List(bond_cap, cap_3body, TYP_THREE_BODY, + if (!Make_List(bond_cap, cap_3body, TYP_THREE_BODY, *lists+THREE_BODIES)) error->one(FLERR,"Problem in initializing angles list."); diff --git a/src/USER-REAXC/reaxc_io_tools.cpp b/src/USER-REAXC/reaxc_io_tools.cpp index 3e1c00307d..6ac64a17bc 100644 --- a/src/USER-REAXC/reaxc_io_tools.cpp +++ b/src/USER-REAXC/reaxc_io_tools.cpp @@ -61,7 +61,7 @@ int Init_Output_Files( reax_system *system, control_params *control, } /* init pressure file */ - if( control->ensemble == NPT || + if ( control->ensemble == NPT || control->ensemble == iNPT || control->ensemble == sNPT ) { sprintf( temp, "%s.prs", control->sim_name ); @@ -109,15 +109,15 @@ void Output_Results( reax_system *system, control_params *control, output_controls *out_control, mpi_datatypes *mpi_data ) { - if((out_control->energy_update_freq > 0 && + if ((out_control->energy_update_freq > 0 && data->step%out_control->energy_update_freq == 0) || (out_control->write_steps > 0 && - data->step%out_control->write_steps == 0)){ + data->step%out_control->write_steps == 0)) { /* update system-wide energies */ Compute_System_Energy( system, data, mpi_data->world ); /* output energies */ - if( system->my_rank == MASTER_NODE && + if ( system->my_rank == MASTER_NODE && out_control->energy_update_freq > 0 && data->step % out_control->energy_update_freq == 0 ) { @@ -141,7 +141,7 @@ void Output_Results( reax_system *system, control_params *control, } /* write current frame */ - if( out_control->write_steps > 0 && + if ( out_control->write_steps > 0 && (data->step-data->prev_steps) % out_control->write_steps == 0 ) { Append_Frame( system, control, data, lists, out_control, mpi_data ); } diff --git a/src/USER-REAXC/reaxc_lookup.cpp b/src/USER-REAXC/reaxc_lookup.cpp index e39412ace6..980e6e0fb6 100644 --- a/src/USER-REAXC/reaxc_lookup.cpp +++ b/src/USER-REAXC/reaxc_lookup.cpp @@ -31,20 +31,20 @@ #include "reaxc_tool_box.h" void Tridiagonal_Solve( const double *a, const double *b, - double *c, double *d, double *x, unsigned int n){ + double *c, double *d, double *x, unsigned int n) { int i; double id; c[0] /= b[0]; /* Division by zero risk. */ d[0] /= b[0]; /* Division by zero would imply a singular matrix. */ - for(i = 1; i < (int)n; i++){ + for (i = 1; i < (int)n; i++) { id = (b[i] - c[i-1] * a[i]); /* Division by zero risk. */ c[i] /= id; /* Last value calculated is redundant. */ d[i] = (d[i] - d[i-1] * a[i])/id; } x[n - 1] = d[n - 1]; - for(i = n - 2; i >= 0; i--) + for (i = n - 2; i >= 0; i--) x[i] = d[i] - c[i] * x[i + 1]; } @@ -64,26 +64,26 @@ void Natural_Cubic_Spline( LAMMPS_NS::Error* error_ptr, const double *h, const d /* build the linear system */ a[0] = a[1] = a[n-1] = 0; - for( i = 2; i < (int)n-1; ++i ) + for ( i = 2; i < (int)n-1; ++i ) a[i] = h[i-1]; b[0] = b[n-1] = 0; - for( i = 1; i < (int)n-1; ++i ) + for ( i = 1; i < (int)n-1; ++i ) b[i] = 2 * (h[i-1] + h[i]); c[0] = c[n-2] = c[n-1] = 0; - for( i = 1; i < (int)n-2; ++i ) + for ( i = 1; i < (int)n-2; ++i ) c[i] = h[i]; d[0] = d[n-1] = 0; - for( i = 1; i < (int)n-1; ++i ) + for ( i = 1; i < (int)n-1; ++i ) d[i] = 6 * ((f[i+1]-f[i])/h[i] - (f[i]-f[i-1])/h[i-1]); v[0] = 0; v[n-1] = 0; Tridiagonal_Solve( &(a[1]), &(b[1]), &(c[1]), &(d[1]), &(v[1]), n-2 ); - for( i = 1; i < (int)n; ++i ){ + for ( i = 1; i < (int)n; ++i ) { coef[i-1].d = (v[i] - v[i-1]) / (6*h[i-1]); coef[i-1].c = v[i]/2; coef[i-1].b = (f[i]-f[i-1])/h[i-1] + h[i-1]*(2*v[i] + v[i-1])/6; @@ -114,25 +114,25 @@ void Complete_Cubic_Spline( LAMMPS_NS::Error* error_ptr, const double *h, const /* build the linear system */ a[0] = 0; - for( i = 1; i < (int)n; ++i ) + for ( i = 1; i < (int)n; ++i ) a[i] = h[i-1]; b[0] = 2*h[0]; - for( i = 1; i < (int)n; ++i ) + for ( i = 1; i < (int)n; ++i ) b[i] = 2 * (h[i-1] + h[i]); c[n-1] = 0; - for( i = 0; i < (int)n-1; ++i ) + for ( i = 0; i < (int)n-1; ++i ) c[i] = h[i]; d[0] = 6 * (f[1]-f[0])/h[0] - 6 * v0; d[n-1] = 6 * vlast - 6 * (f[n-1]-f[n-2]/h[n-2]); - for( i = 1; i < (int)n-1; ++i ) + for ( i = 1; i < (int)n-1; ++i ) d[i] = 6 * ((f[i+1]-f[i])/h[i] - (f[i]-f[i-1])/h[i-1]); Tridiagonal_Solve( &(a[0]), &(b[0]), &(c[0]), &(d[0]), &(v[0]), n ); - for( i = 1; i < (int)n; ++i ){ + for ( i = 1; i < (int)n; ++i ) { coef[i-1].d = (v[i] - v[i-1]) / (6*h[i-1]); coef[i-1].c = v[i]/2; coef[i-1].b = (f[i]-f[i-1])/h[i-1] + h[i-1]*(2*v[i] + v[i-1])/6; @@ -181,21 +181,21 @@ int Init_Lookup_Tables( reax_system *system, control_params *control, LR = (LR_lookup_table**) scalloc(system->error_ptr, num_atom_types, sizeof(LR_lookup_table*), "lookup:LR"); - for( i = 0; i < num_atom_types; ++i ) + for ( i = 0; i < num_atom_types; ++i ) LR[i] = (LR_lookup_table*) scalloc(system->error_ptr, num_atom_types, sizeof(LR_lookup_table), "lookup:LR[i]"); - for( i = 0; i < REAX_MAX_ATOM_TYPES; ++i ) + for ( i = 0; i < REAX_MAX_ATOM_TYPES; ++i ) existing_types[i] = 0; - for( i = 0; i < system->n; ++i ) + for ( i = 0; i < system->n; ++i ) existing_types[ system->my_atoms[i].type ] = 1; MPI_Allreduce( existing_types, aggregated, REAX_MAX_ATOM_TYPES, MPI_INT, MPI_SUM, mpi_data->world ); - for( i = 0; i < num_atom_types; ++i ) { + for ( i = 0; i < num_atom_types; ++i ) { if (aggregated[i]) { - for( j = i; j < num_atom_types; ++j ) { + for ( j = i; j < num_atom_types; ++j ) { if (aggregated[j]) { LR[i][j].xmin = 0; LR[i][j].xmax = control->nonb_cut; @@ -216,7 +216,7 @@ int Init_Lookup_Tables( reax_system *system, control_params *control, smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef), "lookup:LR[i,j].CEclmb"); - for( r = 1; r <= control->tabulate; ++r ) { + for ( r = 1; r <= control->tabulate; ++r ) { LR_vdW_Coulomb( system, workspace, control, i, j, r * dr, &(LR[i][j].y[r]) ); h[r] = LR[i][j].dx; fh[r] = LR[i][j].y[r].H; @@ -277,8 +277,8 @@ void Deallocate_Lookup_Tables( reax_system *system ) ntypes = system->reax_param.num_atom_types; - for( i = 0; i < ntypes; ++i ) { - for( j = i; j < ntypes; ++j ) + for ( i = 0; i < ntypes; ++i ) { + for ( j = i; j < ntypes; ++j ) if (LR[i][j].n) { sfree(system->error_ptr, LR[i][j].y, "LR[i,j].y" ); sfree(system->error_ptr, LR[i][j].H, "LR[i,j].H" ); diff --git a/src/USER-REAXC/reaxc_nonbonded.cpp b/src/USER-REAXC/reaxc_nonbonded.cpp index ccb8f0fed0..7c3350fd40 100644 --- a/src/USER-REAXC/reaxc_nonbonded.cpp +++ b/src/USER-REAXC/reaxc_nonbonded.cpp @@ -75,7 +75,7 @@ void vdW_Coulomb_Energy( reax_system *system, control_params *control, orig_j = system->my_atoms[j].orig_id; flag = 0; - if(nbr_pj->d <= control->nonb_cut) { + if (nbr_pj->d <= control->nonb_cut) { if (j < natoms) flag = 1; else if (orig_i < orig_j) flag = 1; else if (orig_i == orig_j) { @@ -110,7 +110,7 @@ void vdW_Coulomb_Energy( reax_system *system, control_params *control, dTap += workspace->Tap[1]/r_ij; /*vdWaals Calculations*/ - if(system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) { // shielding powr_vdW1 = pow(r_ij, p_vdW1); powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); @@ -139,7 +139,7 @@ void vdW_Coulomb_Energy( reax_system *system, control_params *control, Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; } - if(system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) { // inner wall e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); data->my_en.e_vdW += Tap * e_core; @@ -243,7 +243,7 @@ void Tabulated_vdW_Coulomb_Energy( reax_system *system,control_params *control, orig_j = system->my_atoms[j].orig_id; flag = 0; - if(nbr_pj->d <= control->nonb_cut) { + if (nbr_pj->d <= control->nonb_cut) { if (j < natoms) flag = 1; else if (orig_i < orig_j) flag = 1; else if (orig_i == orig_j) { @@ -372,7 +372,7 @@ void LR_vdW_Coulomb( reax_system *system, storage *workspace, dTap += workspace->Tap[1]/r_ij; /*vdWaals Calculations*/ - if(system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) { // shielding powr_vdW1 = pow(r_ij, p_vdW1); powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); @@ -397,7 +397,7 @@ void LR_vdW_Coulomb( reax_system *system, storage *workspace, Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; } - if(system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) { // inner wall e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); lr->e_vdW += Tap * e_core; diff --git a/src/USER-REAXC/reaxc_torsion_angles.cpp b/src/USER-REAXC/reaxc_torsion_angles.cpp index 380fbf4a02..c49b095b20 100644 --- a/src/USER-REAXC/reaxc_torsion_angles.cpp +++ b/src/USER-REAXC/reaxc_torsion_angles.cpp @@ -85,9 +85,9 @@ double Calculate_Omega( rvec dvec_ij, double r_ij, if (arg < -1.0) arg = -1.0; if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) sin_ijk = MIN_SINE; - else if( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) sin_ijk = -MIN_SINE; + else if ( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) sin_ijk = -MIN_SINE; if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) sin_jkl = MIN_SINE; - else if( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) sin_jkl = -MIN_SINE; + else if ( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) sin_jkl = -MIN_SINE; // dcos_omega_di rvec_ScaledSum( dcos_omega_di, (htra-arg*hnra)/r_ij, dvec_ij, -1., dvec_li ); @@ -230,7 +230,7 @@ void Torsion_Angles( reax_system *system, control_params *control, //tan_ijk_i = 1. / tan( theta_ijk ); if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) tan_ijk_i = cos_ijk / MIN_SINE; - else if( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) + else if ( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) tan_ijk_i = cos_ijk / -MIN_SINE; else tan_ijk_i = cos_ijk / sin_ijk; @@ -249,9 +249,9 @@ void Torsion_Angles( reax_system *system, control_params *control, fbp = &(system->reax_param.fbp[type_i][type_j] [type_k][type_l].prm[0]); - if( i != l && fbh->cnt && + if ( i != l && fbh->cnt && bo_kl->BO > control->thb_cut/*0*/ && - bo_ij->BO * bo_jk->BO * bo_kl->BO > control->thb_cut/*0*/ ){ + bo_ij->BO * bo_jk->BO * bo_kl->BO > control->thb_cut/*0*/ ) { ++num_frb_intrs; r_kl = pbond_kl->d; BOA_kl = bo_kl->BO - control->thb_cut; @@ -262,7 +262,7 @@ void Torsion_Angles( reax_system *system, control_params *control, //tan_jkl_i = 1. / tan( theta_jkl ); if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) tan_jkl_i = cos_jkl / MIN_SINE; - else if( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) + else if ( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) tan_jkl_i = cos_jkl / -MIN_SINE; else tan_jkl_i = cos_jkl /sin_jkl; diff --git a/src/USER-REAXC/reaxc_traj.cpp b/src/USER-REAXC/reaxc_traj.cpp index b71d883c7d..2d56722aba 100644 --- a/src/USER-REAXC/reaxc_traj.cpp +++ b/src/USER-REAXC/reaxc_traj.cpp @@ -578,7 +578,7 @@ int Write_Bonds(reax_system *system, control_params *control, reax_list *bonds, for( i=0; i < system->n; ++i ) for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { j = bonds->select.bond_list[pj].nbr; - if( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && + if ( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && bonds->select.bond_list[pj].bo_data.BO >= control->bg_cut ) ++my_bonds; } @@ -605,7 +605,7 @@ int Write_Bonds(reax_system *system, control_params *control, reax_list *bonds, bo_ij = &( bonds->select.bond_list[pj] ); j = bo_ij->nbr; - if( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && + if ( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && bo_ij->bo_data.BO >= control->bg_cut ) { switch( out_control->bond_info ) { case OPT_BOND_BASIC: @@ -678,7 +678,7 @@ int Write_Angles( reax_system *system, control_params *control, k = angle_ijk->thb; bo_jk = &(bonds->select.bond_list[ angle_ijk->pthb ]); - if( system->my_atoms[i].orig_id < system->my_atoms[k].orig_id && + if ( system->my_atoms[i].orig_id < system->my_atoms[k].orig_id && bo_jk->bo_data.BO >= control->bg_cut ) // physical j&k bond ++my_angles; } @@ -711,7 +711,7 @@ int Write_Angles( reax_system *system, control_params *control, k = angle_ijk->thb; bo_jk = &(bonds->select.bond_list[ angle_ijk->pthb ]); - if( system->my_atoms[i].orig_id < system->my_atoms[k].orig_id && + if ( system->my_atoms[i].orig_id < system->my_atoms[k].orig_id && bo_jk->bo_data.BO >= control->bg_cut ) { // physical j&k bond sprintf( out_control->line, ANGLE_BASIC, system->my_atoms[i].orig_id, system->my_atoms[j].orig_id, diff --git a/src/USER-REAXC/reaxc_valence_angles.cpp b/src/USER-REAXC/reaxc_valence_angles.cpp index 14c57773c7..b545fa93a9 100644 --- a/src/USER-REAXC/reaxc_valence_angles.cpp +++ b/src/USER-REAXC/reaxc_valence_angles.cpp @@ -176,7 +176,7 @@ void Valence_Angles( reax_system *system, control_params *control, BOA_ij = bo_ij->BO - control->thb_cut; - if( BOA_ij/*bo_ij->BO*/ > 0.0 && + if ( BOA_ij/*bo_ij->BO*/ > 0.0 && ( j < system->n || pbond_ij->nbr < system->n ) ) { i = pbond_ij->nbr; type_i = system->my_atoms[i].type; diff --git a/src/USER-SCAFACOS/scafacos.cpp b/src/USER-SCAFACOS/scafacos.cpp index 9cc7c408c1..ab28589f20 100644 --- a/src/USER-SCAFACOS/scafacos.cpp +++ b/src/USER-SCAFACOS/scafacos.cpp @@ -226,7 +226,7 @@ void Scafacos::compute(int eflag, int vflag) memcpy(xpbc,&x[0][0],3*nlocal*sizeof(double)); - if (domain->xperiodic || domain -> yperiodic || domain -> zperiodic){ + if (domain->xperiodic || domain -> yperiodic || domain -> zperiodic) { int j = 0; for (int i = 0; i < nlocal; i++) { domain->remap(&xpbc[j]); @@ -321,7 +321,7 @@ int Scafacos::modify_param(int narg, char **arg) else error->all(FLERR, "Illegal kspace_modify command (tolerance argument)"); // check if method is compatatible to chosen tolerance type - if( + if ( ( strcmp(method,"fmm") == 0 && ( diff --git a/src/USER-SMD/compute_smd_triangle_vertices.cpp b/src/USER-SMD/compute_smd_triangle_vertices.cpp index 9f2f11ebdf..f621029a47 100644 --- a/src/USER-SMD/compute_smd_triangle_vertices.cpp +++ b/src/USER-SMD/compute_smd_triangle_vertices.cpp @@ -95,7 +95,7 @@ void ComputeSMDTriangleVertices::compute_peratom() { int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if ((mask[i] & groupbit) && (mol[i] >= 65535) ){ + if ((mask[i] & groupbit) && (mol[i] >= 65535) ) { outputVector[i][0] = smd_data_9[i][0]; outputVector[i][1] = smd_data_9[i][1]; outputVector[i][2] = smd_data_9[i][2]; diff --git a/src/USER-SMD/pair_smd_tlsph.cpp b/src/USER-SMD/pair_smd_tlsph.cpp index 208be69acc..bf9fcdc1e7 100644 --- a/src/USER-SMD/pair_smd_tlsph.cpp +++ b/src/USER-SMD/pair_smd_tlsph.cpp @@ -679,7 +679,7 @@ void PairTlsph::ComputeForces(int eflag, int vflag) { } // end loop over jj neighbors of i // avoid division by zero and overflow - if ((shepardWeight != 0.0) && (fabs(hourglass_error[i]) < 1.0e300)){ + if ((shepardWeight != 0.0) && (fabs(hourglass_error[i]) < 1.0e300)) { hourglass_error[i] /= shepardWeight; } diff --git a/src/USER-SMTBQ/pair_smtbq.cpp b/src/USER-SMTBQ/pair_smtbq.cpp index aedf90da07..5f416955cf 100644 --- a/src/USER-SMTBQ/pair_smtbq.cpp +++ b/src/USER-SMTBQ/pair_smtbq.cpp @@ -501,7 +501,7 @@ void PairSMTBQ::read_file(char *file) params[i].chi = atof(words[2]) ; params[i].dj = atof(words[3]) ; - if(strcmp(params[i].nom,"O")!=0){ + if (strcmp(params[i].nom,"O")!=0) { params[i].R = atof(words[4]) ; if (verbose) printf(" %s %f %f %f %f\n",words[0],params[i].ne,params[i].chi, params[i].dj,params[i].R); @@ -511,7 +511,7 @@ void PairSMTBQ::read_file(char *file) // Line 4bis - Coordinance et rayon pour Ox - if(strcmp(params[i].nom,"O")==0){ + if (strcmp(params[i].nom,"O")==0) { fgets( ptr, MAXLINE, fp); Tokenize ( ptr, &words ); @@ -543,7 +543,7 @@ void PairSMTBQ::read_file(char *file) ===================================================================== */ m = 0; maxintsm = 0; // - for (k=0 ; k<=maxintparam ; k++){intparams[k].intsm = 0;} + for (k=0 ; k<=maxintparam ; k++) {intparams[k].intsm = 0;} // --------------------------------- for (k = 0; k < maxintparam; k++) { // --------------------------------- @@ -597,7 +597,7 @@ void PairSMTBQ::read_file(char *file) intparams[m].intsm = maxintsm; if (strcmp(intparams[m].mode,"oxide") != 0 && - strcmp(intparams[m].mode,"metal") != 0){ + strcmp(intparams[m].mode,"metal") != 0) { error->all(FLERR,"needs mode to second moment interaction : oxide or metal"); } // if (strcmp(intparams[m].mode,"oxide") == 0) @@ -1400,8 +1400,8 @@ void PairSMTBQ::tabqeq() rcoupe = cutmax ; double cang ; - for (i = 0; i < n ; i++){ - for (j = i; j < n ; j++){ + for (i = 0; i < n ; i++) { + for (j = i; j < n ; j++) { rc = cutmax; if (verbose) printf ("cutmax %f\n",cutmax); m = coultype[i][j] ; @@ -1457,11 +1457,11 @@ void PairSMTBQ::tabqeq() // Make the table fafbOxOxSurf rc = cutmax; - if(strcmp(params[i].nom,"O")==0 || strcmp(params[j].nom,"O")==0){ - if(strcmp(params[i].nom,"O")==0) { + if (strcmp(params[i].nom,"O")==0 || strcmp(params[j].nom,"O")==0) { + if (strcmp(params[i].nom,"O")==0) { ra = ROxSurf; za = (2.0*params[i].ne + 1.0)/(4.0*ra);} - if(strcmp(params[j].nom,"O")==0) { + if (strcmp(params[j].nom,"O")==0) { rb = ROxSurf; zb = (2.0*params[j].ne + 1.0)/(4.0*rb); } @@ -1501,7 +1501,7 @@ void PairSMTBQ::tabqeq() if (r > (rc+nang)) {dij = 0.0 ; ddij = 0.0;} - if(strcmp(params[i].nom,"O")==0 && strcmp(params[j].nom,"O")==0){ + if (strcmp(params[i].nom,"O")==0 && strcmp(params[j].nom,"O")==0) { fafbOxOxSurf[k] = potqn[k] - dij ; if (k == 1) fafbOxOxSurf[0] = fafbOxOxSurf[k] ; @@ -1520,11 +1520,11 @@ void PairSMTBQ::tabqeq() // Makes the table fafbOxOxBB rc = cutmax; - if(strcmp(params[i].nom,"O")==0 || strcmp(params[j].nom,"O")==0){ - if(strcmp(params[i].nom,"O")==0) { + if (strcmp(params[i].nom,"O")==0 || strcmp(params[j].nom,"O")==0) { + if (strcmp(params[i].nom,"O")==0) { ra = ROxBB; za = (2.0*params[i].ne + 1.0)/(4.0*ra);} - if(strcmp(params[j].nom,"O")==0) { + if (strcmp(params[j].nom,"O")==0) { rb = ROxBB; zb = (2.0*params[j].ne + 1.0)/(4.0*rb); } @@ -1565,7 +1565,7 @@ void PairSMTBQ::tabqeq() if (r > (rc+nang)) {dij = 0.0 ; ddij = 0.0;} - if(strcmp(params[i].nom,"O")==0 && strcmp(params[j].nom,"O")==0){ + if (strcmp(params[i].nom,"O")==0 && strcmp(params[j].nom,"O")==0) { fafbOxOxBB[k] = potqn[k] - dij ; if (k == 1) fafbOxOxBB[0] = fafbOxOxBB[k] ; dfafbOxOxBB[k] = dpotqn[k] - ddij/r ; } @@ -1638,9 +1638,9 @@ void PairSMTBQ::potqeq(int i, int j, double qi, double qj, double rsq, fforce = - qi*qj*(t1 + (t2 - t1)*xi/2.0) ; - if(strcmp(params[itype].nom,"O")==0 || strcmp(params[jtype].nom,"O")==0){ + if (strcmp(params[itype].nom,"O")==0 || strcmp(params[jtype].nom,"O")==0) { - if(strcmp(params[itype].nom,"O")==0 && strcmp(params[jtype].nom,"O")==0){ + if (strcmp(params[itype].nom,"O")==0 && strcmp(params[jtype].nom,"O")==0) { // between two oxygens t1 = fafbOxOxSurf[l] + (fafbOxOxSurf[l+1] - fafbOxOxSurf[l])*xi; @@ -1680,7 +1680,7 @@ void PairSMTBQ::potqeq(int i, int j, double qi, double qj, double rsq, t2 = fafbTiOxBB[l+1] + (fafbTiOxBB[l+2] - fafbTiOxBB[l+1])*(xi-1.0); engBB = qi*qj*(t1 + (t2 - t1)*xi/2.0); - if(strcmp(params[jtype].nom,"O")==0) //the atom j is an oxygen + if (strcmp(params[jtype].nom,"O")==0) //the atom j is an oxygen { iIntfCoup2=jIntfCoup2; iCoord=jCoord; } @@ -1758,9 +1758,9 @@ void PairSMTBQ::pot_ES (int i, int j, double rsq, double &eng) engBulk=eng; - if(itype==0 || jtype==0){ + if (itype==0 || jtype==0) { - if(itype==0 && jtype==0){ // between two oxygens + if (itype==0 && jtype==0) { // between two oxygens t1 = fafbOxOxSurf[l] + (fafbOxOxSurf[l+1] - fafbOxOxSurf[l])*xi; t2 = fafbOxOxSurf[l+1] + (fafbOxOxSurf[l+2] - fafbOxOxSurf[l+1])*(xi-1.0); @@ -2062,7 +2062,7 @@ void PairSMTBQ::attractive(Intparam *intparam, double rsq, // if (i < 10) printf ("i %d, iq %f sbcov %f \n",i,iq,sbcov[i]); if (sqrt(r)(nQEqall[gp]); enegmax[gp] = enegmaxall[gp]; } @@ -2758,7 +2758,7 @@ void PairSMTBQ::Charge() // Statistique (ecart type) // ------------------------ for (i=0; i(nQEqcall[i]) ; TransfAll[i+2*cluster] /= static_cast(nQEqaall[i]) ;} sigmaa[i] = sigmac[i] = 0.0; @@ -2788,7 +2788,7 @@ void PairSMTBQ::Charge() - if (me == 0 && strcmp(Bavard,"false") != 0){ + if (me == 0 && strcmp(Bavard,"false") != 0) { for (gp = 0; gp < nteam+1; gp++) { printf (" -------------- Groupe %d -----------------\n",gp); printf (" qtotc %f(+- %f) qtota %f(+- %f)\n", @@ -3632,7 +3632,7 @@ void PairSMTBQ::CheckEnergyVSForce() drL=0.0001; iiiMax=int((cutmax-1.2)/drL); - for (iii=1; iii< iiiMax ; iii++){ + for (iii=1; iii< iiiMax ; iii++) { r=1.2+drL*iii; rsq=r*r; evdwlCoul = 0.0 ; fpairCoul = 0.0; @@ -3732,7 +3732,7 @@ void PairSMTBQ::CheckEnergyVSForce() drL=0.0001; iiiMax=int((cutmax-1.2)/drL); - for (iii=1; iii< iiiMax ; iii++){ + for (iii=1; iii< iiiMax ; iii++) { r=1.2+drL*iii; rsq=r*r; evdwlCoul = 0.0 ; fpairCoul = 0.0; diff --git a/src/USER-TALLY/compute_pe_mol_tally.cpp b/src/USER-TALLY/compute_pe_mol_tally.cpp index d4a7e80602..7cc0f95d80 100644 --- a/src/USER-TALLY/compute_pe_mol_tally.cpp +++ b/src/USER-TALLY/compute_pe_mol_tally.cpp @@ -100,7 +100,7 @@ void ComputePEMolTally::pair_tally_callback(int i, int j, int nlocal, int newton const tagint * const molid = atom->molecule; if ( ((mask[i] & groupbit) && (mask[j] & groupbit2)) - || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ){ + || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ) { evdwl *= 0.5; ecoul *= 0.5; if (newton || i < nlocal) { diff --git a/src/USER-UEF/dump_cfg_uef.cpp b/src/USER-UEF/dump_cfg_uef.cpp index 4b1c8cc2c6..3f39bb5700 100644 --- a/src/USER-UEF/dump_cfg_uef.cpp +++ b/src/USER-UEF/dump_cfg_uef.cpp @@ -72,7 +72,7 @@ void DumpCFGUef::write_header(bigint n) // rot goes from "lab frame" to "upper triangular frame" // it's transpose takes the simulation box to the flow frame for (int i=0;i<3;i++) - for(int j=i+1;j<3;j++) + for (int j=i+1;j<3;j++) { double t=rot[i][j]; rot[i][j]=rot[j][i]; diff --git a/src/USER-UEF/uef_utils.cpp b/src/USER-UEF/uef_utils.cpp index 5fc92618b3..4febbbb577 100644 --- a/src/USER-UEF/uef_utils.cpp +++ b/src/USER-UEF/uef_utils.cpp @@ -277,9 +277,9 @@ void rotation_matrix(double q[3][3], double r[3][3], const double m[3][3]) // this makes r have positive diagonals // q*m = r <==> (-q)*m = (-r) will hold row-wise - if (r[0][0] < 0){ neg_row(q,0); neg_row(r,0); } - if (r[1][1] < 0){ neg_row(q,1); neg_row(r,1); } - if (r[2][2] < 0){ neg_row(q,2); neg_row(r,2); } + if (r[0][0] < 0) { neg_row(q,0); neg_row(r,0); } + if (r[1][1] < 0) { neg_row(q,1); neg_row(r,1); } + if (r[2][2] < 0) { neg_row(q,2); neg_row(r,2); } } /* ---------------------------------------------------------------------- diff --git a/src/USER-VTK/dump_vtk.cpp b/src/USER-VTK/dump_vtk.cpp index 98b8e0bb35..a2bf1fb4bf 100644 --- a/src/USER-VTK/dump_vtk.cpp +++ b/src/USER-VTK/dump_vtk.cpp @@ -1188,7 +1188,7 @@ void DumpVTK::write_domain_vtk() vtkSmartPointer gwriter = vtkSmartPointer::New(); - if(label) gwriter->SetHeader(label); + if (label) gwriter->SetHeader(label); else gwriter->SetHeader("Generated by LAMMPS"); if (binary) gwriter->SetFileTypeToBinary(); @@ -1212,7 +1212,7 @@ void DumpVTK::write_domain_vtk_triclinic() vtkSmartPointer gwriter = vtkSmartPointer::New(); - if(label) gwriter->SetHeader(label); + if (label) gwriter->SetHeader(label); else gwriter->SetHeader("Generated by LAMMPS"); if (binary) gwriter->SetFileTypeToBinary(); @@ -1305,7 +1305,7 @@ void DumpVTK::write_vtk(int n, double *mybuf) vtkSmartPointer writer = vtkSmartPointer::New(); #endif - if(label) writer->SetHeader(label); + if (label) writer->SetHeader(label); else writer->SetHeader("Generated by LAMMPS"); if (binary) writer->SetFileTypeToBinary(); @@ -1890,7 +1890,7 @@ void DumpVTK::identify_vectors() int num_vector3_starts = sizeof(vector3_starts) / sizeof(int); for (int v3s = 0; v3s < num_vector3_starts; v3s++) { - if(name.count(vector3_starts[v3s] ) && + if (name.count(vector3_starts[v3s] ) && name.count(vector3_starts[v3s]+1) && name.count(vector3_starts[v3s]+2) ) { @@ -1906,12 +1906,12 @@ void DumpVTK::identify_vectors() if (it->first < ATTRIBUTES) // neither fix nor compute continue; - if(argindex[it->first] == 0) // single value + if (argindex[it->first] == 0) // single value continue; // assume components are grouped together and in correct order - if(name.count(it->first + 1) && name.count(it->first + 2) ) { // more attributes? - if(it->second.compare(0,it->second.length()-3,name[it->first + 1],0,it->second.length()-3) == 0 && // same attributes? + if (name.count(it->first + 1) && name.count(it->first + 2) ) { // more attributes? + if (it->second.compare(0,it->second.length()-3,name[it->first + 1],0,it->second.length()-3) == 0 && // same attributes? it->second.compare(0,it->second.length()-3,name[it->first + 2],0,it->second.length()-3) == 0 ) { it->second.erase(it->second.length()-1); diff --git a/src/atom.cpp b/src/atom.cpp index 7b15b731c7..daead53a83 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -1884,7 +1884,7 @@ void Atom::add_molecule(int narg, char **arg) int Atom::find_molecule(char *id) { - if(id == nullptr) return -1; + if (id == nullptr) return -1; int imol; for (imol = 0; imol < nmolecule; imol++) if (strcmp(id,molecules[imol]->id) == 0) return imol; @@ -2330,7 +2330,7 @@ void Atom::update_callback(int ifix) int Atom::find_custom(const char *name, int &flag) { - if(name == nullptr) return -1; + if (name == nullptr) return -1; for (int i = 0; i < nivector; i++) if (iname[i] && strcmp(iname[i],name) == 0) { diff --git a/src/comm_tiled.cpp b/src/comm_tiled.cpp index b4e03c6e57..6fa8ef7c37 100644 --- a/src/comm_tiled.cpp +++ b/src/comm_tiled.cpp @@ -201,7 +201,7 @@ void CommTiled::setup() cutghost[1] = cut * length1; length2 = h_inv[2]; cutghost[2] = cut * length2; - if (mode == Comm::MULTI){ + if (mode == Comm::MULTI) { for (i = 1; i <= ntypes; i++) { cutghostmulti[i][0] *= length0; cutghostmulti[i][1] *= length1; diff --git a/src/compute_hexorder_atom.cpp b/src/compute_hexorder_atom.cpp index b59d4d894d..aae935815c 100644 --- a/src/compute_hexorder_atom.cpp +++ b/src/compute_hexorder_atom.cpp @@ -260,8 +260,8 @@ inline void ComputeHexOrderAtom::calc_qn_complex(double delx, double dely, doubl inline void ComputeHexOrderAtom::calc_qn_trig(double delx, double dely, double &u, double &v) { double ntheta; - if(fabs(delx) <= MY_EPSILON) { - if(dely > 0.0) ntheta = ndegree * MY_PI / 2.0; + if (fabs(delx) <= MY_EPSILON) { + if (dely > 0.0) ntheta = ndegree * MY_PI / 2.0; else ntheta = ndegree * 3.0 * MY_PI / 2.0; } else ntheta = ndegree * atan(dely / delx); u = cos(ntheta); diff --git a/src/compute_orientorder_atom.cpp b/src/compute_orientorder_atom.cpp index b334654e82..b4f9662468 100644 --- a/src/compute_orientorder_atom.cpp +++ b/src/compute_orientorder_atom.cpp @@ -440,16 +440,16 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, for (int il = 0; il < nqlist; il++) { int l = qlist[il]; - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { qnm_r[il][m] = 0.0; qnm_i[il][m] = 0.0; } } - for(int ineigh = 0; ineigh < ncount; ineigh++) { + for (int ineigh = 0; ineigh < ncount; ineigh++) { const double * const r = rlist[ineigh]; double rmag = dist(r); - if(rmag <= MY_EPSILON) { + if (rmag <= MY_EPSILON) { return; } @@ -457,7 +457,7 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, double expphi_r = r[0]; double expphi_i = r[1]; double rxymag = sqrt(expphi_r*expphi_r+expphi_i*expphi_i); - if(rxymag <= MY_EPSILON) { + if (rxymag <= MY_EPSILON) { expphi_r = 1.0; expphi_i = 0.0; } else { @@ -476,14 +476,14 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, qnm_r[il][l] += polar_prefactor(l, 0, costheta); double expphim_r = expphi_r; double expphim_i = expphi_i; - for(int m = 1; m <= +l; m++) { + for (int m = 1; m <= +l; m++) { double prefactor = polar_prefactor(l, m, costheta); double ylm_r = prefactor * expphim_r; double ylm_i = prefactor * expphim_i; qnm_r[il][m+l] += ylm_r; qnm_i[il][m+l] += ylm_i; - if(m & 1) { + if (m & 1) { qnm_r[il][-m+l] -= ylm_r; qnm_i[il][-m+l] += ylm_i; } else { @@ -504,7 +504,7 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, double facn = 1.0 / ncount; for (int il = 0; il < nqlist; il++) { int l = qlist[il]; - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { qnm_r[il][m] *= facn; qnm_i[il][m] *= facn; } @@ -518,7 +518,7 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, int l = qlist[il]; double qnormfac = sqrt(MY_4PI/(2*l+1)); double qm_sum = 0.0; - for(int m = 0; m < 2*l+1; m++) + for (int m = 0; m < 2*l+1; m++) qm_sum += qnm_r[il][m]*qnm_r[il][m] + qnm_i[il][m]*qnm_i[il][m]; qn[jj++] = qnormfac * sqrt(qm_sum); } @@ -530,8 +530,8 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, for (int il = 0; il < nqlist; il++) { int l = qlist[il]; double wlsum = 0.0; - for(int m1 = 0; m1 < 2*l+1; m1++) { - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { + for (int m1 = 0; m1 < 2*l+1; m1++) { + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { int m = m1 + m2 - l; double qm1qm2_r = qnm_r[il][m1]*qnm_r[il][m2] - qnm_i[il][m1]*qnm_i[il][m2]; double qm1qm2_i = qnm_r[il][m1]*qnm_i[il][m2] + qnm_i[il][m1]*qnm_r[il][m2]; @@ -550,8 +550,8 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, for (int il = 0; il < nqlist; il++) { int l = qlist[il]; double wlsum = 0.0; - for(int m1 = 0; m1 < 2*l+1; m1++) { - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { + for (int m1 = 0; m1 < 2*l+1; m1++) { + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { int m = m1 + m2 - l; double qm1qm2_r = qnm_r[il][m1]*qnm_r[il][m2] - qnm_i[il][m1]*qnm_i[il][m2]; double qm1qm2_i = qnm_r[il][m1]*qnm_i[il][m2] + qnm_i[il][m1]*qnm_r[il][m2]; @@ -575,14 +575,14 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, int il = iqlcomp; int l = qlcomp; if (qn[il] < QEPSILON) - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { qn[jj++] = 0.0; qn[jj++] = 0.0; } else { double qnormfac = sqrt(MY_4PI/(2*l+1)); double qnfac = qnormfac/qn[il]; - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { qn[jj++] = qnm_r[il][m] * qnfac; qn[jj++] = qnm_i[il][m] * qnfac; } @@ -663,8 +663,8 @@ void ComputeOrientOrderAtom::init_clebsch_gordan() idxcg_count = 0; for (int il = 0; il < nqlist; il++) { int l = qlist[il]; - for(int m1 = 0; m1 < 2*l+1; m1++) - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) + for (int m1 = 0; m1 < 2*l+1; m1++) + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) idxcg_count++; } idxcg_max = idxcg_count; @@ -673,9 +673,9 @@ void ComputeOrientOrderAtom::init_clebsch_gordan() idxcg_count = 0; for (int il = 0; il < nqlist; il++) { int l = qlist[il]; - for(int m1 = 0; m1 < 2*l+1; m1++) { + for (int m1 = 0; m1 < 2*l+1; m1++) { aa2 = m1 - l; - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { bb2 = m2 - l; m = aa2 + bb2 + l; diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 93a9e68a16..16e2ade2af 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -70,7 +70,7 @@ nadapt(0), id_fix_diam(nullptr), id_fix_chg(nullptr), adapt(nullptr) if (iarg+3 > narg) error->all(FLERR,"Illegal fix adapt command"); nadapt++; iarg += 3; - } else if (strcmp(arg[iarg],"bond") == 0 ){ + } else if (strcmp(arg[iarg],"bond") == 0 ) { if (iarg+5 > narg) error->all(FLERR,"Illegal fix adapt command"); nadapt++; iarg += 5; @@ -110,7 +110,7 @@ nadapt(0), id_fix_diam(nullptr), id_fix_chg(nullptr), adapt(nullptr) nadapt++; iarg += 6; - } else if (strcmp(arg[iarg],"bond") == 0 ){ + } else if (strcmp(arg[iarg],"bond") == 0 ) { if (iarg+5 > narg) error->all(FLERR, "Illegal fix adapt command"); adapt[nadapt].which = BOND; int n = strlen(arg[iarg+1]) + 1; @@ -395,7 +395,7 @@ void FixAdapt::init() } delete [] pstyle; - } else if (ad->which == BOND){ + } else if (ad->which == BOND) { ad->bond = nullptr; anybond = 1; @@ -463,10 +463,10 @@ void FixAdapt::init() for (i = ad->ilo; i <= ad->ihi; i++) for (j = MAX(ad->jlo,i); j <= ad->jhi; j++) ad->array_orig[i][j] = ad->array[i][j]; - } else if (ad->which == PAIR && ad->pdim == 0){ + } else if (ad->which == PAIR && ad->pdim == 0) { ad->scalar_orig = *ad->scalar; - } else if (ad->which == BOND && ad->bdim == 1){ + } else if (ad->which == BOND && ad->bdim == 1) { for (i = ad->ilo; i <= ad->ihi; ++i ) ad->vector_orig[i] = ad->vector[i]; } @@ -565,7 +565,7 @@ void FixAdapt::change_settings() // set bond type array values: } else if (ad->which == BOND) { - if (ad->bdim == 1){ + if (ad->bdim == 1) { if (scaleflag) for (i = ad->ilo; i <= ad->ihi; ++i ) ad->vector[i] = value*ad->vector_orig[i]; diff --git a/src/fix_ave_histo_weight.cpp b/src/fix_ave_histo_weight.cpp index 1a638db742..61a36819b0 100644 --- a/src/fix_ave_histo_weight.cpp +++ b/src/fix_ave_histo_weight.cpp @@ -138,7 +138,7 @@ void FixAveHistoWeight::end_of_step() if (which[i] == X) { weights = &atom->x[0][j]; stride = 3; - } else if (which[i] == V){ + } else if (which[i] == V) { weights = &atom->v[0][j]; stride = 3; bin_atoms(&atom->v[0][j],3); diff --git a/src/fix_deform.cpp b/src/fix_deform.cpp index d4edc0d7f2..4aec94fc32 100644 --- a/src/fix_deform.cpp +++ b/src/fix_deform.cpp @@ -362,7 +362,7 @@ rfix(nullptr), irregular(nullptr), set(nullptr) FixDeform::~FixDeform() { - if(set) { + if (set) { for (int i = 0; i < 6; i++) { delete [] set[i].hstr; delete [] set[i].hratestr; diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index b4f6bc987d..674cda4529 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -779,11 +779,11 @@ void FixNH::setup(int /*vflag*/) // if it was read in from a restart file, leave it be if (t0 == 0.0) { - if(p_temp_flag) { + if (p_temp_flag) { t0 = p_temp; } else { t0 = temperature->compute_scalar(); - if(t0 < EPSILON) + if (t0 < EPSILON) error->all(FLERR, "Current temperature too close to zero, consider using ptemp setting"); } } diff --git a/src/fix_nh_sphere.cpp b/src/fix_nh_sphere.cpp index bd599d6731..4e7fb24039 100644 --- a/src/fix_nh_sphere.cpp +++ b/src/fix_nh_sphere.cpp @@ -45,7 +45,7 @@ FixNHSphere::FixNHSphere(LAMMPS *lmp, int narg, char **arg) : int iarg = 3; while (iarg < narg) { - if (strcmp(arg[iarg],"disc") == 0){ + if (strcmp(arg[iarg],"disc") == 0) { inertia = 0.5; if (domain->dimension != 2) error->all(FLERR, @@ -127,7 +127,7 @@ void FixNHSphere::nve_x() double **omega = atom->omega; int *mask = atom->mask; int nlocal = atom->nlocal; - if (dlm_flag == 0){ + if (dlm_flag == 0) { // d_mu/dt = omega cross mu // renormalize mu to dipole length double msq,scale,g[3]; @@ -174,7 +174,7 @@ void FixNHSphere::nve_x() // Q = I + vx + vx^2 * (1-c)/s^2 s2 = a[0]*a[0] + a[1]*a[1]; - if (s2 != 0.0){ // i.e. the vectors are not parallel + if (s2 != 0.0) { // i.e. the vectors are not parallel scale = (1.0 - a[2])/s2; Q[0][0] = 1.0 - scale*a[0]*a[0]; Q[0][1] = -scale*a[0]*a[1]; Q[0][2] = -a[0]; diff --git a/src/fix_nve_sphere.cpp b/src/fix_nve_sphere.cpp index 44a08638bf..cad821176b 100644 --- a/src/fix_nve_sphere.cpp +++ b/src/fix_nve_sphere.cpp @@ -187,7 +187,7 @@ void FixNVESphere::initial_integrate(int /*vflag*/) // Q = I + vx + vx^2 * (1-c)/s^2 s2 = a[0]*a[0] + a[1]*a[1]; - if (s2 != 0.0){ // i.e. the vectors are not parallel + if (s2 != 0.0) { // i.e. the vectors are not parallel scale = (1.0 - a[2])/s2; Q[0][0] = 1.0 - scale*a[0]*a[0]; diff --git a/src/fix_temp_csvr.cpp b/src/fix_temp_csvr.cpp index 674c436e9d..eedf24c387 100644 --- a/src/fix_temp_csvr.cpp +++ b/src/fix_temp_csvr.cpp @@ -105,7 +105,7 @@ double FixTempCSVR::sumnoises(int nn) { the system so it samples the canonical ensemble ---------------------------------------------------------------------- */ -double FixTempCSVR::resamplekin(double ekin_old, double ekin_new){ +double FixTempCSVR::resamplekin(double ekin_old, double ekin_new) { const double tdof = temperature->dof; const double c1 = exp(-update->dt/t_period); const double c2 = (1.0-c1)*ekin_new/ekin_old/tdof; diff --git a/src/hashlittle.cpp b/src/hashlittle.cpp index 5a8869bfea..a76e36050f 100644 --- a/src/hashlittle.cpp +++ b/src/hashlittle.cpp @@ -327,13 +327,13 @@ uint32_t LAMMPS_NS::hashlittle(const void *key, size_t length, uint32_t initval) h = 0; for (p = (uint32_t *)key, bytes=num_bytes; bytes >= (uint32_t) sizeof(uint32_t); - bytes-=sizeof(uint32_t), p++){ + bytes-=sizeof(uint32_t), p++) { h = (h^(*p))*MAXINT_DIV_PHI; } /* Then take care of the remaining bytes, if any */ rest = 0; - for (byteptr = (char *)p; bytes > 0; bytes--, byteptr++){ + for (byteptr = (char *)p; bytes > 0; bytes--, byteptr++) { rest = (rest<<8) | (*byteptr); } diff --git a/src/info.cpp b/src/info.cpp index 085e4e65ea..5202610f9a 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -654,20 +654,20 @@ void Info::available_styles(FILE * out, int flags) fputs("\nStyles information:\n",out); - if(flags & ATOM_STYLES) atom_styles(out); - if(flags & INTEGRATE_STYLES) integrate_styles(out); - if(flags & MINIMIZE_STYLES) minimize_styles(out); - if(flags & PAIR_STYLES) pair_styles(out); - if(flags & BOND_STYLES) bond_styles(out); - if(flags & ANGLE_STYLES) angle_styles(out); - if(flags & DIHEDRAL_STYLES) dihedral_styles(out); - if(flags & IMPROPER_STYLES) improper_styles(out); - if(flags & KSPACE_STYLES) kspace_styles(out); - if(flags & FIX_STYLES) fix_styles(out); - if(flags & COMPUTE_STYLES) compute_styles(out); - if(flags & REGION_STYLES) region_styles(out); - if(flags & DUMP_STYLES) dump_styles(out); - if(flags & COMMAND_STYLES) command_styles(out); + if (flags & ATOM_STYLES) atom_styles(out); + if (flags & INTEGRATE_STYLES) integrate_styles(out); + if (flags & MINIMIZE_STYLES) minimize_styles(out); + if (flags & PAIR_STYLES) pair_styles(out); + if (flags & BOND_STYLES) bond_styles(out); + if (flags & ANGLE_STYLES) angle_styles(out); + if (flags & DIHEDRAL_STYLES) dihedral_styles(out); + if (flags & IMPROPER_STYLES) improper_styles(out); + if (flags & KSPACE_STYLES) kspace_styles(out); + if (flags & FIX_STYLES) fix_styles(out); + if (flags & COMPUTE_STYLES) compute_styles(out); + if (flags & REGION_STYLES) region_styles(out); + if (flags & DUMP_STYLES) dump_styles(out); + if (flags & COMMAND_STYLES) command_styles(out); } void Info::atom_styles(FILE *out) @@ -935,31 +935,31 @@ bool Info::has_style(const std::string &category, const std::string &name) { if ( category == "atom" ) { return find_style(lmp, atom->avec_map, name, false); - } else if( category == "integrate" ) { + } else if ( category == "integrate" ) { return find_style(lmp, update->integrate_map, name, true); - } else if( category == "minimize" ) { + } else if ( category == "minimize" ) { return find_style(lmp, update->minimize_map, name, true); - } else if( category == "pair" ) { + } else if ( category == "pair" ) { return find_style(lmp, force->pair_map, name, true); - } else if( category == "bond" ) { + } else if ( category == "bond" ) { return find_style(lmp, force->bond_map, name, true); - } else if( category == "angle" ) { + } else if ( category == "angle" ) { return find_style(lmp, force->angle_map, name, true); - } else if( category == "dihedral" ) { + } else if ( category == "dihedral" ) { return find_style(lmp, force->dihedral_map, name, true); - } else if( category == "improper" ) { + } else if ( category == "improper" ) { return find_style(lmp, force->improper_map, name, true); - } else if( category == "kspace" ) { + } else if ( category == "kspace" ) { return find_style(lmp, force->kspace_map, name, true); - } else if( category == "fix" ) { + } else if ( category == "fix" ) { return find_style(lmp, modify->fix_map, name, true); - } else if( category == "compute" ) { + } else if ( category == "compute" ) { return find_style(lmp, modify->compute_map, name, true); - } else if( category == "region" ) { + } else if ( category == "region" ) { return find_style(lmp, domain->region_map, name, false); - } else if( category == "dump" ) { + } else if ( category == "dump" ) { return find_style(lmp, output->dump_map, name, false); - } else if( category == "command" ) { + } else if ( category == "command" ) { return find_style(lmp, input->command_map, name, false); } return false; @@ -969,31 +969,31 @@ std::vector Info::get_available_styles(const std::string &category) { if ( category == "atom" ) { return get_style_names(atom->avec_map); - } else if( category == "integrate" ) { + } else if ( category == "integrate" ) { return get_style_names(update->integrate_map); - } else if( category == "minimize" ) { + } else if ( category == "minimize" ) { return get_style_names(update->minimize_map); - } else if( category == "pair" ) { + } else if ( category == "pair" ) { return get_style_names(force->pair_map); - } else if( category == "bond" ) { + } else if ( category == "bond" ) { return get_style_names(force->bond_map); - } else if( category == "angle" ) { + } else if ( category == "angle" ) { return get_style_names(force->angle_map); - } else if( category == "dihedral" ) { + } else if ( category == "dihedral" ) { return get_style_names(force->dihedral_map); - } else if( category == "improper" ) { + } else if ( category == "improper" ) { return get_style_names(force->improper_map); - } else if( category == "kspace" ) { + } else if ( category == "kspace" ) { return get_style_names(force->kspace_map); - } else if( category == "fix" ) { + } else if ( category == "fix" ) { return get_style_names(modify->fix_map); - } else if( category == "compute" ) { + } else if ( category == "compute" ) { return get_style_names(modify->compute_map); - } else if( category == "region" ) { + } else if ( category == "region" ) { return get_style_names(domain->region_map); - } else if( category == "dump" ) { + } else if ( category == "dump" ) { return get_style_names(output->dump_map); - } else if( category == "command" ) { + } else if ( category == "command" ) { return get_style_names(input->command_map); } return std::vector(); @@ -1005,7 +1005,7 @@ static std::vector get_style_names(std::map std::vector names; names.reserve(styles->size()); - for(auto const& kv : *styles) { + for (auto const& kv : *styles) { // skip "secret" styles if (isupper(kv.first[0])) continue; names.push_back(kv.first); @@ -1049,7 +1049,7 @@ static void print_columns(FILE *fp, std::map *styles) // std::map keys are already sorted int pos = 80; - for(typename std::map::iterator it = styles->begin(); it != styles->end(); ++it) { + for (typename std::map::iterator it = styles->begin(); it != styles->end(); ++it) { const std::string &style_name = it->first; // skip "secret" styles @@ -1121,8 +1121,8 @@ bool Info::has_exceptions() { } bool Info::has_package(const char * package_name) { - for(int i = 0; LAMMPS::installed_packages[i] != nullptr; ++i) { - if(strcmp(package_name, LAMMPS::installed_packages[i]) == 0) { + for (int i = 0; LAMMPS::installed_packages[i] != nullptr; ++i) { + if (strcmp(package_name, LAMMPS::installed_packages[i]) == 0) { return true; } } diff --git a/src/library.cpp b/src/library.cpp index 17ca454b3c..00a922f98b 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -2444,7 +2444,7 @@ void lammps_scatter_atoms(void *handle, char *name, int type, int count, void *d int natoms = static_cast (lmp->atom->natoms); void *vptr = lmp->atom->extract(name); - if(vptr == nullptr) { + if (vptr == nullptr) { if (lmp->comm->me == 0) lmp->error->warning(FLERR, "lammps_scatter_atoms: unknown property name"); @@ -2561,7 +2561,7 @@ void lammps_scatter_atoms_subset(void *handle, char *name, int type, int count, } void *vptr = lmp->atom->extract(name); - if(vptr == nullptr) { + if (vptr == nullptr) { if (lmp->comm->me == 0) lmp->error->warning(FLERR, "lammps_scatter_atoms_subset: unknown property name"); @@ -2722,7 +2722,7 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data) return; } - if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; else vptr = (void *) lmp->modify->fix[fcid]->array_atom; } @@ -2751,7 +2751,7 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data) if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep) lmp->modify->compute[fcid]->compute_peratom(); - if(count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; else vptr = (void *) lmp->modify->compute[fcid]->array_atom; @@ -2775,7 +2775,7 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data) lmp->error->warning(FLERR,"lammps_gather: property/atom has count=1"); return; } - if(ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; + if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; else vptr = (void *) lmp->atom->dvector[fcid]; } @@ -2942,7 +2942,7 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d return; } - if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; else vptr = (void *) lmp->modify->fix[fcid]->array_atom; } @@ -2971,7 +2971,7 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep) lmp->modify->compute[fcid]->compute_peratom(); - if(count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; else vptr = (void *) lmp->modify->compute[fcid]->array_atom; @@ -2998,7 +2998,7 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d "property/atom has count=1"); return; } - if(ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; + if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; else vptr = (void *) lmp->atom->dvector[fcid]; } @@ -3183,7 +3183,7 @@ void lammps_gather_subset(void *handle, char *name, return; } - if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; else vptr = (void *) lmp->modify->fix[fcid]->array_atom; } @@ -3212,7 +3212,7 @@ void lammps_gather_subset(void *handle, char *name, if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep) lmp->modify->compute[fcid]->compute_peratom(); - if(count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; else vptr = (void *) lmp->modify->compute[fcid]->array_atom; @@ -3239,7 +3239,7 @@ void lammps_gather_subset(void *handle, char *name, "property/atom has count=1"); return; } - if(ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; + if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; else vptr = (void *) lmp->atom->dvector[fcid]; } @@ -3414,7 +3414,7 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data) return; } - if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; else vptr = (void *) lmp->modify->fix[fcid]->array_atom; } @@ -3443,7 +3443,7 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data) if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep) lmp->modify->compute[fcid]->compute_peratom(); - if(count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; else vptr = (void *) lmp->modify->compute[fcid]->array_atom; @@ -3467,12 +3467,12 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data) lmp->error->warning(FLERR,"lammps_scatter: property/atom has count=1"); return; } - if(ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; + if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; else vptr = (void *) lmp->atom->dvector[fcid]; } - if(vptr == nullptr) { + if (vptr == nullptr) { if (lmp->comm->me == 0) lmp->error->warning(FLERR,"lammps_scatter: unknown property name"); return; @@ -3612,7 +3612,7 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count, return; } - if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; else vptr = (void *) lmp->modify->fix[fcid]->array_atom; } @@ -3641,7 +3641,7 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count, if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep) lmp->modify->compute[fcid]->compute_peratom(); - if(count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; else vptr = (void *) lmp->modify->compute[fcid]->array_atom; } @@ -3666,11 +3666,11 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count, "property/atom has count=1"); return; } - if(ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; + if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; else vptr = (void *) lmp->atom->dvector[fcid]; } - if(vptr == nullptr) { + if (vptr == nullptr) { if (lmp->comm->me == 0) lmp->error->warning(FLERR,"lammps_scatter_atoms_subset: " "unknown property name"); @@ -4025,7 +4025,7 @@ int lammps_neighlist_num_elements(void *handle, int idx) { LAMMPS * lmp = (LAMMPS *) handle; Neighbor * neighbor = lmp->neighbor; - if(idx < 0 || idx >= neighbor->nlist) { + if (idx < 0 || idx >= neighbor->nlist) { return -1; } @@ -4053,13 +4053,13 @@ void lammps_neighlist_element_neighbors(void *handle, int idx, int element, int *numneigh = 0; *neighbors = nullptr; - if(idx < 0 || idx >= neighbor->nlist) { + if (idx < 0 || idx >= neighbor->nlist) { return; } NeighList * list = neighbor->lists[idx]; - if(element < 0 || element >= list->inum) { + if (element < 0 || element >= list->inum) { return; } @@ -4645,7 +4645,7 @@ void lammps_set_fix_external_callback(void *handle, char *id, FixExternalFnPtr c Fix *fix = lmp->modify->fix[ifix]; - if (strcmp("external",fix->style) != 0){ + if (strcmp("external",fix->style) != 0) { char str[128]; snprintf(str, 128, "Fix '%s' is not of style external!", id); lmp->error->all(FLERR,str); @@ -4819,7 +4819,7 @@ int lammps_get_last_error_message(void *handle, char *buffer, int buf_size) { Error *error = lmp->error; buffer[0] = buffer[buf_size-1] = '\0'; - if(!error->get_last_error().empty()) { + if (!error->get_last_error().empty()) { int error_type = error->get_last_error_type(); strncpy(buffer, error->get_last_error().c_str(), buf_size-1); error->set_last_error("", ERROR_NONE); diff --git a/src/modify.cpp b/src/modify.cpp index 2d0c23d125..f3ebb03c38 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -1329,7 +1329,7 @@ void Modify::delete_compute(const std::string &id) int Modify::find_compute(const std::string &id) { - if(id.empty()) return -1; + if (id.empty()) return -1; for (int icompute = 0; icompute < ncompute; icompute++) if (id == compute[icompute]->id) return icompute; return -1; diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 7761aae721..a76bf78c24 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -720,11 +720,11 @@ int Neighbor::init_pair() lists[i]->index = i; lists[i]->requestor = requests[i]->requestor; - if(requests[i]->pair) { + if (requests[i]->pair) { lists[i]->requestor_type = NeighList::PAIR; - } else if(requests[i]->fix) { + } else if (requests[i]->fix) { lists[i]->requestor_type = NeighList::FIX; - } else if(requests[i]->compute) { + } else if (requests[i]->compute) { lists[i]->requestor_type = NeighList::COMPUTE; } diff --git a/src/pair_coul_streitz.cpp b/src/pair_coul_streitz.cpp index 7c4061d22d..01fc0adac3 100644 --- a/src/pair_coul_streitz.cpp +++ b/src/pair_coul_streitz.cpp @@ -113,10 +113,10 @@ void PairCoulStreitz::settings(int narg, char **arg) cut_coul = utils::numeric(FLERR,arg[0],false,lmp); - if (strcmp(arg[1],"wolf") == 0){ + if (strcmp(arg[1],"wolf") == 0) { kspacetype = 1; g_wolf = utils::numeric(FLERR,arg[2],false,lmp); - } else if (strcmp(arg[1],"ewald") == 0){ + } else if (strcmp(arg[1],"ewald") == 0) { ewaldflag = pppmflag = 1; kspacetype = 2; } else { @@ -297,7 +297,7 @@ void PairCoulStreitz::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/potential_file_reader.cpp b/src/potential_file_reader.cpp index d41902c10d..2ad8bbb764 100644 --- a/src/potential_file_reader.cpp +++ b/src/potential_file_reader.cpp @@ -58,7 +58,7 @@ PotentialFileReader::PotentialFileReader(LAMMPS *lmp, try { reader = open_potential(filename); - if(!reader) { + if (!reader) { error->one(FLERR, fmt::format("cannot open {} potential file {}", potential_name, filename)); } } catch (FileReaderException &e) { diff --git a/src/reader_native.cpp b/src/reader_native.cpp index 9fe57198fd..a185f5ab3a 100644 --- a/src/reader_native.cpp +++ b/src/reader_native.cpp @@ -169,7 +169,7 @@ bigint ReaderNative::read_header(double box[3][3], int &boxinfo, int &triclinic, labels[tokens.next()] = nwords++; } - if(nwords == 0) { + if (nwords == 0) { return 1; } diff --git a/src/region.cpp b/src/region.cpp index cd0464e10e..2fe2d88cef 100644 --- a/src/region.cpp +++ b/src/region.cpp @@ -496,7 +496,7 @@ void Region::set_velocity() prev[3] = theta; } - if (varshape){ + if (varshape) { set_velocity_shape(); } } @@ -514,12 +514,12 @@ void Region::velocity_contact(double *vwall, double *x, int ic) vwall[0] = vwall[1] = vwall[2] = 0.0; - if (moveflag){ + if (moveflag) { vwall[0] = v[0]; vwall[1] = v[1]; vwall[2] = v[2]; } - if (rotateflag){ + if (rotateflag) { xc[0] = x[0] - contact[ic].delx; xc[1] = x[1] - contact[ic].dely; xc[2] = x[2] - contact[ic].delz; diff --git a/src/region_block.cpp b/src/region_block.cpp index 385fcdd90a..4e433f424a 100644 --- a/src/region_block.cpp +++ b/src/region_block.cpp @@ -320,7 +320,7 @@ int RegBlock::surface_exterior(double *x, double cutoff) else zp = x[2]; } else { mindist = BIG; - for (int i = 0; i < 6; i++){ + for (int i = 0; i < 6; i++) { if (open_faces[i]) continue; dist = find_closest_point(i,x,xc,yc,zc); if (dist < mindist) { @@ -361,7 +361,7 @@ double RegBlock::find_closest_point(int i, double *x, // check if point projects inside of face - if (inside_face(xproj, i)){ + if (inside_face(xproj, i)) { d2 = d2min = dot*dot; xc = xproj[0] + corners[i][0][0]; yc = xproj[1] + corners[i][0][1]; diff --git a/src/region_cone.cpp b/src/region_cone.cpp index 72d315c16e..de3f8b254b 100644 --- a/src/region_cone.cpp +++ b/src/region_cone.cpp @@ -508,7 +508,7 @@ int RegCone::surface_exterior(double *x, double cutoff) distsq = BIG; - if (!open_faces[2]){ + if (!open_faces[2]) { point_on_line_segment(corner1,corner2,x,xp); distsq = closest(x,xp,nearest,distsq); crad = -2.0*(radiuslo + (nearest[1]-lo)*(radiushi-radiuslo)/(hi-lo)); @@ -573,7 +573,7 @@ int RegCone::surface_exterior(double *x, double cutoff) distsq = BIG; - if (!open_faces[2]){ + if (!open_faces[2]) { point_on_line_segment(corner1,corner2,x,xp); distsq = closest(x,xp,nearest,distsq); crad = -2.0*(radiuslo + (nearest[2]-lo)*(radiushi-radiuslo)/(hi-lo)); diff --git a/src/region_cylinder.cpp b/src/region_cylinder.cpp index 306026cd7e..9e94a53046 100644 --- a/src/region_cylinder.cpp +++ b/src/region_cylinder.cpp @@ -520,7 +520,7 @@ int RegCylinder::surface_exterior(double *x, double cutoff) else d2 = dr2 + dx*dx; if (d2 < d2prev) { xp = hi; - if (r < radius){ + if (r < radius) { yp = x[1]; zp = x[2]; } @@ -572,7 +572,7 @@ int RegCylinder::surface_exterior(double *x, double cutoff) dr = r - radius; dr2 = dr*dr; - if (!open_faces[2]){ + if (!open_faces[2]) { xp = c1 + del1*radius/r; zp = c2 + del2*radius/r; if (x[1] < lo) { diff --git a/src/region_intersect.cpp b/src/region_intersect.cpp index beb8bb42b1..fb2b6239b1 100644 --- a/src/region_intersect.cpp +++ b/src/region_intersect.cpp @@ -313,7 +313,7 @@ void RegIntersect::write_restart(FILE *fp) fwrite(style, 1, sizestyle, fp); fwrite(&nregion,sizeof(int),1,fp); - for (int ilist = 0; ilist < nregion; ilist++){ + for (int ilist = 0; ilist < nregion; ilist++) { domain->regions[list[ilist]]->write_restart(fp); } } diff --git a/src/region_prism.cpp b/src/region_prism.cpp index 3ee45a4255..51c67c706c 100644 --- a/src/region_prism.cpp +++ b/src/region_prism.cpp @@ -393,7 +393,7 @@ void RegPrism::find_nearest(double *x, double &xp, double &yp, double &zp) xproj[0] = x[0] - dot*face[iface][0]; xproj[1] = x[1] - dot*face[iface][1]; xproj[2] = x[2] - dot*face[iface][2]; - if (inside_tri(xproj,corners[i],corners[j],corners[k],face[iface])){ + if (inside_tri(xproj,corners[i],corners[j],corners[k],face[iface])) { distsq = closest(x,xproj,nearest,distsq); } else { diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index b254933531..37ebcd07fb 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -24,8 +24,8 @@ using namespace LAMMPS_NS; -TokenizerException::TokenizerException(const std::string &msg, const std::string &token){ - if(token.empty()) { +TokenizerException::TokenizerException(const std::string &msg, const std::string &token) { + if (token.empty()) { message = msg; } else { message = fmt::format("{}: '{}'", msg, token); @@ -83,12 +83,12 @@ bool Tokenizer::contains(const std::string &str) const { * * \param n number of tokens to skip over */ void Tokenizer::skip(int n) { - for(int i = 0; i < n; ++i) { - if(!has_next()) throw TokenizerException("No more tokens", ""); + for (int i = 0; i < n; ++i) { + if (!has_next()) throw TokenizerException("No more tokens", ""); size_t end = text.find_first_of(separators, start); - if(end == std::string::npos) { + if (end == std::string::npos) { start = end; } else { start = text.find_first_not_of(separators, end+1); @@ -107,11 +107,11 @@ bool Tokenizer::has_next() const { * * \return string with the next token */ std::string Tokenizer::next() { - if(!has_next()) throw TokenizerException("No more tokens", ""); + if (!has_next()) throw TokenizerException("No more tokens", ""); size_t end = text.find_first_of(separators, start); - if(end == std::string::npos) { + if (end == std::string::npos) { std::string token = text.substr(start); start = end; return token; @@ -210,7 +210,7 @@ std::string ValueTokenizer::next_string() { int ValueTokenizer::next_int() { if (has_next()) { std::string current = tokens.next(); - if(!utils::is_integer(current)) { + if (!utils::is_integer(current)) { throw InvalidIntegerException(current); } int value = atoi(current.c_str()); @@ -225,7 +225,7 @@ int ValueTokenizer::next_int() { bigint ValueTokenizer::next_bigint() { if (has_next()) { std::string current = tokens.next(); - if(!utils::is_integer(current)) { + if (!utils::is_integer(current)) { throw InvalidIntegerException(current); } bigint value = ATOBIGINT(current.c_str()); @@ -240,7 +240,7 @@ bigint ValueTokenizer::next_bigint() { tagint ValueTokenizer::next_tagint() { if (has_next()) { std::string current = tokens.next(); - if(!utils::is_integer(current)) { + if (!utils::is_integer(current)) { throw InvalidIntegerException(current); } tagint value = ATOTAGINT(current.c_str()); @@ -255,7 +255,7 @@ tagint ValueTokenizer::next_tagint() { double ValueTokenizer::next_double() { if (has_next()) { std::string current = tokens.next(); - if(!utils::is_double(current)) { + if (!utils::is_double(current)) { throw InvalidFloatException(current); } double value = atof(current.c_str()); diff --git a/src/update.cpp b/src/update.cpp index a8a698a7f3..d52e5a742f 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -324,7 +324,7 @@ void Update::create_integrate(int narg, char **arg, int trysuffix) int sflag; - if(narg-1 > 0) { + if (narg-1 > 0) { new_integrate(arg[0],narg-1,&arg[1],trysuffix,sflag); } else { new_integrate(arg[0],0,nullptr,trysuffix,sflag); diff --git a/src/utils.cpp b/src/utils.cpp index 8bd36a8065..64283aa9c5 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -618,7 +618,7 @@ size_t utils::count_words(const std::string &text, const std::string &separators size_t end = text.find_first_of(separators, start); ++count; - if(end == std::string::npos) { + if (end == std::string::npos) { return count; } else { start = text.find_first_not_of(separators, end + 1); @@ -806,7 +806,7 @@ std::string utils::path_join(const std::string &a, const std::string &b) { bool utils::file_is_readable(const std::string &path) { FILE * fp = fopen(path.c_str(), "r"); - if(fp) { + if (fp) { fclose(fp); return true; } @@ -828,13 +828,13 @@ std::string utils::get_potential_file_path(const std::string &path) { std::string filepath = path; std::string filename = utils::path_basename(path); - if(utils::file_is_readable(filepath)) { + if (utils::file_is_readable(filepath)) { return filepath; } else { // try the environment variable directory const char *var = getenv("LAMMPS_POTENTIALS"); - if (var != nullptr){ + if (var != nullptr) { Tokenizer dirs(var,OS_PATH_VAR_SEP); while (dirs.has_next()) { @@ -935,12 +935,12 @@ FILE *utils::open_potential(const std::string &name, LAMMPS *lmp, std::string filepath = get_potential_file_path(name); - if(!filepath.empty()) { + if (!filepath.empty()) { std::string unit_style = lmp->update->unit_style; std::string date = get_potential_date(filepath, "potential"); std::string units = get_potential_units(filepath, "potential"); - if(!date.empty() && (me == 0)) { + if (!date.empty() && (me == 0)) { logmesg(lmp, fmt::format("Reading potential file {} " "with DATE: {}\n", name, date)); } diff --git a/src/variable.cpp b/src/variable.cpp index c339700787..bd5fc6cf8c 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -2755,7 +2755,7 @@ double Variable::collapse_tree(Tree *tree) ivalue3-ivalue1+1 < ivalue2 ) error->all(FLERR,"Invalid math function in variable formula"); if (update->ntimestep < ivalue1) tree->value = ivalue1; - //else if (update->ntimestep <= ivalue3){ + //else if (update->ntimestep <= ivalue3) { else { tree->value = ivalue1; double logsp = ivalue1; @@ -3664,7 +3664,7 @@ int Variable::math_function(char *word, char *contents, Tree **tree, print_var_error(FLERR,"Invalid math function in variable formula",ivar); double value; if (update->ntimestep < ivalue1) value = ivalue1; - //else if (update->ntimestep <= ivalue3){ + //else if (update->ntimestep <= ivalue3) { else { value = ivalue1; double logsp = ivalue1; From 4f5192fa864c30938d1e12bc19b709e5f87d55bb Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Dec 2020 09:21:11 -0500 Subject: [PATCH 30/51] silence compiler warnings --- src/USER-BOCS/fix_bocs.cpp | 2 +- src/USER-DRUDE/fix_tgnh_drude.cpp | 2 -- src/USER-REACTION/fix_bond_react.cpp | 10 +++++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/USER-BOCS/fix_bocs.cpp b/src/USER-BOCS/fix_bocs.cpp index 6a984edf60..438766e351 100644 --- a/src/USER-BOCS/fix_bocs.cpp +++ b/src/USER-BOCS/fix_bocs.cpp @@ -688,7 +688,7 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) int numBadVolumeIntervals = 0; // count these for message float f1, f2; int test_sscanf; - for (int i = 0; i < inputLines.size(); ++i) { + for (int i = 0; i < (int)inputLines.size(); ++i) { lineNum++; // count each line processed now so lineNum messages can be 1-based test_sscanf = sscanf(inputLines.at(i).c_str()," %f , %f ",&f1, &f2); if (test_sscanf == 2) diff --git a/src/USER-DRUDE/fix_tgnh_drude.cpp b/src/USER-DRUDE/fix_tgnh_drude.cpp index 167d8376db..d660f16c4a 100644 --- a/src/USER-DRUDE/fix_tgnh_drude.cpp +++ b/src/USER-DRUDE/fix_tgnh_drude.cpp @@ -1101,8 +1101,6 @@ void FixTGNHDrude::remap() double oldlo,oldhi; double expfac; - double **x = atom->x; - int *mask = atom->mask; int nlocal = atom->nlocal; double *h = domain->h; diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index e5413c6af7..8d6b1b27ac 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -3385,25 +3385,25 @@ void FixBondReact::ReadConstraints(char *line, int myrxn) strcpy(constraintstr[myrxn],"("); // string for boolean constraint logic for (int i = 0; i < nconstraints[myrxn]; i++) { readline(line); - if (ptr = strrchr(line,'(')) { // reverse char search + if ((ptr = strrchr(line,'('))) { // reverse char search strncat(constraintstr[myrxn],line,ptr-line+1); line = ptr + 1; } // 'C' indicates where to sub in next constraint strcat(constraintstr[myrxn],"C"); - if (ptr = strchr(line,')')) { + if ((ptr = strchr(line,')'))) { strncat(constraintstr[myrxn],ptr,strrchr(line,')')-ptr+1); } - if (ptr = strstr(line,"&&")) { + if ((ptr = strstr(line,"&&"))) { strcat(constraintstr[myrxn],"&&"); *ptr = '\0'; - } else if (ptr = strstr(line,"||")) { + } else if ((ptr = strstr(line,"||"))) { strcat(constraintstr[myrxn],"||"); *ptr = '\0'; } else if (i+1 < nconstraints[myrxn]) { strcat(constraintstr[myrxn],"&&"); } - if (ptr = strchr(line,')')) + if ((ptr = strchr(line,')'))) *ptr = '\0'; sscanf(line,"%s",constraint_type); if (strcmp(constraint_type,"distance") == 0) { From 28de7e351a847257239282b69b6b8eacbc2a8918 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Dec 2020 09:23:47 -0500 Subject: [PATCH 31/51] fix off-by-one bug (arrhenius type constraint uses 5 parameters) --- src/USER-REACTION/fix_bond_react.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/USER-REACTION/fix_bond_react.h b/src/USER-REACTION/fix_bond_react.h index a66f57c2bc..ad8d657e74 100644 --- a/src/USER-REACTION/fix_bond_react.h +++ b/src/USER-REACTION/fix_bond_react.h @@ -33,7 +33,7 @@ class FixBondReact : public Fix { enum {MAXLINE=256}; // max length of line read from files enum {MAXCONIDS=4}; // max # of IDs used by any constraint - enum {MAXCONPAR=4}; // max # of constraint parameters + enum {MAXCONPAR=5}; // max # of constraint parameters FixBondReact(class LAMMPS *, int, char **); ~FixBondReact(); From 51a20175c91b6dbf3306c0df78cb001048dace7f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Dec 2020 09:27:47 -0500 Subject: [PATCH 32/51] more code formatting consistency changes for loops and conditionals --- src/COLLOID/pair_lubricate_poly.cpp | 2 +- src/COMPRESS/zstd_file_writer.cpp | 6 +- src/KOKKOS/atom_vec_angle_kokkos.cpp | 2 +- src/KOKKOS/atom_vec_dpd_kokkos.cpp | 2 +- src/KOKKOS/atom_vec_kokkos.cpp | 6 +- src/KOKKOS/atom_vec_molecular_kokkos.cpp | 2 +- src/KOKKOS/atom_vec_sphere_kokkos.cpp | 4 +- .../compute_orientorder_atom_kokkos.cpp | 6 +- src/KOKKOS/fix_enforce2d_kokkos.cpp | 2 +- src/KOKKOS/fix_eos_table_rx_kokkos.cpp | 2 +- src/KOKKOS/fix_qeq_reax_kokkos.cpp | 16 ++--- src/KOKKOS/fix_rx_kokkos.cpp | 12 ++-- src/KOKKOS/nbin_kokkos.cpp | 2 +- src/KOKKOS/nbin_ssa_kokkos.cpp | 2 +- src/KOKKOS/npair_kokkos.cpp | 2 +- src/KOKKOS/npair_ssa_kokkos.cpp | 2 +- src/KOKKOS/pair_exp6_rx_kokkos.cpp | 2 +- src/KOKKOS/pair_reaxc_kokkos.cpp | 38 +++++------ src/KOKKOS/pair_table_rx_kokkos.cpp | 4 +- src/KOKKOS/verlet_kokkos.cpp | 12 ++-- src/KSPACE/pair_lj_long_tip4p_long.cpp | 4 +- src/KSPACE/pppm_disp.cpp | 8 +-- src/MANYBODY/fix_qeq_comb.cpp | 2 +- src/MANYBODY/pair_comb.cpp | 6 +- src/MANYBODY/pair_comb3.cpp | 18 ++--- src/MANYBODY/pair_eam_cd.cpp | 4 +- src/MANYBODY/pair_eim.cpp | 4 +- src/MANYBODY/pair_gw.cpp | 2 +- src/MANYBODY/pair_gw_zbl.cpp | 2 +- src/MANYBODY/pair_lcbop.cpp | 52 +++++++------- src/MANYBODY/pair_nb3b_harmonic.cpp | 2 +- src/MANYBODY/pair_sw.cpp | 2 +- src/MANYBODY/pair_tersoff.cpp | 2 +- src/MANYBODY/pair_tersoff_mod.cpp | 2 +- src/MANYBODY/pair_tersoff_mod_c.cpp | 2 +- src/MANYBODY/pair_tersoff_zbl.cpp | 2 +- src/MANYBODY/pair_vashishta.cpp | 2 +- src/MC/fix_gcmc.cpp | 3 +- src/MC/fix_widom.cpp | 3 +- src/MISC/dump_xtc.cpp | 6 +- src/MPIIO/dump_cfg_mpiio.cpp | 2 +- src/MSCG/fix_mscg.cpp | 2 +- src/OPT/pair_eam_opt.cpp | 4 +- src/QEQ/fix_qeq.cpp | 38 +++++------ src/QEQ/fix_qeq_dynamic.cpp | 4 +- src/QEQ/fix_qeq_fire.cpp | 4 +- src/QEQ/fix_qeq_point.cpp | 6 +- src/QEQ/fix_qeq_shielded.cpp | 10 +-- src/QEQ/fix_qeq_slater.cpp | 8 +-- src/SHOCK/fix_append_atoms.cpp | 4 +- src/SHOCK/fix_msst.cpp | 58 ++++++++-------- src/SHOCK/fix_nphug.cpp | 6 +- src/SHOCK/fix_wall_piston.cpp | 4 +- src/USER-BOCS/compute_pressure_bocs.cpp | 4 +- src/USER-BOCS/fix_bocs.cpp | 12 ++-- src/USER-COLVARS/colvarproxy_lammps.cpp | 4 +- src/USER-COLVARS/fix_colvars.cpp | 2 +- src/USER-DIFFRACTION/compute_saed.cpp | 16 ++--- src/USER-DIFFRACTION/compute_xrd.cpp | 16 ++--- src/USER-DIFFRACTION/fix_saed_vtk.cpp | 26 +++---- src/USER-DPD/fix_rx.cpp | 6 +- src/USER-DPD/pair_table_rx.cpp | 4 +- src/USER-INTEL/fix_intel.cpp | 6 +- src/USER-INTEL/pair_buck_coul_cut_intel.cpp | 2 +- src/USER-INTEL/pair_buck_coul_long_intel.cpp | 2 +- src/USER-INTEL/pair_buck_intel.cpp | 2 +- .../pair_lj_charmm_coul_long_intel.cpp | 2 +- .../pair_lj_cut_coul_long_intel.cpp | 2 +- src/USER-INTEL/pair_tersoff_intel.cpp | 2 +- src/USER-MANIFOLD/fix_manifoldforce.cpp | 2 +- src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp | 16 ++--- src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp | 21 +++--- src/USER-MANIFOLD/manifold_gaussian_bump.cpp | 6 +- src/USER-MANIFOLD/manifold_thylakoid.cpp | 10 +-- .../manifold_thylakoid_shared.cpp | 2 +- src/USER-MESODPD/pair_edpd.cpp | 2 +- src/USER-MESODPD/pair_mdpd.cpp | 2 +- src/USER-MESODPD/pair_tdpd.cpp | 2 +- src/USER-MGPT/mgpt_readpot.cpp | 6 +- src/USER-MGPT/pair_mgpt.cpp | 30 ++++---- src/USER-MISC/angle_fourier.cpp | 4 +- src/USER-MISC/angle_fourier_simple.cpp | 4 +- src/USER-MISC/angle_gaussian.cpp | 2 +- src/USER-MISC/bond_gaussian.cpp | 2 +- src/USER-MISC/compute_entropy_atom.cpp | 2 +- src/USER-MISC/compute_stress_mop.cpp | 8 +-- src/USER-MISC/compute_stress_mop_profile.cpp | 8 +-- src/USER-MISC/dihedral_fourier.cpp | 10 +-- src/USER-MISC/dihedral_nharmonic.cpp | 4 +- src/USER-MISC/dihedral_spherical.cpp | 20 +++--- src/USER-MISC/fix_flow_gauss.cpp | 8 +-- src/USER-MISC/fix_imd.cpp | 4 +- src/USER-MISC/fix_ipi.cpp | 2 +- src/USER-MISC/fix_propel_self.cpp | 6 +- src/USER-MISC/fix_rhok.cpp | 10 +-- src/USER-MISC/fix_ti_spring.cpp | 4 +- src/USER-MISC/improper_fourier.cpp | 6 +- src/USER-MISC/pair_e3b.cpp | 2 +- src/USER-MISC/pair_extep.cpp | 8 +-- src/USER-MISC/pair_list.cpp | 4 +- src/USER-MISC/pair_local_density.cpp | 14 ++-- src/USER-MISC/pair_meam_spline.cpp | 2 +- src/USER-MISC/pair_meam_sw_spline.cpp | 2 +- src/USER-MISC/pair_tersoff_table.cpp | 2 +- src/USER-MOLFILE/molfile_interface.cpp | 6 +- src/USER-MOLFILE/reader_molfile.cpp | 4 +- src/USER-OMP/angle_fourier_simple_omp.cpp | 4 +- src/USER-OMP/fix_qeq_comb_omp.cpp | 2 +- src/USER-OMP/improper_fourier_omp.cpp | 2 +- src/USER-OMP/pair_comb_omp.cpp | 2 +- src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp | 4 +- src/USER-OMP/pair_reaxc_omp.cpp | 12 ++-- src/USER-OMP/pair_tersoff_zbl_omp.cpp | 2 +- src/USER-OMP/reaxc_bond_orders_omp.cpp | 14 ++-- src/USER-OMP/reaxc_forces_omp.cpp | 10 +-- src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp | 10 +-- src/USER-OMP/reaxc_multi_body_omp.cpp | 6 +- src/USER-OMP/reaxc_nonbonded_omp.cpp | 4 +- src/USER-OMP/reaxc_torsion_angles_omp.cpp | 4 +- src/USER-PTM/ptm_voronoi_cell.cpp | 68 +++++++++---------- src/USER-QMMM/fix_qmmm.cpp | 2 +- src/USER-QTB/fix_qbmsst.cpp | 54 +++++++-------- src/USER-QUIP/pair_quip.cpp | 2 +- src/USER-REACTION/fix_bond_react.cpp | 6 +- src/USER-REAXC/fix_reaxc_bonds.cpp | 4 +- src/USER-REAXC/pair_reaxc.cpp | 20 +++--- src/USER-REAXC/reaxc_allocate.cpp | 26 +++---- src/USER-REAXC/reaxc_bond_orders.cpp | 18 ++--- src/USER-REAXC/reaxc_bonds.cpp | 6 +- src/USER-REAXC/reaxc_control.cpp | 6 +- src/USER-REAXC/reaxc_ffield.cpp | 50 +++++++------- src/USER-REAXC/reaxc_forces.cpp | 36 +++++----- src/USER-REAXC/reaxc_hydrogen_bonds.cpp | 8 +-- src/USER-REAXC/reaxc_io_tools.cpp | 6 +- src/USER-REAXC/reaxc_lookup.cpp | 36 +++++----- src/USER-REAXC/reaxc_multi_body.cpp | 14 ++-- src/USER-REAXC/reaxc_nonbonded.cpp | 10 +-- src/USER-REAXC/reaxc_reset_tools.cpp | 6 +- src/USER-REAXC/reaxc_tool_box.cpp | 2 +- src/USER-REAXC/reaxc_torsion_angles.cpp | 18 ++--- src/USER-REAXC/reaxc_traj.cpp | 44 ++++++------ src/USER-REAXC/reaxc_valence_angles.cpp | 24 +++---- src/USER-REAXC/reaxc_vector.cpp | 6 +- .../compute_smd_triangle_vertices.cpp | 2 +- src/USER-SMTBQ/pair_smtbq.cpp | 24 +++---- src/USER-TALLY/compute_force_tally.cpp | 2 +- src/USER-TALLY/compute_heat_flux_tally.cpp | 2 +- src/USER-TALLY/compute_pe_mol_tally.cpp | 2 +- src/USER-TALLY/compute_pe_tally.cpp | 2 +- src/USER-TALLY/compute_stress_tally.cpp | 2 +- src/USER-VTK/dump_vtk.cpp | 2 +- src/VORONOI/compute_voronoi_atom.cpp | 20 +++--- src/compute_orientorder_atom.cpp | 6 +- src/dump_cfg.cpp | 4 +- src/finish.cpp | 2 +- src/fix_adapt.cpp | 6 +- src/fix_halt.cpp | 2 +- src/info.cpp | 56 +++++++-------- src/library.cpp | 4 +- src/min_hftn.cpp | 4 +- src/min_linesearch.cpp | 2 +- src/molecule.cpp | 6 +- src/pair_coul_streitz.cpp | 4 +- src/pair_hybrid.cpp | 4 +- src/reader_native.cpp | 2 +- src/reader_xyz.cpp | 2 +- src/replicate.cpp | 12 ++-- src/text_file_reader.cpp | 4 +- src/tokenizer.cpp | 2 +- src/utils.cpp | 2 +- src/write_coeff.cpp | 2 +- 171 files changed, 744 insertions(+), 747 deletions(-) diff --git a/src/COLLOID/pair_lubricate_poly.cpp b/src/COLLOID/pair_lubricate_poly.cpp index a395f8c67e..b437bc2bfb 100644 --- a/src/COLLOID/pair_lubricate_poly.cpp +++ b/src/COLLOID/pair_lubricate_poly.cpp @@ -480,7 +480,7 @@ void PairLubricatePoly::init_style() if (strstr(modify->fix[i]->style,"wall") != nullptr) { flagwall = 1; // Walls exist - if (((FixWall *) modify->fix[i])->xflag ) { + if (((FixWall *) modify->fix[i])->xflag) { flagwall = 2; // Moving walls exist wallfix = (FixWall *) modify->fix[i]; } diff --git a/src/COMPRESS/zstd_file_writer.cpp b/src/COMPRESS/zstd_file_writer.cpp index 9f69f95395..f82ade605c 100644 --- a/src/COMPRESS/zstd_file_writer.cpp +++ b/src/COMPRESS/zstd_file_writer.cpp @@ -81,7 +81,7 @@ size_t ZstdFileWriter::write(const void * buffer, size_t length) ZSTD_outBuffer output = { out_buffer, out_buffer_size, 0 }; ZSTD_compressStream2(cctx, &output, &input, mode); fwrite(out_buffer, sizeof(char), output.pos, fp); - } while(input.pos < input.size); + } while (input.pos < input.size); return length; } @@ -100,7 +100,7 @@ void ZstdFileWriter::flush() ZSTD_outBuffer output = { out_buffer, out_buffer_size, 0 }; remaining = ZSTD_compressStream2(cctx, &output, &input, mode); fwrite(out_buffer, sizeof(char), output.pos, fp); - } while(remaining); + } while (remaining); fflush(fp); } @@ -119,7 +119,7 @@ void ZstdFileWriter::close() ZSTD_outBuffer output = { out_buffer, out_buffer_size, 0 }; remaining = ZSTD_compressStream2(cctx, &output, &input, mode); fwrite(out_buffer, sizeof(char), output.pos, fp); - } while(remaining); + } while (remaining); ZSTD_freeCCtx(cctx); cctx = nullptr; diff --git a/src/KOKKOS/atom_vec_angle_kokkos.cpp b/src/KOKKOS/atom_vec_angle_kokkos.cpp index 39897018ec..05f2661e64 100644 --- a/src/KOKKOS/atom_vec_angle_kokkos.cpp +++ b/src/KOKKOS/atom_vec_angle_kokkos.cpp @@ -491,7 +491,7 @@ struct AtomVecAngleKokkos_UnpackComm { /* ---------------------------------------------------------------------- */ void AtomVecAngleKokkos::unpack_comm_kokkos(const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); atomKK->modified(Host,X_MASK); diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.cpp b/src/KOKKOS/atom_vec_dpd_kokkos.cpp index 26fcda983b..5ab3691b16 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.cpp +++ b/src/KOKKOS/atom_vec_dpd_kokkos.cpp @@ -526,7 +526,7 @@ struct AtomVecDPDKokkos_UnpackComm { /* ---------------------------------------------------------------------- */ void AtomVecDPDKokkos::unpack_comm_kokkos(const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); atomKK->modified(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index 86c79141c0..4251a63b12 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -420,7 +420,7 @@ struct AtomVecKokkos_UnpackComm { /* ---------------------------------------------------------------------- */ void AtomVecKokkos::unpack_comm_kokkos(const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { if (commKK->forward_comm_on_host) { sync(Host,X_MASK); modified(Host,X_MASK); @@ -691,7 +691,7 @@ struct AtomVecKokkos_UnpackCommVel { /* ---------------------------------------------------------------------- */ void AtomVecKokkos::unpack_comm_vel_kokkos(const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { if (commKK->forward_comm_on_host) { sync(Host,X_MASK|V_MASK); modified(Host,X_MASK|V_MASK); @@ -864,7 +864,7 @@ struct AtomVecKokkos_PackReverse { /* ---------------------------------------------------------------------- */ int AtomVecKokkos::pack_reverse_kokkos(const int &n, const int &first, - const DAT::tdual_ffloat_2d &buf ) { + const DAT::tdual_ffloat_2d &buf) { if (commKK->reverse_comm_on_host) { sync(Host,F_MASK); struct AtomVecKokkos_PackReverse f(atomKK->k_f,buf,first); diff --git a/src/KOKKOS/atom_vec_molecular_kokkos.cpp b/src/KOKKOS/atom_vec_molecular_kokkos.cpp index 2fb33e02b7..fb328584ff 100644 --- a/src/KOKKOS/atom_vec_molecular_kokkos.cpp +++ b/src/KOKKOS/atom_vec_molecular_kokkos.cpp @@ -563,7 +563,7 @@ struct AtomVecMolecularKokkos_UnpackComm { /* ---------------------------------------------------------------------- */ void AtomVecMolecularKokkos::unpack_comm_kokkos(const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); atomKK->modified(Host,X_MASK); diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.cpp b/src/KOKKOS/atom_vec_sphere_kokkos.cpp index 451e9d737e..0b7a74966b 100644 --- a/src/KOKKOS/atom_vec_sphere_kokkos.cpp +++ b/src/KOKKOS/atom_vec_sphere_kokkos.cpp @@ -917,7 +917,7 @@ struct AtomVecSphereKokkos_UnpackComm { void AtomVecSphereKokkos::unpack_comm_kokkos( const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { // Fallback to AtomVecKokkos if radvary == 0 if (radvary == 0) { AtomVecKokkos::unpack_comm_kokkos(n,first,buf); @@ -994,7 +994,7 @@ struct AtomVecSphereKokkos_UnpackCommVel { void AtomVecSphereKokkos::unpack_comm_vel_kokkos( const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { if (commKK->forward_comm_on_host) { atomKK->modified(Host,X_MASK|RADIUS_MASK|RMASS_MASK|V_MASK|OMEGA_MASK); if (radvary == 0) { diff --git a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp index 8cac92240f..2325288c8c 100644 --- a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp +++ b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp @@ -341,17 +341,17 @@ void ComputeOrientOrderAtomKokkos::operator() (TagComputeOrientOrder #define SWAP(view,i,j) do { \ tmp = view(i); view(i) = view(j); view(j) = tmp; \ - } while(0) + } while (0) #define ISWAP(view,i,j) do { \ itmp = view(i); view(i) = view(j); view(j) = itmp; \ - } while(0) + } while (0) #define SWAP3(view,i,j) do { \ tmp = view(i,0); view(i,0) = view(j,0); view(j,0) = tmp; \ tmp = view(i,1); view(i,1) = view(j,1); view(j,1) = tmp; \ tmp = view(i,2); view(i,2) = view(j,2); view(j,2) = tmp; \ - } while(0) + } while (0) /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp index 8608b90543..e4cf0e5309 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.cpp +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -77,7 +77,7 @@ void FixEnforce2DKokkos::post_force(int /*vflag*/) if (atomKK->torque_flag) flag_mask |= 4; copymode = 1; - switch( flag_mask ) { + switch (flag_mask) { case 0:{ FixEnforce2DKokkosPostForceFunctor functor(this); Kokkos::parallel_for(nlocal,functor); diff --git a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp index a14e301bfa..4d181c2b41 100644 --- a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp +++ b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp @@ -303,7 +303,7 @@ void FixEOStableRXKokkos::energy_lookup(int id, double thetai, doubl nPG = 0; if (rx_flag) { - for (int ispecies = 0; ispecies < nspecies; ispecies++ ) { + for (int ispecies = 0; ispecies < nspecies; ispecies++) { nTotal += dvector(ispecies,id); if (fabs(d_moleculeCorrCoeff[ispecies]) > tolerance) { nPG++; diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reax_kokkos.cpp index e81579061b..e607bea3e3 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reax_kokkos.cpp @@ -139,8 +139,8 @@ void FixQEqReaxKokkos::init_shielding_k() k_shield = DAT::tdual_ffloat_2d("qeq/kk:shield",ntypes+1,ntypes+1); d_shield = k_shield.template view(); - for ( i = 1; i <= ntypes; ++i ) - for ( j = 1; j <= ntypes; ++j ) + for (i = 1; i <= ntypes; ++i) + for (j = 1; j <= ntypes; ++j) k_shield.h_view(i,j) = pow( gamma[i] * gamma[j], -1.5 ); k_shield.template modify(); @@ -1371,11 +1371,11 @@ void FixQEqReaxKokkos::operator()(TagFixQEqReaxPackForwardComm, cons if (pack_flag == 1) d_buf[i] = d_d[j]; - else if ( pack_flag == 2 ) + else if (pack_flag == 2) d_buf[i] = d_s[j]; - else if ( pack_flag == 3 ) + else if (pack_flag == 3) d_buf[i] = d_t[j]; - else if ( pack_flag == 4 ) + else if (pack_flag == 4) d_buf[i] = q[j]; } @@ -1413,11 +1413,11 @@ int FixQEqReaxKokkos::pack_forward_comm(int n, int *list, double *bu if (pack_flag == 1) for (m = 0; m < n; m++) buf[m] = h_d[list[m]]; - else if ( pack_flag == 2 ) + else if (pack_flag == 2) for (m = 0; m < n; m++) buf[m] = h_s[list[m]]; - else if ( pack_flag == 3 ) + else if (pack_flag == 3) for (m = 0; m < n; m++) buf[m] = h_t[list[m]]; - else if ( pack_flag == 4 ) + else if (pack_flag == 4) for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; return n; diff --git a/src/KOKKOS/fix_rx_kokkos.cpp b/src/KOKKOS/fix_rx_kokkos.cpp index 7a8bfbf9dd..036ecd1788 100644 --- a/src/KOKKOS/fix_rx_kokkos.cpp +++ b/src/KOKKOS/fix_rx_kokkos.cpp @@ -417,7 +417,7 @@ int FixRxKokkos::k_rkf45_h0 (const int neq, const double t, const do // compute ydot at t=t0 k_rhs (t, y, ydot, userData); - while(1) + while (1) { // Estimate y'' with finite-difference ... @@ -455,11 +455,11 @@ int FixRxKokkos::k_rkf45_h0 (const int neq, const double t, const do double hrat = hnew / hg; // Accept this value ... the bias factor should bring it within range. - if ( (hrat > 0.5) && (hrat < 2.0) ) + if ((hrat > 0.5) && (hrat < 2.0)) hnew_is_ok = true; // If y'' is still bad after a few iterations, just accept h and give up. - if ( (iter > 1) && hrat > 2.0 ) { + if ((iter > 1) && hrat > 2.0) { hnew = hg; hnew_is_ok = true; } @@ -736,7 +736,7 @@ int FixRxKokkos::rkf45_h0(const int neq, const double t, const doubl // compute ydot at t=t0 rhs (t, y, ydot, v_params); - while(1) + while (1) { // Estimate y'' with finite-difference ... @@ -774,11 +774,11 @@ int FixRxKokkos::rkf45_h0(const int neq, const double t, const doubl double hrat = hnew / hg; // Accept this value ... the bias factor should bring it within range. - if ( (hrat > 0.5) && (hrat < 2.0) ) + if ((hrat > 0.5) && (hrat < 2.0)) hnew_is_ok = true; // If y'' is still bad after a few iterations, just accept h and give up. - if ( (iter > 1) && hrat > 2.0 ) { + if ((iter > 1) && hrat > 2.0) { hnew = hg; hnew_is_ok = true; } diff --git a/src/KOKKOS/nbin_kokkos.cpp b/src/KOKKOS/nbin_kokkos.cpp index 8234ceea6f..abe5b740f1 100644 --- a/src/KOKKOS/nbin_kokkos.cpp +++ b/src/KOKKOS/nbin_kokkos.cpp @@ -92,7 +92,7 @@ void NBinKokkos::bin_atoms() h_resize() = 1; - while(h_resize() > 0) { + while (h_resize() > 0) { h_resize() = 0; deep_copy(d_resize, h_resize); diff --git a/src/KOKKOS/nbin_ssa_kokkos.cpp b/src/KOKKOS/nbin_ssa_kokkos.cpp index 276c3bee36..e38c7be8f2 100644 --- a/src/KOKKOS/nbin_ssa_kokkos.cpp +++ b/src/KOKKOS/nbin_ssa_kokkos.cpp @@ -293,7 +293,7 @@ void NBinSSAKokkos::sortBin( child = parent*2+1; /* Find the next child */ } gbins(ibin, parent) = t; /* We save t in the heap */ - } while(1); + } while (1); } namespace LAMMPS_NS { diff --git a/src/KOKKOS/npair_kokkos.cpp b/src/KOKKOS/npair_kokkos.cpp index 564e1b0b98..20e819deaf 100644 --- a/src/KOKKOS/npair_kokkos.cpp +++ b/src/KOKKOS/npair_kokkos.cpp @@ -207,7 +207,7 @@ void NPairKokkos::build(NeighList *list_) data.special_flag[3] = special_flag[3]; data.h_resize()=1; - while(data.h_resize()) { + while (data.h_resize()) { data.h_new_maxneighs() = list->maxneighs; data.h_resize() = 0; diff --git a/src/KOKKOS/npair_ssa_kokkos.cpp b/src/KOKKOS/npair_ssa_kokkos.cpp index a3608fd35a..62be4a7d31 100644 --- a/src/KOKKOS/npair_ssa_kokkos.cpp +++ b/src/KOKKOS/npair_ssa_kokkos.cpp @@ -452,7 +452,7 @@ fprintf(stdout, "tota%03d total %3d could use %6d inums, expected %6d inums. inu bool firstTry = true; data.h_resize()=1; - while(data.h_resize()) { + while (data.h_resize()) { data.h_new_maxneighs() = list->maxneighs; data.h_resize() = 0; diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index 855d2b259a..4d89169c21 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -2227,7 +2227,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int #endif for (int id = idx_begin; id < idx_end; ++id) { - if ( nTotal[id] < MY_EPSILON || nTotalold[id] < MY_EPSILON ) + if (nTotal[id] < MY_EPSILON || nTotalold[id] < MY_EPSILON) errorFlag1 = 1; // Compute the mole fraction of molecules within the fluid portion of the particle (One Fluid Approximation) diff --git a/src/KOKKOS/pair_reaxc_kokkos.cpp b/src/KOKKOS/pair_reaxc_kokkos.cpp index 5d48b429cc..12eea720ba 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.cpp +++ b/src/KOKKOS/pair_reaxc_kokkos.cpp @@ -375,7 +375,7 @@ void PairReaxCKokkos::init_md() k_tap.template sync(); - if ( control->tabulate ) { + if (control->tabulate) { int ntypes = atom->ntypes; Init_Lookup_Tables(); @@ -462,12 +462,12 @@ int PairReaxCKokkos::Init_Lookup_Tables() LR = (LR_lookup_table**) scalloc( control->error_ptr, num_atom_types+1, sizeof(LR_lookup_table*), "lookup:LR"); - for ( i = 0; i < num_atom_types+1; ++i ) + for (i = 0; i < num_atom_types+1; ++i) LR[i] = (LR_lookup_table*) scalloc( control->error_ptr, num_atom_types+1, sizeof(LR_lookup_table), "lookup:LR[i]"); - for ( i = 1; i <= num_atom_types; ++i ) { - for ( j = i; j <= num_atom_types; ++j ) { + for (i = 1; i <= num_atom_types; ++i) { + for (j = i; j <= num_atom_types; ++j) { LR[i][j].xmin = 0; LR[i][j].xmax = control->nonb_cut; LR[i][j].n = control->tabulate + 2; @@ -487,7 +487,7 @@ int PairReaxCKokkos::Init_Lookup_Tables() smalloc( control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef), "lookup:LR[i,j].CEclmb"); - for ( r = 1; r <= control->tabulate; ++r ) { + for (r = 1; r <= control->tabulate; ++r) { LR_vdW_Coulomb(i, j, r * dr, &(LR[i][j].y[r]) ); h[r] = LR[i][j].dx; fh[r] = LR[i][j].y[r].H; @@ -546,9 +546,9 @@ void PairReaxCKokkos::Deallocate_Lookup_Tables() ntypes = atom->ntypes; - for ( i = 0; i <= ntypes; ++i ) { + for (i = 0; i <= ntypes; ++i) { if (map[i] == -1) continue; - for ( j = i; j <= ntypes; ++j ) { + for (j = i; j <= ntypes; ++j) { if (map[i] == -1) continue; if (LR[i][j].n) { sfree( control->error_ptr, LR[i][j].y, "LR[i,j].y" ); @@ -2301,8 +2301,8 @@ void PairReaxCKokkos::operator()(PairReaxComputeAngular::operator()(PairReaxComputeAngular::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion= 0 && sin_ijk <= 1e-10) tan_ijk_i = cos_ijk / 1e-10; - else if ( sin_ijk <= 0 && sin_ijk >= -1e-10 ) + else if (sin_ijk <= 0 && sin_ijk >= -1e-10) tan_ijk_i = -cos_ijk / 1e-10; else tan_ijk_i = cos_ijk / sin_ijk; @@ -2643,7 +2643,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion= 0 && sin_jil <= 1e-10) tan_jil_i = cos_jil / 1e-10; - else if ( sin_jil <= 0 && sin_jil >= -1e-10 ) + else if (sin_jil <= 0 && sin_jil >= -1e-10) tan_jil_i = -cos_jil / 1e-10; else tan_jil_i = cos_jil / sin_jil; @@ -2703,9 +2703,9 @@ void PairReaxCKokkos::operator()(PairReaxComputeTorsion= 0 && sin_ijk <= 1e-10) sin_ijk_rnd = 1e-10; - else if ( sin_ijk <= 0 && sin_ijk >= -1e-10 ) sin_ijk_rnd = -1e-10; + else if (sin_ijk <= 0 && sin_ijk >= -1e-10) sin_ijk_rnd = -1e-10; if (sin_jil >= 0 && sin_jil <= 1e-10) sin_jil_rnd = 1e-10; - else if ( sin_jil <= 0 && sin_jil >= -1e-10 ) sin_jil_rnd = -1e-10; + else if (sin_jil <= 0 && sin_jil >= -1e-10) sin_jil_rnd = -1e-10; // dcos_omega_di for (int d = 0; d < 3; d++) dcos_omega_dk[d] = ((htra-arg*hnra)/rik) * delik[d] - dellk[d]; @@ -2944,7 +2944,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeHydrogen::operator()(PairReaxComputeBond1= 1.00) { if (gp[37] == 2 || (imass == 12.0000 && jmass == 15.9990) || - (jmass == 12.0000 && imass == 15.9990) ) { + (jmass == 12.0000 && imass == 15.9990)) { const F_FLOAT exphu = exp(-gp[7] * SQR(BO_i - 2.50) ); const F_FLOAT exphua1 = exp(-gp[3] * (d_total_bo[i]-BO_i)); const F_FLOAT exphub1 = exp(-gp[3] * (d_total_bo[j]-BO_i)); @@ -3905,7 +3905,7 @@ void PairReaxCKokkos::operator()(PairReaxFindBondSpecies, const int double bo_tmp = d_BO(i,j_index); - if (bo_tmp >= 0.10 ) { // Why is this a hardcoded value? + if (bo_tmp >= 0.10) { // Why is this a hardcoded value? k_tmpid.view()(i,nj) = j; k_tmpbo.view()(i,nj) = bo_tmp; nj++; diff --git a/src/KOKKOS/pair_table_rx_kokkos.cpp b/src/KOKKOS/pair_table_rx_kokkos.cpp index 0c81090a39..162448416c 100644 --- a/src/KOKKOS/pair_table_rx_kokkos.cpp +++ b/src/KOKKOS/pair_table_rx_kokkos.cpp @@ -1117,7 +1117,7 @@ void PairTableRXKokkos::coeff(int narg, char **arg) ntables++; { - if ( strcmp(site1,"1fluid") == 0 ) + if (strcmp(site1,"1fluid") == 0) isite1 = OneFluidValue; else { isite1 = nspecies; @@ -1132,7 +1132,7 @@ void PairTableRXKokkos::coeff(int narg, char **arg) if (isite1 == nspecies) error->all(FLERR,"isite1 == nspecies"); } - if ( strcmp(site2,"1fluid") == 0 ) + if (strcmp(site2,"1fluid") == 0) isite2 = OneFluidValue; else { isite2 = nspecies; diff --git a/src/KOKKOS/verlet_kokkos.cpp b/src/KOKKOS/verlet_kokkos.cpp index 02cde691d2..3aa7a3575a 100644 --- a/src/KOKKOS/verlet_kokkos.cpp +++ b/src/KOKKOS/verlet_kokkos.cpp @@ -408,7 +408,7 @@ void VerletKokkos::run(int n) unsigned int datamask_modify_device = 0; unsigned int datamask_read_host = 0; - if ( pair_compute_flag ) { + if (pair_compute_flag) { if (force->pair->execution_space==Host) { execute_on_host = true; datamask_read_host |= force->pair->datamask_read; @@ -418,7 +418,7 @@ void VerletKokkos::run(int n) datamask_modify_device |= force->pair->datamask_modify; } } - if ( atomKK->molecular && force->bond ) { + if (atomKK->molecular && force->bond) { if (force->bond->execution_space==Host) { execute_on_host = true; datamask_read_host |= force->bond->datamask_read; @@ -428,7 +428,7 @@ void VerletKokkos::run(int n) datamask_modify_device |= force->bond->datamask_modify; } } - if ( atomKK->molecular && force->angle ) { + if (atomKK->molecular && force->angle) { if (force->angle->execution_space==Host) { execute_on_host = true; datamask_read_host |= force->angle->datamask_read; @@ -438,7 +438,7 @@ void VerletKokkos::run(int n) datamask_modify_device |= force->angle->datamask_modify; } } - if ( atomKK->molecular && force->dihedral ) { + if (atomKK->molecular && force->dihedral) { if (force->dihedral->execution_space==Host) { execute_on_host = true; datamask_read_host |= force->dihedral->datamask_read; @@ -448,7 +448,7 @@ void VerletKokkos::run(int n) datamask_modify_device |= force->dihedral->datamask_modify; } } - if ( atomKK->molecular && force->improper ) { + if (atomKK->molecular && force->improper) { if (force->improper->execution_space==Host) { execute_on_host = true; datamask_read_host |= force->improper->datamask_read; @@ -458,7 +458,7 @@ void VerletKokkos::run(int n) datamask_modify_device |= force->improper->datamask_modify; } } - if ( kspace_compute_flag ) { + if (kspace_compute_flag) { if (force->kspace->execution_space==Host) { execute_on_host = true; datamask_read_host |= force->kspace->datamask_read; diff --git a/src/KSPACE/pair_lj_long_tip4p_long.cpp b/src/KSPACE/pair_lj_long_tip4p_long.cpp index 3421381d37..a6949fe085 100644 --- a/src/KSPACE/pair_lj_long_tip4p_long.cpp +++ b/src/KSPACE/pair_lj_long_tip4p_long.cpp @@ -566,7 +566,7 @@ void PairLJLongTIP4PLong::compute_inner() rsq = delx*delx + dely*dely + delz*delz; jtype = type[j]; - if (rsq < cut_ljsq[itype][jtype] && rsq < cut_out_off_sq ) { // lj + if (rsq < cut_ljsq[itype][jtype] && rsq < cut_out_off_sq) { // lj r2inv = 1.0/rsq; double rn = r2inv*r2inv*r2inv; if (ni == 0) forcelj = rn*(rn*lj1i[jtype]-lj2i[jtype]); @@ -819,7 +819,7 @@ void PairLJLongTIP4PLong::compute_middle() rsq = delx*delx + dely*dely + delz*delz; jtype = type[j]; - if (rsq < cut_ljsq[itype][jtype] && rsq >= cut_in_off_sq && rsq <= cut_out_off_sq ) { // lj + if (rsq < cut_ljsq[itype][jtype] && rsq >= cut_in_off_sq && rsq <= cut_out_off_sq) { // lj r2inv = 1.0/rsq; double rn = r2inv*r2inv*r2inv; if (ni == 0) forcelj = rn*(rn*lj1i[jtype]-lj2i[jtype]); diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 2500336e8f..6621f5bdf3 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -1289,7 +1289,7 @@ void PPPMDisp::init_coeffs() // local pair coeffs // allocate data for eigenvalue decomposition double **A=nullptr; double **Q=nullptr; - if ( n > 1 ) { + if (n > 1) { // get dispersion coefficients double **b = (double **) force->pair->extract("B",tmp); memory->create(A,n,n,"pppm/disp:A"); @@ -1364,7 +1364,7 @@ void PPPMDisp::init_coeffs() // local pair coeffs // check if the function should preferably be [1] or [2] or [3] if (nsplit == 1) { - if ( B ) delete [] B; + if (B) delete [] B; function[3] = 0; function[2] = 0; function[1] = 1; @@ -1380,7 +1380,7 @@ void PPPMDisp::init_coeffs() // local pair coeffs } if (function[2] && (nsplit > 6)) { if (me == 0) utils::logmesg(lmp," Using 7 structure factors\n"); - if ( B ) delete [] B; + if (B) delete [] B; } if (function[3]) { if (me == 0) @@ -2130,7 +2130,7 @@ void PPPMDisp::allocate_peratom() } if (function[2]) { - if (differentiation_flag != 1 ) { + if (differentiation_flag != 1) { memory->create3d_offset(u_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a0"); memory->create3d_offset(u_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, diff --git a/src/MANYBODY/fix_qeq_comb.cpp b/src/MANYBODY/fix_qeq_comb.cpp index 75abba2f09..1241d9905c 100644 --- a/src/MANYBODY/fix_qeq_comb.cpp +++ b/src/MANYBODY/fix_qeq_comb.cpp @@ -217,7 +217,7 @@ void FixQEQComb::post_force(int /*vflag*/) q1[i] = q2[i] = qf[i] = 0.0; } - for (iloop = 0; iloop < loopmax; iloop ++ ) { + for (iloop = 0; iloop < loopmax; iloop ++) { for (ii = 0; ii < inum; ii++) { i = ilist[ii]; if (mask[i] & groupbit) { diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 5a724f7520..f6595f379c 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -283,7 +283,7 @@ void PairComb::compute(int eflag, int vflag) jtype = map[type[j]]; iparam_ij = elem2param[itype][jtype][jtype]; - if (params[iparam_ij].hfocor > 0.0 ) { + if (params[iparam_ij].hfocor > 0.0) { delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; delr1[2] = x[j][2] - ztmp; @@ -595,7 +595,7 @@ void PairComb::read_file(char *file) PotentialFileReader reader(lmp, file, "comb"); char * line; - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); @@ -842,7 +842,7 @@ void PairComb::repulsive(Param *param, double rsq, double &fforce, Asi = param->biga1 * exp(param->lam11*Di); Asj = param->biga2 * exp(param->lam12*Dj); - if ( Asi > 0.0 && Asj > 0.0 ) + if (Asi > 0.0 && Asj > 0.0) bigA = sqrt(Asi*Asj)*param->romiga; else bigA = 0.0; diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index 30abb43dfc..f4434d9d76 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -531,7 +531,7 @@ void PairComb3::read_file(char *file) PotentialFileReader reader(lmp, file, "COMB3"); char * line; - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); @@ -1085,7 +1085,7 @@ void PairComb3::compute(int eflag, int vflag) sht_lnum = sht_num[j]; jtag = tag[j]; - if ( jtag <= itag ) continue ; + if (jtag <= itag) continue ; ycn = NCo[j]; jtype = map[type[j]]; @@ -1402,7 +1402,7 @@ void PairComb3::compute(int eflag, int vflag) // radical i-j-l-p: apply to all CC,CO,OC bonds if ( params[iparam_jil].rad_flag >= 1 && params[iparam_jil].ielementgp == 1 && - params[iparam_jil].kelementgp == 1 ) { + params[iparam_jil].kelementgp == 1) { iparam_lj = elem2param[ltype][jtype][jtype]; lcn=NCo[l]; double rjl=sqrt(rsq2); @@ -1667,7 +1667,7 @@ void PairComb3::force_zeta(Param *parami, Param *paramj, double rsq, // radical energy - if ( parami->rad_flag>0 ) { + if (parami->rad_flag>0) { rad_calc( r, parami, paramj, kconjug, lconjug, i, j, xcn, ycn); bij += brad[0]; pradx = brad[1]*att_eng; @@ -1701,7 +1701,7 @@ void PairComb3::force_zeta(Param *parami, Param *paramj, double rsq, prefac_ji5 = -0.5*att_eng*dbji5; // prefac_ji5 = -pfji4 // combines com6 & com7 below - if ( parami->rad_flag>0 || parami->tor_flag!=0 ) { + if (parami->rad_flag>0 || parami->tor_flag!=0) { prefac_ij2-=pradx; prefac_ji2-=prady; } @@ -1859,7 +1859,7 @@ void PairComb3::comb_fa(double r, Param *parami, Param *paramj, double iq, YYBn = (parami->aB-fabs(pow(parami->bB*(qi-parami->Qo),10))); YYBj = (paramj->aB-fabs(pow(paramj->bB*(qj-paramj->Qo),10))); - if (YYBn*YYBj > 0.0 ) { + if (YYBn*YYBj > 0.0) { AlfDiAlfDj = exp(0.5*(parami->alfi*Di+paramj->alfi*Dj)); Bsi = (pbij1*exp(-alfij1*r)+pbij2*exp(-alfij2*r)+pbij3*exp(-alfij3*r))* sqrt(YYBn*YYBj)*AlfDiAlfDj; // Bsi is cbj @@ -1894,7 +1894,7 @@ void PairComb3::comb_bij_d(double zet, Param *param, double r, int i, zeta = pow(zetang,pow_n)+pcorn; tmp_tbij=pow_n*pow(zetang,(pow_n-1.0)); - if ((1.0 + zeta) < 0.1 ) { + if ((1.0 + zeta) < 0.1) { zeta=0.1-1.0; tbij = pow(1.0 + zeta, -0.5/pow_n); tbij1=0.0; @@ -2933,7 +2933,7 @@ double PairComb3::bbtor1(int torindx, Param *paramk, Param *paraml, vec3_scale(-1.0,delrl,delrl); rmul = sqrt(1.0-rmul*rmul); - if (rmul > 0.1 ) { + if (rmul > 0.1) { double fc1k, fc1l, TT1, TT2, rmut, btt, tork[3], torl[3]; fc1k = comb_fc(rik,paramk); @@ -3065,7 +3065,7 @@ void PairComb3::tor_force(int torindx, Param *paramk, Param *paraml, srmul = sqrt(1.0-rmul*rmul); if (acos(rmul) > MY_PI) srmul = -srmul; - if (srmul > 0.1 ) { + if (srmul > 0.1) { double fc1k, fcp1k, fc1l, fcp1l, srmul2, dt1dik, dt1djl; double TT1, TT2, rmut, btt, tork[3], torl[3]; double dt2dik[3], dt2djl[3], dt2dij[3], AA, AA2; diff --git a/src/MANYBODY/pair_eam_cd.cpp b/src/MANYBODY/pair_eam_cd.cpp index e028e53bb8..b56166424c 100644 --- a/src/MANYBODY/pair_eam_cd.cpp +++ b/src/MANYBODY/pair_eam_cd.cpp @@ -512,7 +512,7 @@ void PairEAMCD::read_h_coeff(char *filename) // h coefficients are stored at the end of the file. // Skip to last line of file. - while(fgets(nextline, MAXLINE, fptr) != nullptr) { + while (fgets(nextline, MAXLINE, fptr) != nullptr) { strcpy(line, nextline); } @@ -527,7 +527,7 @@ void PairEAMCD::read_h_coeff(char *filename) hcoeff = new double[nhcoeff]; int i = 0; - while(values.has_next()) { + while (values.has_next()) { hcoeff[i++] = values.next_double(); } diff --git a/src/MANYBODY/pair_eim.cpp b/src/MANYBODY/pair_eim.cpp index f95a43ed67..db673611e2 100644 --- a/src/MANYBODY/pair_eim.cpp +++ b/src/MANYBODY/pair_eim.cpp @@ -1108,7 +1108,7 @@ char * EIMPotentialFileReader::next_line(FILE * fp) { n = strlen(line); } - while(n == 0 || concat) { + while (n == 0 || concat) { char *ptr = fgets(&line[n], MAXLINE - n, fp); if (ptr == nullptr) { @@ -1143,7 +1143,7 @@ void EIMPotentialFileReader::parse(FILE * fp) char * line = nullptr; bool found_global = false; - while((line = next_line(fp))) { + while ((line = next_line(fp))) { ValueTokenizer values(line); std::string type = values.next_string(); diff --git a/src/MANYBODY/pair_gw.cpp b/src/MANYBODY/pair_gw.cpp index 32ace05546..2f2b9922cb 100644 --- a/src/MANYBODY/pair_gw.cpp +++ b/src/MANYBODY/pair_gw.cpp @@ -385,7 +385,7 @@ void PairGW::read_file(char *file) int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_gw_zbl.cpp b/src/MANYBODY/pair_gw_zbl.cpp index bee8efb692..e166b1f1de 100644 --- a/src/MANYBODY/pair_gw_zbl.cpp +++ b/src/MANYBODY/pair_gw_zbl.cpp @@ -75,7 +75,7 @@ void PairGWZBL::read_file(char *file) int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_lcbop.cpp b/src/MANYBODY/pair_lcbop.cpp index 09ea20df52..070f23dbb9 100644 --- a/src/MANYBODY/pair_lcbop.cpp +++ b/src/MANYBODY/pair_lcbop.cpp @@ -535,12 +535,12 @@ void PairLCBOP::FLR(int eflag, int /*vflag*/) forces for Nij and Mij ------------------------------------------------------------------------- */ -void PairLCBOP::FNij( int i, int j, double factor, double **f, int vflag_atom ) { +void PairLCBOP::FNij( int i, int j, double factor, double **f, int vflag_atom) { int atomi = i; int atomj = j; int *SR_neighs = SR_firstneigh[i]; double **x = atom->x; - for( int k=0; kx; - for( int k=0; k( floor( N_ij ) ), 2 ); // 2 is the highest number of field size_t N_ji_int = MIN( static_cast( floor( N_ji ) ), 2 ); // cast to suppress warning double x = N_ij - N_ij_int; @@ -1096,9 +1096,9 @@ void PairLCBOP::read_file(char *filename) ------------------------------------------------------------------------- */ void PairLCBOP::spline_init() { - for( size_t N_conj_ij=0; N_conj_ij<2; N_conj_ij++ ) // N_conj_ij - for( size_t N_ij=0; N_ij<4-1; N_ij++ ) - for( size_t N_ji=0; N_ji<4-1; N_ji++ ) { + for (size_t N_conj_ij=0; N_conj_ij<2; N_conj_ij++) // N_conj_ij + for (size_t N_ij=0; N_ij<4-1; N_ij++) + for (size_t N_ji=0; N_ji<4-1; N_ji++) { TF_conj_field &field = F_conj_field[N_ij][N_ji][N_conj_ij]; field.f_00 = F_conj_data[N_ij ][N_ji ][N_conj_ij][0]; field.f_01 = F_conj_data[N_ij ][N_ji+1][N_conj_ij][0]; @@ -1126,7 +1126,7 @@ void PairLCBOP::spline_init() { // << gX[4] << " " // << gX[5] << std::endl; // file << "gC:\n"; -// for( int i=0; i<6; i++ ) +// for (int i=0; i<6; i++) // file << gC[i][0] << " " // << gC[i][1] << " " // << gC[i][2] << " " @@ -1170,7 +1170,7 @@ void PairLCBOP::spline_init() { // double x_1 = 1, x_0 = -1; // int n=1000; // double dx = (x_1-x_0)/n; -// for( double x=x_0; x<=x_1+0.0001; x+=dx ) { +// for (double x=x_0; x<=x_1+0.0001; x+=dx) { // double g, dg; // g = gSpline(x, &dg); // file << x << " " << g << " " << dg << std::endl; @@ -1181,7 +1181,7 @@ void PairLCBOP::spline_init() { // double x_1 = 1, x_0 = -1; // int n=1000; // double dx = (x_1-x_0)/n; -// for( double x=x_0; x<=x_1+0.0001; x+=dx ) { +// for (double x=x_0; x<=x_1+0.0001; x+=dx) { // double h, dh; // h = hSpline(x, &dh); // file << x << " " << h << " " << dh << std::endl; @@ -1193,7 +1193,7 @@ void PairLCBOP::spline_init() { // double x_1 = 4, x_0 = 0; // int n=1000; // double dx = (x_1-x_0)/n; -// for( double x=x_0; x<=x_1+0.0001; x+=dx ) { +// for (double x=x_0; x<=x_1+0.0001; x+=dx) { // double f, df; // f = f_c(x, r_1, r_2, &df); // file << x << " " << f << " " << df << std::endl; @@ -1217,23 +1217,23 @@ void PairLCBOP::spline_init() { // // file << "F_conj_0 "; // double dummy; -// for( double y=0; y<=3.0+0.0001; y+=0.1 ) +// for (double y=0; y<=3.0+0.0001; y+=0.1) // file << y << " "; // file << std::endl; -// for( double x=0; x<=3.0+0.0001; x+=0.1 ) { +// for (double x=0; x<=3.0+0.0001; x+=0.1) { // file << x << " "; -// for( double y=0; y<=3.0+0.0001; y+=0.1 ) +// for (double y=0; y<=3.0+0.0001; y+=0.1) // file << F_conj( x, y, 0, &dummy, &dummy, &dummy ) << " "; // file << std::endl; // } // // file << "dF0_dx "; -// for( double y=0; y<=3.0+0.0001; y+=0.1 ) +// for (double y=0; y<=3.0+0.0001; y+=0.1) // file << y << " "; // file << std::endl; -// for( double x=0; x<=3.0+0.0001; x+=0.1 ) { +// for (double x=0; x<=3.0+0.0001; x+=0.1) { // file << x << " "; -// for( double y=0; y<=3.0+0.0001; y+=0.1 ) { +// for (double y=0; y<=3.0+0.0001; y+=0.1) { // double dF_dx; // F_conj( x, y, 0, &dF_dx, &dummy, &dummy ); // file << dF_dx << " "; @@ -1244,12 +1244,12 @@ void PairLCBOP::spline_init() { // // // file << "F_conj_1 "; -// for( double y=0; y<=3.0+0.0001; y+=0.1 ) +// for (double y=0; y<=3.0+0.0001; y+=0.1) // file << y << " "; // file << std::endl; -// for( double x=0; x<=3.0+0.0001; x+=0.1 ) { +// for (double x=0; x<=3.0+0.0001; x+=0.1) { // file << x << " "; -// for( double y=0; y<=3.0+0.0001; y+=0.1 ) +// for (double y=0; y<=3.0+0.0001; y+=0.1) // file << F_conj( x, y, 0, &dummy, &dummy, &dummy ) << " "; // file << std::endl; // } diff --git a/src/MANYBODY/pair_nb3b_harmonic.cpp b/src/MANYBODY/pair_nb3b_harmonic.cpp index 7e53dcc39c..a1dc903a43 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.cpp +++ b/src/MANYBODY/pair_nb3b_harmonic.cpp @@ -301,7 +301,7 @@ void PairNb3bHarmonic::read_file(char *file) int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_sw.cpp b/src/MANYBODY/pair_sw.cpp index c94e75b4a2..e7a334d9a9 100644 --- a/src/MANYBODY/pair_sw.cpp +++ b/src/MANYBODY/pair_sw.cpp @@ -365,7 +365,7 @@ void PairSW::read_file(char *file) double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp index bcfcb149b4..3759932d9d 100644 --- a/src/MANYBODY/pair_tersoff.cpp +++ b/src/MANYBODY/pair_tersoff.cpp @@ -408,7 +408,7 @@ void PairTersoff::read_file(char *file) int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_tersoff_mod.cpp b/src/MANYBODY/pair_tersoff_mod.cpp index f5e4d21ffc..a25845196a 100644 --- a/src/MANYBODY/pair_tersoff_mod.cpp +++ b/src/MANYBODY/pair_tersoff_mod.cpp @@ -58,7 +58,7 @@ void PairTersoffMOD::read_file(char *file) int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_tersoff_mod_c.cpp b/src/MANYBODY/pair_tersoff_mod_c.cpp index c2cbcdd2d9..25bc735b9b 100644 --- a/src/MANYBODY/pair_tersoff_mod_c.cpp +++ b/src/MANYBODY/pair_tersoff_mod_c.cpp @@ -49,7 +49,7 @@ void PairTersoffMODC::read_file(char *file) int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_tersoff_zbl.cpp b/src/MANYBODY/pair_tersoff_zbl.cpp index aee9eda71f..404868f969 100644 --- a/src/MANYBODY/pair_tersoff_zbl.cpp +++ b/src/MANYBODY/pair_tersoff_zbl.cpp @@ -77,7 +77,7 @@ void PairTersoffZBL::read_file(char *file) double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_vashishta.cpp b/src/MANYBODY/pair_vashishta.cpp index 32f3212d75..94f211dd95 100644 --- a/src/MANYBODY/pair_vashishta.cpp +++ b/src/MANYBODY/pair_vashishta.cpp @@ -372,7 +372,7 @@ void PairVashishta::read_file(char *file) double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index 1587849ab7..79cfd09f96 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -485,8 +485,7 @@ void FixGCMC::init() (force->pair->single_enable == 0) || (force->pair_match("^hybrid",0)) || (force->pair_match("^eam",0)) || - (force->pair->tail_flag) - ) { + (force->pair->tail_flag)) { full_flag = true; if (comm->me == 0) error->warning(FLERR,"Fix gcmc using full_energy option"); diff --git a/src/MC/fix_widom.cpp b/src/MC/fix_widom.cpp index 202fd03dd1..c06573ab1a 100644 --- a/src/MC/fix_widom.cpp +++ b/src/MC/fix_widom.cpp @@ -287,8 +287,7 @@ void FixWidom::init() (force->pair->single_enable == 0) || (force->pair_match("hybrid",0)) || (force->pair_match("eam",0)) || - (force->pair->tail_flag) - ) { + (force->pair->tail_flag)) { full_flag = true; if (comm->me == 0) error->warning(FLERR,"Fix widom using full_energy option"); diff --git a/src/MISC/dump_xtc.cpp b/src/MISC/dump_xtc.cpp index 1f95220442..87eac61673 100644 --- a/src/MISC/dump_xtc.cpp +++ b/src/MISC/dump_xtc.cpp @@ -809,7 +809,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) /* when the number of coordinates is small, don't try to compress; just * write them as floats using xdr_vector */ - if (*size <= 9 ) { + if (*size <= 9) { return (xdr_vector(xdrs, (char *) fp, size3, sizeof(*fp), (xdrproc_t)xdr_float)); } @@ -851,7 +851,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) lip = ip; mindiff = INT_MAX; oldlint1 = oldlint2 = oldlint3 = 0; - while(lfp < fp + size3 ) { + while (lfp < fp + size3) { /* find nearest integer */ if (*lfp >= 0.0) lf = *lfp * *precision + 0.5; @@ -1131,7 +1131,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) run = 0; i = 0; lip = ip; - while ( i < lsize ) { + while (i < lsize) { thiscoord = (int *)(lip) + i * 3; if (bitsize == 0) { diff --git a/src/MPIIO/dump_cfg_mpiio.cpp b/src/MPIIO/dump_cfg_mpiio.cpp index eb9de685e3..07fb86d31c 100644 --- a/src/MPIIO/dump_cfg_mpiio.cpp +++ b/src/MPIIO/dump_cfg_mpiio.cpp @@ -416,7 +416,7 @@ int DumpCFGMPIIO::convert_string_omp(int n, double *mybuf) unwrap_coord = (mybuf[bufOffset[tid]+m] - 0.5)/UNWRAPEXPAND + 0.5; //offset += sprintf(&sbuf[offset],vformat[j],unwrap_coord); mpifhStringCountPerThread[tid] += sprintf(&(mpifh_buffer_line_per_thread[tid][mpifhStringCountPerThread[tid]]),vformat[j],unwrap_coord); - } else if (j >= 5 ) { + } else if (j >= 5) { if (vtype[j] == Dump::INT) //offset += // sprintf(&sbuf[offset],vformat[j],static_cast (mybuf[m])); diff --git a/src/MSCG/fix_mscg.cpp b/src/MSCG/fix_mscg.cpp index de17ae45be..38635b0891 100644 --- a/src/MSCG/fix_mscg.cpp +++ b/src/MSCG/fix_mscg.cpp @@ -73,7 +73,7 @@ FixMSCG::FixMSCG(LAMMPS *lmp, int narg, char **arg) : // parse remaining arguments int iarg = 4; - while(iarg < narg) { + while (iarg < narg) { if (strcmp(arg[iarg],"range") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix mscg command"); if (strcmp(arg[iarg+1],"on") == 0) diff --git a/src/OPT/pair_eam_opt.cpp b/src/OPT/pair_eam_opt.cpp index c89afad705..c7d3541e67 100644 --- a/src/OPT/pair_eam_opt.cpp +++ b/src/OPT/pair_eam_opt.cpp @@ -202,7 +202,7 @@ void PairEAMOpt::eval() jtype = type[j] - 1; double p = sqrt(rsq)*tmp_rdr; - if ( (int)p <= nr2 ) { + if ((int)p <= nr2) { int m = (int)p + 1; p -= (double)((int)p); fast_alpha_t& a = tabeighti[jtype*nr+m]; @@ -289,7 +289,7 @@ void PairEAMOpt::eval() double r = sqrt(rsq); double rhoip,rhojp,z2,z2p; double p = r*tmp_rdr; - if ( (int)p <= nr2 ) { + if ((int)p <= nr2) { int m = (int) p + 1; m = MIN(m,nr-1); p -= (double)((int) p); diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index 555b9d2770..733d566b7d 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -103,7 +103,7 @@ FixQEq::FixQEq(LAMMPS *lmp, int narg, char **arg) : grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); - for ( int i = 0; i < atom->nmax; i++ ) + for (int i = 0; i < atom->nmax; i++) for (int j = 0; j < nprev; ++j ) s_hist[i][j] = t_hist[i][j] = atom->q[i]; @@ -234,7 +234,7 @@ void FixQEq::allocate_matrix() numneigh = list->numneigh; m = 0; - for ( ii = 0; ii < inum; ii++ ) { + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; m += numneigh[i]; } @@ -306,7 +306,7 @@ void FixQEq::init_storage() nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - for ( int i = 0; i < nall; i++ ) { + for (int i = 0; i < nall; i++) { Hdia_inv[i] = 1. / eta[atom->type[i]]; b_s[i] = -chi[atom->type[i]]; b_t[i] = -1.0; @@ -352,7 +352,7 @@ int FixQEq::CG( double *b, double *x ) vector_sum( r , 1., b, -1., q, inum ); - for ( ii = 0; ii < inum; ++ii ) { + for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) d[i] = r[i] * Hdia_inv[i]; @@ -362,7 +362,7 @@ int FixQEq::CG( double *b, double *x ) b_norm = parallel_norm( b, inum ); sig_new = parallel_dot( r, d, inum); - for ( loop = 1; loop < maxiter && sqrt(sig_new)/b_norm > tolerance; ++loop ) { + for (loop = 1; loop < maxiter && sqrt(sig_new)/b_norm > tolerance; ++loop) { comm->forward_comm_fix(this); sparse_matvec( &H, d, q ); comm->reverse_comm_fix(this); @@ -373,7 +373,7 @@ int FixQEq::CG( double *b, double *x ) vector_add( x, alfa, d, inum ); vector_add( r, -alfa, q, inum ); - for ( ii = 0; ii < inum; ++ii ) { + for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) p[i] = r[i] * Hdia_inv[i]; @@ -406,17 +406,17 @@ void FixQEq::sparse_matvec( sparse_matrix *A, double *x, double *b ) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - for ( i = 0; i < nlocal; ++i ) { + for (i = 0; i < nlocal; ++i) { if (atom->mask[i] & groupbit) b[i] = eta[ atom->type[i] ] * x[i]; } - for ( i = nlocal; i < nall; ++i ) { + for (i = nlocal; i < nall; ++i) { if (atom->mask[i] & groupbit) b[i] = 0; } - for ( i = 0; i < nlocal; ++i ) { + for (i = 0; i < nlocal; ++i) { if (atom->mask[i] & groupbit) { for ( itr_j=A->firstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { j = A->jlist[itr_j]; @@ -444,12 +444,12 @@ void FixQEq::calculate_Q() t_sum = parallel_vector_acc( t, inum); u = s_sum / t_sum; - for ( ii = 0; ii < inum; ++ii ) { + for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) { q[i] = s[i] - u * t[i]; - for ( k = 4; k > 0; --k ) { + for (k = 4; k > 0; --k) { s_hist[i][k] = s_hist[i][k-1]; t_hist[i][k] = t_hist[i][k-1]; } @@ -471,11 +471,11 @@ int FixQEq::pack_forward_comm(int n, int *list, double *buf, if (pack_flag == 1) for (m = 0; m < n; m++) buf[m] = d[list[m]]; - else if ( pack_flag == 2 ) + else if (pack_flag == 2) for (m = 0; m < n; m++) buf[m] = s[list[m]]; - else if ( pack_flag == 3 ) + else if (pack_flag == 3) for (m = 0; m < n; m++) buf[m] = t[list[m]]; - else if ( pack_flag == 4 ) + else if (pack_flag == 4) for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; else m = 0; @@ -591,7 +591,7 @@ double FixQEq::parallel_norm( double *v, int n ) my_sum = 0.0; norm_sqr = 0.0; - for ( ii = 0; ii < n; ++ii ) { + for (ii = 0; ii < n; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) my_sum += v[i]*v[i]; @@ -616,7 +616,7 @@ double FixQEq::parallel_dot( double *v1, double *v2, int n) my_dot = 0.0; res = 0.0; - for ( ii = 0; ii < n; ++ii ) { + for (ii = 0; ii < n; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) my_dot += v1[i] * v2[i]; @@ -641,7 +641,7 @@ double FixQEq::parallel_vector_acc( double *v, int n ) my_acc = 0.0; res = 0.0; - for ( ii = 0; ii < n; ++ii ) { + for (ii = 0; ii < n; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) my_acc += v[i]; @@ -662,7 +662,7 @@ void FixQEq::vector_sum( double* dest, double c, double* v, ilist = list->ilist; - for ( --k; k>=0; --k ) { + for (--k; k>=0; --k) { kk = ilist[k]; if (atom->mask[kk] & groupbit) dest[kk] = c * v[kk] + d * y[kk]; @@ -678,7 +678,7 @@ void FixQEq::vector_add( double* dest, double c, double* v, int k ) ilist = list->ilist; - for ( --k; k>=0; --k ) { + for (--k; k>=0; --k) { kk = ilist[k]; if (atom->mask[kk] & groupbit) dest[kk] += c * v[kk]; diff --git a/src/QEQ/fix_qeq_dynamic.cpp b/src/QEQ/fix_qeq_dynamic.cpp index 6fc98410eb..2bd63b718d 100644 --- a/src/QEQ/fix_qeq_dynamic.cpp +++ b/src/QEQ/fix_qeq_dynamic.cpp @@ -113,7 +113,7 @@ void FixQEqDynamic::pre_force(int /*vflag*/) q1[i] = q2[i] = qf[i] = 0.0; } - for (iloop = 0; iloop < maxiter; iloop ++ ) { + for (iloop = 0; iloop < maxiter; iloop ++) { for (ii = 0; ii < inum; ii++) { i = ilist[ii]; if (mask[i] & groupbit) { @@ -250,7 +250,7 @@ int FixQEqDynamic::pack_forward_comm(int n, int *list, double *buf, if (pack_flag == 1) for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; - else if ( pack_flag == 2 ) + else if (pack_flag == 2) for (m = 0; m < n; m++) buf[m] = qf[list[m]]; return m; diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index 613d6998aa..6e51c906bc 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -132,7 +132,7 @@ void FixQEqFire::pre_force(int /*vflag*/) dt = qstep; dtmax = TMAX * dt; - for (iloop = 0; iloop < maxiter; iloop ++ ) { + for (iloop = 0; iloop < maxiter; iloop ++) { pack_flag = 1; comm->forward_comm_fix(this); @@ -314,7 +314,7 @@ int FixQEqFire::pack_forward_comm(int n, int *list, double *buf, if (pack_flag == 1) for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; - else if ( pack_flag == 2 ) + else if (pack_flag == 2) for (m = 0; m < n; m++) buf[m] = qf[list[m]]; return m; diff --git a/src/QEQ/fix_qeq_point.cpp b/src/QEQ/fix_qeq_point.cpp index 0c9b918647..f112c4859f 100644 --- a/src/QEQ/fix_qeq_point.cpp +++ b/src/QEQ/fix_qeq_point.cpp @@ -95,7 +95,7 @@ void FixQEqPoint::init_matvec() inum = list->inum; ilist = list->ilist; - for( ii = 0; ii < inum; ++ii ) { + for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) { Hdia_inv[i] = 1. / eta[ atom->type[i] ]; @@ -131,14 +131,14 @@ void FixQEqPoint::compute_H() // fill in the H matrix m_fill = 0; - for( ii = 0; ii < inum; ii++ ) { + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; if (mask[i] & groupbit) { jlist = firstneigh[i]; jnum = numneigh[i]; H.firstnbr[i] = m_fill; - for( jj = 0; jj < jnum; jj++ ) { + for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; j &= NEIGHMASK; diff --git a/src/QEQ/fix_qeq_shielded.cpp b/src/QEQ/fix_qeq_shielded.cpp index 5cea54b4cb..decfe69ccc 100644 --- a/src/QEQ/fix_qeq_shielded.cpp +++ b/src/QEQ/fix_qeq_shielded.cpp @@ -97,8 +97,8 @@ void FixQEqShielded::init_shielding() double d7, swa2, swa3, swb2, swb3; int ntypes = atom->ntypes; - for( i = 1; i <= ntypes; ++i ) - for( j = 1; j <= ntypes; ++j ) + for (i = 1; i <= ntypes; ++i) + for (j = 1; j <= ntypes; ++j) shld[i][j] = pow( gamma[i] * gamma[j], -1.5 ); if (fabs(swa) > 0.01 && comm->me == 0) @@ -158,7 +158,7 @@ void FixQEqShielded::init_matvec() inum = list->inum; ilist = list->ilist; - for( ii = 0; ii < inum; ++ii ) { + for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) { Hdia_inv[i] = 1. / eta[ atom->type[i] ]; @@ -196,14 +196,14 @@ void FixQEqShielded::compute_H() // fill in the H matrix m_fill = 0; r_sqr = 0; - for( ii = 0; ii < inum; ii++ ) { + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; if (mask[i] & groupbit) { jlist = firstneigh[i]; jnum = numneigh[i]; H.firstnbr[i] = m_fill; - for( jj = 0; jj < jnum; jj++ ) { + for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; j &= NEIGHMASK; diff --git a/src/QEQ/fix_qeq_slater.cpp b/src/QEQ/fix_qeq_slater.cpp index 6860fab26b..5cab1f1979 100644 --- a/src/QEQ/fix_qeq_slater.cpp +++ b/src/QEQ/fix_qeq_slater.cpp @@ -136,7 +136,7 @@ void FixQEqSlater::init_matvec() inum = list->inum; ilist = list->ilist; - for( ii = 0; ii < inum; ++ii ) { + for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) { Hdia_inv[i] = 1. / eta[ atom->type[i] ]; @@ -353,17 +353,17 @@ void FixQEqSlater::sparse_matvec( sparse_matrix *A, double *x, double *b ) double r = cutoff; double woself = 0.50*erfc(alpha*r)/r + alpha/MY_PIS; - for( i = 0; i < nlocal; ++i ) { + for (i = 0; i < nlocal; ++i) { if (atom->mask[i] & groupbit) b[i] = (eta[atom->type[i]] - 2.0*force->qqr2e*woself) * x[i]; } - for( i = nlocal; i < nall; ++i ) { + for (i = nlocal; i < nall; ++i) { if (atom->mask[i] & groupbit) b[i] = 0; } - for( i = 0; i < nlocal; ++i ) { + for (i = 0; i < nlocal; ++i) { if (atom->mask[i] & groupbit) { for( itr_j=A->firstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { j = A->jlist[itr_j]; diff --git a/src/SHOCK/fix_append_atoms.cpp b/src/SHOCK/fix_append_atoms.cpp index f15831a498..cfff02d292 100644 --- a/src/SHOCK/fix_append_atoms.cpp +++ b/src/SHOCK/fix_append_atoms.cpp @@ -358,7 +358,7 @@ void FixAppendAtoms::post_force(int /*vflag*/) } for (int i = 0; i < nlocal; i++) { // SET TEMP AHEAD OF SHOCK - if (tempflag && x[i][2] >= domain->boxhi[2] - t_extent ) { + if (tempflag && x[i][2] >= domain->boxhi[2] - t_extent) { gamma1 = gfactor1[type[i]]; gamma2 = gfactor2[type[i]] * tsqrt; f[i][0] += gamma1*v[i][0] + gamma2*(randomt->uniform()-0.5); @@ -386,7 +386,7 @@ void FixAppendAtoms::post_force(int /*vflag*/) // set temp ahead of shock - if (tempflag && x[i][2] >= domain->boxhi[2] - t_extent ) { + if (tempflag && x[i][2] >= domain->boxhi[2] - t_extent) { gamma1 = -rmass[i] / t_period / ftm2v; gamma2 = sqrt(rmass[i]) * sqrt(24.0*boltz/t_period/dt/mvv2e) / ftm2v; gamma2 *= tsqrt; diff --git a/src/SHOCK/fix_msst.cpp b/src/SHOCK/fix_msst.cpp index dabe4c425c..a73409e584 100644 --- a/src/SHOCK/fix_msst.cpp +++ b/src/SHOCK/fix_msst.cpp @@ -324,33 +324,33 @@ void FixMSST::setup(int /*vflag*/) couple(); velocity_sum = compute_vsum(); - if ( v0_set == 0 ) { + if (v0_set == 0) { v0 = compute_vol(); v0_set = 1; if (comm->me == 0) utils::logmesg(lmp,fmt::format("Fix MSST v0 = {:.8g}\n", v0)); } - if ( p0_set == 0 ) { + if (p0_set == 0) { p0 = p_current[direction]; p0_set = 1; - if ( comm->me == 0 ) + if (comm->me == 0) utils::logmesg(lmp,fmt::format("Fix MSST p0 = {:.8g}\n", p0)); } - if ( e0_set == 0 ) { + if (e0_set == 0) { e0 = compute_etotal(); e0_set = 1; - if ( comm->me == 0 ) + if (comm->me == 0) utils::logmesg(lmp,fmt::format("Fix MSST e0 = {:.8g}\n", e0)); } temperature->compute_vector(); double *ke_tensor = temperature->vector; double ke_temp = ke_tensor[0]+ke_tensor[1]+ke_tensor[2]; - if (ke_temp > 0.0 && tscale > 0.0 ) { + if (ke_temp > 0.0 && tscale > 0.0) { // transfer energy from atom velocities to cell volume motion // to bias initial compression @@ -371,7 +371,7 @@ void FixMSST::setup(int /*vflag*/) fac2,tscale)); for (int i = 0; i < atom->nlocal; i++) { if (mask[i] & groupbit) { - for (int k = 0; k < 3; k++ ) { + for (int k = 0; k < 3; k++) { v[i][k]*=sqrt_initial_temperature_scaling; } } @@ -453,7 +453,7 @@ void FixMSST::initial_integrate(int /*vflag*/) // use Taylor expansion to avoid singularity at B = 0 - if ( B * dthalf > 1.0e-06 ) { + if (B * dthalf > 1.0e-06) { omega[sd] = ( omega[sd] + A * ( exp(B * dthalf) - 1.0 ) / B ) * exp(-B * dthalf); } else { @@ -469,7 +469,7 @@ void FixMSST::initial_integrate(int /*vflag*/) if (dftb) { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { const double C = f[i][k] * force->ftm2v / mass[type[i]]; const double TS_term = TS_dot/(mass[type[i]]*velocity_sum); const double escale_term = force->ftm2v*beta*(e0-e_scale) / @@ -478,8 +478,8 @@ void FixMSST::initial_integrate(int /*vflag*/) (velocity_sum * mass[type[i]] * vol ); D += escale_term - TS_term; old_velocity[i][k] = v[i][k]; - if ( k == direction ) D -= 2.0 * omega[sd] / vol; - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (k == direction) D -= 2.0 * omega[sd] / vol; + if (fabs(dthalf * D) > 1.0e-06) { const double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -492,15 +492,15 @@ void FixMSST::initial_integrate(int /*vflag*/) } else { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { const double C = f[i][k] * force->ftm2v / mass[type[i]]; double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ); old_velocity[i][k] = v[i][k]; - if ( k == direction ) { + if (k == direction) { D -= 2.0 * omega[sd] / vol; } - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (fabs(dthalf * D) > 1.0e-06) { const double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -529,7 +529,7 @@ void FixMSST::initial_integrate(int /*vflag*/) if (dftb) { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { const double C = f[i][k] * force->ftm2v / mass[type[i]]; const double TS_term = TS_dot/(mass[type[i]]*velocity_sum); const double escale_term = force->ftm2v*beta*(e0-e_scale) / @@ -537,8 +537,8 @@ void FixMSST::initial_integrate(int /*vflag*/) double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ); D += escale_term - TS_term; - if ( k == direction ) D -= 2.0 * omega[sd] / vol; - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (k == direction) D -= 2.0 * omega[sd] / vol; + if (fabs(dthalf * D) > 1.0e-06) { const double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -551,14 +551,14 @@ void FixMSST::initial_integrate(int /*vflag*/) } else { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { const double C = f[i][k] * force->ftm2v / mass[type[i]]; double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ); - if ( k == direction ) { + if (k == direction) { D -= 2.0 * omega[sd] / vol; } - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (fabs(dthalf * D) > 1.0e-06) { const double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -647,7 +647,7 @@ void FixMSST::final_integrate() if (dftb) { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( int k = 0; k < 3; k++ ) { + for (int k = 0; k < 3; k++) { const double C = f[i][k] * force->ftm2v / mass[type[i]]; const double TS_term = TS_dot/(mass[type[i]]*velocity_sum); const double escale_term = force->ftm2v*beta*(e0-e_scale) / @@ -655,8 +655,8 @@ void FixMSST::final_integrate() double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ); D += escale_term - TS_term; - if ( k == direction ) D -= 2.0 * omega[sd] / vol; - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (k == direction) D -= 2.0 * omega[sd] / vol; + if (fabs(dthalf * D) > 1.0e-06) { const double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -669,14 +669,14 @@ void FixMSST::final_integrate() } else { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( int k = 0; k < 3; k++ ) { + for (int k = 0; k < 3; k++) { const double C = f[i][k] * force->ftm2v / mass[type[i]]; double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ); - if ( k == direction ) { + if (k == direction) { D -= 2.0 * omega[sd] / vol; } - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (fabs(dthalf * D) > 1.0e-06) { const double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -707,11 +707,11 @@ void FixMSST::final_integrate() // prevent blow-up of the volume - if ( vol > v0 && A > 0.0 ) A = -A; + if (vol > v0 && A > 0.0) A = -A; // use taylor expansion to avoid singularity at B == 0. - if ( B * dthalf > 1.0e-06 ) { + if (B * dthalf > 1.0e-06) { omega[sd] = ( omega[sd] + A * ( exp(B * dthalf) - 1.0 ) / B ) * exp(-B * dthalf); } else { @@ -766,7 +766,7 @@ void FixMSST::remap(int flag) // reset global and local box to new size/shape for (i = 0; i < 3; i++) { - if ( direction == i ) { + if (direction == i) { oldlo = domain->boxlo[i]; oldhi = domain->boxhi[i]; ctr = 0.5 * (oldlo + oldhi); diff --git a/src/SHOCK/fix_nphug.cpp b/src/SHOCK/fix_nphug.cpp index b8df9d7014..744f9d89cb 100644 --- a/src/SHOCK/fix_nphug.cpp +++ b/src/SHOCK/fix_nphug.cpp @@ -205,12 +205,12 @@ void FixNPHug::setup(int vflag) { FixNH::setup(vflag); - if ( v0_set == 0 ) { + if (v0_set == 0) { v0 = compute_vol(); v0_set = 1; } - if ( p0_set == 0 ) { + if (p0_set == 0) { p0_set = 1; if (uniaxial == 1) p0 = p_current[idir]; @@ -218,7 +218,7 @@ void FixNPHug::setup(int vflag) p0 = (p_current[0]+p_current[1]+p_current[2])/3.0; } - if ( e0_set == 0 ) { + if (e0_set == 0) { e0 = compute_etotal(); e0_set = 1; } diff --git a/src/SHOCK/fix_wall_piston.cpp b/src/SHOCK/fix_wall_piston.cpp index bddfcaa3cb..66c97bccda 100644 --- a/src/SHOCK/fix_wall_piston.cpp +++ b/src/SHOCK/fix_wall_piston.cpp @@ -307,7 +307,7 @@ void FixWallPiston::post_integrate() } for (int i = 0; i < nlocal; i++) { // SET TEMP AHEAD OF PISTON - if (tempflag && x[i][2] <= domain->boxlo[2] + t_extent ) { + if (tempflag && x[i][2] <= domain->boxlo[2] + t_extent) { gamma1 = gfactor1[type[i]]; gamma2 = gfactor2[type[i]] * tsqrt; f[i][0] += gamma1*v[i][0] + gamma2*(randomt->uniform()-0.5); @@ -324,7 +324,7 @@ void FixWallPiston::post_integrate() for (int i = 0; i < nlocal; i++) { // SET TEMP AHEAD OF PISTON - if (tempflag && x[i][2] <= domain->boxlo[2] + t_extent ) { + if (tempflag && x[i][2] <= domain->boxlo[2] + t_extent) { gamma1 = -rmass[i] / t_period / ftm2v; gamma2 = sqrt(rmass[i]) * sqrt(24.0*boltz/t_period/dt/mvv2e) / ftm2v; gamma2 *= tsqrt; diff --git a/src/USER-BOCS/compute_pressure_bocs.cpp b/src/USER-BOCS/compute_pressure_bocs.cpp index 856dc3d6f5..f97edfeaa1 100644 --- a/src/USER-BOCS/compute_pressure_bocs.cpp +++ b/src/USER-BOCS/compute_pressure_bocs.cpp @@ -320,11 +320,11 @@ double ComputePressureBocs::compute_scalar() volume = (domain->xprd * domain->yprd * domain->zprd); /* MRD NJD if block */ - if ( p_basis_type == BASIS_ANALYTIC ) + if (p_basis_type == BASIS_ANALYTIC) { correction = get_cg_p_corr(N_basis,phi_coeff,N_mol,vavg,volume); } - else if ( p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE ) + else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE) { correction = get_cg_p_corr(splines, p_basis_type, volume); } diff --git a/src/USER-BOCS/fix_bocs.cpp b/src/USER-BOCS/fix_bocs.cpp index 438766e351..81bf3538df 100644 --- a/src/USER-BOCS/fix_bocs.cpp +++ b/src/USER-BOCS/fix_bocs.cpp @@ -186,7 +186,7 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : } iarg += 4; - if ( strcmp(arg[iarg], "analytic") == 0 ) { + if (strcmp(arg[iarg], "analytic") == 0) { if (iarg + 4 > narg) { error->all(FLERR,"Illegal fix bocs command. Basis type analytic" " must be followed by: avg_vol n_mol n_pmatch_coeff"); @@ -202,13 +202,13 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : for (int pmatchi = 0; pmatchi < N_p_match; pmatchi++) p_match_coeffs[pmatchi] = utils::numeric(FLERR,arg[iarg+pmatchi],false,lmp); iarg += (N_p_match); - } else if (strcmp(arg[iarg], "linear_spline") == 0 ) { + } else if (strcmp(arg[iarg], "linear_spline") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix bocs command. " "Supply a file name after linear_spline."); p_basis_type = BASIS_LINEAR_SPLINE; spline_length = read_F_table( arg[iarg+1], p_basis_type ); iarg += 2; - } else if (strcmp(arg[iarg], "cubic_spline") == 0 ) { + } else if (strcmp(arg[iarg], "cubic_spline") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix bocs command. " "Supply a file name after cubic_spline."); p_basis_type = BASIS_CUBIC_SPLINE; @@ -551,7 +551,7 @@ void FixBocs::init() ((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, N_p_match, p_match_coeffs, N_mol, vavg); } - else if ( p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE ) + else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE) { ((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, splines, spline_length); @@ -1592,12 +1592,12 @@ int FixBocs::modify_param(int narg, char **arg) if (p_match_flag) // NJD MRD { - if ( p_basis_type == BASIS_ANALYTIC ) + if (p_basis_type == BASIS_ANALYTIC) { ((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, N_p_match, p_match_coeffs, N_mol, vavg); } - else if ( p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE ) + else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE ) { ((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, splines, spline_length ); } diff --git a/src/USER-COLVARS/colvarproxy_lammps.cpp b/src/USER-COLVARS/colvarproxy_lammps.cpp index 44b0b8b5ed..eb7d1820e5 100644 --- a/src/USER-COLVARS/colvarproxy_lammps.cpp +++ b/src/USER-COLVARS/colvarproxy_lammps.cpp @@ -207,7 +207,7 @@ double colvarproxy_lammps::compute() first_timestep = false; } else { // Use the time step number from LAMMPS Update object - if ( _lmp->update->ntimestep - previous_step == 1 ) { + if (_lmp->update->ntimestep - previous_step == 1) { colvars->it++; b_simulation_continuing = false; } else { @@ -412,7 +412,7 @@ int colvarproxy_lammps::check_atom_id(int atom_number) " for collective variables calculation.\n"); // TODO add upper boundary check? - if ( (aid < 0) ) { + if ((aid < 0)) { cvm::error("Error: invalid atom number specified, "+ cvm::to_str(atom_number)+"\n", INPUT_ERROR); return INPUT_ERROR; diff --git a/src/USER-COLVARS/fix_colvars.cpp b/src/USER-COLVARS/fix_colvars.cpp index 4d47f19ccc..841e2e0099 100644 --- a/src/USER-COLVARS/fix_colvars.cpp +++ b/src/USER-COLVARS/fix_colvars.cpp @@ -132,7 +132,7 @@ static void rebuild_table_int(inthash_t *tptr) { inthash_init(tptr, old_size<<1); for (i=0; inext; h=inthash(tptr, tmp->key); diff --git a/src/USER-DIFFRACTION/compute_saed.cpp b/src/USER-DIFFRACTION/compute_saed.cpp index a241d084be..c0be61dafe 100644 --- a/src/USER-DIFFRACTION/compute_saed.cpp +++ b/src/USER-DIFFRACTION/compute_saed.cpp @@ -88,7 +88,7 @@ ComputeSAED::ComputeSAED(LAMMPS *lmp, int narg, char **arg) : ztype[i] = j; } } - if ( ztype[i] == SAEDmaxType + 1 ) + if (ztype[i] == SAEDmaxType + 1) error->all(FLERR,"Compute SAED: Invalid ASF atom type"); iarg++; } @@ -148,7 +148,7 @@ ComputeSAED::ComputeSAED(LAMMPS *lmp, int narg, char **arg) : } // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0)) { } else { R_Ewald = (1 / lambda); double Rnorm = R_Ewald/ sqrt(Zone[0] * Zone[0] + @@ -213,7 +213,7 @@ ComputeSAED::ComputeSAED(LAMMPS *lmp, int narg, char **arg) : double K[3]; // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { + if ((Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0)) { for (int k = -Knmax[2]; k <= Knmax[2]; k++) { for (int j = -Knmax[1]; j <= Knmax[1]; j++) { for (int i = -Knmax[0]; i <= Knmax[0]; i++) { @@ -239,7 +239,7 @@ ComputeSAED::ComputeSAED(LAMMPS *lmp, int narg, char **arg) : r2 += pow(K[m] - Zone[m],2.0); EmdR2 = pow(R_Ewald - dR_Ewald,2); EpdR2 = pow(R_Ewald + dR_Ewald,2); - if ( (r2 > EmdR2 ) && (r2 < EpdR2 ) ) { + if ((r2 > EmdR2) && (r2 < EpdR2)) { n++; } } @@ -293,7 +293,7 @@ void ComputeSAED::init() int n = 0; // Zone 0 0 0 flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { + if ((Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0)) { for (int k = -Knmax[2]; k <= Knmax[2]; k++) { for (int j = -Knmax[1]; j <= Knmax[1]; j++) { for (int i = -Knmax[0]; i <= Knmax[0]; i++) { @@ -324,7 +324,7 @@ void ComputeSAED::init() r2 += pow(K[m] - Zone[m],2.0); EmdR2 = pow(R_Ewald - dR_Ewald,2); EpdR2 = pow(R_Ewald + dR_Ewald,2); - if ( (r2 > EmdR2 ) && (r2 < EpdR2 ) ) { + if ((r2 > EmdR2) && (r2 < EpdR2)) { store_tmp[3*n] = i; store_tmp[3*n+1] = j; store_tmp[3*n+2] = k; @@ -473,13 +473,13 @@ void ComputeSAED::compute_vector() Fvec[2*n+1] = Fatom2; // reporting progress of calculation - if ( echo ) { + if (echo) { #if defined(_OPENMP) #pragma omp critical // TODO use VMD timer style incrementer #endif { - if ( m == round(frac * nRows) ) { + if (m == round(frac * nRows)) { if (me == 0 && screen) fprintf(screen," %0.0f%% -",frac*100); frac += 0.1; } diff --git a/src/USER-DIFFRACTION/compute_xrd.cpp b/src/USER-DIFFRACTION/compute_xrd.cpp index 3d3bc17c74..0cb47fc2a2 100644 --- a/src/USER-DIFFRACTION/compute_xrd.cpp +++ b/src/USER-DIFFRACTION/compute_xrd.cpp @@ -89,7 +89,7 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) : ztype[i] = j; } } - if ( ztype[i] == XRDmaxType + 1 ) + if (ztype[i] == XRDmaxType + 1) error->all(FLERR,"Compute XRD: Invalid ASF atom type"); iarg++; } @@ -109,7 +109,7 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) : if (iarg+3 > narg) error->all(FLERR,"Illegal Compute XRD Command"); Min2Theta = atof(arg[iarg+1]) / 2; Max2Theta = atof(arg[iarg+2]) / 2; - if (Max2Theta > MY_PI ) { + if (Max2Theta > MY_PI) { Min2Theta = Min2Theta * MY_PI / 180; // converting to radians if necessary Max2Theta = Max2Theta * MY_PI / 180; radflag = 0; @@ -215,7 +215,7 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) : K[1] = j * dK[1]; K[2] = k * dK[2]; dinv2 = (K[0] * K[0] + K[1] * K[1] + K[2] * K[2]); - if (4 >= dinv2 * lambda * lambda ) { + if (4 >= dinv2 * lambda * lambda) { ang = asin(lambda * sqrt(dinv2) * 0.5); if ((ang <= Max2Theta) && (ang >= Min2Theta)) { nRows++; @@ -276,7 +276,7 @@ void ComputeXRD::init() K[1] = j * dK[1]; K[2] = k * dK[2]; dinv2 = (K[0] * K[0] + K[1] * K[1] + K[2] * K[2]); - if (4 >= dinv2 * lambda * lambda ) { + if (4 >= dinv2 * lambda * lambda) { ang = asin(lambda * sqrt(dinv2) * 0.5); if ((ang <= Max2Theta) && (ang >= Min2Theta)) { store_tmp[3*n] = k; @@ -422,12 +422,12 @@ void ComputeXRD::compute_array() Fvec[2*n+1] = Fatom2 * sqrt_lp; // reporting progress of calculation - if ( echo ) { + if (echo) { #if defined(_OPENMP) #pragma omp critical #endif { - if ( m == round(frac * size_array_rows) ) { + if (m == round(frac * size_array_rows)) { if (me == 0 && screen) fprintf(screen," %0.0f%% -",frac*100); frac += 0.1; } @@ -476,12 +476,12 @@ void ComputeXRD::compute_array() Fvec[2*n+1] = Fatom2; // reporting progress of calculation - if ( echo ) { + if (echo) { #if defined(_OPENMP) #pragma omp critical #endif { - if ( m == round(frac * size_array_rows) ) { + if (m == round(frac * size_array_rows)) { if (me == 0 && screen) fprintf(screen," %0.0f%% -",frac*100 ); frac += 0.1; } diff --git a/src/USER-DIFFRACTION/fix_saed_vtk.cpp b/src/USER-DIFFRACTION/fix_saed_vtk.cpp index 0791b25aaa..9c3666b426 100644 --- a/src/USER-DIFFRACTION/fix_saed_vtk.cpp +++ b/src/USER-DIFFRACTION/fix_saed_vtk.cpp @@ -72,7 +72,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : iarg = 6; while (iarg < narg) { - if (strncmp(arg[iarg],"c_",2) == 0 ) { + if (strncmp(arg[iarg],"c_",2) == 0) { int n = strlen(arg[iarg]); char *suffix = new char[n]; @@ -153,7 +153,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : // SAED specific paramaters needed int *periodicity = domain->periodicity; // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0)) { } else { R_Ewald = (1 / lambda); double Rnorm = R_Ewald/ sqrt(Zone[0] * Zone[0] + @@ -200,7 +200,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : } // Find integer dimensions of the reciprocal lattice box bounds - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { + if ((Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0)) { for (int i=0; i<3; i++) { dK[i] = prd_inv[i]*c[i]; Knmax[i] = ceil(Kmax / dK[i]); @@ -233,15 +233,15 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : r=0.0; for (int m=0; m<3; m++) r += pow(K[m] - Zone[m],2.0); r = sqrt(r); - if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) ) ) { + if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) )) { - if ( i < Knmin[0] ) Knmin[0] = i; - if ( j < Knmin[1] ) Knmin[1] = j; - if ( k < Knmin[2] ) Knmin[2] = k; + if (i < Knmin[0]) Knmin[0] = i; + if (j < Knmin[1]) Knmin[1] = j; + if (k < Knmin[2]) Knmin[2] = k; - if ( i > Knmax[0] ) Knmax[0] = i; - if ( j > Knmax[1] ) Knmax[1] = j; - if ( k > Knmax[2] ) Knmax[2] = k; + if (i > Knmax[0]) Knmax[0] = i; + if (j > Knmax[1]) Knmax[1] = j; + if (k > Knmax[2]) Knmax[2] = k; } } } @@ -251,7 +251,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : // Finding dimensions for vtk files for (int i=0; i<3; i++) { - if ( ( (Knmin[i] > 0) && (Knmax[i] > 0) ) || ( (Knmin[i] < 0) && (Knmax[i] < 0) ) ) { + if (( (Knmin[i] > 0) && (Knmax[i] > 0) ) || ( (Knmin[i] < 0) && (Knmax[i] < 0) )) { Dim[i] = abs( (int) Knmin[i] ) + abs( (int) Knmax[i] ); } else Dim[i] = abs( (int) Knmin[i] ) + abs( (int) Knmax[i] ) + 1; } @@ -452,7 +452,7 @@ void FixSAEDVTK::invoke_vector(bigint ntimestep) double K[3]; // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { + if ((Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0)) { for (int k = Knmin[2]; k <= Knmax[2]; k++) { for (int j = Knmin[1]; j <= Knmax[1]; j++) { for (int i = Knmin[0]; i <= Knmax[0]; i++) { @@ -485,7 +485,7 @@ void FixSAEDVTK::invoke_vector(bigint ntimestep) r=0.0; for (int m=0; m<3; m++) r += pow(K[m] - Zone[m],2.0); r = sqrt(r); - if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) ) ) { + if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) )) { fprintf(fp,"%g\n",vector_total[NROW1]/norm); fflush(fp); NROW2++; diff --git a/src/USER-DPD/fix_rx.cpp b/src/USER-DPD/fix_rx.cpp index ad3bf7c30c..c9d12506ab 100644 --- a/src/USER-DPD/fix_rx.cpp +++ b/src/USER-DPD/fix_rx.cpp @@ -1220,7 +1220,7 @@ int FixRX::rkf45_h0 (const int neq, const double t, const double /*t_stop*/, // compute ydot at t=t0 rhs (t, y, ydot, v_params); - while(1) + while (1) { // Estimate y'' with finite-difference ... @@ -1258,11 +1258,11 @@ int FixRX::rkf45_h0 (const int neq, const double t, const double /*t_stop*/, double hrat = hnew / hg; // Accept this value ... the bias factor should bring it within range. - if ( (hrat > 0.5) && (hrat < 2.0) ) + if ((hrat > 0.5) && (hrat < 2.0)) hnew_is_ok = true; // If y'' is still bad after a few iterations, just accept h and give up. - if ( (iter > 1) && hrat > 2.0 ) { + if ((iter > 1) && hrat > 2.0) { hnew = hg; hnew_is_ok = true; } diff --git a/src/USER-DPD/pair_table_rx.cpp b/src/USER-DPD/pair_table_rx.cpp index 6c975c97f3..cefbe5a73d 100644 --- a/src/USER-DPD/pair_table_rx.cpp +++ b/src/USER-DPD/pair_table_rx.cpp @@ -400,7 +400,7 @@ void PairTableRX::coeff(int narg, char **arg) ntables++; { - if ( strcmp(site1,"1fluid") == 0 ) + if (strcmp(site1,"1fluid") == 0) isite1 = OneFluidValue; else { isite1 = nspecies; @@ -415,7 +415,7 @@ void PairTableRX::coeff(int narg, char **arg) if (isite1 == nspecies) error->all(FLERR,"isite1 == nspecies"); } - if ( strcmp(site2,"1fluid") == 0 ) + if (strcmp(site2,"1fluid") == 0) isite2 = OneFluidValue; else { isite2 = nspecies; diff --git a/src/USER-INTEL/fix_intel.cpp b/src/USER-INTEL/fix_intel.cpp index ea65a91953..31bd63160f 100644 --- a/src/USER-INTEL/fix_intel.cpp +++ b/src/USER-INTEL/fix_intel.cpp @@ -1170,7 +1170,7 @@ int FixIntel::set_host_affinity(const int nomp) p = popen(cmd, "r"); if (p == nullptr) return -1; ncores = 0; - while(fgets(readbuf, 512, p)) { + while (fgets(readbuf, 512, p)) { proc_list[ncores] = atoi(readbuf); ncores++; } @@ -1224,7 +1224,7 @@ int FixIntel::set_host_affinity(const int nomp) p = popen(cmd, "r"); if (p == nullptr) return -1; - while(fgets(readbuf, 512, p)) { + while (fgets(readbuf, 512, p)) { lwp = atoi(readbuf); int first = coi_cores + node_rank * mpi_cores; CPU_ZERO(&cpuset); @@ -1260,7 +1260,7 @@ int FixIntel::set_host_affinity(const int nomp) p = popen(cmd, "r"); if (p == nullptr) return -1; - while(fgets(readbuf, 512, p)) { + while (fgets(readbuf, 512, p)) { lwp = atoi(readbuf); nlwp++; if (nlwp <= plwp) continue; diff --git a/src/USER-INTEL/pair_buck_coul_cut_intel.cpp b/src/USER-INTEL/pair_buck_coul_cut_intel.cpp index 1aec1dcbf7..010237dcdf 100644 --- a/src/USER-INTEL/pair_buck_coul_cut_intel.cpp +++ b/src/USER-INTEL/pair_buck_coul_cut_intel.cpp @@ -493,7 +493,7 @@ void PairBuckCoulCutIntel::ForceConst::set_ntypes(const int ntypes, const int ntable, Memory *memory, const int cop) { - if ( (ntypes != _ntypes || ntable != _ntable) ) { + if ((ntypes != _ntypes || ntable != _ntable)) { if (_ntypes > 0) { #ifdef _LMP_INTEL_OFFLOAD flt_t * ospecial_lj = special_lj; diff --git a/src/USER-INTEL/pair_buck_coul_long_intel.cpp b/src/USER-INTEL/pair_buck_coul_long_intel.cpp index d56b0dfd24..72d78fb6c7 100644 --- a/src/USER-INTEL/pair_buck_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_buck_coul_long_intel.cpp @@ -604,7 +604,7 @@ void PairBuckCoulLongIntel::ForceConst::set_ntypes(const int ntypes, const int ntable, Memory *memory, const int cop) { - if ( (ntypes != _ntypes || ntable != _ntable) ) { + if ((ntypes != _ntypes || ntable != _ntable)) { if (_ntypes > 0) { #ifdef _LMP_INTEL_OFFLOAD flt_t * ospecial_lj = special_lj; diff --git a/src/USER-INTEL/pair_buck_intel.cpp b/src/USER-INTEL/pair_buck_intel.cpp index 77f6a1136c..df81b6852f 100644 --- a/src/USER-INTEL/pair_buck_intel.cpp +++ b/src/USER-INTEL/pair_buck_intel.cpp @@ -442,7 +442,7 @@ template void PairBuckIntel::ForceConst::set_ntypes(const int ntypes, Memory *memory, const int cop) { - if ( (ntypes != _ntypes ) ) { + if ((ntypes != _ntypes )) { if (_ntypes > 0) { #ifdef _LMP_INTEL_OFFLOAD flt_t * ospecial_lj = special_lj; diff --git a/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp b/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp index ad15c045ab..b89deacc0b 100644 --- a/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp @@ -640,7 +640,7 @@ void PairLJCharmmCoulLongIntel::ForceConst::set_ntypes(const int ntypes, const int ntable, Memory *memory, const int cop) { - if ( (ntypes != _ntypes || ntable != _ntable) ) { + if ((ntypes != _ntypes || ntable != _ntable)) { if (_ntypes > 0) { #ifdef _LMP_INTEL_OFFLOAD flt_t * ospecial_lj = special_lj; diff --git a/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp b/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp index d6d763677c..111f5610b6 100644 --- a/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp @@ -599,7 +599,7 @@ void PairLJCutCoulLongIntel::ForceConst::set_ntypes(const int ntypes, const int ntable, Memory *memory, const int cop) { - if ( (ntypes != _ntypes || ntable != _ntable) ) { + if ((ntypes != _ntypes || ntable != _ntable)) { if (_ntypes > 0) { #ifdef _LMP_INTEL_OFFLOAD flt_t * ospecial_lj = special_lj; diff --git a/src/USER-INTEL/pair_tersoff_intel.cpp b/src/USER-INTEL/pair_tersoff_intel.cpp index bce2045f26..4284309b74 100644 --- a/src/USER-INTEL/pair_tersoff_intel.cpp +++ b/src/USER-INTEL/pair_tersoff_intel.cpp @@ -566,7 +566,7 @@ template void PairTersoffIntel::ForceConst::set_ntypes(const int ntypes, Memory *memory, const int cop) { - if ( (ntypes != _ntypes) ) { + if ((ntypes != _ntypes)) { if (_ntypes > 0) { #ifdef _LMP_INTEL_OFFLOAD c_first_loop_t * oc_first_loop = c_first_loop[0]; diff --git a/src/USER-MANIFOLD/fix_manifoldforce.cpp b/src/USER-MANIFOLD/fix_manifoldforce.cpp index bcb14ce1f9..d389b9787e 100644 --- a/src/USER-MANIFOLD/fix_manifoldforce.cpp +++ b/src/USER-MANIFOLD/fix_manifoldforce.cpp @@ -86,7 +86,7 @@ FixManifoldForce::FixManifoldForce(LAMMPS *lmp, int narg, char **arg) : // equal style vars (so that they are not overwritten each time step). double *params = ptr_m->params; - for( int i = 0; i < nvars; ++i ) { + for (int i = 0; i < nvars; ++i) { if (was_var( arg[i+4] )) error->all(FLERR,"Equal-style variables not allowed with fix manifoldforce"); diff --git a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp index bea7955d33..229dfd2433 100644 --- a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp +++ b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp @@ -117,7 +117,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, error->all(FLERR, msg); } // Loop over manifold args: - for( int i = 0; i < nvars; ++i ) { + for (int i = 0; i < nvars; ++i) { int len = 0, offset = 0; if (was_var( arg[i+6] )) { len = strlen(arg[i+6]) - 1; // -1 because -2 for v_, +1 for \0. @@ -135,7 +135,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, ptr_m->params = new double[nvars]; if (!ptr_m->params ) error->all(FLERR,"Failed to allocate params!"); - for( int i = 0; i < nvars; ++i ) { + for (int i = 0; i < nvars; ++i) { // If param i was variable type, it will be set later... ptr_m->params[i] = is_var[i] ? 0.0 : utils::numeric( FLERR, arg[i+6] ,false,lmp); } @@ -144,7 +144,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, // Loop over rest of args: int argi = 6 + nvars; - while( argi < narg ) { + while ( argi < narg) { if (strcmp(arg[argi], "every") == 0) { nevery = utils::inumeric(FLERR,arg[argi+1],false,lmp); next_output = update->ntimestep + nevery; @@ -170,7 +170,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, FixNVEManifoldRattle::~FixNVEManifoldRattle() { if (tstrs) { - for( int i = 0; i < nvars; ++i ) { + for (int i = 0; i < nvars; ++i) { delete [] tstrs[i]; } delete [] tstrs; @@ -277,7 +277,7 @@ void FixNVEManifoldRattle::update_var_params() double *ptr_params = ptr_m->params; - for( int i = 0; i < nvars; ++i ) { + for (int i = 0; i < nvars; ++i) { if (is_var[i]) { tvars[i] = input->variable->find(tstrs[i]); if (tvars[i] < 0) { @@ -306,7 +306,7 @@ int FixNVEManifoldRattle::dof(int /*igroup*/) int *mask = atom->mask; int nlocal = atom->nlocal; int natoms = 0; - for( int i = 0; i < nlocal; ++i ) { + for (int i = 0; i < nlocal; ++i) { if (mask[i] & groupbit) ++natoms; } @@ -508,7 +508,7 @@ void FixNVEManifoldRattle::rattle_manifold_x(double *x, double *v, const double c_inv = 1.0 / c; - while ( 1 ) { + while (1) { v[0] = vt[0] - l*no_dt[0]; v[1] = vt[1] - l*no_dt[1]; v[2] = vt[2] - l*no_dt[2]; @@ -643,7 +643,7 @@ void FixNVEManifoldRattle::rattle_manifold_v(double *v, double *f, res = infnorm<4>(R); ++iters; - }while( (res > tolerance) && (iters < max_iter) ); + } while ((res > tolerance) && (iters < max_iter)); if (iters >= max_iter && res >= tolerance) { char msg[2048]; diff --git a/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp b/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp index d8a5360506..9ac81aafb0 100644 --- a/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp +++ b/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp @@ -95,8 +95,7 @@ FixNVTManifoldRattle::FixNVTManifoldRattle(LAMMPS *lmp, int narg, char **arg, which = got_temp = 0; int argi = 6 + ptr_m->nparams(); - while( argi < narg ) - { + while (argi < narg) { if (strcmp( arg[argi], "temp") == 0) { if (argi+3 >= narg) error->all(FLERR,"Keyword 'temp' needs 3 arguments"); @@ -165,7 +164,7 @@ FixNVTManifoldRattle::FixNVTManifoldRattle(LAMMPS *lmp, int narg, char **arg, eta_dot[mtchain] = 0.0; eta_dot[mtchain] = 0.0; - for( int ich = 0; ich < mtchain; ++ich ) { + for (int ich = 0; ich < mtchain; ++ich) { eta[ich] = eta_dot[ich] = eta_dotdot[ich] = 0.0; } @@ -232,11 +231,11 @@ void FixNVTManifoldRattle::setup(int /*vflag*/) // Compute/set eta-masses: double inv_t_freq2 = 1.0 / (t_freq*t_freq); eta_mass[0] = tdof * boltz * t_target * inv_t_freq2; - for( int ich = 1; ich < mtchain; ++ich ) { + for (int ich = 1; ich < mtchain; ++ich) { eta_mass[ich] = boltz * t_target * inv_t_freq2; } - for( int ich = 1; ich < mtchain; ++ich ) { + for (int ich = 1; ich < mtchain; ++ich) { eta_dotdot[ich] = (eta_mass[ich-1]*eta_dot[ich-1]*eta_dot[ich-1] - boltz * t_target ) / eta_mass[ich]; } @@ -268,7 +267,7 @@ void FixNVTManifoldRattle::nhc_temp_integrate() double expfac, kecurrent = tdof * boltz * t_current; double inv_t_freq2 = 1.0 / (t_freq*t_freq); eta_mass[0] = tdof * boltz * t_target * inv_t_freq2; - for( int ich = 1; ich < mtchain; ++ich ) { + for (int ich = 1; ich < mtchain; ++ich) { eta_mass[ich] = boltz * t_target * inv_t_freq2; } @@ -278,7 +277,7 @@ void FixNVTManifoldRattle::nhc_temp_integrate() eta_dotdot[0] = 0; } - for( ich = mtchain-1; ich > 0; --ich ) { + for (ich = mtchain-1; ich > 0; --ich) { expfac = exp(-dt8*eta_dot[ich+1]); eta_dot[ich] *= expfac; eta_dot[ich] += eta_dotdot[ich] * dt4; @@ -311,14 +310,14 @@ void FixNVTManifoldRattle::nhc_temp_integrate() eta_dotdot[0] = 0.0; } - for( int ich = 1; ich < mtchain; ++ich ) { + for (int ich = 1; ich < mtchain; ++ich) { eta[ich] += dthalf*eta_dot[ich]; } eta_dot[0] *= expfac; eta_dot[0] += eta_dotdot[0]*dt4; eta_dot[0] *= expfac; - for( int ich = 1; ich < mtchain; ++ich ) { + for (int ich = 1; ich < mtchain; ++ich) { expfac = exp(-dt8*eta_dot[ich+1]); eta_dot[ich] *= expfac; eta_dotdot[ich] = (eta_mass[ich-1]*eta_dot[ich-1]*eta_dot[ich-1] @@ -340,7 +339,7 @@ void FixNVTManifoldRattle::nh_v_temp() if (which == NOBIAS) { - for( int i = 0; i < nlocal; ++i ) { + for (int i = 0; i < nlocal; ++i) { if (mask[i] & groupbit) { v[i][0] *= factor_eta; v[i][1] *= factor_eta; @@ -348,7 +347,7 @@ void FixNVTManifoldRattle::nh_v_temp() } } } else if (which == BIAS) { - for( int i = 0; i < nlocal; ++i ) { + for (int i = 0; i < nlocal; ++i) { if (mask[i] & groupbit) { temperature->remove_bias(i,v[i]); v[i][0] *= factor_eta; diff --git a/src/USER-MANIFOLD/manifold_gaussian_bump.cpp b/src/USER-MANIFOLD/manifold_gaussian_bump.cpp index 0864e1e2f2..79d0185d1b 100644 --- a/src/USER-MANIFOLD/manifold_gaussian_bump.cpp +++ b/src/USER-MANIFOLD/manifold_gaussian_bump.cpp @@ -69,7 +69,7 @@ public: double ff = x(t) - xx; double ffp = xp(t); // double l = 1.0 / ( 1 + res*res ); - for( int i = 0; i < maxit; ++i ) { + for (int i = 0; i < maxit; ++i) { t -= ff / ffp; ff = x(t) - xx; ffp = xp(t); @@ -294,7 +294,7 @@ void manifold_gaussian_bump::make_lut() cubic_hermite pchip( lut_x0, lut_x1, f_at_rc, 0.0, fp_at_rc, 0.0, error ); double xx = lut_x0; - for( int i = 0; i <= lut_Nbins; ++i ) { + for (int i = 0; i <= lut_Nbins; ++i) { lut_z[i] = pchip.y_from_x( xx ); lut_zp[i] = pchip.yp_from_x( xx ); xx += lut_dx; @@ -355,7 +355,7 @@ void manifold_gaussian_bump::test_lut() FILE *fp = fopen( "test_lut_gaussian.dat", "w" ); double dx = 0.1; - for( double xx = 0; xx < 20; xx += dx ) { + for (double xx = 0; xx < 20; xx += dx) { x[0] = xx; x[1] = 0.0; x[2] = 0.0; diff --git a/src/USER-MANIFOLD/manifold_thylakoid.cpp b/src/USER-MANIFOLD/manifold_thylakoid.cpp index c4dfd33c30..b7eab17fe1 100644 --- a/src/USER-MANIFOLD/manifold_thylakoid.cpp +++ b/src/USER-MANIFOLD/manifold_thylakoid.cpp @@ -57,17 +57,17 @@ void manifold_thylakoid::post_param_init() void manifold_thylakoid::checkup() { - if (comm->me == 0 ) { + if (comm->me == 0) { fprintf(screen,"This is checkup of thylakoid %p\n", this); fprintf(screen,"I have %ld parts. They are:\n", parts.size()); - for ( int i = 0; i < (int)parts.size(); ++i ) { + for (int i = 0; i < (int)parts.size(); ++i) { fprintf(screen, "[%f, %f] x [%f, %f] x [%f, %f]\n", parts[i]->xlo, parts[i]->xhi, parts[i]->ylo, parts[i]->yhi, parts[i]->zlo, parts[i]->zhi ); } fprintf(screen,"My params are:\n"); - for ( int i = 0; i < NPARAMS; ++i ) { + for (int i = 0; i < NPARAMS; ++i) { fprintf(screen,"%f\n", params[i]); } } @@ -120,7 +120,7 @@ void manifold_thylakoid::n( const double *x, double *n ) thyla_part *manifold_thylakoid::get_thyla_part( const double *x, int * /*err_flag*/, std::size_t *idx ) { - for ( std::size_t i = 0; i < parts.size(); ++i ) { + for (std::size_t i = 0; i < parts.size(); ++i) { thyla_part *p = parts[i]; if (is_in_domain(p,x)) { if (idx != nullptr) *idx = i; @@ -604,7 +604,7 @@ thyla_part *manifold_thylakoid::make_cyl_to_plane_part(double X0, double R0, dou void manifold_thylakoid::print_part_data( FILE *fp_doms, FILE *fp_coms ) { - for ( std::size_t i = 0; i < parts.size(); ++i ) { + for (std::size_t i = 0; i < parts.size(); ++i) { thyla_part *p = parts[i]; fprintf(fp_doms, "%f %f\n", p->xlo, p->ylo); fprintf(fp_doms, "%f %f\n", p->xlo, p->yhi); diff --git a/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp b/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp index c0b6871ea8..29e0ee82e9 100644 --- a/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp +++ b/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp @@ -40,7 +40,7 @@ thyla_part::thyla_part( int type, double *args, double xlo, double ylo, double z // The others should be 1. if ( (args[0] != 1.0) && (args[0] != 0.0) && (args[1] != 1.0) && (args[1] != 0.0) && - (args[2] != 1.0) && (args[2] != 0.0) ) { + (args[2] != 1.0) && (args[2] != 0.0)) { err_flag = -1; } break; diff --git a/src/USER-MESODPD/pair_edpd.cpp b/src/USER-MESODPD/pair_edpd.cpp index f7201052ff..04307429b4 100644 --- a/src/USER-MESODPD/pair_edpd.cpp +++ b/src/USER-MESODPD/pair_edpd.cpp @@ -275,7 +275,7 @@ void PairEDPD::settings(int narg, char **arg) // initialize Marsaglia RNG with processor-unique seed - if (seed <= 0 ) { + if (seed <= 0) { struct timespec time; clock_gettime( CLOCK_REALTIME, &time ); seed = time.tv_nsec; // if seed is non-positive, get the current time as the seed diff --git a/src/USER-MESODPD/pair_mdpd.cpp b/src/USER-MESODPD/pair_mdpd.cpp index 4dc42eb56a..30589e19bd 100644 --- a/src/USER-MESODPD/pair_mdpd.cpp +++ b/src/USER-MESODPD/pair_mdpd.cpp @@ -217,7 +217,7 @@ void PairMDPD::settings(int narg, char **arg) // initialize Marsaglia RNG with processor-unique seed - if (seed <= 0 ) { + if (seed <= 0) { struct timespec time; clock_gettime( CLOCK_REALTIME, &time ); seed = time.tv_nsec; // if seed is non-positive, get the current time as the seed diff --git a/src/USER-MESODPD/pair_tdpd.cpp b/src/USER-MESODPD/pair_tdpd.cpp index a416d94a00..a57b682c1c 100644 --- a/src/USER-MESODPD/pair_tdpd.cpp +++ b/src/USER-MESODPD/pair_tdpd.cpp @@ -239,7 +239,7 @@ void PairTDPD::settings(int narg, char **arg) // initialize Marsaglia RNG with processor-unique seed - if (seed <= 0 ) { + if (seed <= 0) { struct timespec time; clock_gettime( CLOCK_REALTIME, &time ); seed = time.tv_nsec; // if seed is non-positive, get the current time as the seed diff --git a/src/USER-MGPT/mgpt_readpot.cpp b/src/USER-MGPT/mgpt_readpot.cpp index 773c3d0fe9..9b89894f6f 100644 --- a/src/USER-MGPT/mgpt_readpot.cpp +++ b/src/USER-MGPT/mgpt_readpot.cpp @@ -75,7 +75,7 @@ static void getparmindata(const char *potin_file,int nvol[1],double vol0[1],doub vsize = 10; volarr = (double *) malloc(sizeof(double) * vsize); n = 0; - while(fgets(line,sizeof(line),in) != nullptr) { + while (fgets(line,sizeof(line),in) != nullptr) { double zval,ivol,rws,mass; double r0x,r1x,drx; int nrx,i; @@ -185,7 +185,7 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl in = fopen(parmin_file,"r"); do { fgets(line,sizeof(line),in); - } while(line[strspn(line," \t")] == '#'); + } while (line[strspn(line," \t")] == '#'); /* Test to see whether this is a one-line or two-line version of parmin */ if (sscanf(line,"%lf %lf %lf %lf %d",&ddl[1],&ddl[2],&ddl[3],&ddl[4],&L) == 5) { @@ -244,7 +244,7 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl do { fgets(line,sizeof(line),in); - } while(line[strspn(line," \t")] == '#'); + } while (line[strspn(line," \t")] == '#'); metalx[0] = 0; diff --git a/src/USER-MGPT/pair_mgpt.cpp b/src/USER-MGPT/pair_mgpt.cpp index b358b12857..75f870e1b2 100644 --- a/src/USER-MGPT/pair_mgpt.cpp +++ b/src/USER-MGPT/pair_mgpt.cpp @@ -481,7 +481,7 @@ void PairMGPT::force_debug_4(double xx[][3], trd2 = transtrace(T12->H1H2##coord,T45->H1H2 ); \ trd3 = transtrace(T12->H1H2 ,T45->H1##coord##H2); \ trd4 = transtrace(T12->H1H2 ,T45->H1H2##coord ); \ - } while(0) + } while (0) */ #define trd_update_4(T12,T45) \ do { \ @@ -510,7 +510,7 @@ void PairMGPT::force_debug_4(double xx[][3], trd1y = utr1y.d; trd2y = utr2y.d; trd3y = utr3y.d; trd4y = utr4y.d; \ trd1z = utr1z.d; trd2z = utr2z.d; trd3z = utr3z.d; trd4z = utr4z.d; \ } \ - } while(0) + } while (0) #define dfix_update_4a(coord) \ do { \ @@ -518,7 +518,7 @@ void PairMGPT::force_debug_4(double xx[][3], dfj##coord = ( ( sij)*trd1##coord + (-sjk)*trd2##coord ) * (ve / anorm4); \ dfk##coord = ( ( sjk)*trd2##coord + (-skm)*trd4##coord ) * (ve / anorm4); \ dfm##coord = ( ( sim)*trd3##coord + ( skm)*trd4##coord ) * (ve / anorm4); \ - } while(0) + } while (0) #define dfix_update_4b(coord) \ @@ -527,7 +527,7 @@ void PairMGPT::force_debug_4(double xx[][3], dfj##coord = ( (-sjk)*trd2##coord + (-sjm)*trd4##coord ) * (ve / anorm4); \ dfk##coord = ( (-ski)*trd1##coord + ( sjk)*trd2##coord ) * (ve / anorm4); \ dfm##coord = ( ( sim)*trd3##coord + ( sjm)*trd4##coord ) * (ve / anorm4); \ - } while(0); + } while (0); #define dfix_update_4c(coord) \ do { \ @@ -535,7 +535,7 @@ void PairMGPT::force_debug_4(double xx[][3], dfj##coord = ( ( sij)*trd1##coord + (-sjm)*trd3##coord ) * (ve / anorm4); \ dfk##coord = ( (-ski)*trd2##coord + (-skm)*trd4##coord ) * (ve / anorm4); \ dfm##coord = ( ( sjm)*trd3##coord + ( skm)*trd4##coord ) * (ve / anorm4); \ - } while(0); + } while (0); #define accumulate_forces_2(w) \ do { \ @@ -546,7 +546,7 @@ void PairMGPT::force_debug_4(double xx[][3], fjx = fjx + dfjx*(w); \ fjy = fjy + dfjy*(w); \ fjz = fjz + dfjz*(w); \ - } while(0) + } while (0) #define accumulate_forces_3(w) \ do { \ @@ -554,7 +554,7 @@ void PairMGPT::force_debug_4(double xx[][3], fkx = fkx + dfkx*(w); \ fky = fky + dfky*(w); \ fkz = fkz + dfkz*(w); \ - } while(0) + } while (0) #define accumulate_forces_4(w) \ do { \ @@ -562,7 +562,7 @@ void PairMGPT::force_debug_4(double xx[][3], fmx = fmx + dfmx*(w); \ fmy = fmy + dfmy*(w); \ fmz = fmz + dfmz*(w); \ - } while(0) + } while (0) @@ -868,7 +868,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, */ p = first[i+1]-1; - while(p >= first[i] && nlist_short[p] > j) { + while (p >= first[i] && nlist_short[p] > j) { nlist_short[p+1] = nlist_short[p]; p = p - 1; } @@ -941,7 +941,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, Since i is in the j-list, and i > k and the list is sorted, the loop below terminates:-) */ - while(mj < first[j+1] && nlist_short[mj] < k) mj = mj + 1; + while (mj < first[j+1] && nlist_short[mj] < k) mj = mj + 1; if (mj < first[j+1] && nlist_short[mj] == k) { /* Closed triplet */ c_jk = 1; @@ -1265,7 +1265,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, i is in both the j-list and the k-list, and i > k, and lists are sorted, so the loop terminates. */ - while(nlist_short[mj] < i && nlist_short[mk] < i) { + while (nlist_short[mj] < i && nlist_short[mk] < i) { if (mj >= first[j+1] || mk >= first[k+1]) { printf("Illegal quad...\n" @@ -1291,7 +1291,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, /* Alrady know ij,jk,ki,jm,km bonds. Look for im bond. */ mi = first[i]; - while(mi < first[i+1] && nlist_short[mi] < m) mi = mi + 1; + while (mi < first[i+1] && nlist_short[mi] < m) mi = mi + 1; if (mi < first[i+1] && nlist_short[mi] == m) c_im = 1; else @@ -1613,7 +1613,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, { Hash::Iterator iter = bond_hash.begin(); int nitem = 0,nhit = 0; - while(iter != bond_hash.end()) { + while (iter != bond_hash.end()) { nitem++; nhit += iter.link()->hits; iter.next(); @@ -2149,7 +2149,7 @@ void PairMGPT::fl_deriv_new(double r,double ri,double xhat,double yhat,double zh Mx[j][i] = Mx[i][j] = fl_x*tmp + fl_ri*(tmpx - x*tmpsum); \ My[j][i] = My[i][j] = fl_y*tmp + fl_ri*(tmpy - y*tmpsum); \ Mz[j][i] = Mz[i][j] = fl_z*tmp + fl_ri*(tmpz - z*tmpsum); \ - } while(0) + } while (0) #define MAKE_ELEMENT_7(i,j) \ do { \ @@ -2168,7 +2168,7 @@ void PairMGPT::fl_deriv_new(double r,double ri,double xhat,double yhat,double zh Mx[j][i] = Mx[i][j] = fl_x*tmp + fl_ri*(tmpx - x*tmpsum); \ My[j][i] = My[i][j] = fl_y*tmp + fl_ri*(tmpy - y*tmpsum); \ Mz[j][i] = Mz[i][j] = fl_z*tmp + fl_ri*(tmpz - z*tmpsum); \ - } while(0) + } while (0) /* End of bond matrix macros */ diff --git a/src/USER-MISC/angle_fourier.cpp b/src/USER-MISC/angle_fourier.cpp index 0194626e81..47b74fad99 100644 --- a/src/USER-MISC/angle_fourier.cpp +++ b/src/USER-MISC/angle_fourier.cpp @@ -204,9 +204,9 @@ void AngleFourier::coeff(int narg, char **arg) double AngleFourier::equilibrium_angle(int i) { double ret=MY_PI; - if ( C2[i] != 0.0 ) { + if (C2[i] != 0.0) { ret = (C1[i]/4.0/C2[i]); - if ( fabs(ret) <= 1.0 ) ret = acos(-ret); + if (fabs(ret) <= 1.0) ret = acos(-ret); } return ret; } diff --git a/src/USER-MISC/angle_fourier_simple.cpp b/src/USER-MISC/angle_fourier_simple.cpp index 4a3e64c6a9..2b40c2f12f 100644 --- a/src/USER-MISC/angle_fourier_simple.cpp +++ b/src/USER-MISC/angle_fourier_simple.cpp @@ -118,10 +118,10 @@ void AngleFourierSimple::compute(int eflag, int vflag) // handle sin(n th)/sin(th) singulatiries - if ( fabs(c)-1.0 > 0.0001 ) { + if (fabs(c)-1.0 > 0.0001) { a = k[type]*C[type]*N[type]*sin(nth)/sin(th); } else { - if ( c >= 0.0 ) { + if (c >= 0.0) { term = 1.0 - c; sgn = 1.0; } else { diff --git a/src/USER-MISC/angle_gaussian.cpp b/src/USER-MISC/angle_gaussian.cpp index 66da9e792e..2150ef7a4b 100644 --- a/src/USER-MISC/angle_gaussian.cpp +++ b/src/USER-MISC/angle_gaussian.cpp @@ -217,7 +217,7 @@ void AngleGaussian::coeff(int narg, char **arg) alpha[i] = new double [n]; width[i] = new double [n]; theta0[i] = new double [n]; - for (int j = 0; j < n; j++ ) { + for (int j = 0; j < n; j++) { alpha[i][j] = utils::numeric(FLERR,arg[3+3*j],false,lmp); width[i][j] = utils::numeric(FLERR,arg[4+3*j],false,lmp); theta0[i][j] = utils::numeric(FLERR,arg[5+3*j],false,lmp)* MY_PI / 180.0; diff --git a/src/USER-MISC/bond_gaussian.cpp b/src/USER-MISC/bond_gaussian.cpp index 42f76eda75..dcb8d7a4ad 100644 --- a/src/USER-MISC/bond_gaussian.cpp +++ b/src/USER-MISC/bond_gaussian.cpp @@ -171,7 +171,7 @@ void BondGaussian::coeff(int narg, char **arg) alpha[i] = new double [n]; width[i] = new double [n]; r0[i] = new double [n]; - for (int j = 0; j < n; j++ ) { + for (int j = 0; j < n; j++) { alpha[i][j] = utils::numeric(FLERR,arg[3+3*j],false,lmp); width[i][j] = utils::numeric(FLERR,arg[4+3*j],false,lmp); r0[i][j] = utils::numeric(FLERR,arg[5+3*j],false,lmp); diff --git a/src/USER-MISC/compute_entropy_atom.cpp b/src/USER-MISC/compute_entropy_atom.cpp index 1362da447b..2fea708a71 100644 --- a/src/USER-MISC/compute_entropy_atom.cpp +++ b/src/USER-MISC/compute_entropy_atom.cpp @@ -122,7 +122,7 @@ void ComputeEntropyAtom::init() error->all(FLERR,"Compute entropy/atom requires a pair style be" " defined"); - if ( (cutoff+cutoff2) > (force->pair->cutforce + neighbor->skin) ) + if ((cutoff+cutoff2) > (force->pair->cutforce + neighbor->skin)) { error->all(FLERR,"Compute entropy/atom cutoff is longer than the" " pairwise cutoff. Increase the neighbor list skin" diff --git a/src/USER-MISC/compute_stress_mop.cpp b/src/USER-MISC/compute_stress_mop.cpp index a1f88aadaf..87de00cedd 100644 --- a/src/USER-MISC/compute_stress_mop.cpp +++ b/src/USER-MISC/compute_stress_mop.cpp @@ -67,7 +67,7 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : pos = 0.5*(domain->boxlo[dir]+domain->boxhi[dir]); } else pos = utils::numeric(FLERR,arg[4],false,lmp); - if ( pos < (domain->boxlo[dir]+domain->prd_half[dir]) ) { + if (pos < (domain->boxlo[dir]+domain->prd_half[dir])) { pos1 = pos + domain->prd[dir]; } else { pos1 = pos - domain->prd[dir]; @@ -319,7 +319,7 @@ void ComputeStressMop::compute_pairs() if (newton_pair || j < nlocal) { //check if ij pair is across plane, add contribution to pressure - if ( ((xi[dir]>pos) && (xj[dir]pos1) && (xj[dir]pos) && (xj[dir]pos1) && (xj[dir]single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); @@ -327,7 +327,7 @@ void ComputeStressMop::compute_pairs() values_local[m+1] += fpair*(xi[1]-xj[1])/area*nktv2p; values_local[m+2] += fpair*(xi[2]-xj[2])/area*nktv2p; } - else if ( ((xi[dir]pos)) || ((xi[dir]pos1)) ) { + else if (((xi[dir]pos)) || ((xi[dir]pos1))) { pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); @@ -338,7 +338,7 @@ void ComputeStressMop::compute_pairs() } else { - if ( ((xi[dir]>pos) && (xj[dir]pos1) && (xj[dir]pos) && (xj[dir]pos1) && (xj[dir]single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); diff --git a/src/USER-MISC/compute_stress_mop_profile.cpp b/src/USER-MISC/compute_stress_mop_profile.cpp index 3bd0139dea..4861e49e7e 100644 --- a/src/USER-MISC/compute_stress_mop_profile.cpp +++ b/src/USER-MISC/compute_stress_mop_profile.cpp @@ -336,7 +336,7 @@ void ComputeStressMopProfile::compute_pairs() //check if ij pair is across plane, add contribution to pressure if ( ((xi[dir]>pos) && (xj[dir]pos1) && (xj[dir]pos1) && (xj[dir]single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); @@ -345,7 +345,7 @@ void ComputeStressMopProfile::compute_pairs() values_local[ibin][m+2] += fpair*(xi[2]-xj[2])/area*nktv2p; } else if ( ((xi[dir]pos)) - || ((xi[dir]pos1)) ) { + || ((xi[dir]pos1))) { pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); @@ -363,7 +363,7 @@ void ComputeStressMopProfile::compute_pairs() //check if ij pair is across plane, add contribution to pressure if ( ((xi[dir]>pos) && (xj[dir]pos1) && (xj[dir]pos1) && (xj[dir]single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); @@ -499,7 +499,7 @@ void ComputeStressMopProfile::setup_bins() // set bin coordinates for (i = 0; i < nbins; i++) { coord[i][0] = offset + i*delta; - if ( coord[i][0] < (domain->boxlo[dir]+domain->prd_half[dir]) ) { + if (coord[i][0] < (domain->boxlo[dir]+domain->prd_half[dir])) { coordp[i][0] = coord[i][0] + domain->prd[dir]; } else { coordp[i][0] = coord[i][0] - domain->prd[dir]; diff --git a/src/USER-MISC/dihedral_fourier.cpp b/src/USER-MISC/dihedral_fourier.cpp index e4a61787a2..7ca8260bfe 100644 --- a/src/USER-MISC/dihedral_fourier.cpp +++ b/src/USER-MISC/dihedral_fourier.cpp @@ -50,11 +50,11 @@ DihedralFourier::~DihedralFourier() memory->destroy(nterms); for (int i=1; i<= atom->ndihedraltypes; i++) { - if ( k[i] ) delete [] k[i]; - if ( multiplicity[i] ) delete [] multiplicity[i]; - if ( shift[i] ) delete [] shift[i]; - if ( cos_shift[i] ) delete [] cos_shift[i]; - if ( sin_shift[i] ) delete [] sin_shift[i]; + if (k[i]) delete [] k[i]; + if (multiplicity[i]) delete [] multiplicity[i]; + if (shift[i]) delete [] shift[i]; + if (cos_shift[i]) delete [] cos_shift[i]; + if (sin_shift[i]) delete [] sin_shift[i]; } delete [] k; delete [] multiplicity; diff --git a/src/USER-MISC/dihedral_nharmonic.cpp b/src/USER-MISC/dihedral_nharmonic.cpp index 1041062530..03f235b166 100644 --- a/src/USER-MISC/dihedral_nharmonic.cpp +++ b/src/USER-MISC/dihedral_nharmonic.cpp @@ -47,7 +47,7 @@ DihedralNHarmonic::~DihedralNHarmonic() if (allocated) { memory->destroy(setflag); for (int i = 1; i <= atom->ndihedraltypes; i++) - if ( a[i] ) delete [] a[i]; + if (a[i]) delete [] a[i]; delete [] a; delete [] nterms; } @@ -290,7 +290,7 @@ void DihedralNHarmonic::coeff(int narg, char **arg) for (int i = ilo; i <= ihi; i++) { a[i] = new double [n]; nterms[i] = n; - for (int j = 0; j < n; j++ ) { + for (int j = 0; j < n; j++) { a[i][j] = utils::numeric(FLERR,arg[2+j],false,lmp); setflag[i] = 1; } diff --git a/src/USER-MISC/dihedral_spherical.cpp b/src/USER-MISC/dihedral_spherical.cpp index 2f77887de9..4d753423f5 100644 --- a/src/USER-MISC/dihedral_spherical.cpp +++ b/src/USER-MISC/dihedral_spherical.cpp @@ -52,16 +52,16 @@ DihedralSpherical::~DihedralSpherical() memory->destroy(nterms); for (int i=1; i<= atom->ndihedraltypes; i++) { - if ( Ccoeff[i] ) delete [] Ccoeff[i]; - if ( phi_mult[i] ) delete [] phi_mult[i]; - if ( phi_shift[i] ) delete [] phi_shift[i]; - if ( phi_offset[i] ) delete [] phi_offset[i]; - if ( theta1_mult[i] ) delete [] theta1_mult[i]; - if ( theta1_shift[i] ) delete [] theta1_shift[i]; - if ( theta1_offset[i] ) delete [] theta1_offset[i]; - if ( theta2_mult[i] ) delete [] theta2_mult[i]; - if ( theta2_shift[i] ) delete [] theta2_shift[i]; - if ( theta2_offset[i] ) delete [] theta2_offset[i]; + if (Ccoeff[i]) delete [] Ccoeff[i]; + if (phi_mult[i]) delete [] phi_mult[i]; + if (phi_shift[i]) delete [] phi_shift[i]; + if (phi_offset[i]) delete [] phi_offset[i]; + if (theta1_mult[i]) delete [] theta1_mult[i]; + if (theta1_shift[i]) delete [] theta1_shift[i]; + if (theta1_offset[i]) delete [] theta1_offset[i]; + if (theta2_mult[i]) delete [] theta2_mult[i]; + if (theta2_shift[i]) delete [] theta2_shift[i]; + if (theta2_offset[i]) delete [] theta2_offset[i]; } delete [] Ccoeff; delete [] phi_mult; diff --git a/src/USER-MISC/fix_flow_gauss.cpp b/src/USER-MISC/fix_flow_gauss.cpp index 0dabf82436..b1b4174352 100644 --- a/src/USER-MISC/fix_flow_gauss.cpp +++ b/src/USER-MISC/fix_flow_gauss.cpp @@ -84,10 +84,10 @@ FixFlowGauss::FixFlowGauss(LAMMPS *lmp, int narg, char **arg) : // process optional keyword int iarg = 6; while (iarg < narg) { - if ( strcmp(arg[iarg],"energy") == 0 ) { - if ( iarg+2 > narg ) error->all(FLERR,"Illegal energy keyword"); - if ( strcmp(arg[iarg+1],"yes") == 0 ) workflag = 1; - else if ( strcmp(arg[iarg+1],"no") != 0 ) + if (strcmp(arg[iarg],"energy") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal energy keyword"); + if (strcmp(arg[iarg+1],"yes") == 0) workflag = 1; + else if (strcmp(arg[iarg+1],"no") != 0) error->all(FLERR,"Illegal energy keyword"); iarg += 2; } else error->all(FLERR,"Illegal fix flow/gauss command"); diff --git a/src/USER-MISC/fix_imd.cpp b/src/USER-MISC/fix_imd.cpp index 0f0f601584..0da5b29b62 100644 --- a/src/USER-MISC/fix_imd.cpp +++ b/src/USER-MISC/fix_imd.cpp @@ -146,7 +146,7 @@ static void rebuild_table_tagint(taginthash_t *tptr) { taginthash_init(tptr, old_size<<1); for (i=0; inext; h=taginthash(tptr, tmp->key); @@ -349,7 +349,7 @@ static void id_sort(tagint *idmap, tagint left, tagint right) #include -#if ( INT_MAX == 2147483647 ) +#if (INT_MAX == 2147483647) typedef int int32; #else typedef short int32; diff --git a/src/USER-MISC/fix_ipi.cpp b/src/USER-MISC/fix_ipi.cpp index 7fb696ce8c..1f1b527816 100644 --- a/src/USER-MISC/fix_ipi.cpp +++ b/src/USER-MISC/fix_ipi.cpp @@ -155,7 +155,7 @@ static void readbuffer(int sockfd, char *data, int len, Error* error) n = nr = read(sockfd,data,len); - while (nr>0 && n0 && nmask; int nlocal = atom->nlocal; - for( int i = 0; i < nlocal; i++ ) { // Iterate through all atoms on this CPU + for (int i = 0; i < nlocal; i++) { // Iterate through all atoms on this CPU if (mask[i] & groupbit) { // ...only those affected by this fix nThisLocal++; } @@ -156,7 +156,7 @@ FixRhok::post_force( int /*inVFlag*/ ) mRhoKLocal[0] = 0.0; mRhoKLocal[1] = 0.0; - for( int i = 0; i < nlocal; i++ ) { // Iterate through all atoms on this CPU + for (int i = 0; i < nlocal; i++) { // Iterate through all atoms on this CPU if (mask[i] & groupbit) { // ...only those affected by this fix // rho_k = sum_i exp( - i k.r_i ) @@ -179,7 +179,7 @@ FixRhok::post_force( int /*inVFlag*/ ) double rhoK = sqrt( mRhoKGlobal[0]*mRhoKGlobal[0] + mRhoKGlobal[1]*mRhoKGlobal[1] ); - for( int i = 0; i < nlocal; i++ ) { // Iterate through all atoms on this CPU + for (int i = 0; i < nlocal; i++) { // Iterate through all atoms on this CPU if (mask[i] & groupbit) { // ...only those affected by this fix // Calculate forces @@ -235,9 +235,9 @@ FixRhok::compute_vector( int inI ) { if (inI == 0) return mRhoKGlobal[0]; // Real part - else if ( inI == 1 ) + else if (inI == 1) return mRhoKGlobal[1]; // Imagniary part - else if ( inI == 2 ) + else if (inI == 2) return sqrt( mRhoKGlobal[0]*mRhoKGlobal[0] + mRhoKGlobal[1]*mRhoKGlobal[1] ); else diff --git a/src/USER-MISC/fix_ti_spring.cpp b/src/USER-MISC/fix_ti_spring.cpp index 3a87dfa96d..5aac36a47b 100644 --- a/src/USER-MISC/fix_ti_spring.cpp +++ b/src/USER-MISC/fix_ti_spring.cpp @@ -222,12 +222,12 @@ void FixTISpring::initial_integrate(int /*vflag*/) const bigint t = update->ntimestep - (t0+t_equil); const double r_switch = 1.0/t_switch; - if ( (t >= 0) && (t <= t_switch) ) { + if ((t >= 0) && (t <= t_switch)) { lambda = switch_func(t*r_switch); dlambda = dswitch_func(t*r_switch); } - if ( (t >= t_equil+t_switch) && (t <= (t_equil+2*t_switch)) ) { + if ((t >= t_equil+t_switch) && (t <= (t_equil+2*t_switch))) { lambda = switch_func(1.0 - (t - t_switch - t_equil)*r_switch); dlambda = - dswitch_func(1.0 - (t - t_switch - t_equil)*r_switch); } diff --git a/src/USER-MISC/improper_fourier.cpp b/src/USER-MISC/improper_fourier.cpp index 89b2333e1c..e03ef33cda 100644 --- a/src/USER-MISC/improper_fourier.cpp +++ b/src/USER-MISC/improper_fourier.cpp @@ -92,7 +92,7 @@ void ImproperFourier::compute(int eflag, int vflag) vb1x, vb1y, vb1z, vb2x, vb2y, vb2z, vb3x, vb3y, vb3z); - if ( all[type] ) { + if (all[type]) { addone(i1,i4,i2,i3, type,evflag,eflag, vb3x, vb3y, vb3z, vb1x, vb1y, vb1z, @@ -274,7 +274,7 @@ void ImproperFourier::allocate() void ImproperFourier::coeff(int narg, char **arg) { - if ( narg != 5 && narg != 6 ) error->all(FLERR,"Incorrect args for improper coefficients"); + if (narg != 5 && narg != 6) error->all(FLERR,"Incorrect args for improper coefficients"); if (!allocated) allocate(); @@ -286,7 +286,7 @@ void ImproperFourier::coeff(int narg, char **arg) double C1_one = utils::numeric(FLERR,arg[3],false,lmp); double C2_one = utils::numeric(FLERR,arg[4],false,lmp); int all_one = 1; - if ( narg == 6 ) all_one = utils::inumeric(FLERR,arg[5],false,lmp); + if (narg == 6) all_one = utils::inumeric(FLERR,arg[5],false,lmp); // convert w0 from degrees to radians diff --git a/src/USER-MISC/pair_e3b.cpp b/src/USER-MISC/pair_e3b.cpp index dceed1fc57..ae65d68d89 100644 --- a/src/USER-MISC/pair_e3b.cpp +++ b/src/USER-MISC/pair_e3b.cpp @@ -418,7 +418,7 @@ void PairE3B::coeff(int narg, char **arg) rs=rc3=rc2=0.0; int iarg = 2; //beginning of keyword/value pairs - while(iarg < narg) { + while (iarg < narg) { char *keyword = arg[iarg++]; if (checkKeyword(keyword,"Ea",1,narg-iarg)) ea=utils::numeric(FLERR,arg[iarg++],false,lmp); diff --git a/src/USER-MISC/pair_extep.cpp b/src/USER-MISC/pair_extep.cpp index 2d0001c680..00ab46e697 100644 --- a/src/USER-MISC/pair_extep.cpp +++ b/src/USER-MISC/pair_extep.cpp @@ -362,7 +362,7 @@ void PairExTeP::compute(int eflag, int vflag) f[k][0] -= fc_prefac_ik * delr2[0]; f[k][1] -= fc_prefac_ik * delr2[1]; f[k][2] -= fc_prefac_ik * delr2[2]; - if ( itype != ktype ) { + if (itype != ktype) { fc_prefac_ik = dFc_dNdij * fc_prefac_ik_0; f[i][0] += fc_prefac_ik * delr2[0]; f[i][1] += fc_prefac_ik * delr2[1]; @@ -1094,8 +1094,8 @@ void PairExTeP::costheta_d(double *rij_hat, double rij, void PairExTeP::spline_init() { for ( int iel=0; ielcreate(style,num,"pair_list:style"); memory->create(params,num,"pair_list:params"); @@ -227,7 +227,7 @@ void PairList::settings(int narg, char **arg) tagint id1, id2; int nharm=0, nmorse=0, nlj126=0; - while(fgets(line,1024,fp)) { + while (fgets(line,1024,fp)) { ptr = strtok(line," \t\n\r\f"); // skip empty lines diff --git a/src/USER-MISC/pair_local_density.cpp b/src/USER-MISC/pair_local_density.cpp index 3da1fcbed2..dc4e694995 100644 --- a/src/USER-MISC/pair_local_density.cpp +++ b/src/USER-MISC/pair_local_density.cpp @@ -594,7 +594,7 @@ void PairLocalDensity::interpolate_cbspl(int n, double delta, fpa = 0.; fpb = 0.; - for ( i = 0; i < n-1; i++ ) { + for (i = 0; i < n-1; i++) { dl[i] = du[i] = delta; } @@ -602,32 +602,32 @@ void PairLocalDensity::interpolate_cbspl(int n, double delta, dd[n-1] = 2.0 * delta; coeff_c[0] = ( 3.0 / delta ) * ( f[1] - f[0] ) - 3.0 * fpa; coeff_c[n-1] = 3.0 * fpb - ( 3.0 / delta ) * ( f[n-1] - f[n-2] ); - for ( i = 0; i < n-2; i++ ) { + for (i = 0; i < n-2; i++) { dd[i+1] = 4.0 * delta; coeff_c[i+1] = ( 3.0 / delta ) * ( f[i+2] - f[i+1] ) - ( 3.0 / delta ) * ( f[i+1] - f[i] ); } // tridiagonal solver - for ( i = 0; i < n-1; i++ ) { + for (i = 0; i < n-1; i++) { du[i] /= dd[i]; dd[i+1] -= dl[i]*du[i]; } coeff_c[0] /= dd[0]; - for ( i = 1; i < n; i++ ) + for (i = 1; i < n; i++) coeff_c[i] = ( coeff_c[i] - dl[i-1] * coeff_c[i-1] ) / dd[i]; - for ( i = n-2; i >= 0; i-- ) + for (i = n-2; i >= 0; i--) coeff_c[i] -= coeff_c[i+1] * du[i]; - for ( i = 0; i < n-1; i++ ) { + for (i = 0; i < n-1; i++) { coeff_d[i] = ( coeff_c[i+1] - coeff_c[i] ) / ( 3.0 * delta ); coeff_b[i] = ( f[i+1] - f[i] ) / delta - delta * ( coeff_c[i+1] + 2.0*coeff_c[i] ) / 3.0; } // normalize - for ( i = 0; i < n-1; i++ ) { + for (i = 0; i < n-1; i++) { coeff_b[i] = coeff_b[i] * delta ; coeff_c[i] = coeff_c[i] * delta*delta ; coeff_d[i] = coeff_d[i] * delta*delta*delta; diff --git a/src/USER-MISC/pair_meam_spline.cpp b/src/USER-MISC/pair_meam_spline.cpp index 57981e8922..a6bf602c70 100644 --- a/src/USER-MISC/pair_meam_spline.cpp +++ b/src/USER-MISC/pair_meam_spline.cpp @@ -632,7 +632,7 @@ int PairMEAMSpline::pack_forward_comm(int n, int *list, double *buf, { int* list_iter = list; int* list_iter_end = list + n; - while(list_iter != list_iter_end) + while (list_iter != list_iter_end) *buf++ = Uprime_values[*list_iter++]; return n; } diff --git a/src/USER-MISC/pair_meam_sw_spline.cpp b/src/USER-MISC/pair_meam_sw_spline.cpp index 09f5fa436d..58c0f75546 100644 --- a/src/USER-MISC/pair_meam_sw_spline.cpp +++ b/src/USER-MISC/pair_meam_sw_spline.cpp @@ -562,7 +562,7 @@ int PairMEAMSWSpline::pack_forward_comm(int n, int *list, double *buf, { int* list_iter = list; int* list_iter_end = list + n; - while(list_iter != list_iter_end) + while (list_iter != list_iter_end) *buf++ = Uprime_values[*list_iter++]; return n; } diff --git a/src/USER-MISC/pair_tersoff_table.cpp b/src/USER-MISC/pair_tersoff_table.cpp index 9eae918128..0d5bbc1147 100644 --- a/src/USER-MISC/pair_tersoff_table.cpp +++ b/src/USER-MISC/pair_tersoff_table.cpp @@ -860,7 +860,7 @@ void PairTersoffTable::read_file(char *file) double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/USER-MOLFILE/molfile_interface.cpp b/src/USER-MOLFILE/molfile_interface.cpp index ecc2b7468f..1ced86da86 100644 --- a/src/USER-MOLFILE/molfile_interface.cpp +++ b/src/USER-MOLFILE/molfile_interface.cpp @@ -54,7 +54,7 @@ extern "C" { // make sure we have the proper plugin type (native reader) // for the desired file type (called "name" at this level) if ((strcmp(MOLFILE_PLUGIN_TYPE,p->type) == 0) - && (strcmp(r->name, p->name) == 0) ) { + && (strcmp(r->name, p->name) == 0)) { r->p = static_cast(p); } return 0; @@ -408,7 +408,7 @@ int MolfileInterface::find_plugin(const char *pluginpath) retval = (retval > E_DIR) ? retval : E_DIR; // search for suitable file names and try to inspect them - while(dir) { + while (dir) { char *fullname; int len; @@ -515,7 +515,7 @@ int MolfileInterface::load_plugin(const char *filename) // check if the new plugin is of a newer minor version } else if ( (p->majorv == plugin->majorv) && - (p->minorv >= plugin->minorv) ) { + (p->minorv >= plugin->minorv)) { retval = E_VERSION; } } diff --git a/src/USER-MOLFILE/reader_molfile.cpp b/src/USER-MOLFILE/reader_molfile.cpp index 458f9190f1..4820d9a861 100644 --- a/src/USER-MOLFILE/reader_molfile.cpp +++ b/src/USER-MOLFILE/reader_molfile.cpp @@ -302,11 +302,11 @@ bigint ReaderMolfile::read_header(double box[3][3], int &boxinfo, int &triclinic (fieldtype[i] == Y) || (fieldtype[i] == Z) || (fieldtype[i] == ID) || - (fieldtype[i] == TYPE) ) { + (fieldtype[i] == TYPE)) { fieldindex[i] = fieldtype[i]; } else if ( (fieldtype[i] == VX) || (fieldtype[i] == VY) || - (fieldtype[i] == VZ) ) { + (fieldtype[i] == VZ)) { fieldindex[i] = fieldtype[i]; needvels = 1; } else { diff --git a/src/USER-OMP/angle_fourier_simple_omp.cpp b/src/USER-OMP/angle_fourier_simple_omp.cpp index 9ccf078342..0be602f3b0 100644 --- a/src/USER-OMP/angle_fourier_simple_omp.cpp +++ b/src/USER-OMP/angle_fourier_simple_omp.cpp @@ -135,10 +135,10 @@ void AngleFourierSimpleOMP::eval(int nfrom, int nto, ThrData * const thr) // handle sin(n th)/sin(th) singulatiries - if ( fabs(c)-1.0 > 0.0001 ) { + if (fabs(c)-1.0 > 0.0001) { a = k[type]*C[type]*N[type]*sin(nth)/sin(th); } else { - if ( c >= 0.0 ) { + if (c >= 0.0) { term = 1.0 - c; sgn = 1.0; } else { diff --git a/src/USER-OMP/fix_qeq_comb_omp.cpp b/src/USER-OMP/fix_qeq_comb_omp.cpp index 957c49abe6..aceff62ebc 100644 --- a/src/USER-OMP/fix_qeq_comb_omp.cpp +++ b/src/USER-OMP/fix_qeq_comb_omp.cpp @@ -125,7 +125,7 @@ void FixQEQCombOMP::post_force(int /* vflag */) q1[i] = q2[i] = qf[i] = 0.0; } - for (iloop = 0; iloop < loopmax; iloop ++ ) { + for (iloop = 0; iloop < loopmax; iloop ++) { for (ii = 0; ii < inum; ii++) { i = ilist[ii]; if (mask[i] & groupbit) { diff --git a/src/USER-OMP/improper_fourier_omp.cpp b/src/USER-OMP/improper_fourier_omp.cpp index 5d2a03ccd3..b38b642dbc 100644 --- a/src/USER-OMP/improper_fourier_omp.cpp +++ b/src/USER-OMP/improper_fourier_omp.cpp @@ -120,7 +120,7 @@ void ImproperFourierOMP::eval(int nfrom, int nto, ThrData * const thr) vb1x,vb1y,vb1z, vb2x,vb2y,vb2z, vb3x,vb3y,vb3z,thr); - if ( all[type] ) { + if (all[type]) { add1_thr(i1,i4,i2,i3,type, vb3x,vb3y,vb3z, vb1x,vb1y,vb1z, diff --git a/src/USER-OMP/pair_comb_omp.cpp b/src/USER-OMP/pair_comb_omp.cpp index 045db5d402..2da9ca8d8f 100644 --- a/src/USER-OMP/pair_comb_omp.cpp +++ b/src/USER-OMP/pair_comb_omp.cpp @@ -242,7 +242,7 @@ void PairCombOMP::eval(int iifrom, int iito, ThrData * const thr) jtype = map[type[j]]; iparam_ij = elem2param[itype][jtype][jtype]; - if (params[iparam_ij].hfocor > 0.0 ) { + if (params[iparam_ij].hfocor > 0.0) { delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; delr1[2] = x[j][2] - ztmp; diff --git a/src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp b/src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp index 0b8efe25ef..4dadd0a1ea 100644 --- a/src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp +++ b/src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp @@ -1189,7 +1189,7 @@ void PairLJLongTIP4PLongOMP::eval_inner(int iifrom, int iito, ThrData * const th rsq = delx*delx + dely*dely + delz*delz; jtype = type[j]; - if (rsq < cut_ljsq[itype][jtype] && rsq < cut_out_off_sq ) { // lj + if (rsq < cut_ljsq[itype][jtype] && rsq < cut_out_off_sq) { // lj r2inv = 1.0/rsq; double rn = r2inv*r2inv*r2inv; if (ni == 0) forcelj = rn*(rn*lj1i[jtype]-lj2i[jtype]); @@ -1443,7 +1443,7 @@ void PairLJLongTIP4PLongOMP::eval_middle(int iifrom, int iito, ThrData * const t rsq = delx*delx + dely*dely + delz*delz; jtype = type[j]; - if (rsq < cut_ljsq[itype][jtype] && rsq >= cut_in_off_sq && rsq <= cut_out_off_sq ) { // lj + if (rsq < cut_ljsq[itype][jtype] && rsq >= cut_in_off_sq && rsq <= cut_out_off_sq) { // lj r2inv = 1.0/rsq; double rn = r2inv*r2inv*r2inv; if (ni == 0) forcelj = rn*(rn*lj1i[jtype]-lj2i[jtype]); diff --git a/src/USER-OMP/pair_reaxc_omp.cpp b/src/USER-OMP/pair_reaxc_omp.cpp index b717f87d0f..d10a4573f1 100644 --- a/src/USER-OMP/pair_reaxc_omp.cpp +++ b/src/USER-OMP/pair_reaxc_omp.cpp @@ -365,7 +365,7 @@ void PairReaxCOMP::init_style( ) error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an " "increased neighbor list skin."); - for ( int i = 0; i < LIST_N; ++i ) + for (int i = 0; i < LIST_N; ++i) lists[i].allocated = 0; if (fix_reax == nullptr) { @@ -433,7 +433,7 @@ void PairReaxCOMP::setup( ) InitializeOMP( system, control, data, workspace, &lists, out_control, mpi_data, world ); - for ( int k = 0; k < system->N; ++k ) { + for (int k = 0; k < system->N; ++k) { num_bonds[k] = system->my_atoms[k].num_bonds; num_hbonds[k] = system->my_atoms[k].num_hbonds; } @@ -472,7 +472,7 @@ void PairReaxCOMP::write_reax_atoms() #if defined(_OPENMP) #pragma omp parallel for schedule(static) default(shared) #endif - for ( int i = 0; i < system->N; ++i ) { + for (int i = 0; i < system->N; ++i) { system->my_atoms[i].orig_id = atom->tag[i]; system->my_atoms[i].type = map[atom->type[i]]; system->my_atoms[i].x[0] = atom->x[i][0]; @@ -596,7 +596,7 @@ void PairReaxCOMP::read_reax_forces(int /* vflag */) #if defined(_OPENMP) #pragma omp parallel for schedule(static) default(shared) #endif - for ( int i = 0; i < system->N; ++i ) { + for (int i = 0; i < system->N; ++i) { system->my_atoms[i].f[0] = workspace->f[i][0]; system->my_atoms[i].f[1] = workspace->f[i][1]; system->my_atoms[i].f[2] = workspace->f[i][2]; @@ -622,14 +622,14 @@ void PairReaxCOMP::FindBond() bond_data *bo_ij; nj = 0; - for ( pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj ) { + for (pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj) { bo_ij = &( lists->select.bond_list[pj] ); j = bo_ij->nbr; if (j < i) continue; bo_tmp = bo_ij->bo_data.BO; - if (bo_tmp >= bo_cut ) { + if (bo_tmp >= bo_cut) { tmpid[i][nj] = j; tmpbo[i][nj] = bo_tmp; nj ++; diff --git a/src/USER-OMP/pair_tersoff_zbl_omp.cpp b/src/USER-OMP/pair_tersoff_zbl_omp.cpp index 44d7994c9e..5dd411760c 100644 --- a/src/USER-OMP/pair_tersoff_zbl_omp.cpp +++ b/src/USER-OMP/pair_tersoff_zbl_omp.cpp @@ -95,7 +95,7 @@ void PairTersoffZBLOMP::read_file(char *file) double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/USER-OMP/reaxc_bond_orders_omp.cpp b/src/USER-OMP/reaxc_bond_orders_omp.cpp index ec93d9478d..499c5f2933 100644 --- a/src/USER-OMP/reaxc_bond_orders_omp.cpp +++ b/src/USER-OMP/reaxc_bond_orders_omp.cpp @@ -46,7 +46,7 @@ using namespace LAMMPS_NS; void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, - storage *workspace, reax_list **lists ) { + storage *workspace, reax_list **lists) { reax_list *bonds = (*lists) + BONDS; bond_data *nbr_j, *nbr_k; bond_order_data *bo_ij, *bo_ji; @@ -164,7 +164,7 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, } // forces on k: i neighbor - for ( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { + for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -194,7 +194,7 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, } // forces on k: j neighbor - for ( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { + for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -229,7 +229,7 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, simulation_data * /* data */, - storage *workspace, reax_list **lists ) { + storage *workspace, reax_list **lists) { reax_list *bonds = (*lists) + BONDS; bond_data *nbr_j, *nbr_k; bond_order_data *bo_ij, *bo_ji; @@ -274,7 +274,7 @@ void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, * forces related to atom i * * first neighbors of atom i * ************************************/ - for ( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { + for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -307,7 +307,7 @@ void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, /* force */ rvec_Add(workspace->forceReduction[reductionOffset+i],temp ); - for ( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { + for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -692,7 +692,7 @@ void BOOMP( reax_system *system, control_params * /* control */, simulation_data #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for (j = 0; j < system->N; ++j ) { + for (j = 0; j < system->N; ++j) { type_j = system->my_atoms[j].type; if (type_j < 0) continue; sbp_j = &(system->reax_param.sbp[ type_j ]); diff --git a/src/USER-OMP/reaxc_forces_omp.cpp b/src/USER-OMP/reaxc_forces_omp.cpp index 68ab6f933d..7fe6a41e9d 100644 --- a/src/USER-OMP/reaxc_forces_omp.cpp +++ b/src/USER-OMP/reaxc_forces_omp.cpp @@ -92,7 +92,7 @@ void Compute_Bonded_ForcesOMP( reax_system *system, control_params *control, #endif /* Implement all force calls as function pointers */ - for ( i = 0; i < NUM_INTRS; i++ ) { + for (i = 0; i < NUM_INTRS; i++) { (Interaction_Functions[i])( system, control, data, workspace, lists, out_control ); } @@ -284,7 +284,7 @@ void Validate_ListsOMP(reax_system *system, storage * /*workspace*/, reax_list * #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for (int i = 0; i < N; ++i ) { + for (int i = 0; i < N; ++i) { system->my_atoms[i].num_bonds = MAX(Num_Entries(i,bonds)*2, MIN_BONDS); if (i < N-1) @@ -308,7 +308,7 @@ void Validate_ListsOMP(reax_system *system, storage * /*workspace*/, reax_list * #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for (int i = 0; i < n; ++i ) { + for (int i = 0; i < n; ++i) { Hindex = system->my_atoms[i].Hindex; if (Hindex > -1) { system->my_atoms[i].num_hbonds = @@ -335,7 +335,7 @@ void Validate_ListsOMP(reax_system *system, storage * /*workspace*/, reax_list * void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, simulation_data *data, storage *workspace, reax_list **lists, output_controls * /* out_control */, - MPI_Comm comm ) { + MPI_Comm comm) { #ifdef OMP_TIMING double startTimeBase, endTimeBase; startTimeBase = MPI_Wtime(); @@ -395,7 +395,7 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, start_i = Start_Index(i, far_nbrs); end_i = End_Index(i, far_nbrs); - for ( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); if (nbr_pj->d <= cutoff) { int j = nbr_pj->nbr; diff --git a/src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp b/src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp index 0070fbc7c2..c0fe4e3792 100644 --- a/src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp +++ b/src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp @@ -111,8 +111,8 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, Hydrogen bond is between j and k. so in this function i->X, j->H, k->Z when we map variables onto the ones in the handout.*/ - // for( j = 0; j < system->n; ++j ) - for( j = ifrom; j < ito; ++j ) { + // for (j = 0; j < system->n; ++j) + for (j = ifrom; j < ito; ++j) { /* j has to be of type H */ if (system->reax_param.sbp[system->my_atoms[j].type].p_hbond == 1) { /*set j's variables */ @@ -124,7 +124,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, if (type_j < 0) continue; top = 0; - for( pi = start_j; pi < end_j; ++pi ) { + for (pi = start_j; pi < end_j; ++pi) { pbond_ij = &( bond_list[pi] ); i = pbond_ij->nbr; type_i = system->my_atoms[i].type; @@ -136,7 +136,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, hblist[top++] = pi; } - for( pk = hb_start_j; pk < hb_end_j; ++pk ) { + for (pk = hb_start_j; pk < hb_end_j; ++pk) { /* set k's varibles */ k = hbond_list[pk].nbr; type_k = system->my_atoms[k].type; @@ -145,7 +145,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, r_jk = nbr_jk->d; rvec_Scale( dvec_jk, hbond_list[pk].scl, nbr_jk->dvec ); - for( itr = 0; itr < top; ++itr ) { + for (itr = 0; itr < top; ++itr) { pi = hblist[itr]; pbond_ij = &( bonds->select.bond_list[pi] ); i = pbond_ij->nbr; diff --git a/src/USER-OMP/reaxc_multi_body_omp.cpp b/src/USER-OMP/reaxc_multi_body_omp.cpp index 52ef7048d6..e2af2d96ad 100644 --- a/src/USER-OMP/reaxc_multi_body_omp.cpp +++ b/src/USER-OMP/reaxc_multi_body_omp.cpp @@ -116,7 +116,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, numbonds = 0; e_lp = 0.0; - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) numbonds ++; /* calculate the energy */ @@ -137,7 +137,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, /* correction for C2 */ if (p_lp3 > 0.001 && !strcmp(system->reax_param.sbp[type_i].name, "C")) - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; if (type_j < 0) continue; @@ -227,7 +227,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, numbonds = 0; e_un = 0.0; - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) numbonds ++; if (numbonds > 0) total_Eun += e_un = diff --git a/src/USER-OMP/reaxc_nonbonded_omp.cpp b/src/USER-OMP/reaxc_nonbonded_omp.cpp index ce463c39ff..7abcb5b42a 100644 --- a/src/USER-OMP/reaxc_nonbonded_omp.cpp +++ b/src/USER-OMP/reaxc_nonbonded_omp.cpp @@ -96,13 +96,13 @@ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for( i = 0; i < natoms; ++i ) { + for (i = 0; i < natoms; ++i) { if (system->my_atoms[i].type < 0) continue; start_i = Start_Index(i, far_nbrs); end_i = End_Index(i, far_nbrs); orig_i = system->my_atoms[i].orig_id; - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); j = nbr_pj->nbr; orig_j = system->my_atoms[j].orig_id; diff --git a/src/USER-OMP/reaxc_torsion_angles_omp.cpp b/src/USER-OMP/reaxc_torsion_angles_omp.cpp index 79fa9e0f47..cb92a9a68c 100644 --- a/src/USER-OMP/reaxc_torsion_angles_omp.cpp +++ b/src/USER-OMP/reaxc_torsion_angles_omp.cpp @@ -202,7 +202,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, //tan_ijk_i = 1. / tan( theta_ijk ); if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) tan_ijk_i = cos_ijk / MIN_SINE; - else if ( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) + else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) tan_ijk_i = cos_ijk / -MIN_SINE; else tan_ijk_i = cos_ijk / sin_ijk; @@ -241,7 +241,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, //tan_jkl_i = 1. / tan( theta_jkl ); if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) tan_jkl_i = cos_jkl / MIN_SINE; - else if ( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) + else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) tan_jkl_i = cos_jkl / -MIN_SINE; else tan_jkl_i = cos_jkl /sin_jkl; diff --git a/src/USER-PTM/ptm_voronoi_cell.cpp b/src/USER-PTM/ptm_voronoi_cell.cpp index 5b29706b82..ab0b9172aa 100644 --- a/src/USER-PTM/ptm_voronoi_cell.cpp +++ b/src/USER-PTM/ptm_voronoi_cell.cpp @@ -103,9 +103,9 @@ voronoicell_base::~voronoicell_base() { * \param[in] vb a pointered to the class to be copied. */ template void voronoicell_base::check_memory_for_copy(vc_class &vc,voronoicell_base* vb) { - while(current_vertex_ordercurrent_vertex_order) add_memory_vorder(vc); - for (int i=0;imec[i]) add_memory(vc,i,ds2); - while(current_verticesp) add_memory_vertices(vc); + while (current_vertex_ordercurrent_vertex_order) add_memory_vorder(vc); + for (int i=0;imec[i]) add_memory(vc,i,ds2); + while (current_verticesp) add_memory_vertices(vc); } /** Increases the memory storage for a particular vertex order, by increasing @@ -139,7 +139,7 @@ void voronoicell_base::add_memory(vc_class &vc,int i,int *stackp2) { l=new int[s*mem[i]]; int m=0; vc.n_allocate_aux1(i); - while(j=0) { ed[k]=l+j; @@ -211,14 +211,14 @@ void voronoicell_base::add_memory_vorder(vc_class &vc) { #endif p1=new int[i]; for (j=0;j=p) throw true; u=l;up=lp; for (us=0;us=p) throw true; u=q;up=qp; @@ -410,7 +410,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq } if (us==qs) { us++; - while(us=current_vertex_order) add_memory_vorder(vc); + while (nu[p]>=current_vertex_order) add_memory_vorder(vc); if (mec[nu[p]]==mem[nu[p]]) add_memory(vc,nu[p],stackp2); // Copy the edges of the original vertex into the new @@ -651,7 +651,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq ed[p]=mep[nu[p]]+((nu[p]<<1)+1)*mec[nu[p]]++; ed[p][nu[p]<<1]=p; us=i++; - while(i=current_vertex_order) add_memory_vorder(vc); + while (k>=current_vertex_order) add_memory_vorder(vc); if (mec[k]==mem[k]) add_memory(vc,k,stackp2); // Now create a new vertex with order k, or augment @@ -903,7 +903,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq vc.n_set_aux1(k); edp=mep[k]+((k<<1)+1)*mec[k]++; i=0; - while(ids) { + while (stackp>ds) { --p; - while(ed[p][nu[p]]==-1) { + while (ed[p][nu[p]]==-1) { j=nu[p]; edp=ed[p];edd=(mep[j]+((j<<1)+1)*--mec[j]); - while(edp inline bool voronoicell_base::collapse_order2(vc_class &vc) { if (!collapse_order1(vc)) return false; int a,b,i,j,k,l; - while(mec[2]>0) { + while (mec[2]>0) { // Pick a order 2 vertex and read in its edges i=--mec[2]; @@ -1142,7 +1142,7 @@ inline bool voronoicell_base::collapse_order2(vc_class &vc) { template inline bool voronoicell_base::collapse_order1(vc_class &vc) { int i,j,k; - while(mec[1]>0) { + while (mec[1]>0) { up=0; #if VOROPP_VERBOSE >=1 fputs("Order one collapse\n",stderr); @@ -1187,7 +1187,7 @@ inline bool voronoicell_base::delete_connection(vc_class &vc,int j,int k,bool ha if (mec[i]==mem[i]) add_memory(vc,i,ds2); vc.n_set_aux1(i); for (l=0;l &v) { ed[i][j]=-1-k; l=cycle_up(ed[i][nu[i]+j],k); m=ed[k][l];ed[k][l]=-1-m; - while(m!=i) { + while (m!=i) { n=cycle_up(ed[k][nu[k]+l],m); ux=pts[3*k]-pts[3*i]; uy=pts[3*k+1]-pts[3*i+1]; diff --git a/src/USER-QMMM/fix_qmmm.cpp b/src/USER-QMMM/fix_qmmm.cpp index 32b77aaf80..f352cce827 100644 --- a/src/USER-QMMM/fix_qmmm.cpp +++ b/src/USER-QMMM/fix_qmmm.cpp @@ -108,7 +108,7 @@ static void rebuild_table_tagint(taginthash_t *tptr) { taginthash_init(tptr, old_size<<1); for (i=0; inext; h=taginthash(tptr, tmp->key); diff --git a/src/USER-QTB/fix_qbmsst.cpp b/src/USER-QTB/fix_qbmsst.cpp index 82dd76a1b5..2257c9992e 100644 --- a/src/USER-QTB/fix_qbmsst.cpp +++ b/src/USER-QTB/fix_qbmsst.cpp @@ -49,20 +49,20 @@ FixQBMSST::FixQBMSST(LAMMPS *lmp, int narg, char **arg) : { if (narg < 5) error->all(FLERR,"Illegal fix qbmsst command"); - if ( strcmp(arg[3],"x") == 0 ) { + if (strcmp(arg[3],"x") == 0) { direction = 0; box_change |= BOX_CHANGE_X; - } else if ( strcmp(arg[3],"y") == 0 ) { + } else if (strcmp(arg[3],"y") == 0) { direction = 1; box_change |= BOX_CHANGE_Y; - } else if ( strcmp(arg[3],"z") == 0 ) { + } else if (strcmp(arg[3],"z") == 0) { direction = 2; box_change |= BOX_CHANGE_Z; } else { error->all(FLERR,"Illegal fix qbmsst command"); } velocity = atof(arg[4]); - if ( velocity < 0 ) + if (velocity < 0) error->all(FLERR,"Illegal fix qbmsst command"); // default parameters @@ -431,34 +431,34 @@ void FixQBMSST::setup(int /*vflag*/) couple(); velocity_sum = compute_vsum(); - if ( v0_set == 0 ) { + if (v0_set == 0) { v0 = compute_vol(); v0_set = 1; if (comm->me == 0) utils::logmesg(lmp,fmt::format("Fix QBMSST v0 = {:12.5e}\n", v0)); } - if ( p0_set == 0 ) { + if (p0_set == 0) { p0 = p_current[direction]; p0_set = 1; - if ( comm->me == 0 ) + if (comm->me == 0) utils::logmesg(lmp,fmt::format("Fix QBMSST p0 = {:12.5e}\n", p0)); } - if ( e0_set == 0 ) { + if (e0_set == 0) { e0 = compute_etotal(); e0_set = 1; old_eavg = e0; - if ( comm->me == 0 ) + if (comm->me == 0) utils::logmesg(lmp,fmt::format("Fix QBMSST e0 = to be {:12.5e}\n",e0)); } temperature->compute_vector(); double *ke_tensor = temperature->vector; double ke_temp = ke_tensor[0]+ke_tensor[1]+ke_tensor[2]; - if (ke_temp > 0.0 && tscale > 0.0 ) { + if (ke_temp > 0.0 && tscale > 0.0) { // transfer energy from atom velocities to cell volume motion // to bias initial compression @@ -477,7 +477,7 @@ void FixQBMSST::setup(int /*vflag*/) "factor of {:12.5e}\n",fac2,tscale)); for (int i = 0; i < atom->nlocal; i++) { if (mask[i] & groupbit) { - for (int k = 0; k < 3; k++ ) { + for (int k = 0; k < 3; k++) { v[i][k]*=sqrt_initial_temperature_scaling; } } @@ -596,12 +596,12 @@ void FixQBMSST::initial_integrate(int /*vflag*/) double B = total_mass * mu / ( qmass * vol ); // prevent blow-up of the volume. - if ( vol > v0 && A > 0.0 ) { + if (vol > v0 && A > 0.0) { A = -A; } // use taylor expansion to avoid singularity at B == 0. - if ( B * dthalf > 1.0e-06 ) { + if (B * dthalf > 1.0e-06) { omega[sd] = ( omega[sd] + A * ( exp(B * dthalf) - 1.0 ) / B ) * exp(-B * dthalf); } else { @@ -614,15 +614,15 @@ void FixQBMSST::initial_integrate(int /*vflag*/) velocity_sum = compute_vsum(); for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { double C = (f[i][k] + fran[i][k])* force->ftm2v / mass[type[i]];// this term now has a random force part double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ) - fric_coef; old_velocity[i][k] = v[i][k]; - if ( k == direction ) { + if (k == direction) { D = D - 2.0 * omega[sd] / vol; } - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (fabs(dthalf * D) > 1.0e-06) { double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -638,7 +638,7 @@ void FixQBMSST::initial_integrate(int /*vflag*/) // reset the velocities. for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { v[i][k] = old_velocity[i][k]; } } @@ -647,15 +647,15 @@ void FixQBMSST::initial_integrate(int /*vflag*/) // propagate velocities 1/2 step using the new velocity sum. for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { double C = (f[i][k] + fran[i][k])* force->ftm2v / mass[type[i]];// this term now has a random force part double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ) - fric_coef; - if ( k == direction ) { + if (k == direction) { D = D - 2.0 * omega[sd] / vol; } - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (fabs(dthalf * D) > 1.0e-06) { double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -715,15 +715,15 @@ void FixQBMSST::final_integrate() for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( int k = 0; k < 3; k++ ) { + for (int k = 0; k < 3; k++) { double C = (f[i][k] + fran[i][k]) * force->ftm2v / mass[type[i]];// this term now has a random force part double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ) - fric_coef; - if ( k == direction ) { + if (k == direction) { D = D - 2.0 * omega[sd] / vol; } - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (fabs(dthalf * D) > 1.0e-06) { double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -753,13 +753,13 @@ void FixQBMSST::final_integrate() // prevent blow-up of the volume. - if ( vol > v0 && A > 0.0 ) { + if (vol > v0 && A > 0.0) { A = -A; } // use taylor expansion to avoid singularity at B == 0. - if ( B * dthalf > 1.0e-06 ) { + if (B * dthalf > 1.0e-06) { omega[sd] = ( omega[sd] + A * ( exp(B * dthalf) - 1.0 ) / B ) * exp(-B * dthalf); } else { @@ -814,7 +814,7 @@ void FixQBMSST::remap(int flag) // reset global and local box to new size/shape for (i = 0; i < 3; i++) { - if ( direction == i ) { + if (direction == i) { oldlo = domain->boxlo[i]; oldhi = domain->boxhi[i]; ctr = 0.5 * (oldlo + oldhi); @@ -1084,7 +1084,7 @@ double FixQBMSST::compute_vol() ------------------------------------------------------------------------- */ void FixQBMSST::check_alloc(int n) { - if ( atoms_allocated < n ) { + if (atoms_allocated < n) { memory->destroy(old_velocity); memory->create(old_velocity,n,3,"qbmsst:old_velocity"); atoms_allocated = n; diff --git a/src/USER-QUIP/pair_quip.cpp b/src/USER-QUIP/pair_quip.cpp index 3ca19285f6..f850925764 100644 --- a/src/USER-QUIP/pair_quip.cpp +++ b/src/USER-QUIP/pair_quip.cpp @@ -162,7 +162,7 @@ void PairQUIP::compute(int eflag, int vflag) iquip = 0; for (ii = 0; ii < ntotal; ii++) { - for ( jj = 0; jj < 3; jj++ ) { + for (jj = 0; jj < 3; jj++) { f[ii][jj] += quip_force[iquip]; iquip++; } diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 8d6b1b27ac..483bd1c0f6 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -334,7 +334,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : strcpy(files[rxn],arg[iarg]); iarg++; - while (iarg < narg && strcmp(arg[iarg],"react") != 0 ) { + while (iarg < narg && strcmp(arg[iarg],"react") != 0) { if (strcmp(arg[iarg],"prob") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal fix bond/react command: " "'prob' keyword has too few arguments"); @@ -1293,7 +1293,7 @@ void FixBondReact::superimpose_algorithm() nxspecial[local_atom2][0] == nxspecial[local_atom1][0]) && (nxspecial[local_atom1][0] == 0 || xspecial[local_atom1][0] == atom->tag[local_atom2]) && - check_constraints() ) { + check_constraints()) { status = ACCEPT; glove_ghostcheck(); } else @@ -2772,7 +2772,7 @@ void FixBondReact::update_everything() for (int p = 0; p < twomol->natoms; p++) { int pp = equivalences[p][1][rxnID]-1; if (p!=j && special[atom->map(update_mega_glove[jj+1][i])][k] == update_mega_glove[pp+1][i] - && landlocked_atoms[p][rxnID] == 1 ) { + && landlocked_atoms[p][rxnID] == 1) { for (int n = k; n < nspecial[atom->map(update_mega_glove[jj+1][i])][2]-1; n++) { special[atom->map(update_mega_glove[jj+1][i])][n] = special[atom->map(update_mega_glove[jj+1][i])][n+1]; } diff --git a/src/USER-REAXC/fix_reaxc_bonds.cpp b/src/USER-REAXC/fix_reaxc_bonds.cpp index fa115e343e..6d90ef5fae 100644 --- a/src/USER-REAXC/fix_reaxc_bonds.cpp +++ b/src/USER-REAXC/fix_reaxc_bonds.cpp @@ -195,7 +195,7 @@ void FixReaxCBonds::FindBond(struct _reax_list * /*lists*/, int &numbonds) i = ilist[ii]; nj = 0; - for( pj = Start_Index(i, reaxc->lists); pj < End_Index(i, reaxc->lists); ++pj ) { + for (pj = Start_Index(i, reaxc->lists); pj < End_Index(i, reaxc->lists); ++pj) { bo_ij = &( reaxc->lists->select.bond_list[pj] ); j = bo_ij->nbr; jtag = tag[j]; @@ -262,7 +262,7 @@ void FixReaxCBonds::RecvBuffer(double *buf, int nbuf, int nbuf_local, double cutof3 = reaxc->control->bg_cut; MPI_Request irequest, irequest2; - if (me == 0 ) { + if (me == 0) { fprintf(fp,"# Timestep " BIGINT_FORMAT " \n",ntimestep); fprintf(fp,"# \n"); fprintf(fp,"# Number of particles %d \n",natoms); diff --git a/src/USER-REAXC/pair_reaxc.cpp b/src/USER-REAXC/pair_reaxc.cpp index 1fb6eb9005..bfe9330819 100644 --- a/src/USER-REAXC/pair_reaxc.cpp +++ b/src/USER-REAXC/pair_reaxc.cpp @@ -420,7 +420,7 @@ void PairReaxC::init_style( ) error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an " "increased neighbor list skin."); - for ( int i = 0; i < LIST_N; ++i ) + for (int i = 0; i < LIST_N; ++i) if (lists[i].allocated != 1) lists[i].allocated = 0; @@ -478,7 +478,7 @@ void PairReaxC::setup( ) write_reax_lists(); Initialize( system, control, data, workspace, &lists, out_control, mpi_data, world ); - for ( int k = 0; k < system->N; ++k ) { + for (int k = 0; k < system->N; ++k) { num_bonds[k] = system->my_atoms[k].num_bonds; num_hbonds[k] = system->my_atoms[k].num_hbonds; } @@ -645,7 +645,7 @@ void PairReaxC::write_reax_atoms() if (system->N > system->total_cap) error->all(FLERR,"Too many ghost atoms"); - for ( int i = 0; i < system->N; ++i ) { + for (int i = 0; i < system->N; ++i) { system->my_atoms[i].orig_id = atom->tag[i]; system->my_atoms[i].type = map[atom->type[i]]; system->my_atoms[i].x[0] = atom->x[i][0]; @@ -703,13 +703,13 @@ int PairReaxC::estimate_reax_lists() int numall = list->inum + list->gnum; - for ( itr_i = 0; itr_i < numall; ++itr_i ) { + for (itr_i = 0; itr_i < numall; ++itr_i) { i = ilist[itr_i]; marked[i] = 1; ++num_marked; jlist = firstneigh[i]; - for ( itr_j = 0; itr_j < numneigh[i]; ++itr_j ) { + for (itr_j = 0; itr_j < numneigh[i]; ++itr_j) { j = jlist[itr_j]; j &= NEIGHMASK; get_distance( x[j], x[i], &d_sqr, &dvec ); @@ -751,7 +751,7 @@ int PairReaxC::write_reax_lists() int numall = list->inum + list->gnum; - for ( itr_i = 0; itr_i < numall; ++itr_i ) { + for (itr_i = 0; itr_i < numall; ++itr_i) { i = ilist[itr_i]; jlist = firstneigh[i]; Set_Start_Index( i, num_nbrs, far_nbrs ); @@ -761,7 +761,7 @@ int PairReaxC::write_reax_lists() else cutoff_sqr = control->bond_cut*control->bond_cut; - for ( itr_j = 0; itr_j < numneigh[i]; ++itr_j ) { + for (itr_j = 0; itr_j < numneigh[i]; ++itr_j) { j = jlist[itr_j]; j &= NEIGHMASK; get_distance( x[j], x[i], &d_sqr, &dvec ); @@ -784,7 +784,7 @@ int PairReaxC::write_reax_lists() void PairReaxC::read_reax_forces(int /*vflag*/) { - for ( int i = 0; i < system->N; ++i ) { + for (int i = 0; i < system->N; ++i) { system->my_atoms[i].f[0] = workspace->f[i][0]; system->my_atoms[i].f[1] = workspace->f[i][1]; system->my_atoms[i].f[2] = workspace->f[i][2]; @@ -864,14 +864,14 @@ void PairReaxC::FindBond() for (i = 0; i < system->n; i++) { nj = 0; - for ( pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj ) { + for (pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj) { bo_ij = &( lists->select.bond_list[pj] ); j = bo_ij->nbr; if (j < i) continue; bo_tmp = bo_ij->bo_data.BO; - if (bo_tmp >= bo_cut ) { + if (bo_tmp >= bo_cut) { tmpid[i][nj] = j; tmpbo[i][nj] = bo_tmp; nj ++; diff --git a/src/USER-REAXC/reaxc_allocate.cpp b/src/USER-REAXC/reaxc_allocate.cpp index f017eae41e..f043dc85d6 100644 --- a/src/USER-REAXC/reaxc_allocate.cpp +++ b/src/USER-REAXC/reaxc_allocate.cpp @@ -96,9 +96,9 @@ void DeAllocate_System( reax_system *system ) sfree(system->error_ptr, ff_params->gp.l, "ff:globals" ); - for( i = 0; i < ntypes; ++i ) { - for( j = 0; j < ntypes; ++j ) { - for( k = 0; k < ntypes; ++k ) { + for (i = 0; i < ntypes; ++i) { + for (j = 0; j < ntypes; ++j) { + for (k = 0; k < ntypes; ++k) { sfree(system->error_ptr, ff_params->fbp[i][j][k], "ff:fbp[i,j,k]" ); } sfree(system->error_ptr, ff_params->fbp[i][j], "ff:fbp[i,j]" ); @@ -129,7 +129,7 @@ void DeAllocate_Workspace( control_params * control, storage *workspace ) workspace->allocated = 0; /* communication storage */ - for( i = 0; i < MAX_NBRS; ++i ) { + for (i = 0; i < MAX_NBRS; ++i) { sfree(control->error_ptr, workspace->tmp_dbl[i], "tmp_dbl[i]" ); sfree(control->error_ptr, workspace->tmp_rvec[i], "tmp_rvec[i]" ); sfree(control->error_ptr, workspace->tmp_rvec2[i], "tmp_rvec2[i]" ); @@ -169,7 +169,7 @@ void DeAllocate_Workspace( control_params * control, storage *workspace ) sfree(control->error_ptr, workspace->x, "x" ); /* GMRES storage */ - for( i = 0; i < RESTART+1; ++i ) { + for (i = 0; i < RESTART+1; ++i) { sfree(control->error_ptr, workspace->h[i], "h[i]" ); sfree(control->error_ptr, workspace->v[i], "v[i]" ); } @@ -219,7 +219,7 @@ int Allocate_Workspace( reax_system * /*system*/, control_params * control, local_rvec = local_cap * sizeof(rvec); /* communication storage */ - for( i = 0; i < MAX_NBRS; ++i ) { + for (i = 0; i < MAX_NBRS; ++i) { workspace->tmp_dbl[i] = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "tmp_dbl"); workspace->tmp_rvec[i] = (rvec*) @@ -277,7 +277,7 @@ int Allocate_Workspace( reax_system * /*system*/, control_params * control, workspace->hc = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "hc"); workspace->v = (double**) scalloc(control->error_ptr, RESTART+1, sizeof(double*), "v"); - for( i = 0; i < RESTART+1; ++i ) { + for (i = 0; i < RESTART+1; ++i) { workspace->h[i] = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "h[i]"); workspace->v[i] = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "v[i]"); } @@ -336,7 +336,7 @@ static int Reallocate_HBonds_List( reax_system *system, reax_list *hbonds ) double saferzone = system->saferzone; total_hbonds = 0; - for( i = 0; i < system->n; ++i ) + for (i = 0; i < system->n; ++i) if ((system->my_atoms[i].Hindex) >= 0) { total_hbonds += system->my_atoms[i].num_hbonds; } @@ -361,7 +361,7 @@ static int Reallocate_Bonds_List( reax_system *system, reax_list *bonds, *total_bonds = 0; *est_3body = 0; - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { *est_3body += SQR(system->my_atoms[i].num_bonds); *total_bonds += system->my_atoms[i].num_bonds; } @@ -411,13 +411,13 @@ void ReAllocate( reax_system *system, control_params *control, realloc = &(workspace->realloc); if ( system->n >= DANGER_ZONE * system->local_cap || - (0 && system->n <= LOOSE_ZONE * system->local_cap) ) { + (0 && system->n <= LOOSE_ZONE * system->local_cap)) { system->local_cap = MAX( (int)(system->n * safezone), mincap ); } int Nflag = 0; if ( system->N >= DANGER_ZONE * system->total_cap || - (0 && system->N <= LOOSE_ZONE * system->total_cap) ) { + (0 && system->N <= LOOSE_ZONE * system->total_cap)) { Nflag = 1; system->total_cap = MAX( (int)(system->N * safezone), mincap ); } @@ -467,7 +467,7 @@ void ReAllocate( reax_system *system, control_params *control, if (control->hbond_cut > 0) { Hflag = 0; if ( system->numH >= DANGER_ZONE * system->Hcap || - (0 && system->numH <= LOOSE_ZONE * system->Hcap) ) { + (0 && system->numH <= LOOSE_ZONE * system->Hcap)) { Hflag = 1; system->Hcap = int(MAX( system->numH * saferzone, mincap )); } @@ -497,7 +497,7 @@ void ReAllocate( reax_system *system, control_params *control, realloc->num_3body = (int)(MAX(realloc->num_3body*safezone, MIN_3BODIES)); if ( !Make_List( num_bonds, realloc->num_3body, TYP_THREE_BODY, - (*lists)+THREE_BODIES ) ) { + (*lists)+THREE_BODIES )) { system->error_ptr->one(FLERR, "Problem in initializing angles list"); } realloc->num_3body = -1; diff --git a/src/USER-REAXC/reaxc_bond_orders.cpp b/src/USER-REAXC/reaxc_bond_orders.cpp index a9985d79f3..6a854e1805 100644 --- a/src/USER-REAXC/reaxc_bond_orders.cpp +++ b/src/USER-REAXC/reaxc_bond_orders.cpp @@ -67,7 +67,7 @@ void Add_dBond_to_Forces_NPT( int i, int pj, simulation_data *data, coef.C2dDelta = bo_ij->C2dbo * (workspace->CdDelta[i]+workspace->CdDelta[j]); coef.C3dDelta = bo_ij->C3dbo * (workspace->CdDelta[i]+workspace->CdDelta[j]); - for( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { + for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -100,7 +100,7 @@ void Add_dBond_to_Forces_NPT( int i, int pj, simulation_data *data, /* force */ rvec_Add( workspace->f[i], temp ); - for( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { + for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -217,7 +217,7 @@ void Add_dBond_to_Forces( reax_system *system, int i, int pj, } // forces on k: i neighbor - for( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { + for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -237,7 +237,7 @@ void Add_dBond_to_Forces( reax_system *system, int i, int pj, } // forces on k: j neighbor - for( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { + for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -262,7 +262,7 @@ void Add_dBond_to_Forces( reax_system *system, int i, int pj, int BOp( storage *workspace, reax_list *bonds, double bo_cut, int i, int btop_i, far_neighbor_data *nbr_pj, single_body_parameters *sbp_i, single_body_parameters *sbp_j, - two_body_parameters *twbp ) { + two_body_parameters *twbp) { int j, btop_j; double r2, C12, C34, C56; double Cln_BOp_s, Cln_BOp_pi, Cln_BOp_pi2; @@ -383,7 +383,7 @@ void BO( reax_system *system, control_params * /*control*/, simulation_data * /* p_boc2 = system->reax_param.gp.l[1]; /* Calculate Deltaprime, Deltaprime_boc values */ - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { type_i = system->my_atoms[i].type; if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[type_i]); @@ -395,7 +395,7 @@ void BO( reax_system *system, control_params * /*control*/, simulation_data * /* } /* Corrected Bond Order calculations */ - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { type_i = system->my_atoms[i].type; if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[type_i]); @@ -405,7 +405,7 @@ void BO( reax_system *system, control_params * /*control*/, simulation_data * /* start_i = Start_Index(i, bonds); end_i = End_Index(i, bonds); - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; if (type_j < 0) continue; @@ -558,7 +558,7 @@ void BO( reax_system *system, control_params * /*control*/, simulation_data * /* } p_lp1 = system->reax_param.gp.l[15]; - for( j = 0; j < system->N; ++j ) { + for (j = 0; j < system->N; ++j) { type_j = system->my_atoms[j].type; if (type_j < 0) continue; sbp_j = &(system->reax_param.sbp[ type_j ]); diff --git a/src/USER-REAXC/reaxc_bonds.cpp b/src/USER-REAXC/reaxc_bonds.cpp index 91dc38d56d..c706a2fd79 100644 --- a/src/USER-REAXC/reaxc_bonds.cpp +++ b/src/USER-REAXC/reaxc_bonds.cpp @@ -54,11 +54,11 @@ void Bonds( reax_system *system, control_params * /*control*/, gp37 = (int) system->reax_param.gp.l[37]; natoms = system->n; - for( i = 0; i < natoms; ++i ) { + for (i = 0; i < natoms; ++i) { start_i = Start_Index(i, bonds); end_i = End_Index(i, bonds); - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { j = bonds->select.bond_list[pj].nbr; if (system->my_atoms[i].orig_id > system->my_atoms[j].orig_id) @@ -106,7 +106,7 @@ void Bonds( reax_system *system, control_params * /*control*/, if (bo_ij->BO >= 1.00) { if ( gp37 == 2 || (sbp_i->mass == 12.0000 && sbp_j->mass == 15.9990) || - (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990) ) { + (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990)) { exphu = exp( -gp7 * SQR(bo_ij->BO - 2.50) ); exphua1 = exp(-gp3 * (workspace->total_bond_order[i]-bo_ij->BO)); exphub1 = exp(-gp3 * (workspace->total_bond_order[j]-bo_ij->BO)); diff --git a/src/USER-REAXC/reaxc_control.cpp b/src/USER-REAXC/reaxc_control.cpp index ab183bdaa4..b717b6b97f 100644 --- a/src/USER-REAXC/reaxc_control.cpp +++ b/src/USER-REAXC/reaxc_control.cpp @@ -41,7 +41,7 @@ char Read_Control_File( char *control_file, control_params* control, double val; /* open control file */ - if ( (fp = fopen( control_file, "r" ) ) == nullptr ) { + if ((fp = fopen( control_file, "r" ) ) == nullptr) { control->error_ptr->all(FLERR, "The control file cannot be opened"); } @@ -343,7 +343,7 @@ char Read_Control_File( char *control_file, control_params* control, } else if (strcmp(tmp[0], "ignore") == 0) { control->num_ignored = atoi(tmp[1]); - for( i = 0; i < control->num_ignored; ++i ) + for (i = 0; i < control->num_ignored; ++i) control->ignore[atoi(tmp[i+2])] = 1; } else if (strcmp(tmp[0], "dipole_anal") == 0) { @@ -379,7 +379,7 @@ char Read_Control_File( char *control_file, control_params* control, else control->T = control->T_init; /* free memory allocations at the top */ - for( i = 0; i < MAX_TOKENS; i++ ) + for (i = 0; i < MAX_TOKENS; i++) free( tmp[i] ); free( tmp ); free( s ); diff --git a/src/USER-REAXC/reaxc_ffield.cpp b/src/USER-REAXC/reaxc_ffield.cpp index 13e01c3a53..e54b3b75e0 100644 --- a/src/USER-REAXC/reaxc_ffield.cpp +++ b/src/USER-REAXC/reaxc_ffield.cpp @@ -109,7 +109,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, tor_flag = (char****) scalloc(control->error_ptr, reax->num_atom_types, sizeof(char***), "tor_flag"); - for( i = 0; i < reax->num_atom_types; i++ ) { + for (i = 0; i < reax->num_atom_types; i++) { reax->tbp[i] = (two_body_parameters*) scalloc(control->error_ptr, reax->num_atom_types, sizeof(two_body_parameters), "tbp[i]"); reax->thbp[i]= (three_body_header**) @@ -121,7 +121,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, tor_flag[i] = (char***) scalloc(control->error_ptr, reax->num_atom_types, sizeof(char**), "tor_flag[i]"); - for( j = 0; j < reax->num_atom_types; j++ ) { + for (j = 0; j < reax->num_atom_types; j++) { reax->thbp[i][j]= (three_body_header*) scalloc(control->error_ptr, reax->num_atom_types, sizeof(three_body_header), "thbp[i,j]"); reax->hbp[i][j] = (hbond_parameters*) @@ -144,7 +144,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, char errmsg[1024]; - for( i = 0; i < reax->num_atom_types; i++ ) { + for (i = 0; i < reax->num_atom_types; i++) { /* line one */ fgets( s, MAX_LINE, fp ); c = Tokenize( s, &tmp ); @@ -158,7 +158,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, control->error_ptr->all(FLERR, errmsg); } - for( j = 0; j < (int)(strlen(tmp[0])); ++j ) + for (j = 0; j < (int)(strlen(tmp[0])); ++j) reax->sbp[i].name[j] = toupper( tmp[0][j] ); val = atof(tmp[1]); reax->sbp[i].r_s = val; @@ -302,9 +302,9 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, } /* Equate vval3 to valf for first-row elements (25/10/2004) */ - for( i = 0; i < reax->num_atom_types; i++ ) + for (i = 0; i < reax->num_atom_types; i++) if ( reax->sbp[i].mass < 21 && - reax->sbp[i].valency_val != reax->sbp[i].valency_boc ) { + reax->sbp[i].valency_val != reax->sbp[i].valency_boc) { if (me == 0) { char errmsg[256]; snprintf(errmsg, 256, "Changed valency_val to valency_boc for %s", @@ -542,16 +542,16 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, } } - for( i = 0; i < reax->num_atom_types; ++i ) - for( j = 0; j < reax->num_atom_types; ++j ) - for( k = 0; k < reax->num_atom_types; ++k ) + for (i = 0; i < reax->num_atom_types; ++i) + for (j = 0; j < reax->num_atom_types; ++j) + for (k = 0; k < reax->num_atom_types; ++k) reax->thbp[i][j][k].cnt = 0; fgets( s, MAX_LINE, fp ); c = Tokenize( s, &tmp ); l = atoi( tmp[0] ); - for( i = 0; i < l; i++ ) { + for (i = 0; i < l; i++) { fgets(s,MAX_LINE,fp); c=Tokenize(s,&tmp); @@ -598,10 +598,10 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, } /* clear all entries first */ - for( i = 0; i < reax->num_atom_types; ++i ) - for( j = 0; j < reax->num_atom_types; ++j ) - for( k = 0; k < reax->num_atom_types; ++k ) - for( m = 0; m < reax->num_atom_types; ++m ) { + for (i = 0; i < reax->num_atom_types; ++i) + for (j = 0; j < reax->num_atom_types; ++j) + for (k = 0; k < reax->num_atom_types; ++k) + for (m = 0; m < reax->num_atom_types; ++m) { reax->fbp[i][j][k][m].cnt = 0; tor_flag[i][j][k][m] = 0; } @@ -611,7 +611,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, c = Tokenize( s, &tmp ); l = atoi( tmp[0] ); - for( i = 0; i < l; i++ ) { + for (i = 0; i < l; i++) { fgets( s, MAX_LINE, fp ); c = Tokenize( s, &tmp ); @@ -653,8 +653,8 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, } } else { /* This means the entry is of the form 0-X-Y-0 */ if (k < reax->num_atom_types && m < reax->num_atom_types) - for( p = 0; p < reax->num_atom_types; p++ ) - for( o = 0; o < reax->num_atom_types; o++ ) { + for (p = 0; p < reax->num_atom_types; p++) + for (o = 0; o < reax->num_atom_types; o++) { reax->fbp[p][k][m][o].cnt = 1; reax->fbp[o][m][k][p].cnt = 1; @@ -682,12 +682,12 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, c = Tokenize( s, &tmp ); l = atoi( tmp[0] ); - for( i = 0; i < reax->num_atom_types; ++i ) - for( j = 0; j < reax->num_atom_types; ++j ) - for( k = 0; k < reax->num_atom_types; ++k ) + for (i = 0; i < reax->num_atom_types; ++i) + for (j = 0; j < reax->num_atom_types; ++j) + for (k = 0; k < reax->num_atom_types; ++k) reax->hbp[i][j][k].r0_hb = -1.0; - for( i = 0; i < l; i++ ) { + for (i = 0; i < l; i++) { fgets( s, MAX_LINE, fp ); c = Tokenize( s, &tmp ); @@ -713,16 +713,16 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, } /* deallocate helper storage */ - for( i = 0; i < MAX_TOKENS; i++ ) + for (i = 0; i < MAX_TOKENS; i++) free( tmp[i] ); free( tmp ); free( s ); /* deallocate tor_flag */ - for( i = 0; i < reax->num_atom_types; i++ ) { - for( j = 0; j < reax->num_atom_types; j++ ) { - for( k = 0; k < reax->num_atom_types; k++ ) { + for (i = 0; i < reax->num_atom_types; i++) { + for (j = 0; j < reax->num_atom_types; j++) { + for (k = 0; k < reax->num_atom_types; k++) { free( tor_flag[i][j][k] ); } free( tor_flag[i][j] ); diff --git a/src/USER-REAXC/reaxc_forces.cpp b/src/USER-REAXC/reaxc_forces.cpp index 3cc66b7530..cde80e9866 100644 --- a/src/USER-REAXC/reaxc_forces.cpp +++ b/src/USER-REAXC/reaxc_forces.cpp @@ -74,7 +74,7 @@ void Compute_Bonded_Forces( reax_system *system, control_params *control, int i; /* Implement all force calls as function pointers */ - for( i = 0; i < NUM_INTRS; i++ ) { + for (i = 0; i < NUM_INTRS; i++) { (Interaction_Functions[i])( system, control, data, workspace, lists, out_control ); } @@ -104,8 +104,8 @@ void Compute_Total_Force( reax_system *system, control_params *control, int i, pj; reax_list *bonds = (*lists) + BONDS; - for( i = 0; i < system->N; ++i ) - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) + for (i = 0; i < system->N; ++i) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) if (i < bonds->select.bond_list[pj].nbr) { if (control->virial == 0) Add_dBond_to_Forces( system, i, pj, workspace, lists ); @@ -127,7 +127,7 @@ void Validate_Lists( reax_system *system, storage * /*workspace*/, reax_list **l if (N > 0) { bonds = *lists + BONDS; - for( i = 0; i < N; ++i ) { + for (i = 0; i < N; ++i) { system->my_atoms[i].num_bonds = MAX(Num_Entries(i,bonds)*2, MIN_BONDS); if (i < N-1) @@ -148,7 +148,7 @@ void Validate_Lists( reax_system *system, storage * /*workspace*/, reax_list **l if (numH > 0) { hbonds = *lists + HBONDS; - for( i = 0; i < N; ++i ) { + for (i = 0; i < N; ++i) { Hindex = system->my_atoms[i].Hindex; if (Hindex > -1) { system->my_atoms[i].num_hbonds = @@ -176,7 +176,7 @@ void Validate_Lists( reax_system *system, storage * /*workspace*/, reax_list **l void Init_Forces_noQEq( reax_system *system, control_params *control, simulation_data *data, storage *workspace, - reax_list **lists, output_controls * /*out_control*/ ) { + reax_list **lists, output_controls * /*out_control*/) { int i, j, pj; int start_i, end_i; int type_i, type_j; @@ -194,9 +194,9 @@ void Init_Forces_noQEq( reax_system *system, control_params *control, bonds = *lists + BONDS; hbonds = *lists + HBONDS; - for( i = 0; i < system->n; ++i ) + for (i = 0; i < system->n; ++i) workspace->bond_mark[i] = 0; - for( i = system->n; i < system->N; ++i ) { + for (i = system->n; i < system->N; ++i) { workspace->bond_mark[i] = 1000; // put ghost atoms to an infinite distance } @@ -205,7 +205,7 @@ void Init_Forces_noQEq( reax_system *system, control_params *control, btop_i = 0; renbr = (data->step-data->prev_steps) % control->reneighbor == 0; - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { atom_i = &(system->my_atoms[i]); type_i = atom_i->type; if (type_i < 0) continue; @@ -232,7 +232,7 @@ void Init_Forces_noQEq( reax_system *system, control_params *control, } /* update i-j distance - check if j is within cutoff */ - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); j = nbr_pj->nbr; atom_j = &(system->my_atoms[j]); @@ -263,7 +263,7 @@ void Init_Forces_noQEq( reax_system *system, control_params *control, if (local) { /* hydrogen bond lists */ if (control->hbond_cut > 0 && (ihb==1 || ihb==2) && - nbr_pj->d <= control->hbond_cut ) { + nbr_pj->d <= control->hbond_cut) { // fprintf( stderr, "%d %d\n", atom1, atom2 ); jhb = sbp_j->p_hbond; if (ihb == 1 && jhb == 2) { @@ -287,7 +287,7 @@ void Init_Forces_noQEq( reax_system *system, control_params *control, if (//(workspace->bond_mark[i] < 3 || workspace->bond_mark[j] < 3) && nbr_pj->d <= control->bond_cut && BOp( workspace, bonds, control->bo_cut, - i , btop_i, nbr_pj, sbp_i, sbp_j, twbp ) ) { + i , btop_i, nbr_pj, sbp_i, sbp_j, twbp )) { num_bonds += 2; ++btop_i; @@ -343,7 +343,7 @@ void Estimate_Storages( reax_system *system, control_params *control, memset( bond_top, 0, sizeof(int) * system->total_cap ); *num_3body = 0; - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { atom_i = &(system->my_atoms[i]); type_i = atom_i->type; if (type_i < 0) continue; @@ -362,7 +362,7 @@ void Estimate_Storages( reax_system *system, control_params *control, ihb = -1; } - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); j = nbr_pj->nbr; atom_j = &(system->my_atoms[j]); @@ -380,11 +380,11 @@ void Estimate_Storages( reax_system *system, control_params *control, /* hydrogen bond lists */ if (control->hbond_cut > 0.1 && (ihb==1 || ihb==2) && - nbr_pj->d <= control->hbond_cut ) { + nbr_pj->d <= control->hbond_cut) { jhb = sbp_j->p_hbond; if (ihb == 1 && jhb == 2) ++hb_top[i]; - else if ( j < system->n && ihb == 2 && jhb == 1 ) + else if (j < system->n && ihb == 2 && jhb == 1) ++hb_top[j]; } } @@ -422,10 +422,10 @@ void Estimate_Storages( reax_system *system, control_params *control, } *Htop = (int)(MAX( *Htop * safezone, mincap * MIN_HENTRIES )); - for( i = 0; i < system->n; ++i ) + for (i = 0; i < system->n; ++i) hb_top[i] = (int)(MAX(hb_top[i] * saferzone, system->minhbonds)); - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { *num_3body += SQR(bond_top[i]); bond_top[i] = MAX( bond_top[i] * 2, MIN_BONDS ); } diff --git a/src/USER-REAXC/reaxc_hydrogen_bonds.cpp b/src/USER-REAXC/reaxc_hydrogen_bonds.cpp index 680f069bab..ac94d7b62c 100644 --- a/src/USER-REAXC/reaxc_hydrogen_bonds.cpp +++ b/src/USER-REAXC/reaxc_hydrogen_bonds.cpp @@ -63,7 +63,7 @@ void Hydrogen_Bonds( reax_system *system, control_params *control, hbonds = (*lists) + HBONDS; hbond_list = hbonds->select.hbond_list; - for( j = 0; j < system->n; ++j ) + for (j = 0; j < system->n; ++j) if (system->reax_param.sbp[system->my_atoms[j].type].p_hbond == 1) { type_j = system->my_atoms[j].type; start_j = Start_Index(j, bonds); @@ -73,7 +73,7 @@ void Hydrogen_Bonds( reax_system *system, control_params *control, if (type_j < 0) continue; top = 0; - for( pi = start_j; pi < end_j; ++pi ) { + for (pi = start_j; pi < end_j; ++pi) { pbond_ij = &( bond_list[pi] ); i = pbond_ij->nbr; type_i = system->my_atoms[i].type; @@ -85,7 +85,7 @@ void Hydrogen_Bonds( reax_system *system, control_params *control, hblist[top++] = pi; } - for( pk = hb_start_j; pk < hb_end_j; ++pk ) { + for (pk = hb_start_j; pk < hb_end_j; ++pk) { /* set k's varibles */ k = hbond_list[pk].nbr; type_k = system->my_atoms[k].type; @@ -94,7 +94,7 @@ void Hydrogen_Bonds( reax_system *system, control_params *control, r_jk = nbr_jk->d; rvec_Scale( dvec_jk, hbond_list[pk].scl, nbr_jk->dvec ); - for( itr = 0; itr < top; ++itr ) { + for (itr = 0; itr < top; ++itr) { pi = hblist[itr]; pbond_ij = &( bonds->select.bond_list[pi] ); i = pbond_ij->nbr; diff --git a/src/USER-REAXC/reaxc_io_tools.cpp b/src/USER-REAXC/reaxc_io_tools.cpp index 6ac64a17bc..5864ab6a15 100644 --- a/src/USER-REAXC/reaxc_io_tools.cpp +++ b/src/USER-REAXC/reaxc_io_tools.cpp @@ -63,7 +63,7 @@ int Init_Output_Files( reax_system *system, control_params *control, /* init pressure file */ if ( control->ensemble == NPT || control->ensemble == iNPT || - control->ensemble == sNPT ) { + control->ensemble == sNPT) { sprintf( temp, "%s.prs", control->sim_name ); if ((out_control->prs = fopen( temp, "w" )) != nullptr) { fprintf(out_control->prs,"%8s%13s%13s%13s%13s%13s%13s%13s\n", @@ -119,7 +119,7 @@ void Output_Results( reax_system *system, control_params *control, /* output energies */ if ( system->my_rank == MASTER_NODE && out_control->energy_update_freq > 0 && - data->step % out_control->energy_update_freq == 0 ) { + data->step % out_control->energy_update_freq == 0) { if (control->virial && out_control->prs) { fprintf( out_control->prs, @@ -142,7 +142,7 @@ void Output_Results( reax_system *system, control_params *control, /* write current frame */ if ( out_control->write_steps > 0 && - (data->step-data->prev_steps) % out_control->write_steps == 0 ) { + (data->step-data->prev_steps) % out_control->write_steps == 0) { Append_Frame( system, control, data, lists, out_control, mpi_data ); } } diff --git a/src/USER-REAXC/reaxc_lookup.cpp b/src/USER-REAXC/reaxc_lookup.cpp index 980e6e0fb6..b45a6da265 100644 --- a/src/USER-REAXC/reaxc_lookup.cpp +++ b/src/USER-REAXC/reaxc_lookup.cpp @@ -64,26 +64,26 @@ void Natural_Cubic_Spline( LAMMPS_NS::Error* error_ptr, const double *h, const d /* build the linear system */ a[0] = a[1] = a[n-1] = 0; - for ( i = 2; i < (int)n-1; ++i ) + for (i = 2; i < (int)n-1; ++i) a[i] = h[i-1]; b[0] = b[n-1] = 0; - for ( i = 1; i < (int)n-1; ++i ) + for (i = 1; i < (int)n-1; ++i) b[i] = 2 * (h[i-1] + h[i]); c[0] = c[n-2] = c[n-1] = 0; - for ( i = 1; i < (int)n-2; ++i ) + for (i = 1; i < (int)n-2; ++i) c[i] = h[i]; d[0] = d[n-1] = 0; - for ( i = 1; i < (int)n-1; ++i ) + for (i = 1; i < (int)n-1; ++i) d[i] = 6 * ((f[i+1]-f[i])/h[i] - (f[i]-f[i-1])/h[i-1]); v[0] = 0; v[n-1] = 0; Tridiagonal_Solve( &(a[1]), &(b[1]), &(c[1]), &(d[1]), &(v[1]), n-2 ); - for ( i = 1; i < (int)n; ++i ) { + for (i = 1; i < (int)n; ++i) { coef[i-1].d = (v[i] - v[i-1]) / (6*h[i-1]); coef[i-1].c = v[i]/2; coef[i-1].b = (f[i]-f[i-1])/h[i-1] + h[i-1]*(2*v[i] + v[i-1])/6; @@ -114,25 +114,25 @@ void Complete_Cubic_Spline( LAMMPS_NS::Error* error_ptr, const double *h, const /* build the linear system */ a[0] = 0; - for ( i = 1; i < (int)n; ++i ) + for (i = 1; i < (int)n; ++i) a[i] = h[i-1]; b[0] = 2*h[0]; - for ( i = 1; i < (int)n; ++i ) + for (i = 1; i < (int)n; ++i) b[i] = 2 * (h[i-1] + h[i]); c[n-1] = 0; - for ( i = 0; i < (int)n-1; ++i ) + for (i = 0; i < (int)n-1; ++i) c[i] = h[i]; d[0] = 6 * (f[1]-f[0])/h[0] - 6 * v0; d[n-1] = 6 * vlast - 6 * (f[n-1]-f[n-2]/h[n-2]); - for ( i = 1; i < (int)n-1; ++i ) + for (i = 1; i < (int)n-1; ++i) d[i] = 6 * ((f[i+1]-f[i])/h[i] - (f[i]-f[i-1])/h[i-1]); Tridiagonal_Solve( &(a[0]), &(b[0]), &(c[0]), &(d[0]), &(v[0]), n ); - for ( i = 1; i < (int)n; ++i ) { + for (i = 1; i < (int)n; ++i) { coef[i-1].d = (v[i] - v[i-1]) / (6*h[i-1]); coef[i-1].c = v[i]/2; coef[i-1].b = (f[i]-f[i-1])/h[i-1] + h[i-1]*(2*v[i] + v[i-1])/6; @@ -181,21 +181,21 @@ int Init_Lookup_Tables( reax_system *system, control_params *control, LR = (LR_lookup_table**) scalloc(system->error_ptr, num_atom_types, sizeof(LR_lookup_table*), "lookup:LR"); - for ( i = 0; i < num_atom_types; ++i ) + for (i = 0; i < num_atom_types; ++i) LR[i] = (LR_lookup_table*) scalloc(system->error_ptr, num_atom_types, sizeof(LR_lookup_table), "lookup:LR[i]"); - for ( i = 0; i < REAX_MAX_ATOM_TYPES; ++i ) + for (i = 0; i < REAX_MAX_ATOM_TYPES; ++i) existing_types[i] = 0; - for ( i = 0; i < system->n; ++i ) + for (i = 0; i < system->n; ++i) existing_types[ system->my_atoms[i].type ] = 1; MPI_Allreduce( existing_types, aggregated, REAX_MAX_ATOM_TYPES, MPI_INT, MPI_SUM, mpi_data->world ); - for ( i = 0; i < num_atom_types; ++i ) { + for (i = 0; i < num_atom_types; ++i) { if (aggregated[i]) { - for ( j = i; j < num_atom_types; ++j ) { + for (j = i; j < num_atom_types; ++j) { if (aggregated[j]) { LR[i][j].xmin = 0; LR[i][j].xmax = control->nonb_cut; @@ -216,7 +216,7 @@ int Init_Lookup_Tables( reax_system *system, control_params *control, smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef), "lookup:LR[i,j].CEclmb"); - for ( r = 1; r <= control->tabulate; ++r ) { + for (r = 1; r <= control->tabulate; ++r) { LR_vdW_Coulomb( system, workspace, control, i, j, r * dr, &(LR[i][j].y[r]) ); h[r] = LR[i][j].dx; fh[r] = LR[i][j].y[r].H; @@ -277,8 +277,8 @@ void Deallocate_Lookup_Tables( reax_system *system ) ntypes = system->reax_param.num_atom_types; - for ( i = 0; i < ntypes; ++i ) { - for ( j = i; j < ntypes; ++j ) + for (i = 0; i < ntypes; ++i) { + for (j = i; j < ntypes; ++j) if (LR[i][j].n) { sfree(system->error_ptr, LR[i][j].y, "LR[i,j].y" ); sfree(system->error_ptr, LR[i][j].H, "LR[i,j].H" ); diff --git a/src/USER-REAXC/reaxc_multi_body.cpp b/src/USER-REAXC/reaxc_multi_body.cpp index 00c8fbab2d..ab66e3352a 100644 --- a/src/USER-REAXC/reaxc_multi_body.cpp +++ b/src/USER-REAXC/reaxc_multi_body.cpp @@ -63,7 +63,7 @@ void Atom_Energy( reax_system *system, control_params *control, p_ovun7 = system->reax_param.gp.l[8]; p_ovun8 = system->reax_param.gp.l[9]; - for( i = 0; i < system->n; ++i ) { + for (i = 0; i < system->n; ++i) { /* set the parameter pointer */ type_i = system->my_atoms[i].type; if (type_i < 0) continue; @@ -76,7 +76,7 @@ void Atom_Energy( reax_system *system, control_params *control, numbonds = 0; e_lp = 0.0; - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) numbonds ++; /* calculate the energy */ @@ -97,7 +97,7 @@ void Atom_Energy( reax_system *system, control_params *control, /* correction for C2 */ if (p_lp3 > 0.001 && !strcmp(system->reax_param.sbp[type_i].name, "C")) - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; if (type_j < 0) continue; @@ -127,7 +127,7 @@ void Atom_Energy( reax_system *system, control_params *control, } - for( i = 0; i < system->n; ++i ) { + for (i = 0; i < system->n; ++i) { type_i = system->my_atoms[i].type; if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[ type_i ]); @@ -139,7 +139,7 @@ void Atom_Energy( reax_system *system, control_params *control, p_ovun2 = sbp_i->p_ovun2; sum_ovun1 = sum_ovun2 = 0; - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; if (type_j < 0) continue; @@ -186,7 +186,7 @@ void Atom_Energy( reax_system *system, control_params *control, numbonds = 0; e_un = 0.0; - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) numbonds ++; if (numbonds > 0 || control->enobondsflag) @@ -214,7 +214,7 @@ void Atom_Energy( reax_system *system, control_params *control, if (numbonds > 0 || control->enobondsflag) workspace->CdDelta[i] += CEunder3; // UnCoor - 1st term - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { pbond = &(bonds->select.bond_list[pj]); j = pbond->nbr; bo_ij = &(pbond->bo_data); diff --git a/src/USER-REAXC/reaxc_nonbonded.cpp b/src/USER-REAXC/reaxc_nonbonded.cpp index 7c3350fd40..97790aa997 100644 --- a/src/USER-REAXC/reaxc_nonbonded.cpp +++ b/src/USER-REAXC/reaxc_nonbonded.cpp @@ -62,13 +62,13 @@ void vdW_Coulomb_Energy( reax_system *system, control_params *control, e_vdW = 0; e_lg = de_lg = 0.0; - for( i = 0; i < natoms; ++i ) { + for (i = 0; i < natoms; ++i) { if (system->my_atoms[i].type < 0) continue; start_i = Start_Index(i, far_nbrs); end_i = End_Index(i, far_nbrs); orig_i = system->my_atoms[i].orig_id; - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); j = nbr_pj->nbr; if (system->my_atoms[j].type < 0) continue; @@ -228,14 +228,14 @@ void Tabulated_vdW_Coulomb_Energy( reax_system *system,control_params *control, e_ele = e_vdW = 0; - for( i = 0; i < natoms; ++i ) { + for (i = 0; i < natoms; ++i) { type_i = system->my_atoms[i].type; if (type_i < 0) continue; start_i = Start_Index(i,far_nbrs); end_i = End_Index(i,far_nbrs); orig_i = system->my_atoms[i].orig_id; - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); j = nbr_pj->nbr; type_j = system->my_atoms[j].type; @@ -322,7 +322,7 @@ void Compute_Polarization_Energy( reax_system *system, simulation_data *data ) double q, en_tmp; data->my_en.e_pol = 0.0; - for( i = 0; i < system->n; i++ ) { + for (i = 0; i < system->n; i++) { type_i = system->my_atoms[i].type; if (type_i < 0) continue; q = system->my_atoms[i].q; diff --git a/src/USER-REAXC/reaxc_reset_tools.cpp b/src/USER-REAXC/reaxc_reset_tools.cpp index e400f38970..5caaf860e7 100644 --- a/src/USER-REAXC/reaxc_reset_tools.cpp +++ b/src/USER-REAXC/reaxc_reset_tools.cpp @@ -41,7 +41,7 @@ void Reset_Atoms( reax_system* system, control_params *control ) system->numH = 0; if (control->hbond_cut > 0) - for( i = 0; i < system->n; ++i ) { + for (i = 0; i < system->n; ++i) { atom = &(system->my_atoms[i]); if (atom->type < 0) continue; if (system->reax_param.sbp[ atom->type ].p_hbond == 1) @@ -135,7 +135,7 @@ void Reset_Neighbor_Lists( reax_system *system, control_params *control, total_bonds = 0; /* reset start-end indexes */ - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { Set_Start_Index( i, total_bonds, bonds ); Set_End_Index( i, total_bonds, bonds ); total_bonds += system->my_atoms[i].num_bonds; @@ -158,7 +158,7 @@ void Reset_Neighbor_Lists( reax_system *system, control_params *control, total_hbonds = 0; /* reset start-end indexes */ - for( i = 0; i < system->n; ++i ) { + for (i = 0; i < system->n; ++i) { Hindex = system->my_atoms[i].Hindex; if (Hindex > -1) { Set_Start_Index( Hindex, total_hbonds, hbonds ); diff --git a/src/USER-REAXC/reaxc_tool_box.cpp b/src/USER-REAXC/reaxc_tool_box.cpp index b27a1635fe..b559a362f4 100644 --- a/src/USER-REAXC/reaxc_tool_box.cpp +++ b/src/USER-REAXC/reaxc_tool_box.cpp @@ -62,7 +62,7 @@ int Tokenize( char* s, char*** tok ) strncpy( test, s, MAX_LINE-1); - for( word = strtok(test, sep); word; word = strtok(nullptr, sep) ) { + for (word = strtok(test, sep); word; word = strtok(nullptr, sep)) { strncpy( (*tok)[count], word, MAX_LINE ); count++; } diff --git a/src/USER-REAXC/reaxc_torsion_angles.cpp b/src/USER-REAXC/reaxc_torsion_angles.cpp index c49b095b20..305e83707d 100644 --- a/src/USER-REAXC/reaxc_torsion_angles.cpp +++ b/src/USER-REAXC/reaxc_torsion_angles.cpp @@ -85,9 +85,9 @@ double Calculate_Omega( rvec dvec_ij, double r_ij, if (arg < -1.0) arg = -1.0; if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) sin_ijk = MIN_SINE; - else if ( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) sin_ijk = -MIN_SINE; + else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) sin_ijk = -MIN_SINE; if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) sin_jkl = MIN_SINE; - else if ( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) sin_jkl = -MIN_SINE; + else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) sin_jkl = -MIN_SINE; // dcos_omega_di rvec_ScaledSum( dcos_omega_di, (htra-arg*hnra)/r_ij, dvec_ij, -1., dvec_li ); @@ -169,13 +169,13 @@ void Torsion_Angles( reax_system *system, control_params *control, natoms = system->n; - for( j = 0; j < natoms; ++j ) { + for (j = 0; j < natoms; ++j) { type_j = system->my_atoms[j].type; Delta_j = workspace->Delta_boc[j]; start_j = Start_Index(j, bonds); end_j = End_Index(j, bonds); - for( pk = start_j; pk < end_j; ++pk ) { + for (pk = start_j; pk < end_j; ++pk) { pbond_jk = &( bonds->select.bond_list[pk] ); k = pbond_jk->nbr; bo_jk = &( pbond_jk->bo_data ); @@ -212,7 +212,7 @@ void Torsion_Angles( reax_system *system, control_params *control, exp_tor34_inv = 1.0 / (1.0 + exp_tor3_DjDk + exp_tor4_DjDk); f11_DjDk = (2.0 + exp_tor3_DjDk) * exp_tor34_inv; - for( pi = start_pk; pi < end_pk; ++pi ) { + for (pi = start_pk; pi < end_pk; ++pi) { p_ijk = &( thb_intrs->select.three_body_list[pi] ); pij = p_ijk->pthb; // pij is pointer to i on j's bond_list pbond_ij = &( bonds->select.bond_list[pij] ); @@ -230,14 +230,14 @@ void Torsion_Angles( reax_system *system, control_params *control, //tan_ijk_i = 1. / tan( theta_ijk ); if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) tan_ijk_i = cos_ijk / MIN_SINE; - else if ( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) + else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) tan_ijk_i = cos_ijk / -MIN_SINE; else tan_ijk_i = cos_ijk / sin_ijk; exp_tor2_ij = exp( -p_tor2 * BOA_ij ); exp_cot2_ij = exp( -p_cot2 * SQR(BOA_ij -1.5) ); - for( pl = start_pj; pl < end_pj; ++pl ) { + for (pl = start_pj; pl < end_pj; ++pl) { p_jkl = &( thb_intrs->select.three_body_list[pl] ); l = p_jkl->thb; plk = p_jkl->pthb; //pointer to l on k's bond_list! @@ -251,7 +251,7 @@ void Torsion_Angles( reax_system *system, control_params *control, if ( i != l && fbh->cnt && bo_kl->BO > control->thb_cut/*0*/ && - bo_ij->BO * bo_jk->BO * bo_kl->BO > control->thb_cut/*0*/ ) { + bo_ij->BO * bo_jk->BO * bo_kl->BO > control->thb_cut/*0*/) { ++num_frb_intrs; r_kl = pbond_kl->d; BOA_kl = bo_kl->BO - control->thb_cut; @@ -262,7 +262,7 @@ void Torsion_Angles( reax_system *system, control_params *control, //tan_jkl_i = 1. / tan( theta_jkl ); if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) tan_jkl_i = cos_jkl / MIN_SINE; - else if ( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) + else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) tan_jkl_i = cos_jkl / -MIN_SINE; else tan_jkl_i = cos_jkl /sin_jkl; diff --git a/src/USER-REAXC/reaxc_traj.cpp b/src/USER-REAXC/reaxc_traj.cpp index 2d56722aba..66a1c70b0e 100644 --- a/src/USER-REAXC/reaxc_traj.cpp +++ b/src/USER-REAXC/reaxc_traj.cpp @@ -285,7 +285,7 @@ int Write_Init_Desc( reax_system *system, control_params * /*control*/, out_control->line[0] = 0; out_control->buffer[0] = 0; - for( i = 0; i < system->n; ++i ) { + for (i = 0; i < system->n; ++i) { p_atom = &( system->my_atoms[i] ); sprintf( out_control->line, INIT_DESC, p_atom->orig_id, p_atom->type, p_atom->name, @@ -299,7 +299,7 @@ int Write_Init_Desc( reax_system *system, control_params * /*control*/, np * INIT_DESCS + me, mpi_data->world ); } else { buffer_len = system->n * INIT_DESC_LEN; - for( i = 0; i < np; ++i ) + for (i = 0; i < np; ++i) if (i != MASTER_NODE) { MPI_Recv( out_control->buffer + buffer_len, buffer_req - buffer_len, MPI_CHAR, i, np*INIT_DESCS+i, mpi_data->world, &status ); @@ -508,10 +508,10 @@ int Write_Atoms( reax_system *system, control_params * /*control*/, /* fill in buffer */ out_control->line[0] = 0; out_control->buffer[0] = 0; - for( i = 0; i < system->n; ++i ) { + for (i = 0; i < system->n; ++i) { p_atom = &( system->my_atoms[i] ); - switch( out_control->atom_info ) { + switch (out_control->atom_info) { case OPT_ATOM_BASIC: sprintf( out_control->line, ATOM_BASIC, p_atom->orig_id, p_atom->x[0], p_atom->x[1], p_atom->x[2], @@ -545,7 +545,7 @@ int Write_Atoms( reax_system *system, control_params * /*control*/, np*ATOM_LINES+me, mpi_data->world ); } else { buffer_len = system->n * line_len; - for( i = 0; i < np; ++i ) + for (i = 0; i < np; ++i) if (i != MASTER_NODE) { MPI_Recv( out_control->buffer + buffer_len, buffer_req - buffer_len, MPI_CHAR, i, np*ATOM_LINES+i, mpi_data->world, &status ); @@ -575,8 +575,8 @@ int Write_Bonds(reax_system *system, control_params *control, reax_list *bonds, /* count the number of bonds I will write */ my_bonds = 0; - for( i=0; i < system->n; ++i ) - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { + for (i=0; i < system->n; ++i) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { j = bonds->select.bond_list[pj].nbr; if ( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && bonds->select.bond_list[pj].bo_data.BO >= control->bg_cut ) @@ -600,14 +600,14 @@ int Write_Bonds(reax_system *system, control_params *control, reax_list *bonds, out_control->buffer[0] = 0; my_bonds = 0; - for( i=0; i < system->n; ++i ) { - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { + for (i=0; i < system->n; ++i) { + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { bo_ij = &( bonds->select.bond_list[pj] ); j = bo_ij->nbr; if ( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && - bo_ij->bo_data.BO >= control->bg_cut ) { - switch( out_control->bond_info ) { + bo_ij->bo_data.BO >= control->bg_cut) { + switch (out_control->bond_info) { case OPT_BOND_BASIC: sprintf( out_control->line, BOND_BASIC, system->my_atoms[i].orig_id, system->my_atoms[j].orig_id, @@ -634,7 +634,7 @@ int Write_Bonds(reax_system *system, control_params *control, reax_list *bonds, np*BOND_LINES+me, mpi_data->world ); } else { buffer_len = my_bonds * line_len; - for( i = 0; i < np; ++i ) + for (i = 0; i < np; ++i) if (i != MASTER_NODE) { MPI_Recv( out_control->buffer + buffer_len, buffer_req - buffer_len, MPI_CHAR, i, np*BOND_LINES+i, mpi_data->world, &status ); @@ -666,14 +666,14 @@ int Write_Angles( reax_system *system, control_params *control, /* count the number of valence angles I will output */ my_angles = 0; - for( j = 0; j < system->n; ++j ) - for( pi = Start_Index(j, bonds); pi < End_Index(j, bonds); ++pi ) { + for (j = 0; j < system->n; ++j) + for (pi = Start_Index(j, bonds); pi < End_Index(j, bonds); ++pi) { bo_ij = &(bonds->select.bond_list[pi]); i = bo_ij->nbr; if (bo_ij->bo_data.BO >= control->bg_cut) // physical j&i bond - for( pk = Start_Index( pi, thb_intrs ); - pk < End_Index( pi, thb_intrs ); ++pk ) { + for (pk = Start_Index( pi, thb_intrs); + pk < End_Index( pi, thb_intrs ); ++pk) { angle_ijk = &(thb_intrs->select.three_body_list[pk]); k = angle_ijk->thb; bo_jk = &(bonds->select.bond_list[ angle_ijk->pthb ]); @@ -699,20 +699,20 @@ int Write_Angles( reax_system *system, control_params *control, my_angles = 0; out_control->line[0] = 0; out_control->buffer[0] = 0; - for( j = 0; j < system->n; ++j ) - for( pi = Start_Index(j, bonds); pi < End_Index(j, bonds); ++pi ) { + for (j = 0; j < system->n; ++j) + for (pi = Start_Index(j, bonds); pi < End_Index(j, bonds); ++pi) { bo_ij = &(bonds->select.bond_list[pi]); i = bo_ij->nbr; if (bo_ij->bo_data.BO >= control->bg_cut) // physical j&i bond - for( pk = Start_Index( pi, thb_intrs ); - pk < End_Index( pi, thb_intrs ); ++pk ) { + for (pk = Start_Index( pi, thb_intrs); + pk < End_Index( pi, thb_intrs ); ++pk) { angle_ijk = &(thb_intrs->select.three_body_list[pk]); k = angle_ijk->thb; bo_jk = &(bonds->select.bond_list[ angle_ijk->pthb ]); if ( system->my_atoms[i].orig_id < system->my_atoms[k].orig_id && - bo_jk->bo_data.BO >= control->bg_cut ) { // physical j&k bond + bo_jk->bo_data.BO >= control->bg_cut) { // physical j&k bond sprintf( out_control->line, ANGLE_BASIC, system->my_atoms[i].orig_id, system->my_atoms[j].orig_id, system->my_atoms[k].orig_id, RAD2DEG( angle_ijk->theta ) ); @@ -729,7 +729,7 @@ int Write_Angles( reax_system *system, control_params *control, np*ANGLE_LINES+me, mpi_data->world ); } else { buffer_len = my_angles * line_len; - for( i = 0; i < np; ++i ) + for (i = 0; i < np; ++i) if (i != MASTER_NODE) { MPI_Recv( out_control->buffer + buffer_len, buffer_req - buffer_len, MPI_CHAR, i, np*ANGLE_LINES+i, mpi_data->world, &status ); diff --git a/src/USER-REAXC/reaxc_valence_angles.cpp b/src/USER-REAXC/reaxc_valence_angles.cpp index b545fa93a9..9aec0a1f05 100644 --- a/src/USER-REAXC/reaxc_valence_angles.cpp +++ b/src/USER-REAXC/reaxc_valence_angles.cpp @@ -37,7 +37,7 @@ static double Dot( double* v1, double* v2, int k ) { double ret = 0.0; - for( int i=0; i < k; ++i ) + for (int i=0; i < k; ++i) ret += v1[i] * v2[i]; return ret; @@ -66,7 +66,7 @@ void Calculate_dCos_Theta( rvec dvec_ji, double d_ji, rvec dvec_jk, double d_jk, double dot_dvecs = Dot( dvec_ji, dvec_jk, 3 ); double Cdot_inv3 = dot_dvecs * inv_dists3; - for( t = 0; t < 3; ++t ) { + for (t = 0; t < 3; ++t) { (*dcos_theta_di)[t] = dvec_jk[t] * inv_dists - Cdot_inv3 * sqr_d_jk * dvec_ji[t]; (*dcos_theta_dj)[t] = -(dvec_jk[t] + dvec_ji[t]) * inv_dists + @@ -124,7 +124,7 @@ void Valence_Angles( reax_system *system, control_params *control, num_thb_intrs = 0; - for( j = 0; j < system->N; ++j ) { // Ray: the first one with system->N + for (j = 0; j < system->N; ++j) { // Ray: the first one with system->N type_j = system->my_atoms[j].type; if (type_j < 0) continue; start_j = Start_Index(j, bonds); @@ -134,7 +134,7 @@ void Valence_Angles( reax_system *system, control_params *control, p_val5 = system->reax_param.sbp[ type_j ].p_val5; SBOp = 0, prod_SBO = 1; - for( t = start_j; t < end_j; ++t ) { + for (t = start_j; t < end_j; ++t) { bo_jt = &(bonds->select.bond_list[t].bo_data); SBOp += (bo_jt->BO_pi + bo_jt->BO_pi2); temp = SQR( bo_jt->BO ); @@ -169,7 +169,7 @@ void Valence_Angles( reax_system *system, control_params *control, expval6 = exp( p_val6 * workspace->Delta_boc[j] ); - for( pi = start_j; pi < end_j; ++pi ) { + for (pi = start_j; pi < end_j; ++pi) { Set_Start_Index( pi, num_thb_intrs, thb_intrs ); pbond_ij = &(bonds->select.bond_list[pi]); bo_ij = &(pbond_ij->bo_data); @@ -177,15 +177,15 @@ void Valence_Angles( reax_system *system, control_params *control, if ( BOA_ij/*bo_ij->BO*/ > 0.0 && - ( j < system->n || pbond_ij->nbr < system->n ) ) { + ( j < system->n || pbond_ij->nbr < system->n )) { i = pbond_ij->nbr; type_i = system->my_atoms[i].type; - for( pk = start_j; pk < pi; ++pk ) { + for (pk = start_j; pk < pi; ++pk) { start_pk = Start_Index( pk, thb_intrs ); end_pk = End_Index( pk, thb_intrs ); - for( t = start_pk; t < end_pk; ++t ) + for (t = start_pk; t < end_pk; ++t) if (thb_intrs->select.three_body_list[t].thb == i) { p_ijk = &(thb_intrs->select.three_body_list[num_thb_intrs] ); p_kji = &(thb_intrs->select.three_body_list[t]); @@ -202,7 +202,7 @@ void Valence_Angles( reax_system *system, control_params *control, } } - for( pk = pi+1; pk < end_j; ++pk ) { + for (pk = pi+1; pk < end_j; ++pk) { pbond_jk = &(bonds->select.bond_list[pk]); bo_jk = &(pbond_jk->bo_data); BOA_jk = bo_jk->BO - control->thb_cut; @@ -232,10 +232,10 @@ void Valence_Angles( reax_system *system, control_params *control, if ((j < system->n) && (BOA_jk > 0.0) && (bo_ij->BO > control->thb_cut) && (bo_jk->BO > control->thb_cut) && - (bo_ij->BO * bo_jk->BO > control->thb_cutsq) ) { + (bo_ij->BO * bo_jk->BO > control->thb_cutsq)) { thbh = &( system->reax_param.thbp[ type_i ][ type_j ][ type_k ] ); - for( cnt = 0; cnt < thbh->cnt; ++cnt ) { + for (cnt = 0; cnt < thbh->cnt; ++cnt) { if (fabs(thbh->prm[cnt].p_val1) > 0.001) { thbp = &( thbh->prm[cnt] ); @@ -345,7 +345,7 @@ void Valence_Angles( reax_system *system, control_params *control, workspace->CdDelta[i] += CEcoa4; workspace->CdDelta[k] += CEcoa5; - for( t = start_j; t < end_j; ++t ) { + for (t = start_j; t < end_j; ++t) { pbond_jt = &( bonds->select.bond_list[t] ); bo_jt = &(pbond_jt->bo_data); temp_bo_jt = bo_jt->BO; diff --git a/src/USER-REAXC/reaxc_vector.cpp b/src/USER-REAXC/reaxc_vector.cpp index edee65d637..e0e3a14782 100644 --- a/src/USER-REAXC/reaxc_vector.cpp +++ b/src/USER-REAXC/reaxc_vector.cpp @@ -107,15 +107,15 @@ void rtensor_MatVec( rvec ret, rtensor m, rvec v ) if (ret == v) { - for( i = 0; i < 3; ++i ) + for (i = 0; i < 3; ++i) temp[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2]; - for( i = 0; i < 3; ++i ) + for (i = 0; i < 3; ++i) ret[i] = temp[i]; } else { - for( i = 0; i < 3; ++i ) + for (i = 0; i < 3; ++i) ret[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2]; } } diff --git a/src/USER-SMD/compute_smd_triangle_vertices.cpp b/src/USER-SMD/compute_smd_triangle_vertices.cpp index f621029a47..c487e60872 100644 --- a/src/USER-SMD/compute_smd_triangle_vertices.cpp +++ b/src/USER-SMD/compute_smd_triangle_vertices.cpp @@ -95,7 +95,7 @@ void ComputeSMDTriangleVertices::compute_peratom() { int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if ((mask[i] & groupbit) && (mol[i] >= 65535) ) { + if ((mask[i] & groupbit) && (mol[i] >= 65535)) { outputVector[i][0] = smd_data_9[i][0]; outputVector[i][1] = smd_data_9[i][1]; outputVector[i][2] = smd_data_9[i][2]; diff --git a/src/USER-SMTBQ/pair_smtbq.cpp b/src/USER-SMTBQ/pair_smtbq.cpp index 5f416955cf..6989be8376 100644 --- a/src/USER-SMTBQ/pair_smtbq.cpp +++ b/src/USER-SMTBQ/pair_smtbq.cpp @@ -153,9 +153,9 @@ PairSMTBQ::~PairSMTBQ() if (elements) { for ( i = 0; i < nelements; i++) delete [] elements[i]; - for( i = 0; i < atom->ntypes ; i++ ) free( params[i].nom ); - for( i = 1; i <= maxintparam ; i++ ) free( intparams[i].typepot ); - for( i = 1; i <= maxintparam ; i++ ) free( intparams[i].mode ); + for (i = 0; i < atom->ntypes ; i++ ) free( params[i].nom); + for (i = 1; i <= maxintparam ; i++ ) free( intparams[i].typepot); + for (i = 1; i <= maxintparam ; i++ ) free( intparams[i].mode); } free(QEqMode); @@ -400,7 +400,7 @@ void PairSMTBQ::read_file(char *file) // open file on all processors FILE *fp; fp = utils::open_potential(file,lmp,nullptr); - if ( fp == nullptr ) { + if (fp == nullptr) { char str[128]; snprintf(str,128,"Cannot open SMTBQ potential file %s",file); error->one(FLERR,str); @@ -572,7 +572,7 @@ void PairSMTBQ::read_file(char *file) // if (test == 0) printf (" on a %s -> %d = %s\n",words[2],j,params[j].nom); - if ( test == 1 ) { + if (test == 1) { if (verbose) printf ("========== fin des interaction ==========\n"); break ; } @@ -766,7 +766,7 @@ void PairSMTBQ::read_file(char *file) } else if (strcmp(QEqMode,"QEqAll") != 0 && strcmp(QEqMode,"QEqAllParallel") != 0 && - strcmp(QEqMode,"Surface") != 0 ) { + strcmp(QEqMode,"Surface") != 0) { error->all(FLERR,"The QEq Mode is not known. QEq mode should be :\n" " Possible QEq modes | parameters\n" " QEqAll | no parameters\n" @@ -809,7 +809,7 @@ void PairSMTBQ::read_file(char *file) /* ======================================================== */ /* deallocate helper storage */ - for( i = 0; i < MAXTOKENS ; i++ ) free( words[i] ); + for (i = 0; i < MAXTOKENS ; i++ ) free( words[i]); free( words ); free( ptr ); fclose(fp); @@ -1055,7 +1055,7 @@ void PairSMTBQ::compute(int eflag, int vflag) // ---------------------------------------------- if ( strcmp(intparams[m].typepot,"buck") == 0 || - strcmp(intparams[m].typepot,"buckPlusAttr") ==0 ) { + strcmp(intparams[m].typepot,"buckPlusAttr") ==0) { // ---------------------------------------------- evdwl = 0.0; fpair =0.0; @@ -1079,7 +1079,7 @@ void PairSMTBQ::compute(int eflag, int vflag) } // ----------------------------------- Rep O-O - if (strcmp(intparams[m].typepot,"buckPlusAttr") == 0 ) { + if (strcmp(intparams[m].typepot,"buckPlusAttr") == 0) { // ---------------------------------------------- evdwl = 0.0; fpair =0.0; @@ -2577,7 +2577,7 @@ void PairSMTBQ::Charge() // Init_charge(nQEq,nQEqa,nQEqc); // --------------------------------- - if (update->ntimestep == 0 && (strcmp(QInitMode,"true") == 0) ) { + if (update->ntimestep == 0 && (strcmp(QInitMode,"true") == 0)) { //Carefull here it won't be fine if there are more than 2 species!!! QOxInit=max(QOxInit, -0.98* params[1].qform *nQEqcall[gp]/nQEqaall[gp]) ; @@ -2622,7 +2622,7 @@ void PairSMTBQ::Charge() // -------------------------------------------- - for (iloop = 0; iloop < loopmax; iloop ++ ) { + for (iloop = 0; iloop < loopmax; iloop ++) { // -------------------------------------------- qtot = qtotll = Transf[3*cluster] = 0.0 ; @@ -3556,7 +3556,7 @@ int PairSMTBQ::Tokenize( char* s, char*** tok ) strncpy( test, s, MAXLINE-1 ); - for( mot = strtok(test, sep); mot; mot = strtok(nullptr, sep) ) { + for (mot = strtok(test, sep); mot; mot = strtok(nullptr, sep)) { strncpy( (*tok)[count], mot, MAXLINE ); count++; } diff --git a/src/USER-TALLY/compute_force_tally.cpp b/src/USER-TALLY/compute_force_tally.cpp index e9b507ff11..21c518f3d7 100644 --- a/src/USER-TALLY/compute_force_tally.cpp +++ b/src/USER-TALLY/compute_force_tally.cpp @@ -122,7 +122,7 @@ void ComputeForceTally::pair_tally_callback(int i, int j, int nlocal, int newton const int * const mask = atom->mask; if ( ((mask[i] & groupbit) && (mask[j] & groupbit2)) - || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ) { + || ((mask[i] & groupbit2) && (mask[j] & groupbit))) { if (newton || i < nlocal) { if (mask[i] & groupbit) { diff --git a/src/USER-TALLY/compute_heat_flux_tally.cpp b/src/USER-TALLY/compute_heat_flux_tally.cpp index 18edae46ea..002d0e3238 100644 --- a/src/USER-TALLY/compute_heat_flux_tally.cpp +++ b/src/USER-TALLY/compute_heat_flux_tally.cpp @@ -131,7 +131,7 @@ void ComputeHeatFluxTally::pair_tally_callback(int i, int j, int nlocal, int new const int * const mask = atom->mask; if ( ((mask[i] & groupbit) && (mask[j] & groupbit2)) - || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ) { + || ((mask[i] & groupbit2) && (mask[j] & groupbit))) { const double epairhalf = 0.5 * (evdwl + ecoul); fpair *= 0.5; diff --git a/src/USER-TALLY/compute_pe_mol_tally.cpp b/src/USER-TALLY/compute_pe_mol_tally.cpp index 7cc0f95d80..97c1a7ffbe 100644 --- a/src/USER-TALLY/compute_pe_mol_tally.cpp +++ b/src/USER-TALLY/compute_pe_mol_tally.cpp @@ -100,7 +100,7 @@ void ComputePEMolTally::pair_tally_callback(int i, int j, int nlocal, int newton const tagint * const molid = atom->molecule; if ( ((mask[i] & groupbit) && (mask[j] & groupbit2)) - || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ) { + || ((mask[i] & groupbit2) && (mask[j] & groupbit))) { evdwl *= 0.5; ecoul *= 0.5; if (newton || i < nlocal) { diff --git a/src/USER-TALLY/compute_pe_tally.cpp b/src/USER-TALLY/compute_pe_tally.cpp index 3d589aed70..451c785b13 100644 --- a/src/USER-TALLY/compute_pe_tally.cpp +++ b/src/USER-TALLY/compute_pe_tally.cpp @@ -119,7 +119,7 @@ void ComputePETally::pair_tally_callback(int i, int j, int nlocal, int newton, const int * const mask = atom->mask; if ( ((mask[i] & groupbit) && (mask[j] & groupbit2)) - || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ) { + || ((mask[i] & groupbit2) && (mask[j] & groupbit))) { evdwl *= 0.5; ecoul *= 0.5; if (newton || i < nlocal) { diff --git a/src/USER-TALLY/compute_stress_tally.cpp b/src/USER-TALLY/compute_stress_tally.cpp index c2c474fb1c..e32a134ec3 100644 --- a/src/USER-TALLY/compute_stress_tally.cpp +++ b/src/USER-TALLY/compute_stress_tally.cpp @@ -124,7 +124,7 @@ void ComputeStressTally::pair_tally_callback(int i, int j, int nlocal, int newto const int * const mask = atom->mask; if ( ((mask[i] & groupbit) && (mask[j] & groupbit2)) - || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ) { + || ((mask[i] & groupbit2) && (mask[j] & groupbit))) { fpair *= 0.5; const double v0 = dx*dx*fpair; diff --git a/src/USER-VTK/dump_vtk.cpp b/src/USER-VTK/dump_vtk.cpp index a2bf1fb4bf..518015d688 100644 --- a/src/USER-VTK/dump_vtk.cpp +++ b/src/USER-VTK/dump_vtk.cpp @@ -1910,7 +1910,7 @@ void DumpVTK::identify_vectors() continue; // assume components are grouped together and in correct order - if (name.count(it->first + 1) && name.count(it->first + 2) ) { // more attributes? + if (name.count(it->first + 1) && name.count(it->first + 2)) { // more attributes? if (it->second.compare(0,it->second.length()-3,name[it->first + 1],0,it->second.length()-3) == 0 && // same attributes? it->second.compare(0,it->second.length()-3,name[it->first + 2],0,it->second.length()-3) == 0 ) { diff --git a/src/VORONOI/compute_voronoi_atom.cpp b/src/VORONOI/compute_voronoi_atom.cpp index 50ebe8b7cf..2c3dac06f8 100644 --- a/src/VORONOI/compute_voronoi_atom.cpp +++ b/src/VORONOI/compute_voronoi_atom.cpp @@ -68,7 +68,7 @@ ComputeVoronoi::ComputeVoronoi(LAMMPS *lmp, int narg, char **arg) : faces = nullptr; int iarg = 3; - while ( iarg 0 ) { + if (maxedge > 0) { vector_flag = 1; size_vector = maxedge+1; memory->create(edge,maxedge+1,"voronoi/atom:edge"); @@ -269,7 +269,7 @@ void ComputeVoronoi::buildCells() // cutghost is in lamda coordinates for triclinic boxes, use subxx_lamda double *h = domain->h; - for( i=0; i<3; ++i ) { + for (i=0; i<3; ++i) { sublo_bound[i] = sublo_lamda[i]-cut[i]-e; subhi_bound[i] = subhi_lamda[i]+cut[i]+e; if (domain->periodicity[i]==0) { @@ -290,7 +290,7 @@ void ComputeVoronoi::buildCells() } else { // orthogonal box - for( i=0; i<3; ++i ) { + for (i=0; i<3; ++i) { sublo_bound[i] = sublo[i]-cut[i]-e; subhi_bound[i] = subhi[i]+cut[i]+e; if (domain->periodicity[i]==0) { @@ -307,15 +307,15 @@ void ComputeVoronoi::buildCells() // n = # of voro++ spatial hash cells (with approximately cubic cells) int nall = nlocal + atom->nghost; double n[3], V; - for( i=0; i<3; ++i ) n[i] = subhi_bound[i] - sublo_bound[i]; + for (i=0; i<3; ++i) n[i] = subhi_bound[i] - sublo_bound[i]; V = n[0]*n[1]*n[2]; - for( i=0; i<3; ++i ) { + for (i=0; i<3; ++i) { n[i] = round( n[i]*pow( double(nall)/(V*8.0), 0.333333 ) ); n[i] = n[i]==0 ? 1 : n[i]; } // clear edge statistics - if ( maxedge > 0 ) + if (maxedge > 0) for (i = 0; i <= maxedge; ++i) edge[i]=0; // initialize voro++ container @@ -543,10 +543,10 @@ void ComputeVoronoi::processCell(voronoicell_neighbor &c, int i) c.vertices(vcell); c.face_vertices(vlist); // for each face: vertex count followed list of vertex indices (n_1,v1_1,v2_1,v3_1,..,vn_1,n_2,v2_1,...) double dx, dy, dz, r2, t2 = ethresh*ethresh; - for( j=0; j < (int)vlist.size(); j+=vlist[j]+1 ) { + for (j=0; j < (int)vlist.size(); j+=vlist[j]+1) { int a, b, nedge = 0; // vlist[j] contains number of vertex indices for the current face - for( k=0; k < vlist[j]; ++k ) { + for (k=0; k < vlist[j]; ++k) { a = vlist[j+1+k]; // first vertex in edge b = vlist[j+1+(k+1)%vlist[j]]; // second vertex in edge (possible wrap around to first vertex in list) dx = vcell[a*3] - vcell[b*3]; @@ -625,7 +625,7 @@ void ComputeVoronoi::compute_vector() invoked_vector = update->ntimestep; if (invoked_peratom < invoked_vector) compute_peratom(); - for( int i=0; i= 2 && j <= 4) { unwrap_coord = (mybuf[m] - 0.5)/UNWRAPEXPAND + 0.5; offset += sprintf(&sbuf[offset],vformat[j],unwrap_coord); - } else if (j >= 5 ) { + } else if (j >= 5) { if (vtype[j] == Dump::INT) offset += sprintf(&sbuf[offset],vformat[j],static_cast (mybuf[m])); @@ -279,7 +279,7 @@ void DumpCFG::write_lines(int n, double *mybuf) } else if (j >= 2 && j <= 4) { unwrap_coord = (mybuf[m] - 0.5)/UNWRAPEXPAND + 0.5; fprintf(fp,vformat[j],unwrap_coord); - } else if (j >= 5 ) { + } else if (j >= 5) { if (vtype[j] == Dump::INT) fprintf(fp,vformat[j],static_cast (mybuf[m])); else if (vtype[j] == Dump::DOUBLE) diff --git a/src/finish.cpp b/src/finish.cpp index c3d921f3c4..810155f1b0 100644 --- a/src/finish.cpp +++ b/src/finish.cpp @@ -134,7 +134,7 @@ void Finish::end(int flag) (strcmp(update->unit_style,"micro") == 0) || (strcmp(update->unit_style,"nano") == 0) || (strcmp(update->unit_style,"electron") == 0) || - (strcmp(update->unit_style,"real") == 0)) ) { + (strcmp(update->unit_style,"real") == 0))) { double one_fs = force->femtosecond; double t_step = ((double) time_loop) / ((double) update->nsteps); double step_t = 1.0/t_step; diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 16e2ade2af..657323802d 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -70,7 +70,7 @@ nadapt(0), id_fix_diam(nullptr), id_fix_chg(nullptr), adapt(nullptr) if (iarg+3 > narg) error->all(FLERR,"Illegal fix adapt command"); nadapt++; iarg += 3; - } else if (strcmp(arg[iarg],"bond") == 0 ) { + } else if (strcmp(arg[iarg],"bond") == 0) { if (iarg+5 > narg) error->all(FLERR,"Illegal fix adapt command"); nadapt++; iarg += 5; @@ -110,7 +110,7 @@ nadapt(0), id_fix_diam(nullptr), id_fix_chg(nullptr), adapt(nullptr) nadapt++; iarg += 6; - } else if (strcmp(arg[iarg],"bond") == 0 ) { + } else if (strcmp(arg[iarg],"bond") == 0) { if (iarg+5 > narg) error->all(FLERR, "Illegal fix adapt command"); adapt[nadapt].which = BOND; int n = strlen(arg[iarg+1]) + 1; @@ -651,7 +651,7 @@ void FixAdapt::change_settings() } } if (anybond) { - for (int m = 0; m < nadapt; ++m ) { + for (int m = 0; m < nadapt; ++m) { Adapt *ad = &adapt[m]; if (ad->which == BOND) { ad->bond->reinit(); diff --git a/src/fix_halt.cpp b/src/fix_halt.cpp index f09a8c4464..76941dc176 100644 --- a/src/fix_halt.cpp +++ b/src/fix_halt.cpp @@ -107,7 +107,7 @@ FixHalt::FixHalt(LAMMPS *lmp, int narg, char **arg) : dlimit_path = new char[len]; // strip off quotes, if present if ( ((arg[iarg][0] == '"') || (arg[iarg][0] == '\'')) - && (arg[iarg][0] == arg[iarg][len-2]) ) { + && (arg[iarg][0] == arg[iarg][len-2])) { strcpy(dlimit_path,&arg[iarg][1]); dlimit_path[len-3] = '\0'; } else strcpy(dlimit_path,arg[iarg]); diff --git a/src/info.cpp b/src/info.cpp index 5202610f9a..bb3111cb69 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -933,33 +933,33 @@ bool Info::is_defined(const char *category, const char *name) bool Info::has_style(const std::string &category, const std::string &name) { - if ( category == "atom" ) { + if (category == "atom") { return find_style(lmp, atom->avec_map, name, false); - } else if ( category == "integrate" ) { + } else if (category == "integrate") { return find_style(lmp, update->integrate_map, name, true); - } else if ( category == "minimize" ) { + } else if (category == "minimize") { return find_style(lmp, update->minimize_map, name, true); - } else if ( category == "pair" ) { + } else if (category == "pair") { return find_style(lmp, force->pair_map, name, true); - } else if ( category == "bond" ) { + } else if (category == "bond") { return find_style(lmp, force->bond_map, name, true); - } else if ( category == "angle" ) { + } else if (category == "angle") { return find_style(lmp, force->angle_map, name, true); - } else if ( category == "dihedral" ) { + } else if (category == "dihedral") { return find_style(lmp, force->dihedral_map, name, true); - } else if ( category == "improper" ) { + } else if (category == "improper") { return find_style(lmp, force->improper_map, name, true); - } else if ( category == "kspace" ) { + } else if (category == "kspace") { return find_style(lmp, force->kspace_map, name, true); - } else if ( category == "fix" ) { + } else if (category == "fix") { return find_style(lmp, modify->fix_map, name, true); - } else if ( category == "compute" ) { + } else if (category == "compute") { return find_style(lmp, modify->compute_map, name, true); - } else if ( category == "region" ) { + } else if (category == "region") { return find_style(lmp, domain->region_map, name, false); - } else if ( category == "dump" ) { + } else if (category == "dump") { return find_style(lmp, output->dump_map, name, false); - } else if ( category == "command" ) { + } else if (category == "command") { return find_style(lmp, input->command_map, name, false); } return false; @@ -967,33 +967,33 @@ bool Info::has_style(const std::string &category, const std::string &name) std::vector Info::get_available_styles(const std::string &category) { - if ( category == "atom" ) { + if (category == "atom") { return get_style_names(atom->avec_map); - } else if ( category == "integrate" ) { + } else if (category == "integrate") { return get_style_names(update->integrate_map); - } else if ( category == "minimize" ) { + } else if (category == "minimize") { return get_style_names(update->minimize_map); - } else if ( category == "pair" ) { + } else if (category == "pair") { return get_style_names(force->pair_map); - } else if ( category == "bond" ) { + } else if (category == "bond") { return get_style_names(force->bond_map); - } else if ( category == "angle" ) { + } else if (category == "angle") { return get_style_names(force->angle_map); - } else if ( category == "dihedral" ) { + } else if (category == "dihedral") { return get_style_names(force->dihedral_map); - } else if ( category == "improper" ) { + } else if (category == "improper") { return get_style_names(force->improper_map); - } else if ( category == "kspace" ) { + } else if (category == "kspace") { return get_style_names(force->kspace_map); - } else if ( category == "fix" ) { + } else if (category == "fix") { return get_style_names(modify->fix_map); - } else if ( category == "compute" ) { + } else if (category == "compute") { return get_style_names(modify->compute_map); - } else if ( category == "region" ) { + } else if (category == "region") { return get_style_names(domain->region_map); - } else if ( category == "dump" ) { + } else if (category == "dump") { return get_style_names(output->dump_map); - } else if ( category == "command" ) { + } else if (category == "command") { return get_style_names(input->command_map); } return std::vector(); diff --git a/src/library.cpp b/src/library.cpp index 00a922f98b..7d3f2f8996 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -2758,7 +2758,7 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data) } // property / atom if ( (vptr == nullptr) && ((strstr(name,"d_") == name) - || (strstr(name,"i_") == name)) ) { + || (strstr(name,"i_") == name))) { fcid = lmp->atom->find_custom(&name[2], ltype); if (fcid < 0) { if (lmp->comm->me == 0) @@ -4269,7 +4269,7 @@ included in the LAMMPS library in use. */ int lammps_config_package_count() { int i = 0; - while(LAMMPS::installed_packages[i] != nullptr) { + while (LAMMPS::installed_packages[i] != nullptr) { ++i; } return i; diff --git a/src/min_hftn.cpp b/src/min_hftn.cpp index beca1a839a..c554981835 100644 --- a/src/min_hftn.cpp +++ b/src/min_hftn.cpp @@ -410,7 +410,7 @@ int MinHFTN::execute_hftn_(const bool bPrintProgress, double dMag = 0.5 * (fabs (dCurrentEnergy) + fabs (dNewEnergy)); dMag = MAX (dMag, MIN_ETOL_MAG); if ( (fabs (dAred) < (update->etol * dMag)) - || (dStepLengthInf == 0.0) ) { + || (dStepLengthInf == 0.0)) { if (bPrintProgress) hftn_print_line_ (true, niter+1, neval, dNewEnergy, dNewForce2, @@ -1267,7 +1267,7 @@ double MinHFTN::compute_to_tr_(const double dPP, //---- CHECK FOR ERRONEOUS DATA. if ( (dDD <= 0.0) || (dPP < 0.0) || (dTrustRadius < 0.0) - || (dTrustRadius * dTrustRadius < dPP) ) { + || (dTrustRadius * dTrustRadius < dPP)) { printf ("HFTN internal error - bad data given to compute_to_tr_()\n"); return( 0.0 ); } diff --git a/src/min_linesearch.cpp b/src/min_linesearch.cpp index 8856359bcb..0c6dd46408 100644 --- a/src/min_linesearch.cpp +++ b/src/min_linesearch.cpp @@ -545,7 +545,7 @@ pseudo code: bactrack = true // GRAD_TOL = 0.1 - if ( (not backtrack) && (fabs(fhCurr/fh0) <= GRAD_TOL) ): + if ((not backtrack) && (fabs(fhCurr/fh0) <= GRAD_TOL)): // forces sufficiently reduced without energy increase EXIT with success diff --git a/src/molecule.cpp b/src/molecule.cpp index d85cf47c71..819083e0b3 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -796,7 +796,7 @@ void Molecule::fragments(char *line) fragmentnames[i] = values.next_string(); - while(values.has_next()) { + while (values.has_next()) { int atomID = values.next_int(); if (atomID <= 0 || atomID > natoms) error->one(FLERR,"Invalid atom ID in Fragments section of molecule file"); @@ -1630,11 +1630,11 @@ void Molecule::body(int flag, int pflag, char *line) if (flag) { if (pflag == 0) { - while(values.has_next()) { + while (values.has_next()) { ibodyparams[nword++] = values.next_int(); } } else { - while(values.has_next()) { + while (values.has_next()) { dbodyparams[nword++] = values.next_double(); } } diff --git a/src/pair_coul_streitz.cpp b/src/pair_coul_streitz.cpp index 01fc0adac3..de2f180d44 100644 --- a/src/pair_coul_streitz.cpp +++ b/src/pair_coul_streitz.cpp @@ -247,7 +247,7 @@ void PairCoulStreitz::read_file(char *file) PotentialFileReader reader(lmp, file, "coul/streitz"); char * line; - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); @@ -318,7 +318,7 @@ void PairCoulStreitz::setup_params() for (i = 0; i < nelements; i++) { n = -1; for (m = 0; m < nparams; m++) { - if (i == params[m].ielement ) { + if (i == params[m].ielement) { if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); n = m; } diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 7e4c1d2781..3026c9c741 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -775,14 +775,14 @@ void PairHybrid::read_restart(FILE *fp) special_lj[m] = special_coul[m] = nullptr; if (me == 0) utils::sfread(FLERR,&n,sizeof(int),1,fp,nullptr,error); MPI_Bcast(&n,1,MPI_INT,0,world); - if (n > 0 ) { + if (n > 0) { special_lj[m] = new double[4]; if (me == 0) utils::sfread(FLERR,special_lj[m],sizeof(double),4,fp,nullptr,error); MPI_Bcast(special_lj[m],4,MPI_DOUBLE,0,world); } if (me == 0) utils::sfread(FLERR,&n,sizeof(int),1,fp,nullptr,error); MPI_Bcast(&n,1,MPI_INT,0,world); - if (n > 0 ) { + if (n > 0) { special_coul[m] = new double[4]; if (me == 0) utils::sfread(FLERR,special_coul[m],sizeof(double),4,fp,nullptr,error); MPI_Bcast(special_coul[m],4,MPI_DOUBLE,0,world); diff --git a/src/reader_native.cpp b/src/reader_native.cpp index a185f5ab3a..7c8bd9c3a8 100644 --- a/src/reader_native.cpp +++ b/src/reader_native.cpp @@ -165,7 +165,7 @@ bigint ReaderNative::read_header(double box[3][3], int &boxinfo, int &triclinic, Tokenizer tokens(labelline); nwords = 0; - while(tokens.has_next()) { + while (tokens.has_next()) { labels[tokens.next()] = nwords++; } diff --git a/src/reader_xyz.cpp b/src/reader_xyz.cpp index 6a51849a5e..b144857879 100644 --- a/src/reader_xyz.cpp +++ b/src/reader_xyz.cpp @@ -148,7 +148,7 @@ bigint ReaderXYZ::read_header(double /*box*/[3][3], int &boxinfo, int &/*triclin (fieldtype[i] == Y) || (fieldtype[i] == Z) || (fieldtype[i] == ID) || - (fieldtype[i] == TYPE) ) { + (fieldtype[i] == TYPE)) { fieldindex[i] = fieldtype[i]; } else { fieldflag = 1; diff --git a/src/replicate.cpp b/src/replicate.cpp index 296e099208..9e91c30612 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -510,12 +510,12 @@ void Replicate::command(int narg, char **arg) if (!xoverlap) { if (xboxlo < 0) { _xoverlap1 = 1; - if ( _lo[0] > (subhi[0] - EPSILON) ) _xoverlap1 = 0; + if (_lo[0] > (subhi[0] - EPSILON)) _xoverlap1 = 0; } if (xboxhi > 0) { _xoverlap2 = 1; - if ( _hi[0] < (sublo[0] + EPSILON) ) _xoverlap2 = 0; + if (_hi[0] < (sublo[0] + EPSILON)) _xoverlap2 = 0; } if (_xoverlap1 || _xoverlap2) xoverlap = 1; @@ -526,12 +526,12 @@ void Replicate::command(int narg, char **arg) if (!yoverlap) { if (yboxlo < 0) { _yoverlap1 = 1; - if ( _lo[1] > (subhi[1] - EPSILON) ) _yoverlap1 = 0; + if (_lo[1] > (subhi[1] - EPSILON)) _yoverlap1 = 0; } if (yboxhi > 0) { _yoverlap2 = 1; - if ( _hi[1] < (sublo[1] + EPSILON) ) _yoverlap2 = 0; + if (_hi[1] < (sublo[1] + EPSILON)) _yoverlap2 = 0; } if (_yoverlap1 || _yoverlap2) yoverlap = 1; @@ -543,12 +543,12 @@ void Replicate::command(int narg, char **arg) if (!zoverlap) { if (zboxlo < 0) { _zoverlap1 = 1; - if ( _lo[2] > (subhi[2] - EPSILON) ) _zoverlap1 = 0; + if (_lo[2] > (subhi[2] - EPSILON)) _zoverlap1 = 0; } if (zboxhi > 0) { _zoverlap2 = 1; - if ( _hi[2] < (sublo[2] + EPSILON) ) _zoverlap2 = 0; + if (_hi[2] < (sublo[2] + EPSILON)) _zoverlap2 = 0; } if (_zoverlap1 || _zoverlap2) zoverlap = 1; diff --git a/src/text_file_reader.cpp b/src/text_file_reader.cpp index 23ef4a5568..19f15d8522 100644 --- a/src/text_file_reader.cpp +++ b/src/text_file_reader.cpp @@ -101,7 +101,7 @@ char *TextFileReader::next_line(int nparams) { n = strlen(line); } - while(nwords == 0 || nwords < nparams) { + while (nwords == 0 || nwords < nparams) { char *ptr = fgets(&line[n], MAXLINE - n, fp); if (ptr == nullptr) { @@ -148,7 +148,7 @@ void TextFileReader::next_dvector(double * list, int n) { } ValueTokenizer values(line); - while(values.has_next()) { + while (values.has_next()) { list[i++] = values.next_double(); } } diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 37ebcd07fb..a9d82ca913 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -145,7 +145,7 @@ std::vector Tokenizer::as_vector() { // generate vector std::vector tokens; - while(has_next()) { + while (has_next()) { tokens.emplace_back(next()); } diff --git a/src/utils.cpp b/src/utils.cpp index 64283aa9c5..a58b384225 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1091,7 +1091,7 @@ void utils::merge_sort(int *index, int num, void *ptr, // copy all indices not handled by the chunked merge sort loop - for ( ; i < num ; i++ ) dest[i] = hold[i]; + for (; i < num ; i++) dest[i] = hold[i]; chunk *= 2; } diff --git a/src/write_coeff.cpp b/src/write_coeff.cpp index f84e1a2e33..8f1f6140ed 100644 --- a/src/write_coeff.cpp +++ b/src/write_coeff.cpp @@ -97,7 +97,7 @@ void WriteCoeff::command(int narg, char **arg) fprintf(two,"# LAMMPS coeff file via write_coeff, version %s\n", lmp->version); - while(1) { + while (1) { int coeff_mode = REGULAR_MODE; if (fgets(str,256,one) == nullptr) break; From b08582de69e6965d084d754bec77f38fba38a2b2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Dec 2020 09:54:46 -0500 Subject: [PATCH 33/51] fix bond/react buffer overflow: must not use sprintf to write to char variable --- src/USER-REACTION/fix_bond_react.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 483bd1c0f6..b5244d62a3 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -1966,12 +1966,11 @@ int FixBondReact::check_constraints() } if (nconstraints[rxnID] > 0) { - char evalstr[MAXLINE],*ptr,valstr; + char evalstr[MAXLINE],*ptr; strcpy(evalstr,constraintstr[rxnID]); for (int i = 0; i < nconstraints[rxnID]; i++) { - sprintf(&valstr,"%d", satisfied[i]); ptr = strchr(evalstr,'C'); - *ptr = valstr; + *ptr = satisfied[i] ? '1' : '0'; } double verdict = input->variable->evaluate_boolean(evalstr); if (verdict == 0.0) return 0; From 5b34d58e48540c5f3509f5a8ea96456da62864da Mon Sep 17 00:00:00 2001 From: Evan Weinberg Date: Wed, 30 Dec 2020 15:01:56 -0500 Subject: [PATCH 34/51] Removed kokkos_type.h include from pair_snap_kokkos.h --- src/KOKKOS/pair_snap_kokkos.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/KOKKOS/pair_snap_kokkos.h b/src/KOKKOS/pair_snap_kokkos.h index 352e6e30b1..c2a7e20384 100644 --- a/src/KOKKOS/pair_snap_kokkos.h +++ b/src/KOKKOS/pair_snap_kokkos.h @@ -13,8 +13,6 @@ #ifdef PAIR_CLASS -#include "kokkos_type.h" - PairStyle(snap/kk,PairSNAPKokkosDevice) PairStyle(snap/kk/device,PairSNAPKokkosDevice) #ifdef LMP_KOKKOS_GPU From f00ca10b1e4d6fa58b1359953a6214b0f74bc9cb Mon Sep 17 00:00:00 2001 From: Evan Weinberg Date: Wed, 30 Dec 2020 15:35:37 -0500 Subject: [PATCH 35/51] PR-specific whitespace fixes. --- src/KOKKOS/sna_kokkos_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index dc5ab2bcb8..e88ae1f0b3 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -531,7 +531,7 @@ void SNAKokkos::compute_ui(const typename Kokko // grab the cached value const complex ulist_prev = ulist_wrapper.get(ma); - // ulist_accum += rootpq * a.conj() * ulist_prev; + // ulist_accum += rootpq * a.conj() * ulist_prev; real rootpq = rootpqarray(j - ma, j - mb); ulist_accum.re += rootpq * (a.re * ulist_prev.re + a.im * ulist_prev.im); ulist_accum.im += rootpq * (a.re * ulist_prev.im - a.im * ulist_prev.re); @@ -943,7 +943,7 @@ void SNAKokkos::compute_fused_deidrj(const type const complex ulist_prev = ulist_wrapper.get(ma); const complex dulist_prev = dulist_wrapper.get(ma); - // ulist_accum += rootpq * a.conj() * ulist_prev; + // ulist_accum += rootpq * a.conj() * ulist_prev; real rootpq = rootpqarray(j - ma, j - mb); ulist_accum.re += rootpq * (a.re * ulist_prev.re + a.im * ulist_prev.im); ulist_accum.im += rootpq * (a.re * ulist_prev.im - a.im * ulist_prev.re); From 4d96b068de3ba4d3ff86dd6a78694eca5cef6aec Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 4 Jan 2021 11:01:12 -0500 Subject: [PATCH 36/51] properly initialize pointers to be freed --- src/REPLICA/neb.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/REPLICA/neb.cpp b/src/REPLICA/neb.cpp index 6f58d933a5..a6a70fde38 100644 --- a/src/REPLICA/neb.cpp +++ b/src/REPLICA/neb.cpp @@ -42,7 +42,7 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ -NEB::NEB(LAMMPS *lmp) : Pointers(lmp) {} +NEB::NEB(LAMMPS *lmp) : Pointers(lmp), all(nullptr), rdist(nullptr) {} /* ---------------------------------------------------------------------- internal NEB constructor, called from TAD @@ -50,7 +50,7 @@ NEB::NEB(LAMMPS *lmp) : Pointers(lmp) {} NEB::NEB(LAMMPS *lmp, double etol_in, double ftol_in, int n1steps_in, int n2steps_in, int nevery_in, double *buf_init, double *buf_final) - : Pointers(lmp) + : Pointers(lmp), all(nullptr), rdist(nullptr) { double delx,dely,delz; From 80d992a5ac9242ce845452d1c8cdd322e93db00f Mon Sep 17 00:00:00 2001 From: Evan Weinberg Date: Mon, 4 Jan 2021 19:06:03 -0500 Subject: [PATCH 37/51] Replies to PR review: comment and variable name clean-up. --- src/KOKKOS/kokkos_type.h | 6 +++--- src/KOKKOS/pair_snap_kokkos.h | 8 ++++++-- src/KOKKOS/pair_snap_kokkos_impl.h | 26 +++++++++++--------------- src/KOKKOS/sna_kokkos.h | 8 ++++---- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index aac87e9153..6ef7c7b4e4 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -1090,10 +1090,10 @@ struct params_lj_coul { typedef double SNAreal; //typedef struct { SNAreal re, im; } SNAcomplex; -template -struct alignas(2*sizeof(real_)) SNAComplex +template +struct alignas(2*sizeof(real_type)) SNAComplex { - using real = real_; + using real = real_type; using complex = SNAComplex; real re,im; diff --git a/src/KOKKOS/pair_snap_kokkos.h b/src/KOKKOS/pair_snap_kokkos.h index c2a7e20384..84567c38ad 100644 --- a/src/KOKKOS/pair_snap_kokkos.h +++ b/src/KOKKOS/pair_snap_kokkos.h @@ -65,7 +65,7 @@ struct TagPairSNAPComputeYiCPU{}; struct TagPairSNAPComputeDuidrjCPU{}; struct TagPairSNAPComputeDeidrjCPU{}; -template +template class PairSNAPKokkos : public PairSNAP { public: enum {EnabledNeighFlags=FULL|HALF|HALFTHREAD}; @@ -75,9 +75,13 @@ public: typedef EV_FLOAT value_type; static constexpr int vector_length = vector_length_; - using real = real_; + using real = real_type; using complex = SNAComplex; + // type-dependent team sizes + static constexpr int team_size_compute_ui = sizeof(real) == 4 ? 8 : 4; + static constexpr int team_size_compute_fused_deidrj = sizeof(real) == 4 ? 4 : 2; + PairSNAPKokkos(class LAMMPS *); ~PairSNAPKokkos(); diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index 194738828c..c554f48710 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -324,7 +324,9 @@ void PairSNAPKokkos::compute(int eflag_in, int // ComputeUi w/vector parallelism, shared memory, direct atomicAdd into ulisttot { // new AoSoA form - constexpr int team_size = sizeof(real) == 4 ? 8 : 4; // shared memory reqs + + // team_size_compute_ui is defined in `pair_snap_kokkos.h` + constexpr int team_size = team_size_compute_ui; // scratch size: 32 atoms * (twojmax+1) cached values, no double buffer const int tile_size = vector_length * (twojmax + 1); @@ -341,7 +343,7 @@ void PairSNAPKokkos::compute(int eflag_in, int int n_teams = chunk_size_div * max_neighs * (twojmax + 1); int n_teams_div = (n_teams + team_size - 1) / team_size; - typename Kokkos::TeamPolicy policy_ui(n_teams_div,team_size, vector_length); + typename Kokkos::TeamPolicy policy_ui(n_teams_div, team_size, vector_length); policy_ui = policy_ui.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); Kokkos::parallel_for("ComputeUi",policy_ui,*this); @@ -389,7 +391,9 @@ void PairSNAPKokkos::compute(int eflag_in, int // Fused ComputeDuidrj, ComputeDeidrj { // new AoSoA form - constexpr int team_size = sizeof(real) == 4 ? 4 : 2; // shared memory reqs + + // team_size_compute_fused_deidrj is defined in `pair_snap_kokkos.h` + constexpr int team_size = team_size_compute_fused_deidrj; // scratch size: 32 atoms * (twojmax+1) cached values * 2 for u, du, no double buffer const int tile_size = vector_length * (twojmax + 1); @@ -731,20 +735,15 @@ KOKKOS_INLINE_FUNCTION void PairSNAPKokkos::operator() (TagPairSNAPComputeUi,const typename Kokkos::TeamPolicy::member_type& team) const { SNAKokkos my_sna = snaKK; - constexpr int team_size = sizeof(real) == 4 ? 8 : 4; - if (team.team_size() != team_size) return; // error - // extract flattened atom_div / neighbor number / bend location - int flattened_idx = team.team_rank() + team.league_rank() * team_size; + int flattened_idx = team.team_rank() + team.league_rank() * team_size_compute_ui; // extract neighbor index, iatom_div - const int iatom_div = flattened_idx / (max_neighs * (twojmax + 1)); // plug in int_fastdiv + const int iatom_div = flattened_idx / (max_neighs * (twojmax + 1)); const int jj_jbend = flattened_idx - iatom_div * (max_neighs * (twojmax + 1)); const int jbend = jj_jbend / max_neighs; const int jj = jj_jbend - jbend * max_neighs; - // check base atom numbers, hopefully this doesn't lead to blocking conditions? - // yep, we can't have a return in here Kokkos::parallel_for(Kokkos::ThreadVectorRange(team, vector_length), [&] (const int iatom_mod) { const int ii = iatom_mod + vector_length * iatom_div; @@ -857,14 +856,11 @@ KOKKOS_INLINE_FUNCTION void PairSNAPKokkos::operator() (TagPairSNAPComputeFusedDeidrj,const typename Kokkos::TeamPolicy::member_type& team) const { SNAKokkos my_sna = snaKK; - constexpr int team_size = sizeof(real) == 4 ? 4 : 2; - if (team.team_size() != team_size) return; // error - // extract flattened atom_div / neighbor number / bend location - int flattened_idx = team.team_rank() + team.league_rank() * team_size; + int flattened_idx = team.team_rank() + team.league_rank() * team_size_compute_fused_deidrj; // extract neighbor index, iatom_div - const int iatom_div = flattened_idx / (max_neighs * (twojmax + 1)); // plug in int_fastdiv + const int iatom_div = flattened_idx / (max_neighs * (twojmax + 1)); const int jj_jbend = flattened_idx - iatom_div * (max_neighs * (twojmax + 1)); const int jbend = jj_jbend / max_neighs; const int jj = jj_jbend - jbend * max_neighs; diff --git a/src/KOKKOS/sna_kokkos.h b/src/KOKKOS/sna_kokkos.h index d34e9a9e17..7ee01776d0 100644 --- a/src/KOKKOS/sna_kokkos.h +++ b/src/KOKKOS/sna_kokkos.h @@ -25,9 +25,9 @@ namespace LAMMPS_NS { -template +template struct WignerWrapper { - using real = real_; + using real = real_type; using complex = SNAComplex; static constexpr int vector_length = vector_length_; @@ -56,11 +56,11 @@ struct alignas(8) FullHalfMapper { int flip_sign; // 0 -> isn't flipped, 1 -> conj, -1 -> -conj }; -template +template class SNAKokkos { public: - using real = real_; + using real = real_type; using complex = SNAComplex; static constexpr int vector_length = vector_length_; From e0f8d01176f901a40a1b3fa302cddc1fe808dc47 Mon Sep 17 00:00:00 2001 From: Evan Weinberg Date: Mon, 4 Jan 2021 19:33:31 -0500 Subject: [PATCH 38/51] Whitespace fix. --- src/KOKKOS/pair_snap_kokkos_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index c554f48710..e4df428881 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -391,7 +391,7 @@ void PairSNAPKokkos::compute(int eflag_in, int // Fused ComputeDuidrj, ComputeDeidrj { // new AoSoA form - + // team_size_compute_fused_deidrj is defined in `pair_snap_kokkos.h` constexpr int team_size = team_size_compute_fused_deidrj; From df01bbc0162901b43e2b27484a6c4025cb705351 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 4 Jan 2021 23:28:58 -0500 Subject: [PATCH 39/51] provide input script backward compatibility w/o documenting the old option --- src/KOKKOS/kokkos.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 34100ff16f..3e25ae061f 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -415,7 +415,8 @@ void KokkosLMP::accelerator(int narg, char **arg) } else error->all(FLERR,"Illegal package kokkos command"); reverse_comm_changed = 0; iarg += 2; - } else if (strcmp(arg[iarg],"gpu/aware") == 0) { + } else if ((strcmp(arg[iarg],"gpu/aware") == 0) + || (strcmp(arg[iarg],"cuda/aware") == 0)) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"off") == 0) gpu_aware_flag = 0; else if (strcmp(arg[iarg+1],"on") == 0) gpu_aware_flag = 1; From 973c23018568de26b025bd37fcdd7581344cb74d Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 5 Jan 2021 08:29:47 -0700 Subject: [PATCH 40/51] Update chunksize --- doc/src/compute_orientorder_atom.rst | 6 +++--- doc/src/pair_snap.rst | 6 +++--- src/SNAP/pair_snap.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/src/compute_orientorder_atom.rst b/doc/src/compute_orientorder_atom.rst index 2a36fb4cc0..af4e6a21e8 100644 --- a/doc/src/compute_orientorder_atom.rst +++ b/doc/src/compute_orientorder_atom.rst @@ -115,8 +115,8 @@ The optional keyword *chunksize* is only applicable when using the the KOKKOS package and is ignored otherwise. This keyword controls the number of atoms in each pass used to compute the bond-orientational order parameters and is used to avoid running out of memory. For example -if there are 4000 atoms in the simulation and the *chunksize* -is set to 2000, the parameter calculation will be broken up +if there are 32768 atoms in the simulation and the *chunksize* +is set to 16384, the parameter calculation will be broken up into two passes. The value of :math:`Q_l` is set to zero for atoms not in the @@ -193,7 +193,7 @@ Default The option defaults are *cutoff* = pair style cutoff, *nnn* = 12, *degrees* = 5 4 6 8 10 12 i.e. :math:`Q_4`, :math:`Q_6`, :math:`Q_8`, :math:`Q_{10}`, and :math:`Q_{12}`, -*wl* = no, *wl/hat* = no, *components* off, and *chunksize* = 2000 +*wl* = no, *wl/hat* = no, *components* off, and *chunksize* = 16384 ---------- diff --git a/doc/src/pair_snap.rst b/doc/src/pair_snap.rst index 8aa10f5986..a99331345e 100644 --- a/doc/src/pair_snap.rst +++ b/doc/src/pair_snap.rst @@ -152,7 +152,7 @@ The default values for these keywords are * *chemflag* = 0 * *bnormflag* = 0 * *wselfallflag* = 0 -* *chunksize* = 2000 +* *chunksize* = 4096 If *quadraticflag* is set to 1, then the SNAP energy expression includes additional quadratic terms that have been shown to increase the overall accuracy of the potential without much increase @@ -189,8 +189,8 @@ pair style *snap* with the KOKKOS package and is ignored otherwise. This keyword controls the number of atoms in each pass used to compute the bispectrum components and is used to avoid running out of memory. For example -if there are 4000 atoms in the simulation and the *chunksize* -is set to 2000, the bispectrum calculation will be broken up +if there are 8192 atoms in the simulation and the *chunksize* +is set to 4096, the bispectrum calculation will be broken up into two passes. Detailed definitions for all the other keywords diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index a7ea6de591..741c237ca8 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -657,7 +657,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) chemflag = 0; bnormflag = 0; wselfallflag = 0; - chunksize = 2000; + chunksize = 4096; // open SNAP parameter file on proc 0 From 12ccc00ac9d2551af208781e4741f3d094dff2de Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 5 Jan 2021 08:34:08 -0700 Subject: [PATCH 41/51] Formatting tweak --- src/KOKKOS/pair_snap_kokkos_impl.h | 24 ++++++++++++------------ src/KOKKOS/sna_kokkos_impl.h | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index e4df428881..26ecd0dd36 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -299,10 +299,10 @@ void PairSNAPKokkos::compute(int eflag_in, int Kokkos::DefaultExecutionSpace::scratch_memory_space, Kokkos::MemoryTraits > ScratchViewType; - int scratch_size = ScratchViewType::shmem_size( team_size * max_neighs ); + int scratch_size = ScratchViewType::shmem_size(team_size * max_neighs); typename Kokkos::TeamPolicy policy_neigh(chunk_size,team_size,vector_length); - policy_neigh = policy_neigh.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); + policy_neigh = policy_neigh.set_scratch_size(0, Kokkos::PerTeam(scratch_size)); Kokkos::parallel_for("ComputeNeigh",policy_neigh,*this); } @@ -334,7 +334,7 @@ void PairSNAPKokkos::compute(int eflag_in, int Kokkos::DefaultExecutionSpace::scratch_memory_space, Kokkos::MemoryTraits > ScratchViewType; - int scratch_size = ScratchViewType::shmem_size( team_size * tile_size ); + int scratch_size = ScratchViewType::shmem_size(team_size * tile_size); // total number of teams needed int chunk_size_div = (chunk_size + vector_length - 1) / vector_length; @@ -344,7 +344,7 @@ void PairSNAPKokkos::compute(int eflag_in, int int n_teams_div = (n_teams + team_size - 1) / team_size; typename Kokkos::TeamPolicy policy_ui(n_teams_div, team_size, vector_length); - policy_ui = policy_ui.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); + policy_ui = policy_ui.set_scratch_size(0, Kokkos::PerTeam(scratch_size)); Kokkos::parallel_for("ComputeUi",policy_ui,*this); @@ -401,7 +401,7 @@ void PairSNAPKokkos::compute(int eflag_in, int Kokkos::DefaultExecutionSpace::scratch_memory_space, Kokkos::MemoryTraits > ScratchViewType; - int scratch_size = ScratchViewType::shmem_size( 2 * team_size * tile_size ); + int scratch_size = ScratchViewType::shmem_size(2 * team_size * tile_size); // total number of teams needed int chunk_size_div = (chunk_size + vector_length - 1) / vector_length; @@ -411,7 +411,7 @@ void PairSNAPKokkos::compute(int eflag_in, int int n_teams_div = (n_teams + team_size - 1) / team_size; typename Kokkos::TeamPolicy policy_fused_deidrj(n_teams_div,team_size,vector_length); - policy_fused_deidrj = policy_fused_deidrj.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); + policy_fused_deidrj = policy_fused_deidrj.set_scratch_size(0, Kokkos::PerTeam(scratch_size)); for (int k = 0; k < 3; k++) { snaKK.set_dir(k); @@ -631,7 +631,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom const int tile_size = max_neighs; // number of elements per thread const int team_rank = team.team_rank(); const int scratch_shift = team_rank * tile_size; // offset into pointer for entire team - int* type_cache = (int*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(int), 0) + scratch_shift; + int* type_cache = (int*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(int), 0) + scratch_shift; // Load various info about myself up front const int i = d_ilist[ii + chunk_offset]; @@ -668,7 +668,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom type_cache[jj] = jtype; - if ( jtype >= 0 ) + if (jtype >= 0) count++; }, ninside); @@ -679,7 +679,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom const int jtype = type_cache[jj]; - if ( jtype >= 0 ) { + if (jtype >= 0) { if (final) { T_INT j = d_neighbors(i,jj); const F_FLOAT dx = x(j,0) - xtmp; @@ -778,7 +778,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPTra if (mapper.flip_sign == 1) { utot_im = -utot_im; - } else if (mapper.flip_sign == -1 ) { + } else if (mapper.flip_sign == -1) { utot_re = -utot_re; } @@ -957,7 +957,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom const int jtype = type(j); const F_FLOAT rsq = dx*dx + dy*dy + dz*dz; - if ( rsq < rnd_cutsq(itype,jtype) ) + if (rsq < rnd_cutsq(itype,jtype)) count++; }); },ninside); @@ -977,7 +977,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom const F_FLOAT rsq = dx*dx + dy*dy + dz*dz; const int elem_j = d_map[jtype]; - if ( rsq < rnd_cutsq(itype,jtype) ) { + if (rsq < rnd_cutsq(itype,jtype)) { if (final) { my_sna.rij(ii,offset,0) = static_cast(dx); my_sna.rij(ii,offset,1) = static_cast(dy); diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index e88ae1f0b3..ed80647083 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -496,7 +496,7 @@ void SNAKokkos::compute_ui(const typename Kokko const int scratch_shift = team_rank * tile_size; // extract and wrap - WignerWrapper ulist_wrapper((complex*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper ulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); // load parameters @@ -900,8 +900,8 @@ void SNAKokkos::compute_fused_deidrj(const type const int scratch_shift = team_rank * tile_size; // extract, wrap shared memory buffer - WignerWrapper ulist_wrapper((complex*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); - WignerWrapper dulist_wrapper((complex*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper ulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper dulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); // load parameters const auto a = a_pack(iatom_mod, jnbor, iatom_div); @@ -1335,7 +1335,7 @@ void SNAKokkos::compute_yi_cpu(int iter, int jju1 = idxu_block[j1] + (j1 + 1) * mb1min; int jju2 = idxu_block[j2] + (j2 + 1) * mb2max; - int icgb = mb1min * (j2 +1 ) + mb2max; + int icgb = mb1min * (j2 +1) + mb2max; for (int ib = 0; ib < nb; ib++) { From fffbb8ac7fb524e464a09ad799d23bbd075d40fc Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 5 Jan 2021 09:08:57 -0700 Subject: [PATCH 42/51] Switch 'real' to 'real_type' --- src/KOKKOS/kokkos_type.h | 28 +-- src/KOKKOS/pair_snap_kokkos.h | 24 +- src/KOKKOS/pair_snap_kokkos_impl.h | 220 ++++++++--------- src/KOKKOS/sna_kokkos.h | 66 ++--- src/KOKKOS/sna_kokkos_impl.h | 370 ++++++++++++++--------------- 5 files changed, 354 insertions(+), 354 deletions(-) diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index 6ef7c7b4e4..fbe9799bee 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -1090,20 +1090,20 @@ struct params_lj_coul { typedef double SNAreal; //typedef struct { SNAreal re, im; } SNAcomplex; -template -struct alignas(2*sizeof(real_type)) SNAComplex +template +struct alignas(2*sizeof(real_type_)) SNAComplex { - using real = real_type; - using complex = SNAComplex; - real re,im; + using real_type = real_type_; + using complex = SNAComplex; + real_type re,im; KOKKOS_FORCEINLINE_FUNCTION SNAComplex() - : re(static_cast(0.)), im(static_cast(0.)) { ; } + : re(static_cast(0.)), im(static_cast(0.)) { ; } - KOKKOS_FORCEINLINE_FUNCTION SNAComplex(real re) - : re(re), im(static_cast(0.)) { ; } + KOKKOS_FORCEINLINE_FUNCTION SNAComplex(real_type re) + : re(re), im(static_cast(0.)) { ; } - KOKKOS_FORCEINLINE_FUNCTION SNAComplex(real re, real im) + KOKKOS_FORCEINLINE_FUNCTION SNAComplex(real_type re, real_type im) : re(re), im(im) { ; } KOKKOS_FORCEINLINE_FUNCTION SNAComplex(const SNAComplex& other) @@ -1132,19 +1132,19 @@ struct alignas(2*sizeof(real_type)) SNAComplex } KOKKOS_INLINE_FUNCTION - static constexpr complex zero() { return complex(static_cast(0.), static_cast(0.)); } + static constexpr complex zero() { return complex(static_cast(0.), static_cast(0.)); } KOKKOS_INLINE_FUNCTION - static constexpr complex one() { return complex(static_cast(1.), static_cast(0.)); } + static constexpr complex one() { return complex(static_cast(1.), static_cast(0.)); } KOKKOS_INLINE_FUNCTION const complex conj() { return complex(re, -im); } }; -template -KOKKOS_FORCEINLINE_FUNCTION SNAComplex operator*(const real& r, const SNAComplex& self) { - return SNAComplex(r*self.re, r*self.im); +template +KOKKOS_FORCEINLINE_FUNCTION SNAComplex operator*(const real_type& r, const SNAComplex& self) { + return SNAComplex(r*self.re, r*self.im); } typedef SNAComplex SNAcomplex; diff --git a/src/KOKKOS/pair_snap_kokkos.h b/src/KOKKOS/pair_snap_kokkos.h index 84567c38ad..416cc1b888 100644 --- a/src/KOKKOS/pair_snap_kokkos.h +++ b/src/KOKKOS/pair_snap_kokkos.h @@ -65,7 +65,7 @@ struct TagPairSNAPComputeYiCPU{}; struct TagPairSNAPComputeDuidrjCPU{}; struct TagPairSNAPComputeDeidrjCPU{}; -template +template class PairSNAPKokkos : public PairSNAP { public: enum {EnabledNeighFlags=FULL|HALF|HALFTHREAD}; @@ -75,12 +75,12 @@ public: typedef EV_FLOAT value_type; static constexpr int vector_length = vector_length_; - using real = real_type; - using complex = SNAComplex; + using real_type = real_type_; + using complex = SNAComplex; // type-dependent team sizes - static constexpr int team_size_compute_ui = sizeof(real) == 4 ? 8 : 4; - static constexpr int team_size_compute_fused_deidrj = sizeof(real) == 4 ? 4 : 2; + static constexpr int team_size_compute_ui = sizeof(real_type) == 4 ? 8 : 4; + static constexpr int team_size_compute_fused_deidrj = sizeof(real_type) == 4 ? 4 : 2; PairSNAPKokkos(class LAMMPS *); ~PairSNAPKokkos(); @@ -190,7 +190,7 @@ protected: t_bvec bvec; typedef Kokkos::View t_dbvec; t_dbvec dbvec; - SNAKokkos snaKK; + SNAKokkos snaKK; int inum,max_neighs,chunk_size,chunk_offset; int host_flag; @@ -225,14 +225,14 @@ inline double dist2(double* x,double* y); Kokkos::View i_uarraytot_r, i_uarraytot_i; Kokkos::View i_zarray_r, i_zarray_i; - Kokkos::View d_radelem; // element radii - Kokkos::View d_wjelem; // elements weights - Kokkos::View d_coeffelem; // element bispectrum coefficients + Kokkos::View d_radelem; // element radii + Kokkos::View d_wjelem; // elements weights + Kokkos::View d_coeffelem; // element bispectrum coefficients Kokkos::View d_map; // mapping from atom types to elements Kokkos::View d_ninside; // ninside for all atoms in list - Kokkos::View d_beta; // betas for all atoms in list - Kokkos::View d_beta_pack; // betas for all atoms in list, GPU - Kokkos::View d_bispectrum; // bispectrum components for all atoms in list + Kokkos::View d_beta; // betas for all atoms in list + Kokkos::View d_beta_pack; // betas for all atoms in list, GPU + Kokkos::View d_bispectrum; // bispectrum components for all atoms in list typedef Kokkos::DualView tdual_fparams; tdual_fparams k_cutsq; diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index 26ecd0dd36..1349232136 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -48,8 +48,8 @@ namespace LAMMPS_NS { //static double t7 = 0.0; /* ---------------------------------------------------------------------- */ -template -PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : PairSNAP(lmp) +template +PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : PairSNAP(lmp) { respa_enable = 0; @@ -67,8 +67,8 @@ PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : P /* ---------------------------------------------------------------------- */ -template -PairSNAPKokkos::~PairSNAPKokkos() +template +PairSNAPKokkos::~PairSNAPKokkos() { if (copymode) return; @@ -81,8 +81,8 @@ PairSNAPKokkos::~PairSNAPKokkos() init specific to this pair style ------------------------------------------------------------------------- */ -template -void PairSNAPKokkos::init_style() +template +void PairSNAPKokkos::init_style() { if (force->newton_pair == 0) error->all(FLERR,"Pair style SNAP requires newton pair on"); @@ -128,8 +128,8 @@ struct FindMaxNumNeighs { This version is a straightforward implementation ---------------------------------------------------------------------- */ -template -void PairSNAPKokkos::compute(int eflag_in, int vflag_in) +template +void PairSNAPKokkos::compute(int eflag_in, int vflag_in) { eflag = eflag_in; vflag = vflag_in; @@ -192,9 +192,9 @@ void PairSNAPKokkos::compute(int eflag_in, int if (beta_max < inum) { beta_max = inum; - d_beta = Kokkos::View("PairSNAPKokkos:beta",ncoeff,inum); + d_beta = Kokkos::View("PairSNAPKokkos:beta",ncoeff,inum); if (!host_flag) - d_beta_pack = Kokkos::View("PairSNAPKokkos:beta_pack",vector_length,ncoeff,(inum + vector_length - 1) / vector_length); + d_beta_pack = Kokkos::View("PairSNAPKokkos:beta_pack",vector_length,ncoeff,(inum + vector_length - 1) / vector_length); d_ninside = Kokkos::View("PairSNAPKokkos:ninside",inum); } @@ -501,8 +501,8 @@ void PairSNAPKokkos::compute(int eflag_in, int allocate all arrays ------------------------------------------------------------------------- */ -template -void PairSNAPKokkos::allocate() +template +void PairSNAPKokkos::allocate() { PairSNAP::allocate(); @@ -515,8 +515,8 @@ void PairSNAPKokkos::allocate() init for one type pair i,j and corresponding j,i ------------------------------------------------------------------------- */ -template -double PairSNAPKokkos::init_one(int i, int j) +template +double PairSNAPKokkos::init_one(int i, int j) { double cutone = PairSNAP::init_one(i,j); k_cutsq.h_view(i,j) = k_cutsq.h_view(j,i) = cutone*cutone; @@ -529,16 +529,16 @@ double PairSNAPKokkos::init_one(int i, int j) set coeffs for one or more type pairs ------------------------------------------------------------------------- */ -template -void PairSNAPKokkos::coeff(int narg, char **arg) +template +void PairSNAPKokkos::coeff(int narg, char **arg) { PairSNAP::coeff(narg,arg); // Set up element lists - d_radelem = Kokkos::View("pair:radelem",nelements); - d_wjelem = Kokkos::View("pair:wjelem",nelements); - d_coeffelem = Kokkos::View("pair:coeffelem",nelements,ncoeffall); + d_radelem = Kokkos::View("pair:radelem",nelements); + d_wjelem = Kokkos::View("pair:wjelem",nelements); + d_coeffelem = Kokkos::View("pair:coeffelem",nelements,ncoeffall); auto h_radelem = Kokkos::create_mirror_view(d_radelem); auto h_wjelem = Kokkos::create_mirror_view(d_wjelem); @@ -562,7 +562,7 @@ void PairSNAPKokkos::coeff(int narg, char **arg Kokkos::deep_copy(d_coeffelem,h_coeffelem); Kokkos::deep_copy(d_map,h_map); - snaKK = SNAKokkos(rfac0,twojmax, + snaKK = SNAKokkos(rfac0,twojmax, rmin0,switchflag,bzeroflag,chemflag,bnormflag,wselfallflag,nelements); snaKK.grow_rij(0,0); snaKK.init(); @@ -573,9 +573,9 @@ void PairSNAPKokkos::coeff(int narg, char **arg of AoSoA data layouts and scratch memory for recursive polynomials ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPBeta,const int& ii) const { +void PairSNAPKokkos::operator() (TagPairSNAPBeta,const int& ii) const { if (ii >= chunk_size) return; @@ -585,7 +585,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPBet const int i = d_ilist[ii + chunk_offset]; const int itype = type[i]; const int ielem = d_map[itype]; - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; auto d_coeffi = Kokkos::subview(d_coeffelem, ielem, Kokkos::ALL); @@ -605,7 +605,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPBet for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { const auto jdxb = jcoeff % idxb_max; const auto jdx_chem = jcoeff / idxb_max; - real bvecj = my_sna.blist(jdxb, jdx_chem, ii); + real_type bvecj = my_sna.blist(jdxb, jdx_chem, ii); d_beta_pack(iatom_mod,icoeff,iatom_div) += d_coeffi[k]*bvecj; d_beta_pack(iatom_mod,jcoeff,iatom_div) += d_coeffi[k]*bveci; k++; @@ -614,11 +614,11 @@ void PairSNAPKokkos::operator() (TagPairSNAPBet } } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeNeigh,const typename Kokkos::TeamPolicy::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeNeigh,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; // extract atom number int ii = team.team_rank() + team.league_rank() * team.team_size(); @@ -686,11 +686,11 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom const F_FLOAT dy = x(j,1) - ytmp; const F_FLOAT dz = x(j,2) - ztmp; const int elem_j = d_map[jtype]; - my_sna.rij(ii,offset,0) = static_cast(dx); - my_sna.rij(ii,offset,1) = static_cast(dy); - my_sna.rij(ii,offset,2) = static_cast(dz); - my_sna.wj(ii,offset) = static_cast(d_wjelem[elem_j]); - my_sna.rcutij(ii,offset) = static_cast((radi + d_radelem[elem_j])*rcutfac); + my_sna.rij(ii,offset,0) = static_cast(dx); + my_sna.rij(ii,offset,1) = static_cast(dy); + my_sna.rij(ii,offset,2) = static_cast(dz); + my_sna.wj(ii,offset) = static_cast(d_wjelem[elem_j]); + my_sna.rcutij(ii,offset) = static_cast((radi + d_radelem[elem_j])*rcutfac); my_sna.inside(ii,offset) = j; if (chemflag) my_sna.element(ii,offset) = elem_j; @@ -702,10 +702,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom }); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeCayleyKlein,const int iatom_mod, const int jnbor, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeCayleyKlein,const int iatom_mod, const int jnbor, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int ii = iatom_mod + iatom_div * vector_length; if (ii >= chunk_size) return; @@ -716,10 +716,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom my_sna.compute_cayley_klein(iatom_mod,jnbor,iatom_div); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPPreUi, const int iatom_mod, const int j, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPPreUi, const int iatom_mod, const int j, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int ii = iatom_mod + iatom_div * vector_length; if (ii >= chunk_size) return; @@ -730,10 +730,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPPre my_sna.pre_ui(iatom_mod, j, ielem, iatom_div); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeUi,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeUi,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // extract flattened atom_div / neighbor number / bend location int flattened_idx = team.team_rank() + team.league_rank() * team_size_compute_ui; @@ -757,10 +757,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformUi,const int iatom_mod, const int idxu, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPTransformUi,const int iatom_mod, const int idxu, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int iatom = iatom_mod + iatom_div * vector_length; if (iatom >= chunk_size) return; @@ -791,10 +791,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPTra } } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeYi,const int iatom_mod, const int jjz, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeYi,const int iatom_mod, const int jjz, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int iatom = iatom_mod + iatom_div * vector_length; if (iatom >= chunk_size) return; @@ -804,10 +804,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom my_sna.compute_yi(iatom_mod,jjz,iatom_div,d_beta_pack); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeZi,const int iatom_mod, const int jjz, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeZi,const int iatom_mod, const int jjz, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int iatom = iatom_mod + iatom_div * vector_length; if (iatom >= chunk_size) return; @@ -817,10 +817,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom my_sna.compute_zi(iatom_mod,jjz,iatom_div); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeBi,const int iatom_mod, const int jjb, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeBi,const int iatom_mod, const int jjb, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int iatom = iatom_mod + iatom_div * vector_length; if (iatom >= chunk_size) return; @@ -830,10 +830,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom my_sna.compute_bi(iatom_mod,jjb,iatom_div); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformBi,const int iatom_mod, const int idxb, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPTransformBi,const int iatom_mod, const int idxb, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int iatom = iatom_mod + iatom_div * vector_length; if (iatom >= chunk_size) return; @@ -851,10 +851,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPTra } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeFusedDeidrj,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeFusedDeidrj,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // extract flattened atom_div / neighbor number / bend location int flattened_idx = team.team_rank() + team.league_rank() * team_size_compute_fused_deidrj; @@ -887,14 +887,14 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom different arithmetic intensity requirements for the CPU vs GPU. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPBetaCPU,const int& ii) const { +void PairSNAPKokkos::operator() (TagPairSNAPBetaCPU,const int& ii) const { const int i = d_ilist[ii + chunk_offset]; const int itype = type[i]; const int ielem = d_map[itype]; - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; auto d_coeffi = Kokkos::subview(d_coeffelem, ielem, Kokkos::ALL); @@ -922,14 +922,14 @@ void PairSNAPKokkos::operator() (TagPairSNAPBet } } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeNeighCPU,const typename Kokkos::TeamPolicy::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeNeighCPU,const typename Kokkos::TeamPolicy::member_type& team) const { int ii = team.league_rank(); const int i = d_ilist[ii + chunk_offset]; - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; const double xtmp = x(i,0); const double ytmp = x(i,1); const double ztmp = x(i,2); @@ -979,11 +979,11 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom if (rsq < rnd_cutsq(itype,jtype)) { if (final) { - my_sna.rij(ii,offset,0) = static_cast(dx); - my_sna.rij(ii,offset,1) = static_cast(dy); - my_sna.rij(ii,offset,2) = static_cast(dz); - my_sna.wj(ii,offset) = static_cast(d_wjelem[elem_j]); - my_sna.rcutij(ii,offset) = static_cast((radi + d_radelem[elem_j])*rcutfac); + my_sna.rij(ii,offset,0) = static_cast(dx); + my_sna.rij(ii,offset,1) = static_cast(dy); + my_sna.rij(ii,offset,2) = static_cast(dz); + my_sna.wj(ii,offset) = static_cast(d_wjelem[elem_j]); + my_sna.rcutij(ii,offset) = static_cast((radi + d_radelem[elem_j])*rcutfac); my_sna.inside(ii,offset) = j; if (chemflag) my_sna.element(ii,offset) = elem_j; @@ -996,10 +996,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPPreUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPPreUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number const int ii = team.team_rank() + team.team_size() * team.league_rank(); @@ -1012,10 +1012,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPPre -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); @@ -1029,10 +1029,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom my_sna.compute_ui_cpu(team,ii,jj); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformUiCPU, const int j, const int iatom) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPTransformUiCPU, const int j, const int iatom) const { + SNAKokkos my_sna = snaKK; if (iatom >= chunk_size) return; @@ -1079,32 +1079,32 @@ void PairSNAPKokkos::operator() (TagPairSNAPTra } } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeYiCPU,const int& ii) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeYiCPU,const int& ii) const { + SNAKokkos my_sna = snaKK; my_sna.compute_yi_cpu(ii,d_beta); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeZiCPU,const int& ii) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeZiCPU,const int& ii) const { + SNAKokkos my_sna = snaKK; my_sna.compute_zi_cpu(ii); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeBiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeBiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { int ii = team.league_rank(); - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; my_sna.compute_bi_cpu(team,ii); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeDuidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeDuidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); @@ -1118,10 +1118,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom my_sna.compute_duidrj_cpu(team,ii,jj); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeDeidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeDeidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); @@ -1141,10 +1141,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom likely not worth it. ------------------------------------------------------------------------- */ -template +template template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team, EV_FLOAT& ev) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team, EV_FLOAT& ev) const { // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial @@ -1153,7 +1153,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom int ii = team.league_rank(); const int i = d_ilist[ii + chunk_offset]; - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; const int ninside = d_ninside(ii); Kokkos::parallel_for (Kokkos::TeamThreadRange(team,ninside), @@ -1242,20 +1242,20 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom } } -template +template template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team) const { EV_FLOAT ev; this->template operator()(TagPairSNAPComputeForce(), team, ev); } /* ---------------------------------------------------------------------- */ -template +template template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::v_tally_xyz(EV_FLOAT &ev, const int &i, const int &j, +void PairSNAPKokkos::v_tally_xyz(EV_FLOAT &ev, const int &i, const int &j, const F_FLOAT &fx, const F_FLOAT &fy, const F_FLOAT &fz, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { @@ -1300,24 +1300,24 @@ void PairSNAPKokkos::v_tally_xyz(EV_FLOAT &ev, memory usage ------------------------------------------------------------------------- */ -template -double PairSNAPKokkos::memory_usage() +template +double PairSNAPKokkos::memory_usage() { double bytes = Pair::memory_usage(); int n = atom->ntypes+1; bytes += n*n*sizeof(int); - bytes += n*n*sizeof(real); - bytes += (2*ncoeffall)*sizeof(real); - bytes += (ncoeff*3)*sizeof(real); + bytes += n*n*sizeof(real_type); + bytes += (2*ncoeffall)*sizeof(real_type); + bytes += (ncoeff*3)*sizeof(real_type); bytes += snaKK.memory_usage(); return bytes; } /* ---------------------------------------------------------------------- */ -template +template template -void PairSNAPKokkos::check_team_size_for(int inum, int &team_size) { +void PairSNAPKokkos::check_team_size_for(int inum, int &team_size) { int team_size_max; team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelForTag()); @@ -1326,9 +1326,9 @@ void PairSNAPKokkos::check_team_size_for(int in team_size = team_size_max/vector_length; } -template +template template -void PairSNAPKokkos::check_team_size_reduce(int inum, int &team_size) { +void PairSNAPKokkos::check_team_size_reduce(int inum, int &team_size) { int team_size_max; team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelReduceTag()); diff --git a/src/KOKKOS/sna_kokkos.h b/src/KOKKOS/sna_kokkos.h index 7ee01776d0..f183acdb57 100644 --- a/src/KOKKOS/sna_kokkos.h +++ b/src/KOKKOS/sna_kokkos.h @@ -25,18 +25,18 @@ namespace LAMMPS_NS { -template +template struct WignerWrapper { - using real = real_type; - using complex = SNAComplex; + using real_type = real_type_; + using complex = SNAComplex; static constexpr int vector_length = vector_length_; const int offset; // my offset into the vector (0, ..., vector_length - 1) - real* buffer; // buffer of real numbers + real_type* buffer; // buffer of real numbers KOKKOS_INLINE_FUNCTION WignerWrapper(complex* buffer_, const int offset_) - : offset(offset_), buffer(reinterpret_cast(buffer_)) + : offset(offset_), buffer(reinterpret_cast(buffer_)) { ; } KOKKOS_INLINE_FUNCTION @@ -56,26 +56,26 @@ struct alignas(8) FullHalfMapper { int flip_sign; // 0 -> isn't flipped, 1 -> conj, -1 -> -conj }; -template +template class SNAKokkos { public: - using real = real_type; - using complex = SNAComplex; + using real_type = real_type_; + using complex = SNAComplex; static constexpr int vector_length = vector_length_; typedef Kokkos::View t_sna_1i; - typedef Kokkos::View t_sna_1d; - typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1d_atomic; + typedef Kokkos::View t_sna_1d; + typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1d_atomic; typedef Kokkos::View t_sna_2i; - typedef Kokkos::View t_sna_2d; - typedef Kokkos::View t_sna_2d_ll; - typedef Kokkos::View t_sna_3d; - typedef Kokkos::View t_sna_3d_ll; - typedef Kokkos::View t_sna_4d; - typedef Kokkos::View t_sna_4d_ll; - typedef Kokkos::View t_sna_3d3; - typedef Kokkos::View t_sna_5d; + typedef Kokkos::View t_sna_2d; + typedef Kokkos::View t_sna_2d_ll; + typedef Kokkos::View t_sna_3d; + typedef Kokkos::View t_sna_3d_ll; + typedef Kokkos::View t_sna_4d; + typedef Kokkos::View t_sna_4d_ll; + typedef Kokkos::View t_sna_3d3; + typedef Kokkos::View t_sna_5d; typedef Kokkos::View t_sna_1c; typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1c_atomic; @@ -93,10 +93,10 @@ public: inline SNAKokkos() {}; KOKKOS_INLINE_FUNCTION - SNAKokkos(const SNAKokkos& sna, const typename Kokkos::TeamPolicy::member_type& team); + SNAKokkos(const SNAKokkos& sna, const typename Kokkos::TeamPolicy::member_type& team); inline - SNAKokkos(real, int, real, int, int, int, int, int, int); + SNAKokkos(real_type, int, real_type, int, int, int, int, int, int); KOKKOS_INLINE_FUNCTION ~SNAKokkos(); @@ -123,7 +123,7 @@ inline void compute_zi(const int&, const int&, const int&); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_yi(int,int,int, - const Kokkos::View &beta_pack); // ForceSNAP + const Kokkos::View &beta_pack); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_bi(const int&, const int&, const int&); // ForceSNAP @@ -136,7 +136,7 @@ inline void compute_zi_cpu(const int&); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_yi_cpu(int, - const Kokkos::View &beta); // ForceSNAP + const Kokkos::View &beta); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_bi_cpu(const typename Kokkos::TeamPolicy::member_type& team, int); // ForceSNAP @@ -151,13 +151,13 @@ inline void compute_deidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int); // ForceSNAP KOKKOS_INLINE_FUNCTION - real compute_sfac(real, real); // add_uarraytot, compute_duarray + real_type compute_sfac(real_type, real_type); // add_uarraytot, compute_duarray KOKKOS_INLINE_FUNCTION - real compute_dsfac(real, real); // compute_duarray + real_type compute_dsfac(real_type, real_type); // compute_duarray KOKKOS_INLINE_FUNCTION - void compute_s_dsfac(const real, const real, real&, real&); // compute_cayley_klein + void compute_s_dsfac(const real_type, const real_type, real_type&, real_type&); // compute_cayley_klein static KOKKOS_FORCEINLINE_FUNCTION void sincos_wrapper(double x, double* sin_, double *cos_) { sincos(x, sin_, cos_); } @@ -224,7 +224,7 @@ inline int ntriples; private: - real rmin0, rfac0; + real_type rmin0, rfac0; //use indexlist instead of loops, constructor generates these // Same across all SNAKokkos @@ -265,12 +265,12 @@ inline void init_rootpqarray(); // init() KOKKOS_INLINE_FUNCTION - void add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int, int, const real&, const real&, const real&, int); // compute_ui + void add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int, int, const real_type&, const real_type&, const real_type&, int); // compute_ui KOKKOS_INLINE_FUNCTION void compute_uarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int, - const real&, const real&, const real&, - const real&, const real&); // compute_ui_cpu + const real_type&, const real_type&, const real_type&, + const real_type&, const real_type&); // compute_ui_cpu inline @@ -280,8 +280,8 @@ inline int compute_ncoeff(); // SNAKokkos() KOKKOS_INLINE_FUNCTION void compute_duarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int, - const real&, const real&, const real&, // compute_duidrj_cpu - const real&, const real&, const real&, const real&, const real&); + const real_type&, const real_type&, const real_type&, // compute_duidrj_cpu + const real_type&, const real_type&, const real_type&, const real_type&, const real_type&); // Sets the style for the switching function // 0 = none @@ -293,11 +293,11 @@ inline int bnorm_flag; // Self-weight - real wself; + real_type wself; int wselfall_flag; int bzero_flag; // 1 if bzero subtracted from barray - Kokkos::View bzero; // array of B values for isolated atoms + Kokkos::View bzero; // array of B values for isolated atoms // for per-direction dulist calculation, specify the direction. int dir; diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index ed80647083..23c1670bd8 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -25,16 +25,16 @@ namespace LAMMPS_NS { static const double MY_PI = 3.14159265358979323846; // pi -template +template inline -SNAKokkos::SNAKokkos(real rfac0_in, - int twojmax_in, real rmin0_in, int switch_flag_in, int bzero_flag_in, +SNAKokkos::SNAKokkos(real_type rfac0_in, + int twojmax_in, real_type rmin0_in, int switch_flag_in, int bzero_flag_in, int chem_flag_in, int bnorm_flag_in, int wselfall_flag_in, int nelements_in) { LAMMPS_NS::ExecutionSpace execution_space = ExecutionSpaceFromDevice::space; host_flag = (execution_space == LAMMPS_NS::Host); - wself = static_cast(1.0); + wself = static_cast(1.0); rfac0 = rfac0_in; rmin0 = rmin0_in; @@ -63,7 +63,7 @@ SNAKokkos::SNAKokkos(real rfac0_in, cglist = t_sna_1d("SNAKokkos::cglist",idxcg_max); if (bzero_flag) { - bzero = Kokkos::View("sna:bzero",twojmax+1); + bzero = Kokkos::View("sna:bzero",twojmax+1); auto h_bzero = Kokkos::create_mirror_view(bzero); double www = wself*wself*wself; @@ -78,15 +78,15 @@ SNAKokkos::SNAKokkos(real rfac0_in, /* ---------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -SNAKokkos::~SNAKokkos() +SNAKokkos::~SNAKokkos() { } -template +template inline -void SNAKokkos::build_indexlist() +void SNAKokkos::build_indexlist() { // index list for cglist @@ -274,17 +274,17 @@ void SNAKokkos::build_indexlist() /* ---------------------------------------------------------------------- */ -template +template inline -void SNAKokkos::init() +void SNAKokkos::init() { init_clebsch_gordan(); init_rootpqarray(); } -template +template inline -void SNAKokkos::grow_rij(int newnatom, int newnmax) +void SNAKokkos::grow_rij(int newnatom, int newnmax) { if(newnatom <= natom && newnmax <= nmax) return; natom = newnatom; @@ -358,9 +358,9 @@ void SNAKokkos::grow_rij(int newnatom, int newn ComputeFusedDeidrj, which are one warp per atom-neighbor pair. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_cayley_klein(const int& iatom_mod, const int& jnbor, const int& iatom_div) +void SNAKokkos::compute_cayley_klein(const int& iatom_mod, const int& jnbor, const int& iatom_div) { const int iatom = iatom_mod + vector_length * iatom_div; const auto x = rij(iatom,jnbor,0); @@ -369,25 +369,25 @@ void SNAKokkos::compute_cayley_klein(const int& const auto rsq = x * x + y * y + z * z; const auto r = sqrt(rsq); const auto rcut = rcutij(iatom, jnbor); - const auto rscale0 = rfac0 * static_cast(MY_PI) / (rcut - rmin0); + const auto rscale0 = rfac0 * static_cast(MY_PI) / (rcut - rmin0); const auto theta0 = (r - rmin0) * rscale0; - real sn, cs; + real_type sn, cs; sincos_wrapper(theta0, &sn, &cs); - const real z0 = r * cs / sn; - const real dz0dr = z0 / r - (r*rscale0) * (rsq + z0 * z0) / rsq; + const real_type z0 = r * cs / sn; + const real_type dz0dr = z0 / r - (r*rscale0) * (rsq + z0 * z0) / rsq; const auto wj_local = wj(iatom, jnbor); - real sfac, dsfac; + real_type sfac, dsfac; compute_s_dsfac(r, rcut, sfac, dsfac); sfac *= wj_local; dsfac *= wj_local; - const auto rinv = static_cast(1.0) / r; + const auto rinv = static_cast(1.0) / r; const auto ux = x * rinv; const auto uy = y * rinv; const auto uz = z * rinv; - const auto r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); + const auto r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); const complex a = { z0 * r0inv, -z * r0inv }; const complex b = { r0inv * y, -r0inv * x }; @@ -433,9 +433,9 @@ void SNAKokkos::compute_cayley_klein(const int& // we need to explicitly zero `dedr` somewhere before hitting // ComputeFusedDeidrj --- this is just a convenient place to do it. - dedr(iatom_mod + vector_length * iatom_div, jnbor, 0) = static_cast(0.); - dedr(iatom_mod + vector_length * iatom_div, jnbor, 1) = static_cast(0.); - dedr(iatom_mod + vector_length * iatom_div, jnbor, 2) = static_cast(0.); + dedr(iatom_mod + vector_length * iatom_div, jnbor, 0) = static_cast(0.); + dedr(iatom_mod + vector_length * iatom_div, jnbor, 1) = static_cast(0.); + dedr(iatom_mod + vector_length * iatom_div, jnbor, 2) = static_cast(0.); } @@ -445,9 +445,9 @@ void SNAKokkos::compute_cayley_klein(const int& advantage of the symmetry of the Wigner U matrices. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::pre_ui(const int& iatom_mod, const int& j, const int& ielem, const int& iatom_div) +void SNAKokkos::pre_ui(const int& iatom_mod, const int& j, const int& ielem, const int& iatom_div) { for (int jelem = 0; jelem < nelements; jelem++) { @@ -459,11 +459,11 @@ void SNAKokkos::pre_ui(const int& iatom_mod, co for (int mb = 0; 2*mb <= j; mb++) { for (int ma = 0; ma <= j; ma++) { - real re_part = static_cast(0.); + real_type re_part = static_cast(0.); if (ma == mb && (!chem_flag || ielem == jelem || wselfall_flag)) { re_part = wself; } ulisttot_re_pack(iatom_mod, jju_half, jelem, iatom_div) = re_part; - ulisttot_im_pack(iatom_mod, jju_half, jelem, iatom_div) = static_cast(0.); + ulisttot_im_pack(iatom_mod, jju_half, jelem, iatom_div) = static_cast(0.); jju_half++; } @@ -477,9 +477,9 @@ void SNAKokkos::pre_ui(const int& iatom_mod, co accumulating to the total. GPU only. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_ui(const typename Kokkos::TeamPolicy::member_type& team, const int iatom_mod, const int j_bend, const int jnbor, const int iatom_div) +void SNAKokkos::compute_ui(const typename Kokkos::TeamPolicy::member_type& team, const int iatom_mod, const int j_bend, const int jnbor, const int iatom_div) { // utot(j,ma,mb) = 0 for all j,ma,ma @@ -496,7 +496,7 @@ void SNAKokkos::compute_ui(const typename Kokko const int scratch_shift = team_rank * tile_size; // extract and wrap - WignerWrapper ulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper ulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); // load parameters @@ -532,7 +532,7 @@ void SNAKokkos::compute_ui(const typename Kokko const complex ulist_prev = ulist_wrapper.get(ma); // ulist_accum += rootpq * a.conj() * ulist_prev; - real rootpq = rootpqarray(j - ma, j - mb); + real_type rootpq = rootpqarray(j - ma, j - mb); ulist_accum.re += rootpq * (a.re * ulist_prev.re + a.im * ulist_prev.im); ulist_accum.im += rootpq * (a.re * ulist_prev.im - a.im * ulist_prev.re); @@ -572,7 +572,7 @@ void SNAKokkos::compute_ui(const typename Kokko Kokkos::atomic_add(&(ulisttot_im_pack(iatom_mod, jjup + ma, jelem, iatom_div)), ulist_prev.im * sfac); // ulist_accum += rootpq * b * ulist_prev; - real rootpq = rootpqarray(j - ma, mb); + real_type rootpq = rootpqarray(j - ma, mb); ulist_accum.re += rootpq * (b.re * ulist_prev.re - b.im * ulist_prev.im); ulist_accum.im += rootpq * (b.re * ulist_prev.im + b.im * ulist_prev.re); @@ -614,9 +614,9 @@ void SNAKokkos::compute_ui(const typename Kokko divergence. GPU version ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, const int& iatom_div) +void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, const int& iatom_div) { const int j1 = idxz(jjz, 0); @@ -629,7 +629,7 @@ void SNAKokkos::compute_zi(const int& iatom_mod const int na = idxz(jjz, 7); const int nb = idxz(jjz, 8); - const real* cgblock = cglist.data() + idxcg_block(j1, j2, j); + const real_type* cgblock = cglist.data() + idxcg_block(j1, j2, j); int idouble = 0; @@ -688,9 +688,9 @@ void SNAKokkos::compute_zi(const int& iatom_mod divergence. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_bi(const int& iatom_mod, const int& jjb, const int& iatom_div) +void SNAKokkos::compute_bi(const int& iatom_mod, const int& jjb, const int& iatom_div) { // for j1 = 0,...,twojmax // for j2 = 0,twojmax @@ -751,10 +751,10 @@ void SNAKokkos::compute_bi(const int& iatom_mod const auto utot = ulisttot_pack(iatom_mod, jju_index, elem3, iatom_div); const auto zloc = zlist_pack(iatom_mod, jjz_index, idouble, iatom_div); - sumzu += static_cast(0.5) * (utot.re * zloc.re + utot.im * zloc.im); + sumzu += static_cast(0.5) * (utot.re * zloc.re + utot.im * zloc.im); } // end if jeven - sumzu *= static_cast(2.0); + sumzu *= static_cast(2.0); if (bzero_flag) { if (!wselfall_flag) { if (elem1 == elem2 && elem1 == elem3) { @@ -781,12 +781,12 @@ void SNAKokkos::compute_bi(const int& iatom_mod divergence. GPU version. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, - const Kokkos::View &beta_pack) +void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, + const Kokkos::View &beta_pack) { - real betaj; + real_type betaj; const int j1 = idxz(jjz, 0); const int j2 = idxz(jjz, 1); @@ -799,15 +799,15 @@ void SNAKokkos::compute_yi(int iatom_mod, int j const int nb = idxz(jjz, 8); const int jju_half = idxz(jjz, 9); - const real *cgblock = cglist.data() + idxcg_block(j1,j2,j); + const real_type *cgblock = cglist.data() + idxcg_block(j1,j2,j); //int mb = (2 * (mb1min+mb2max) - j1 - j2 + j) / 2; //int ma = (2 * (ma1min+ma2max) - j1 - j2 + j) / 2; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - real ztmp_r = 0.0; - real ztmp_i = 0.0; + real_type ztmp_r = 0.0; + real_type ztmp_i = 0.0; int jju1 = idxu_block[j1] + (j1 + 1) * mb1min; int jju2 = idxu_block[j2] + (j2 + 1) * mb2max; @@ -888,9 +888,9 @@ void SNAKokkos::compute_yi(int iatom_mod, int j and accumulation into dEidRj. GPU only. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_fused_deidrj(const typename Kokkos::TeamPolicy::member_type& team, const int iatom_mod, const int j_bend, const int jnbor, const int iatom_div) +void SNAKokkos::compute_fused_deidrj(const typename Kokkos::TeamPolicy::member_type& team, const int iatom_mod, const int j_bend, const int jnbor, const int iatom_div) { // get shared memory offset // scratch size: 32 atoms * (twojmax+1) cached values, no double buffer @@ -900,8 +900,8 @@ void SNAKokkos::compute_fused_deidrj(const type const int scratch_shift = team_rank * tile_size; // extract, wrap shared memory buffer - WignerWrapper ulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); - WignerWrapper dulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper ulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper dulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); // load parameters const auto a = a_pack(iatom_mod, jnbor, iatom_div); @@ -913,7 +913,7 @@ void SNAKokkos::compute_fused_deidrj(const type const int jelem = element(iatom_mod + vector_length * iatom_div, jnbor); - auto dedr_full_sum = static_cast(0.); + auto dedr_full_sum = static_cast(0.); // we need to "choose" when to bend // this for loop is here for context --- we expose additional @@ -944,7 +944,7 @@ void SNAKokkos::compute_fused_deidrj(const type const complex dulist_prev = dulist_wrapper.get(ma); // ulist_accum += rootpq * a.conj() * ulist_prev; - real rootpq = rootpqarray(j - ma, j - mb); + real_type rootpq = rootpqarray(j - ma, j - mb); ulist_accum.re += rootpq * (a.re * ulist_prev.re + a.im * ulist_prev.im); ulist_accum.im += rootpq * (a.re * ulist_prev.im - a.im * ulist_prev.re); @@ -996,7 +996,7 @@ void SNAKokkos::compute_fused_deidrj(const type const complex dulist_prev = dulist_wrapper.get(ma); // ulist_accum += rootpq * b * ulist_prev; - real rootpq = rootpqarray(j - ma, mb); + real_type rootpq = rootpqarray(j - ma, mb); ulist_accum.re += rootpq * (b.re * ulist_prev.re - b.im * ulist_prev.im); ulist_accum.im += rootpq * (b.re * ulist_prev.im + b.im * ulist_prev.re); @@ -1037,8 +1037,8 @@ void SNAKokkos::compute_fused_deidrj(const type // grab y_local early auto y_local = complex(ylist_pack_re(iatom_mod, jjup + ma, jelem, iatom_div), ylist_pack_im(iatom_mod, jjup+ma, jelem, iatom_div)); if (j % 2 == 1 && 2*(mb-1) == j-1) { // double check me... - if (ma == (mb-1)) { y_local = static_cast(0.5)*y_local; } - else if (ma > (mb-1)) { y_local.re = static_cast(0.); y_local.im = static_cast(0.); } // can probably avoid this outright + if (ma == (mb-1)) { y_local = static_cast(0.5)*y_local; } + else if (ma > (mb-1)) { y_local.re = static_cast(0.); y_local.im = static_cast(0.); } // can probably avoid this outright // else the ma < mb gets "double counted", cancelling the 0.5. } @@ -1053,7 +1053,7 @@ void SNAKokkos::compute_fused_deidrj(const type //} // end reference loop over j_bend // dedr gets zeroed out at the start of each iteration in compute_cayley_klein - Kokkos::atomic_add(&(dedr(iatom_mod + vector_length * iatom_div, jnbor, dir)), static_cast(2.0) * dedr_full_sum); + Kokkos::atomic_add(&(dedr(iatom_mod + vector_length * iatom_div, jnbor, dir)), static_cast(2.0) * dedr_full_sum); } @@ -1068,9 +1068,9 @@ void SNAKokkos::compute_fused_deidrj(const type advantage of the symmetry of the Wigner U matrices. * ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::pre_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, const int& iatom, const int& ielem) +void SNAKokkos::pre_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, const int& iatom, const int& ielem) { for (int jelem = 0; jelem < nelements; jelem++) { for (int j = 0; j <= twojmax; j++) { @@ -1085,7 +1085,7 @@ void SNAKokkos::pre_ui_cpu(const typename Kokko // if m is on the "diagonal", initialize it with the self energy. // Otherwise zero it out - complex init(static_cast(0.),static_cast(0.)); + complex init(static_cast(0.),static_cast(0.)); if (m % (j+2) == 0 && (!chem_flag || ielem == jelem || wselfall_flag)) { init.re = wself; } //need to map iatom to element ulisttot(jjup, jelem, iatom) = init; @@ -1102,11 +1102,11 @@ void SNAKokkos::pre_ui_cpu(const typename Kokko data layout comments. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) +void SNAKokkos::compute_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) { - real rsq, r, x, y, z, z0, theta0; + real_type rsq, r, x, y, z, z0, theta0; // utot(j,ma,mb) = 0 for all j,ma,ma // utot(j,ma,ma) = 1 for all j,ma @@ -1132,9 +1132,9 @@ void SNAKokkos::compute_ui_cpu(const typename K compute Zi by summing over products of Ui, CPU version ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_zi_cpu(const int& iter) +void SNAKokkos::compute_zi_cpu(const int& iter) { const int iatom = iter / idxz_max; const int jjz = iter % idxz_max; @@ -1149,22 +1149,22 @@ void SNAKokkos::compute_zi_cpu(const int& iter) const int na = idxz(jjz, 7); const int nb = idxz(jjz, 8); - const real *cgblock = cglist.data() + idxcg_block(j1,j2,j); + const real_type *cgblock = cglist.data() + idxcg_block(j1,j2,j); int idouble = 0; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - zlist(jjz, idouble, iatom).re = static_cast(0.0); - zlist(jjz, idouble, iatom).im = static_cast(0.0); + zlist(jjz, idouble, iatom).re = static_cast(0.0); + zlist(jjz, idouble, iatom).im = static_cast(0.0); int jju1 = idxu_block[j1] + (j1+1)*mb1min; int jju2 = idxu_block[j2] + (j2+1)*mb2max; int icgb = mb1min*(j2+1) + mb2max; for(int ib = 0; ib < nb; ib++) { - real suma1_r = static_cast(0.0); - real suma1_i = static_cast(0.0); + real_type suma1_r = static_cast(0.0); + real_type suma1_i = static_cast(0.0); int ma1 = ma1min; int ma2 = ma2max; @@ -1201,9 +1201,9 @@ void SNAKokkos::compute_zi_cpu(const int& iter) compute Bi by summing conj(Ui)*Zi, CPU version ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom) +void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom) { // for j1 = 0,...,twojmax // for j2 = 0,twojmax @@ -1229,11 +1229,11 @@ void SNAKokkos::compute_bi_cpu(const typename K int jjz = idxz_block(j1, j2, j); int jju = idxu_block[j]; - real sumzu = static_cast(0.0); - real sumzu_temp = static_cast(0.0); + real_type sumzu = static_cast(0.0); + real_type sumzu_temp = static_cast(0.0); const int bound = (j+2)/2; Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,(j+1)*bound), - [&] (const int mbma, real& sum) { + [&] (const int mbma, real_type& sum) { //for(int mb = 0; 2*mb < j; mb++) //for(int ma = 0; ma <= j; ma++) { const int ma = mbma % (j + 1); @@ -1252,7 +1252,7 @@ void SNAKokkos::compute_bi_cpu(const typename K if (j%2 == 0) { const int mb = j/2; Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team, mb), - [&] (const int ma, real& sum) { + [&] (const int ma, real_type& sum) { //for(int ma = 0; ma < mb; ma++) { const int jju_index = jju+(mb-1)*(j+1)+(j+1)+ma; const int jjz_index = jjz+(mb-1)*(j+1)+(j+1)+ma; @@ -1265,13 +1265,13 @@ void SNAKokkos::compute_bi_cpu(const typename K const int ma = mb; const int jju_index = jju+(mb-1)*(j+1)+(j+1)+ma; const int jjz_index = jjz+(mb-1)*(j+1)+(j+1)+ma; - sumzu += static_cast(0.5)* + sumzu += static_cast(0.5)* (ulisttot_full(jju_index, elem3, iatom).re * zlist(jjz_index, jalloy, iatom).re + ulisttot_full(jju_index, elem3, iatom).im * zlist(jjz_index, jalloy, iatom).im); } // end if jeven Kokkos::single(Kokkos::PerThread(team), [&] () { - sumzu *= static_cast(2.0); + sumzu *= static_cast(2.0); // apply bzero shift @@ -1303,12 +1303,12 @@ void SNAKokkos::compute_bi_cpu(const typename K CPU version ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_yi_cpu(int iter, - const Kokkos::View &beta) +void SNAKokkos::compute_yi_cpu(int iter, + const Kokkos::View &beta) { - real betaj; + real_type betaj; const int iatom = iter / idxz_max; const int jjz = iter % idxz_max; @@ -1323,15 +1323,15 @@ void SNAKokkos::compute_yi_cpu(int iter, const int nb = idxz(jjz, 8); const int jju_half = idxz(jjz, 9); - const real *cgblock = cglist.data() + idxcg_block(j1,j2,j); + const real_type *cgblock = cglist.data() + idxcg_block(j1,j2,j); //int mb = (2 * (mb1min+mb2max) - j1 - j2 + j) / 2; //int ma = (2 * (ma1min+ma2max) - j1 - j2 + j) / 2; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - real ztmp_r = 0.0; - real ztmp_i = 0.0; + real_type ztmp_r = 0.0; + real_type ztmp_i = 0.0; int jju1 = idxu_block[j1] + (j1 + 1) * mb1min; int jju2 = idxu_block[j2] + (j2 + 1) * mb2max; @@ -1339,8 +1339,8 @@ void SNAKokkos::compute_yi_cpu(int iter, for (int ib = 0; ib < nb; ib++) { - real suma1_r = 0.0; - real suma1_i = 0.0; + real_type suma1_r = 0.0; + real_type suma1_i = 0.0; int ma1 = ma1min; int ma2 = ma2max; @@ -1411,19 +1411,19 @@ void SNAKokkos::compute_yi_cpu(int iter, data layout ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_duidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) +void SNAKokkos::compute_duidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) { - real rsq, r, x, y, z, z0, theta0, cs, sn; - real dz0dr; + real_type rsq, r, x, y, z, z0, theta0, cs, sn; + real_type dz0dr; x = rij(iatom,jnbor,0); y = rij(iatom,jnbor,1); z = rij(iatom,jnbor,2); rsq = x * x + y * y + z * z; r = sqrt(rsq); - auto rscale0 = rfac0 * static_cast(MY_PI) / (rcutij(iatom,jnbor) - rmin0); + auto rscale0 = rfac0 * static_cast(MY_PI) / (rcutij(iatom,jnbor) - rmin0); theta0 = (r - rmin0) * rscale0; sincos_wrapper(theta0, &sn, &cs); z0 = r * cs / sn; @@ -1442,16 +1442,16 @@ void SNAKokkos::compute_duidrj_cpu(const typena ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_deidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) +void SNAKokkos::compute_deidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) { - t_scalar3 final_sum; + t_scalar3 final_sum; const int jelem = element(iatom, jnbor); //for(int j = 0; j <= twojmax; j++) { Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,twojmax+1), - [&] (const int& j, t_scalar3& sum_tmp) { + [&] (const int& j, t_scalar3& sum_tmp) { int jju_half = idxu_half_block[j]; int jju_cache = idxu_cache_block[j]; @@ -1509,10 +1509,10 @@ void SNAKokkos::compute_deidrj_cpu(const typena of the symmetry of the Wigner U matrices. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, - const real& r, const real& wj, const real& rcut, int jelem) +void SNAKokkos::add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, + const real_type& r, const real_type& wj, const real_type& rcut, int jelem) { const auto sfac = compute_sfac(r, rcut) * wj; @@ -1539,18 +1539,18 @@ void SNAKokkos::add_uarraytot(const typename Ko information stored between layers via scratch memory on the GPU path ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_uarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, - const real& x, const real& y, const real& z, const real& z0, const real& r) +void SNAKokkos::compute_uarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, + const real_type& x, const real_type& y, const real_type& z, const real_type& z0, const real_type& r) { - real r0inv; - real a_r, b_r, a_i, b_i; - real rootpq; + real_type r0inv; + real_type a_r, b_r, a_i, b_i; + real_type rootpq; // compute Cayley-Klein parameters for unit quaternion - r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); + r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); a_r = r0inv * z0; a_i = -r0inv * z; b_r = r0inv * y; @@ -1630,23 +1630,23 @@ void SNAKokkos::compute_uarray_cpu(const typena Uses same cached data layout of ulist ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_duarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, - const real& x, const real& y, const real& z, - const real& z0, const real& r, const real& dz0dr, - const real& wj, const real& rcut) +void SNAKokkos::compute_duarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, + const real_type& x, const real_type& y, const real_type& z, + const real_type& z0, const real_type& r, const real_type& dz0dr, + const real_type& wj, const real_type& rcut) { - real r0inv; - real a_r, a_i, b_r, b_i; - real da_r[3], da_i[3], db_r[3], db_i[3]; - real dz0[3], dr0inv[3], dr0invdr; - real rootpq; + real_type r0inv; + real_type a_r, a_i, b_r, b_i; + real_type da_r[3], da_i[3], db_r[3], db_i[3]; + real_type dz0[3], dr0inv[3], dr0invdr; + real_type rootpq; - real rinv = 1.0 / r; - real ux = x * rinv; - real uy = y * rinv; - real uz = z * rinv; + real_type rinv = 1.0 / r; + real_type ux = x * rinv; + real_type uy = y * rinv; + real_type uz = z * rinv; r0inv = 1.0 / sqrt(r * r + z0 * z0); a_r = z0 * r0inv; @@ -1761,8 +1761,8 @@ void SNAKokkos::compute_duarray_cpu(const typen }); } - real sfac = compute_sfac(r, rcut); - real dsfac = compute_dsfac(r, rcut); + real_type sfac = compute_sfac(r, rcut); + real_type dsfac = compute_dsfac(r, rcut); sfac *= wj; dsfac *= wj; @@ -1796,9 +1796,9 @@ void SNAKokkos::compute_duarray_cpu(const typen factorial n, wrapper for precomputed table ------------------------------------------------------------------------- */ -template +template inline -double SNAKokkos::factorial(int n) +double SNAKokkos::factorial(int n) { //if (n < 0 || n > nmaxfactorial) { // char str[128]; @@ -1813,8 +1813,8 @@ double SNAKokkos::factorial(int n) factorial n table, size SNA::nmaxfactorial+1 ------------------------------------------------------------------------- */ -template -const double SNAKokkos::nfac_table[] = { +template +const double SNAKokkos::nfac_table[] = { 1, 1, 2, @@ -1989,9 +1989,9 @@ const double SNAKokkos::nfac_table[] = { the function delta given by VMK Eq. 8.2(1) ------------------------------------------------------------------------- */ -template +template inline -double SNAKokkos::deltacg(int j1, int j2, int j) +double SNAKokkos::deltacg(int j1, int j2, int j) { double sfaccg = factorial((j1 + j2 + j) / 2 + 1); return sqrt(factorial((j1 + j2 - j) / 2) * @@ -2004,9 +2004,9 @@ double SNAKokkos::deltacg(int j1, int j2, int j the quasi-binomial formula VMK 8.2.1(3) ------------------------------------------------------------------------- */ -template +template inline -void SNAKokkos::init_clebsch_gordan() +void SNAKokkos::init_clebsch_gordan() { auto h_cglist = Kokkos::create_mirror_view(cglist); @@ -2074,23 +2074,23 @@ void SNAKokkos::init_clebsch_gordan() the p = 0, q = 0 entries are allocated and skipped for convenience. ------------------------------------------------------------------------- */ -template +template inline -void SNAKokkos::init_rootpqarray() +void SNAKokkos::init_rootpqarray() { auto h_rootpqarray = Kokkos::create_mirror_view(rootpqarray); for (int p = 1; p <= twojmax; p++) for (int q = 1; q <= twojmax; q++) - h_rootpqarray(p,q) = static_cast(sqrt(static_cast(p)/q)); + h_rootpqarray(p,q) = static_cast(sqrt(static_cast(p)/q)); Kokkos::deep_copy(rootpqarray,h_rootpqarray); } /* ---------------------------------------------------------------------- */ -template +template inline -int SNAKokkos::compute_ncoeff() +int SNAKokkos::compute_ncoeff() { int ncount; @@ -2111,19 +2111,19 @@ int SNAKokkos::compute_ncoeff() /* ---------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -real SNAKokkos::compute_sfac(real r, real rcut) +real_type SNAKokkos::compute_sfac(real_type r, real_type rcut) { - constexpr real one = static_cast(1.0); - constexpr real zero = static_cast(0.0); - constexpr real onehalf = static_cast(0.5); + constexpr real_type one = static_cast(1.0); + constexpr real_type zero = static_cast(0.0); + constexpr real_type onehalf = static_cast(0.5); if (switch_flag == 0) return one; if (switch_flag == 1) { if(r <= rmin0) return one; else if(r > rcut) return zero; else { - auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); + auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); return onehalf * (cos((r - rmin0) * rcutfac) + one); } } @@ -2132,37 +2132,37 @@ real SNAKokkos::compute_sfac(real r, real rcut) /* ---------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -real SNAKokkos::compute_dsfac(real r, real rcut) +real_type SNAKokkos::compute_dsfac(real_type r, real_type rcut) { - constexpr real zero = static_cast(0.0); - constexpr real onehalf = static_cast(0.5); + constexpr real_type zero = static_cast(0.0); + constexpr real_type onehalf = static_cast(0.5); if (switch_flag == 0) return zero; if (switch_flag == 1) { if(r <= rmin0) return zero; else if(r > rcut) return zero; else { - auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); + auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); return -onehalf * sin((r - rmin0) * rcutfac) * rcutfac; } } return zero; } -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_s_dsfac(const real r, const real rcut, real& sfac, real& dsfac) { - constexpr real one = static_cast(1.0); - constexpr real zero = static_cast(0.0); - constexpr real onehalf = static_cast(0.5); +void SNAKokkos::compute_s_dsfac(const real_type r, const real_type rcut, real_type& sfac, real_type& dsfac) { + constexpr real_type one = static_cast(1.0); + constexpr real_type zero = static_cast(0.0); + constexpr real_type onehalf = static_cast(0.5); if (switch_flag == 0) { sfac = zero; dsfac = zero; } else if (switch_flag == 1) { if (r <= rmin0) { sfac = one; dsfac = zero; } else if (r > rcut) { sfac = zero; dsfac = zero; } else { - const auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); - real sn, cs; + const auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); + real_type sn, cs; sincos_wrapper((r - rmin0) * rcutfac, &sn, &cs); // need to create a wrapper sfac = onehalf * (cs + one); dsfac = -onehalf * sn * rcutfac; @@ -2174,9 +2174,9 @@ void SNAKokkos::compute_s_dsfac(const real r, c /* ---------------------------------------------------------------------- */ // set direction of batched Duidrj -template +template KOKKOS_FORCEINLINE_FUNCTION -void SNAKokkos::set_dir(int dir_) { +void SNAKokkos::set_dir(int dir_) { dir = dir_; } @@ -2184,8 +2184,8 @@ void SNAKokkos::set_dir(int dir_) { memory usage of arrays ------------------------------------------------------------------------- */ -template -double SNAKokkos::memory_usage() +template +double SNAKokkos::memory_usage() { int jdimpq = twojmax + 2; int jdim = twojmax + 1; @@ -2193,48 +2193,48 @@ double SNAKokkos::memory_usage() bytes = 0; - bytes += jdimpq*jdimpq * sizeof(real); // pqarray - bytes += idxcg_max * sizeof(real); // cglist + bytes += jdimpq*jdimpq * sizeof(real_type); // pqarray + bytes += idxcg_max * sizeof(real_type); // cglist #ifdef LMP_KOKKOS_GPU if (!host_flag) { auto natom_pad = (natom+vector_length-1)/vector_length; - bytes += natom_pad * nmax * sizeof(real) * 2; // a_pack - bytes += natom_pad * nmax * sizeof(real) * 2; // b_pack - bytes += natom_pad * nmax * 3 * sizeof(real) * 2; // da_pack - bytes += natom_pad * nmax * 3 * sizeof(real) * 2; // db_pack - bytes += natom_pad * nmax * 4 * sizeof(real); // sfac_pack + bytes += natom_pad * nmax * sizeof(real_type) * 2; // a_pack + bytes += natom_pad * nmax * sizeof(real_type) * 2; // b_pack + bytes += natom_pad * nmax * 3 * sizeof(real_type) * 2; // da_pack + bytes += natom_pad * nmax * 3 * sizeof(real_type) * 2; // db_pack + bytes += natom_pad * nmax * 4 * sizeof(real_type); // sfac_pack - bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ulisttot_re_pack - bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ulisttot_im_pack - bytes += natom_pad * idxu_max * nelements * sizeof(real) * 2; // ulisttot_pack + bytes += natom_pad * idxu_half_max * nelements * sizeof(real_type); // ulisttot_re_pack + bytes += natom_pad * idxu_half_max * nelements * sizeof(real_type); // ulisttot_im_pack + bytes += natom_pad * idxu_max * nelements * sizeof(real_type) * 2; // ulisttot_pack - bytes += natom_pad * idxz_max * ndoubles * sizeof(real) * 2; // zlist_pack - bytes += natom_pad * idxb_max * ntriples * sizeof(real); // blist_pack + bytes += natom_pad * idxz_max * ndoubles * sizeof(real_type) * 2; // zlist_pack + bytes += natom_pad * idxb_max * ntriples * sizeof(real_type); // blist_pack - bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ylist_pack_re - bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ylist_pack_im + bytes += natom_pad * idxu_half_max * nelements * sizeof(real_type); // ylist_pack_re + bytes += natom_pad * idxu_half_max * nelements * sizeof(real_type); // ylist_pack_im } else { #endif - bytes += natom * nmax * idxu_cache_max * sizeof(real) * 2; // ulist - bytes += natom * idxu_half_max * nelements * sizeof(real) * 2; // ulisttot - bytes += natom * idxu_max * nelements * sizeof(real) * 2; // ulisttot_full + bytes += natom * nmax * idxu_cache_max * sizeof(real_type) * 2; // ulist + bytes += natom * idxu_half_max * nelements * sizeof(real_type) * 2; // ulisttot + bytes += natom * idxu_max * nelements * sizeof(real_type) * 2; // ulisttot_full - bytes += natom * idxz_max * ndoubles * sizeof(real) * 2; // zlist - bytes += natom * idxb_max * ntriples * sizeof(real); // blist + bytes += natom * idxz_max * ndoubles * sizeof(real_type) * 2; // zlist + bytes += natom * idxb_max * ntriples * sizeof(real_type); // blist - bytes += natom * idxu_half_max * nelements * sizeof(real) * 2; // ylist + bytes += natom * idxu_half_max * nelements * sizeof(real_type) * 2; // ylist - bytes += natom * nmax * idxu_cache_max * 3 * sizeof(real) * 2; // dulist + bytes += natom * nmax * idxu_cache_max * 3 * sizeof(real_type) * 2; // dulist #ifdef LMP_KOKKOS_GPU } #endif - bytes += natom * nmax * 3 * sizeof(real); // dedr + bytes += natom * nmax * 3 * sizeof(real_type); // dedr bytes += jdim * jdim * jdim * sizeof(int); // idxcg_block bytes += jdim * sizeof(int); // idxu_block @@ -2247,12 +2247,12 @@ double SNAKokkos::memory_usage() bytes += idxz_max * 10 * sizeof(int); // idxz bytes += idxb_max * 3 * sizeof(int); // idxb - bytes += jdim * sizeof(real); // bzero + bytes += jdim * sizeof(real_type); // bzero - bytes += natom * nmax * 3 * sizeof(real); // rij - bytes += natom * nmax * sizeof(real); // inside - bytes += natom * nmax * sizeof(real); // wj - bytes += natom * nmax * sizeof(real); // rcutij + bytes += natom * nmax * 3 * sizeof(real_type); // rij + bytes += natom * nmax * sizeof(real_type); // inside + bytes += natom * nmax * sizeof(real_type); // wj + bytes += natom * nmax * sizeof(real_type); // rcutij return bytes; } From e42845799d045a3b788702f4eee4ee2dfbe048c2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 5 Jan 2021 15:42:35 -0500 Subject: [PATCH 43/51] more consistent formatting for conditionals and loops --- src/KOKKOS/atom_kokkos.h | 12 +-- src/KOKKOS/atom_vec_kokkos.h | 4 +- src/KOKKOS/memory_kokkos.h | 12 +-- src/KOKKOS/nbin_ssa_kokkos.h | 24 ++--- src/KOKKOS/pair_kokkos.h | 38 ++++---- src/KOKKOS/pair_snap_kokkos_impl.h | 4 +- src/KOKKOS/sna_kokkos_impl.h | 103 ++++++++++---------- src/MANYBODY/pair_eam_cd.h | 4 +- src/USER-CGDNA/mf_oxdna.h | 18 ++-- src/USER-DPD/random_external_state.h | 4 +- src/USER-MANIFOLD/manifold.h | 6 +- src/USER-MANIFOLD/manifold_factory.h | 4 +- src/USER-MISC/pair_ilp_graphene_hbn.h | 4 +- src/USER-MISC/pair_kolmogorov_crespi_full.h | 4 +- src/USER-MISC/pair_meam_spline.h | 12 +-- src/USER-MISC/pair_meam_sw_spline.h | 12 +-- src/USER-PTM/ptm_voronoi_cell.h | 6 +- src/math_eigen_impl.h | 60 ++++++------ 18 files changed, 163 insertions(+), 168 deletions(-) diff --git a/src/KOKKOS/atom_kokkos.h b/src/KOKKOS/atom_kokkos.h index 6eebbad661..b554442b37 100644 --- a/src/KOKKOS/atom_kokkos.h +++ b/src/KOKKOS/atom_kokkos.h @@ -100,18 +100,18 @@ struct SortFunctor { dest(i) = source(index(i)); } void operator()(const typename std::enable_if::type& i) { - for(int j=0; j < (int)source.extent(1); j++) + for (int j=0; j < (int)source.extent(1); j++) dest(i,j) = source(index(i),j); } void operator()(const typename std::enable_if::type& i) { - for(int j=0; j < (int)source.extent(1); j++) - for(int k=0; k < (int)source.extent(2); k++) + for (int j=0; j < (int)source.extent(1); j++) + for (int k=0; k < (int)source.extent(2); k++) dest(i,j,k) = source(index(i),j,k); } void operator()(const typename std::enable_if::type& i) { - for(int j=0; j < (int)source.extent(1); j++) - for(int k=0; k < (int)source.extent(2); k++) - for(int l=0; l < (int)source.extent(3); l++) + for (int j=0; j < (int)source.extent(1); j++) + for (int k=0; k < (int)source.extent(2); k++) + for (int l=0; l < (int)source.extent(3); l++) dest(i,j,k,l) = source(index(i),j,k,l); } }; diff --git a/src/KOKKOS/atom_vec_kokkos.h b/src/KOKKOS/atom_vec_kokkos.h index 9fbf172535..f81b7715ad 100644 --- a/src/KOKKOS/atom_vec_kokkos.h +++ b/src/KOKKOS/atom_vec_kokkos.h @@ -178,7 +178,7 @@ class AtomVecKokkos : public AtomVec { } mirror_type tmp_view((typename ViewType::value_type*)buffer, src.d_view.layout()); - if(space == Device) { + if (space == Device) { Kokkos::deep_copy(LMPHostType(),tmp_view,src.h_view), Kokkos::deep_copy(LMPHostType(),src.d_view,tmp_view); src.clear_sync_state(); @@ -191,7 +191,7 @@ class AtomVecKokkos : public AtomVec { #else template void perform_async_copy(ViewType& src, unsigned int space) { - if(space == Device) + if (space == Device) src.template sync(); else src.template sync(); diff --git a/src/KOKKOS/memory_kokkos.h b/src/KOKKOS/memory_kokkos.h index 2f9e0cc375..445ecd87f2 100644 --- a/src/KOKKOS/memory_kokkos.h +++ b/src/KOKKOS/memory_kokkos.h @@ -92,7 +92,7 @@ void destroy_kokkos(TYPE data, typename TYPE::value_type* &array) template TYPE destroy_kokkos(TYPE &data) { - /*if(data.data()!=nullptr) + /*if (data.data()!=nullptr) free(data.data());*/ data = TYPE(); return data; @@ -173,7 +173,7 @@ TYPE create_kokkos(TYPE &data, typename TYPE::value_type **&array, bigint n = 0; for (int i = 0; i < n1; i++) { - if(n2==0) + if (n2==0) array[i] = nullptr; else array[i] = &data.h_view(i,0); @@ -194,7 +194,7 @@ template bigint n = 0; for (int i = 0; i < n1; i++) { - if(n2==0) + if (n2==0) array[i] = nullptr; else array[i] = &h_data(i,0); @@ -218,7 +218,7 @@ TYPE grow_kokkos(TYPE &data, typename TYPE::value_type **&array, array = (typename TYPE::value_type**) srealloc(array,nbytes,name); for (int i = 0; i < n1; i++) - if(n2==0) + if (n2==0) array[i] = nullptr; else array[i] = &data.h_view(i,0); @@ -235,7 +235,7 @@ TYPE create_kokkos(TYPE &data, typename TYPE::value_type **&array, array = (typename TYPE::value_type **) smalloc(nbytes,name); for (int i = 0; i < n1; i++) - if(data.h_view.extent(1)==0) + if (data.h_view.extent(1)==0) array[i] = nullptr; else array[i] = &data.h_view(i,0); @@ -255,7 +255,7 @@ TYPE grow_kokkos(TYPE &data, typename TYPE::value_type **&array, array = (typename TYPE::value_type **) smalloc(nbytes,name); for (int i = 0; i < n1; i++) - if(data.h_view.extent(1)==0) + if (data.h_view.extent(1)==0) array[i] = nullptr; else array[i] = &data.h_view(i,0); diff --git a/src/KOKKOS/nbin_ssa_kokkos.h b/src/KOKKOS/nbin_ssa_kokkos.h index cc98859913..a99e0d448c 100644 --- a/src/KOKKOS/nbin_ssa_kokkos.h +++ b/src/KOKKOS/nbin_ssa_kokkos.h @@ -108,20 +108,20 @@ class NBinSSAKokkos : public NBinStandard { if (y >= subhi_[1]) iy = 1; if (x < sublo_[0]) ix = -1; if (x >= subhi_[0]) ix = 1; - if(iz < 0){ + if (iz < 0){ return -1; - } else if(iz == 0){ - if( iy<0 ) return -1; // bottom left/middle/right - if( (iy==0) && (ix<0) ) return -1; // left atoms - if( (iy==0) && (ix==0) ) return 0; // Locally owned atoms - if( (iy==0) && (ix>0) ) return 2; // Right atoms - if( (iy>0) && (ix==0) ) return 1; // Top-middle atoms - if( (iy>0) && (ix!=0) ) return 3; // Top-right and top-left atoms + } else if (iz == 0){ + if (iy<0) return -1; // bottom left/middle/right + if ((iy==0) && (ix<0) ) return -1; // left atoms + if ((iy==0) && (ix==0)) return 0; // Locally owned atoms + if ((iy==0) && (ix>0) ) return 2; // Right atoms + if ((iy>0) && (ix==0)) return 1; // Top-middle atoms + if ((iy>0) && (ix!=0)) return 3; // Top-right and top-left atoms } else { // iz > 0 - if((ix==0) && (iy==0)) return 4; // Back atoms - if((ix==0) && (iy!=0)) return 5; // Top-back and bottom-back atoms - if((ix!=0) && (iy==0)) return 6; // Left-back and right-back atoms - if((ix!=0) && (iy!=0)) return 7; // Back corner atoms + if ((ix==0) && (iy==0)) return 4; // Back atoms + if ((ix==0) && (iy!=0)) return 5; // Top-back and bottom-back atoms + if ((ix!=0) && (iy==0)) return 6; // Left-back and right-back atoms + if ((ix!=0) && (iy!=0)) return 7; // Back corner atoms } return -2; } diff --git a/src/KOKKOS/pair_kokkos.h b/src/KOKKOS/pair_kokkos.h index cb55dd3141..7dc3e33f74 100644 --- a/src/KOKKOS/pair_kokkos.h +++ b/src/KOKKOS/pair_kokkos.h @@ -144,7 +144,7 @@ struct PairComputeFunctor { const int jtype = c.type(j); const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { const F_FLOAT fpair = factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); @@ -213,13 +213,13 @@ struct PairComputeFunctor { const int jtype = c.type(j); const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { F_FLOAT fpair = F_FLOAT(); - if(rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) + if (rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) fpair+=factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); - if(rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) + if (rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) fpair+=c.template compute_fcoul(rsq,i,j,itype,jtype,factor_coul,qtmp); fxtmp += delx*fpair; @@ -236,11 +236,11 @@ struct PairComputeFunctor { F_FLOAT evdwl = 0.0; F_FLOAT ecoul = 0.0; if (c.eflag) { - if(rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) { evdwl = factor_lj * c.template compute_evdwl(rsq,i,j,itype,jtype); ev.evdwl += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)&&(NEWTON_PAIR||(j(rsq,i,j,itype,jtype,factor_coul,qtmp); ev.ecoul += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)&&(NEWTON_PAIR||(j(rsq,i,j,itype,jtype); @@ -351,13 +351,13 @@ struct PairComputeFunctor { const int jtype = c.type(j); const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { F_FLOAT fpair = F_FLOAT(); - if(rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) + if (rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) fpair+=factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); - if(rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) + if (rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) fpair+=c.template compute_fcoul(rsq,i,j,itype,jtype,factor_coul,qtmp); ftmp.x += delx*fpair; @@ -413,7 +413,7 @@ struct PairComputeFunctor { const int jtype = c.type(j); const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { const F_FLOAT fpair = factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); @@ -510,13 +510,13 @@ struct PairComputeFunctor { const int jtype = c.type(j); const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { F_FLOAT fpair = F_FLOAT(); - if(rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) + if (rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) fpair+=factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); - if(rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) + if (rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) fpair+=c.template compute_fcoul(rsq,i,j,itype,jtype,factor_coul,qtmp); fev_tmp.f[0] += delx*fpair; @@ -526,11 +526,11 @@ struct PairComputeFunctor { F_FLOAT evdwl = 0.0; F_FLOAT ecoul = 0.0; if (c.eflag) { - if(rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) { evdwl = factor_lj * c.template compute_evdwl(rsq,i,j,itype,jtype); fev_tmp.evdwl += 0.5*evdwl; } - if(rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) { ecoul = c.template compute_ecoul(rsq,i,j,itype,jtype,factor_coul,qtmp); fev_tmp.ecoul += 0.5*ecoul; } @@ -722,7 +722,7 @@ int GetTeamSize(FunctorStyle& KOKKOS_GPU_ARG(functor), int KOKKOS_GPU_ARG(inum), else team_size_max = Kokkos::TeamPolicy<>(inum,Kokkos::AUTO).team_size_max(functor,Kokkos::ParallelForTag()); - if(team_size*vector_length > team_size_max) + if (team_size*vector_length > team_size_max) team_size = team_size_max/vector_length; #else team_size = 1; @@ -743,7 +743,7 @@ EV_FLOAT pair_compute_neighlist (PairStyle* fpair, typename std::enable_if<(NEIG int vector_length = 8; int atoms_per_team = 32; - if(fpair->atom->ntypes > MAX_TYPES_STACKPARAMS) { + if (fpair->atom->ntypes > MAX_TYPES_STACKPARAMS) { PairComputeFunctor ff(fpair,list); atoms_per_team = GetTeamSize(ff, list->inum, (fpair->eflag || fpair->vflag), atoms_per_team, vector_length); Kokkos::TeamPolicy > policy(list->inum,atoms_per_team,vector_length); @@ -757,7 +757,7 @@ EV_FLOAT pair_compute_neighlist (PairStyle* fpair, typename std::enable_if<(NEIG else Kokkos::parallel_for(policy,ff); } } else { - if(fpair->atom->ntypes > MAX_TYPES_STACKPARAMS) { + if (fpair->atom->ntypes > MAX_TYPES_STACKPARAMS) { PairComputeFunctor ff(fpair,list); if (fpair->eflag || fpair->vflag) Kokkos::parallel_reduce(list->inum,ff,ev); else Kokkos::parallel_for(list->inum,ff); diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index da99cbd52a..cf4d5851b6 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -1323,7 +1323,7 @@ void PairSNAPKokkos::check_team_size_for(i team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelForTag()); - if(team_size*vector_length > team_size_max) + if (team_size*vector_length > team_size_max) team_size = team_size_max/vector_length; } @@ -1334,7 +1334,7 @@ void PairSNAPKokkos::check_team_size_reduc team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelReduceTag()); - if(team_size*vector_length > team_size_max) + if (team_size*vector_length > team_size_max) team_size = team_size_max/vector_length; } diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index 23c1670bd8..d7aabb22c8 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -67,7 +67,7 @@ SNAKokkos::SNAKokkos(real_type rfac0_in, auto h_bzero = Kokkos::create_mirror_view(bzero); double www = wself*wself*wself; - for(int j = 0; j <= twojmax; j++) + for (int j = 0; j <= twojmax; j++) if (bnorm_flag) h_bzero[j] = www; else @@ -95,9 +95,9 @@ void SNAKokkos::build_indexlist() auto h_idxcg_block = Kokkos::create_mirror_view(idxcg_block); int idxcg_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { h_idxcg_block(j1,j2,j) = idxcg_count; for (int m1 = 0; m1 <= j1; m1++) for (int m2 = 0; m2 <= j2; m2++) @@ -114,10 +114,10 @@ void SNAKokkos::build_indexlist() int idxu_count = 0; - for(int j = 0; j <= twojmax; j++) { + for (int j = 0; j <= twojmax; j++) { h_idxu_block[j] = idxu_count; - for(int mb = 0; mb <= j; mb++) - for(int ma = 0; ma <= j; ma++) + for (int mb = 0; mb <= j; mb++) + for (int ma = 0; ma <= j; ma++) idxu_count++; } idxu_max = idxu_count; @@ -128,10 +128,10 @@ void SNAKokkos::build_indexlist() auto h_idxu_half_block = Kokkos::create_mirror_view(idxu_half_block); int idxu_half_count = 0; - for(int j = 0; j <= twojmax; j++) { + for (int j = 0; j <= twojmax; j++) { h_idxu_half_block[j] = idxu_half_count; - for(int mb = 0; 2*mb <= j; mb++) - for(int ma = 0; ma <= j; ma++) + for (int mb = 0; 2*mb <= j; mb++) + for (int ma = 0; ma <= j; ma++) idxu_half_count++; } idxu_half_max = idxu_half_count; @@ -142,10 +142,10 @@ void SNAKokkos::build_indexlist() auto h_idxu_full_half = Kokkos::create_mirror_view(idxu_full_half); idxu_count = 0; - for(int j = 0; j <= twojmax; j++) { + for (int j = 0; j <= twojmax; j++) { int jju_half = h_idxu_half_block[j]; - for(int mb = 0; mb <= j; mb++) { - for(int ma = 0; ma <= j; ma++) { + for (int mb = 0; mb <= j; mb++) { + for (int ma = 0; ma <= j; ma++) { FullHalfMapper mapper; if (2*mb <= j) { mapper.idxu_half = jju_half + mb * (j + 1) + ma; @@ -169,9 +169,9 @@ void SNAKokkos::build_indexlist() auto h_idxu_cache_block = Kokkos::create_mirror_view(idxu_cache_block); int idxu_cache_count = 0; - for(int j = 0; j <= twojmax; j++) { + for (int j = 0; j <= twojmax; j++) { h_idxu_cache_block[j] = idxu_cache_count; - for(int mb = 0; mb < ((j+3)/2); mb++) + for (int mb = 0; mb < ((j+3)/2); mb++) for (int ma = 0; ma <= j; ma++) idxu_cache_count++; } @@ -181,9 +181,9 @@ void SNAKokkos::build_indexlist() // index list for beta and B int idxb_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) if (j >= j1) idxb_count++; idxb_max = idxb_count; @@ -191,9 +191,9 @@ void SNAKokkos::build_indexlist() auto h_idxb = Kokkos::create_mirror_view(idxb); idxb_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) if (j >= j1) { h_idxb(idxb_count,0) = j1; h_idxb(idxb_count,1) = j2; @@ -208,9 +208,9 @@ void SNAKokkos::build_indexlist() auto h_idxb_block = Kokkos::create_mirror_view(idxb_block); idxb_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { if (j >= j1) { h_idxb_block(j1,j2,j) = idxb_count; idxb_count++; @@ -222,9 +222,9 @@ void SNAKokkos::build_indexlist() int idxz_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) for (int mb = 0; 2*mb <= j; mb++) for (int ma = 0; ma <= j; ma++) idxz_count++; @@ -237,9 +237,9 @@ void SNAKokkos::build_indexlist() auto h_idxz_block = Kokkos::create_mirror_view(idxz_block); idxz_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { h_idxz_block(j1,j2,j) = idxz_count; // find right beta(ii,jjb) entry @@ -286,7 +286,7 @@ template inline void SNAKokkos::grow_rij(int newnatom, int newnmax) { - if(newnatom <= natom && newnmax <= nmax) return; + if (newnatom <= natom && newnmax <= nmax) return; natom = newnatom; nmax = newnmax; @@ -644,7 +644,7 @@ void SNAKokkos::compute_zi(const int& iato #ifdef LMP_KK_DEVICE_COMPILE #pragma unroll #endif - for(int ib = 0; ib < nb; ib++) { + for (int ib = 0; ib < nb; ib++) { int ma1 = ma1min; int ma2 = ma2max; @@ -653,7 +653,7 @@ void SNAKokkos::compute_zi(const int& iato #ifdef LMP_KK_DEVICE_COMPILE #pragma unroll #endif - for(int ia = 0; ia < na; ia++) { + for (int ia = 0; ia < na; ia++) { const auto utot1 = ulisttot_pack(iatom_mod, jju1+ma1, elem1, iatom_div); const auto utot2 = ulisttot_pack(iatom_mod, jju2+ma2, elem2, iatom_div); const auto cgcoeff_a = cgblock[icga]; @@ -717,8 +717,8 @@ void SNAKokkos::compute_bi(const int& iato double sumzu = 0.0; double sumzu_temp = 0.0; - for(int mb = 0; 2*mb < j; mb++) { - for(int ma = 0; ma <= j; ma++) { + for (int mb = 0; 2*mb < j; mb++) { + for (int ma = 0; ma <= j; ma++) { const int jju_index = jju+mb*(j+1)+ma; const int jjz_index = jjz+mb*(j+1)+ma; if (2*mb == j) return; // I think we can remove this? @@ -734,7 +734,7 @@ void SNAKokkos::compute_bi(const int& iato sumzu_temp = 0.; const int mb = j/2; - for(int ma = 0; ma < mb; ma++) { + for (int ma = 0; ma < mb; ma++) { const int jju_index = jju+(mb-1)*(j+1)+(j+1)+ma; const int jjz_index = jjz+(mb-1)*(j+1)+(j+1)+ma; @@ -1161,7 +1161,7 @@ void SNAKokkos::compute_zi_cpu(const int& int jju1 = idxu_block[j1] + (j1+1)*mb1min; int jju2 = idxu_block[j2] + (j2+1)*mb2max; int icgb = mb1min*(j2+1) + mb2max; - for(int ib = 0; ib < nb; ib++) { + for (int ib = 0; ib < nb; ib++) { real_type suma1_r = static_cast(0.0); real_type suma1_i = static_cast(0.0); @@ -1169,7 +1169,7 @@ void SNAKokkos::compute_zi_cpu(const int& int ma1 = ma1min; int ma2 = ma2max; int icga = ma1min * (j2 + 1) + ma2max; - for(int ia = 0; ia < na; ia++) { + for (int ia = 0; ia < na; ia++) { suma1_r += cgblock[icga] * (ulisttot_full(jju1+ma1, elem1, iatom).re * ulisttot_full(jju2+ma2, elem2, iatom).re - ulisttot_full(jju1+ma1, elem1, iatom).im * ulisttot_full(jju2+ma2, elem2, iatom).im); suma1_i += cgblock[icga] * (ulisttot_full(jju1+ma1, elem1, iatom).re * ulisttot_full(jju2+ma2, elem2, iatom).im + @@ -1222,7 +1222,6 @@ void SNAKokkos::compute_bi_cpu(const typen for (int elem3 = 0; elem3 < nelements; elem3++) { Kokkos::parallel_for(Kokkos::TeamThreadRange(team,idxb_max), [&] (const int& jjb) { - //for(int jjb = 0; jjb < idxb_max; jjb++) { const int j1 = idxb(jjb, 0); const int j2 = idxb(jjb, 1); const int j = idxb(jjb, 2); @@ -1234,8 +1233,6 @@ void SNAKokkos::compute_bi_cpu(const typen const int bound = (j+2)/2; Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,(j+1)*bound), [&] (const int mbma, real_type& sum) { - //for(int mb = 0; 2*mb < j; mb++) - //for(int ma = 0; ma <= j; ma++) { const int ma = mbma % (j + 1); const int mb = mbma / (j + 1); const int jju_index = jju + mb * (j + 1) + ma; @@ -1253,7 +1250,6 @@ void SNAKokkos::compute_bi_cpu(const typen const int mb = j/2; Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team, mb), [&] (const int ma, real_type& sum) { - //for(int ma = 0; ma < mb; ma++) { const int jju_index = jju+(mb-1)*(j+1)+(j+1)+ma; const int jjz_index = jjz+(mb-1)*(j+1)+(j+1)+ma; sum += @@ -1449,14 +1445,13 @@ void SNAKokkos::compute_deidrj_cpu(const t t_scalar3 final_sum; const int jelem = element(iatom, jnbor); - //for(int j = 0; j <= twojmax; j++) { Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,twojmax+1), [&] (const int& j, t_scalar3& sum_tmp) { int jju_half = idxu_half_block[j]; int jju_cache = idxu_cache_block[j]; - for(int mb = 0; 2*mb < j; mb++) - for(int ma = 0; ma <= j; ma++) { + for (int mb = 0; 2*mb < j; mb++) + for (int ma = 0; ma <= j; ma++) { sum_tmp.x += dulist(jju_cache,iatom,jnbor,0).re * ylist(jju_half,jelem,iatom).re + dulist(jju_cache,iatom,jnbor,0).im * ylist(jju_half,jelem,iatom).im; sum_tmp.y += dulist(jju_cache,iatom,jnbor,1).re * ylist(jju_half,jelem,iatom).re + @@ -1471,7 +1466,7 @@ void SNAKokkos::compute_deidrj_cpu(const t if (j%2 == 0) { int mb = j/2; - for(int ma = 0; ma < mb; ma++) { + for (int ma = 0; ma < mb; ma++) { sum_tmp.x += dulist(jju_cache,iatom,jnbor,0).re * ylist(jju_half,jelem,iatom).re + dulist(jju_cache,iatom,jnbor,0).im * ylist(jju_half,jelem,iatom).im; sum_tmp.y += dulist(jju_cache,iatom,jnbor,1).re * ylist(jju_half,jelem,iatom).re + @@ -2015,9 +2010,9 @@ void SNAKokkos::init_clebsch_gordan() int ifac; int idxcg_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { for (int m1 = 0; m1 <= j1; m1++) { aa2 = 2 * m1 - j1; @@ -2028,7 +2023,7 @@ void SNAKokkos::init_clebsch_gordan() bb2 = 2 * m2 - j2; m = (aa2 + bb2 + j) / 2; - if(m < 0 || m > j) { + if (m < 0 || m > j) { h_cglist[idxcg_count] = 0.0; idxcg_count++; continue; @@ -2120,8 +2115,8 @@ real_type SNAKokkos::compute_sfac(real_typ constexpr real_type onehalf = static_cast(0.5); if (switch_flag == 0) return one; if (switch_flag == 1) { - if(r <= rmin0) return one; - else if(r > rcut) return zero; + if (r <= rmin0) return one; + else if (r > rcut) return zero; else { auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); return onehalf * (cos((r - rmin0) * rcutfac) + one); @@ -2140,8 +2135,8 @@ real_type SNAKokkos::compute_dsfac(real_ty constexpr real_type onehalf = static_cast(0.5); if (switch_flag == 0) return zero; if (switch_flag == 1) { - if(r <= rmin0) return zero; - else if(r > rcut) return zero; + if (r <= rmin0) return zero; + else if (r > rcut) return zero; else { auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); return -onehalf * sin((r - rmin0) * rcutfac) * rcutfac; diff --git a/src/MANYBODY/pair_eam_cd.h b/src/MANYBODY/pair_eam_cd.h index 8f306d1019..4d938aad10 100644 --- a/src/MANYBODY/pair_eam_cd.h +++ b/src/MANYBODY/pair_eam_cd.h @@ -60,7 +60,7 @@ public: // Evaluates the h(x) polynomial for a given local concentration x. inline double evalH(double x) const { double v = 0.0; - for(int i = nhcoeff-1; i >= 1; i--) { + for (int i = nhcoeff-1; i >= 1; i--) { v = (v + hcoeff[i]) * x; } return v + hcoeff[0]; @@ -69,7 +69,7 @@ public: // Calculates the derivative of the h(x) polynomial. inline double evalHprime(double x) const { double v = 0.0; - for(int i = nhcoeff-1; i >= 2; i--) { + for (int i = nhcoeff-1; i >= 2; i--) { v = (v + (double)i * hcoeff[i]) * x; } return v + hcoeff[1]; diff --git a/src/USER-CGDNA/mf_oxdna.h b/src/USER-CGDNA/mf_oxdna.h index e4ed1bbd03..00df53234d 100644 --- a/src/USER-CGDNA/mf_oxdna.h +++ b/src/USER-CGDNA/mf_oxdna.h @@ -96,13 +96,13 @@ inline double MFOxdna::F2(double r, double k, double cut_0, double cut_lc, double b_lo, double b_hi, double cut_c) { - if(r < cut_lc || r > cut_hc){ + if (r < cut_lc || r > cut_hc){ return 0; } - else if(r < cut_lo){ + else if (r < cut_lo){ return k * b_lo * (cut_lc - r)*(cut_lc-r); } - else if(r < cut_hi){ + else if (r < cut_hi){ return k * 0.5 * ((r - cut_0)*(r-cut_0) - (cut_0 - cut_c)*(cut_0 - cut_c)); } else{ @@ -118,13 +118,13 @@ inline double MFOxdna::DF2(double r, double k, double cut_0, double cut_lc, double cut_hc, double cut_lo, double cut_hi, double b_lo, double b_hi) { - if(r < cut_lc || r > cut_hc){ + if (r < cut_lc || r > cut_hc){ return 0; } - else if(r < cut_lo){ + else if (r < cut_lo){ return 2*k * b_lo * (r - cut_lc); } - else if(r < cut_hi){ + else if (r < cut_hi){ return k * (r - cut_0); } else{ @@ -171,7 +171,7 @@ inline double MFOxdna::F4(double theta, double a, double theta_0, else if (dtheta > dtheta_ast) { return b * (dtheta-dtheta_c)*(dtheta-dtheta_c); } - else if(dtheta > -dtheta_ast) { + else if (dtheta > -dtheta_ast) { return 1 - a * dtheta*dtheta; } else { @@ -235,13 +235,13 @@ inline double MFOxdna::F5(double x, double a, double x_ast, inline double MFOxdna::DF5(double x, double a, double x_ast, double b, double x_c) { - if(x >= 0) { + if (x >= 0) { return 0.0; } else if (x > x_ast) { return -2 * a * x; } - else if(x > x_c) { + else if (x > x_c) { return 2 * b * (x-x_c); } else { diff --git a/src/USER-DPD/random_external_state.h b/src/USER-DPD/random_external_state.h index de017ee8bd..e7d11a5926 100644 --- a/src/USER-DPD/random_external_state.h +++ b/src/USER-DPD/random_external_state.h @@ -141,9 +141,9 @@ namespace random_external_state { // RNGs with k calls to genNextParallelState() LAMMPS_INLINE void es_init(es_RNG_t &serial_state, uint64_t seed) { - if(seed==0) seed = uint64_t(1318319); + if (seed==0) seed = uint64_t(1318319); serial_state = seed; - for(int i = 0; i < 17; i++) es_rand(serial_state); + for (int i = 0; i < 17; i++) es_rand(serial_state); } // Call genNextParallelState() once for each RNG to generate diff --git a/src/USER-MANIFOLD/manifold.h b/src/USER-MANIFOLD/manifold.h index 9adf7055c7..7c3197e161 100644 --- a/src/USER-MANIFOLD/manifold.h +++ b/src/USER-MANIFOLD/manifold.h @@ -77,17 +77,17 @@ namespace user_manifold { // Some utility functions that are templated, so I implement them // here in the header. template< unsigned int size > inline - double infnorm( double *vect ) + double infnorm(double *vect) { double largest = fabs( vect[0] ); - for( unsigned int i = 1; i < size; ++i ){ + for (unsigned int i = 1; i < size; ++i){ double c = fabs( vect[i] ); largest = ( c > largest ) ? c : largest; } return largest; } - inline double dot( double *a, double *b ){ + inline double dot(double *a, double *b){ return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; } diff --git a/src/USER-MANIFOLD/manifold_factory.h b/src/USER-MANIFOLD/manifold_factory.h index 1eac8bf644..cc23874eba 100644 --- a/src/USER-MANIFOLD/manifold_factory.h +++ b/src/USER-MANIFOLD/manifold_factory.h @@ -93,8 +93,8 @@ class manifold; void make_manifold_if( manifold **man_ptr, const char *name, LAMMPS *lmp, int narg, char **arg ) { - if( strcmp( m_type::type(), name ) == 0 ){ - if( *man_ptr == nullptr ){ + if ( strcmp( m_type::type(), name ) == 0 ){ + if ( *man_ptr == nullptr ){ *man_ptr = new m_type(lmp, narg, arg); } } diff --git a/src/USER-MISC/pair_ilp_graphene_hbn.h b/src/USER-MISC/pair_ilp_graphene_hbn.h index 5ca8eb64a7..aadb792cad 100644 --- a/src/USER-MISC/pair_ilp_graphene_hbn.h +++ b/src/USER-MISC/pair_ilp_graphene_hbn.h @@ -82,7 +82,7 @@ class PairILPGrapheneHBN : public Pair { double Tap_coeff[8] = {1.0,0.0,0.0,0.0,-35.0,84.0,-70.0,20.0}; r = r_ij/Rcut; - if(r >= 1.0) {Tap = 0.0;} + if (r >= 1.0) {Tap = 0.0;} else { Tap = Tap_coeff[7] * r + Tap_coeff[6]; Tap = Tap * r + Tap_coeff[5]; @@ -101,7 +101,7 @@ class PairILPGrapheneHBN : public Pair { double Tap_coeff[8] = {1.0,0.0,0.0,0.0,-35.0,84.0,-70.0,20.0}; r = r_ij/Rcut; - if(r >= 1.0) {dTap = 0.0;} + if (r >= 1.0) {dTap = 0.0;} else { dTap = 7.0*Tap_coeff[7] * r + 6.0*Tap_coeff[6]; dTap = dTap * r + 5.0*Tap_coeff[5]; diff --git a/src/USER-MISC/pair_kolmogorov_crespi_full.h b/src/USER-MISC/pair_kolmogorov_crespi_full.h index c579788110..f7d9237be4 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_full.h +++ b/src/USER-MISC/pair_kolmogorov_crespi_full.h @@ -84,7 +84,7 @@ class PairKolmogorovCrespiFull : public Pair { double Tap_coeff[8] = {1.0,0.0,0.0,0.0,-35.0,84.0,-70.0,20.0}; r = r_ij/Rcut; - if(r >= 1.0) {Tap = 0.0;} + if (r >= 1.0) {Tap = 0.0;} else{ Tap = Tap_coeff[7] * r + Tap_coeff[6]; Tap = Tap * r + Tap_coeff[5]; @@ -104,7 +104,7 @@ class PairKolmogorovCrespiFull : public Pair { double Tap_coeff[8] = {1.0,0.0,0.0,0.0,-35.0,84.0,-70.0,20.0}; r = r_ij/Rcut; - if(r >= 1.0) {dTap = 0.0;} + if (r >= 1.0) {dTap = 0.0;} else { dTap = 7.0*Tap_coeff[7] * r + 6.0*Tap_coeff[6]; dTap = dTap * r + 5.0*Tap_coeff[5]; diff --git a/src/USER-MISC/pair_meam_spline.h b/src/USER-MISC/pair_meam_spline.h index 31be826d0d..d1dc5064f5 100644 --- a/src/USER-MISC/pair_meam_spline.h +++ b/src/USER-MISC/pair_meam_spline.h @@ -118,10 +118,10 @@ protected: inline double eval(double x) const { x -= xmin; - if(x <= 0.0) { // Left extrapolation. + if (x <= 0.0) { // Left extrapolation. return Y[0] + deriv0 * x; } - else if(x >= xmax_shifted) { // Right extrapolation. + else if (x >= xmax_shifted) { // Right extrapolation. return Y[N-1] + derivN * (x - xmax_shifted); } else { @@ -131,7 +131,7 @@ protected: int khi = N-1; while(khi - klo > 1) { int k = (khi + klo) / 2; - if(Xs[k] > x) khi = k; + if (Xs[k] > x) khi = k; else klo = k; } double h = Xs[khi] - Xs[klo]; @@ -156,11 +156,11 @@ protected: inline double eval(double x, double& deriv) const { x -= xmin; - if(x <= 0.0) { // Left extrapolation. + if (x <= 0.0) { // Left extrapolation. deriv = deriv0; return Y[0] + deriv0 * x; } - else if(x >= xmax_shifted) { // Right extrapolation. + else if (x >= xmax_shifted) { // Right extrapolation. deriv = derivN; return Y[N-1] + derivN * (x - xmax_shifted); } @@ -171,7 +171,7 @@ protected: int khi = N-1; while(khi - klo > 1) { int k = (khi + klo) / 2; - if(Xs[k] > x) khi = k; + if (Xs[k] > x) khi = k; else klo = k; } double h = Xs[khi] - Xs[klo]; diff --git a/src/USER-MISC/pair_meam_sw_spline.h b/src/USER-MISC/pair_meam_sw_spline.h index 1fd59b34a5..7b40d123ed 100644 --- a/src/USER-MISC/pair_meam_sw_spline.h +++ b/src/USER-MISC/pair_meam_sw_spline.h @@ -106,10 +106,10 @@ protected: inline double eval(double x) const { x -= xmin; - if(x <= 0.0) { // Left extrapolation. + if (x <= 0.0) { // Left extrapolation. return Y[0] + deriv0 * x; } - else if(x >= xmax_shifted) { // Right extrapolation. + else if (x >= xmax_shifted) { // Right extrapolation. return Y[N-1] + derivN * (x - xmax_shifted); } else { @@ -119,7 +119,7 @@ protected: int khi = N-1; while(khi - klo > 1) { int k = (khi + klo) / 2; - if(Xs[k] > x) khi = k; + if (Xs[k] > x) khi = k; else klo = k; } double h = Xs[khi] - Xs[klo]; @@ -144,11 +144,11 @@ protected: inline double eval(double x, double& deriv) const { x -= xmin; - if(x <= 0.0) { // Left extrapolation. + if (x <= 0.0) { // Left extrapolation. deriv = deriv0; return Y[0] + deriv0 * x; } - else if(x >= xmax_shifted) { // Right extrapolation. + else if (x >= xmax_shifted) { // Right extrapolation. deriv = derivN; return Y[N-1] + derivN * (x - xmax_shifted); } @@ -159,7 +159,7 @@ protected: int khi = N-1; while(khi - klo > 1) { int k = (khi + klo) / 2; - if(Xs[k] > x) khi = k; + if (Xs[k] > x) khi = k; else klo = k; } double h = Xs[khi] - Xs[klo]; diff --git a/src/USER-PTM/ptm_voronoi_cell.h b/src/USER-PTM/ptm_voronoi_cell.h index 69e3b5bdc4..138f290c42 100644 --- a/src/USER-PTM/ptm_voronoi_cell.h +++ b/src/USER-PTM/ptm_voronoi_cell.h @@ -328,12 +328,12 @@ class voronoicell_neighbor : public voronoicell_base { inline void n_allocate(int i,int m) {mne[i]=new int[m*i];} inline void n_add_memory_vertices(int i) { int **pp=new int*[i]; - for(int j=0;j l2_norm(const std::vector& vec) { template inline void scalar_mul(T1 a, std::vector& vec) { int n = vec.size(); - for(int i = 0;i < n;i++) + for (int i = 0;i < n;i++) vec[i] *= a; } @@ -465,7 +465,7 @@ inline void normalize(std::vector& vec) { template inline real_t l1_norm(const std::vector& vec) { real_t norm = real_t(); // Zero initialization - for(const T& element : vec) + for (const T& element : vec) norm += std::abs(element); return norm; } @@ -746,7 +746,7 @@ template int Jacobi:: MaxEntryRow(Scalar const *const *M, int i) const { int j_max = i+1; - for(int j = i+2; j < n; j++) + for (int j = i+2; j < n; j++) if (std::abs(M[i][j]) > std::abs(M[i][j_max])) j_max = j; return j_max; @@ -963,9 +963,9 @@ run(real_t& eigvalue, std::vector& eigvec) const pev = std::numeric_limits>::max(); int itern = this->max_iteration; - for(int k = 1;k <= this->max_iteration;k++) { + for (int k = 1;k <= this->max_iteration;k++) { // vk = (A + offset*E)uk, here E is the identity matrix - for(int i = 0;i < n;i++) { + for (int i = 0;i < n;i++) { vk[i] = uk[i]*this->eigenvalue_offset; } this->mv_mul(uk, vk); @@ -984,7 +984,7 @@ run(real_t& eigvalue, std::vector& eigvec) const alpha.push_back(alphak); - for(int i = 0;i < n; i++) { + for (int i = 0;i < n; i++) { uk[i] = vk[i] - betak*u[k-1][i] - alphak*u[k][i]; } @@ -993,14 +993,14 @@ run(real_t& eigvalue, std::vector& eigvec) const betak = l2_norm(uk); beta.push_back(betak); - if(this->find_maximum) { + if (this->find_maximum) { ev = find_maximum_eigenvalue(alpha, beta); } else { ev = find_minimum_eigenvalue(alpha, beta); } const real_t zero_threshold = minimum_effective_decimal>()*1e-1; - if(betak < zero_threshold) { + if (betak < zero_threshold) { u.push_back(uk); // This element will never be accessed, // but this "push" guarantees u to always have one more element than @@ -1012,7 +1012,7 @@ run(real_t& eigvalue, std::vector& eigvec) const normalize(uk); u.push_back(uk); - if(abs(ev-pev) < std::min(abs(ev), abs(pev))*this->eps) { + if (abs(ev-pev) < std::min(abs(ev), abs(pev))*this->eps) { itern = k; break; } else { @@ -1030,18 +1030,18 @@ run(real_t& eigvalue, std::vector& eigvec) const beta[m-1] = 0.0; - if(eigvec.size() < n) { + if (eigvec.size() < n) { eigvec.resize(n); } - for(int i = 0;i < n;i++) { + for (int i = 0;i < n;i++) { eigvec[i] = cv[m-1]*u[m-1][i]; } - for(int k = m-2;k >= 1;k--) { + for (int k = m-2;k >= 1;k--) { cv[k] = ((ev - alpha[k+1])*cv[k+1] - beta[k+1]*cv[k+2])/beta[k]; - for(int i = 0;i < n;i++) { + for (int i = 0;i < n;i++) { eigvec[i] += cv[k]*u[k][i]; } } @@ -1062,9 +1062,9 @@ schmidt_orth(std::vector& uorth, const std::vector>& u) int n = uorth.size(); - for(int k = 0;k < u.size();k++) { + for (int k = 0;k < u.size();k++) { T innprod = inner_prod(uorth, u[k]); - for(int i = 0;i < n;i++) + for (int i = 0;i < n;i++) uorth[i] -= innprod * u[k][i]; } } @@ -1083,16 +1083,16 @@ find_minimum_eigenvalue(const std::vector>& alpha, real_t mid; int nmid; // Number of eigenvalues smaller than the "mid" - while(upper-lower > std::min(abs(lower), abs(upper))*eps) { + while (upper-lower > std::min(abs(lower), abs(upper))*eps) { mid = (lower+upper)/2.0; nmid = num_of_eigs_smaller_than(mid, alpha, beta); - if(nmid >= 1) { + if (nmid >= 1) { upper = mid; } else { lower = mid; } - if(mid == pmid) { + if (mid == pmid) { break; // This avoids an infinite loop due to zero matrix } pmid = mid; @@ -1119,17 +1119,17 @@ find_maximum_eigenvalue(const std::vector>& alpha, // triangular matrix, which equals the rank of it - while(upper-lower > std::min(abs(lower), abs(upper))*eps) { + while (upper-lower > std::min(abs(lower), abs(upper))*eps) { mid = (lower+upper)/2.0; nmid = num_of_eigs_smaller_than(mid, alpha, beta); - if(nmid < m) { + if (nmid < m) { lower = mid; } else { upper = mid; } - if(mid == pmid) { + if (mid == pmid) { break; // This avoids an infinite loop due to zero matrix } pmid = mid; @@ -1173,12 +1173,12 @@ num_of_eigs_smaller_than(real_t c, int count = 0; int m = alpha.size(); - for(int i = 1;i < m;i++){ + for (int i = 1;i < m;i++){ q_i = alpha[i] - c - beta[i-1]*beta[i-1]/q_i; - if(q_i < 0){ + if (q_i < 0){ count++; } - if(q_i == 0){ + if (q_i == 0){ q_i = minimum_effective_decimal>(); } } @@ -1271,7 +1271,7 @@ init(std::vector& v) std::uniform_real_distribution rand((T)(-1.0), (T)(1.0)); int n = v.size(); - for(int i = 0;i < n;i++) { + for (int i = 0;i < n;i++) { v[i] = rand(mt); } @@ -1288,7 +1288,7 @@ init(std::vector>& v) std::uniform_real_distribution rand((T)(-1.0), (T)(1.0)); int n = v.size(); - for(int i = 0;i < n;i++) { + for (int i = 0;i < n;i++) { v[i] = std::complex(rand(mt), rand(mt)); } @@ -1319,14 +1319,14 @@ PrincipalEigen(ConstMatrix matrix, { //assert(n > 0); auto matmul = [&](const std::vector& in, std::vector& out) { - for(int i = 0; i < n; i++) { - for(int j = 0; j < n; j++) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { out[i] += matrix[i][j]*in[j]; } } }; auto init_vec = [&](std::vector& vec) { - for(int i = 0; i < n; i++) + for (int i = 0; i < n; i++) vec[i] = 0.0; vec[0] = 1.0; }; From cf841e99c4eada564dc18adfd3c634201b09b694 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 5 Jan 2021 15:45:52 -0500 Subject: [PATCH 44/51] change '){' tp ') {' --- src/KOKKOS/atom_kokkos.h | 8 ++++---- src/KOKKOS/compute_temp_kokkos.h | 2 +- src/KOKKOS/fix_langevin_kokkos.h | 4 ++-- src/KOKKOS/fix_qeq_reax_kokkos.h | 4 ++-- src/KOKKOS/fix_setforce_kokkos.h | 2 +- src/KOKKOS/fix_shardlow_kokkos.h | 4 ++-- src/KOKKOS/kokkos_type.h | 4 ++-- src/KOKKOS/min_linesearch_kokkos.h | 2 +- src/KOKKOS/nbin_ssa_kokkos.h | 4 ++-- src/KOKKOS/pair_buck_coul_cut_kokkos.h | 4 ++-- src/KOKKOS/pair_buck_coul_long_kokkos.h | 4 ++-- src/KOKKOS/pair_buck_kokkos.h | 4 ++-- src/KOKKOS/pair_coul_cut_kokkos.h | 4 ++-- src/KOKKOS/pair_coul_debye_kokkos.h | 4 ++-- src/KOKKOS/pair_coul_long_kokkos.h | 4 ++-- src/KOKKOS/pair_dpd_fdt_energy_kokkos.h | 4 ++-- src/KOKKOS/pair_kokkos.h | 8 ++++---- src/KOKKOS/pair_lj_class2_kokkos.h | 4 ++-- src/KOKKOS/pair_lj_cut_kokkos.h | 4 ++-- src/KOKKOS/pair_lj_expand_kokkos.h | 4 ++-- .../pair_lj_gromacs_coul_gromacs_kokkos.h | 4 ++-- src/KOKKOS/pair_lj_gromacs_kokkos.h | 4 ++-- src/KOKKOS/pair_lj_sdk_kokkos.h | 4 ++-- src/KOKKOS/pair_morse_kokkos.h | 4 ++-- src/KOKKOS/pair_reaxc_kokkos.h | 20 +++++++++---------- src/KOKKOS/pair_snap_kokkos_impl.h | 4 ++-- src/KOKKOS/pair_tersoff_kokkos.h | 4 ++-- src/KOKKOS/pair_tersoff_mod_kokkos.h | 4 ++-- src/KOKKOS/pair_tersoff_zbl_kokkos.h | 4 ++-- src/KOKKOS/pair_yukawa_kokkos.h | 4 ++-- src/KOKKOS/sna_kokkos_impl.h | 2 +- src/KSPACE/pair_coul_msm.h | 2 +- src/USER-CGDNA/mf_oxdna.h | 12 +++++------ src/USER-EFF/pair_eff_inline.h | 2 +- src/USER-MANIFOLD/fix_nve_manifold_rattle.h | 2 +- src/USER-MANIFOLD/manifold.h | 16 +++++++-------- src/USER-MANIFOLD/manifold_cylinder.h | 10 +++++----- src/USER-MANIFOLD/manifold_cylinder_dent.h | 10 +++++----- src/USER-MANIFOLD/manifold_dumbbell.h | 10 +++++----- src/USER-MANIFOLD/manifold_ellipsoid.h | 10 +++++----- src/USER-MANIFOLD/manifold_factory.h | 6 +++--- src/USER-MANIFOLD/manifold_gaussian_bump.h | 4 ++-- src/USER-MANIFOLD/manifold_plane.h | 10 +++++----- src/USER-MANIFOLD/manifold_plane_wiggle.h | 10 +++++----- src/USER-MANIFOLD/manifold_sphere.h | 12 +++++------ src/USER-MANIFOLD/manifold_spine.h | 14 ++++++------- src/USER-MANIFOLD/manifold_supersphere.h | 12 +++++------ src/USER-MANIFOLD/manifold_thylakoid.h | 8 ++++---- src/USER-MANIFOLD/manifold_thylakoid_shared.h | 4 ++-- src/USER-MANIFOLD/manifold_torus.h | 10 +++++----- src/USER-UEF/compute_pressure_uef.h | 2 +- src/USER-UEF/compute_temp_uef.h | 2 +- src/USER-UEF/dump_cfg_uef.h | 2 +- src/USER-UEF/fix_nvt_uef.h | 2 +- 54 files changed, 156 insertions(+), 156 deletions(-) diff --git a/src/KOKKOS/atom_kokkos.h b/src/KOKKOS/atom_kokkos.h index b554442b37..c875817a70 100644 --- a/src/KOKKOS/atom_kokkos.h +++ b/src/KOKKOS/atom_kokkos.h @@ -83,16 +83,16 @@ struct SortFunctor { ViewType source; Kokkos::View dest; IndexView index; - SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind){ + SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind) { dest = Kokkos::View("",src.extent(0)); } - SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind){ + SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind) { dest = Kokkos::View("",src.extent(0),src.extent(1)); } - SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind){ + SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind) { dest = Kokkos::View("",src.extent(0),src.extent(1),src.extent(2)); } - SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind){ + SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind) { dest = Kokkos::View("",src.extent(0),src.extent(1),src.extent(2),src.extent(3)); } KOKKOS_INLINE_FUNCTION diff --git a/src/KOKKOS/compute_temp_kokkos.h b/src/KOKKOS/compute_temp_kokkos.h index 7f116f7120..555881869d 100644 --- a/src/KOKKOS/compute_temp_kokkos.h +++ b/src/KOKKOS/compute_temp_kokkos.h @@ -34,7 +34,7 @@ namespace LAMMPS_NS { t0 = t1 = t2 = t3 = t4 = t5 = 0.0; } KOKKOS_INLINE_FUNCTION - s_CTEMP& operator+=(const s_CTEMP &rhs){ + s_CTEMP& operator+=(const s_CTEMP &rhs) { t0 += rhs.t0; t1 += rhs.t1; t2 += rhs.t2; diff --git a/src/KOKKOS/fix_langevin_kokkos.h b/src/KOKKOS/fix_langevin_kokkos.h index 034e4eaa8f..411adc2219 100644 --- a/src/KOKKOS/fix_langevin_kokkos.h +++ b/src/KOKKOS/fix_langevin_kokkos.h @@ -36,7 +36,7 @@ namespace LAMMPS_NS { fx = fy = fz = 0.0; } KOKKOS_INLINE_FUNCTION - s_FSUM& operator+=(const s_FSUM &rhs){ + s_FSUM& operator+=(const s_FSUM &rhs) { fx += rhs.fx; fy += rhs.fy; fz += rhs.fz; @@ -175,7 +175,7 @@ namespace LAMMPS_NS { FixLangevinKokkosPostForceFunctor(FixLangevinKokkos* c_ptr): c(*c_ptr) {} - ~FixLangevinKokkosPostForceFunctor(){c.cleanup_copy();} + ~FixLangevinKokkosPostForceFunctor() {c.cleanup_copy();} KOKKOS_INLINE_FUNCTION void operator()(const int i) const { diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.h b/src/KOKKOS/fix_qeq_reax_kokkos.h index cc9bff3652..bbfeb00266 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.h +++ b/src/KOKKOS/fix_qeq_reax_kokkos.h @@ -147,9 +147,9 @@ class FixQEqReaxKokkos : public FixQEqReax, public KokkosBase { struct params_qeq{ KOKKOS_INLINE_FUNCTION - params_qeq(){chi=0;eta=0;gamma=0;}; + params_qeq() {chi=0;eta=0;gamma=0;}; KOKKOS_INLINE_FUNCTION - params_qeq(int /*i*/){chi=0;eta=0;gamma=0;}; + params_qeq(int /*i*/) {chi=0;eta=0;gamma=0;}; F_FLOAT chi, eta, gamma; }; diff --git a/src/KOKKOS/fix_setforce_kokkos.h b/src/KOKKOS/fix_setforce_kokkos.h index ecbfd71e36..709d31279b 100644 --- a/src/KOKKOS/fix_setforce_kokkos.h +++ b/src/KOKKOS/fix_setforce_kokkos.h @@ -34,7 +34,7 @@ struct s_double_3 { d0 = d1 = d2 = 0.0; } KOKKOS_INLINE_FUNCTION - s_double_3& operator+=(const s_double_3 &rhs){ + s_double_3& operator+=(const s_double_3 &rhs) { d0 += rhs.d0; d1 += rhs.d1; d2 += rhs.d2; diff --git a/src/KOKKOS/fix_shardlow_kokkos.h b/src/KOKKOS/fix_shardlow_kokkos.h index d5541ac5b7..1d11de0fcb 100644 --- a/src/KOKKOS/fix_shardlow_kokkos.h +++ b/src/KOKKOS/fix_shardlow_kokkos.h @@ -62,9 +62,9 @@ class FixShardlowKokkos : public FixShardlow { struct params_ssa { KOKKOS_INLINE_FUNCTION - params_ssa(){cutinv=FLT_MAX;halfsigma=0;kappa=0;alpha=0;}; + params_ssa() {cutinv=FLT_MAX;halfsigma=0;kappa=0;alpha=0;}; KOKKOS_INLINE_FUNCTION - params_ssa(int /*i*/){cutinv=FLT_MAX;halfsigma=0;kappa=0;alpha=0;}; + params_ssa(int /*i*/) {cutinv=FLT_MAX;halfsigma=0;kappa=0;alpha=0;}; F_FLOAT cutinv,halfsigma,kappa,alpha; }; diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index fbe9799bee..7050af80fc 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -1068,9 +1068,9 @@ void memset_kokkos (ViewType &view) { struct params_lj_coul { KOKKOS_INLINE_FUNCTION - params_lj_coul(){cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; + params_lj_coul() {cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; KOKKOS_INLINE_FUNCTION - params_lj_coul(int /*i*/){cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; + params_lj_coul(int /*i*/) {cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; F_FLOAT cut_ljsq,cut_coulsq,lj1,lj2,lj3,lj4,offset; }; diff --git a/src/KOKKOS/min_linesearch_kokkos.h b/src/KOKKOS/min_linesearch_kokkos.h index 43336335b1..5439a93932 100644 --- a/src/KOKKOS/min_linesearch_kokkos.h +++ b/src/KOKKOS/min_linesearch_kokkos.h @@ -25,7 +25,7 @@ namespace LAMMPS_NS { d0 = d1 = 0.0; } KOKKOS_INLINE_FUNCTION - s_double2& operator+=(const s_double2 &rhs){ + s_double2& operator+=(const s_double2 &rhs) { d0 += rhs.d0; d1 += rhs.d1; return *this; diff --git a/src/KOKKOS/nbin_ssa_kokkos.h b/src/KOKKOS/nbin_ssa_kokkos.h index a99e0d448c..c9a389bed4 100644 --- a/src/KOKKOS/nbin_ssa_kokkos.h +++ b/src/KOKKOS/nbin_ssa_kokkos.h @@ -108,9 +108,9 @@ class NBinSSAKokkos : public NBinStandard { if (y >= subhi_[1]) iy = 1; if (x < sublo_[0]) ix = -1; if (x >= subhi_[0]) ix = 1; - if (iz < 0){ + if (iz < 0) { return -1; - } else if (iz == 0){ + } else if (iz == 0) { if (iy<0) return -1; // bottom left/middle/right if ((iy==0) && (ix<0) ) return -1; // left atoms if ((iy==0) && (ix==0)) return 0; // Locally owned atoms diff --git a/src/KOKKOS/pair_buck_coul_cut_kokkos.h b/src/KOKKOS/pair_buck_coul_cut_kokkos.h index ca843df2d4..683cb37310 100644 --- a/src/KOKKOS/pair_buck_coul_cut_kokkos.h +++ b/src/KOKKOS/pair_buck_coul_cut_kokkos.h @@ -46,9 +46,9 @@ class PairBuckCoulCutKokkos : public PairBuckCoulCut { struct params_buck_coul{ KOKKOS_INLINE_FUNCTION - params_buck_coul(){cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; + params_buck_coul() {cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; KOKKOS_INLINE_FUNCTION - params_buck_coul(int /*i*/){cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; + params_buck_coul(int /*i*/) {cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; F_FLOAT cut_ljsq,cut_coulsq,a,c,rhoinv,buck1,buck2,offset; }; diff --git a/src/KOKKOS/pair_buck_coul_long_kokkos.h b/src/KOKKOS/pair_buck_coul_long_kokkos.h index 1cb407776c..c383a64081 100644 --- a/src/KOKKOS/pair_buck_coul_long_kokkos.h +++ b/src/KOKKOS/pair_buck_coul_long_kokkos.h @@ -47,9 +47,9 @@ class PairBuckCoulLongKokkos : public PairBuckCoulLong { struct params_buck_coul{ KOKKOS_INLINE_FUNCTION - params_buck_coul(){cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; + params_buck_coul() {cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; KOKKOS_INLINE_FUNCTION - params_buck_coul(int /*i*/){cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; + params_buck_coul(int /*i*/) {cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; F_FLOAT cut_ljsq,cut_coulsq,a,c,rhoinv,buck1,buck2,offset; }; diff --git a/src/KOKKOS/pair_buck_kokkos.h b/src/KOKKOS/pair_buck_kokkos.h index ed23bf6a5b..8bd8fc9ffe 100644 --- a/src/KOKKOS/pair_buck_kokkos.h +++ b/src/KOKKOS/pair_buck_kokkos.h @@ -45,9 +45,9 @@ class PairBuckKokkos : public PairBuck { struct params_buck{ KOKKOS_INLINE_FUNCTION - params_buck(){cutsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; + params_buck() {cutsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; KOKKOS_INLINE_FUNCTION - params_buck(int /*i*/){cutsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; + params_buck(int /*i*/) {cutsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; F_FLOAT cutsq,a,c,rhoinv,buck1,buck2,offset; }; diff --git a/src/KOKKOS/pair_coul_cut_kokkos.h b/src/KOKKOS/pair_coul_cut_kokkos.h index d525422d2f..6fb5334cb4 100644 --- a/src/KOKKOS/pair_coul_cut_kokkos.h +++ b/src/KOKKOS/pair_coul_cut_kokkos.h @@ -46,9 +46,9 @@ class PairCoulCutKokkos : public PairCoulCut { struct params_coul{ KOKKOS_INLINE_FUNCTION - params_coul(){cutsq=0,scale=0;}; + params_coul() {cutsq=0,scale=0;}; KOKKOS_INLINE_FUNCTION - params_coul(int /*i*/){cutsq=0,scale=0;}; + params_coul(int /*i*/) {cutsq=0,scale=0;}; F_FLOAT cutsq, scale; }; diff --git a/src/KOKKOS/pair_coul_debye_kokkos.h b/src/KOKKOS/pair_coul_debye_kokkos.h index 900613aaa0..b5dc2eaed4 100644 --- a/src/KOKKOS/pair_coul_debye_kokkos.h +++ b/src/KOKKOS/pair_coul_debye_kokkos.h @@ -46,9 +46,9 @@ class PairCoulDebyeKokkos : public PairCoulDebye { struct params_coul{ KOKKOS_INLINE_FUNCTION - params_coul(){cutsq=0,scale=0;}; + params_coul() {cutsq=0,scale=0;}; KOKKOS_INLINE_FUNCTION - params_coul(int /*i*/){cutsq=0,scale=0;}; + params_coul(int /*i*/) {cutsq=0,scale=0;}; F_FLOAT cutsq, scale; }; diff --git a/src/KOKKOS/pair_coul_long_kokkos.h b/src/KOKKOS/pair_coul_long_kokkos.h index 590ab191a4..11847bc25c 100644 --- a/src/KOKKOS/pair_coul_long_kokkos.h +++ b/src/KOKKOS/pair_coul_long_kokkos.h @@ -47,9 +47,9 @@ class PairCoulLongKokkos : public PairCoulLong { struct params_coul{ KOKKOS_INLINE_FUNCTION - params_coul(){cut_coulsq=0;}; + params_coul() {cut_coulsq=0;}; KOKKOS_INLINE_FUNCTION - params_coul(int /*i*/){cut_coulsq=0;}; + params_coul(int /*i*/) {cut_coulsq=0;}; F_FLOAT cut_coulsq; }; diff --git a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.h b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.h index b6cf65976d..250a318568 100644 --- a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.h +++ b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.h @@ -88,9 +88,9 @@ class PairDPDfdtEnergyKokkos : public PairDPDfdtEnergy { struct params_dpd { KOKKOS_INLINE_FUNCTION - params_dpd(){cut=0;a0=0;sigma=0;kappa=0;alpha=0;}; + params_dpd() {cut=0;a0=0;sigma=0;kappa=0;alpha=0;}; KOKKOS_INLINE_FUNCTION - params_dpd(int /*i*/){cut=0;a0=0;sigma=0;kappa=0;alpha=0;}; + params_dpd(int /*i*/) {cut=0;a0=0;sigma=0;kappa=0;alpha=0;}; F_FLOAT cut,a0,sigma,kappa,alpha; }; diff --git a/src/KOKKOS/pair_kokkos.h b/src/KOKKOS/pair_kokkos.h index 7dc3e33f74..a3b31f54cc 100644 --- a/src/KOKKOS/pair_kokkos.h +++ b/src/KOKKOS/pair_kokkos.h @@ -305,7 +305,7 @@ struct PairComputeFunctor { },fsum); - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { f(i,0) += fsum.x; f(i,1) += fsum.y; f(i,2) += fsum.z; @@ -366,7 +366,7 @@ struct PairComputeFunctor { } },fsum); - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { f(i,0) += fsum.x; f(i,1) += fsum.y; f(i,2) += fsum.z; @@ -437,7 +437,7 @@ struct PairComputeFunctor { } },fev); - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { f(i,0) += fev.f[0]; f(i,1) += fev.f[1]; f(i,2) += fev.f[2]; @@ -546,7 +546,7 @@ struct PairComputeFunctor { } },fev); - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { f(i,0) += fev.f[0]; f(i,1) += fev.f[1]; f(i,2) += fev.f[2]; diff --git a/src/KOKKOS/pair_lj_class2_kokkos.h b/src/KOKKOS/pair_lj_class2_kokkos.h index 8c40599f95..4be6c40667 100644 --- a/src/KOKKOS/pair_lj_class2_kokkos.h +++ b/src/KOKKOS/pair_lj_class2_kokkos.h @@ -46,9 +46,9 @@ class PairLJClass2Kokkos : public PairLJClass2 { struct params_lj{ KOKKOS_INLINE_FUNCTION - params_lj(){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; + params_lj() {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; KOKKOS_INLINE_FUNCTION - params_lj(int /*i*/){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; + params_lj(int /*i*/) {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; F_FLOAT cutsq,lj1,lj2,lj3,lj4,offset; }; diff --git a/src/KOKKOS/pair_lj_cut_kokkos.h b/src/KOKKOS/pair_lj_cut_kokkos.h index 1bb0421b4a..557a28b698 100644 --- a/src/KOKKOS/pair_lj_cut_kokkos.h +++ b/src/KOKKOS/pair_lj_cut_kokkos.h @@ -46,9 +46,9 @@ class PairLJCutKokkos : public PairLJCut { struct params_lj{ KOKKOS_INLINE_FUNCTION - params_lj(){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; + params_lj() {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; KOKKOS_INLINE_FUNCTION - params_lj(int /*i*/){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; + params_lj(int /*i*/) {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; F_FLOAT cutsq,lj1,lj2,lj3,lj4,offset; }; diff --git a/src/KOKKOS/pair_lj_expand_kokkos.h b/src/KOKKOS/pair_lj_expand_kokkos.h index d6a860690a..ef288dcfe3 100644 --- a/src/KOKKOS/pair_lj_expand_kokkos.h +++ b/src/KOKKOS/pair_lj_expand_kokkos.h @@ -46,9 +46,9 @@ class PairLJExpandKokkos : public PairLJExpand { struct params_lj{ KOKKOS_INLINE_FUNCTION - params_lj(){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;shift=0;}; + params_lj() {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;shift=0;}; KOKKOS_INLINE_FUNCTION - params_lj(int /*i*/){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;shift=0;}; + params_lj(int /*i*/) {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;shift=0;}; F_FLOAT cutsq,lj1,lj2,lj3,lj4,offset,shift; }; diff --git a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.h b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.h index fd4511c519..88dbf28699 100644 --- a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.h +++ b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.h @@ -47,9 +47,9 @@ class PairLJGromacsCoulGromacsKokkos : public PairLJGromacsCoulGromacs { struct params_lj_coul_gromacs{ KOKKOS_INLINE_FUNCTION - params_lj_coul_gromacs(){cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; + params_lj_coul_gromacs() {cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; KOKKOS_INLINE_FUNCTION - params_lj_coul_gromacs(int /*i*/){cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; + params_lj_coul_gromacs(int /*i*/) {cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; F_FLOAT cut_ljsq,cut_coulsq,lj1,lj2,lj3,lj4,offset,ljsw1,ljsw2,ljsw3,ljsw4,ljsw5; }; diff --git a/src/KOKKOS/pair_lj_gromacs_kokkos.h b/src/KOKKOS/pair_lj_gromacs_kokkos.h index 956c5df47d..47804ffe0a 100644 --- a/src/KOKKOS/pair_lj_gromacs_kokkos.h +++ b/src/KOKKOS/pair_lj_gromacs_kokkos.h @@ -46,9 +46,9 @@ class PairLJGromacsKokkos : public PairLJGromacs { struct params_lj{ KOKKOS_INLINE_FUNCTION - params_lj(){cut_inner_sq=0;cut_inner=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; + params_lj() {cut_inner_sq=0;cut_inner=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; KOKKOS_INLINE_FUNCTION - params_lj(int /*i*/){cut_inner_sq=0;cut_inner=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; + params_lj(int /*i*/) {cut_inner_sq=0;cut_inner=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; F_FLOAT cut_inner_sq,cut_inner,lj1,lj2,lj3,lj4,offset,ljsw1,ljsw2,ljsw3,ljsw4,ljsw5; }; diff --git a/src/KOKKOS/pair_lj_sdk_kokkos.h b/src/KOKKOS/pair_lj_sdk_kokkos.h index 0a183051ba..470bda1f9f 100644 --- a/src/KOKKOS/pair_lj_sdk_kokkos.h +++ b/src/KOKKOS/pair_lj_sdk_kokkos.h @@ -46,9 +46,9 @@ class PairLJSDKKokkos : public PairLJSDK { struct params_lj{ KOKKOS_INLINE_FUNCTION - params_lj(){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;lj_type=0;}; + params_lj() {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;lj_type=0;}; KOKKOS_INLINE_FUNCTION - params_lj(int /*i*/){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;lj_type=0;}; + params_lj(int /*i*/) {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;lj_type=0;}; F_FLOAT cutsq,lj1,lj2,lj3,lj4,offset; int lj_type; }; diff --git a/src/KOKKOS/pair_morse_kokkos.h b/src/KOKKOS/pair_morse_kokkos.h index 41de06a560..d747cc9e1e 100644 --- a/src/KOKKOS/pair_morse_kokkos.h +++ b/src/KOKKOS/pair_morse_kokkos.h @@ -45,9 +45,9 @@ class PairMorseKokkos : public PairMorse { struct params_morse{ KOKKOS_INLINE_FUNCTION - params_morse(){cutsq=0,d0=0;alpha=0;r0=0;offset=0;} + params_morse() {cutsq=0,d0=0;alpha=0;r0=0;offset=0;} KOKKOS_INLINE_FUNCTION - params_morse(int /*i*/){cutsq=0,d0=0;alpha=0;r0=0;offset=0;} + params_morse(int /*i*/) {cutsq=0,d0=0;alpha=0;r0=0;offset=0;} F_FLOAT cutsq,d0,alpha,r0,offset; }; diff --git a/src/KOKKOS/pair_reaxc_kokkos.h b/src/KOKKOS/pair_reaxc_kokkos.h index 3e5c07cc4d..d54f275d6f 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.h +++ b/src/KOKKOS/pair_reaxc_kokkos.h @@ -249,10 +249,10 @@ class PairReaxCKokkos : public PairReaxC { struct params_sing{ KOKKOS_INLINE_FUNCTION - params_sing(){mass=0;chi=0;eta=0;r_s=0;r_pi=0;r_pi2=0;valency=0;valency_val=0;valency_e=0;valency_boc=0;nlp_opt=0; + params_sing() {mass=0;chi=0;eta=0;r_s=0;r_pi=0;r_pi2=0;valency=0;valency_val=0;valency_e=0;valency_boc=0;nlp_opt=0; p_lp2=0;p_ovun2=0;p_ovun5=0;p_val3=0;p_val5=0;p_hbond=0;}; KOKKOS_INLINE_FUNCTION - params_sing(int /*i*/){mass=0;chi=0;eta=0;r_s=0;r_pi=0;r_pi2=0;valency=0;valency_val=0;valency_e=0;valency_boc=0;nlp_opt=0; + params_sing(int /*i*/) {mass=0;chi=0;eta=0;r_s=0;r_pi=0;r_pi2=0;valency=0;valency_val=0;valency_e=0;valency_boc=0;nlp_opt=0; p_lp2=0;p_ovun2=0;p_ovun5=0;p_val3=0;p_val5=0;p_hbond=0;}; F_FLOAT mass,chi,eta,r_s,r_pi,r_pi2,valency,valency_val,valency_e,valency_boc,nlp_opt, p_lp2,p_ovun2,p_ovun5, p_val3, p_val5, p_hbond; @@ -260,12 +260,12 @@ class PairReaxCKokkos : public PairReaxC { struct params_twbp{ KOKKOS_INLINE_FUNCTION - params_twbp(){gamma=0;gamma_w=0;alpha=0;r_vdw=0;epsilon=0;acore=0;ecore=0;rcore=0;lgre=0;lgcij=0; + params_twbp() {gamma=0;gamma_w=0;alpha=0;r_vdw=0;epsilon=0;acore=0;ecore=0;rcore=0;lgre=0;lgcij=0; r_s=0;r_pi=0;r_pi2=0;p_bo1=0;p_bo2=0;p_bo3=0;p_bo4=0;p_bo5=0;p_bo6=0;ovc=0;v13cor=0; p_boc3=0;p_boc4=0;p_boc5=0;p_be1=0,p_be2=0,De_s=0,De_p=0;De_pp=0; p_ovun1=0;}; KOKKOS_INLINE_FUNCTION - params_twbp(int /*i*/){gamma=0;gamma_w=0;alpha=0;r_vdw=0;epsilon=0;acore=0;ecore=0;rcore=0;lgre=0;lgcij=0; + params_twbp(int /*i*/) {gamma=0;gamma_w=0;alpha=0;r_vdw=0;epsilon=0;acore=0;ecore=0;rcore=0;lgre=0;lgcij=0; r_s=0;r_pi=0;r_pi2=0;p_bo1=0;p_bo2=0;p_bo3=0;p_bo4=0;p_bo5=0;p_bo6=0;ovc=0;v13cor=0; p_boc3=0;p_boc4=0;p_boc5=0;p_be1=0,p_be2=0,De_s=0,De_p=0;De_pp=0; p_ovun1=0;}; @@ -277,25 +277,25 @@ class PairReaxCKokkos : public PairReaxC { struct params_thbp{ KOKKOS_INLINE_FUNCTION - params_thbp(){cnt=0;theta_00=0;p_val1=0;p_val2=0;p_val4=0;p_val7=0;p_pen1=0;p_coa1=0;}; + params_thbp() {cnt=0;theta_00=0;p_val1=0;p_val2=0;p_val4=0;p_val7=0;p_pen1=0;p_coa1=0;}; KOKKOS_INLINE_FUNCTION - params_thbp(int /*i*/){cnt=0;theta_00=0;p_val1=0;p_val2=0;p_val4=0;p_val7=0;p_pen1=0;p_coa1=0;}; + params_thbp(int /*i*/) {cnt=0;theta_00=0;p_val1=0;p_val2=0;p_val4=0;p_val7=0;p_pen1=0;p_coa1=0;}; F_FLOAT cnt, theta_00, p_val1, p_val2, p_val4, p_val7, p_pen1, p_coa1; }; struct params_fbp{ KOKKOS_INLINE_FUNCTION - params_fbp(){p_tor1=0;p_cot1=0;V1=0;V2=0;V3=0;}; + params_fbp() {p_tor1=0;p_cot1=0;V1=0;V2=0;V3=0;}; KOKKOS_INLINE_FUNCTION - params_fbp(int /*i*/){p_tor1=0;p_cot1=0;V1=0;V2=0;V3=0;}; + params_fbp(int /*i*/) {p_tor1=0;p_cot1=0;V1=0;V2=0;V3=0;}; F_FLOAT p_tor1, p_cot1, V1, V2, V3; }; struct params_hbp{ KOKKOS_INLINE_FUNCTION - params_hbp(){p_hb1=0;p_hb2=0;p_hb3=0;r0_hb=0;}; + params_hbp() {p_hb1=0;p_hb2=0;p_hb3=0;r0_hb=0;}; KOKKOS_INLINE_FUNCTION - params_hbp(int /*i*/){p_hb1=0;p_hb2=0;p_hb3=0;r0_hb=0;}; + params_hbp(int /*i*/) {p_hb1=0;p_hb2=0;p_hb3=0;r0_hb=0;}; F_FLOAT p_hb1, p_hb2, p_hb3, r0_hb; }; diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index cf4d5851b6..359ac652ef 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -949,7 +949,7 @@ void PairSNAPKokkos::operator() (TagPairSN int ninside = 0; Kokkos::parallel_reduce(Kokkos::TeamThreadRange(team,num_neighs), [&] (const int jj, int& count) { - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { T_INT j = d_neighbors(i,jj); const F_FLOAT dx = x(j,0) - xtmp; const F_FLOAT dy = x(j,1) - ytmp; @@ -1166,7 +1166,7 @@ void PairSNAPKokkos::operator() (TagPairSN fij[1] = my_sna.dedr(ii,jj,1); fij[2] = my_sna.dedr(ii,jj,2); - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { a_f(i,0) += fij[0]; a_f(i,1) += fij[1]; a_f(i,2) += fij[2]; diff --git a/src/KOKKOS/pair_tersoff_kokkos.h b/src/KOKKOS/pair_tersoff_kokkos.h index 9bae8df91f..dbc6dc7901 100644 --- a/src/KOKKOS/pair_tersoff_kokkos.h +++ b/src/KOKKOS/pair_tersoff_kokkos.h @@ -153,10 +153,10 @@ class PairTersoffKokkos : public PairTersoff { struct params_ters{ KOKKOS_INLINE_FUNCTION - params_ters(){powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; + params_ters() {powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; bigr=0;bigd=0;lam1=0;biga=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;}; KOKKOS_INLINE_FUNCTION - params_ters(int /*i*/){powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; + params_ters(int /*i*/) {powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; bigr=0;bigd=0;lam1=0;biga=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;}; F_FLOAT powerm, gamma, lam3, c, d, h, powern, beta, lam2, bigb, bigr, bigd, lam1, biga, cutsq, c1, c2, c3, c4; diff --git a/src/KOKKOS/pair_tersoff_mod_kokkos.h b/src/KOKKOS/pair_tersoff_mod_kokkos.h index 4d541c0446..f6a03e1908 100644 --- a/src/KOKKOS/pair_tersoff_mod_kokkos.h +++ b/src/KOKKOS/pair_tersoff_mod_kokkos.h @@ -153,10 +153,10 @@ class PairTersoffMODKokkos : public PairTersoffMOD { struct params_ters{ KOKKOS_INLINE_FUNCTION - params_ters(){powerm=0;lam3=0;h=0;powern=0;beta=0;lam2=0;bigb=0;bigr=0;bigd=0; + params_ters() {powerm=0;lam3=0;h=0;powern=0;beta=0;lam2=0;bigb=0;bigr=0;bigd=0; lam1=0;biga=0;powern_del=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;c5=0;ca1=0;ca4=0;}; KOKKOS_INLINE_FUNCTION - params_ters(int /*i*/){powerm=0;lam3=0;h=0;powern=0;beta=0;lam2=0;bigb=0;bigr=0;bigd=0; + params_ters(int /*i*/) {powerm=0;lam3=0;h=0;powern=0;beta=0;lam2=0;bigb=0;bigr=0;bigd=0; lam1=0;biga=0;powern_del=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;c5=0;ca1=0;ca4=0;}; F_FLOAT powerm, lam3, h, powern, beta, lam2, bigb, bigr, bigd, lam1, biga, powern_del, cutsq, c1, c2, c3, c4, c5, ca1, ca4; diff --git a/src/KOKKOS/pair_tersoff_zbl_kokkos.h b/src/KOKKOS/pair_tersoff_zbl_kokkos.h index fccbca7f46..f82a69cc29 100644 --- a/src/KOKKOS/pair_tersoff_zbl_kokkos.h +++ b/src/KOKKOS/pair_tersoff_zbl_kokkos.h @@ -152,10 +152,10 @@ class PairTersoffZBLKokkos : public PairTersoffZBL { struct params_ters{ KOKKOS_INLINE_FUNCTION - params_ters(){powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; + params_ters() {powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; bigr=0;bigd=0;lam1=0;biga=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;Z_i=0;Z_j=0;ZBLcut=0;ZBLexpscale=0;}; KOKKOS_INLINE_FUNCTION - params_ters(int /*i*/){powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; + params_ters(int /*i*/) {powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; bigr=0;bigd=0;lam1=0;biga=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;Z_i=0;Z_j=0;ZBLcut=0;ZBLexpscale=0;}; F_FLOAT powerm, gamma, lam3, c, d, h, powern, beta, lam2, bigb, bigr, bigd, lam1, biga, cutsq, c1, c2, c3, c4, Z_i, Z_j, ZBLcut, ZBLexpscale; diff --git a/src/KOKKOS/pair_yukawa_kokkos.h b/src/KOKKOS/pair_yukawa_kokkos.h index 5e2a1e53e8..a78f9d5f7c 100644 --- a/src/KOKKOS/pair_yukawa_kokkos.h +++ b/src/KOKKOS/pair_yukawa_kokkos.h @@ -45,9 +45,9 @@ class PairYukawaKokkos : public PairYukawa { struct params_yukawa { KOKKOS_INLINE_FUNCTION - params_yukawa(){ cutsq=0, a = 0; offset = 0; } + params_yukawa() { cutsq=0, a = 0; offset = 0; } KOKKOS_INLINE_FUNCTION - params_yukawa(int /*i*/){ cutsq=0, a = 0; offset = 0; } + params_yukawa(int /*i*/) { cutsq=0, a = 0; offset = 0; } F_FLOAT cutsq, a, offset; }; diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index d7aabb22c8..f20c677d1d 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -1271,7 +1271,7 @@ void SNAKokkos::compute_bi_cpu(const typen // apply bzero shift - if (bzero_flag){ + if (bzero_flag) { if (!wselfall_flag) { if (elem1 == elem2 && elem1 == elem3) { sumzu -= bzero[j]; diff --git a/src/KSPACE/pair_coul_msm.h b/src/KSPACE/pair_coul_msm.h index e4b4bc4750..ed7b6864fd 100644 --- a/src/KSPACE/pair_coul_msm.h +++ b/src/KSPACE/pair_coul_msm.h @@ -27,7 +27,7 @@ namespace LAMMPS_NS { class PairCoulMSM : public PairCoulLong { public: PairCoulMSM(class LAMMPS *); - virtual ~PairCoulMSM(){}; + virtual ~PairCoulMSM() {}; virtual void compute(int, int); virtual double single(int, int, int, int, double, double, double, double &); virtual void *extract(const char *, int &); diff --git a/src/USER-CGDNA/mf_oxdna.h b/src/USER-CGDNA/mf_oxdna.h index 00df53234d..3c4e714f6b 100644 --- a/src/USER-CGDNA/mf_oxdna.h +++ b/src/USER-CGDNA/mf_oxdna.h @@ -96,13 +96,13 @@ inline double MFOxdna::F2(double r, double k, double cut_0, double cut_lc, double b_lo, double b_hi, double cut_c) { - if (r < cut_lc || r > cut_hc){ + if (r < cut_lc || r > cut_hc) { return 0; } - else if (r < cut_lo){ + else if (r < cut_lo) { return k * b_lo * (cut_lc - r)*(cut_lc-r); } - else if (r < cut_hi){ + else if (r < cut_hi) { return k * 0.5 * ((r - cut_0)*(r-cut_0) - (cut_0 - cut_c)*(cut_0 - cut_c)); } else{ @@ -118,13 +118,13 @@ inline double MFOxdna::DF2(double r, double k, double cut_0, double cut_lc, double cut_hc, double cut_lo, double cut_hi, double b_lo, double b_hi) { - if (r < cut_lc || r > cut_hc){ + if (r < cut_lc || r > cut_hc) { return 0; } - else if (r < cut_lo){ + else if (r < cut_lo) { return 2*k * b_lo * (r - cut_lc); } - else if (r < cut_hi){ + else if (r < cut_hi) { return k * (r - cut_0); } else{ diff --git a/src/USER-EFF/pair_eff_inline.h b/src/USER-EFF/pair_eff_inline.h index c93a3803f9..f30a122265 100644 --- a/src/USER-EFF/pair_eff_inline.h +++ b/src/USER-EFF/pair_eff_inline.h @@ -543,7 +543,7 @@ inline void SmallRForce(double dx, double dy, double dz, { /* Handles case where rc is small to avoid division by zero */ - if (rc > 0.000001){ + if (rc > 0.000001) { force /= rc; *fx = force * dx; *fy = force * dy; *fz = force * dz; } else { diff --git a/src/USER-MANIFOLD/fix_nve_manifold_rattle.h b/src/USER-MANIFOLD/fix_nve_manifold_rattle.h index 7ed1f75fa8..9ec2b3c78c 100644 --- a/src/USER-MANIFOLD/fix_nve_manifold_rattle.h +++ b/src/USER-MANIFOLD/fix_nve_manifold_rattle.h @@ -74,7 +74,7 @@ namespace user_manifold { class manifold; } virtual void reset_dt(); virtual void end_of_step(); virtual int dof(int); - virtual void setup(int){} // Not needed for fixNVE but is for fixNVT + virtual void setup(int) {} // Not needed for fixNVE but is for fixNVT virtual double memory_usage(); protected: diff --git a/src/USER-MANIFOLD/manifold.h b/src/USER-MANIFOLD/manifold.h index 7c3197e161..be9f2c9f65 100644 --- a/src/USER-MANIFOLD/manifold.h +++ b/src/USER-MANIFOLD/manifold.h @@ -46,8 +46,8 @@ namespace user_manifold { // Abstract base class. class manifold : protected Pointers { public: - manifold(class LAMMPS* lmp) : Pointers(lmp), params(nullptr){ } - virtual ~manifold(){ delete[] params; } + manifold(class LAMMPS* lmp) : Pointers(lmp), params(nullptr) { } + virtual ~manifold() { delete[] params; } virtual double g( const double * ) = 0; virtual void n( const double *, double * ) = 0; @@ -61,13 +61,13 @@ namespace user_manifold { virtual const char *id() = 0; - virtual void set_atom_id( tagint /*a_id*/ ){} + virtual void set_atom_id( tagint /*a_id*/ ) {} virtual int nparams() = 0; - // double *get_params(){ return params; }; + // double *get_params() { return params; }; // Overload if any initialization depends on params: - virtual void post_param_init(){} - virtual void checkup(){} // Some diagnostics... + virtual void post_param_init() {} + virtual void checkup() {} // Some diagnostics... double *params; }; @@ -80,14 +80,14 @@ namespace user_manifold { double infnorm(double *vect) { double largest = fabs( vect[0] ); - for (unsigned int i = 1; i < size; ++i){ + for (unsigned int i = 1; i < size; ++i) { double c = fabs( vect[i] ); largest = ( c > largest ) ? c : largest; } return largest; } - inline double dot(double *a, double *b){ + inline double dot(double *a, double *b) { return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; } diff --git a/src/USER-MANIFOLD/manifold_cylinder.h b/src/USER-MANIFOLD/manifold_cylinder.h index f8cddadf66..78a1725e5e 100644 --- a/src/USER-MANIFOLD/manifold_cylinder.h +++ b/src/USER-MANIFOLD/manifold_cylinder.h @@ -14,13 +14,13 @@ namespace user_manifold { public: enum { NPARAMS = 1 }; // Number of parameters. manifold_cylinder( LAMMPS *lmp, int, char ** ); - virtual ~manifold_cylinder(){} + virtual ~manifold_cylinder() {} virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char *type(){ return "cylinder"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char *type() { return "cylinder"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_cylinder_dent.h b/src/USER-MANIFOLD/manifold_cylinder_dent.h index 33167d670b..04c23d959d 100644 --- a/src/USER-MANIFOLD/manifold_cylinder_dent.h +++ b/src/USER-MANIFOLD/manifold_cylinder_dent.h @@ -12,13 +12,13 @@ namespace user_manifold { public: manifold_cylinder_dent( LAMMPS *lmp, int, char ** ); enum { NPARAMS = 3 }; // Number of parameters. - virtual ~manifold_cylinder_dent(){} + virtual ~manifold_cylinder_dent() {} virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char *type(){ return "cylinder/dent"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char *type() { return "cylinder/dent"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_dumbbell.h b/src/USER-MANIFOLD/manifold_dumbbell.h index fea718b487..cb2a1f0d0e 100644 --- a/src/USER-MANIFOLD/manifold_dumbbell.h +++ b/src/USER-MANIFOLD/manifold_dumbbell.h @@ -14,15 +14,15 @@ namespace user_manifold { public: enum { NPARAMS = 4 }; // Number of parameters. manifold_dumbbell( LAMMPS *lmp, int, char ** ); - virtual ~manifold_dumbbell(){} + virtual ~manifold_dumbbell() {} virtual double g ( const double *x ); virtual void n ( const double *x, double *nn ); - static const char* type(){ return "dumbbell"; } - virtual const char *id(){ return type(); } + static const char* type() { return "dumbbell"; } + virtual const char *id() { return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_ellipsoid.h b/src/USER-MANIFOLD/manifold_ellipsoid.h index e23dbec72a..373bdc8e91 100644 --- a/src/USER-MANIFOLD/manifold_ellipsoid.h +++ b/src/USER-MANIFOLD/manifold_ellipsoid.h @@ -12,14 +12,14 @@ namespace user_manifold { public: enum { NPARAMS = 3 }; manifold_ellipsoid( LAMMPS *lmp, int, char ** ); - virtual ~manifold_ellipsoid(){} + virtual ~manifold_ellipsoid() {} virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char* type(){ return "ellipsoid"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char* type() { return "ellipsoid"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_factory.h b/src/USER-MANIFOLD/manifold_factory.h index cc23874eba..c6533855ad 100644 --- a/src/USER-MANIFOLD/manifold_factory.h +++ b/src/USER-MANIFOLD/manifold_factory.h @@ -68,7 +68,7 @@ struct LAMMPS { }; struct Pointers { - Pointers(LAMMPS *) : error( &e ){} + Pointers(LAMMPS *) : error( &e ) {} Error e; Error *error; }; @@ -93,8 +93,8 @@ class manifold; void make_manifold_if( manifold **man_ptr, const char *name, LAMMPS *lmp, int narg, char **arg ) { - if ( strcmp( m_type::type(), name ) == 0 ){ - if ( *man_ptr == nullptr ){ + if ( strcmp( m_type::type(), name ) == 0 ) { + if ( *man_ptr == nullptr ) { *man_ptr = new m_type(lmp, narg, arg); } } diff --git a/src/USER-MANIFOLD/manifold_gaussian_bump.h b/src/USER-MANIFOLD/manifold_gaussian_bump.h index 4fef84e3a5..d65979416b 100644 --- a/src/USER-MANIFOLD/manifold_gaussian_bump.h +++ b/src/USER-MANIFOLD/manifold_gaussian_bump.h @@ -59,10 +59,10 @@ namespace user_manifold { // Variant of g that computes n at the same time. virtual double g_and_n( const double *x, double *nn ); - static const char* type(){ return "gaussian_bump"; } + static const char* type() { return "gaussian_bump"; } virtual const char *id() { return type(); } - virtual int nparams(){ return NPARAMS; } + virtual int nparams() { return NPARAMS; } virtual void post_param_init(); private: // Some private constants: diff --git a/src/USER-MANIFOLD/manifold_plane.h b/src/USER-MANIFOLD/manifold_plane.h index 738c632b17..2fa7d6829e 100644 --- a/src/USER-MANIFOLD/manifold_plane.h +++ b/src/USER-MANIFOLD/manifold_plane.h @@ -14,13 +14,13 @@ namespace user_manifold { public: enum { NPARAMS = 6 }; // Number of parameters. manifold_plane( LAMMPS *lmp, int, char ** ); - virtual ~manifold_plane(){} + virtual ~manifold_plane() {} virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char *type(){ return "plane"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char *type() { return "plane"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_plane_wiggle.h b/src/USER-MANIFOLD/manifold_plane_wiggle.h index fe84713d7d..c1408d8900 100644 --- a/src/USER-MANIFOLD/manifold_plane_wiggle.h +++ b/src/USER-MANIFOLD/manifold_plane_wiggle.h @@ -13,13 +13,13 @@ namespace user_manifold { public: enum { NPARAMS = 2 }; // Number of parameters. manifold_plane_wiggle( LAMMPS *lmp, int, char ** ); - virtual ~manifold_plane_wiggle(){} + virtual ~manifold_plane_wiggle() {} virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char *type(){ return "plane/wiggle"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char *type() { return "plane/wiggle"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_sphere.h b/src/USER-MANIFOLD/manifold_sphere.h index d9cd46c9c3..a0f7f48c5f 100644 --- a/src/USER-MANIFOLD/manifold_sphere.h +++ b/src/USER-MANIFOLD/manifold_sphere.h @@ -12,9 +12,9 @@ namespace user_manifold { class manifold_sphere : public manifold { public: enum { NPARAMS = 1 }; - manifold_sphere( LAMMPS *lmp, int, char ** ) : manifold(lmp){} + manifold_sphere( LAMMPS *lmp, int, char ** ) : manifold(lmp) {} - virtual ~manifold_sphere(){} + virtual ~manifold_sphere() {} virtual double g( const double *x ) { double R = params[0]; @@ -46,10 +46,10 @@ namespace user_manifold { h[0][0] = h[1][1] = h[2][2] = 2.0; } - static const char* type(){ return "sphere"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char* type() { return "sphere"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_spine.h b/src/USER-MANIFOLD/manifold_spine.h index ba5e82a6bb..09b61b8300 100644 --- a/src/USER-MANIFOLD/manifold_spine.h +++ b/src/USER-MANIFOLD/manifold_spine.h @@ -13,16 +13,16 @@ namespace user_manifold { public: enum { NPARAMS = 5 }; // Number of parameters. manifold_spine( LAMMPS *lmp, int, char ** ); - virtual ~manifold_spine(){} + virtual ~manifold_spine() {} virtual double g ( const double *x ); virtual void n ( const double *x, double *nn ); virtual double g_and_n( const double *x, double *nn ); - static const char* type(){ return "spine"; } - virtual const char *id(){ return type(); } + static const char* type() { return "spine"; } + virtual const char *id() { return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } protected: int power; }; @@ -31,8 +31,8 @@ namespace user_manifold { public: manifold_spine_two( LAMMPS *lmp, int, char **); - static const char* type(){ return "spine/two"; } - virtual const char *id(){ return type(); } + static const char* type() { return "spine/two"; } + virtual const char *id() { return type(); } }; } diff --git a/src/USER-MANIFOLD/manifold_supersphere.h b/src/USER-MANIFOLD/manifold_supersphere.h index 1d9c62d7a2..031ec71932 100644 --- a/src/USER-MANIFOLD/manifold_supersphere.h +++ b/src/USER-MANIFOLD/manifold_supersphere.h @@ -12,9 +12,9 @@ namespace user_manifold { class manifold_supersphere : public manifold { public: enum { NPARAMS = 2 }; - manifold_supersphere( LAMMPS *lmp, int, char ** ) : manifold(lmp){} + manifold_supersphere( LAMMPS *lmp, int, char ** ) : manifold(lmp) {} - virtual ~manifold_supersphere(){} + virtual ~manifold_supersphere() {} double my_sign( double a ) { @@ -46,10 +46,10 @@ namespace user_manifold { nn[2] = q * my_sign(x[2])*pow(zz,q-1); } - static const char* type(){ return "supersphere"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char* type() { return "supersphere"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_thylakoid.h b/src/USER-MANIFOLD/manifold_thylakoid.h index d3ffa67765..8044d13813 100644 --- a/src/USER-MANIFOLD/manifold_thylakoid.h +++ b/src/USER-MANIFOLD/manifold_thylakoid.h @@ -18,10 +18,10 @@ namespace user_manifold { virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char* type(){ return "thylakoid"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char* type() { return "thylakoid"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } virtual void post_param_init(); diff --git a/src/USER-MANIFOLD/manifold_thylakoid_shared.h b/src/USER-MANIFOLD/manifold_thylakoid_shared.h index 756f392bbb..1af32cc206 100644 --- a/src/USER-MANIFOLD/manifold_thylakoid_shared.h +++ b/src/USER-MANIFOLD/manifold_thylakoid_shared.h @@ -21,7 +21,7 @@ namespace user_manifold { thyla_part( int type, double *args, double xlo, double ylo, double zlo, double xhi, double yhi, double zhi ); - thyla_part() : type(-1), x0(-1337), y0(-1337), z0(-1337){} + thyla_part() : type(-1), x0(-1337), y0(-1337), z0(-1337) {} ~thyla_part(); double g( const double *x ); @@ -43,7 +43,7 @@ namespace user_manifold { struct thyla_part_geom { - thyla_part_geom() : pt(3), lo(3), hi(3){} + thyla_part_geom() : pt(3), lo(3), hi(3) {} std::vector pt, lo, hi; // Function for mirroring thyla_geoms: diff --git a/src/USER-MANIFOLD/manifold_torus.h b/src/USER-MANIFOLD/manifold_torus.h index 0c3bd6e2eb..d7fbc7958b 100644 --- a/src/USER-MANIFOLD/manifold_torus.h +++ b/src/USER-MANIFOLD/manifold_torus.h @@ -13,14 +13,14 @@ namespace user_manifold { public: enum {NPARAMS=2}; manifold_torus( LAMMPS *, int, char ** ); - ~manifold_torus(){} + ~manifold_torus() {} virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char *type(){ return "torus"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char *type() { return "torus"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-UEF/compute_pressure_uef.h b/src/USER-UEF/compute_pressure_uef.h index d3a4d3195c..f5ce642a0e 100644 --- a/src/USER-UEF/compute_pressure_uef.h +++ b/src/USER-UEF/compute_pressure_uef.h @@ -29,7 +29,7 @@ namespace LAMMPS_NS { class ComputePressureUef : public ComputePressure { public: ComputePressureUef(class LAMMPS *, int, char **); - virtual ~ComputePressureUef(){} + virtual ~ComputePressureUef() {} virtual void init(); virtual void compute_vector(); virtual double compute_scalar(); diff --git a/src/USER-UEF/compute_temp_uef.h b/src/USER-UEF/compute_temp_uef.h index 460e2b18c0..837e9c1c3e 100644 --- a/src/USER-UEF/compute_temp_uef.h +++ b/src/USER-UEF/compute_temp_uef.h @@ -29,7 +29,7 @@ namespace LAMMPS_NS { class ComputeTempUef : public ComputeTemp { public: ComputeTempUef(class LAMMPS *, int, char **); - virtual ~ComputeTempUef(){} + virtual ~ComputeTempUef() {} virtual void init(); virtual void compute_vector(); void yes_rot(); diff --git a/src/USER-UEF/dump_cfg_uef.h b/src/USER-UEF/dump_cfg_uef.h index d2881136ad..d8e7b15bcc 100644 --- a/src/USER-UEF/dump_cfg_uef.h +++ b/src/USER-UEF/dump_cfg_uef.h @@ -29,7 +29,7 @@ namespace LAMMPS_NS { class DumpCFGUef : public DumpCFG { public: DumpCFGUef(LAMMPS *lmp, int narg, char **arg) : - DumpCFG(lmp, narg, arg){} + DumpCFG(lmp, narg, arg) {} void init_style(); void write_header(bigint); diff --git a/src/USER-UEF/fix_nvt_uef.h b/src/USER-UEF/fix_nvt_uef.h index 718e36e756..b98da7963f 100644 --- a/src/USER-UEF/fix_nvt_uef.h +++ b/src/USER-UEF/fix_nvt_uef.h @@ -29,7 +29,7 @@ namespace LAMMPS_NS { class FixNVTUef : public FixNHUef { public: FixNVTUef(class LAMMPS *, int, char **); - ~FixNVTUef(){} + ~FixNVTUef() {} }; } From 21bffd5258a8f2fd17c674416d52e54fef166dad Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 7 Jan 2021 08:48:41 -0700 Subject: [PATCH 45/51] Fix compile error --- src/KOKKOS/pppm_kokkos.cpp | 44 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/KOKKOS/pppm_kokkos.cpp b/src/KOKKOS/pppm_kokkos.cpp index 0b86c01d42..0de2edf4fb 100644 --- a/src/KOKKOS/pppm_kokkos.cpp +++ b/src/KOKKOS/pppm_kokkos.cpp @@ -1653,7 +1653,7 @@ void PPPMKokkos::poisson_ik() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft1->compute(d_work1,d_work1,FFT3d::FORWARD); + fft1->compute(d_work1,d_work1,FFT3dKokkos::FORWARD); // global energy and virial contribution @@ -1716,7 +1716,7 @@ void PPPMKokkos::poisson_ik() Kokkos::parallel_for(Kokkos::RangePolicy(0,inum_fft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); + fft2->compute(d_work2,d_work2,FFT3dKokkos::BACKWARD); copymode = 1; @@ -1730,7 +1730,7 @@ void PPPMKokkos::poisson_ik() Kokkos::parallel_for(Kokkos::RangePolicy(0,inum_fft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); + fft2->compute(d_work2,d_work2,FFT3dKokkos::BACKWARD); copymode = 1; @@ -1743,7 +1743,7 @@ void PPPMKokkos::poisson_ik() Kokkos::parallel_for(Kokkos::RangePolicy(0,inum_fft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); + fft2->compute(d_work2,d_work2,FFT3dKokkos::BACKWARD); copymode = 1; @@ -1882,7 +1882,7 @@ void PPPMKokkos::poisson_ik_triclinic() // n += 2; // } // -// fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); +// fft2->compute(d_work2,d_work2,FFT3dKokkos::BACKWARD); // // n = 0; // for (k = nzlo_in-nzlo_out; k <= nzhi_in-nzlo_out; k++) // parallel_for2 @@ -1897,7 +1897,7 @@ void PPPMKokkos::poisson_ik_triclinic() // n += 2; // } // -// fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); +// fft2->compute(d_work2,d_work2,FFT3dKokkos::BACKWARD); // // n = 0; // for (k = nzlo_in-nzlo_out; k <= nzhi_in-nzlo_out; k++) // parallel_for4 @@ -1916,7 +1916,7 @@ void PPPMKokkos::poisson_ik_triclinic() // n += 2; // } // -// fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); +// fft2->compute(d_work2,d_work2,FFT3dKokkos::BACKWARD); // // n = 0; // for (k = nzlo_in-nzlo_out; k <= nzhi_in-nzlo_out; k++) // parallel_for6 @@ -1999,7 +1999,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); + fft2->compute(d_work2,d_work2,FFT3dKokkos::BACKWARD); copymode = 1; @@ -2016,7 +2016,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); + fft2->compute(d_work2,d_work2,FFT3dKokkos::BACKWARD); copymode = 1; @@ -2028,7 +2028,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); + fft2->compute(d_work2,d_work2,FFT3dKokkos::BACKWARD); copymode = 1; @@ -2040,7 +2040,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); + fft2->compute(d_work2,d_work2,FFT3dKokkos::BACKWARD); copymode = 1; @@ -2051,7 +2051,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); + fft2->compute(d_work2,d_work2,FFT3dKokkos::BACKWARD); copymode = 1; @@ -2063,7 +2063,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); + fft2->compute(d_work2,d_work2,FFT3dKokkos::BACKWARD); copymode = 1; @@ -2075,7 +2075,7 @@ void PPPMKokkos::poisson_peratom() Kokkos::parallel_for(Kokkos::RangePolicy(0,nfft),*this); copymode = 0; - fft2->compute(d_work2,d_work2,FFT3d::BACKWARD); + fft2->compute(d_work2,d_work2,FFT3dKokkos::BACKWARD); copymode = 1; @@ -2817,10 +2817,10 @@ int PPPMKokkos::timing_1d(int n, double &time1d) time1 = MPI_Wtime(); for (int i = 0; i < n; i++) { - fft1->timing1d(d_work1,nfft_both,FFT3d::FORWARD); - fft2->timing1d(d_work1,nfft_both,FFT3d::BACKWARD); - fft2->timing1d(d_work1,nfft_both,FFT3d::BACKWARD); - fft2->timing1d(d_work1,nfft_both,FFT3d::BACKWARD); + fft1->timing1d(d_work1,nfft_both,FFT3dKokkos::FORWARD); + fft2->timing1d(d_work1,nfft_both,FFT3dKokkos::BACKWARD); + fft2->timing1d(d_work1,nfft_both,FFT3dKokkos::BACKWARD); + fft2->timing1d(d_work1,nfft_both,FFT3dKokkos::BACKWARD); } MPI_Barrier(world); @@ -2854,10 +2854,10 @@ int PPPMKokkos::timing_3d(int n, double &time3d) time1 = MPI_Wtime(); for (int i = 0; i < n; i++) { - fft1->compute(d_work1,d_work1,FFT3d::FORWARD); - fft2->compute(d_work1,d_work1,FFT3d::BACKWARD); - fft2->compute(d_work1,d_work1,FFT3d::BACKWARD); - fft2->compute(d_work1,d_work1,FFT3d::BACKWARD); + fft1->compute(d_work1,d_work1,FFT3dKokkos::FORWARD); + fft2->compute(d_work1,d_work1,FFT3dKokkos::BACKWARD); + fft2->compute(d_work1,d_work1,FFT3dKokkos::BACKWARD); + fft2->compute(d_work1,d_work1,FFT3dKokkos::BACKWARD); } MPI_Barrier(world); From dec574babf41dc4644144cf02f9e75bb69959cf5 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 7 Jan 2021 09:52:40 -0700 Subject: [PATCH 46/51] Flip sign in pppm_kokkos --- src/KOKKOS/pppm_kokkos.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/KOKKOS/pppm_kokkos.cpp b/src/KOKKOS/pppm_kokkos.cpp index 0de2edf4fb..db1cb18c9d 100644 --- a/src/KOKKOS/pppm_kokkos.cpp +++ b/src/KOKKOS/pppm_kokkos.cpp @@ -1793,8 +1793,8 @@ void PPPMKokkos::operator()(TagPPPM_poisson_ik5, const int &ii) cons const int k = ii/(numy_fft*numx_fft); const int j = (ii - k*numy_fft*numx_fft) / numx_fft; const int i = ii - k*numy_fft*numx_fft - j*numx_fft; - d_work2[n] = d_fkx[i]*d_work1[n+1]; - d_work2[n+1] = -d_fkx[i]*d_work1[n]; + d_work2[n] = -d_fkx[i]*d_work1[n+1]; + d_work2[n+1] = d_fkx[i]*d_work1[n]; } template @@ -1818,8 +1818,8 @@ void PPPMKokkos::operator()(TagPPPM_poisson_ik7, const int &ii) cons const int n = ii*2; const int k = ii/(numy_fft*numx_fft); const int j = (ii - k*numy_fft*numx_fft) / numx_fft; - d_work2[n] = d_fky[j]*d_work1[n+1]; - d_work2[n+1] = -d_fky[j]*d_work1[n]; + d_work2[n] = -d_fky[j]*d_work1[n+1]; + d_work2[n+1] = d_fky[j]*d_work1[n]; } template @@ -1842,8 +1842,8 @@ void PPPMKokkos::operator()(TagPPPM_poisson_ik9, const int &ii) cons { const int n = ii*2; const int k = ii/(numy_fft*numx_fft); - d_work2[n] = d_fkz[k]*d_work1[n+1]; - d_work2[n+1] = -d_fkz[k]*d_work1[n]; + d_work2[n] = -d_fkz[k]*d_work1[n+1]; + d_work2[n+1] = d_fkz[k]*d_work1[n]; } template @@ -1877,8 +1877,8 @@ void PPPMKokkos::poisson_ik_triclinic() // // n = 0; // for (i = 0; i < nfft; i++) { // parallel_for1 -// d_work2[n] = d_fkx[i]*d_work1[n+1]; -// d_work2[n+1] = -d_fkx[i]*d_work1[n]; +// d_work2[n] = -d_fkx[i]*d_work1[n+1]; +// d_work2[n+1] = d_fkx[i]*d_work1[n]; // n += 2; // } // @@ -1892,8 +1892,8 @@ void PPPMKokkos::poisson_ik_triclinic() // // n = 0; // for (i = 0; i < nfft; i++) { // parallel_for3 -// d_work2[n] = d_fky[i]*d_work1[n+1]; -// d_work2[n+1] = -d_fky[i]*d_work1[n]; +// d_work2[n] = -d_fky[i]*d_work1[n+1]; +// d_work2[n+1] = d_fky[i]*d_work1[n]; // n += 2; // } // @@ -1911,8 +1911,8 @@ void PPPMKokkos::poisson_ik_triclinic() // // n = 0; // for (i = 0; i < nfft; i++) { // parallel_for5 -// d_work2[n] = d_fkz[i]*d_work1[n+1]; -// d_work2[n+1] = -d_fkz[i]*d_work1[n]; +// d_work2[n] = -d_fkz[i]*d_work1[n+1]; +// d_work2[n+1] = d_fkz[i]*d_work1[n]; // n += 2; // } // From 21a0d26c4a6863b975cf5a39383dce1adcf9d9db Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 7 Jan 2021 11:08:48 -0700 Subject: [PATCH 47/51] cuFFT uses reverse notation --- src/KOKKOS/fft3d_kokkos.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/KOKKOS/fft3d_kokkos.cpp b/src/KOKKOS/fft3d_kokkos.cpp index 5db9ea607e..0a796e2e76 100644 --- a/src/KOKKOS/fft3d_kokkos.cpp +++ b/src/KOKKOS/fft3d_kokkos.cpp @@ -225,7 +225,7 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, else FFTW_API(execute_dft)(plan->plan_fast_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); #elif defined(FFT_CUFFT) - cufftExec(plan->plan_fast,d_data.data(),d_data.data(),flag); + cufftExec(plan->plan_fast,d_data.data(),d_data.data(),-flag); #else typename FFT_AT::t_FFT_DATA_1d d_tmp = typename FFT_AT::t_FFT_DATA_1d(Kokkos::view_alloc("fft_3d:tmp",Kokkos::WithoutInitializing),d_data.extent(0)); @@ -269,7 +269,7 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, else FFTW_API(execute_dft)(plan->plan_mid_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); #elif defined(FFT_CUFFT) - cufftExec(plan->plan_mid,d_data.data(),d_data.data(),flag); + cufftExec(plan->plan_mid,d_data.data(),d_data.data(),-flag); #else d_tmp = typename FFT_AT::t_FFT_DATA_1d(Kokkos::view_alloc("fft_3d:tmp",Kokkos::WithoutInitializing),d_data.extent(0)); if (flag == FORWARD) @@ -311,7 +311,7 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, else FFTW_API(execute_dft)(plan->plan_slow_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); #elif defined(FFT_CUFFT) - cufftExec(plan->plan_slow,d_data.data(),d_data.data(),flag); + cufftExec(plan->plan_slow,d_data.data(),d_data.data(),-flag); #else d_tmp = typename FFT_AT::t_FFT_DATA_1d(Kokkos::view_alloc("fft_3d:tmp",Kokkos::WithoutInitializing),d_data.extent(0)); if (flag == FORWARD) @@ -859,9 +859,9 @@ void FFT3dKokkos::fft_3d_1d_only_kokkos(typename FFT_AT::t_FFT_DATA_ FFTW_API(execute_dft)(plan->plan_slow_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); } #elif defined(FFT_CUFFT) - cufftExec(plan->plan_fast,d_data.data(),d_data.data(),flag); - cufftExec(plan->plan_mid,d_data.data(),d_data.data(),flag); - cufftExec(plan->plan_slow,d_data.data(),d_data.data(),flag); + cufftExec(plan->plan_fast,d_data.data(),d_data.data(),-flag); + cufftExec(plan->plan_mid,d_data.data(),d_data.data(),-flag); + cufftExec(plan->plan_slow,d_data.data(),d_data.data(),-flag); #else kiss_fft_functor f; typename FFT_AT::t_FFT_DATA_1d d_tmp = From 99ecefca632843bbb91f098e027d1b50f5824b1f Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 7 Jan 2021 11:16:57 -0700 Subject: [PATCH 48/51] Don't use the enum in fft3d_kokkos.cpp so as to match fft3d.cpp --- src/KOKKOS/fft3d_kokkos.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/KOKKOS/fft3d_kokkos.cpp b/src/KOKKOS/fft3d_kokkos.cpp index 0a796e2e76..21a3d52e50 100644 --- a/src/KOKKOS/fft3d_kokkos.cpp +++ b/src/KOKKOS/fft3d_kokkos.cpp @@ -215,12 +215,12 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, length = plan->length1; #if defined(FFT_MKL) - if (flag == FORWARD) + if (flag == 1) DftiComputeForward(plan->handle_fast,d_data.data()); else DftiComputeBackward(plan->handle_fast,d_data.data()); #elif defined(FFT_FFTW3) - if (flag == FORWARD) + if (flag == 1) FFTW_API(execute_dft)(plan->plan_fast_forward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); else FFTW_API(execute_dft)(plan->plan_fast_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); @@ -230,7 +230,7 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, typename FFT_AT::t_FFT_DATA_1d d_tmp = typename FFT_AT::t_FFT_DATA_1d(Kokkos::view_alloc("fft_3d:tmp",Kokkos::WithoutInitializing),d_data.extent(0)); kiss_fft_functor f; - if (flag == FORWARD) + if (flag == 1) f = kiss_fft_functor(d_data,d_tmp,plan->cfg_fast_forward,length); else f = kiss_fft_functor(d_data,d_tmp,plan->cfg_fast_backward,length); @@ -259,12 +259,12 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, length = plan->length2; #if defined(FFT_MKL) - if (flag == FORWARD) + if (flag == 1) DftiComputeForward(plan->handle_mid,d_data.data()); else DftiComputeBackward(plan->handle_mid,d_data.data()); #elif defined(FFT_FFTW3) - if (flag == FORWARD) + if (flag == 1) FFTW_API(execute_dft)(plan->plan_mid_forward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); else FFTW_API(execute_dft)(plan->plan_mid_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); @@ -272,7 +272,7 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, cufftExec(plan->plan_mid,d_data.data(),d_data.data(),-flag); #else d_tmp = typename FFT_AT::t_FFT_DATA_1d(Kokkos::view_alloc("fft_3d:tmp",Kokkos::WithoutInitializing),d_data.extent(0)); - if (flag == FORWARD) + if (flag == 1) f = kiss_fft_functor(d_data,d_tmp,plan->cfg_mid_forward,length); else f = kiss_fft_functor(d_data,d_tmp,plan->cfg_mid_backward,length); @@ -301,12 +301,12 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, length = plan->length3; #if defined(FFT_MKL) - if (flag == FORWARD) + if (flag == 1) DftiComputeForward(plan->handle_slow,d_data.data()); else DftiComputeBackward(plan->handle_slow,d_data.data()); #elif defined(FFT_FFTW3) - if (flag == FORWARD) + if (flag == 1) FFTW_API(execute_dft)(plan->plan_slow_forward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); else FFTW_API(execute_dft)(plan->plan_slow_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); @@ -314,7 +314,7 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, cufftExec(plan->plan_slow,d_data.data(),d_data.data(),-flag); #else d_tmp = typename FFT_AT::t_FFT_DATA_1d(Kokkos::view_alloc("fft_3d:tmp",Kokkos::WithoutInitializing),d_data.extent(0)); - if (flag == FORWARD) + if (flag == 1) f = kiss_fft_functor(d_data,d_tmp,plan->cfg_slow_forward,length); else f = kiss_fft_functor(d_data,d_tmp,plan->cfg_slow_backward,length); @@ -336,7 +336,7 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, // scaling if required - if (flag == BACKWARD && plan->scaled) { + if (flag == -1 && plan->scaled) { FFT_SCALAR norm = plan->norm; int num = plan->normnum; From 7abab6dd0f149f341a64ab267a6610522a0691fa Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 7 Jan 2021 21:36:59 -0700 Subject: [PATCH 49/51] Fix bug in Kokkos PPPM per-atom introduced by 985fc86aa3f8e907c8dae04321db2b6464c007eb --- src/KOKKOS/pppm_kokkos.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/KOKKOS/pppm_kokkos.cpp b/src/KOKKOS/pppm_kokkos.cpp index db1cb18c9d..86a8401e7e 100644 --- a/src/KOKKOS/pppm_kokkos.cpp +++ b/src/KOKKOS/pppm_kokkos.cpp @@ -579,7 +579,6 @@ void PPPMKokkos::compute(int eflag, int vflag) // invoke allocate_peratom() if needed for first time ev_init(eflag,vflag,0); - eflag_atom = vflag_atom = 0; // reallocate per-atom arrays if necessary From 91252176af370af966dfa271b51bab139b8936bc Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 7 Jan 2021 21:49:25 -0700 Subject: [PATCH 50/51] Cleanup --- src/KOKKOS/fft3d_kokkos.cpp | 4 ++-- src/KOKKOS/pppm_kokkos.cpp | 4 ++-- src/KSPACE/pppm.cpp | 4 ++-- src/KSPACE/pppm_disp.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/KOKKOS/fft3d_kokkos.cpp b/src/KOKKOS/fft3d_kokkos.cpp index 21a3d52e50..a8b366d389 100644 --- a/src/KOKKOS/fft3d_kokkos.cpp +++ b/src/KOKKOS/fft3d_kokkos.cpp @@ -127,7 +127,7 @@ void FFT3dKokkos::timing1d(typename FFT_AT::t_FFT_SCALAR_1d d_in, in in starting address of input data on this proc out starting address of where output data for this proc will be placed (can be same as in) - flag 1 for forward FFT, -1 for inverse FFT + flag 1 for forward FFT, -1 for backward FFT plan plan returned by previous call to fft_3d_create_plan ------------------------------------------------------------------------- */ @@ -805,7 +805,7 @@ void FFT3dKokkos::bifactor(int n, int *factor1, int *factor2) Arguments: in starting address of input data on this proc, all set to 0.0 nsize size of in - flag 1 for forward FFT, -1 for inverse FFT + flag 1 for forward FFT, -1 for backward FFT plan plan returned by previous call to fft_3d_create_plan ------------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pppm_kokkos.cpp b/src/KOKKOS/pppm_kokkos.cpp index 86a8401e7e..edee26e645 100644 --- a/src/KOKKOS/pppm_kokkos.cpp +++ b/src/KOKKOS/pppm_kokkos.cpp @@ -1693,7 +1693,7 @@ void PPPMKokkos::poisson_ik() return; } - // compute gradients of V(r) in each of 3 dims by transformimg -ik*V(k) + // compute gradients of V(r) in each of 3 dims by transforming ik*V(k) // FFT leaves data in 3d brick decomposition // copy it into inner portion of vdx,vdy,vdz arrays @@ -1868,7 +1868,7 @@ void PPPMKokkos::poisson_ik_triclinic() { // int i,j,k,n; // -// // compute gradients of V(r) in each of 3 dims by transformimg -ik*V(k) +// // compute gradients of V(r) in each of 3 dims by transforming ik*V(k) // // FFT leaves data in 3d brick decomposition // // copy it into inner portion of vdx,vdy,vdz arrays // diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index 1d50eab50d..e803a57fb3 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -2059,7 +2059,7 @@ void PPPM::poisson_ik() return; } - // compute gradients of V(r) in each of 3 dims by transformimg ik*V(k) + // compute gradients of V(r) in each of 3 dims by transforming ik*V(k) // FFT leaves data in 3d brick decomposition // copy it into inner portion of vdx,vdy,vdz arrays @@ -2135,7 +2135,7 @@ void PPPM::poisson_ik_triclinic() { int i,j,k,n; - // compute gradients of V(r) in each of 3 dims by transformimg ik*V(k) + // compute gradients of V(r) in each of 3 dims by transforming ik*V(k) // FFT leaves data in 3d brick decomposition // copy it into inner portion of vdx,vdy,vdz arrays diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 0ab8025b8f..8619545ba3 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -1194,7 +1194,7 @@ void PPPMDisp::compute(int eflag, int vflag) if (evflag_atom) fieldforce_none_peratom(); } - // update qsum and qsqsum,if atom count has changed and energy needed + // update qsum and qsqsum, if atom count has changed and energy needed if ((eflag_global || eflag_atom) && atom->natoms != natoms_original) { qsum_qsq(); @@ -1214,7 +1214,7 @@ void PPPMDisp::compute(int eflag, int vflag) energy_1 *= 0.5*volume; energy_6 *= 0.5*volume; - + energy_1 -= g_ewald*qsqsum/MY_PIS + MY_PI2*qsum*qsum / (g_ewald*g_ewald*volume); energy_6 += - MY_PI*MY_PIS/(6*volume)*pow(g_ewald_6,3)*csumij + @@ -3186,7 +3186,7 @@ double PPPMDisp::compute_qopt_ad() sum2 *= sum2; qopt += sum1 - sum2/(sum3*sum4); } - + return qopt; } @@ -4842,7 +4842,7 @@ void PPPMDisp::poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT3 } // v2 & v3 term - + n = 0; for (i = 0; i < nft; i++) { wk2[n] = wk1[n]*vcoeff[i][2] + wk1[n+1]*vcoeff2[i][0]; From acb7cab1506c32049de9c1d56df605007f4570ba Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 7 Jan 2021 21:52:09 -0700 Subject: [PATCH 51/51] whitespace --- src/KSPACE/pppm_disp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 8619545ba3..fbcf2dd324 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -1214,7 +1214,7 @@ void PPPMDisp::compute(int eflag, int vflag) energy_1 *= 0.5*volume; energy_6 *= 0.5*volume; - + energy_1 -= g_ewald*qsqsum/MY_PIS + MY_PI2*qsum*qsum / (g_ewald*g_ewald*volume); energy_6 += - MY_PI*MY_PIS/(6*volume)*pow(g_ewald_6,3)*csumij + @@ -3186,7 +3186,7 @@ double PPPMDisp::compute_qopt_ad() sum2 *= sum2; qopt += sum1 - sum2/(sum3*sum4); } - + return qopt; } @@ -4842,7 +4842,7 @@ void PPPMDisp::poisson_peratom(FFT_SCALAR* wk1, FFT_SCALAR* wk2, LAMMPS_NS::FFT3 } // v2 & v3 term - + n = 0; for (i = 0; i < nft; i++) { wk2[n] = wk1[n]*vcoeff[i][2] + wk1[n+1]*vcoeff2[i][0];