From c9cf8b57f4ce3ade34f55911824b5a126bf3200a Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Wed, 3 Feb 2021 10:00:25 -0600 Subject: [PATCH 1/4] Fix behavor of a 2nd call to 'pair_style kim ...' & a bug for parameter changes --- src/KIM/pair_kim.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index ee6f5f98a5..ecb62cdf7a 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -540,6 +540,19 @@ void PairKIM::coeff(int narg, char **arg) kimerror = KIM_Model_ClearThenRefresh(pkim); if (kimerror) error->all(FLERR,"KIM KIM_Model_ClearThenRefresh returned error"); + + // Update cached quantities that may have changed due to Refresh + KIM_Model_GetInfluenceDistance(pkim, &kim_global_influence_distance); + KIM_Model_GetNeighborListPointers( + pkim, + &kim_number_of_neighbor_lists, + &kim_cutoff_values, + &modelWillNotRequestNeighborsOfNoncontributingParticles); + if (neighborLists) { + delete [] neighborLists; + neighborLists = 0; + } + neighborLists = new NeighList*[kim_number_of_neighbor_lists]; } } @@ -809,6 +822,8 @@ void PairKIM::kim_free() error->all(FLERR,"Unable to destroy Compute Arguments Object"); KIM_Model_Destroy(&pkim); + + lmps_maxalloc = 0; } kim_init_ok = false; } From 8da3bc91444523948433f01e2a90701bfcfa81a0 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Thu, 4 Feb 2021 09:47:29 -0600 Subject: [PATCH 2/4] Increment instance_me in pair_kim to ensure neighbor correct list updates --- src/KIM/pair_kim.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index ecb62cdf7a..53ccdc1d73 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -550,7 +550,7 @@ void PairKIM::coeff(int narg, char **arg) &modelWillNotRequestNeighborsOfNoncontributingParticles); if (neighborLists) { delete [] neighborLists; - neighborLists = 0; + neighborLists = nullptr; } neighborLists = new NeighList*[kim_number_of_neighbor_lists]; } @@ -604,6 +604,9 @@ void PairKIM::init_style() neighbor->requests[irequest]->cutoff = kim_cutoff_values[i] + neighbor->skin; } + // increment instance_me in case of need to change the neighbor list + // request settings + instance_me += 1; } /* ---------------------------------------------------------------------- @@ -823,7 +826,7 @@ void PairKIM::kim_free() KIM_Model_Destroy(&pkim); - lmps_maxalloc = 0; + lmps_maxalloc = 0; // reinitialize member variable } kim_init_ok = false; } @@ -874,7 +877,7 @@ void PairKIM::kim_init() &modelWillNotRequestNeighborsOfNoncontributingParticles); if (neighborLists) { delete [] neighborLists; - neighborLists = 0; + neighborLists = nulptr; } neighborLists = new NeighList*[kim_number_of_neighbor_lists]; From 302be3f946c470ccbf9a156f9ae5f00c224899d4 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Thu, 4 Feb 2021 10:09:14 -0600 Subject: [PATCH 3/4] Fix typo --- src/KIM/pair_kim.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index 53ccdc1d73..2f1fb9da3e 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -877,7 +877,7 @@ void PairKIM::kim_init() &modelWillNotRequestNeighborsOfNoncontributingParticles); if (neighborLists) { delete [] neighborLists; - neighborLists = nulptr; + neighborLists = nullptr; } neighborLists = new NeighList*[kim_number_of_neighbor_lists]; From 5256631bee97c06e7c302e4b722111e0e3303b11 Mon Sep 17 00:00:00 2001 From: Yaser Afshar Date: Thu, 4 Feb 2021 11:08:39 -0600 Subject: [PATCH 4/4] test for correctly supporting the use of multiple calls to pair_style kim --- unittest/commands/test_kim_commands.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/unittest/commands/test_kim_commands.cpp b/unittest/commands/test_kim_commands.cpp index 4e16e28783..275a9eae3a 100644 --- a/unittest/commands/test_kim_commands.cpp +++ b/unittest/commands/test_kim_commands.cpp @@ -219,6 +219,20 @@ TEST_F(KimCommandsTest, kim_interactions) int ifix = lmp->modify->find_fix("KIM_MODEL_STORE"); ASSERT_GE(ifix, 0); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("clear"); + lmp->input->one("kim_init LennardJones_Ar real"); + lmp->input->one("lattice fcc 4.4300"); + lmp->input->one("region box block 0 10 0 10 0 10"); + lmp->input->one("create_box 1 box"); + lmp->input->one("create_atoms 1 box"); + lmp->input->one("kim_interactions Ar"); + lmp->input->one("mass 1 39.95"); + lmp->input->one("run 1"); + lmp->input->one("kim_interactions Ar"); + lmp->input->one("run 1"); + if (!verbose) ::testing::internal::GetCapturedStdout(); } TEST_F(KimCommandsTest, kim_param)