simplify and apply clang-format
This commit is contained in:
@ -73,7 +73,7 @@ protected:
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
group = lmp->group;
|
||||
group = lmp->group;
|
||||
domain = lmp->domain;
|
||||
}
|
||||
|
||||
|
||||
@ -59,6 +59,7 @@ using ::testing::StrEq;
|
||||
class KimCommandsTest : public ::testing::Test {
|
||||
protected:
|
||||
LAMMPS *lmp;
|
||||
Variable *variable;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
@ -68,6 +69,7 @@ protected:
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
variable = lmp->input->variable;
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
@ -76,53 +78,45 @@ protected:
|
||||
delete lmp;
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void command(const std::string &cmd) { lmp->input->one(cmd); }
|
||||
};
|
||||
|
||||
TEST_F(KimCommandsTest, kim)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal kim command.*",
|
||||
lmp->input->one("kim"););
|
||||
TEST_FAILURE(".*ERROR: Unknown kim subcommand.*",
|
||||
lmp->input->one("kim unknown"););
|
||||
TEST_FAILURE(".*kim_init.*has been renamed to.*",
|
||||
lmp->input->one("kim_init"););
|
||||
TEST_FAILURE(".*kim_interactions.*has been renamed to.*",
|
||||
lmp->input->one("kim_interactions"););
|
||||
TEST_FAILURE(".*kim_param.*has been renamed to.*",
|
||||
lmp->input->one("kim_param"););
|
||||
TEST_FAILURE(".*kim_property.*has been renamed to.*",
|
||||
lmp->input->one("kim_property"););
|
||||
TEST_FAILURE(".*kim_query.*has been renamed to.*",
|
||||
lmp->input->one("kim_query"););
|
||||
TEST_FAILURE(".*ERROR: Illegal kim command.*", command("kim"););
|
||||
TEST_FAILURE(".*ERROR: Unknown kim subcommand.*", command("kim unknown"););
|
||||
TEST_FAILURE(".*kim_init.*has been renamed to.*", command("kim_init"););
|
||||
TEST_FAILURE(".*kim_interactions.*has been renamed to.*", command("kim_interactions"););
|
||||
TEST_FAILURE(".*kim_param.*has been renamed to.*", command("kim_param"););
|
||||
TEST_FAILURE(".*kim_property.*has been renamed to.*", command("kim_property"););
|
||||
TEST_FAILURE(".*kim_query.*has been renamed to.*", command("kim_query"););
|
||||
}
|
||||
|
||||
TEST_F(KimCommandsTest, kim_init)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim init' command.*", command("kim init"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim init' command.*",
|
||||
lmp->input->one("kim init"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim init' command.*",
|
||||
lmp->input->one("kim init LennardJones_Ar real si"););
|
||||
command("kim init LennardJones_Ar real si"););
|
||||
TEST_FAILURE(".*ERROR: LAMMPS unit_style lj not supported by KIM models.*",
|
||||
lmp->input->one("kim init LennardJones_Ar lj"););
|
||||
command("kim init LennardJones_Ar lj"););
|
||||
TEST_FAILURE(".*ERROR: LAMMPS unit_style micro not supported by KIM models.*",
|
||||
lmp->input->one("kim init LennardJones_Ar micro"););
|
||||
command("kim init LennardJones_Ar micro"););
|
||||
TEST_FAILURE(".*ERROR: LAMMPS unit_style nano not supported by KIM models.*",
|
||||
lmp->input->one("kim init LennardJones_Ar nano"););
|
||||
TEST_FAILURE(".*ERROR: Unknown unit_style.*",
|
||||
lmp->input->one("kim init LennardJones_Ar new_style"););
|
||||
TEST_FAILURE(".*ERROR: KIM Model name not found.*",
|
||||
lmp->input->one("kim init Unknown_Model real"););
|
||||
command("kim init LennardJones_Ar nano"););
|
||||
TEST_FAILURE(".*ERROR: Unknown unit_style.*", command("kim init LennardJones_Ar new_style"););
|
||||
TEST_FAILURE(".*ERROR: KIM Model name not found.*", command("kim init Unknown_Model real"););
|
||||
TEST_FAILURE(".*ERROR: Incompatible units for KIM Simulator Model, required units = metal.*",
|
||||
lmp->input->one("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu real"););
|
||||
command("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu real"););
|
||||
// TEST_FAILURE(".*ERROR: KIM Model does not support the requested unit system.*",
|
||||
// lmp->input->one("kim init ex_model_Ar_P_Morse real"););
|
||||
// command("kim init ex_model_Ar_P_Morse real"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("kim init LennardJones_Ar real");
|
||||
command("kim init LennardJones_Ar real");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
int ifix = lmp->modify->find_fix("KIM_MODEL_STORE");
|
||||
@ -133,124 +127,122 @@ TEST_F(KimCommandsTest, kim_interactions)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim interactions' command.*",
|
||||
lmp->input->one("kim interactions"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim interactions' command.*", command("kim interactions"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("kim init LennardJones_Ar real");
|
||||
command("kim init LennardJones_Ar real");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Must use 'kim interactions' command "
|
||||
"after simulation box is defined.*",
|
||||
lmp->input->one("kim interactions Ar"););
|
||||
command("kim interactions Ar"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
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");
|
||||
command("kim init LennardJones_Ar real");
|
||||
command("lattice fcc 4.4300");
|
||||
command("region box block 0 10 0 10 0 10");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim interactions' command.*",
|
||||
lmp->input->one("kim interactions Ar Ar"););
|
||||
command("kim interactions Ar Ar"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("lattice fcc 4.4300");
|
||||
lmp->input->one("region box block 0 20 0 20 0 20");
|
||||
lmp->input->one("create_box 4 box");
|
||||
lmp->input->one("create_atoms 4 box");
|
||||
command("clear");
|
||||
command("lattice fcc 4.4300");
|
||||
command("region box block 0 20 0 20 0 20");
|
||||
command("create_box 4 box");
|
||||
command("create_atoms 4 box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim interactions' command.*",
|
||||
lmp->input->one("kim interactions Ar Ar"););
|
||||
command("kim interactions Ar Ar"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
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");
|
||||
command("clear");
|
||||
command("lattice fcc 4.4300");
|
||||
command("region box block 0 10 0 10 0 10");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Must use 'kim init' before 'kim interactions'.*",
|
||||
lmp->input->one("kim interactions Ar"););
|
||||
command("kim interactions Ar"););
|
||||
|
||||
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");
|
||||
command("clear");
|
||||
command("kim init LennardJones_Ar real");
|
||||
command("lattice fcc 4.4300");
|
||||
command("region box block 0 10 0 10 0 10");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*ERROR: fixed_types cannot be used with a KIM Portable Model.*",
|
||||
lmp->input->one("kim interactions fixed_types"););
|
||||
command("kim interactions fixed_types"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("units real");
|
||||
lmp->input->one("pair_style kim LennardJones_Ar");
|
||||
lmp->input->one("region box block 0 1 0 1 0 1");
|
||||
lmp->input->one("create_box 4 box");
|
||||
lmp->input->one("pair_coeff * * Ar Ar Ar Ar");
|
||||
command("clear");
|
||||
command("units real");
|
||||
command("pair_style kim LennardJones_Ar");
|
||||
command("region box block 0 1 0 1 0 1");
|
||||
command("create_box 4 box");
|
||||
command("pair_coeff * * Ar Ar Ar Ar");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
|
||||
lmp->input->one("lattice fcc 4.920");
|
||||
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");
|
||||
command("clear");
|
||||
command("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
|
||||
command("lattice fcc 4.920");
|
||||
command("region box block 0 10 0 10 0 10");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Species 'Ar' is not supported by this KIM Simulator Model.*",
|
||||
lmp->input->one("kim interactions Ar"););
|
||||
command("kim interactions Ar"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
|
||||
lmp->input->one("lattice fcc 4.08");
|
||||
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 Au");
|
||||
command("clear");
|
||||
command("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
|
||||
command("lattice fcc 4.08");
|
||||
command("region box block 0 10 0 10 0 10");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 box");
|
||||
command("kim interactions Au");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// ASSERT_EQ(lmp->output->var_kim_periodic, 1);
|
||||
// TEST_FAILURE(".*ERROR: Incompatible units for KIM Simulator Model.*",
|
||||
// lmp->input->one("kim interactions Au"););
|
||||
|
||||
// command("kim interactions Au"););
|
||||
|
||||
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");
|
||||
command("clear");
|
||||
command("kim init LennardJones_Ar real");
|
||||
command("lattice fcc 4.4300");
|
||||
command("region box block 0 10 0 10 0 10");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 box");
|
||||
command("kim interactions Ar");
|
||||
command("mass 1 39.95");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
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");
|
||||
command("clear");
|
||||
command("kim init LennardJones_Ar real");
|
||||
command("lattice fcc 4.4300");
|
||||
command("region box block 0 10 0 10 0 10");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 box");
|
||||
command("kim interactions Ar");
|
||||
command("mass 1 39.95");
|
||||
command("run 1");
|
||||
command("kim interactions Ar");
|
||||
command("run 1");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
@ -258,189 +250,188 @@ TEST_F(KimCommandsTest, kim_param)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim param' command.*",
|
||||
lmp->input->one("kim param"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim param' command.*", command("kim param"););
|
||||
TEST_FAILURE(".*ERROR: Incorrect arguments in 'kim param' command.\n"
|
||||
"'kim param get/set' is mandatory.*",
|
||||
lmp->input->one("kim param unknown shift 1 shift"););
|
||||
command("kim param unknown shift 1 shift"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
|
||||
command("clear");
|
||||
command("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*ERROR: 'kim param' can only be used with a KIM Portable Model.*",
|
||||
lmp->input->one("kim param get shift 1 shift"););
|
||||
command("kim param get shift 1 shift"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
|
||||
command("clear");
|
||||
command("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim param get' command.\nTo get the new "
|
||||
"parameter values, pair style must be assigned.\nMust use 'kim"
|
||||
" interactions' or 'pair_style kim' before 'kim param get'.*",
|
||||
lmp->input->one("kim param get shift 1 shift"););
|
||||
command("kim param get shift 1 shift"););
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim param set' command.\nTo set the new "
|
||||
"parameter values, pair style must be assigned.\nMust use 'kim"
|
||||
" interactions' or 'pair_style kim' before 'kim param set'.*",
|
||||
lmp->input->one("kim param set shift 1 2"););
|
||||
command("kim param set shift 1 2"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("kim init LennardJones612_UniversalShifted__MO_959249795837_003 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");
|
||||
command("clear");
|
||||
command("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
|
||||
command("lattice fcc 4.4300");
|
||||
command("region box block 0 10 0 10 0 10");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 box");
|
||||
command("kim interactions Ar");
|
||||
command("mass 1 39.95");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal index '0' for "
|
||||
"'shift' parameter with the extent of '1'.*",
|
||||
lmp->input->one("kim param get shift 0 shift"););
|
||||
command("kim param get shift 0 shift"););
|
||||
TEST_FAILURE(".*ERROR: Illegal index '2' for "
|
||||
"'shift' parameter with the extent of '1'.*",
|
||||
lmp->input->one("kim param get shift 2 shift"););
|
||||
command("kim param get shift 2 shift"););
|
||||
TEST_FAILURE(".*ERROR: Illegal index_range.\nExpected integer "
|
||||
"parameter\\(s\\) instead of '1.' in index_range.*",
|
||||
lmp->input->one("kim param get shift 1. shift"););
|
||||
command("kim param get shift 1. shift"););
|
||||
TEST_FAILURE(".*ERROR: Illegal index_range '1-2' for 'shift' "
|
||||
"parameter with the extent of '1'.*",
|
||||
lmp->input->one("kim param get shift 1:2 shift"););
|
||||
command("kim param get shift 1:2 shift"););
|
||||
TEST_FAILURE(".*ERROR: Illegal index_range.\nExpected integer "
|
||||
"parameter\\(s\\) instead of '1-2' in index_range.*",
|
||||
lmp->input->one("kim param get shift 1-2 shift"););
|
||||
command("kim param get shift 1-2 shift"););
|
||||
TEST_FAILURE(".*ERROR: Wrong number of arguments in 'kim param "
|
||||
"get' command.\nThe LAMMPS '3' variable names or "
|
||||
"'s1 split' is mandatory.*",
|
||||
lmp->input->one("kim param get sigmas 1:3 s1 s2"););
|
||||
command("kim param get sigmas 1:3 s1 s2"););
|
||||
TEST_FAILURE(".*ERROR: Wrong argument in 'kim param get' command.\nThis "
|
||||
"Model does not have the requested 'unknown' parameter.*",
|
||||
lmp->input->one("kim param get unknown 1 unknown"););
|
||||
command("kim param get unknown 1 unknown"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("kim param get shift 1 shift");
|
||||
command("kim param get shift 1 shift");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_FALSE(lmp->input->variable->find("shift") == -1);
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("shift")) == "1");
|
||||
ASSERT_FALSE(variable->find("shift") == -1);
|
||||
ASSERT_THAT(variable->retrieve("shift"), StrEq("1"));
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal index '2' for "
|
||||
"'shift' parameter with the extent of '1'.*",
|
||||
lmp->input->one("kim param set shift 2 2"););
|
||||
command("kim param set shift 2 2"););
|
||||
TEST_FAILURE(".*ERROR: Illegal index_range.\nExpected integer "
|
||||
"parameter\\(s\\) instead of '1.' in index_range.*",
|
||||
lmp->input->one("kim param set shift 1. shift"););
|
||||
command("kim param set shift 1. shift"););
|
||||
TEST_FAILURE(".*ERROR: Illegal index_range '1-2' for "
|
||||
"'shift' parameter with the extent of '1'.*",
|
||||
lmp->input->one("kim param set shift 1:2 2"););
|
||||
command("kim param set shift 1:2 2"););
|
||||
TEST_FAILURE(".*ERROR: Wrong number of variable values for pair coefficients.*",
|
||||
lmp->input->one("kim param set sigmas 1:3 0.5523570 0.4989030"););
|
||||
command("kim param set sigmas 1:3 0.5523570 0.4989030"););
|
||||
TEST_FAILURE(".*ERROR: Wrong argument for pair coefficients.\nThis "
|
||||
"Model does not have the requested '0.4989030' parameter.*",
|
||||
lmp->input->one("kim param set sigmas 1:1 0.5523570 0.4989030"););
|
||||
command("kim param set sigmas 1:1 0.5523570 0.4989030"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("variable new_shift equal 2");
|
||||
lmp->input->one("kim param set shift 1 ${new_shift}");
|
||||
lmp->input->one("kim param get shift 1 shift");
|
||||
command("variable new_shift equal 2");
|
||||
command("kim param set shift 1 ${new_shift}");
|
||||
command("kim param get shift 1 shift");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("shift")) == "2");
|
||||
ASSERT_THAT(variable->retrieve("shift"), StrEq("2"));
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
|
||||
lmp->input->one("kim param get cutoffs 1:3 list"););
|
||||
command("kim param get cutoffs 1:3 list"););
|
||||
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
|
||||
lmp->input->one("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 list"););
|
||||
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 list"););
|
||||
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
|
||||
lmp->input->one("kim param get cutoffs 1:3 split"););
|
||||
command("kim param get cutoffs 1:3 split"););
|
||||
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
|
||||
lmp->input->one("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 split"););
|
||||
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 split"););
|
||||
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
|
||||
lmp->input->one("kim param get cutoffs 1:3 explicit"););
|
||||
command("kim param get cutoffs 1:3 explicit"););
|
||||
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
|
||||
lmp->input->one("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 explicit"););
|
||||
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 explicit"););
|
||||
TEST_FAILURE(".*ERROR: Wrong number of arguments in 'kim param get' "
|
||||
"command.\nThe LAMMPS '3' variable names or 'cutoffs "
|
||||
"split/list' is mandatory.*",
|
||||
lmp->input->one("kim param get cutoffs 1:3 cutoffs"););
|
||||
command("kim param get cutoffs 1:3 cutoffs"););
|
||||
TEST_FAILURE(".*ERROR: Wrong number of arguments in 'kim param get' "
|
||||
"command.\nThe LAMMPS '3' variable names or 'cutoffs_1 "
|
||||
"split' is mandatory.*",
|
||||
lmp->input->one("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2"););
|
||||
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 cutoffs_3");
|
||||
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 cutoffs_3");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_1")) == "2.20943");
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_2")) == "2.10252");
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_3")) == "5.666115");
|
||||
ASSERT_THAT(variable->retrieve("cutoffs_1"), StrEq("2.20943"));
|
||||
ASSERT_THAT(variable->retrieve("cutoffs_2"), StrEq("2.10252"));
|
||||
ASSERT_THAT(variable->retrieve("cutoffs_3"), StrEq("5.666115"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 cutoffs_3 explicit");
|
||||
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 cutoffs_3 explicit");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_1")) == "2.20943");
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_2")) == "2.10252");
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_3")) == "5.666115");
|
||||
ASSERT_THAT(variable->retrieve("cutoffs_1"), StrEq("2.20943"));
|
||||
ASSERT_THAT(variable->retrieve("cutoffs_2"), StrEq("2.10252"));
|
||||
ASSERT_THAT(variable->retrieve("cutoffs_3"), StrEq("5.666115"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("kim param get cutoffs 1:3 cutoffs split");
|
||||
command("kim param get cutoffs 1:3 cutoffs split");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_1")) == "2.20943");
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_2")) == "2.10252");
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_3")) == "5.666115");
|
||||
ASSERT_THAT(variable->retrieve("cutoffs_1"), StrEq("2.20943"));
|
||||
ASSERT_THAT(variable->retrieve("cutoffs_2"), StrEq("2.10252"));
|
||||
ASSERT_THAT(variable->retrieve("cutoffs_3"), StrEq("5.666115"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("kim param get cutoffs 1:3 cutoffs list");
|
||||
command("kim param get cutoffs 1:3 cutoffs list");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs")) == "2.20943 2.10252 5.666115");
|
||||
ASSERT_THAT(variable->retrieve("cutoffs"), StrEq("2.20943 2.10252 5.666115"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("kim param set cutoffs 1 2.21 cutoffs 2 2.11");
|
||||
lmp->input->one("kim param get cutoffs 1:2 cutoffs list");
|
||||
command("kim param set cutoffs 1 2.21 cutoffs 2 2.11");
|
||||
command("kim param get cutoffs 1:2 cutoffs list");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs")) == "2.21 2.11");
|
||||
ASSERT_THAT(variable->retrieve("cutoffs"), StrEq("2.21 2.11"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("kim param set cutoffs 1:3 2.3 2.2 5.7");
|
||||
lmp->input->one("kim param get cutoffs 1:3 cutoffs list");
|
||||
command("kim param set cutoffs 1:3 2.3 2.2 5.7");
|
||||
command("kim param get cutoffs 1:3 cutoffs list");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs")) == "2.3 2.2 5.7");
|
||||
ASSERT_THAT(variable->retrieve("cutoffs"), StrEq("2.3 2.2 5.7"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("units 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("mass 1 39.95");
|
||||
lmp->input->one("pair_style kim LennardJones612_UniversalShifted__MO_959249795837_003");
|
||||
lmp->input->one("pair_coeff * * Ar");
|
||||
command("clear");
|
||||
command("units real");
|
||||
command("lattice fcc 4.4300");
|
||||
command("region box block 0 10 0 10 0 10");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 box");
|
||||
command("mass 1 39.95");
|
||||
command("pair_style kim LennardJones612_UniversalShifted__MO_959249795837_003");
|
||||
command("pair_coeff * * Ar");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("kim param get shift 1 shift");
|
||||
command("kim param get shift 1 shift");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("shift")) == "1");
|
||||
ASSERT_THAT(variable->retrieve("shift"), StrEq("1"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("variable new_shift equal 2");
|
||||
lmp->input->one("kim param set shift 1 ${new_shift}");
|
||||
lmp->input->one("kim param get shift 1 shift");
|
||||
command("variable new_shift equal 2");
|
||||
command("kim param set shift 1 ${new_shift}");
|
||||
command("kim param get shift 1 shift");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("shift")) == "2");
|
||||
ASSERT_THAT(variable->retrieve("shift"), StrEq("2"));
|
||||
}
|
||||
|
||||
TEST_F(KimCommandsTest, kim_property)
|
||||
@ -452,38 +443,36 @@ TEST_F(KimCommandsTest, kim_property)
|
||||
TEST_FAILURE(".*ERROR: Invalid Python version.\n"
|
||||
"The kim-property Python package requires Python "
|
||||
"3 >= 3.6 support.*",
|
||||
lmp->input->one("kim property"););
|
||||
command("kim property"););
|
||||
} else {
|
||||
TEST_FAILURE(".*ERROR: Invalid 'kim property' command.*",
|
||||
lmp->input->one("kim property"););
|
||||
TEST_FAILURE(".*ERROR: Invalid 'kim property' command.*",
|
||||
lmp->input->one("kim property create"););
|
||||
TEST_FAILURE(".*ERROR: Invalid 'kim property' command.*", command("kim property"););
|
||||
TEST_FAILURE(".*ERROR: Invalid 'kim property' command.*", command("kim property create"););
|
||||
TEST_FAILURE(".*ERROR: Incorrect arguments in 'kim property' command."
|
||||
"\n'kim property create/destroy/modify/remove/dump' "
|
||||
"is mandatory.*",
|
||||
lmp->input->one("kim property unknown 1 atomic-mass"););
|
||||
command("kim property unknown 1 atomic-mass"););
|
||||
}
|
||||
#if defined(KIM_EXTRA_UNITTESTS)
|
||||
TEST_FAILURE(".*ERROR: Invalid 'kim property create' command.*",
|
||||
lmp->input->one("kim property create 1"););
|
||||
command("kim property create 1"););
|
||||
TEST_FAILURE(".*ERROR: Invalid 'kim property destroy' command.*",
|
||||
lmp->input->one("kim property destroy 1 cohesive-potential-energy-cubic-crystal"););
|
||||
command("kim property destroy 1 cohesive-potential-energy-cubic-crystal"););
|
||||
TEST_FAILURE(".*ERROR: Invalid 'kim property modify' command.*",
|
||||
lmp->input->one("kim property modify 1 key short-name"););
|
||||
command("kim property modify 1 key short-name"););
|
||||
TEST_FAILURE(".*ERROR: There is no property instance to modify the content.*",
|
||||
lmp->input->one("kim property modify 1 key short-name source-value 1 fcc"););
|
||||
command("kim property modify 1 key short-name source-value 1 fcc"););
|
||||
TEST_FAILURE(".*ERROR: Invalid 'kim property remove' command.*",
|
||||
lmp->input->one("kim property remove 1 key"););
|
||||
command("kim property remove 1 key"););
|
||||
TEST_FAILURE(".*ERROR: There is no property instance to remove the content.*",
|
||||
lmp->input->one("kim property remove 1 key short-name"););
|
||||
command("kim property remove 1 key short-name"););
|
||||
TEST_FAILURE(".*ERROR: There is no property instance to dump the content.*",
|
||||
lmp->input->one("kim property dump results.edn"););
|
||||
command("kim property dump results.edn"););
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
|
||||
lmp->input->one("kim property create 1 cohesive-potential-energy-cubic-crystal");
|
||||
lmp->input->one("kim property modify 1 key short-name source-value 1 fcc");
|
||||
lmp->input->one("kim property destroy 1");
|
||||
command("clear");
|
||||
command("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
|
||||
command("kim property create 1 cohesive-potential-energy-cubic-crystal");
|
||||
command("kim property modify 1 key short-name source-value 1 fcc");
|
||||
command("kim property destroy 1");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
#endif
|
||||
}
|
||||
@ -492,264 +481,233 @@ TEST_F(KimCommandsTest, kim_query)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.*",
|
||||
lmp->input->one("kim query"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.*", command("kim query"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe keyword 'split' "
|
||||
"must be followed by the name of the query function.*",
|
||||
lmp->input->one("kim query a0 split"););
|
||||
command("kim query a0 split"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe keyword 'list' "
|
||||
"must be followed by the name of the query function.*",
|
||||
lmp->input->one("kim query a0 list"););
|
||||
command("kim query a0 list"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe keyword 'index' "
|
||||
"must be followed by the name of the query function.*",
|
||||
lmp->input->one("kim query a0 index"););
|
||||
command("kim query a0 index"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'list' keyword "
|
||||
"can not be used after 'split'.*",
|
||||
lmp->input->one("kim query a0 split list"););
|
||||
command("kim query a0 split list"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'index' keyword "
|
||||
"can not be used after 'split'.*",
|
||||
lmp->input->one("kim query a0 split index"););
|
||||
command("kim query a0 split index"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'split' keyword "
|
||||
"can not be used after 'list'.*",
|
||||
lmp->input->one("kim query a0 list split"););
|
||||
command("kim query a0 list split"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'index' keyword "
|
||||
"can not be used after 'list'.*",
|
||||
lmp->input->one("kim query a0 list index"););
|
||||
command("kim query a0 list index"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'list' keyword "
|
||||
"can not be used after 'index'.*",
|
||||
lmp->input->one("kim query a0 index list"););
|
||||
command("kim query a0 index list"););
|
||||
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'split' keyword "
|
||||
"can not be used after 'index'.*",
|
||||
lmp->input->one("kim query a0 index split"););
|
||||
command("kim query a0 index split"););
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `crystal` "
|
||||
"to 'kim query' is wrong. The query format is the "
|
||||
"keyword=\\[value\\], where value is always an array of one "
|
||||
"or more comma-separated items.*",
|
||||
lmp->input->one("kim query a0 get_lattice_constant_cubic "
|
||||
"crystal"););
|
||||
command("kim query a0 get_lattice_constant_cubic "
|
||||
"crystal"););
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `"
|
||||
"crystal=fcc` to 'kim query' is wrong. The query format is the "
|
||||
"keyword=\\[value\\], where value is always an array of one "
|
||||
"or more comma-separated items.*",
|
||||
lmp->input->one("kim query a0 get_lattice_constant_cubic "
|
||||
"crystal=fcc"););
|
||||
command("kim query a0 get_lattice_constant_cubic "
|
||||
"crystal=fcc"););
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `"
|
||||
"crystal=\\[fcc` to 'kim query' is wrong. The query format is "
|
||||
"the keyword=\\[value\\], where value is always an array of "
|
||||
"one or more comma-separated items.*",
|
||||
lmp->input->one("kim query a0 get_lattice_constant_cubic "
|
||||
"crystal=[fcc"););
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `"
|
||||
command("kim query a0 get_lattice_constant_cubic "
|
||||
"crystal=[fcc"););
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `"
|
||||
"crystal=fcc\\]` to 'kim query' is wrong. The query format is "
|
||||
"the keyword=\\[value\\], where value is always an array of "
|
||||
"one or more comma-separated items.*",
|
||||
lmp->input->one("kim query a0 get_lattice_constant_cubic "
|
||||
"crystal=fcc]"););
|
||||
command("kim query a0 get_lattice_constant_cubic "
|
||||
"crystal=fcc]"););
|
||||
|
||||
std::string squery("kim query a0 get_lattice_constant_cubic ");
|
||||
squery += "crystal=[\"fcc\"] species=\"Al\",\"Ni\" units=[\"angstrom\"]";
|
||||
std::string squery = "kim query a0 get_lattice_constant_cubic "
|
||||
"crystal=[\"fcc\"] species=\"Al\",\"Ni\" units=[\"angstrom\"]";
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
|
||||
"\"Al\",\"Ni\"` to 'kim query' is wrong. The query format is "
|
||||
"the keyword=\\[value\\], where value is always an array of "
|
||||
"one or more comma-separated items.*",
|
||||
lmp->input->one(squery););
|
||||
command(squery););
|
||||
|
||||
squery = "kim query a0 get_lattice_constant_cubic ";
|
||||
squery += "crystal=[fcc] species=Al,Ni units=[angstrom]";
|
||||
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] species=Al,Ni units=[angstrom]";
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
|
||||
"Al,Ni` to 'kim query' is wrong. The query format is "
|
||||
"the keyword=\\[value\\], where value is always an array of "
|
||||
"one or more comma-separated items.*",
|
||||
lmp->input->one(squery););
|
||||
command(squery););
|
||||
|
||||
squery = "kim query a0 get_lattice_constant_cubic ";
|
||||
squery += "crystal=[fcc] species=Al,Ni, units=[angstrom]";
|
||||
squery =
|
||||
"kim query a0 get_lattice_constant_cubic crystal=[fcc] species=Al,Ni, units=[angstrom]";
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
|
||||
"Al,Ni,` to 'kim query' is wrong. The query format is "
|
||||
"the keyword=\\[value\\], where value is always an array of "
|
||||
"one or more comma-separated items.*",
|
||||
lmp->input->one(squery););
|
||||
command(squery););
|
||||
|
||||
squery = "kim query a0 get_lattice_constant_cubic ";
|
||||
squery += "crystal=[fcc] species=[Al,Ni, units=[angstrom]";
|
||||
squery =
|
||||
"kim query a0 get_lattice_constant_cubic crystal=[fcc] species=[Al,Ni, units=[angstrom]";
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
|
||||
"\\[Al,Ni,` to 'kim query' is wrong. The query format is "
|
||||
"the keyword=\\[value\\], where value is always an array of "
|
||||
"one or more comma-separated items.*",
|
||||
lmp->input->one(squery););
|
||||
command(squery););
|
||||
|
||||
squery = "kim query a0 get_lattice_constant_cubic ";
|
||||
squery += "crystal=[fcc] species=Al,Ni], units=[angstrom]";
|
||||
squery =
|
||||
"kim query a0 get_lattice_constant_cubic crystal=[fcc] species=Al,Ni], units=[angstrom]";
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
|
||||
"Al,Ni\\],` to 'kim query' is wrong. The query format is "
|
||||
"the keyword=\\[value\\], where value is always an array of "
|
||||
"one or more comma-separated items.*",
|
||||
lmp->input->one(squery););
|
||||
command(squery););
|
||||
|
||||
squery = "kim query a0 get_lattice_constant_cubic ";
|
||||
squery += "crystal=[fcc] species=Al,\"Ni\"], units=[angstrom]";
|
||||
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] species=Al,\"Ni\"], "
|
||||
"units=[angstrom]";
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
|
||||
"Al,\"Ni\"\\],` to 'kim query' is wrong. The query format is "
|
||||
"the keyword=\\[value\\], where value is always an array of "
|
||||
"one or more comma-separated items.*",
|
||||
lmp->input->one(squery););
|
||||
command(squery););
|
||||
|
||||
squery = "kim query a0 get_lattice_constant_cubic ";
|
||||
squery += "crystal=[fcc] species=\"Al\",Ni], units=[angstrom]";
|
||||
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] species=\"Al\",Ni], "
|
||||
"units=[angstrom]";
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
|
||||
"\"Al\",Ni\\],` to 'kim query' is wrong. The query format is "
|
||||
"the keyword=\\[value\\], where value is always an array of "
|
||||
"one or more comma-separated items.*",
|
||||
lmp->input->one(squery););
|
||||
command(squery););
|
||||
|
||||
squery = "kim query a0 get_lattice_constant_cubic crystal=[\"fcc\"] "
|
||||
"species=[\"Al\"]";
|
||||
squery = "kim query a0 get_lattice_constant_cubic crystal=[\"fcc\"] species=[\"Al\"]";
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nMust use 'kim init' before "
|
||||
"'kim query' or must provide the model name after query "
|
||||
"function with the format of 'model=\\[model_name\\]'.*",
|
||||
lmp->input->one(squery););
|
||||
command(squery););
|
||||
|
||||
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] "
|
||||
"species=[Al]";
|
||||
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] species=[Al]";
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nMust use 'kim init' before "
|
||||
"'kim query' or must provide the model name after query "
|
||||
"function with the format of 'model=\\[model_name\\]'.*",
|
||||
lmp->input->one(squery););
|
||||
command(squery););
|
||||
|
||||
squery = "kim query a0 get_lattice_constant_cubic crystal=[\"fcc\"] "
|
||||
"species=[Al]";
|
||||
squery = "kim query a0 get_lattice_constant_cubic crystal=[\"fcc\"] species=[Al]";
|
||||
TEST_FAILURE(".*ERROR: Illegal query format.\nMust use 'kim init' before "
|
||||
"'kim query' or must provide the model name after query "
|
||||
"function with the format of 'model=\\[model_name\\]'.*",
|
||||
lmp->input->one(squery););
|
||||
command(squery););
|
||||
|
||||
#if defined(KIM_EXTRA_UNITTESTS)
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
|
||||
squery = "kim query latconst_1 get_lattice_constant_cubic ";
|
||||
squery += "crystal=[fcc] species=[Al] units=[angstrom] ";
|
||||
squery += "model=[EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005]";
|
||||
lmp->input->one(squery);
|
||||
command("clear");
|
||||
command("kim query latconst_1 get_lattice_constant_cubic "
|
||||
"crystal=[fcc] species=[Al] units=[angstrom] "
|
||||
"model=[EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005]");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_1")) ==
|
||||
"4.032082033157349"));
|
||||
ASSERT_THAT(variable->retrieve("latconst_1"), StrEq("4.032082033157349"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("kim init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal");
|
||||
command("clear");
|
||||
command("kim init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal");
|
||||
command("kim query latconst_1 get_lattice_constant_cubic crystal=[fcc] species=[Al] "
|
||||
"units=[angstrom]");
|
||||
|
||||
squery = "kim query latconst_1 get_lattice_constant_cubic ";
|
||||
squery += "crystal=[fcc] species=[Al] units=[angstrom]";
|
||||
lmp->input->one(squery);
|
||||
|
||||
squery = "kim query latconst_2 get_lattice_constant_cubic ";
|
||||
squery += "crystal=[fcc] species=[Al] units=[angstrom] ";
|
||||
squery += "model=[LennardJones612_UniversalShifted__MO_959249795837_003]";
|
||||
lmp->input->one(squery);
|
||||
command("kim query latconst_2 get_lattice_constant_cubic crystal=[fcc] species=[Al] "
|
||||
"units=[angstrom] "
|
||||
"model=[LennardJones612_UniversalShifted__MO_959249795837_003]");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_1")) ==
|
||||
"4.032082033157349"));
|
||||
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_2")) ==
|
||||
"3.328125931322575"));
|
||||
ASSERT_THAT(variable->retrieve("latconst_1"), StrEq("4.032082033157349"));
|
||||
ASSERT_THAT(variable->retrieve("latconst_2"), StrEq("3.328125931322575"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("kim init EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000 metal");
|
||||
command("clear");
|
||||
command("kim init EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000 metal");
|
||||
|
||||
squery = "kim query latconst split get_lattice_constant_hexagonal ";
|
||||
squery += "crystal=[hcp] species=[Zr] units=[angstrom]";
|
||||
lmp->input->one(squery);
|
||||
command("kim query latconst split get_lattice_constant_hexagonal crystal=[hcp] species=[Zr] "
|
||||
"units=[angstrom]");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_1")) ==
|
||||
"3.234055244384789"));
|
||||
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_2")) ==
|
||||
"5.167650199630013"));
|
||||
ASSERT_THAT(variable->retrieve("latconst_1"), StrEq("3.234055244384789"));
|
||||
ASSERT_THAT(variable->retrieve("latconst_2"), StrEq("5.167650199630013"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
command("clear");
|
||||
|
||||
squery = "kim query latconst index get_lattice_constant_hexagonal ";
|
||||
squery += "crystal=[hcp] species=[Zr] units=[angstrom] ";
|
||||
squery += "model=[EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000]";
|
||||
lmp->input->one(squery);
|
||||
command("kim query latconst index get_lattice_constant_hexagonal "
|
||||
"crystal=[hcp] species=[Zr] units=[angstrom] "
|
||||
"model=[EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000]");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst")) ==
|
||||
"3.234055244384789"));
|
||||
ASSERT_THAT(variable->retrieve("latconst"), StrEq("3.234055244384789"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("variable latconst delete");
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("kim init EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000 metal");
|
||||
command("variable latconst delete");
|
||||
command("clear");
|
||||
command("kim init EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000 metal");
|
||||
|
||||
squery = "kim query latconst list get_lattice_constant_hexagonal ";
|
||||
squery += "crystal=[hcp] species=[Zr] units=[angstrom]";
|
||||
lmp->input->one(squery);
|
||||
command("kim query latconst list get_lattice_constant_hexagonal crystal=[hcp] species=[Zr] "
|
||||
"units=[angstrom]");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst")) ==
|
||||
"3.234055244384789 5.167650199630013"));
|
||||
ASSERT_THAT(variable->retrieve("latconst"), StrEq("3.234055244384789 5.167650199630013"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("kim init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal");
|
||||
command("clear");
|
||||
command("kim init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal");
|
||||
|
||||
squery = "kim query alpha get_linear_thermal_expansion_coefficient_cubic ";
|
||||
squery += "crystal=[fcc] species=[Al] units=[1/K] temperature=[293.15] ";
|
||||
squery += "temperature_units=[K]";
|
||||
lmp->input->one(squery);
|
||||
command("kim query alpha get_linear_thermal_expansion_coefficient_cubic "
|
||||
"crystal=[fcc] species=[Al] units=[1/K] temperature=[293.15] "
|
||||
"temperature_units=[K]");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("alpha")) ==
|
||||
"1.654960564704273e-05"));
|
||||
ASSERT_THAT(variable->retrieve("alpha"), StrEq("1.654960564704273e-05"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
command("clear");
|
||||
|
||||
squery = "kim query model_list list get_available_models ";
|
||||
squery += "species=[Al]";
|
||||
lmp->input->one(squery);
|
||||
command("kim query model_list list get_available_models species=[Al]");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
std::string model_list = lmp->input->variable->retrieve("model_list");
|
||||
std::string model_list = variable->retrieve("model_list");
|
||||
auto n = model_list.find("EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005");
|
||||
ASSERT_TRUE(n != std::string::npos);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
command("clear");
|
||||
|
||||
squery = "kim query model_name index get_available_models ";
|
||||
squery += "species=[Al]";
|
||||
lmp->input->one(squery);
|
||||
lmp->input->one("variable model_name delete");
|
||||
command("kim query model_name index get_available_models species=[Al]");
|
||||
command("variable model_name delete");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
command("clear");
|
||||
|
||||
squery = "kim query model_name index get_available_models ";
|
||||
squery += "species=[Al] potential_type=[eam,meam]";
|
||||
lmp->input->one(squery);
|
||||
lmp->input->one("variable model_name delete");
|
||||
command("kim query model_name index get_available_models "
|
||||
"species=[Al] potential_type=[eam,meam]");
|
||||
command("variable model_name delete");
|
||||
|
||||
squery = "kim query model_name index get_available_models ";
|
||||
squery += "species=[Al] potential_type=[\"eam\",\"meam\"]";
|
||||
lmp->input->one(squery);
|
||||
lmp->input->one("variable model_name delete");
|
||||
command("kim query model_name index get_available_models "
|
||||
"species=[Al] potential_type=[\"eam\",\"meam\"]");
|
||||
command("variable model_name delete");
|
||||
|
||||
squery = "kim query model_name index get_available_models ";
|
||||
squery += "species=[Al] potential_type=[eam,\"meam\"]";
|
||||
lmp->input->one(squery);
|
||||
lmp->input->one("variable model_name delete");
|
||||
command("kim query model_name index get_available_models "
|
||||
"species=[Al] potential_type=[eam,\"meam\"]");
|
||||
command("variable model_name delete");
|
||||
|
||||
squery = "kim query model_name index get_available_models ";
|
||||
squery += "species=[Al] potential_type=[\"eam\",meam]";
|
||||
lmp->input->one(squery);
|
||||
lmp->input->one("variable model_name delete");
|
||||
command("kim query model_name index get_available_models "
|
||||
"species=[Al] potential_type=[\"eam\",meam]");
|
||||
command("variable model_name delete");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -81,12 +81,14 @@ protected:
|
||||
delete lmp;
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void command(const std::string &cmd) { lmp->input->one(cmd); }
|
||||
};
|
||||
|
||||
TEST_F(LatticeRegionTest, lattice_none)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice none 2.0");
|
||||
command("lattice none 2.0");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
auto lattice = lmp->domain->lattice;
|
||||
ASSERT_EQ(lattice->style, Lattice::NONE);
|
||||
@ -96,14 +98,14 @@ TEST_F(LatticeRegionTest, lattice_none)
|
||||
ASSERT_EQ(lattice->nbasis, 0);
|
||||
ASSERT_EQ(lattice->basis, nullptr);
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*", lmp->input->one("lattice"););
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*", lmp->input->one("lattice xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*", lmp->input->one("lattice none 1.0 origin"););
|
||||
TEST_FAILURE(".*ERROR: Expected floating point.*", lmp->input->one("lattice none xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*", command("lattice"););
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*", command("lattice xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*", command("lattice none 1.0 origin"););
|
||||
TEST_FAILURE(".*ERROR: Expected floating point.*", command("lattice none xxx"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("units lj");
|
||||
lmp->input->one("lattice none 1.0");
|
||||
command("units lj");
|
||||
command("lattice none 1.0");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
lattice = lmp->domain->lattice;
|
||||
ASSERT_EQ(lattice->xlattice, 1.0);
|
||||
@ -114,7 +116,7 @@ TEST_F(LatticeRegionTest, lattice_none)
|
||||
TEST_F(LatticeRegionTest, lattice_sc)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice sc 1.0 spacing 1.5 2.0 3.0");
|
||||
command("lattice sc 1.0 spacing 1.5 2.0 3.0");
|
||||
auto output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
ASSERT_THAT(output, MatchesRegex(".*Lattice spacing in x,y,z = 1.50* 2.0* 3.0*.*"));
|
||||
@ -125,7 +127,7 @@ TEST_F(LatticeRegionTest, lattice_sc)
|
||||
ASSERT_EQ(lattice->zlattice, 3.0);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice sc 2.0");
|
||||
command("lattice sc 2.0");
|
||||
output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
ASSERT_THAT(output, MatchesRegex(".*Lattice spacing in x,y,z = 2.0* 2.0* 2.0*.*"));
|
||||
@ -151,25 +153,24 @@ TEST_F(LatticeRegionTest, lattice_sc)
|
||||
ASSERT_EQ(lattice->basis[0][2], 0.0);
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*",
|
||||
lmp->input->one("lattice sc 1.0 origin 1.0 1.0 1.0"););
|
||||
command("lattice sc 1.0 origin 1.0 1.0 1.0"););
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*", command("lattice sc 1.0 origin 1.0"););
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*",
|
||||
lmp->input->one("lattice sc 1.0 origin 1.0"););
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*",
|
||||
lmp->input->one("lattice sc 1.0 origin 0.0 0.0 0.0 xxx"););
|
||||
command("lattice sc 1.0 origin 0.0 0.0 0.0 xxx"););
|
||||
TEST_FAILURE(".*ERROR: Expected floating point.*",
|
||||
lmp->input->one("lattice sc 1.0 origin xxx 1.0 1.0"););
|
||||
command("lattice sc 1.0 origin xxx 1.0 1.0"););
|
||||
TEST_FAILURE(".*ERROR: Lattice orient vectors are not orthogonal.*",
|
||||
lmp->input->one("lattice sc 1.0 orient x 2 2 0"););
|
||||
command("lattice sc 1.0 orient x 2 2 0"););
|
||||
TEST_FAILURE(".*ERROR: Lattice orient vectors are not right-handed.*",
|
||||
lmp->input->one("lattice sc 1.0 orient y 0 -1 0"););
|
||||
command("lattice sc 1.0 orient y 0 -1 0"););
|
||||
TEST_FAILURE(".*ERROR: Lattice spacings are invalid.*",
|
||||
lmp->input->one("lattice sc 1.0 spacing 0.0 1.0 1.0"););
|
||||
command("lattice sc 1.0 spacing 0.0 1.0 1.0"););
|
||||
TEST_FAILURE(".*ERROR: Lattice spacings are invalid.*",
|
||||
lmp->input->one("lattice sc 1.0 spacing 1.0 -0.1 1.0"););
|
||||
command("lattice sc 1.0 spacing 1.0 -0.1 1.0"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("units lj");
|
||||
lmp->input->one("lattice sc 2.0");
|
||||
command("units lj");
|
||||
command("lattice sc 2.0");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
lattice = lmp->domain->lattice;
|
||||
ASSERT_DOUBLE_EQ(lattice->xlattice, pow(0.5, 1.0 / 3.0));
|
||||
@ -177,16 +178,16 @@ TEST_F(LatticeRegionTest, lattice_sc)
|
||||
ASSERT_DOUBLE_EQ(lattice->zlattice, pow(0.5, 1.0 / 3.0));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("dimension 2");
|
||||
command("dimension 2");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
|
||||
lmp->input->one("lattice sc 1.0"););
|
||||
command("lattice sc 1.0"););
|
||||
}
|
||||
|
||||
TEST_F(LatticeRegionTest, lattice_bcc)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice bcc 4.2 orient x 1 1 0 orient y -1 1 0");
|
||||
command("lattice bcc 4.2 orient x 1 1 0 orient y -1 1 0");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
auto lattice = lmp->domain->lattice;
|
||||
ASSERT_EQ(lattice->style, Lattice::BCC);
|
||||
@ -202,16 +203,16 @@ TEST_F(LatticeRegionTest, lattice_bcc)
|
||||
ASSERT_EQ(lattice->basis[1][2], 0.5);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("dimension 2");
|
||||
command("dimension 2");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
|
||||
lmp->input->one("lattice bcc 1.0"););
|
||||
command("lattice bcc 1.0"););
|
||||
}
|
||||
|
||||
TEST_F(LatticeRegionTest, lattice_fcc)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice fcc 3.5 origin 0.5 0.5 0.5");
|
||||
command("lattice fcc 3.5 origin 0.5 0.5 0.5");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
auto lattice = lmp->domain->lattice;
|
||||
ASSERT_EQ(lattice->style, Lattice::FCC);
|
||||
@ -233,23 +234,22 @@ TEST_F(LatticeRegionTest, lattice_fcc)
|
||||
ASSERT_EQ(lattice->basis[3][2], 0.5);
|
||||
|
||||
TEST_FAILURE(".*ERROR: Invalid option in lattice command for non-custom style.*",
|
||||
lmp->input->one("lattice fcc 1.0 basis 0.0 0.0 0.0"););
|
||||
command("lattice fcc 1.0 basis 0.0 0.0 0.0"););
|
||||
TEST_FAILURE(".*ERROR: Invalid option in lattice command for non-custom style.*",
|
||||
lmp->input->one("lattice fcc 1.0 a1 0.0 1.0 0.0"););
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*",
|
||||
lmp->input->one("lattice fcc 1.0 orient w 1 0 0"););
|
||||
command("lattice fcc 1.0 a1 0.0 1.0 0.0"););
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*", command("lattice fcc 1.0 orient w 1 0 0"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("dimension 2");
|
||||
command("dimension 2");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
|
||||
lmp->input->one("lattice fcc 1.0"););
|
||||
command("lattice fcc 1.0"););
|
||||
}
|
||||
|
||||
TEST_F(LatticeRegionTest, lattice_hcp)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice hcp 3.0 orient z 0 0 1");
|
||||
command("lattice hcp 3.0 orient z 0 0 1");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
auto lattice = lmp->domain->lattice;
|
||||
ASSERT_EQ(lattice->style, Lattice::HCP);
|
||||
@ -280,20 +280,20 @@ TEST_F(LatticeRegionTest, lattice_hcp)
|
||||
ASSERT_DOUBLE_EQ(lattice->a3[2], sqrt(8.0 / 3.0));
|
||||
|
||||
TEST_FAILURE(".*ERROR: Invalid option in lattice command for non-custom style.*",
|
||||
lmp->input->one("lattice hcp 1.0 a2 0.0 1.0 0.0"););
|
||||
command("lattice hcp 1.0 a2 0.0 1.0 0.0"););
|
||||
TEST_FAILURE(".*ERROR: Invalid option in lattice command for non-custom style.*",
|
||||
lmp->input->one("lattice hcp 1.0 a3 0.0 1.0 0.0"););
|
||||
command("lattice hcp 1.0 a3 0.0 1.0 0.0"););
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("dimension 2");
|
||||
command("dimension 2");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
|
||||
lmp->input->one("lattice hcp 1.0"););
|
||||
command("lattice hcp 1.0"););
|
||||
}
|
||||
|
||||
TEST_F(LatticeRegionTest, lattice_diamond)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice diamond 4.1 orient x 1 1 2 orient y -1 1 0 orient z -1 -1 1");
|
||||
command("lattice diamond 4.1 orient x 1 1 2 orient y -1 1 0 orient z -1 -1 1");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
auto lattice = lmp->domain->lattice;
|
||||
ASSERT_EQ(lattice->style, Lattice::DIAMOND);
|
||||
@ -336,17 +336,17 @@ TEST_F(LatticeRegionTest, lattice_diamond)
|
||||
ASSERT_EQ(lattice->a3[2], 1.0);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("dimension 2");
|
||||
command("dimension 2");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
|
||||
lmp->input->one("lattice diamond 1.0"););
|
||||
command("lattice diamond 1.0"););
|
||||
}
|
||||
|
||||
TEST_F(LatticeRegionTest, lattice_sq)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("dimension 2");
|
||||
lmp->input->one("lattice sq 3.0");
|
||||
command("dimension 2");
|
||||
command("lattice sq 3.0");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
auto lattice = lmp->domain->lattice;
|
||||
ASSERT_EQ(lattice->style, Lattice::SQ);
|
||||
@ -358,22 +358,21 @@ TEST_F(LatticeRegionTest, lattice_sq)
|
||||
ASSERT_EQ(lattice->basis[0][1], 0.0);
|
||||
ASSERT_EQ(lattice->basis[0][2], 0.0);
|
||||
|
||||
TEST_FAILURE(
|
||||
".*ERROR: Lattice settings are not compatible with 2d simulation.*",
|
||||
lmp->input->one("lattice sq 1.0 orient x 1 1 2 orient y -1 1 0 orient z -1 -1 1"););
|
||||
TEST_FAILURE(".*ERROR: Lattice settings are not compatible with 2d simulation.*",
|
||||
command("lattice sq 1.0 orient x 1 1 2 orient y -1 1 0 orient z -1 -1 1"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("dimension 3");
|
||||
command("dimension 3");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
|
||||
lmp->input->one("lattice sq 1.0"););
|
||||
command("lattice sq 1.0"););
|
||||
}
|
||||
|
||||
TEST_F(LatticeRegionTest, lattice_sq2)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("dimension 2");
|
||||
lmp->input->one("lattice sq2 2.0");
|
||||
command("dimension 2");
|
||||
command("lattice sq2 2.0");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
auto lattice = lmp->domain->lattice;
|
||||
ASSERT_EQ(lattice->style, Lattice::SQ2);
|
||||
@ -389,17 +388,17 @@ TEST_F(LatticeRegionTest, lattice_sq2)
|
||||
ASSERT_EQ(lattice->basis[1][2], 0.0);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("dimension 3");
|
||||
command("dimension 3");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
|
||||
lmp->input->one("lattice sq2 1.0"););
|
||||
command("lattice sq2 1.0"););
|
||||
}
|
||||
|
||||
TEST_F(LatticeRegionTest, lattice_hex)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("dimension 2");
|
||||
lmp->input->one("lattice hex 2.0");
|
||||
command("dimension 2");
|
||||
command("lattice hex 2.0");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
auto lattice = lmp->domain->lattice;
|
||||
ASSERT_EQ(lattice->style, Lattice::HEX);
|
||||
@ -424,32 +423,32 @@ TEST_F(LatticeRegionTest, lattice_hex)
|
||||
ASSERT_EQ(lattice->a3[2], 1.0);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("dimension 3");
|
||||
command("dimension 3");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
|
||||
lmp->input->one("lattice hex 1.0"););
|
||||
command("lattice hex 1.0"););
|
||||
}
|
||||
|
||||
TEST_F(LatticeRegionTest, lattice_custom)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("variable a equal 4.34");
|
||||
lmp->input->one("variable b equal $a*sqrt(3.0)");
|
||||
lmp->input->one("variable c equal $a*sqrt(8.0/3.0)");
|
||||
lmp->input->one("variable t equal 1.0/3.0");
|
||||
lmp->input->one("variable f equal 5.0/6.0");
|
||||
lmp->input->one("lattice custom 1.0 "
|
||||
"a1 $a 0.0 0.0 "
|
||||
"a2 0.0 $b 0.0 "
|
||||
"a3 0.0 0.0 $c "
|
||||
"basis 0.0 0.0 0.0 "
|
||||
"basis 0.5 0.5 0.0 "
|
||||
"basis $t 0.0 0.5 "
|
||||
"basis $f 0.5 0.5 "
|
||||
"basis 0.0 0.0 0.625 "
|
||||
"basis 0.5 0.5 0.625 "
|
||||
"basis $t 0.0 0.125 "
|
||||
"basis $f 0.5 0.125 ");
|
||||
command("variable a equal 4.34");
|
||||
command("variable b equal $a*sqrt(3.0)");
|
||||
command("variable c equal $a*sqrt(8.0/3.0)");
|
||||
command("variable t equal 1.0/3.0");
|
||||
command("variable f equal 5.0/6.0");
|
||||
command("lattice custom 1.0 "
|
||||
"a1 $a 0.0 0.0 "
|
||||
"a2 0.0 $b 0.0 "
|
||||
"a3 0.0 0.0 $c "
|
||||
"basis 0.0 0.0 0.0 "
|
||||
"basis 0.5 0.5 0.0 "
|
||||
"basis $t 0.0 0.5 "
|
||||
"basis $f 0.5 0.5 "
|
||||
"basis 0.0 0.0 0.625 "
|
||||
"basis 0.5 0.5 0.625 "
|
||||
"basis $t 0.0 0.125 "
|
||||
"basis $f 0.5 0.125 ");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
auto lattice = lmp->domain->lattice;
|
||||
ASSERT_EQ(lattice->style, Lattice::CUSTOM);
|
||||
@ -492,47 +491,47 @@ TEST_F(LatticeRegionTest, lattice_custom)
|
||||
ASSERT_DOUBLE_EQ(lattice->a3[2], 4.34 * sqrt(8.0 / 3.0));
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*",
|
||||
lmp->input->one("lattice custom 1.0 basis -0.1 0 0"););
|
||||
command("lattice custom 1.0 basis -0.1 0 0"););
|
||||
TEST_FAILURE(".*ERROR: Illegal lattice command.*",
|
||||
lmp->input->one("lattice custom 1.0 basis 0.0 1.0 0"););
|
||||
command("lattice custom 1.0 basis 0.0 1.0 0"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("dimension 2");
|
||||
command("dimension 2");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: No basis atoms in lattice.*", lmp->input->one("lattice custom 1.0"););
|
||||
TEST_FAILURE(".*ERROR: No basis atoms in lattice.*", command("lattice custom 1.0"););
|
||||
TEST_FAILURE(".*ERROR: Lattice settings are not compatible with 2d simulation.*",
|
||||
lmp->input->one("lattice custom 1.0 origin 0.5 0.5 0.5 basis 0.0 0.0 0.0"););
|
||||
command("lattice custom 1.0 origin 0.5 0.5 0.5 basis 0.0 0.0 0.0"););
|
||||
TEST_FAILURE(".*ERROR: Lattice settings are not compatible with 2d simulation.*",
|
||||
lmp->input->one("lattice custom 1.0 a1 1.0 1.0 1.0 basis 0.0 0.0 0.0"););
|
||||
command("lattice custom 1.0 a1 1.0 1.0 1.0 basis 0.0 0.0 0.0"););
|
||||
TEST_FAILURE(".*ERROR: Lattice settings are not compatible with 2d simulation.*",
|
||||
lmp->input->one("lattice custom 1.0 a2 1.0 1.0 1.0 basis 0.0 0.0 0.0"););
|
||||
command("lattice custom 1.0 a2 1.0 1.0 1.0 basis 0.0 0.0 0.0"););
|
||||
TEST_FAILURE(".*ERROR: Lattice settings are not compatible with 2d simulation.*",
|
||||
lmp->input->one("lattice custom 1.0 a3 1.0 1.0 1.0 basis 0.0 0.0 0.0"););
|
||||
command("lattice custom 1.0 a3 1.0 1.0 1.0 basis 0.0 0.0 0.0"););
|
||||
}
|
||||
|
||||
TEST_F(LatticeRegionTest, region_fail)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice none 2.0");
|
||||
lmp->input->one("region box block 0 1 0 1 0 1");
|
||||
command("lattice none 2.0");
|
||||
command("region box block 0 1 0 1 0 1");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Create_atoms command before simulation box is defined.*",
|
||||
lmp->input->one("create_atoms 1 box"););
|
||||
command("create_atoms 1 box"););
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("create_box 1 box");
|
||||
command("create_box 1 box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Cannot create atoms with undefined lattice.*",
|
||||
lmp->input->one("create_atoms 1 box"););
|
||||
command("create_atoms 1 box"););
|
||||
}
|
||||
|
||||
TEST_F(LatticeRegionTest, region_block_lattice)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice sc 1.5");
|
||||
lmp->input->one("region box block 0 2 0 2 0 2 units lattice");
|
||||
lmp->input->one("create_box 1 box");
|
||||
lmp->input->one("create_atoms 1 box");
|
||||
command("lattice sc 1.5");
|
||||
command("region box block 0 2 0 2 0 2 units lattice");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_EQ(lmp->domain->triclinic, 0);
|
||||
@ -555,10 +554,10 @@ TEST_F(LatticeRegionTest, region_block_lattice)
|
||||
TEST_F(LatticeRegionTest, region_block_box)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice sc 1.5 origin 0.75 0.75 0.75");
|
||||
lmp->input->one("region box block 0 2 0 2 0 2 units box");
|
||||
lmp->input->one("create_box 1 box");
|
||||
lmp->input->one("create_atoms 1 box");
|
||||
command("lattice sc 1.5 origin 0.75 0.75 0.75");
|
||||
command("region box block 0 2 0 2 0 2 units box");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->domain->triclinic, 0);
|
||||
|
||||
@ -572,11 +571,11 @@ TEST_F(LatticeRegionTest, region_block_box)
|
||||
TEST_F(LatticeRegionTest, region_cone)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice fcc 2.5 origin 0.5 0.5 0.5");
|
||||
lmp->input->one("region box cone x 1.0 1.0 0.5 2.1 0.0 2.0");
|
||||
lmp->input->one("create_box 1 box");
|
||||
lmp->input->one("create_atoms 1 region box");
|
||||
lmp->input->one("write_dump all atom init.lammpstrj");
|
||||
command("lattice fcc 2.5 origin 0.5 0.5 0.5");
|
||||
command("region box cone x 1.0 1.0 0.5 2.1 0.0 2.0");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 region box");
|
||||
command("write_dump all atom init.lammpstrj");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->domain->triclinic, 0);
|
||||
ASSERT_EQ(lmp->atom->natoms, 42);
|
||||
@ -585,10 +584,10 @@ TEST_F(LatticeRegionTest, region_cone)
|
||||
TEST_F(LatticeRegionTest, region_cylinder)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice fcc 2.5 origin 0.5 0.5 0.5");
|
||||
lmp->input->one("region box cylinder z 1.0 1.0 2.1 0.0 2.0 ");
|
||||
lmp->input->one("create_box 1 box");
|
||||
lmp->input->one("create_atoms 1 region box");
|
||||
command("lattice fcc 2.5 origin 0.5 0.5 0.5");
|
||||
command("region box cylinder z 1.0 1.0 2.1 0.0 2.0 ");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 region box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->domain->triclinic, 0);
|
||||
ASSERT_EQ(lmp->atom->natoms, 114);
|
||||
@ -597,10 +596,10 @@ TEST_F(LatticeRegionTest, region_cylinder)
|
||||
TEST_F(LatticeRegionTest, region_prism)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice bcc 2.5 origin 0.75 0.75 0.75");
|
||||
lmp->input->one("region box prism 0 2 0 2 0 2 0.5 0.0 0.0");
|
||||
lmp->input->one("create_box 1 box");
|
||||
lmp->input->one("create_atoms 1 box");
|
||||
command("lattice bcc 2.5 origin 0.75 0.75 0.75");
|
||||
command("region box prism 0 2 0 2 0 2 0.5 0.0 0.0");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->domain->triclinic, 1);
|
||||
ASSERT_EQ(lmp->atom->natoms, 16);
|
||||
@ -609,10 +608,10 @@ TEST_F(LatticeRegionTest, region_prism)
|
||||
TEST_F(LatticeRegionTest, region_sphere)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice fcc 2.5 origin 0.5 0.5 0.5");
|
||||
lmp->input->one("region box sphere 1.0 1.0 1.0 1.1");
|
||||
lmp->input->one("create_box 1 box");
|
||||
lmp->input->one("create_atoms 1 region box");
|
||||
command("lattice fcc 2.5 origin 0.5 0.5 0.5");
|
||||
command("region box sphere 1.0 1.0 1.0 1.1");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 region box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->domain->triclinic, 0);
|
||||
ASSERT_EQ(lmp->atom->natoms, 14);
|
||||
@ -621,12 +620,12 @@ TEST_F(LatticeRegionTest, region_sphere)
|
||||
TEST_F(LatticeRegionTest, region_union)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice fcc 2.5 origin 0.5 0.5 0.5");
|
||||
lmp->input->one("region part1 sphere 2.0 1.0 1.0 1.1");
|
||||
lmp->input->one("region part2 block 0.0 2.0 0.0 2.0 0.0 2.0");
|
||||
lmp->input->one("region box union 2 part1 part2");
|
||||
lmp->input->one("create_box 1 box");
|
||||
lmp->input->one("create_atoms 1 region box");
|
||||
command("lattice fcc 2.5 origin 0.5 0.5 0.5");
|
||||
command("region part1 sphere 2.0 1.0 1.0 1.1");
|
||||
command("region part2 block 0.0 2.0 0.0 2.0 0.0 2.0");
|
||||
command("region box union 2 part1 part2");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 region box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->domain->triclinic, 0);
|
||||
ASSERT_EQ(lmp->atom->natoms, 67);
|
||||
@ -635,12 +634,12 @@ TEST_F(LatticeRegionTest, region_union)
|
||||
TEST_F(LatticeRegionTest, region_intersect)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice fcc 2.5 origin 0.5 0.5 0.5");
|
||||
lmp->input->one("region part1 sphere 2.0 1.0 1.0 1.8");
|
||||
lmp->input->one("region part2 block 0.0 2.0 0.0 2.0 0.0 2.0");
|
||||
lmp->input->one("region box intersect 2 part1 part2");
|
||||
lmp->input->one("create_box 1 box");
|
||||
lmp->input->one("create_atoms 1 region box");
|
||||
command("lattice fcc 2.5 origin 0.5 0.5 0.5");
|
||||
command("region part1 sphere 2.0 1.0 1.0 1.8");
|
||||
command("region part2 block 0.0 2.0 0.0 2.0 0.0 2.0");
|
||||
command("region box intersect 2 part1 part2");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 region box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->domain->triclinic, 0);
|
||||
ASSERT_EQ(lmp->atom->natoms, 21);
|
||||
@ -649,14 +648,14 @@ TEST_F(LatticeRegionTest, region_intersect)
|
||||
TEST_F(LatticeRegionTest, region_plane)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("lattice fcc 2.5 origin 0.5 0.5 0.5");
|
||||
lmp->input->one("region box block 0.0 2.0 0.0 2.0 0.0 2.0");
|
||||
lmp->input->one("region part1 plane 0.5 1.0 0.0 0.75 0.0 0.0");
|
||||
lmp->input->one("region part2 plane 1.5 1.0 0.0 0.75 0.0 0.0 side out");
|
||||
lmp->input->one("region atoms intersect 2 part1 part2");
|
||||
lmp->input->one("create_box 1 box");
|
||||
lmp->input->one("create_atoms 1 region atoms");
|
||||
lmp->input->one("write_dump all atom init.lammpstrj");
|
||||
command("lattice fcc 2.5 origin 0.5 0.5 0.5");
|
||||
command("region box block 0.0 2.0 0.0 2.0 0.0 2.0");
|
||||
command("region part1 plane 0.5 1.0 0.0 0.75 0.0 0.0");
|
||||
command("region part2 plane 1.5 1.0 0.0 0.75 0.0 0.0 side out");
|
||||
command("region atoms intersect 2 part1 part2");
|
||||
command("create_box 1 box");
|
||||
command("create_atoms 1 region atoms");
|
||||
command("write_dump all atom init.lammpstrj");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->domain->triclinic, 0);
|
||||
ASSERT_EQ(lmp->atom->natoms, 16);
|
||||
|
||||
@ -85,6 +85,8 @@ protected:
|
||||
delete lmp;
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void command(const std::string &cmd) { lmp->input->one(cmd); }
|
||||
};
|
||||
|
||||
TEST_F(ResetIDsTest, MolIDAll)
|
||||
@ -125,7 +127,7 @@ TEST_F(ResetIDsTest, MolIDAll)
|
||||
// the original data file has two different molecule IDs
|
||||
// for two residues of the same molecule/fragment.
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("reset_mol_ids all");
|
||||
command("reset_mol_ids all");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_EQ(molid[GETIDX(1)], 1);
|
||||
@ -167,10 +169,10 @@ TEST_F(ResetIDsTest, DeletePlusAtomID)
|
||||
|
||||
// delete two water molecules
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("group allwater molecule 3:6");
|
||||
lmp->input->one("group twowater molecule 4:6:2");
|
||||
lmp->input->one("delete_atoms group twowater compress no bond yes");
|
||||
lmp->input->one("reset_mol_ids all");
|
||||
command("group allwater molecule 3:6");
|
||||
command("group twowater molecule 4:6:2");
|
||||
command("delete_atoms group twowater compress no bond yes");
|
||||
command("reset_mol_ids all");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->atom->natoms, 23);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 26);
|
||||
@ -229,7 +231,7 @@ TEST_F(ResetIDsTest, DeletePlusAtomID)
|
||||
ASSERT_GE(GETIDX(26), 0);
|
||||
|
||||
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, 23);
|
||||
@ -245,9 +247,9 @@ TEST_F(ResetIDsTest, PartialOffset)
|
||||
|
||||
// delete two water molecules
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("group allwater molecule 3:6");
|
||||
lmp->input->one("group nowater subtract all allwater");
|
||||
lmp->input->one("reset_mol_ids allwater offset 4");
|
||||
command("group allwater molecule 3:6");
|
||||
command("group nowater subtract all allwater");
|
||||
command("reset_mol_ids allwater offset 4");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->atom->natoms, 29);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 29);
|
||||
@ -283,7 +285,7 @@ TEST_F(ResetIDsTest, PartialOffset)
|
||||
ASSERT_EQ(molid[GETIDX(29)], 8);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("reset_mol_ids nowater offset 0");
|
||||
command("reset_mol_ids nowater offset 0");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_EQ(molid[GETIDX(1)], 1);
|
||||
@ -325,11 +327,11 @@ TEST_F(ResetIDsTest, DeleteAdd)
|
||||
|
||||
// delete two water molecules
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("group allwater molecule 3:6");
|
||||
lmp->input->one("group twowater molecule 4:6:2");
|
||||
lmp->input->one("group nowater subtract all allwater");
|
||||
lmp->input->one("delete_atoms group twowater compress no bond yes mol yes");
|
||||
lmp->input->one("reset_mol_ids allwater");
|
||||
command("group allwater molecule 3:6");
|
||||
command("group twowater molecule 4:6:2");
|
||||
command("group nowater subtract all allwater");
|
||||
command("delete_atoms group twowater compress no bond yes mol yes");
|
||||
command("reset_mol_ids allwater");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->atom->natoms, 23);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 26);
|
||||
@ -388,7 +390,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
|
||||
ASSERT_GE(GETIDX(26), 0);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("reset_atom_ids sort yes");
|
||||
command("reset_atom_ids sort yes");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 23);
|
||||
@ -396,7 +398,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
|
||||
ASSERT_GE(GETIDX(i), 0);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("reset_mol_ids nowater offset 1");
|
||||
command("reset_mol_ids nowater offset 1");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_EQ(molid[GETIDX(1)], 2);
|
||||
@ -424,11 +426,11 @@ TEST_F(ResetIDsTest, DeleteAdd)
|
||||
ASSERT_EQ(molid[GETIDX(23)], 4);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("create_atoms 1 single 0.0 0.0 0.0");
|
||||
lmp->input->one("create_atoms 2 single 1.0 0.0 0.0");
|
||||
lmp->input->one("create_atoms 3 single 2.0 0.0 0.0");
|
||||
lmp->input->one("create_atoms 4 single 3.0 0.0 0.0");
|
||||
lmp->input->one("reset_mol_ids all single yes");
|
||||
command("create_atoms 1 single 0.0 0.0 0.0");
|
||||
command("create_atoms 2 single 1.0 0.0 0.0");
|
||||
command("create_atoms 3 single 2.0 0.0 0.0");
|
||||
command("create_atoms 4 single 3.0 0.0 0.0");
|
||||
command("reset_mol_ids all single yes");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->atom->natoms, 27);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 27);
|
||||
@ -442,7 +444,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
|
||||
ASSERT_EQ(molid[GETIDX(27)], 7);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("reset_mol_ids all single no");
|
||||
command("reset_mol_ids all single no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_EQ(molid[GETIDX(21)], 3);
|
||||
@ -454,7 +456,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
|
||||
ASSERT_EQ(molid[GETIDX(27)], 0);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("reset_mol_ids all compress no single yes");
|
||||
command("reset_mol_ids all compress no single yes");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
ASSERT_EQ(molid[GETIDX(21)], 21);
|
||||
@ -472,20 +474,20 @@ TEST_F(ResetIDsTest, TopologyData)
|
||||
|
||||
// delete two water molecules
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("group allwater molecule 3:6");
|
||||
lmp->input->one("group twowater molecule 4:6:2");
|
||||
lmp->input->one("group nowater subtract all allwater");
|
||||
lmp->input->one("delete_atoms group twowater compress no bond yes mol yes");
|
||||
command("group allwater molecule 3:6");
|
||||
command("group twowater molecule 4:6:2");
|
||||
command("group nowater subtract all allwater");
|
||||
command("delete_atoms group twowater compress no bond yes mol yes");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->atom->natoms, 23);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 26);
|
||||
|
||||
auto num_bond = lmp->atom->num_bond;
|
||||
auto num_angle = lmp->atom->num_angle;
|
||||
auto bond_atom = lmp->atom->bond_atom;
|
||||
auto angle_atom1 = lmp->atom->angle_atom1;
|
||||
auto angle_atom2 = lmp->atom->angle_atom2;
|
||||
auto angle_atom3 = lmp->atom->angle_atom3;
|
||||
auto num_bond = lmp->atom->num_bond;
|
||||
auto num_angle = lmp->atom->num_angle;
|
||||
auto bond_atom = lmp->atom->bond_atom;
|
||||
auto angle_atom1 = lmp->atom->angle_atom1;
|
||||
auto angle_atom2 = lmp->atom->angle_atom2;
|
||||
auto angle_atom3 = lmp->atom->angle_atom3;
|
||||
ASSERT_EQ(num_bond[GETIDX(1)], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(1)][0], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(1)][1], 3);
|
||||
@ -561,15 +563,15 @@ TEST_F(ResetIDsTest, TopologyData)
|
||||
ASSERT_EQ(angle_atom3[GETIDX(24)][0], 26);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("reset_atom_ids sort yes");
|
||||
command("reset_atom_ids sort yes");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
num_bond = lmp->atom->num_bond;
|
||||
num_angle = lmp->atom->num_angle;
|
||||
bond_atom = lmp->atom->bond_atom;
|
||||
angle_atom1 = lmp->atom->angle_atom1;
|
||||
angle_atom2 = lmp->atom->angle_atom2;
|
||||
angle_atom3 = lmp->atom->angle_atom3;
|
||||
num_bond = lmp->atom->num_bond;
|
||||
num_angle = lmp->atom->num_angle;
|
||||
bond_atom = lmp->atom->bond_atom;
|
||||
angle_atom1 = lmp->atom->angle_atom1;
|
||||
angle_atom2 = lmp->atom->angle_atom2;
|
||||
angle_atom3 = lmp->atom->angle_atom3;
|
||||
ASSERT_EQ(num_bond[GETIDX(1)], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(1)][0], 3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(1)][1], 2);
|
||||
@ -658,26 +660,23 @@ TEST_F(ResetIDsTest, DeathTests)
|
||||
{
|
||||
if (lmp->atom->natoms == 0) GTEST_SKIP();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", lmp->input->one("reset_mol_ids"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", command("reset_mol_ids"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
|
||||
lmp->input->one("reset_mol_ids all offset 1 1"););
|
||||
command("reset_mol_ids all offset 1 1"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
|
||||
lmp->input->one("reset_mol_ids all offset -2"););
|
||||
command("reset_mol_ids all offset -2"););
|
||||
TEST_FAILURE(".*ERROR on proc 0: Expected integer.*", command("reset_mol_ids all offset xxx"););
|
||||
TEST_FAILURE(".*ERROR on proc 0: Expected integer.*",
|
||||
lmp->input->one("reset_mol_ids all offset xxx"););
|
||||
TEST_FAILURE(".*ERROR on proc 0: Expected integer.*",
|
||||
lmp->input->one("reset_mol_ids all compress yes single no offset xxx"););
|
||||
command("reset_mol_ids all compress yes single no offset xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", command("reset_mol_ids all offset"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
|
||||
lmp->input->one("reset_mol_ids all offset"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
|
||||
lmp->input->one("reset_mol_ids all compress"););
|
||||
command("reset_mol_ids all compress"););
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
|
||||
lmp->input->one("reset_mol_ids all compress xxx"););
|
||||
command("reset_mol_ids all compress xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", command("reset_mol_ids all single"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
|
||||
lmp->input->one("reset_mol_ids all single"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
|
||||
lmp->input->one("reset_mol_ids all single xxx"););
|
||||
command("reset_mol_ids all single xxx"););
|
||||
}
|
||||
|
||||
TEST(ResetMolIds, CMDFail)
|
||||
@ -693,20 +692,23 @@ TEST(ResetMolIds, CMDFail)
|
||||
TEST_FAILURE(".*ERROR: Reset_mol_ids command before simulation box is.*",
|
||||
lmp->input->one("reset_mol_ids all"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("atom_modify id no");
|
||||
lmp->input->one("region box block 0 1 0 1 0 1");
|
||||
lmp->input->one("create_box 1 box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Cannot use reset_mol_ids unless.*",
|
||||
lmp->input->one("reset_mol_ids all"););
|
||||
auto command = [&](const std::string &line) {
|
||||
lmp->input->one(line.c_str());
|
||||
};
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("region box block 0 1 0 1 0 1");
|
||||
lmp->input->one("create_box 1 box");
|
||||
command("atom_modify id no");
|
||||
command("region box block 0 1 0 1 0 1");
|
||||
command("create_box 1 box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Can only use reset_mol_ids.*", lmp->input->one("reset_mol_ids all"););
|
||||
TEST_FAILURE(".*ERROR: Cannot use reset_mol_ids unless.*", command("reset_mol_ids all"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command("clear");
|
||||
command("region box block 0 1 0 1 0 1");
|
||||
command("create_box 1 box");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Can only use reset_mol_ids.*", command("reset_mol_ids all"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
delete lmp;
|
||||
|
||||
@ -82,11 +82,13 @@ protected:
|
||||
delete lmp;
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void command(const std::string &cmd) { lmp->input->one(cmd); }
|
||||
};
|
||||
|
||||
TEST_F(SimpleCommandsTest, UnknownCommand)
|
||||
{
|
||||
TEST_FAILURE(".*ERROR: Unknown command.*", lmp->input->one("XXX one two"););
|
||||
TEST_FAILURE(".*ERROR: Unknown command.*", command("XXX one two"););
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, Echo)
|
||||
@ -95,31 +97,31 @@ TEST_F(SimpleCommandsTest, Echo)
|
||||
ASSERT_EQ(lmp->input->echo_log, 0);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("echo none");
|
||||
command("echo none");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->input->echo_screen, 0);
|
||||
ASSERT_EQ(lmp->input->echo_log, 0);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("echo both");
|
||||
command("echo both");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->input->echo_screen, 1);
|
||||
ASSERT_EQ(lmp->input->echo_log, 1);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("echo screen");
|
||||
command("echo screen");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->input->echo_screen, 1);
|
||||
ASSERT_EQ(lmp->input->echo_log, 0);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("echo log");
|
||||
command("echo log");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->input->echo_screen, 0);
|
||||
ASSERT_EQ(lmp->input->echo_log, 1);
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal echo command.*", lmp->input->one("echo"););
|
||||
TEST_FAILURE(".*ERROR: Illegal echo command.*", lmp->input->one("echo xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal echo command.*", command("echo"););
|
||||
TEST_FAILURE(".*ERROR: Illegal echo command.*", command("echo xxx"););
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, Log)
|
||||
@ -127,13 +129,13 @@ TEST_F(SimpleCommandsTest, Log)
|
||||
ASSERT_EQ(lmp->logfile, nullptr);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("log simple_command_test.log");
|
||||
lmp->input->one("print 'test1'");
|
||||
command("log simple_command_test.log");
|
||||
command("print 'test1'");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_NE(lmp->logfile, nullptr);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("log none");
|
||||
command("log none");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->logfile, nullptr);
|
||||
|
||||
@ -145,12 +147,12 @@ TEST_F(SimpleCommandsTest, Log)
|
||||
ASSERT_THAT(text, StrEq("test1"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("log simple_command_test.log append");
|
||||
lmp->input->one("print 'test2'");
|
||||
command("log simple_command_test.log append");
|
||||
command("print 'test2'");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_NE(lmp->logfile, nullptr);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("log none");
|
||||
command("log none");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->logfile, nullptr);
|
||||
|
||||
@ -162,7 +164,7 @@ TEST_F(SimpleCommandsTest, Log)
|
||||
in.close();
|
||||
remove("simple_command_test.log");
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal log command.*", lmp->input->one("log"););
|
||||
TEST_FAILURE(".*ERROR: Illegal log command.*", command("log"););
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, Newton)
|
||||
@ -171,22 +173,22 @@ TEST_F(SimpleCommandsTest, Newton)
|
||||
ASSERT_EQ(lmp->force->newton_pair, 1);
|
||||
ASSERT_EQ(lmp->force->newton_bond, 1);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("newton off");
|
||||
command("newton off");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->force->newton_pair, 0);
|
||||
ASSERT_EQ(lmp->force->newton_bond, 0);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("newton on off");
|
||||
command("newton on off");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->force->newton_pair, 1);
|
||||
ASSERT_EQ(lmp->force->newton_bond, 0);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("newton off on");
|
||||
command("newton off on");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->force->newton_pair, 0);
|
||||
ASSERT_EQ(lmp->force->newton_bond, 1);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("newton on");
|
||||
command("newton on");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->force->newton_pair, 1);
|
||||
ASSERT_EQ(lmp->force->newton_bond, 1);
|
||||
@ -195,21 +197,20 @@ TEST_F(SimpleCommandsTest, Newton)
|
||||
TEST_F(SimpleCommandsTest, Partition)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("echo none");
|
||||
command("echo none");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Illegal partition command .*",
|
||||
lmp->input->one("partition xxx 1 echo none"););
|
||||
TEST_FAILURE(".*ERROR: Illegal partition command .*", command("partition xxx 1 echo none"););
|
||||
TEST_FAILURE(".*ERROR: Numeric index 2 is out of bounds.*",
|
||||
lmp->input->one("partition yes 2 echo none"););
|
||||
command("partition yes 2 echo none"););
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one("partition yes 1 print 'test'");
|
||||
command("partition yes 1 print 'test'");
|
||||
auto text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, StrEq("test\n"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one("partition no 1 print 'test'");
|
||||
command("partition no 1 print 'test'");
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, StrEq(""));
|
||||
@ -218,14 +219,14 @@ TEST_F(SimpleCommandsTest, Partition)
|
||||
TEST_F(SimpleCommandsTest, Quit)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one("echo none");
|
||||
command("echo none");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
TEST_FAILURE(".*ERROR: Expected integer .*", lmp->input->one("quit xxx"););
|
||||
TEST_FAILURE(".*ERROR: Expected integer .*", command("quit xxx"););
|
||||
|
||||
// the following tests must be skipped with OpenMPI due to using threads
|
||||
if (have_openmpi) GTEST_SKIP();
|
||||
ASSERT_EXIT(lmp->input->one("quit"), ExitedWithCode(0), "");
|
||||
ASSERT_EXIT(lmp->input->one("quit 9"), ExitedWithCode(9), "");
|
||||
ASSERT_EXIT(command("quit"), ExitedWithCode(0), "");
|
||||
ASSERT_EXIT(command("quit 9"), ExitedWithCode(9), "");
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, ResetTimestep)
|
||||
@ -233,19 +234,19 @@ TEST_F(SimpleCommandsTest, ResetTimestep)
|
||||
ASSERT_EQ(lmp->update->ntimestep, 0);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("reset_timestep 10");
|
||||
command("reset_timestep 10");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->update->ntimestep, 10);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("reset_timestep 0");
|
||||
command("reset_timestep 0");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->update->ntimestep, 0);
|
||||
|
||||
TEST_FAILURE(".*ERROR: Timestep must be >= 0.*", lmp->input->one("reset_timestep -10"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_timestep .*", lmp->input->one("reset_timestep"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_timestep .*", lmp->input->one("reset_timestep 10 10"););
|
||||
TEST_FAILURE(".*ERROR: Expected integer .*", lmp->input->one("reset_timestep xxx"););
|
||||
TEST_FAILURE(".*ERROR: Timestep must be >= 0.*", command("reset_timestep -10"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_timestep .*", command("reset_timestep"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_timestep .*", command("reset_timestep 10 10"););
|
||||
TEST_FAILURE(".*ERROR: Expected integer .*", command("reset_timestep xxx"););
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, Suffix)
|
||||
@ -254,39 +255,38 @@ TEST_F(SimpleCommandsTest, Suffix)
|
||||
ASSERT_EQ(lmp->suffix, nullptr);
|
||||
ASSERT_EQ(lmp->suffix2, nullptr);
|
||||
|
||||
TEST_FAILURE(".*ERROR: May only enable suffixes after defining one.*",
|
||||
lmp->input->one("suffix on"););
|
||||
TEST_FAILURE(".*ERROR: May only enable suffixes after defining one.*", command("suffix on"););
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("suffix one");
|
||||
command("suffix one");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_THAT(lmp->suffix, StrEq("one"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("suffix hybrid two three");
|
||||
command("suffix hybrid two three");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_THAT(lmp->suffix, StrEq("two"));
|
||||
ASSERT_THAT(lmp->suffix2, StrEq("three"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("suffix four");
|
||||
command("suffix four");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_THAT(lmp->suffix, StrEq("four"));
|
||||
ASSERT_EQ(lmp->suffix2, nullptr);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("suffix off");
|
||||
command("suffix off");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->suffix_enable, 0);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("suffix on");
|
||||
command("suffix on");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->suffix_enable, 1);
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal suffix command.*", lmp->input->one("suffix"););
|
||||
TEST_FAILURE(".*ERROR: Illegal suffix command.*", lmp->input->one("suffix hybrid"););
|
||||
TEST_FAILURE(".*ERROR: Illegal suffix command.*", lmp->input->one("suffix hybrid one"););
|
||||
TEST_FAILURE(".*ERROR: Illegal suffix command.*", command("suffix"););
|
||||
TEST_FAILURE(".*ERROR: Illegal suffix command.*", command("suffix hybrid"););
|
||||
TEST_FAILURE(".*ERROR: Illegal suffix command.*", command("suffix hybrid one"););
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, Thermo)
|
||||
@ -294,53 +294,53 @@ TEST_F(SimpleCommandsTest, Thermo)
|
||||
ASSERT_EQ(lmp->output->thermo_every, 0);
|
||||
ASSERT_EQ(lmp->output->var_thermo, nullptr);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("thermo 2");
|
||||
command("thermo 2");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->output->thermo_every, 2);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("variable step equal logfreq(10,3,10)");
|
||||
lmp->input->one("thermo v_step");
|
||||
command("variable step equal logfreq(10,3,10)");
|
||||
command("thermo v_step");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_THAT(lmp->output->var_thermo, StrEq("step"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("thermo 10");
|
||||
command("thermo 10");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->output->thermo_every, 10);
|
||||
ASSERT_EQ(lmp->output->var_thermo, nullptr);
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal thermo command.*", lmp->input->one("thermo"););
|
||||
TEST_FAILURE(".*ERROR: Illegal thermo command.*", lmp->input->one("thermo -1"););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", lmp->input->one("thermo xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal thermo command.*", command("thermo"););
|
||||
TEST_FAILURE(".*ERROR: Illegal thermo command.*", command("thermo -1"););
|
||||
TEST_FAILURE(".*ERROR: Expected integer.*", command("thermo xxx"););
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, TimeStep)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("timestep 1");
|
||||
command("timestep 1");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->update->dt, 1.0);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("timestep 0.1");
|
||||
command("timestep 0.1");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->update->dt, 0.1);
|
||||
|
||||
// zero timestep is legal and works (atoms don't move)
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("timestep 0.0");
|
||||
command("timestep 0.0");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->update->dt, 0.0);
|
||||
|
||||
// negative timestep also creates a viable MD.
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("timestep -0.1");
|
||||
command("timestep -0.1");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->update->dt, -0.1);
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal timestep command.*", lmp->input->one("timestep"););
|
||||
TEST_FAILURE(".*ERROR: Expected floating point.*", lmp->input->one("timestep xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal timestep command.*", command("timestep"););
|
||||
TEST_FAILURE(".*ERROR: Expected floating point.*", command("timestep xxx"););
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, Units)
|
||||
@ -353,24 +353,24 @@ TEST_F(SimpleCommandsTest, Units)
|
||||
ASSERT_THAT(lmp->update->unit_style, StrEq("lj"));
|
||||
for (std::size_t i = 0; i < num; ++i) {
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one(fmt::format("units {}", names[i]));
|
||||
command(fmt::format("units {}", names[i]));
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_THAT(lmp->update->unit_style, StrEq(names[i]));
|
||||
ASSERT_EQ(lmp->update->dt, dt[i]);
|
||||
}
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
command("clear");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_THAT(lmp->update->unit_style, StrEq("lj"));
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal units command.*", lmp->input->one("units unknown"););
|
||||
TEST_FAILURE(".*ERROR: Illegal units command.*", command("units unknown"););
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, Shell)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("shell putenv TEST_VARIABLE=simpletest");
|
||||
command("shell putenv TEST_VARIABLE=simpletest");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
char *test_var = getenv("TEST_VARIABLE");
|
||||
@ -378,8 +378,8 @@ TEST_F(SimpleCommandsTest, Shell)
|
||||
ASSERT_THAT(test_var, StrEq("simpletest"));
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("shell putenv TEST_VARIABLE=simpletest");
|
||||
lmp->input->one("shell putenv TEST_VARIABLE2=simpletest2 OTHER_VARIABLE=2");
|
||||
command("shell putenv TEST_VARIABLE=simpletest");
|
||||
command("shell putenv TEST_VARIABLE2=simpletest2 OTHER_VARIABLE=2");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
char *test_var2 = getenv("TEST_VARIABLE2");
|
||||
|
||||
@ -298,31 +298,31 @@ TEST_F(VariableTest, IfCommand)
|
||||
command("if 1>0 then 'print \".*bingo!\"'");
|
||||
auto text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text,MatchesRegex(".*bingo!.*"));
|
||||
ASSERT_THAT(text, MatchesRegex(".*bingo!.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
command("if (1>=0) then 'print \"bingo!\"'");
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text,MatchesRegex(".*bingo!.*"));
|
||||
ASSERT_THAT(text, MatchesRegex(".*bingo!.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
command("if (-1.0e-1<0.0E+0) then 'print \"bingo!\"'");
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text,MatchesRegex(".*bingo!.*"));
|
||||
ASSERT_THAT(text, MatchesRegex(".*bingo!.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
command("if (${one}==1.0)&&(2>=1) then 'print \"bingo!\"'");
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text,MatchesRegex(".*bingo!.*"));
|
||||
ASSERT_THAT(text, MatchesRegex(".*bingo!.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
command("if !((${one}!=1.0)||(2|^1)) then 'print \"missed\"' else 'print \"bingo!\"'");
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text,MatchesRegex(".*bingo!.*"));
|
||||
ASSERT_THAT(text, MatchesRegex(".*bingo!.*"));
|
||||
|
||||
TEST_FAILURE(".*ERROR: Invalid Boolean syntax in if command.*",
|
||||
command("if () then 'print \"bingo!\"'"););
|
||||
|
||||
Reference in New Issue
Block a user