add option to extract newton_bond/newton_pair settings

This commit is contained in:
Axel Kohlmeyer
2020-11-17 16:38:11 -05:00
committed by Richard Berger
parent 7cb644b425
commit 849e5ffee2
2 changed files with 34 additions and 4 deletions

View File

@ -841,6 +841,10 @@ not recognized, the function returns -1.
See :doc:`create_box`.
* - nthreads
- Number of requested OpenMP threads for LAMMPS' execution
* - newton_bond
- 1 if Newton's 3rd law is applied to bonded interactions, 0 if not.
* - newton_pair
- 1 if Newton's 3rd law is applied to non-bonded interactions, 0 if not.
* - triclinic
- 1 if the the simulation box is triclinic, 0 if orthogonal.
See :doc:`change_box`.
@ -933,6 +937,8 @@ int lammps_extract_setting(void *handle, const char *keyword)
if (strcmp(keyword,"dimension") == 0) return lmp->domain->dimension;
if (strcmp(keyword,"box_exist") == 0) return lmp->domain->box_exist;
if (strcmp(keyword,"newton_bond") == 0) return lmp->force->newton_bond;
if (strcmp(keyword,"newton_pair") == 0) return lmp->force->newton_pair;
if (strcmp(keyword,"triclinic") == 0) return lmp->domain->triclinic;
if (strcmp(keyword,"universe_rank") == 0) return lmp->universe->me;

View File

@ -91,10 +91,11 @@ TEST_F(LibraryProperties, thermo)
{
if (!lammps_has_style(lmp, "atom", "full")) GTEST_SKIP();
std::string input = INPUT_DIR + PATH_SEP + "in.fourmol";
if (!verbose) ::testing::internal::CaptureStdout();
::testing::internal::CaptureStdout();
lammps_file(lmp, input.c_str());
lammps_command(lmp, "run 2 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
EXPECT_EQ(lammps_get_thermo(lmp, "step"), 2);
EXPECT_EQ(lammps_get_thermo(lmp, "atoms"), 29);
EXPECT_DOUBLE_EQ(lammps_get_thermo(lmp, "vol"), 3375.0);
@ -106,10 +107,11 @@ TEST_F(LibraryProperties, box)
{
if (!lammps_has_style(lmp, "atom", "full")) GTEST_SKIP();
std::string input = INPUT_DIR + PATH_SEP + "in.fourmol";
if (!verbose) ::testing::internal::CaptureStdout();
::testing::internal::CaptureStdout();
lammps_file(lmp, input.c_str());
lammps_command(lmp, "run 2 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
double boxlo[3], boxhi[3], xy, yz, xz;
int pflags[3], boxflag;
lammps_extract_box(lmp, boxlo, boxhi, &xy, &yz, &xz, pflags, &boxflag);
@ -204,6 +206,28 @@ TEST_F(LibraryProperties, setting)
EXPECT_EQ(lammps_extract_setting(lmp, "universe_size"), 1);
EXPECT_EQ(lammps_extract_setting(lmp, "universe_rank"), 0);
EXPECT_GT(lammps_extract_setting(lmp, "nthreads"), 0);
EXPECT_EQ(lammps_extract_setting(lmp, "newton_pair"), 1);
EXPECT_EQ(lammps_extract_setting(lmp, "newton_bond"), 1);
if (!verbose) ::testing::internal::CaptureStdout();
lammps_command(lmp, "newton off");
if (!verbose) ::testing::internal::GetCapturedStdout();
EXPECT_EQ(lammps_extract_setting(lmp, "newton_pair"), 0);
EXPECT_EQ(lammps_extract_setting(lmp, "newton_bond"), 0);
if (!verbose) ::testing::internal::CaptureStdout();
lammps_command(lmp, "newton on off");
if (!verbose) ::testing::internal::GetCapturedStdout();
EXPECT_EQ(lammps_extract_setting(lmp, "newton_pair"), 1);
EXPECT_EQ(lammps_extract_setting(lmp, "newton_bond"), 0);
if (!verbose) ::testing::internal::CaptureStdout();
lammps_command(lmp, "newton off on");
if (!verbose) ::testing::internal::GetCapturedStdout();
EXPECT_EQ(lammps_extract_setting(lmp, "newton_pair"), 0);
EXPECT_EQ(lammps_extract_setting(lmp, "newton_bond"), 1);
if (!verbose) ::testing::internal::CaptureStdout();
lammps_command(lmp, "newton on");
if (!verbose) ::testing::internal::GetCapturedStdout();
EXPECT_EQ(lammps_extract_setting(lmp, "newton_pair"), 1);
EXPECT_EQ(lammps_extract_setting(lmp, "newton_bond"), 1);
EXPECT_EQ(lammps_extract_setting(lmp, "ntypes"), 0);
EXPECT_EQ(lammps_extract_setting(lmp, "nbondtypes"), 0);