From 810698dc07ca91b7df46f352b7b90d07b72c00d3 Mon Sep 17 00:00:00 2001 From: Michele Ceriotti Date: Fri, 5 Jul 2024 09:07:30 +0200 Subject: [PATCH] Skip neighbor folding at first call There may be issues due to the fact that the NL is initialized with the LAMMPS data file, that does not have to be the same as the starting config in i-PI --- src/MISC/fix_ipi.cpp | 9 ++++++++- src/MISC/fix_ipi.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/MISC/fix_ipi.cpp b/src/MISC/fix_ipi.cpp index e08727a4ed..80666790e2 100644 --- a/src/MISC/fix_ipi.cpp +++ b/src/MISC/fix_ipi.cpp @@ -188,6 +188,7 @@ FixIPI::FixIPI(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), irregul master = (comm->me == 0) ? 1 : 0; inet = 1; reset_flag = 0; + firsttime = 1; int iarg = 5; while (iarg < narg) { @@ -253,6 +254,7 @@ void FixIPI::init() ipisock = 0; // TODO: should check for success in socket opening, // but the current open_socket routine dies brutally if unsuccessful + // tell lammps we have assigned a socket socketflag = 1; @@ -382,7 +384,11 @@ void FixIPI::initial_integrate(int /*vflag*/) // snapshot at neighbor list creation, minimizing the // number of neighbor list updates auto xhold = neighbor->get_xhold(); - if (xhold != NULL) { // don't wrap if xhold is not used in the NL + if (xhold != NULL && !firsttime) { + // don't wrap if xhold is not used in the NL, or the + // first call (because the NL is initialized from the + // data file that might have nothing to do with the + // current structure for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { auto delx = x[i][0] - xhold[i][0]; @@ -397,6 +403,7 @@ void FixIPI::initial_integrate(int /*vflag*/) } } } + firsttime = 0; // check if kspace solver is used if (reset_flag && kspace_flag) { diff --git a/src/MISC/fix_ipi.h b/src/MISC/fix_ipi.h index de954c8578..31bd59b2fa 100644 --- a/src/MISC/fix_ipi.h +++ b/src/MISC/fix_ipi.h @@ -42,6 +42,7 @@ class FixIPI : public Fix { long bsize; int kspace_flag; int reset_flag; + int firsttime; private: class Irregular *irregular;