From b29ffabe566e991af062c7b3bf71a96828881d4e Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Tue, 21 Jan 2020 14:24:55 -0700 Subject: [PATCH] move two_charge_force calc to occur at init, not constructor --- src/KOKKOS/pppm_kokkos.cpp | 4 ++++ src/KSPACE/ewald.cpp | 4 ++++ src/KSPACE/ewald_dipole.cpp | 8 ++++++-- src/KSPACE/ewald_dipole_spin.cpp | 8 ++++++-- src/KSPACE/msm.cpp | 4 ++++ src/KSPACE/pppm.cpp | 4 ++++ src/KSPACE/pppm_dipole.cpp | 4 ++++ src/KSPACE/pppm_dipole_spin.cpp | 4 ++++ src/KSPACE/pppm_disp.cpp | 7 +++++++ src/kspace.cpp | 17 +++++++++++++---- src/kspace.h | 1 + 11 files changed, 57 insertions(+), 8 deletions(-) diff --git a/src/KOKKOS/pppm_kokkos.cpp b/src/KOKKOS/pppm_kokkos.cpp index b5539ef6e4..0e7dbdb99b 100644 --- a/src/KOKKOS/pppm_kokkos.cpp +++ b/src/KOKKOS/pppm_kokkos.cpp @@ -210,6 +210,10 @@ void PPPMKokkos::init() error->all(FLERR,str); } + // compute two charge force + + two_charge(); + // extract short-range Coulombic cutoff from pair style triclinic = domain->triclinic; diff --git a/src/KSPACE/ewald.cpp b/src/KSPACE/ewald.cpp index d74d90b0d6..bbadad8505 100644 --- a/src/KSPACE/ewald.cpp +++ b/src/KSPACE/ewald.cpp @@ -112,6 +112,10 @@ void Ewald::init() "and slab correction"); } + // compute two charge force + + two_charge(); + // extract short-range Coulombic cutoff from pair style triclinic = domain->triclinic; diff --git a/src/KSPACE/ewald_dipole.cpp b/src/KSPACE/ewald_dipole.cpp index 1939742bfc..d6a8aef9e3 100644 --- a/src/KSPACE/ewald_dipole.cpp +++ b/src/KSPACE/ewald_dipole.cpp @@ -76,10 +76,10 @@ void EwaldDipole::init() if (dipoleflag && q2) error->all(FLERR,"Cannot (yet) use charges with Kspace style EwaldDipole"); - triclinic_check(); - // no triclinic ewald dipole (yet) + triclinic_check(); + triclinic = domain->triclinic; if (triclinic) error->all(FLERR,"Cannot (yet) use EwaldDipole with triclinic box"); @@ -100,6 +100,10 @@ void EwaldDipole::init() error->all(FLERR,"Incorrect boundaries with slab EwaldDipole"); } + // compute two charge force + + two_charge(); + // extract short-range Coulombic cutoff from pair style triclinic = domain->triclinic; diff --git a/src/KSPACE/ewald_dipole_spin.cpp b/src/KSPACE/ewald_dipole_spin.cpp index 82832f6e4c..f9a2a3f08d 100644 --- a/src/KSPACE/ewald_dipole_spin.cpp +++ b/src/KSPACE/ewald_dipole_spin.cpp @@ -70,10 +70,10 @@ void EwaldDipoleSpin::init() spinflag = atom->sp?1:0; - triclinic_check(); - // no triclinic ewald spin (yet) + triclinic_check(); + triclinic = domain->triclinic; if (triclinic) error->all(FLERR,"Cannot (yet) use EwaldDipoleSpin with triclinic box"); @@ -94,6 +94,10 @@ void EwaldDipoleSpin::init() error->all(FLERR,"Incorrect boundaries with slab EwaldDipoleSpin"); } + // compute two charge force + + two_charge(); + // extract short-range Coulombic cutoff from pair style pair_check(); diff --git a/src/KSPACE/msm.cpp b/src/KSPACE/msm.cpp index 81dbabdbbd..126236a328 100644 --- a/src/KSPACE/msm.cpp +++ b/src/KSPACE/msm.cpp @@ -181,6 +181,10 @@ void MSM::init() error->all(FLERR,"Cannot (yet) use single precision with MSM " "(remove -DFFT_SINGLE from Makefile and re-compile)"); + // compute two charge force + + two_charge(); + // extract short-range Coulombic cutoff from pair style triclinic = domain->triclinic; diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index 75470c962f..cd0a1bf47a 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -225,6 +225,10 @@ void PPPM::init() error->all(FLERR,str); } + // compute two charge force + + two_charge(); + // extract short-range Coulombic cutoff from pair style triclinic = domain->triclinic; diff --git a/src/KSPACE/pppm_dipole.cpp b/src/KSPACE/pppm_dipole.cpp index 40d0c1ac73..2d5f6ad981 100644 --- a/src/KSPACE/pppm_dipole.cpp +++ b/src/KSPACE/pppm_dipole.cpp @@ -149,6 +149,10 @@ void PPPMDipole::init() error->all(FLERR,str); } + // compute two charge force + + two_charge(); + // extract short-range Coulombic cutoff from pair style triclinic = domain->triclinic; diff --git a/src/KSPACE/pppm_dipole_spin.cpp b/src/KSPACE/pppm_dipole_spin.cpp index 7f7745eb3e..35145b5ca8 100644 --- a/src/KSPACE/pppm_dipole_spin.cpp +++ b/src/KSPACE/pppm_dipole_spin.cpp @@ -129,6 +129,10 @@ void PPPMDipoleSpin::init() error->all(FLERR,str); } + // compute two charge force + + two_charge(); + // extract short-range Coulombic cutoff from pair style triclinic = domain->triclinic; diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 0d0d4c7eb2..0bb81f125e 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -259,7 +259,10 @@ void PPPMDisp::init() if (logfile) fprintf(logfile,"PPPMDisp initialization ...\n"); } + // error check + triclinic_check(); + if (domain->dimension == 2) error->all(FLERR,"Cannot use PPPMDisp with 2d simulation"); if (comm->style != 0) @@ -280,6 +283,10 @@ void PPPMDisp::init() error->all(FLERR,str); } + // compute two charge force + + two_charge(); + // free all arrays previously allocated deallocate(); diff --git a/src/kspace.cpp b/src/kspace.cpp index f9020416bf..b79e1077bf 100644 --- a/src/kspace.cpp +++ b/src/kspace.cpp @@ -39,7 +39,8 @@ KSpace::KSpace(LAMMPS *lmp) : Pointers(lmp) virial[0] = virial[1] = virial[2] = virial[3] = virial[4] = virial[5] = 0.0; triclinic_support = 1; - ewaldflag = pppmflag = msmflag = dispersionflag = tip4pflag = dipoleflag = spinflag = 0; + ewaldflag = pppmflag = msmflag = dispersionflag = tip4pflag = + dipoleflag = spinflag = 0; compute_flag = 1; group_group_enable = 0; stagger_flag = 0; @@ -78,9 +79,6 @@ KSpace::KSpace(LAMMPS *lmp) : Pointers(lmp) accuracy_absolute = -1.0; accuracy_real_6 = -1.0; accuracy_kspace_6 = -1.0; - two_charge_force = force->qqr2e * - (force->qelectron * force->qelectron) / - (force->angstrom * force->angstrom); neighrequest_flag = 1; mixflag = 0; @@ -158,6 +156,17 @@ KSpace::~KSpace() memory->destroy(dgcons); } +/* ---------------------------------------------------------------------- + calculate this in init() so that units are finalized +------------------------------------------------------------------------- */ + +void KSpace::two_charge() +{ + two_charge_force = force->qqr2e * + (force->qelectron * force->qelectron) / + (force->angstrom * force->angstrom); +} + /* ---------------------------------------------------------------------- */ void KSpace::triclinic_check() diff --git a/src/kspace.h b/src/kspace.h index 60df2345fd..4bae983364 100644 --- a/src/kspace.h +++ b/src/kspace.h @@ -95,6 +95,7 @@ class KSpace : protected Pointers { KSpace(class LAMMPS *); virtual ~KSpace(); + void two_charge(); void triclinic_check(); void modify_params(int, char **); void *extract(const char *);