diff --git a/unittest/c-library/test_library_properties.cpp b/unittest/c-library/test_library_properties.cpp index 2b2b1cd58e..19e881e32b 100644 --- a/unittest/c-library/test_library_properties.cpp +++ b/unittest/c-library/test_library_properties.cpp @@ -315,6 +315,60 @@ TEST_F(LibraryProperties, global) EXPECT_DOUBLE_EQ((*d_ptr), 0.1); }; +TEST_F(LibraryProperties, neighlist) +{ + if (!lammps_has_style(lmp, "pair", "sw")) GTEST_SKIP(); + const char sysinit[] = "boundary f f f\n" + "units real\n" + "region box block -5 5 -5 5 -5 5\n" + "create_box 2 box\n" + "mass 1 1.0\n" + "mass 2 1.0\n" + "pair_style hybrid/overlay lj/cut 4.0 lj/cut 4.0 morse 4.0 sw\n" + "pair_coeff * * sw Si.sw Si NULL\n" + "pair_coeff 1 2 morse 0.2 2.0 2.0\n" + "pair_coeff 2 2 lj/cut 1 0.1 2.0\n" + "pair_coeff * * lj/cut 2 0.01 2.0\n" + "compute dist all pair/local dist\n" + "fix dist all ave/histo 1 1 1 0.0 3.0 4 c_dist mode vector\n" + "thermo_style custom f_dist[*]"; + + const double pos[] = {0.0, 0.0, 0.0, -1.1, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, -1.1, + 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, -1.1, 0.0, 0.0, 1.0}; + const tagint ids[] = {1, 2, 3, 4, 5, 6, 7}; + const int types[] = {1, 1, 1, 1, 2, 2, 2}; + + const int numatoms = sizeof(ids) / sizeof(tagint); + + if (!verbose) ::testing::internal::CaptureStdout(); + lammps_commands_string(lmp, sysinit); + lammps_create_atoms(lmp, numatoms, ids, types, pos, nullptr, nullptr, 0); + lammps_command(lmp, "run 0 post no"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + int nhisto = *(double *)lammps_extract_fix(lmp,"dist",LMP_STYLE_GLOBAL,LMP_TYPE_VECTOR,0,0); + int nskip = *(double *)lammps_extract_fix(lmp,"dist",LMP_STYLE_GLOBAL,LMP_TYPE_VECTOR,1,0); + double minval = *(double *)lammps_extract_fix(lmp,"dist",LMP_STYLE_GLOBAL,LMP_TYPE_VECTOR,2,0); + double maxval = *(double *)lammps_extract_fix(lmp,"dist",LMP_STYLE_GLOBAL,LMP_TYPE_VECTOR,3,0); + // 21 pair distances counted, none skipped, smallest 1.0, largest 2.1 + EXPECT_EQ(nhisto,21); + EXPECT_EQ(nskip,0); + EXPECT_DOUBLE_EQ(minval,1.0); + EXPECT_DOUBLE_EQ(maxval,2.1); + + const int nlocal = lammps_extract_setting(lmp, "nlocal"); + EXPECT_EQ(nlocal, numatoms); + EXPECT_NE(lammps_find_pair_neighlist(lmp, "sw", 1, 0, 0), -1); + EXPECT_NE(lammps_find_pair_neighlist(lmp, "morse", 1, 0, 0), -1); + EXPECT_NE(lammps_find_pair_neighlist(lmp, "lj/cut", 1, 1, 0), -1); + EXPECT_NE(lammps_find_pair_neighlist(lmp, "lj/cut", 1, 2, 0), -1); + EXPECT_EQ(lammps_find_pair_neighlist(lmp, "lj/cut", 1, 0, 0), -1); + EXPECT_EQ(lammps_find_pair_neighlist(lmp, "hybrid/overlay", 1, 0, 0), -1); + EXPECT_NE(lammps_find_compute_neighlist(lmp, "dist", 0),-1); + EXPECT_EQ(lammps_find_fix_neighlist(lmp, "dist", 0),-1); + EXPECT_EQ(lammps_find_compute_neighlist(lmp, "xxx", 0),-1); +}; + class AtomProperties : public ::testing::Test { protected: void *lmp;