update unit tests
This commit is contained in:
@ -162,13 +162,17 @@ TEST(lammps_external, array)
|
||||
for (int i = 0; i < nlocal; ++i)
|
||||
force[i][0] = force[i][1] = force[i][2] = 0.0;
|
||||
lammps_fix_external_set_energy_global(handle, "ext", 0.5);
|
||||
double v[6] = {0.5, 0.5, 0.5, 0.0, 0.0, 0.0};
|
||||
lammps_fix_external_set_virial_global(handle, "ext", v);
|
||||
lammps_command(handle, "run 5 post no");
|
||||
double temp = lammps_get_thermo(handle, "temp");
|
||||
double pe = lammps_get_thermo(handle, "pe");
|
||||
output = ::testing::internal::GetCapturedStdout();
|
||||
double temp = lammps_get_thermo(handle, "temp");
|
||||
double pe = lammps_get_thermo(handle, "pe");
|
||||
double press = lammps_get_thermo(handle, "press");
|
||||
output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
EXPECT_DOUBLE_EQ(temp, 4.0 / 525.0);
|
||||
EXPECT_DOUBLE_EQ(pe, 1.0 / 16.0);
|
||||
EXPECT_DOUBLE_EQ(press, 0.069166666666666668);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
nlocal = lammps_extract_setting(handle, "nlocal");
|
||||
@ -176,13 +180,18 @@ TEST(lammps_external, array)
|
||||
for (int i = 0; i < nlocal; ++i)
|
||||
force[i][0] = force[i][1] = force[i][2] = 6.0;
|
||||
lammps_fix_external_set_energy_global(handle, "ext", 1.0);
|
||||
v[0] = v[1] = v[2] = 1.0;
|
||||
v[3] = v[4] = v[5] = 0.0;
|
||||
lammps_fix_external_set_virial_global(handle, "ext", v);
|
||||
lammps_command(handle, "run 5 post no");
|
||||
temp = lammps_get_thermo(handle, "temp");
|
||||
pe = lammps_get_thermo(handle, "pe");
|
||||
press = lammps_get_thermo(handle, "press");
|
||||
output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
EXPECT_DOUBLE_EQ(temp, 1.0 / 30.0);
|
||||
EXPECT_DOUBLE_EQ(pe, 1.0 / 8.0);
|
||||
EXPECT_DOUBLE_EQ(press, 0.15416666666666667);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lammps_close(handle);
|
||||
|
||||
@ -75,7 +75,8 @@ class PythonExternal(unittest.TestCase):
|
||||
velocity all set 0.1 0.0 -0.1
|
||||
fix 1 all nve
|
||||
fix ext all external pf/array 1
|
||||
thermo_style custom step temp pe ke
|
||||
fix_modify ext energy yes virial yes
|
||||
thermo_style custom step temp pe ke press
|
||||
thermo 5
|
||||
"""
|
||||
lmp.commands_string(basic_system)
|
||||
@ -86,10 +87,12 @@ class PythonExternal(unittest.TestCase):
|
||||
force[i][1] = 0.0
|
||||
force[i][2] = 0.0
|
||||
lmp.fix_external_set_energy_global("ext", 0.5)
|
||||
|
||||
lmp.fix_external_set_virial_global("ext",[0.5, 0.5, 0.5, 0.0, 0.0, 0.0])
|
||||
|
||||
lmp.command("run 5 post no")
|
||||
self.assertAlmostEqual(lmp.get_thermo("temp"),4.0/525.0,14)
|
||||
self.assertAlmostEqual(lmp.get_thermo("pe"),1.0/16.0,14)
|
||||
self.assertAlmostEqual(lmp.get_thermo("press"),0.06916666666666667,14)
|
||||
|
||||
force = lmp.fix_external_get_force("ext");
|
||||
nlocal = lmp.extract_setting("nlocal");
|
||||
@ -98,9 +101,11 @@ class PythonExternal(unittest.TestCase):
|
||||
force[i][1] = 6.0
|
||||
force[i][2] = 6.0
|
||||
lmp.fix_external_set_energy_global("ext", 1.0)
|
||||
lmp.fix_external_set_virial_global("ext",[1.0, 1.0, 1.0, 0.0, 0.0, 0.0])
|
||||
lmp.command("run 5 post no")
|
||||
self.assertAlmostEqual(lmp.get_thermo("temp"),1.0/30.0,14)
|
||||
self.assertAlmostEqual(lmp.get_thermo("pe"),1.0/8.0,14)
|
||||
self.assertAlmostEqual(lmp.get_thermo("press"),0.15416666666666667,14)
|
||||
|
||||
##############################
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user