add unit conversion to table pair style
This commit is contained in:
@ -140,6 +140,10 @@ TEST_F(PairUnitConvertTest, lj_cut)
|
||||
lmp->input->one("read_data test_pair_unit_convert.data");
|
||||
lmp->input->one("pair_style lj/cut 6.0");
|
||||
lmp->input->one("pair_coeff * * 0.01014286346782117 2.0");
|
||||
remove("test.table.metal");
|
||||
lmp->input->one("pair_write 1 1 1000 r 0.1 6.0 test.table.metal lj_1_1");
|
||||
lmp->input->one("pair_write 1 2 1000 r 0.1 6.0 test.table.metal lj_1_2");
|
||||
lmp->input->one("pair_write 2 2 1000 r 0.1 6.0 test.table.metal lj_2_2");
|
||||
lmp->input->one("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
@ -158,6 +162,10 @@ TEST_F(PairUnitConvertTest, lj_cut)
|
||||
lmp->input->one("read_data test_pair_unit_convert.data");
|
||||
lmp->input->one("pair_style lj/cut 6.0");
|
||||
lmp->input->one("pair_coeff * * 0.2339 2.0");
|
||||
remove("test.table.real");
|
||||
lmp->input->one("pair_write 1 1 1000 r 0.1 6.0 test.table.real lj_1_1");
|
||||
lmp->input->one("pair_write 1 2 1000 r 0.1 6.0 test.table.real lj_1_2");
|
||||
lmp->input->one("pair_write 2 2 1000 r 0.1 6.0 test.table.real lj_2_2");
|
||||
lmp->input->one("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
@ -216,6 +224,101 @@ TEST_F(PairUnitConvertTest, sw)
|
||||
EXPECT_NEAR(ev_convert * fold[i][j], f[i][j], fabs(f[i][j] * rel_error));
|
||||
}
|
||||
|
||||
TEST_F(PairUnitConvertTest, table_metal2real)
|
||||
{
|
||||
// check if the prerequisite pair style is available
|
||||
if (!info->has_style("pair", "table")) GTEST_SKIP();
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("units metal");
|
||||
lmp->input->one("read_data test_pair_unit_convert.data");
|
||||
lmp->input->one("pair_style table linear 1000");
|
||||
lmp->input->one("pair_coeff 1 1 test.table.metal lj_1_1");
|
||||
lmp->input->one("pair_coeff 1 2 test.table.metal lj_1_2");
|
||||
lmp->input->one("pair_coeff 2 2 test.table.metal lj_2_2");
|
||||
lmp->input->one("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// copy pressure, energy, and force from first step
|
||||
double pold;
|
||||
lmp->output->thermo->evaluate_keyword("press", &pold);
|
||||
double eold = lmp->force->pair->eng_vdwl + lmp->force->pair->eng_coul;
|
||||
double **f = lmp->atom->f;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
for (int j = 0; j < 3; ++j)
|
||||
fold[i][j] = f[i][j];
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("units real");
|
||||
lmp->input->one("read_data test_pair_unit_convert.data");
|
||||
lmp->input->one("pair_style table linear 1000");
|
||||
lmp->input->one("pair_coeff 1 1 test.table.metal lj_1_1");
|
||||
lmp->input->one("pair_coeff 1 2 test.table.metal lj_1_2");
|
||||
lmp->input->one("pair_coeff 2 2 test.table.metal lj_2_2");
|
||||
lmp->input->one("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
double pnew;
|
||||
lmp->output->thermo->evaluate_keyword("press", &pnew);
|
||||
EXPECT_NEAR(pold, p_convert * pnew, fabs(pnew * rel_error));
|
||||
double enew = lmp->force->pair->eng_vdwl + lmp->force->pair->eng_coul;
|
||||
EXPECT_NEAR(ev_convert * eold, enew, fabs(enew * rel_error));
|
||||
|
||||
f = lmp->atom->f;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
for (int j = 0; j < 3; ++j)
|
||||
EXPECT_NEAR(ev_convert * fold[i][j], f[i][j], fabs(f[i][j] * rel_error));
|
||||
}
|
||||
|
||||
TEST_F(PairUnitConvertTest, table_real2metal)
|
||||
{
|
||||
// check if the prerequisite pair style is available
|
||||
if (!info->has_style("pair", "table")) GTEST_SKIP();
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("units real");
|
||||
lmp->input->one("read_data test_pair_unit_convert.data");
|
||||
lmp->input->one("pair_style table linear 1000");
|
||||
lmp->input->one("pair_coeff 1 1 test.table.real lj_1_1");
|
||||
lmp->input->one("pair_coeff 1 2 test.table.real lj_1_2");
|
||||
lmp->input->one("pair_coeff 2 2 test.table.real lj_2_2");
|
||||
lmp->input->one("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// copy pressure, energy, and force from first step
|
||||
double pold;
|
||||
lmp->output->thermo->evaluate_keyword("press", &pold);
|
||||
double eold = lmp->force->pair->eng_vdwl + lmp->force->pair->eng_coul;
|
||||
double **f = lmp->atom->f;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
for (int j = 0; j < 3; ++j)
|
||||
fold[i][j] = f[i][j];
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("units metal");
|
||||
lmp->input->one("read_data test_pair_unit_convert.data");
|
||||
lmp->input->one("pair_style table linear 1000");
|
||||
lmp->input->one("pair_coeff 1 1 test.table.real lj_1_1");
|
||||
lmp->input->one("pair_coeff 1 2 test.table.real lj_1_2");
|
||||
lmp->input->one("pair_coeff 2 2 test.table.real lj_2_2");
|
||||
lmp->input->one("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
double pnew;
|
||||
lmp->output->thermo->evaluate_keyword("press", &pnew);
|
||||
EXPECT_NEAR(pold, 1.0/p_convert * pnew, fabs(pnew * rel_error));
|
||||
double enew = lmp->force->pair->eng_vdwl + lmp->force->pair->eng_coul;
|
||||
EXPECT_NEAR(1.0/ev_convert * eold, enew, fabs(enew * rel_error));
|
||||
|
||||
f = lmp->atom->f;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
for (int j = 0; j < 3; ++j)
|
||||
EXPECT_NEAR(1.0/ev_convert * fold[i][j], f[i][j],
|
||||
fabs(f[i][j] * rel_error));
|
||||
}
|
||||
|
||||
TEST_F(PairUnitConvertTest, tersoff)
|
||||
{
|
||||
// check if the prerequisite pair style is available
|
||||
@ -539,5 +642,7 @@ int main(int argc, char **argv)
|
||||
|
||||
int rv = RUN_ALL_TESTS();
|
||||
MPI_Finalize();
|
||||
remove("test.table.metal");
|
||||
remove("test.table.real");
|
||||
return rv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user