add unit conversion to vashishta pair style
This commit is contained in:
@ -40,7 +40,9 @@ const double ev_convert = utils::get_conversion_factor(utils::ENERGY, utils::MET
|
||||
// 1atm in bar
|
||||
const double p_convert = 1.01325;
|
||||
// relative error for comparing numbers
|
||||
const double rel_error = 1.0e-7;
|
||||
// cannot use smaller value due to lack of consistency
|
||||
// of data in update.cpp. could be 1.0e-12
|
||||
const double rel_error = 5.0e-7;
|
||||
|
||||
class PairUnitConvertTest : public ::testing::Test {
|
||||
protected:
|
||||
@ -171,6 +173,49 @@ TEST_F(PairUnitConvertTest, lj_cut)
|
||||
EXPECT_NEAR(ev_convert * fold[i][j], f[i][j], fabs(f[i][j] * rel_error));
|
||||
}
|
||||
|
||||
TEST_F(PairUnitConvertTest, sw)
|
||||
{
|
||||
// check if the prerequisite pair style is available
|
||||
if (!info->has_style("pair", "sw")) 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 sw");
|
||||
lmp->input->one("pair_coeff * * GaN.sw Ga N");
|
||||
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 sw");
|
||||
lmp->input->one("pair_coeff * * GaN.sw Ga N");
|
||||
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, tersoff)
|
||||
{
|
||||
// check if the prerequisite pair style is available
|
||||
@ -256,6 +301,7 @@ TEST_F(PairUnitConvertTest, tersoff_mod)
|
||||
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, tersoff_mod_c)
|
||||
{
|
||||
// check if the prerequisite pair style is available
|
||||
@ -342,16 +388,16 @@ TEST_F(PairUnitConvertTest, tersoff_table)
|
||||
EXPECT_NEAR(ev_convert * fold[i][j], f[i][j], fabs(f[i][j] * rel_error));
|
||||
}
|
||||
|
||||
TEST_F(PairUnitConvertTest, sw)
|
||||
TEST_F(PairUnitConvertTest, vashishta)
|
||||
{
|
||||
// check if the prerequisite pair style is available
|
||||
if (!info->has_style("pair", "sw")) GTEST_SKIP();
|
||||
if (!info->has_style("pair", "vashishta")) 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 sw");
|
||||
lmp->input->one("pair_coeff * * GaN.sw Ga N");
|
||||
lmp->input->one("pair_style vashishta");
|
||||
lmp->input->one("pair_coeff * * SiC.vashishta Si C");
|
||||
lmp->input->one("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
@ -368,8 +414,8 @@ TEST_F(PairUnitConvertTest, sw)
|
||||
lmp->input->one("clear");
|
||||
lmp->input->one("units real");
|
||||
lmp->input->one("read_data test_pair_unit_convert.data");
|
||||
lmp->input->one("pair_style sw");
|
||||
lmp->input->one("pair_coeff * * GaN.sw Ga N");
|
||||
lmp->input->one("pair_style vashishta");
|
||||
lmp->input->one("pair_coeff * * SiC.vashishta Si C");
|
||||
lmp->input->one("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user