From 94b80f9ac6ee02b9376fba17fa1e84578963d4e5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 13 Oct 2019 17:47:09 -0400 Subject: [PATCH 1/5] correct pppm/tip4p to give correct forces with tip4p with triclinic cells --- src/KSPACE/pppm_tip4p.cpp | 28 ++++++++++++++++++++-------- src/USER-OMP/pppm_omp.cpp | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/KSPACE/pppm_tip4p.cpp b/src/KSPACE/pppm_tip4p.cpp index f664a0dca3..6e330112de 100644 --- a/src/KSPACE/pppm_tip4p.cpp +++ b/src/KSPACE/pppm_tip4p.cpp @@ -500,11 +500,21 @@ void PPPMTIP4P::find_M(int i, int &iH1, int &iH2, double *xM) // since local atoms are in lambda coordinates, but ghosts are not. int *sametag = atom->sametag; - double xo[3],xh1[3],xh2[3]; + double xo[3],xh1[3],xh2[3],xm[0]; + double *lo = domain->boxlo_lamda; + double *hi = domain->boxhi_lamda; + double *prd = domain->prd_lamda; + const int nlocal = atom->nlocal; - domain->lamda2x(x[i],xo); - domain->lamda2x(x[iH1],xh1); - domain->lamda2x(x[iH2],xh2); + for (int ii = 0; ii < 3; ++ii) { + xo[ii] = x[i][ii]; + xh1[ii] = x[iH1][ii]; + xh2[ii] = x[iH2][ii]; + } + + if (i < nlocal) domain->lamda2x(x[i],xo); + if (iH1 < nlocal) domain->lamda2x(x[iH1],xh1); + if (iH2 < nlocal) domain->lamda2x(x[iH2],xh2); double delx = xo[0] - xh1[0]; double dely = xo[1] - xh1[1]; @@ -513,6 +523,8 @@ void PPPMTIP4P::find_M(int i, int &iH1, int &iH2, double *xM) double rsq; int closest = iH1; + // no need to run lamda2x() here -> ghost atoms + while (sametag[iH1] >= 0) { iH1 = sametag[iH1]; delx = xo[0] - x[iH1][0]; @@ -561,13 +573,13 @@ void PPPMTIP4P::find_M(int i, int &iH1, int &iH2, double *xM) double dely2 = xh2[1] - xo[1]; double delz2 = xh2[2] - xo[2]; - xM[0] = xo[0] + alpha * 0.5 * (delx1 + delx2); - xM[1] = xo[1] + alpha * 0.5 * (dely1 + dely2); - xM[2] = xo[2] + alpha * 0.5 * (delz1 + delz2); + xm[0] = xo[0] + alpha * 0.5 * (delx1 + delx2); + xm[1] = xo[1] + alpha * 0.5 * (dely1 + dely2); + xm[2] = xo[2] + alpha * 0.5 * (delz1 + delz2); // ... and convert M to lamda space for PPPM - domain->x2lamda(xM,xM); + domain->x2lamda(xm,xM); } else { diff --git a/src/USER-OMP/pppm_omp.cpp b/src/USER-OMP/pppm_omp.cpp index 3ef3de1ab7..c6aaafaa31 100644 --- a/src/USER-OMP/pppm_omp.cpp +++ b/src/USER-OMP/pppm_omp.cpp @@ -48,7 +48,7 @@ using namespace MathSpecial; PPPMOMP::PPPMOMP(LAMMPS *lmp) : PPPM(lmp), ThrOMP(lmp, THR_KSPACE) { - triclinic_support = 0; + triclinic_support = 1; suffix_flag |= Suffix::OMP; } From be01cfffa33f3c91b882d31a9d649df48817e8ef Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 14 Oct 2019 07:53:24 -0400 Subject: [PATCH 2/5] fix typo and port find_M() code to USER-OMP version --- src/KSPACE/pppm_tip4p.cpp | 5 +---- src/USER-OMP/pppm_tip4p_omp.cpp | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/KSPACE/pppm_tip4p.cpp b/src/KSPACE/pppm_tip4p.cpp index 6e330112de..5a0ced3674 100644 --- a/src/KSPACE/pppm_tip4p.cpp +++ b/src/KSPACE/pppm_tip4p.cpp @@ -500,10 +500,7 @@ void PPPMTIP4P::find_M(int i, int &iH1, int &iH2, double *xM) // since local atoms are in lambda coordinates, but ghosts are not. int *sametag = atom->sametag; - double xo[3],xh1[3],xh2[3],xm[0]; - double *lo = domain->boxlo_lamda; - double *hi = domain->boxhi_lamda; - double *prd = domain->prd_lamda; + double xo[3],xh1[3],xh2[3],xm[3]; const int nlocal = atom->nlocal; for (int ii = 0; ii < 3; ++ii) { diff --git a/src/USER-OMP/pppm_tip4p_omp.cpp b/src/USER-OMP/pppm_tip4p_omp.cpp index d7c12613d9..1a2bcfc0a3 100644 --- a/src/USER-OMP/pppm_tip4p_omp.cpp +++ b/src/USER-OMP/pppm_tip4p_omp.cpp @@ -750,11 +750,18 @@ void PPPMTIP4POMP::find_M_thr(int i, int &iH1, int &iH2, dbl3_t &xM) // since local atoms are in lambda coordinates, but ghosts are not. int *sametag = atom->sametag; - double xo[3],xh1[3],xh2[3]; + double xo[3],xh1[3],xh2[3],xm[3]; + const int nlocal = atom->nlocal; - domain->lamda2x(x[i],xo); - domain->lamda2x(x[iH1],xh1); - domain->lamda2x(x[iH2],xh2); + for (int ii = 0; ii < 3; ++ii) { + xo[ii] = x[i][ii]; + xh1[ii] = x[iH1][ii]; + xh2[ii] = x[iH2][ii]; + } + + if (i < nlocal) domain->lamda2x(x[i],xo); + if (iH1 < nlocal) domain->lamda2x(x[iH1],xh1); + if (iH2 < nlocal) domain->lamda2x(x[iH2],xh2); double delx = xo[0] - xh1[0]; double dely = xo[1] - xh1[1]; @@ -763,6 +770,7 @@ void PPPMTIP4POMP::find_M_thr(int i, int &iH1, int &iH2, dbl3_t &xM) double rsq; int closest = iH1; + // no need to run lamda2x here -> ghost atoms while (sametag[iH1] >= 0) { iH1 = sametag[iH1]; delx = xo[0] - x[iH1][0]; @@ -811,13 +819,13 @@ void PPPMTIP4POMP::find_M_thr(int i, int &iH1, int &iH2, dbl3_t &xM) double dely2 = xh2[1] - xo[1]; double delz2 = xh2[2] - xo[2]; - xM.x = xo[0] + alpha * 0.5 * (delx1 + delx2); - xM.y = xo[1] + alpha * 0.5 * (dely1 + dely2); - xM.z = xo[2] + alpha * 0.5 * (delz1 + delz2); + xm[0] = xo[0] + alpha * 0.5 * (delx1 + delx2); + xm[1] = xo[1] + alpha * 0.5 * (dely1 + dely2); + xm[2] = xo[2] + alpha * 0.5 * (delz1 + delz2); // ... and convert M to lamda space for PPPM - domain->x2lamda((double *)&xM,(double *)&xM); + domain->x2lamda(xm,(double *)&xM); } else { From 25b114eeb479a136a7a50fa207e4b1f9887133a4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 13 Oct 2019 17:12:36 -0400 Subject: [PATCH 3/5] avoid compilation failure without installed packages --- src/force.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/force.cpp b/src/force.cpp index 1cc6b3e01b..cc121a5f80 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -21,6 +21,7 @@ #include "style_improper.h" #include "style_pair.h" #include "style_kspace.h" +#include "atom.h" #include "comm.h" #include "pair.h" #include "pair_hybrid.h" From 28c9255f99892f3e4032dad9c11d2dab314b5b7f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 14 Oct 2019 08:02:59 -0400 Subject: [PATCH 4/5] don't include USER-PLUMED in "most" preset --- cmake/presets/most.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/presets/most.cmake b/cmake/presets/most.cmake index 35ad7ba55c..2be17a1826 100644 --- a/cmake/presets/most.cmake +++ b/cmake/presets/most.cmake @@ -7,7 +7,7 @@ set(ALL_PACKAGES ASPHERE CLASS2 COLLOID CORESHELL DIPOLE PYTHON QEQ REPLICA RIGID SHOCK SRD VORONOI USER-CGDNA USER-CGSDK USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-FEP USER-MEAMC USER-MESO - USER-MISC USER-MOFFF USER-OMP USER-PLUMED USER-PHONON USER-REAXC + USER-MISC USER-MOFFF USER-OMP USER-PHONON USER-REAXC USER-SPH USER-SMD USER-UEF USER-YAFF) foreach(PKG ${ALL_PACKAGES}) From 37456733bfd680374f43f6711494e3be3ab9488c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 15 Oct 2019 09:28:34 +0200 Subject: [PATCH 5/5] prefer local mpi.h file by using '#include "mpi.h"' instead of '#include ' --- src/STUBS/mpi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/STUBS/mpi.c b/src/STUBS/mpi.c index f56d3616c8..a5a00f86a5 100644 --- a/src/STUBS/mpi.c +++ b/src/STUBS/mpi.c @@ -12,14 +12,13 @@ ------------------------------------------------------------------------ */ /* Single-processor "stub" versions of MPI routines */ -/* -I. in Makefile insures dummy mpi.h in this dir is included */ #include #include #include #include #include -#include +#include "mpi.h" #include "../version.h" /* data structure for double/int */