From 6158802974a30303be4cc3c6e89a71049641ddf7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 14 Mar 2021 17:18:03 -0400 Subject: [PATCH] add support for testing per-atom properties with fix property/atom --- unittest/formats/test_atom_styles.cpp | 1232 +++++++++++++++---------- 1 file changed, 741 insertions(+), 491 deletions(-) diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp index b9957c6732..37d436a7a2 100644 --- a/unittest/formats/test_atom_styles.cpp +++ b/unittest/formats/test_atom_styles.cpp @@ -102,6 +102,9 @@ class AtomStyleTest : public ::testing::Test { protected: LAMMPS *lmp; + // convenience... + void command(const std::string cmd) { lmp->input->one(cmd); } + void SetUp() override { const char *args[] = {"SimpleCommandsTest", "-log", "none", "-echo", "screen", "-nocite"}; @@ -112,10 +115,10 @@ protected: if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_NE(lmp, nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("units real"); - lmp->input->one("dimension 3"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("region box block -4 4 -4 4 -4 4"); + command("units real"); + command("dimension 3"); + command("pair_style zero 4.0"); + command("region box block -4 4 -4 4 -4 4"); if (!verbose) ::testing::internal::GetCapturedStdout(); } @@ -248,6 +251,12 @@ struct AtomState { bool has_nspecial = false; bool has_special = false; + + bool has_extra_grow = false; + bool has_extra_restart = false; + bool has_extra_border = false; + bool has_extra = false; + bool has_sametag = false; }; #define ASSERT_ARRAY_ALLOCATED(ptr, enabled) \ @@ -265,7 +274,7 @@ void ASSERT_ATOM_STATE_EQ(Atom *atom, const AtomState &expected) ASSERT_EQ(atom->natoms, expected.natoms); ASSERT_EQ(atom->nlocal, expected.nlocal); ASSERT_EQ(atom->nghost, expected.nghost); - ASSERT_EQ(atom->nmax, expected.nmax); + ASSERT_EQ(atom->nmax == 1, expected.nmax == 1); ASSERT_EQ(atom->tag_enable, expected.tag_enable); ASSERT_EQ(atom->molecular, expected.molecular); ASSERT_EQ(atom->nellipsoids, expected.nellipsoids); @@ -455,11 +464,11 @@ void ASSERT_ATOM_STATE_EQ(Atom *atom, const AtomState &expected) ASSERT_EQ(atom->nextra_border_max, expected.nextra_border_max); ASSERT_EQ(atom->nextra_store, expected.nextra_store); - ASSERT_ARRAY_ALLOCATED(atom->extra_grow, false); - ASSERT_ARRAY_ALLOCATED(atom->extra_restart, false); - ASSERT_ARRAY_ALLOCATED(atom->extra_border, false); - ASSERT_ARRAY_ALLOCATED(atom->extra, false); - ASSERT_ARRAY_ALLOCATED(atom->sametag, false); + ASSERT_ARRAY_ALLOCATED(atom->extra_grow, expected.has_extra_grow); + ASSERT_ARRAY_ALLOCATED(atom->extra_restart, expected.has_extra_restart); + ASSERT_ARRAY_ALLOCATED(atom->extra_border, expected.has_extra_border); + ASSERT_ARRAY_ALLOCATED(atom->extra, expected.has_extra); + ASSERT_ARRAY_ALLOCATED(atom->sametag, expected.has_sametag); ASSERT_EQ(atom->map_style, expected.map_style); ASSERT_EQ(atom->map_user, expected.map_user); @@ -496,8 +505,8 @@ TEST_F(AtomStyleTest, atomic_after_charge) expected.has_f = true; if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("atom_style charge"); - lmp->input->one("atom_style atomic"); + command("atom_style charge"); + command("atom_style atomic"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_ATOM_STATE_EQ(lmp->atom, expected); @@ -506,15 +515,15 @@ TEST_F(AtomStyleTest, atomic_after_charge) TEST_F(AtomStyleTest, atomic) { if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("atom_modify map hash"); - lmp->input->one("create_box 2 box"); - lmp->input->one("create_atoms 1 single -2.0 2.0 0.1"); - lmp->input->one("create_atoms 1 single -2.0 -2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 -2.0 0.1"); - lmp->input->one("mass 1 4.0"); - lmp->input->one("mass 2 2.4"); - lmp->input->one("pair_coeff * *"); + command("atom_modify map hash"); + command("create_box 2 box"); + command("create_atoms 1 single -2.0 2.0 0.1"); + command("create_atoms 1 single -2.0 -2.0 -0.1"); + command("create_atoms 2 single 2.0 2.0 -0.1"); + command("create_atoms 2 single 2.0 -2.0 0.1"); + command("mass 1 4.0"); + command("mass 2 2.4"); + command("pair_coeff * *"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); @@ -534,14 +543,14 @@ TEST_F(AtomStyleTest, atomic) ASSERT_EQ(lmp->atom->map_user, 2); ASSERT_EQ(lmp->atom->map_tag_max, 4); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("pair_coeff * *"); - lmp->input->one("write_data test_atom_styles.data nocoeff"); - lmp->input->one("clear"); - lmp->input->one("atom_style atomic"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("atom_modify map array"); - lmp->input->one("units real"); - lmp->input->one("read_data test_atom_styles.data"); + command("pair_coeff * *"); + command("write_data test_atom_styles.data nocoeff"); + command("clear"); + command("atom_style atomic"); + command("pair_style zero 4.0"); + command("atom_modify map array"); + command("units real"); + command("read_data test_atom_styles.data"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -591,12 +600,12 @@ TEST_F(AtomStyleTest, atomic) ASSERT_EQ(lmp->atom->tag_consecutive(), 1); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("pair_coeff * *"); - lmp->input->one("group two id 2:4:2"); - lmp->input->one("delete_atoms group two compress no"); - lmp->input->one("write_restart test_atom_styles.restart"); - lmp->input->one("clear"); - lmp->input->one("read_restart test_atom_styles.restart"); + command("pair_coeff * *"); + command("group two id 2:4:2"); + command("delete_atoms group two compress no"); + command("write_restart test_atom_styles.restart"); + command("clear"); + command("read_restart test_atom_styles.restart"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -632,14 +641,14 @@ TEST_F(AtomStyleTest, atomic) ASSERT_EQ(lmp->atom->map_user, 1); ASSERT_EQ(lmp->atom->map_tag_max, 3); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("reset_atom_ids"); + command("reset_atom_ids"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_EQ(lmp->atom->map_tag_max, 2); ASSERT_EQ(lmp->atom->tag_consecutive(), 1); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("comm_style tiled"); - lmp->input->one("change_box all triclinic"); - lmp->input->one("replicate 2 2 2"); + command("comm_style tiled"); + command("change_box all triclinic"); + command("replicate 2 2 2"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_EQ(lmp->atom->map_tag_max, 16); x = lmp->atom->x; @@ -697,7 +706,7 @@ TEST_F(AtomStyleTest, atomic) TEST_F(AtomStyleTest, charge) { if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("atom_style charge"); + command("atom_style charge"); if (!verbose) ::testing::internal::GetCapturedStdout(); AtomState expected; @@ -714,18 +723,18 @@ TEST_F(AtomStyleTest, charge) ASSERT_ATOM_STATE_EQ(lmp->atom, expected); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("create_box 2 box"); - lmp->input->one("create_atoms 1 single -2.0 2.0 0.1"); - lmp->input->one("create_atoms 1 single -2.0 -2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 -2.0 0.1"); - lmp->input->one("mass 1 4.0"); - lmp->input->one("mass 2 2.4"); - lmp->input->one("set atom 1 charge -0.5"); - lmp->input->one("set atom 2 charge 0.5"); - lmp->input->one("set atom 3 charge -1.0"); - lmp->input->one("set atom 4 charge 1.0"); - lmp->input->one("pair_coeff * *"); + command("create_box 2 box"); + command("create_atoms 1 single -2.0 2.0 0.1"); + command("create_atoms 1 single -2.0 -2.0 -0.1"); + command("create_atoms 2 single 2.0 2.0 -0.1"); + command("create_atoms 2 single 2.0 -2.0 0.1"); + command("mass 1 4.0"); + command("mass 2 2.4"); + command("set atom 1 charge -0.5"); + command("set atom 2 charge 0.5"); + command("set atom 3 charge -1.0"); + command("set atom 4 charge 1.0"); + command("pair_coeff * *"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("charge")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -740,14 +749,14 @@ TEST_F(AtomStyleTest, charge) ASSERT_NE(lmp->atom->mass, nullptr); ASSERT_NE(lmp->atom->mass_setflag, nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("pair_coeff * *"); - lmp->input->one("write_data test_atom_styles.data nocoeff"); - lmp->input->one("clear"); - lmp->input->one("atom_style charge"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("units real"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); + command("pair_coeff * *"); + command("write_data test_atom_styles.data nocoeff"); + command("clear"); + command("atom_style charge"); + command("pair_style zero 4.0"); + command("units real"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("charge")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -803,13 +812,13 @@ TEST_F(AtomStyleTest, charge) ASSERT_EQ(lmp->atom->mass_setflag[2], 1); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("pair_coeff * *"); - lmp->input->one("group two id 2:4:2"); - lmp->input->one("delete_atoms group two compress no"); - lmp->input->one("write_restart test_atom_styles.restart"); - lmp->input->one("clear"); + command("pair_coeff * *"); + command("group two id 2:4:2"); + command("delete_atoms group two compress no"); + command("write_restart test_atom_styles.restart"); + command("clear"); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); - lmp->input->one("read_restart test_atom_styles.restart"); + command("read_restart test_atom_styles.restart"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("charge")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -847,9 +856,9 @@ TEST_F(AtomStyleTest, charge) ASSERT_EQ(lmp->atom->mass_setflag[2], 1); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("reset_atom_ids"); - lmp->input->one("change_box all triclinic"); - lmp->input->one("replicate 2 2 2 bbox"); + command("reset_atom_ids"); + command("change_box all triclinic"); + command("replicate 2 2 2 bbox"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_EQ(lmp->atom->map_tag_max, 16); q = lmp->atom->q; @@ -874,7 +883,7 @@ TEST_F(AtomStyleTest, charge) TEST_F(AtomStyleTest, sphere) { if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("atom_style sphere"); + command("atom_style sphere"); if (!verbose) ::testing::internal::GetCapturedStdout(); AtomState expected; @@ -896,20 +905,20 @@ TEST_F(AtomStyleTest, sphere) ASSERT_ATOM_STATE_EQ(lmp->atom, expected); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("create_box 2 box"); - lmp->input->one("create_atoms 1 single -2.0 2.0 0.1"); - lmp->input->one("create_atoms 1 single -2.0 -2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 -2.0 0.1"); - lmp->input->one("set atom 1 mass 4.0"); - lmp->input->one("set atom 2 mass 4.0"); - lmp->input->one("set atom 3 mass 2.4"); - lmp->input->one("set atom 4 mass 2.4"); - lmp->input->one("set atom 1 omega -0.5 0.1 0.1"); - lmp->input->one("set atom 2 omega 0.5 -0.1 -0.1"); - lmp->input->one("set atom 3 omega -1.0 0.0 0.0"); - lmp->input->one("set atom 4 omega 0.0 1.0 0.0"); - lmp->input->one("pair_coeff * *"); + command("create_box 2 box"); + command("create_atoms 1 single -2.0 2.0 0.1"); + command("create_atoms 1 single -2.0 -2.0 -0.1"); + command("create_atoms 2 single 2.0 2.0 -0.1"); + command("create_atoms 2 single 2.0 -2.0 0.1"); + command("set atom 1 mass 4.0"); + command("set atom 2 mass 4.0"); + command("set atom 3 mass 2.4"); + command("set atom 4 mass 2.4"); + command("set atom 1 omega -0.5 0.1 0.1"); + command("set atom 2 omega 0.5 -0.1 -0.1"); + command("set atom 3 omega -1.0 0.0 0.0"); + command("set atom 4 omega 0.0 1.0 0.0"); + command("pair_coeff * *"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("sphere")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -925,14 +934,14 @@ TEST_F(AtomStyleTest, sphere) ASSERT_EQ(lmp->atom->mass_setflag, nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("pair_coeff * *"); - lmp->input->one("write_data test_atom_styles.data nocoeff"); - lmp->input->one("clear"); - lmp->input->one("atom_style sphere"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("units real"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); + command("pair_coeff * *"); + command("write_data test_atom_styles.data nocoeff"); + command("clear"); + command("atom_style sphere"); + command("pair_style zero 4.0"); + command("units real"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("sphere")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -998,15 +1007,15 @@ TEST_F(AtomStyleTest, sphere) EXPECT_NEAR(omega[GETIDX(4)][2], 0.0, EPSILON); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("pair_coeff * *"); - lmp->input->one("group two id 2:4:2"); - lmp->input->one("delete_atoms group two compress no"); - lmp->input->one("write_restart test_atom_styles.restart"); - lmp->input->one("clear"); + command("pair_coeff * *"); + command("group two id 2:4:2"); + command("delete_atoms group two compress no"); + command("write_restart test_atom_styles.restart"); + command("clear"); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); - lmp->input->one("read_restart test_atom_styles.restart"); - lmp->input->one("replicate 1 1 2"); - lmp->input->one("reset_atom_ids"); + command("read_restart test_atom_styles.restart"); + command("replicate 1 1 2"); + command("reset_atom_ids"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("sphere")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -1045,7 +1054,7 @@ TEST_F(AtomStyleTest, ellipsoid) if (!LAMMPS::is_installed_pkg("ASPHERE")) GTEST_SKIP(); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("atom_style ellipsoid"); + command("atom_style ellipsoid"); if (!verbose) ::testing::internal::GetCapturedStdout(); AtomState expected; @@ -1066,23 +1075,23 @@ TEST_F(AtomStyleTest, ellipsoid) ASSERT_ATOM_STATE_EQ(lmp->atom, expected); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("create_box 3 box"); - lmp->input->one("create_atoms 1 single -2.0 2.0 0.1"); - lmp->input->one("create_atoms 1 single -2.0 -2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 -2.0 0.1"); - lmp->input->one("create_atoms 3 single 2.0 2.0 -2.1"); - lmp->input->one("create_atoms 3 single 2.0 -2.0 2.1"); - lmp->input->one("set type 1 mass 4.0"); - lmp->input->one("set type 2 mass 2.4"); - lmp->input->one("set type 3 mass 4.4"); - lmp->input->one("set type 1 shape 1.0 1.0 1.0"); - lmp->input->one("set type 2 shape 3.0 0.8 1.1"); - lmp->input->one("set atom 1 quat 1.0 0.0 0.0 0.0"); - lmp->input->one("set atom 2 quat 0.0 1.0 0.0 90.0"); - lmp->input->one("set atom 3 quat 1.0 0.0 1.0 30.0"); - lmp->input->one("set atom 4 quat 1.0 1.0 1.0 60.0"); - lmp->input->one("pair_coeff * *"); + command("create_box 3 box"); + command("create_atoms 1 single -2.0 2.0 0.1"); + command("create_atoms 1 single -2.0 -2.0 -0.1"); + command("create_atoms 2 single 2.0 2.0 -0.1"); + command("create_atoms 2 single 2.0 -2.0 0.1"); + command("create_atoms 3 single 2.0 2.0 -2.1"); + command("create_atoms 3 single 2.0 -2.0 2.1"); + command("set type 1 mass 4.0"); + command("set type 2 mass 2.4"); + command("set type 3 mass 4.4"); + command("set type 1 shape 1.0 1.0 1.0"); + command("set type 2 shape 3.0 0.8 1.1"); + command("set atom 1 quat 1.0 0.0 0.0 0.0"); + command("set atom 2 quat 0.0 1.0 0.0 90.0"); + command("set atom 3 quat 1.0 0.0 1.0 30.0"); + command("set atom 4 quat 1.0 1.0 1.0 60.0"); + command("pair_coeff * *"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("ellipsoid")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -1112,14 +1121,14 @@ TEST_F(AtomStyleTest, ellipsoid) ASSERT_EQ(lmp->atom->mass_setflag, nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("write_data test_atom_styles.data nocoeff"); - lmp->input->one("clear"); - lmp->input->one("atom_style ellipsoid"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("units real"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); - lmp->input->one("pair_coeff * *"); + command("write_data test_atom_styles.data nocoeff"); + command("clear"); + command("atom_style ellipsoid"); + command("pair_style zero 4.0"); + command("units real"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); + command("pair_coeff * *"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("ellipsoid")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -1231,13 +1240,13 @@ TEST_F(AtomStyleTest, ellipsoid) EXPECT_NEAR(bonus[3].quat[3], sqrt(5.0 / 30.0), EPSILON); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("group two id 2:4:2"); - lmp->input->one("delete_atoms group two compress no"); - lmp->input->one("write_restart test_atom_styles.restart"); - lmp->input->one("clear"); - lmp->input->one("read_restart test_atom_styles.restart"); - lmp->input->one("comm_style tiled"); - lmp->input->one("replicate 1 1 2 bbox"); + command("group two id 2:4:2"); + command("delete_atoms group two compress no"); + command("write_restart test_atom_styles.restart"); + command("clear"); + command("read_restart test_atom_styles.restart"); + command("comm_style tiled"); + command("replicate 1 1 2 bbox"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("ellipsoid")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -1312,7 +1321,7 @@ TEST_F(AtomStyleTest, ellipsoid) EXPECT_NEAR(bonus[3].quat[3], 0.25056280708573159, EPSILON); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("reset_atom_ids"); + command("reset_atom_ids"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_EQ(lmp->atom->nellipsoids, 4); ASSERT_EQ(lmp->atom->tag_consecutive(), 1); @@ -1382,8 +1391,8 @@ TEST_F(AtomStyleTest, line) if (!LAMMPS::is_installed_pkg("ASPHERE")) GTEST_SKIP(); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("dimension 2"); - lmp->input->one("atom_style line"); + command("dimension 2"); + command("atom_style line"); if (!verbose) ::testing::internal::GetCapturedStdout(); AtomState expected; @@ -1407,23 +1416,23 @@ TEST_F(AtomStyleTest, line) ASSERT_ATOM_STATE_EQ(lmp->atom, expected); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("create_box 3 box"); - lmp->input->one("create_atoms 1 single -2.0 2.0 0.0"); - lmp->input->one("create_atoms 1 single -2.0 -2.0 0.0"); - lmp->input->one("create_atoms 2 single 2.0 2.0 0.0"); - lmp->input->one("create_atoms 2 single 2.0 -2.0 0.0"); - lmp->input->one("create_atoms 3 single 3.0 0.0 0.0"); - lmp->input->one("create_atoms 3 single 0.0 -3.0 0.0"); - lmp->input->one("set type 1 mass 4.0"); - lmp->input->one("set type 2 mass 2.4"); - lmp->input->one("set type 3 mass 4.4"); - lmp->input->one("set type 1 length 2.0"); - lmp->input->one("set type 2 length 3.0"); - lmp->input->one("set atom 1 theta 0.0"); - lmp->input->one("set atom 2 theta 90.0"); - lmp->input->one("set atom 3 theta 30.0"); - lmp->input->one("set atom 4 theta 60.0"); - lmp->input->one("pair_coeff * *"); + command("create_box 3 box"); + command("create_atoms 1 single -2.0 2.0 0.0"); + command("create_atoms 1 single -2.0 -2.0 0.0"); + command("create_atoms 2 single 2.0 2.0 0.0"); + command("create_atoms 2 single 2.0 -2.0 0.0"); + command("create_atoms 3 single 3.0 0.0 0.0"); + command("create_atoms 3 single 0.0 -3.0 0.0"); + command("set type 1 mass 4.0"); + command("set type 2 mass 2.4"); + command("set type 3 mass 4.4"); + command("set type 1 length 2.0"); + command("set type 2 length 3.0"); + command("set atom 1 theta 0.0"); + command("set atom 2 theta 90.0"); + command("set atom 3 theta 30.0"); + command("set atom 4 theta 60.0"); + command("pair_coeff * *"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("line")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -1441,14 +1450,14 @@ TEST_F(AtomStyleTest, line) ASSERT_EQ(lmp->atom->mass_setflag, nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("write_data test_atom_styles.data nocoeff"); - lmp->input->one("clear"); - lmp->input->one("dimension 2"); - lmp->input->one("atom_style line"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("units real"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); + command("write_data test_atom_styles.data nocoeff"); + command("clear"); + command("dimension 2"); + command("atom_style line"); + command("pair_style zero 4.0"); + command("units real"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("line")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -1540,15 +1549,15 @@ TEST_F(AtomStyleTest, line) EXPECT_NEAR(bonus[3].theta, MathConst::MY_PI / 3.0, EPSILON); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("pair_coeff * *"); - lmp->input->one("group two id 2:4:2"); - lmp->input->one("delete_atoms group two compress no"); - lmp->input->one("write_restart test_atom_styles.restart"); - lmp->input->one("clear"); - lmp->input->one("read_restart test_atom_styles.restart"); - lmp->input->one("comm_style tiled"); - lmp->input->one("change_box all triclinic"); - lmp->input->one("replicate 1 2 1 bbox"); + command("pair_coeff * *"); + command("group two id 2:4:2"); + command("delete_atoms group two compress no"); + command("write_restart test_atom_styles.restart"); + command("clear"); + command("read_restart test_atom_styles.restart"); + command("comm_style tiled"); + command("change_box all triclinic"); + command("replicate 1 2 1 bbox"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("line")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -1603,7 +1612,7 @@ TEST_F(AtomStyleTest, line) EXPECT_NEAR(bonus[3].theta, MathConst::MY_PI / 6.0, EPSILON); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("reset_atom_ids"); + command("reset_atom_ids"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_EQ(lmp->atom->nlines, 4); ASSERT_EQ(lmp->atom->tag_consecutive(), 1); @@ -1653,7 +1662,7 @@ TEST_F(AtomStyleTest, tri) if (!LAMMPS::is_installed_pkg("ASPHERE")) GTEST_SKIP(); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("atom_style tri"); + command("atom_style tri"); if (!verbose) ::testing::internal::GetCapturedStdout(); AtomState expected; @@ -1678,23 +1687,23 @@ TEST_F(AtomStyleTest, tri) ASSERT_ATOM_STATE_EQ(lmp->atom, expected); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("create_box 3 box"); - lmp->input->one("create_atoms 1 single -2.0 2.0 0.1"); - lmp->input->one("create_atoms 1 single -2.0 -2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 -2.0 0.1"); - lmp->input->one("create_atoms 3 single 2.0 2.0 -2.1"); - lmp->input->one("create_atoms 3 single 2.0 -2.0 2.1"); - lmp->input->one("set type 1 mass 4.0"); - lmp->input->one("set type 2 mass 2.4"); - lmp->input->one("set type 3 mass 4.4"); - lmp->input->one("set type 1 tri 1.0"); - lmp->input->one("set type 2 tri 1.5"); - lmp->input->one("set atom 1 quat 1.0 0.0 0.0 0.0"); - lmp->input->one("set atom 2 quat 0.0 1.0 0.0 90.0"); - lmp->input->one("set atom 3 quat 1.0 0.0 1.0 30.0"); - lmp->input->one("set atom 4 quat 1.0 1.0 1.0 60.0"); - lmp->input->one("pair_coeff * *"); + command("create_box 3 box"); + command("create_atoms 1 single -2.0 2.0 0.1"); + command("create_atoms 1 single -2.0 -2.0 -0.1"); + command("create_atoms 2 single 2.0 2.0 -0.1"); + command("create_atoms 2 single 2.0 -2.0 0.1"); + command("create_atoms 3 single 2.0 2.0 -2.1"); + command("create_atoms 3 single 2.0 -2.0 2.1"); + command("set type 1 mass 4.0"); + command("set type 2 mass 2.4"); + command("set type 3 mass 4.4"); + command("set type 1 tri 1.0"); + command("set type 2 tri 1.5"); + command("set atom 1 quat 1.0 0.0 0.0 0.0"); + command("set atom 2 quat 0.0 1.0 0.0 90.0"); + command("set atom 3 quat 1.0 0.0 1.0 30.0"); + command("set atom 4 quat 1.0 1.0 1.0 60.0"); + command("pair_coeff * *"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("tri")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -1724,14 +1733,14 @@ TEST_F(AtomStyleTest, tri) ASSERT_EQ(lmp->atom->mass_setflag, nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("write_data test_atom_styles.data nocoeff"); - lmp->input->one("clear"); - lmp->input->one("atom_style tri"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("units real"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); - lmp->input->one("pair_coeff * *"); + command("write_data test_atom_styles.data nocoeff"); + command("clear"); + command("atom_style tri"); + command("pair_style zero 4.0"); + command("units real"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); + command("pair_coeff * *"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("tri")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -1886,13 +1895,13 @@ TEST_F(AtomStyleTest, tri) EXPECT_NEAR(bonus[3].c3[2], -0.32808266428854477, EPSILON); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("group two id 2:4:2"); - lmp->input->one("delete_atoms group two compress no"); - lmp->input->one("write_restart test_atom_styles.restart"); - lmp->input->one("clear"); - lmp->input->one("read_restart test_atom_styles.restart"); - lmp->input->one("change_box all triclinic"); - lmp->input->one("replicate 1 1 2"); + command("group two id 2:4:2"); + command("delete_atoms group two compress no"); + command("write_restart test_atom_styles.restart"); + command("clear"); + command("read_restart test_atom_styles.restart"); + command("change_box all triclinic"); + command("replicate 1 1 2"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("tri")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -2012,7 +2021,7 @@ TEST_F(AtomStyleTest, tri) EXPECT_NEAR(bonus[3].c3[2], -0.15731490073748589, EPSILON); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("reset_atom_ids"); + command("reset_atom_ids"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_EQ(lmp->atom->ntris, 4); ASSERT_EQ(lmp->atom->tag_consecutive(), 1); @@ -2057,7 +2066,7 @@ TEST_F(AtomStyleTest, body_nparticle) if (!LAMMPS::is_installed_pkg("BODY")) GTEST_SKIP(); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("atom_style body nparticle 2 4"); + command("atom_style body nparticle 2 4"); if (!verbose) ::testing::internal::GetCapturedStdout(); AtomState expected; @@ -2122,16 +2131,16 @@ TEST_F(AtomStyleTest, body_nparticle) fputs(data_file, fp); fclose(fp); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data input_atom_styles.data"); - lmp->input->one("create_atoms 3 single 2.0 2.0 -2.1"); - lmp->input->one("create_atoms 3 single 2.0 -2.0 2.1"); - lmp->input->one("set type 3 mass 4.4"); - lmp->input->one("set atom 1 quat 1.0 0.0 0.0 0.0"); - lmp->input->one("set atom 2 quat 0.0 1.0 0.0 90.0"); - lmp->input->one("set atom 3 quat 1.0 0.0 1.0 30.0"); - lmp->input->one("set atom 4 quat 1.0 1.0 1.0 60.0"); - lmp->input->one("pair_coeff * *"); + command("atom_modify map array"); + command("read_data input_atom_styles.data"); + command("create_atoms 3 single 2.0 2.0 -2.1"); + command("create_atoms 3 single 2.0 -2.0 2.1"); + command("set type 3 mass 4.4"); + command("set atom 1 quat 1.0 0.0 0.0 0.0"); + command("set atom 2 quat 0.0 1.0 0.0 90.0"); + command("set atom 3 quat 1.0 0.0 1.0 30.0"); + command("set atom 4 quat 1.0 1.0 1.0 60.0"); + command("pair_coeff * *"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("body")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -2299,14 +2308,14 @@ TEST_F(AtomStyleTest, body_nparticle) ASSERT_NE(bonus[3].dvalue, nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("write_data test_atom_styles.data nocoeff"); - lmp->input->one("clear"); - lmp->input->one("atom_style body nparticle 2 4"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("units real"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); - lmp->input->one("pair_coeff * *"); + command("write_data test_atom_styles.data nocoeff"); + command("clear"); + command("atom_style body nparticle 2 4"); + command("pair_style zero 4.0"); + command("units real"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); + command("pair_coeff * *"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("body")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -2472,13 +2481,13 @@ TEST_F(AtomStyleTest, body_nparticle) ASSERT_NE(bonus[3].dvalue, nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("group two id 2:4:2"); - lmp->input->one("delete_atoms group two compress no"); - lmp->input->one("write_restart test_atom_styles.restart"); - lmp->input->one("clear"); - lmp->input->one("read_restart test_atom_styles.restart"); - lmp->input->one("comm_style tiled"); - lmp->input->one("replicate 1 1 2"); + command("group two id 2:4:2"); + command("delete_atoms group two compress no"); + command("write_restart test_atom_styles.restart"); + command("clear"); + command("read_restart test_atom_styles.restart"); + command("comm_style tiled"); + command("replicate 1 1 2"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("body")); avec = (AtomVecBody *)lmp->atom->avec; @@ -2587,7 +2596,7 @@ TEST_F(AtomStyleTest, body_nparticle) ASSERT_NE(bonus[3].dvalue, nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("reset_atom_ids"); + command("reset_atom_ids"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_EQ(lmp->atom->nbodies, 4); ASSERT_EQ(lmp->atom->tag_consecutive(), 1); @@ -2625,9 +2634,9 @@ TEST_F(AtomStyleTest, template) if (!LAMMPS::is_installed_pkg("MOLECULE")) GTEST_SKIP(); create_molecule_files(); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); - lmp->input->one("atom_style template twomols"); - lmp->input->one("newton on"); + command("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); + command("atom_style template twomols"); + command("newton on"); if (!verbose) ::testing::internal::GetCapturedStdout(); AtomState expected; @@ -2651,23 +2660,23 @@ TEST_F(AtomStyleTest, template) ASSERT_ATOM_STATE_EQ(lmp->atom, expected); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("create_box 4 box bond/types 2 angle/types 2 "); - lmp->input->one("create_atoms 0 single -2.0 2.0 0.1 mol twomols 65234"); - lmp->input->one("create_atoms 0 single -2.0 -2.0 -0.1 mol twomols 62346"); - lmp->input->one("create_atoms 0 single 2.0 2.0 -0.1 mol twomols 61354"); - lmp->input->one("create_atoms 3 single 2.0 -2.0 0.1"); - lmp->input->one("create_atoms 3 single 2.0 2.0 -2.1"); - lmp->input->one("create_atoms 4 single 2.0 -2.0 2.1"); - lmp->input->one("mass 1 16.0"); - lmp->input->one("mass 2 1.0"); - lmp->input->one("mass 3 12.0"); - lmp->input->one("mass 4 16.0"); - lmp->input->one("bond_style zero"); - lmp->input->one("bond_coeff 1 1.0"); - lmp->input->one("bond_coeff 2 1.16"); - lmp->input->one("angle_style zero"); - lmp->input->one("angle_coeff * 109.0"); - lmp->input->one("pair_coeff * *"); + command("create_box 4 box bond/types 2 angle/types 2 "); + command("create_atoms 0 single -2.0 2.0 0.1 mol twomols 65234"); + command("create_atoms 0 single -2.0 -2.0 -0.1 mol twomols 62346"); + command("create_atoms 0 single 2.0 2.0 -0.1 mol twomols 61354"); + command("create_atoms 3 single 2.0 -2.0 0.1"); + command("create_atoms 3 single 2.0 2.0 -2.1"); + command("create_atoms 4 single 2.0 -2.0 2.1"); + command("mass 1 16.0"); + command("mass 2 1.0"); + command("mass 3 12.0"); + command("mass 4 16.0"); + command("bond_style zero"); + command("bond_coeff 1 1.0"); + command("bond_coeff 2 1.16"); + command("angle_style zero"); + command("angle_coeff * 109.0"); + command("pair_coeff * *"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("template")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -2699,17 +2708,17 @@ TEST_F(AtomStyleTest, template) ASSERT_NE(lmp->atom->mass_setflag, nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("write_data test_atom_styles.data"); - lmp->input->one("clear"); - lmp->input->one("units real"); - lmp->input->one("newton off"); - lmp->input->one("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); - lmp->input->one("atom_style template twomols"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("bond_style zero"); - lmp->input->one("angle_style zero"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); + command("write_data test_atom_styles.data"); + command("clear"); + command("units real"); + command("newton off"); + command("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); + command("atom_style template twomols"); + command("pair_style zero 4.0"); + command("bond_style zero"); + command("angle_style zero"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("template")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -2773,15 +2782,15 @@ TEST_F(AtomStyleTest, template) ASSERT_EQ(molatom[GETIDX(12)], -1); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("clear"); - lmp->input->one("units real"); - lmp->input->one("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); - lmp->input->one("atom_style template twomols"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("bond_style zero"); - lmp->input->one("angle_style zero"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); + command("clear"); + command("units real"); + command("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); + command("atom_style template twomols"); + command("pair_style zero 4.0"); + command("bond_style zero"); + command("angle_style zero"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("template")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -2895,13 +2904,13 @@ TEST_F(AtomStyleTest, template) ASSERT_EQ(type[GETIDX(12)], 4); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("group two id 7:10"); - lmp->input->one("delete_atoms group two compress no"); - lmp->input->one("write_restart test_atom_styles.restart"); - lmp->input->one("clear"); - lmp->input->one("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); - lmp->input->one("read_restart test_atom_styles.restart"); - lmp->input->one("replicate 1 1 2 bbox"); + command("group two id 7:10"); + command("delete_atoms group two compress no"); + command("write_restart test_atom_styles.restart"); + command("clear"); + command("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); + command("read_restart test_atom_styles.restart"); + command("replicate 1 1 2 bbox"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("template")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -2973,7 +2982,7 @@ TEST_F(AtomStyleTest, template) ASSERT_EQ(molatom[GETIDX(24)], -1); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("reset_atom_ids"); + command("reset_atom_ids"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_EQ(lmp->atom->tag_consecutive(), 1); ASSERT_EQ(lmp->atom->map_tag_max, 16); @@ -3021,9 +3030,9 @@ TEST_F(AtomStyleTest, template_charge) if (!LAMMPS::is_installed_pkg("MOLECULE")) GTEST_SKIP(); create_molecule_files(); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); - lmp->input->one("atom_style hybrid template twomols charge"); - lmp->input->one("newton on"); + command("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); + command("atom_style hybrid template twomols charge"); + command("newton on"); if (!verbose) ::testing::internal::GetCapturedStdout(); AtomState expected; @@ -3056,26 +3065,26 @@ TEST_F(AtomStyleTest, template_charge) ASSERT_NE(hybrid->styles[1], nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("create_box 4 box bond/types 2 angle/types 2 "); - lmp->input->one("create_atoms 0 single -2.0 2.0 0.1 mol twomols 65234"); - lmp->input->one("create_atoms 0 single -2.0 -2.0 -0.1 mol twomols 62346"); - lmp->input->one("create_atoms 0 single 2.0 2.0 -0.1 mol twomols 61354"); - lmp->input->one("create_atoms 3 single 2.0 -2.0 0.1"); - lmp->input->one("create_atoms 3 single 2.0 2.0 -2.1"); - lmp->input->one("create_atoms 4 single 2.0 -2.0 2.1"); - lmp->input->one("mass 1 16.0"); - lmp->input->one("mass 2 1.0"); - lmp->input->one("mass 3 12.0"); - lmp->input->one("mass 4 16.0"); - lmp->input->one("set atom 10 charge 0.7"); - lmp->input->one("set atom 11 charge -0.35"); - lmp->input->one("set atom 12 charge -0.35"); - lmp->input->one("bond_style zero"); - lmp->input->one("bond_coeff 1 1.0"); - lmp->input->one("bond_coeff 2 1.16"); - lmp->input->one("angle_style zero"); - lmp->input->one("angle_coeff * 109.0"); - lmp->input->one("pair_coeff * *"); + command("create_box 4 box bond/types 2 angle/types 2 "); + command("create_atoms 0 single -2.0 2.0 0.1 mol twomols 65234"); + command("create_atoms 0 single -2.0 -2.0 -0.1 mol twomols 62346"); + command("create_atoms 0 single 2.0 2.0 -0.1 mol twomols 61354"); + command("create_atoms 3 single 2.0 -2.0 0.1"); + command("create_atoms 3 single 2.0 2.0 -2.1"); + command("create_atoms 4 single 2.0 -2.0 2.1"); + command("mass 1 16.0"); + command("mass 2 1.0"); + command("mass 3 12.0"); + command("mass 4 16.0"); + command("set atom 10 charge 0.7"); + command("set atom 11 charge -0.35"); + command("set atom 12 charge -0.35"); + command("bond_style zero"); + command("bond_coeff 1 1.0"); + command("bond_coeff 2 1.16"); + command("angle_style zero"); + command("angle_coeff * 109.0"); + command("pair_coeff * *"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_NE(lmp->atom->avec, nullptr); hybrid = (AtomVecHybrid *)lmp->atom->avec; @@ -3115,17 +3124,17 @@ TEST_F(AtomStyleTest, template_charge) ASSERT_NE(lmp->atom->mass_setflag, nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("write_data test_atom_styles.data"); - lmp->input->one("clear"); - lmp->input->one("units real"); - lmp->input->one("newton off"); - lmp->input->one("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); - lmp->input->one("atom_style hybrid template twomols charge"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("bond_style zero"); - lmp->input->one("angle_style zero"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); + command("write_data test_atom_styles.data"); + command("clear"); + command("units real"); + command("newton off"); + command("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); + command("atom_style hybrid template twomols charge"); + command("pair_style zero 4.0"); + command("bond_style zero"); + command("angle_style zero"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("hybrid")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -3189,15 +3198,15 @@ TEST_F(AtomStyleTest, template_charge) ASSERT_EQ(molatom[GETIDX(12)], -1); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("clear"); - lmp->input->one("units real"); - lmp->input->one("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); - lmp->input->one("atom_style hybrid template twomols charge"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("bond_style zero"); - lmp->input->one("angle_style zero"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); + command("clear"); + command("units real"); + command("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); + command("atom_style hybrid template twomols charge"); + command("pair_style zero 4.0"); + command("bond_style zero"); + command("angle_style zero"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("hybrid")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -3324,13 +3333,13 @@ TEST_F(AtomStyleTest, template_charge) ASSERT_EQ(type[GETIDX(12)], 4); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("group two id 7:10"); - lmp->input->one("delete_atoms group two compress no"); - lmp->input->one("write_restart test_atom_styles.restart"); - lmp->input->one("clear"); - lmp->input->one("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); - lmp->input->one("read_restart test_atom_styles.restart"); - lmp->input->one("replicate 1 1 2 bbox"); + command("group two id 7:10"); + command("delete_atoms group two compress no"); + command("write_restart test_atom_styles.restart"); + command("clear"); + command("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); + command("read_restart test_atom_styles.restart"); + command("replicate 1 1 2 bbox"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("hybrid")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -3402,7 +3411,7 @@ TEST_F(AtomStyleTest, template_charge) ASSERT_EQ(molatom[GETIDX(24)], -1); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("reset_atom_ids"); + command("reset_atom_ids"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_EQ(lmp->atom->tag_consecutive(), 1); ASSERT_EQ(lmp->atom->map_tag_max, 16); @@ -3450,8 +3459,8 @@ TEST_F(AtomStyleTest, bond) if (!LAMMPS::is_installed_pkg("MOLECULE")) GTEST_SKIP(); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("atom_style bond"); - lmp->input->one("newton on"); + command("atom_style bond"); + command("newton on"); if (!verbose) ::testing::internal::GetCapturedStdout(); AtomState expected; @@ -3473,25 +3482,25 @@ TEST_F(AtomStyleTest, bond) ASSERT_ATOM_STATE_EQ(lmp->atom, expected); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("create_box 3 box bond/types 2 " - "extra/bond/per/atom 2 extra/special/per/atom 4"); - lmp->input->one("create_atoms 1 single -2.0 2.0 0.1"); - lmp->input->one("create_atoms 1 single -2.0 -2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 -2.0 0.1"); - lmp->input->one("create_atoms 3 single 2.0 2.0 -2.1"); - lmp->input->one("create_atoms 3 single 2.0 -2.0 2.1"); - lmp->input->one("mass 1 4.0"); - lmp->input->one("mass 2 2.4"); - lmp->input->one("mass 3 4.4"); - lmp->input->one("bond_style zero"); - lmp->input->one("bond_coeff * 4.0"); - lmp->input->one("pair_coeff * *"); - lmp->input->one("create_bonds single/bond 1 1 5"); - lmp->input->one("create_bonds single/bond 1 1 3"); - lmp->input->one("create_bonds single/bond 2 3 5"); - lmp->input->one("create_bonds single/bond 2 3 6"); - lmp->input->one("create_bonds single/bond 2 5 6"); + command("create_box 3 box bond/types 2 " + "extra/bond/per/atom 2 extra/special/per/atom 4"); + command("create_atoms 1 single -2.0 2.0 0.1"); + command("create_atoms 1 single -2.0 -2.0 -0.1"); + command("create_atoms 2 single 2.0 2.0 -0.1"); + command("create_atoms 2 single 2.0 -2.0 0.1"); + command("create_atoms 3 single 2.0 2.0 -2.1"); + command("create_atoms 3 single 2.0 -2.0 2.1"); + command("mass 1 4.0"); + command("mass 2 2.4"); + command("mass 3 4.4"); + command("bond_style zero"); + command("bond_coeff * 4.0"); + command("pair_coeff * *"); + command("create_bonds single/bond 1 1 5"); + command("create_bonds single/bond 1 1 3"); + command("create_bonds single/bond 2 3 5"); + command("create_bonds single/bond 2 3 6"); + command("create_bonds single/bond 2 5 6"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("bond")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -3526,17 +3535,17 @@ TEST_F(AtomStyleTest, bond) lmp->atom->bond_type[GETIDX(5)][0] *= -1; if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("write_data test_atom_styles.data nocoeff"); - lmp->input->one("clear"); - lmp->input->one("units real"); - lmp->input->one("newton off"); - lmp->input->one("atom_style bond"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("bond_style zero"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); - lmp->input->one("pair_coeff * *"); - lmp->input->one("bond_coeff * 4.0"); + command("write_data test_atom_styles.data nocoeff"); + command("clear"); + command("units real"); + command("newton off"); + command("atom_style bond"); + command("pair_style zero 4.0"); + command("bond_style zero"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); + command("pair_coeff * *"); + command("bond_coeff * 4.0"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("bond")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -3587,15 +3596,15 @@ TEST_F(AtomStyleTest, bond) ASSERT_EQ(bond_atom[GETIDX(6)][1], 5); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("clear"); - lmp->input->one("units real"); - lmp->input->one("atom_style bond"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("bond_style zero"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); - lmp->input->one("pair_coeff * *"); - lmp->input->one("bond_coeff * 4.0"); + command("clear"); + command("units real"); + command("atom_style bond"); + command("pair_style zero 4.0"); + command("bond_style zero"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); + command("pair_coeff * *"); + command("bond_coeff * 4.0"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("bond")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -3685,13 +3694,13 @@ TEST_F(AtomStyleTest, bond) lmp->atom->bond_type[GETIDX(5)][0] *= -1; if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("pair_coeff * *"); - lmp->input->one("group two id 2:4:2"); - lmp->input->one("delete_atoms group two compress no"); - lmp->input->one("write_restart test_atom_styles.restart"); - lmp->input->one("clear"); - lmp->input->one("read_restart test_atom_styles.restart"); - lmp->input->one("replicate 1 1 2 bbox"); + command("pair_coeff * *"); + command("group two id 2:4:2"); + command("delete_atoms group two compress no"); + command("write_restart test_atom_styles.restart"); + command("clear"); + command("read_restart test_atom_styles.restart"); + command("replicate 1 1 2 bbox"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("bond")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -3747,8 +3756,8 @@ TEST_F(AtomStyleTest, bond) ASSERT_EQ(bond_type[GETIDX(11)][0], 2); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("delete_bonds all bond 2"); - lmp->input->one("reset_atom_ids"); + command("delete_bonds all bond 2"); + command("reset_atom_ids"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_EQ(lmp->atom->tag_consecutive(), 1); ASSERT_EQ(lmp->atom->map_tag_max, 8); @@ -3798,8 +3807,8 @@ TEST_F(AtomStyleTest, angle) if (!LAMMPS::is_installed_pkg("MOLECULE")) GTEST_SKIP(); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("atom_style angle"); - lmp->input->one("newton on"); + command("atom_style angle"); + command("newton on"); if (!verbose) ::testing::internal::GetCapturedStdout(); AtomState expected; @@ -3822,30 +3831,30 @@ TEST_F(AtomStyleTest, angle) ASSERT_ATOM_STATE_EQ(lmp->atom, expected); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("create_box 3 box bond/types 2 angle/types 2 " - "extra/bond/per/atom 2 extra/angle/per/atom 1 " - "extra/special/per/atom 4"); - lmp->input->one("create_atoms 1 single -2.0 2.0 0.1"); - lmp->input->one("create_atoms 1 single -2.0 -2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 -2.0 0.1"); - lmp->input->one("create_atoms 3 single 2.0 2.0 -2.1"); - lmp->input->one("create_atoms 3 single 2.0 -2.0 2.1"); - lmp->input->one("mass 1 4.0"); - lmp->input->one("mass 2 2.4"); - lmp->input->one("mass 3 4.4"); - lmp->input->one("pair_coeff * *"); - lmp->input->one("bond_style zero"); - lmp->input->one("bond_coeff * 4.0"); - lmp->input->one("angle_style zero"); - lmp->input->one("angle_coeff * 90.0"); - lmp->input->one("create_bonds single/bond 1 1 3"); - lmp->input->one("create_bonds single/bond 1 1 5"); - lmp->input->one("create_bonds single/bond 2 3 5"); - lmp->input->one("create_bonds single/bond 2 3 6"); - lmp->input->one("create_bonds single/bond 2 5 6"); - lmp->input->one("create_bonds single/angle 1 1 3 5"); - lmp->input->one("create_bonds single/angle 2 3 5 6"); + command("create_box 3 box bond/types 2 angle/types 2 " + "extra/bond/per/atom 2 extra/angle/per/atom 1 " + "extra/special/per/atom 4"); + command("create_atoms 1 single -2.0 2.0 0.1"); + command("create_atoms 1 single -2.0 -2.0 -0.1"); + command("create_atoms 2 single 2.0 2.0 -0.1"); + command("create_atoms 2 single 2.0 -2.0 0.1"); + command("create_atoms 3 single 2.0 2.0 -2.1"); + command("create_atoms 3 single 2.0 -2.0 2.1"); + command("mass 1 4.0"); + command("mass 2 2.4"); + command("mass 3 4.4"); + command("pair_coeff * *"); + command("bond_style zero"); + command("bond_coeff * 4.0"); + command("angle_style zero"); + command("angle_coeff * 90.0"); + command("create_bonds single/bond 1 1 3"); + command("create_bonds single/bond 1 1 5"); + command("create_bonds single/bond 2 3 5"); + command("create_bonds single/bond 2 3 6"); + command("create_bonds single/bond 2 5 6"); + command("create_bonds single/angle 1 1 3 5"); + command("create_bonds single/angle 2 3 5 6"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("angle")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -3882,19 +3891,19 @@ TEST_F(AtomStyleTest, angle) lmp->atom->angle_type[GETIDX(5)][0] *= -1; if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("write_data test_atom_styles.data nocoeff"); - lmp->input->one("clear"); - lmp->input->one("units real"); - lmp->input->one("newton off"); - lmp->input->one("atom_style angle"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("bond_style zero"); - lmp->input->one("angle_style zero"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); - lmp->input->one("pair_coeff * *"); - lmp->input->one("bond_coeff * 4.0"); - lmp->input->one("angle_coeff * 90.0"); + command("write_data test_atom_styles.data nocoeff"); + command("clear"); + command("units real"); + command("newton off"); + command("atom_style angle"); + command("pair_style zero 4.0"); + command("bond_style zero"); + command("angle_style zero"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); + command("pair_coeff * *"); + command("bond_coeff * 4.0"); + command("angle_coeff * 90.0"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("angle")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -3980,15 +3989,15 @@ TEST_F(AtomStyleTest, angle) ASSERT_EQ(angle_atom3[GETIDX(6)][0], 6); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("clear"); - lmp->input->one("units real"); - lmp->input->one("atom_style angle"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("bond_style zero"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); - lmp->input->one("pair_coeff * *"); - lmp->input->one("bond_coeff * 4.0"); + command("clear"); + command("units real"); + command("atom_style angle"); + command("pair_style zero 4.0"); + command("bond_style zero"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); + command("pair_coeff * *"); + command("bond_coeff * 4.0"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("angle")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -4079,13 +4088,13 @@ TEST_F(AtomStyleTest, angle) ASSERT_EQ(angle_type[GETIDX(5)][0], 2); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("pair_coeff * *"); - lmp->input->one("group two id 2:4:2"); - lmp->input->one("delete_atoms group two compress no"); - lmp->input->one("write_restart test_atom_styles.restart"); - lmp->input->one("clear"); - lmp->input->one("read_restart test_atom_styles.restart"); - lmp->input->one("replicate 1 1 2"); + command("pair_coeff * *"); + command("group two id 2:4:2"); + command("delete_atoms group two compress no"); + command("write_restart test_atom_styles.restart"); + command("clear"); + command("read_restart test_atom_styles.restart"); + command("replicate 1 1 2"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("angle")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -4124,8 +4133,8 @@ TEST_F(AtomStyleTest, angle) ASSERT_EQ(angle_type[GETIDX(11)][0], 2); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("delete_bonds all angle 2"); - lmp->input->one("reset_atom_ids"); + command("delete_bonds all angle 2"); + command("reset_atom_ids"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_EQ(lmp->atom->tag_consecutive(), 1); ASSERT_EQ(lmp->atom->map_tag_max, 8); @@ -4159,7 +4168,7 @@ TEST_F(AtomStyleTest, full_ellipsoid) if (!LAMMPS::is_installed_pkg("MOLECULE")) GTEST_SKIP(); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("atom_style hybrid full ellipsoid"); + command("atom_style hybrid full ellipsoid"); if (!verbose) ::testing::internal::GetCapturedStdout(); AtomState expected; @@ -4197,40 +4206,40 @@ TEST_F(AtomStyleTest, full_ellipsoid) ASSERT_NE(hybrid->styles[1], nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("create_box 3 box bond/types 2 " - "extra/bond/per/atom 2 extra/special/per/atom 4"); - lmp->input->one("create_atoms 1 single -2.0 2.0 0.1"); - lmp->input->one("create_atoms 1 single -2.0 -2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 2.0 -0.1"); - lmp->input->one("create_atoms 2 single 2.0 -2.0 0.1"); - lmp->input->one("create_atoms 3 single 2.0 2.0 -2.1"); - lmp->input->one("create_atoms 3 single 2.0 -2.0 2.1"); - lmp->input->one("set type 1 mass 4.0"); - lmp->input->one("set type 2 mass 2.4"); - lmp->input->one("set type 3 mass 4.4"); - lmp->input->one("mass 1 4.0"); - lmp->input->one("mass 2 2.4"); - lmp->input->one("mass 3 4.4"); - lmp->input->one("set type 1 shape 1.0 1.0 1.0"); - lmp->input->one("set type 2 shape 3.0 0.8 1.1"); - lmp->input->one("set atom 1 quat 1.0 0.0 0.0 0.0"); - lmp->input->one("set atom 2 quat 0.0 1.0 0.0 90.0"); - lmp->input->one("set atom 3 quat 1.0 0.0 1.0 30.0"); - lmp->input->one("set atom 4 quat 1.0 1.0 1.0 60.0"); - lmp->input->one("set atom 1 charge -0.5"); - lmp->input->one("set atom 2 charge 0.5"); - lmp->input->one("set atom 3 charge -1.0"); - lmp->input->one("set atom 4 charge 1.0"); - lmp->input->one("set atom 5 charge 2.0"); - lmp->input->one("set atom 6 charge -2.0"); - lmp->input->one("bond_style zero"); - lmp->input->one("bond_coeff * 4.0"); - lmp->input->one("pair_coeff * *"); - lmp->input->one("create_bonds single/bond 1 1 5"); - lmp->input->one("create_bonds single/bond 1 1 3"); - lmp->input->one("create_bonds single/bond 2 3 5"); - lmp->input->one("create_bonds single/bond 2 3 6"); - lmp->input->one("create_bonds single/bond 2 5 6"); + command("create_box 3 box bond/types 2 " + "extra/bond/per/atom 2 extra/special/per/atom 4"); + command("create_atoms 1 single -2.0 2.0 0.1"); + command("create_atoms 1 single -2.0 -2.0 -0.1"); + command("create_atoms 2 single 2.0 2.0 -0.1"); + command("create_atoms 2 single 2.0 -2.0 0.1"); + command("create_atoms 3 single 2.0 2.0 -2.1"); + command("create_atoms 3 single 2.0 -2.0 2.1"); + command("set type 1 mass 4.0"); + command("set type 2 mass 2.4"); + command("set type 3 mass 4.4"); + command("mass 1 4.0"); + command("mass 2 2.4"); + command("mass 3 4.4"); + command("set type 1 shape 1.0 1.0 1.0"); + command("set type 2 shape 3.0 0.8 1.1"); + command("set atom 1 quat 1.0 0.0 0.0 0.0"); + command("set atom 2 quat 0.0 1.0 0.0 90.0"); + command("set atom 3 quat 1.0 0.0 1.0 30.0"); + command("set atom 4 quat 1.0 1.0 1.0 60.0"); + command("set atom 1 charge -0.5"); + command("set atom 2 charge 0.5"); + command("set atom 3 charge -1.0"); + command("set atom 4 charge 1.0"); + command("set atom 5 charge 2.0"); + command("set atom 6 charge -2.0"); + command("bond_style zero"); + command("bond_coeff * 4.0"); + command("pair_coeff * *"); + command("create_bonds single/bond 1 1 5"); + command("create_bonds single/bond 1 1 3"); + command("create_bonds single/bond 2 3 5"); + command("create_bonds single/bond 2 3 6"); + command("create_bonds single/bond 2 5 6"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("hybrid")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -4262,16 +4271,16 @@ TEST_F(AtomStyleTest, full_ellipsoid) ASSERT_NE(lmp->atom->mass_setflag, nullptr); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("write_data test_atom_styles.data nocoeff"); - lmp->input->one("clear"); - lmp->input->one("units real"); - lmp->input->one("atom_style hybrid full ellipsoid"); - lmp->input->one("pair_style zero 4.0"); - lmp->input->one("bond_style zero"); - lmp->input->one("atom_modify map array"); - lmp->input->one("read_data test_atom_styles.data"); - lmp->input->one("pair_coeff * *"); - lmp->input->one("bond_coeff * 4.0"); + command("write_data test_atom_styles.data nocoeff"); + command("clear"); + command("units real"); + command("atom_style hybrid full ellipsoid"); + command("pair_style zero 4.0"); + command("bond_style zero"); + command("atom_modify map array"); + command("read_data test_atom_styles.data"); + command("pair_coeff * *"); + command("bond_coeff * 4.0"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("hybrid")); ASSERT_NE(lmp->atom->avec, nullptr); @@ -4398,13 +4407,13 @@ TEST_F(AtomStyleTest, full_ellipsoid) EXPECT_NEAR(bonus[3].quat[3], sqrt(5.0 / 30.0), EPSILON); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("pair_coeff * *"); - lmp->input->one("group two id 2:4:2"); - lmp->input->one("delete_atoms group two compress no"); - lmp->input->one("write_restart test_atom_styles.restart"); - lmp->input->one("clear"); - lmp->input->one("read_restart test_atom_styles.restart"); - lmp->input->one("replicate 1 1 2 bbox"); + command("pair_coeff * *"); + command("group two id 2:4:2"); + command("delete_atoms group two compress no"); + command("write_restart test_atom_styles.restart"); + command("clear"); + command("read_restart test_atom_styles.restart"); + command("replicate 1 1 2 bbox"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("hybrid")); hybrid = (AtomVecHybrid *)lmp->atom->avec; @@ -4485,7 +4494,7 @@ TEST_F(AtomStyleTest, full_ellipsoid) EXPECT_NEAR(bonus[3].quat[3], 0.25056280708573159, EPSILON); if (!verbose) ::testing::internal::CaptureStdout(); - lmp->input->one("reset_atom_ids"); + command("reset_atom_ids"); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_EQ(lmp->atom->nellipsoids, 4); ASSERT_EQ(lmp->atom->tag_consecutive(), 1); @@ -4551,6 +4560,247 @@ TEST_F(AtomStyleTest, full_ellipsoid) EXPECT_NEAR(bonus[3].quat[3], 0.25056280708573159, EPSILON); } +TEST_F(AtomStyleTest, property_atom) +{ + if (!verbose) ::testing::internal::CaptureStdout(); + command("atom_modify map array"); + command("fix Properties all property/atom i_one d_two mol d_three q rmass ghost yes"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + AtomState expected; + expected.atom_style = "atomic"; + expected.molecular = Atom::ATOMIC; + expected.tag_enable = 1; + expected.map_style = 1; + expected.map_user = 1; + expected.has_type = true; + expected.has_image = true; + expected.has_mask = true; + expected.has_x = true; + expected.has_v = true; + expected.has_f = true; + expected.has_iname = true; + expected.has_dname = true; + expected.has_extra_grow = true; + expected.has_extra_restart = true; + expected.has_extra_border = true; + expected.molecule_flag = 1; + expected.q_flag = 1; + expected.rmass_flag = 1; + expected.nivector = 1; + expected.ndvector = 2; + expected.nextra_grow = 1; + expected.nextra_grow_max = 1; + expected.nextra_restart = 1; + expected.nextra_restart_max = 1; + expected.nextra_border = 1; + expected.nextra_border_max = 1; + ASSERT_ATOM_STATE_EQ(lmp->atom, expected); + + if (!verbose) ::testing::internal::CaptureStdout(); + command("create_box 2 box"); + command("create_atoms 1 single -2.0 2.0 0.1"); + command("create_atoms 1 single -2.0 -2.0 -0.1"); + command("create_atoms 2 single 2.0 2.0 -0.1"); + command("create_atoms 2 single 2.0 -2.0 0.1"); + command("mass 1 4.0"); + command("mass 2 2.4"); + command("set atom 1 charge -0.5"); + command("set atom 2 charge 0.5"); + command("set atom 3 charge -1.0"); + command("set atom 4 charge 1.0"); + command("set type 1 mass 4.0"); + command("set type 2 mass 2.4"); + command("set atom 1 mol 1"); + command("set atom 2 mol 2"); + command("set atom 3 mol 2"); + command("set atom 4 mol 1"); + command("set atom * i_one -5"); + command("set atom 3* i_one 5"); + command("set type 1 d_two 2.0"); + command("set type 2 d_two 1.0"); + command("set atom 1 d_three -2.5"); + command("set atom 2 d_three -1.0"); + command("set atom 3 d_three 0.5"); + command("set atom 4 d_three 2.0"); + + if (!verbose) ::testing::internal::GetCapturedStdout(); + expected.natoms = 4; + expected.nlocal = 4; + expected.map_tag_max = 4; + expected.nmax = 16384; + expected.ntypes = 2; + expected.has_mass = true; + expected.has_mass_setflag = true; + expected.has_sametag = true; + ASSERT_ATOM_STATE_EQ(lmp->atom, expected); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_NE(lmp->atom->rmass, nullptr); + + if (!verbose) ::testing::internal::CaptureStdout(); + command("pair_coeff * *"); + command("write_data test_atom_styles.data nocoeff"); + command("clear"); + command("atom_style atomic"); + command("pair_style zero 4.0"); + command("units real"); + command("atom_modify map array"); + command("fix props all property/atom i_one d_two mol d_three q rmass ghost yes"); + command("read_data test_atom_styles.data fix props NULL Properties"); + command("pair_coeff * *"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 4); + ASSERT_EQ(lmp->atom->nlocal, 4); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, Atom::ATOMIC); + ASSERT_EQ(lmp->atom->ntypes, 2); + ASSERT_EQ(lmp->atom->q_flag, 1); + ASSERT_EQ(lmp->atom->molecule_flag, 1); + ASSERT_EQ(lmp->atom->rmass_flag, 1); + ASSERT_NE(lmp->atom->sametag, nullptr); + ASSERT_EQ(lmp->atom->tag_consecutive(), 1); + ASSERT_EQ(lmp->atom->map_style, Atom::MAP_ARRAY); + ASSERT_EQ(lmp->atom->map_user, 1); + ASSERT_EQ(lmp->atom->map_tag_max, 4); + + auto x = lmp->atom->x; + auto v = lmp->atom->v; + auto q = lmp->atom->q; + EXPECT_NEAR(x[GETIDX(1)][0], -2.0, EPSILON); + EXPECT_NEAR(x[GETIDX(1)][1], 2.0, EPSILON); + EXPECT_NEAR(x[GETIDX(1)][2], 0.1, EPSILON); + EXPECT_NEAR(x[GETIDX(2)][0], -2.0, EPSILON); + EXPECT_NEAR(x[GETIDX(2)][1], -2.0, EPSILON); + EXPECT_NEAR(x[GETIDX(2)][2], -0.1, EPSILON); + EXPECT_NEAR(x[GETIDX(3)][0], 2.0, EPSILON); + EXPECT_NEAR(x[GETIDX(3)][1], 2.0, EPSILON); + EXPECT_NEAR(x[GETIDX(3)][2], -0.1, EPSILON); + EXPECT_NEAR(x[GETIDX(4)][0], 2.0, EPSILON); + EXPECT_NEAR(x[GETIDX(4)][1], -2.0, EPSILON); + EXPECT_NEAR(x[GETIDX(4)][2], 0.1, EPSILON); + EXPECT_NEAR(v[GETIDX(1)][0], 0.0, EPSILON); + EXPECT_NEAR(v[GETIDX(1)][1], 0.0, EPSILON); + EXPECT_NEAR(v[GETIDX(1)][2], 0.0, EPSILON); + EXPECT_NEAR(v[GETIDX(2)][0], 0.0, EPSILON); + EXPECT_NEAR(v[GETIDX(2)][1], 0.0, EPSILON); + EXPECT_NEAR(v[GETIDX(2)][2], 0.0, EPSILON); + EXPECT_NEAR(v[GETIDX(3)][0], 0.0, EPSILON); + EXPECT_NEAR(v[GETIDX(3)][1], 0.0, EPSILON); + EXPECT_NEAR(v[GETIDX(3)][2], 0.0, EPSILON); + EXPECT_NEAR(v[GETIDX(4)][0], 0.0, EPSILON); + EXPECT_NEAR(v[GETIDX(4)][1], 0.0, EPSILON); + EXPECT_NEAR(v[GETIDX(4)][2], 0.0, EPSILON); + EXPECT_NEAR(q[GETIDX(1)], -0.5, EPSILON); + EXPECT_NEAR(q[GETIDX(2)], 0.5, EPSILON); + EXPECT_NEAR(q[GETIDX(3)], -1.0, EPSILON); + EXPECT_NEAR(q[GETIDX(4)], 1.0, EPSILON); + + EXPECT_NEAR(lmp->atom->mass[1], 4.0, EPSILON); + EXPECT_NEAR(lmp->atom->mass[2], 2.4, EPSILON); + ASSERT_EQ(lmp->atom->mass_setflag[1], 1); + ASSERT_EQ(lmp->atom->mass_setflag[2], 1); + + auto rmass = lmp->atom->rmass; + auto one = lmp->atom->ivector[0]; + auto two = lmp->atom->dvector[0]; + auto three = lmp->atom->dvector[1]; + + EXPECT_NEAR(rmass[GETIDX(1)], 4.0, EPSILON); + EXPECT_NEAR(rmass[GETIDX(2)], 4.0, EPSILON); + EXPECT_NEAR(rmass[GETIDX(3)], 2.4, EPSILON); + EXPECT_NEAR(rmass[GETIDX(4)], 2.4, EPSILON); + EXPECT_EQ(one[GETIDX(1)], -5); + EXPECT_EQ(one[GETIDX(2)], -5); + EXPECT_EQ(one[GETIDX(3)], 5); + EXPECT_EQ(one[GETIDX(4)], 5); + EXPECT_NEAR(two[GETIDX(1)], 2.0, EPSILON); + EXPECT_NEAR(two[GETIDX(2)], 2.0, EPSILON); + EXPECT_NEAR(two[GETIDX(3)], 1.0, EPSILON); + EXPECT_NEAR(two[GETIDX(4)], 1.0, EPSILON); + EXPECT_NEAR(three[GETIDX(1)], -2.5, EPSILON); + EXPECT_NEAR(three[GETIDX(2)], -1.0, EPSILON); + EXPECT_NEAR(three[GETIDX(3)], 0.5, EPSILON); + EXPECT_NEAR(three[GETIDX(4)], 2.0, EPSILON); + + if (!verbose) ::testing::internal::CaptureStdout(); + command("pair_coeff * *"); + command("group two id 2:4:2"); + command("delete_atoms group two compress no"); + command("write_restart test_atom_styles.restart"); + command("clear"); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); + command("read_restart test_atom_styles.restart"); + command("fix props all property/atom i_one d_two mol d_three q rmass ghost yes"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + expected.natoms = 2; + expected.nlocal = 2; + expected.nghost = 0; + expected.map_tag_max = 3; + expected.nmax = 16384; + expected.ntypes = 2; + expected.has_mass = true; + expected.has_mass_setflag = true; + expected.has_sametag = true; + expected.has_extra = true; + expected.nextra_store = 7; + + ASSERT_ATOM_STATE_EQ(lmp->atom, expected); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->tag_consecutive(), 0); + + q = lmp->atom->q; + EXPECT_NEAR(q[GETIDX(1)], -0.5, EPSILON); + EXPECT_NEAR(q[GETIDX(3)], -1.0, EPSILON); + + rmass = lmp->atom->rmass; + one = lmp->atom->ivector[0]; + two = lmp->atom->dvector[0]; + three = lmp->atom->dvector[1]; + EXPECT_NEAR(lmp->atom->mass[1], 4.0, EPSILON); + EXPECT_NEAR(lmp->atom->mass[2], 2.4, EPSILON); + ASSERT_EQ(lmp->atom->mass_setflag[1], 1); + ASSERT_EQ(lmp->atom->mass_setflag[2], 1); + EXPECT_NEAR(rmass[GETIDX(1)], 4.0, EPSILON); + EXPECT_NEAR(rmass[GETIDX(3)], 2.4, EPSILON); + EXPECT_EQ(one[GETIDX(1)], -5); + EXPECT_EQ(one[GETIDX(3)], 5); + EXPECT_NEAR(two[GETIDX(1)], 2.0, EPSILON); + EXPECT_NEAR(two[GETIDX(3)], 1.0, EPSILON); + EXPECT_NEAR(three[GETIDX(1)], -2.5, EPSILON); + EXPECT_NEAR(three[GETIDX(3)], 0.5, EPSILON); + + if (!verbose) ::testing::internal::CaptureStdout(); + command("reset_atom_ids"); + command("change_box all triclinic"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->atom->map_tag_max, 2); + q = lmp->atom->q; + EXPECT_NEAR(q[GETIDX(1)], -0.5, EPSILON); + EXPECT_NEAR(q[GETIDX(2)], -1.0, EPSILON); + + rmass = lmp->atom->rmass; + one = lmp->atom->ivector[0]; + two = lmp->atom->dvector[0]; + three = lmp->atom->dvector[1]; + EXPECT_NEAR(lmp->atom->mass[1], 4.0, EPSILON); + EXPECT_NEAR(lmp->atom->mass[2], 2.4, EPSILON); + ASSERT_EQ(lmp->atom->mass_setflag[1], 1); + ASSERT_EQ(lmp->atom->mass_setflag[2], 1); + EXPECT_NEAR(rmass[GETIDX(1)], 4.0, EPSILON); + EXPECT_NEAR(rmass[GETIDX(2)], 2.4, EPSILON); + EXPECT_EQ(one[GETIDX(1)], -5); + EXPECT_EQ(one[GETIDX(2)], 5); + EXPECT_NEAR(two[GETIDX(1)], 2.0, EPSILON); + EXPECT_NEAR(two[GETIDX(2)], 1.0, EPSILON); + EXPECT_NEAR(three[GETIDX(1)], -2.5, EPSILON); + EXPECT_NEAR(three[GETIDX(2)], 0.5, EPSILON); +} + } // namespace LAMMPS_NS int main(int argc, char **argv)