forked from lijiext/lammps
enable aligning consecutive assignments
This commit is contained in:
parent
3db944decc
commit
9c3d108bbc
|
@ -2,6 +2,7 @@
|
|||
Language: Cpp
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignEscapedNewlines: Left
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortLambdasOnASingleLine: None
|
||||
|
|
|
@ -72,7 +72,7 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new
|
|||
|
||||
// check if prerequisite styles are available
|
||||
Info *info = new Info(lmp);
|
||||
int nfail = 0;
|
||||
int nfail = 0;
|
||||
for (auto &prerequisite : cfg.prerequisites) {
|
||||
std::string style = prerequisite.second;
|
||||
|
||||
|
@ -217,8 +217,9 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
{
|
||||
// initialize system geometry
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS *lmp = init_lammps(argc, argv, config);
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
|
@ -229,7 +230,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
return;
|
||||
}
|
||||
|
||||
const int natoms = lmp->atom->natoms;
|
||||
const int natoms = lmp->atom->natoms;
|
||||
const int bufsize = 256;
|
||||
char buf[bufsize];
|
||||
std::string block("");
|
||||
|
@ -241,8 +242,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
|
||||
// date_generated
|
||||
std::time_t now = time(NULL);
|
||||
block = ctime(&now);
|
||||
block = block.substr(0, block.find("\n") - 1);
|
||||
block = ctime(&now);
|
||||
block = block.substr(0, block.find("\n") - 1);
|
||||
writer.emit("date_generated", block);
|
||||
|
||||
// epsilon
|
||||
|
@ -312,7 +313,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
|
||||
// init_forces
|
||||
block.clear();
|
||||
double **f = lmp->atom->f;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
for (int i = 0; i < natoms; ++i) {
|
||||
snprintf(buf, bufsize, "% 3d % 23.16e % 23.16e % 23.16e\n", (int)tag[i], f[i][0], f[i][1],
|
||||
|
@ -334,7 +335,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
writer.emit_block("run_stress", buf);
|
||||
|
||||
block.clear();
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
for (int i = 0; i < natoms; ++i) {
|
||||
snprintf(buf, bufsize, "% 3d % 23.16e % 23.16e % 23.16e\n", (int)tag[i], f[i][0], f[i][1],
|
||||
|
@ -350,11 +351,13 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
TEST(AngleStyle, plain)
|
||||
{
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
|
@ -375,8 +378,8 @@ TEST(AngleStyle, plain)
|
|||
ASSERT_EQ(lmp->atom->natoms, nlocal);
|
||||
|
||||
double epsilon = test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
ErrorStats stats;
|
||||
stats.reset();
|
||||
const std::vector<coord_t> &f_ref = test_config.init_forces;
|
||||
|
@ -388,7 +391,7 @@ TEST(AngleStyle, plain)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
Angle *angle = lmp->force->angle;
|
||||
Angle *angle = lmp->force->angle;
|
||||
double *stress = angle->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
|
||||
|
@ -407,8 +410,8 @@ TEST(AngleStyle, plain)
|
|||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
stress = angle->virial;
|
||||
f = lmp->atom->f;
|
||||
stress = angle->virial;
|
||||
const std::vector<coord_t> &f_run = test_config.run_forces;
|
||||
ASSERT_EQ(nlocal + 1, f_run.size());
|
||||
stats.reset();
|
||||
|
@ -430,7 +433,7 @@ TEST(AngleStyle, plain)
|
|||
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, energy, epsilon);
|
||||
|
@ -444,7 +447,7 @@ TEST(AngleStyle, plain)
|
|||
// skip over these tests if newton bond is forced to be on
|
||||
if (lmp->force->newton_bond == 0) {
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
|
@ -454,7 +457,7 @@ TEST(AngleStyle, plain)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
angle = lmp->force->angle;
|
||||
angle = lmp->force->angle;
|
||||
stress = angle->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 2 * epsilon);
|
||||
|
@ -473,7 +476,7 @@ TEST(AngleStyle, plain)
|
|||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
stress = angle->virial;
|
||||
stats.reset();
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
|
@ -494,7 +497,7 @@ TEST(AngleStyle, plain)
|
|||
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, energy, epsilon);
|
||||
|
@ -505,7 +508,7 @@ TEST(AngleStyle, plain)
|
|||
restart_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
ASSERT_EQ(nlocal + 1, f_ref.size());
|
||||
|
@ -516,7 +519,7 @@ TEST(AngleStyle, plain)
|
|||
}
|
||||
if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl;
|
||||
|
||||
angle = lmp->force->angle;
|
||||
angle = lmp->force->angle;
|
||||
stress = angle->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
|
||||
|
@ -535,7 +538,7 @@ TEST(AngleStyle, plain)
|
|||
data_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
ASSERT_EQ(nlocal + 1, f_ref.size());
|
||||
|
@ -546,7 +549,7 @@ TEST(AngleStyle, plain)
|
|||
}
|
||||
if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl;
|
||||
|
||||
angle = lmp->force->angle;
|
||||
angle = lmp->force->angle;
|
||||
stress = angle->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
|
||||
|
@ -571,11 +574,13 @@ TEST(AngleStyle, omp)
|
|||
if (!LAMMPS::is_installed_pkg("USER-OMP")) GTEST_SKIP();
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
|
@ -596,9 +601,9 @@ TEST(AngleStyle, omp)
|
|||
ASSERT_EQ(lmp->atom->natoms, nlocal);
|
||||
|
||||
// relax error a bit for USER-OMP package
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
const std::vector<coord_t> &f_ref = test_config.init_forces;
|
||||
ErrorStats stats;
|
||||
stats.reset();
|
||||
|
@ -609,7 +614,7 @@ TEST(AngleStyle, omp)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
Angle *angle = lmp->force->angle;
|
||||
Angle *angle = lmp->force->angle;
|
||||
double *stress = angle->virial;
|
||||
|
||||
stats.reset();
|
||||
|
@ -629,8 +634,8 @@ TEST(AngleStyle, omp)
|
|||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
stress = angle->virial;
|
||||
f = lmp->atom->f;
|
||||
stress = angle->virial;
|
||||
const std::vector<coord_t> &f_run = test_config.run_forces;
|
||||
ASSERT_EQ(nlocal + 1, f_run.size());
|
||||
stats.reset();
|
||||
|
@ -652,7 +657,7 @@ TEST(AngleStyle, omp)
|
|||
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for USER-OMP with angle style hybrid
|
||||
|
@ -669,7 +674,7 @@ TEST(AngleStyle, omp)
|
|||
// skip over these tests if newton bond is forced to be on
|
||||
if (lmp->force->newton_bond == 0) {
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
|
@ -679,7 +684,7 @@ TEST(AngleStyle, omp)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
angle = lmp->force->angle;
|
||||
angle = lmp->force->angle;
|
||||
stress = angle->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
|
||||
|
@ -718,7 +723,7 @@ TEST(AngleStyle, omp)
|
|||
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for USER-OMP with angle style hybrid
|
||||
|
@ -736,8 +741,9 @@ TEST(AngleStyle, omp)
|
|||
TEST(AngleStyle, single)
|
||||
{
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
// create a LAMMPS instance with standard settings to detect the number of atom types
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
|
@ -755,7 +761,7 @@ TEST(AngleStyle, single)
|
|||
|
||||
// gather some information and skip if unsupported
|
||||
int nangletypes = lmp->atom->nangletypes;
|
||||
int molecular = lmp->atom->molecular;
|
||||
int molecular = lmp->atom->molecular;
|
||||
if (molecular != 1) {
|
||||
std::cerr << "Only simple molecular atom styles are supported\n";
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
|
@ -824,13 +830,13 @@ TEST(AngleStyle, single)
|
|||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
int idx1 = lmp->atom->map(1);
|
||||
int idx2 = lmp->atom->map(2);
|
||||
int idx3 = lmp->atom->map(3);
|
||||
int idx1 = lmp->atom->map(1);
|
||||
int idx2 = lmp->atom->map(2);
|
||||
int idx3 = lmp->atom->map(3);
|
||||
double epsilon = test_config.epsilon;
|
||||
double eangle[4], esingle[4];
|
||||
|
||||
eangle[0] = angle->energy;
|
||||
eangle[0] = angle->energy;
|
||||
esingle[0] = angle->single(1, idx1, idx2, idx3);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
|
@ -838,10 +844,10 @@ TEST(AngleStyle, single)
|
|||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
eangle[1] = angle->energy;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
eangle[1] = angle->energy;
|
||||
esingle[1] = angle->single(1, idx1, idx2, idx3);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
|
@ -849,10 +855,10 @@ TEST(AngleStyle, single)
|
|||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
eangle[2] = angle->energy;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
eangle[2] = angle->energy;
|
||||
esingle[2] = angle->single(1, idx1, idx2, idx3);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
|
@ -860,10 +866,10 @@ TEST(AngleStyle, single)
|
|||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
eangle[3] = angle->energy;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
eangle[3] = angle->energy;
|
||||
esingle[3] = angle->single(1, idx1, idx2, idx3);
|
||||
|
||||
ErrorStats stats;
|
||||
|
|
|
@ -72,7 +72,7 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new
|
|||
|
||||
// check if prerequisite styles are available
|
||||
Info *info = new Info(lmp);
|
||||
int nfail = 0;
|
||||
int nfail = 0;
|
||||
for (auto &prerequisite : cfg.prerequisites) {
|
||||
std::string style = prerequisite.second;
|
||||
|
||||
|
@ -217,8 +217,9 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
{
|
||||
// initialize system geometry
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS *lmp = init_lammps(argc, argv, config);
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
|
@ -229,7 +230,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
return;
|
||||
}
|
||||
|
||||
const int natoms = lmp->atom->natoms;
|
||||
const int natoms = lmp->atom->natoms;
|
||||
const int bufsize = 256;
|
||||
char buf[bufsize];
|
||||
std::string block("");
|
||||
|
@ -241,8 +242,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
|
||||
// date_generated
|
||||
std::time_t now = time(NULL);
|
||||
block = ctime(&now);
|
||||
block = block.substr(0, block.find("\n") - 1);
|
||||
block = ctime(&now);
|
||||
block = block.substr(0, block.find("\n") - 1);
|
||||
writer.emit("date_generated", block);
|
||||
|
||||
// epsilon
|
||||
|
@ -312,7 +313,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
|
||||
// init_forces
|
||||
block.clear();
|
||||
double **f = lmp->atom->f;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
for (int i = 0; i < natoms; ++i) {
|
||||
snprintf(buf, bufsize, "% 3d % 23.16e % 23.16e % 23.16e\n", (int)tag[i], f[i][0], f[i][1],
|
||||
|
@ -334,7 +335,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
writer.emit_block("run_stress", buf);
|
||||
|
||||
block.clear();
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
for (int i = 0; i < natoms; ++i) {
|
||||
snprintf(buf, bufsize, "% 3d % 23.16e % 23.16e % 23.16e\n", (int)tag[i], f[i][0], f[i][1],
|
||||
|
@ -350,11 +351,13 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
TEST(BondStyle, plain)
|
||||
{
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
|
@ -375,8 +378,8 @@ TEST(BondStyle, plain)
|
|||
ASSERT_EQ(lmp->atom->natoms, nlocal);
|
||||
|
||||
double epsilon = test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
ErrorStats stats;
|
||||
stats.reset();
|
||||
const std::vector<coord_t> &f_ref = test_config.init_forces;
|
||||
|
@ -388,7 +391,7 @@ TEST(BondStyle, plain)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
Bond *bond = lmp->force->bond;
|
||||
Bond *bond = lmp->force->bond;
|
||||
double *stress = bond->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
|
||||
|
@ -407,8 +410,8 @@ TEST(BondStyle, plain)
|
|||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
stress = bond->virial;
|
||||
f = lmp->atom->f;
|
||||
stress = bond->virial;
|
||||
const std::vector<coord_t> &f_run = test_config.run_forces;
|
||||
ASSERT_EQ(nlocal + 1, f_run.size());
|
||||
stats.reset();
|
||||
|
@ -430,7 +433,7 @@ TEST(BondStyle, plain)
|
|||
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon);
|
||||
|
@ -444,7 +447,7 @@ TEST(BondStyle, plain)
|
|||
// skip over these tests if newton bond is forced to be on
|
||||
if (lmp->force->newton_bond == 0) {
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
|
@ -454,7 +457,7 @@ TEST(BondStyle, plain)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
bond = lmp->force->bond;
|
||||
bond = lmp->force->bond;
|
||||
stress = bond->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 2 * epsilon);
|
||||
|
@ -473,7 +476,7 @@ TEST(BondStyle, plain)
|
|||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
stress = bond->virial;
|
||||
stats.reset();
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
|
@ -494,7 +497,7 @@ TEST(BondStyle, plain)
|
|||
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon);
|
||||
|
@ -505,7 +508,7 @@ TEST(BondStyle, plain)
|
|||
restart_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
ASSERT_EQ(nlocal + 1, f_ref.size());
|
||||
|
@ -516,7 +519,7 @@ TEST(BondStyle, plain)
|
|||
}
|
||||
if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl;
|
||||
|
||||
bond = lmp->force->bond;
|
||||
bond = lmp->force->bond;
|
||||
stress = bond->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
|
||||
|
@ -535,7 +538,7 @@ TEST(BondStyle, plain)
|
|||
data_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
ASSERT_EQ(nlocal + 1, f_ref.size());
|
||||
|
@ -546,7 +549,7 @@ TEST(BondStyle, plain)
|
|||
}
|
||||
if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl;
|
||||
|
||||
bond = lmp->force->bond;
|
||||
bond = lmp->force->bond;
|
||||
stress = bond->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
|
||||
|
@ -571,11 +574,13 @@ TEST(BondStyle, omp)
|
|||
if (!LAMMPS::is_installed_pkg("USER-OMP")) GTEST_SKIP();
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
|
@ -596,9 +601,9 @@ TEST(BondStyle, omp)
|
|||
ASSERT_EQ(lmp->atom->natoms, nlocal);
|
||||
|
||||
// relax error a bit for USER-OMP package
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
const std::vector<coord_t> &f_ref = test_config.init_forces;
|
||||
ErrorStats stats;
|
||||
stats.reset();
|
||||
|
@ -609,7 +614,7 @@ TEST(BondStyle, omp)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
Bond *bond = lmp->force->bond;
|
||||
Bond *bond = lmp->force->bond;
|
||||
double *stress = bond->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
|
||||
|
@ -628,8 +633,8 @@ TEST(BondStyle, omp)
|
|||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
stress = bond->virial;
|
||||
f = lmp->atom->f;
|
||||
stress = bond->virial;
|
||||
const std::vector<coord_t> &f_run = test_config.run_forces;
|
||||
ASSERT_EQ(nlocal + 1, f_run.size());
|
||||
stats.reset();
|
||||
|
@ -651,7 +656,7 @@ TEST(BondStyle, omp)
|
|||
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for USER-OMP with bond style hybrid
|
||||
|
@ -668,7 +673,7 @@ TEST(BondStyle, omp)
|
|||
// skip over these tests if newton bond is forced to be on
|
||||
if (lmp->force->newton_bond == 0) {
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
|
@ -678,7 +683,7 @@ TEST(BondStyle, omp)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
bond = lmp->force->bond;
|
||||
bond = lmp->force->bond;
|
||||
stress = bond->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
|
||||
|
@ -717,7 +722,7 @@ TEST(BondStyle, omp)
|
|||
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for USER-OMP with bond style hybrid
|
||||
|
@ -735,8 +740,9 @@ TEST(BondStyle, omp)
|
|||
TEST(BondStyle, single)
|
||||
{
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
// create a LAMMPS instance with standard settings to detect the number of atom types
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
|
@ -754,7 +760,7 @@ TEST(BondStyle, single)
|
|||
|
||||
// gather some information and skip if unsupported
|
||||
int nbondtypes = lmp->atom->nbondtypes;
|
||||
int molecular = lmp->atom->molecular;
|
||||
int molecular = lmp->atom->molecular;
|
||||
if (molecular != 1) {
|
||||
std::cerr << "Only simple molecular atom styles are supported\n";
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
|
@ -825,21 +831,21 @@ TEST(BondStyle, single)
|
|||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
int idx1 = lmp->atom->map(1);
|
||||
int idx2 = lmp->atom->map(2);
|
||||
int idx3 = lmp->atom->map(3);
|
||||
int idx4 = lmp->atom->map(4);
|
||||
int idx1 = lmp->atom->map(1);
|
||||
int idx2 = lmp->atom->map(2);
|
||||
int idx3 = lmp->atom->map(3);
|
||||
int idx4 = lmp->atom->map(4);
|
||||
double epsilon = test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
double **x = lmp->atom->x;
|
||||
double delx1 = x[idx2][0] - x[idx1][0];
|
||||
double dely1 = x[idx2][1] - x[idx1][1];
|
||||
double delz1 = x[idx2][2] - x[idx1][2];
|
||||
double rsq1 = delx1 * delx1 + dely1 * dely1 + delz1 * delz1;
|
||||
double delx2 = x[idx4][0] - x[idx3][0];
|
||||
double dely2 = x[idx4][1] - x[idx3][1];
|
||||
double delz2 = x[idx4][2] - x[idx3][2];
|
||||
double rsq2 = delx2 * delx2 + dely2 * dely2 + delz2 * delz2;
|
||||
double **f = lmp->atom->f;
|
||||
double **x = lmp->atom->x;
|
||||
double delx1 = x[idx2][0] - x[idx1][0];
|
||||
double dely1 = x[idx2][1] - x[idx1][1];
|
||||
double delz1 = x[idx2][2] - x[idx1][2];
|
||||
double rsq1 = delx1 * delx1 + dely1 * dely1 + delz1 * delz1;
|
||||
double delx2 = x[idx4][0] - x[idx3][0];
|
||||
double dely2 = x[idx4][1] - x[idx3][1];
|
||||
double delz2 = x[idx4][2] - x[idx3][2];
|
||||
double rsq2 = delx2 * delx2 + dely2 * dely2 + delz2 * delz2;
|
||||
double fsingle = 0.0;
|
||||
double ebond[4], esngl[4];
|
||||
ErrorStats stats;
|
||||
|
@ -866,20 +872,20 @@ TEST(BondStyle, single)
|
|||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
x = lmp->atom->x;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
idx4 = lmp->atom->map(4);
|
||||
delx1 = x[idx2][0] - x[idx1][0];
|
||||
dely1 = x[idx2][1] - x[idx1][1];
|
||||
delz1 = x[idx2][2] - x[idx1][2];
|
||||
rsq1 = delx1 * delx1 + dely1 * dely1 + delz1 * delz1;
|
||||
delx2 = x[idx4][0] - x[idx3][0];
|
||||
dely2 = x[idx4][1] - x[idx3][1];
|
||||
delz2 = x[idx4][2] - x[idx3][2];
|
||||
rsq2 = delx2 * delx2 + dely2 * dely2 + delz2 * delz2;
|
||||
f = lmp->atom->f;
|
||||
x = lmp->atom->x;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
idx4 = lmp->atom->map(4);
|
||||
delx1 = x[idx2][0] - x[idx1][0];
|
||||
dely1 = x[idx2][1] - x[idx1][1];
|
||||
delz1 = x[idx2][2] - x[idx1][2];
|
||||
rsq1 = delx1 * delx1 + dely1 * dely1 + delz1 * delz1;
|
||||
delx2 = x[idx4][0] - x[idx3][0];
|
||||
dely2 = x[idx4][1] - x[idx3][1];
|
||||
delz2 = x[idx4][2] - x[idx3][2];
|
||||
rsq2 = delx2 * delx2 + dely2 * dely2 + delz2 * delz2;
|
||||
fsingle = 0.0;
|
||||
|
||||
ebond[1] = bond->energy;
|
||||
|
@ -904,20 +910,20 @@ TEST(BondStyle, single)
|
|||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
x = lmp->atom->x;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
idx4 = lmp->atom->map(4);
|
||||
delx1 = x[idx2][0] - x[idx1][0];
|
||||
dely1 = x[idx2][1] - x[idx1][1];
|
||||
delz1 = x[idx2][2] - x[idx1][2];
|
||||
rsq1 = delx1 * delx1 + dely1 * dely1 + delz1 * delz1;
|
||||
delx2 = x[idx4][0] - x[idx3][0];
|
||||
dely2 = x[idx4][1] - x[idx3][1];
|
||||
delz2 = x[idx4][2] - x[idx3][2];
|
||||
rsq2 = delx2 * delx2 + dely2 * dely2 + delz2 * delz2;
|
||||
f = lmp->atom->f;
|
||||
x = lmp->atom->x;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
idx4 = lmp->atom->map(4);
|
||||
delx1 = x[idx2][0] - x[idx1][0];
|
||||
dely1 = x[idx2][1] - x[idx1][1];
|
||||
delz1 = x[idx2][2] - x[idx1][2];
|
||||
rsq1 = delx1 * delx1 + dely1 * dely1 + delz1 * delz1;
|
||||
delx2 = x[idx4][0] - x[idx3][0];
|
||||
dely2 = x[idx4][1] - x[idx3][1];
|
||||
delz2 = x[idx4][2] - x[idx3][2];
|
||||
rsq2 = delx2 * delx2 + dely2 * dely2 + delz2 * delz2;
|
||||
fsingle = 0.0;
|
||||
|
||||
ebond[2] = bond->energy;
|
||||
|
@ -942,20 +948,20 @@ TEST(BondStyle, single)
|
|||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
x = lmp->atom->x;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
idx4 = lmp->atom->map(4);
|
||||
delx1 = x[idx2][0] - x[idx1][0];
|
||||
dely1 = x[idx2][1] - x[idx1][1];
|
||||
delz1 = x[idx2][2] - x[idx1][2];
|
||||
rsq1 = delx1 * delx1 + dely1 * dely1 + delz1 * delz1;
|
||||
delx2 = x[idx4][0] - x[idx3][0];
|
||||
dely2 = x[idx4][1] - x[idx3][1];
|
||||
delz2 = x[idx4][2] - x[idx3][2];
|
||||
rsq2 = delx2 * delx2 + dely2 * dely2 + delz2 * delz2;
|
||||
f = lmp->atom->f;
|
||||
x = lmp->atom->x;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
idx4 = lmp->atom->map(4);
|
||||
delx1 = x[idx2][0] - x[idx1][0];
|
||||
dely1 = x[idx2][1] - x[idx1][1];
|
||||
delz1 = x[idx2][2] - x[idx1][2];
|
||||
rsq1 = delx1 * delx1 + dely1 * dely1 + delz1 * delz1;
|
||||
delx2 = x[idx4][0] - x[idx3][0];
|
||||
dely2 = x[idx4][1] - x[idx3][1];
|
||||
delz2 = x[idx4][2] - x[idx3][2];
|
||||
rsq2 = delx2 * delx2 + dely2 * dely2 + delz2 * delz2;
|
||||
fsingle = 0.0;
|
||||
|
||||
ebond[3] = bond->energy;
|
||||
|
@ -995,8 +1001,9 @@ TEST(BondStyle, single)
|
|||
TEST(BondStyle, extract)
|
||||
{
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
|
@ -1011,8 +1018,8 @@ TEST(BondStyle, extract)
|
|||
GTEST_SKIP();
|
||||
}
|
||||
Bond *bond = lmp->force->bond;
|
||||
void *ptr = nullptr;
|
||||
int dim = 0;
|
||||
void *ptr = nullptr;
|
||||
int dim = 0;
|
||||
for (auto extract : test_config.extract) {
|
||||
ptr = bond->extract(extract.first.c_str(), dim);
|
||||
EXPECT_NE(ptr, nullptr);
|
||||
|
|
|
@ -12,13 +12,14 @@
|
|||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "error_stats.h"
|
||||
#include "fmt/format.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
void ErrorStats::reset()
|
||||
{
|
||||
num = 0;
|
||||
num = 0;
|
||||
maxidx = -1;
|
||||
sum = sumsq = maxerr = 0.0;
|
||||
}
|
||||
|
@ -47,8 +48,8 @@ double ErrorStats::dev() const
|
|||
std::ostream &operator<<(std::ostream &out, const ErrorStats &stats)
|
||||
{
|
||||
const std::ios_base::fmtflags flags = out.flags();
|
||||
const std::streamsize width = out.width(10);
|
||||
const std::streamsize prec = out.precision(3);
|
||||
const std::streamsize width = out.width(10);
|
||||
const std::streamsize prec = out.precision(3);
|
||||
|
||||
out << std::scientific << "Average: " << stats.avg() << " StdDev: " << stats.dev()
|
||||
<< " MaxErr: " << stats.max();
|
||||
|
|
|
@ -72,7 +72,7 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new
|
|||
|
||||
// check if prerequisite styles are available
|
||||
Info *info = new Info(lmp);
|
||||
int nfail = 0;
|
||||
int nfail = 0;
|
||||
for (auto &prerequisite : cfg.prerequisites) {
|
||||
std::string style = prerequisite.second;
|
||||
|
||||
|
@ -216,8 +216,9 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
{
|
||||
// initialize system geometry
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS *lmp = init_lammps(argc, argv, config);
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
|
@ -228,7 +229,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
return;
|
||||
}
|
||||
|
||||
const int natoms = lmp->atom->natoms;
|
||||
const int natoms = lmp->atom->natoms;
|
||||
const int bufsize = 256;
|
||||
char buf[bufsize];
|
||||
std::string block("");
|
||||
|
@ -240,8 +241,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
|
||||
// date_generated
|
||||
std::time_t now = time(NULL);
|
||||
block = ctime(&now);
|
||||
block = block.substr(0, block.find("\n") - 1);
|
||||
block = ctime(&now);
|
||||
block = block.substr(0, block.find("\n") - 1);
|
||||
writer.emit("date_generated", block);
|
||||
|
||||
// epsilon
|
||||
|
@ -306,7 +307,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
|
||||
// init_forces
|
||||
block.clear();
|
||||
double **f = lmp->atom->f;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
for (int i = 0; i < natoms; ++i) {
|
||||
snprintf(buf, bufsize, "% 3d % 23.16e % 23.16e % 23.16e\n", (int)tag[i], f[i][0], f[i][1],
|
||||
|
@ -331,7 +332,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
writer.emit_block("run_stress", buf);
|
||||
|
||||
block.clear();
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
for (int i = 0; i < natoms; ++i) {
|
||||
snprintf(buf, bufsize, "% 3d % 23.16e % 23.16e % 23.16e\n", (int)tag[i], f[i][0], f[i][1],
|
||||
|
@ -347,11 +348,13 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
|||
TEST(PairStyle, plain)
|
||||
{
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
|
@ -372,8 +375,8 @@ TEST(PairStyle, plain)
|
|||
ASSERT_EQ(lmp->atom->natoms, nlocal);
|
||||
|
||||
double epsilon = test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
ErrorStats stats;
|
||||
stats.reset();
|
||||
const std::vector<coord_t> &f_ref = test_config.init_forces;
|
||||
|
@ -385,7 +388,7 @@ TEST(PairStyle, plain)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
Pair *pair = lmp->force->pair;
|
||||
Pair *pair = lmp->force->pair;
|
||||
double *stress = pair->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
|
||||
|
@ -405,8 +408,8 @@ TEST(PairStyle, plain)
|
|||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
stress = pair->virial;
|
||||
f = lmp->atom->f;
|
||||
stress = pair->virial;
|
||||
const std::vector<coord_t> &f_run = test_config.run_forces;
|
||||
ASSERT_EQ(nlocal + 1, f_run.size());
|
||||
stats.reset();
|
||||
|
@ -428,7 +431,7 @@ TEST(PairStyle, plain)
|
|||
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon);
|
||||
|
@ -443,7 +446,7 @@ TEST(PairStyle, plain)
|
|||
// skip over these tests if newton pair is forced to be on
|
||||
if (lmp->force->newton_pair == 0) {
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
|
@ -453,7 +456,7 @@ TEST(PairStyle, plain)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
pair = lmp->force->pair;
|
||||
pair = lmp->force->pair;
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 3 * epsilon);
|
||||
|
@ -473,7 +476,7 @@ TEST(PairStyle, plain)
|
|||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
|
@ -494,7 +497,7 @@ TEST(PairStyle, plain)
|
|||
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon);
|
||||
|
@ -506,7 +509,7 @@ TEST(PairStyle, plain)
|
|||
restart_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
ASSERT_EQ(nlocal + 1, f_ref.size());
|
||||
|
@ -517,7 +520,7 @@ TEST(PairStyle, plain)
|
|||
}
|
||||
if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl;
|
||||
|
||||
pair = lmp->force->pair;
|
||||
pair = lmp->force->pair;
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
|
||||
|
@ -537,7 +540,7 @@ TEST(PairStyle, plain)
|
|||
data_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
ASSERT_EQ(nlocal + 1, f_ref.size());
|
||||
|
@ -548,7 +551,7 @@ TEST(PairStyle, plain)
|
|||
}
|
||||
if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl;
|
||||
|
||||
pair = lmp->force->pair;
|
||||
pair = lmp->force->pair;
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
|
||||
|
@ -577,8 +580,8 @@ TEST(PairStyle, plain)
|
|||
// and compute_middle() so we get a significant deviation.
|
||||
if (pair->ncoultablebits) epsilon *= 1.0e6;
|
||||
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
pair = lmp->force->pair;
|
||||
stats.reset();
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
|
@ -599,7 +602,7 @@ TEST(PairStyle, plain)
|
|||
if (print_stats) std::cerr << "run_stress stats, r-RESPA:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon);
|
||||
|
@ -616,11 +619,13 @@ TEST(PairStyle, omp)
|
|||
if (!LAMMPS::is_installed_pkg("USER-OMP")) GTEST_SKIP();
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
|
@ -641,9 +646,9 @@ TEST(PairStyle, omp)
|
|||
ASSERT_EQ(lmp->atom->natoms, nlocal);
|
||||
|
||||
// relax error a bit for USER-OMP package
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
const std::vector<coord_t> &f_ref = test_config.init_forces;
|
||||
ErrorStats stats;
|
||||
stats.reset();
|
||||
|
@ -654,7 +659,7 @@ TEST(PairStyle, omp)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
Pair *pair = lmp->force->pair;
|
||||
Pair *pair = lmp->force->pair;
|
||||
double *stress = pair->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
|
||||
|
@ -674,8 +679,8 @@ TEST(PairStyle, omp)
|
|||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
stress = pair->virial;
|
||||
f = lmp->atom->f;
|
||||
stress = pair->virial;
|
||||
const std::vector<coord_t> &f_run = test_config.run_forces;
|
||||
ASSERT_EQ(nlocal + 1, f_run.size());
|
||||
stats.reset();
|
||||
|
@ -697,7 +702,7 @@ TEST(PairStyle, omp)
|
|||
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon);
|
||||
|
@ -712,7 +717,7 @@ TEST(PairStyle, omp)
|
|||
// skip over these tests if newton pair is forced to be on
|
||||
if (lmp->force->newton_pair == 0) {
|
||||
|
||||
f = lmp->atom->f;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
|
@ -722,7 +727,7 @@ TEST(PairStyle, omp)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
pair = lmp->force->pair;
|
||||
pair = lmp->force->pair;
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
|
||||
|
@ -762,7 +767,7 @@ TEST(PairStyle, omp)
|
|||
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon);
|
||||
|
@ -780,11 +785,13 @@ TEST(PairStyle, intel)
|
|||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "intel", "0", "mode", "double", "omp",
|
||||
"4", "lrt", "no", "-sf", "intel"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
|
@ -823,8 +830,8 @@ TEST(PairStyle, intel)
|
|||
const int nlocal = lmp->atom->nlocal;
|
||||
ASSERT_EQ(lmp->atom->natoms, nlocal);
|
||||
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
const std::vector<coord_t> &f_ref = test_config.init_forces;
|
||||
ErrorStats stats;
|
||||
stats.reset();
|
||||
|
@ -835,7 +842,7 @@ TEST(PairStyle, intel)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats:" << stats << std::endl;
|
||||
|
||||
Pair *pair = lmp->force->pair;
|
||||
Pair *pair = lmp->force->pair;
|
||||
double *stress = pair->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
|
||||
|
@ -855,8 +862,8 @@ TEST(PairStyle, intel)
|
|||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
stress = pair->virial;
|
||||
f = lmp->atom->f;
|
||||
stress = pair->virial;
|
||||
const std::vector<coord_t> &f_run = test_config.run_forces;
|
||||
ASSERT_EQ(nlocal + 1, f_run.size());
|
||||
stats.reset();
|
||||
|
@ -878,7 +885,7 @@ TEST(PairStyle, intel)
|
|||
if (print_stats) std::cerr << "run_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon);
|
||||
|
@ -898,13 +905,15 @@ TEST(PairStyle, opt)
|
|||
{
|
||||
if (!LAMMPS::is_installed_pkg("OPT")) GTEST_SKIP();
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite", "-sf", "opt"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config);
|
||||
std::string output;
|
||||
if (!verbose) output = ::testing::internal::GetCapturedStdout();
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles with /opt suffix\n"
|
||||
|
@ -923,9 +932,9 @@ TEST(PairStyle, opt)
|
|||
ASSERT_EQ(lmp->atom->natoms, nlocal);
|
||||
|
||||
// relax error a bit for OPT package
|
||||
double epsilon = 2.0 * test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
double epsilon = 2.0 * test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
const std::vector<coord_t> &f_ref = test_config.init_forces;
|
||||
ErrorStats stats;
|
||||
stats.reset();
|
||||
|
@ -936,7 +945,7 @@ TEST(PairStyle, opt)
|
|||
}
|
||||
if (print_stats) std::cerr << "init_forces stats:" << stats << std::endl;
|
||||
|
||||
Pair *pair = lmp->force->pair;
|
||||
Pair *pair = lmp->force->pair;
|
||||
double *stress = pair->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
|
||||
|
@ -956,8 +965,8 @@ TEST(PairStyle, opt)
|
|||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
stress = pair->virial;
|
||||
f = lmp->atom->f;
|
||||
stress = pair->virial;
|
||||
const std::vector<coord_t> &f_run = test_config.run_forces;
|
||||
ASSERT_EQ(nlocal + 1, f_run.size());
|
||||
stats.reset();
|
||||
|
@ -979,7 +988,7 @@ TEST(PairStyle, opt)
|
|||
if (print_stats) std::cerr << "run_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon);
|
||||
|
@ -994,8 +1003,9 @@ TEST(PairStyle, opt)
|
|||
TEST(PairStyle, single)
|
||||
{
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
// create a LAMMPS instance with standard settings to detect the number of atom types
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
|
@ -1012,7 +1022,7 @@ TEST(PairStyle, single)
|
|||
}
|
||||
|
||||
// gather some information and skip if unsupported
|
||||
int ntypes = lmp->atom->ntypes;
|
||||
int ntypes = lmp->atom->ntypes;
|
||||
int molecular = lmp->atom->molecular;
|
||||
if (molecular > 1) {
|
||||
std::cerr << "Only atomic and simple molecular atom styles are supported\n";
|
||||
|
@ -1115,15 +1125,15 @@ TEST(PairStyle, single)
|
|||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
int idx1 = lmp->atom->map(1);
|
||||
int idx2 = lmp->atom->map(2);
|
||||
int idx1 = lmp->atom->map(1);
|
||||
int idx2 = lmp->atom->map(2);
|
||||
double epsilon = test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
double **x = lmp->atom->x;
|
||||
double delx = x[idx2][0] - x[idx1][0];
|
||||
double dely = x[idx2][1] - x[idx1][1];
|
||||
double delz = x[idx2][2] - x[idx1][2];
|
||||
double rsq = delx * delx + dely * dely + delz * delz;
|
||||
double **f = lmp->atom->f;
|
||||
double **x = lmp->atom->x;
|
||||
double delx = x[idx2][0] - x[idx1][0];
|
||||
double dely = x[idx2][1] - x[idx1][1];
|
||||
double delz = x[idx2][2] - x[idx1][2];
|
||||
double rsq = delx * delx + dely * dely + delz * delz;
|
||||
double fsingle = 0.0;
|
||||
double epair[4], esngl[4];
|
||||
double splj = lmp->force->special_lj[1];
|
||||
|
@ -1144,14 +1154,14 @@ TEST(PairStyle, single)
|
|||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
x = lmp->atom->x;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
delx = x[idx2][0] - x[idx1][0];
|
||||
dely = x[idx2][1] - x[idx1][1];
|
||||
delz = x[idx2][2] - x[idx1][2];
|
||||
rsq = delx * delx + dely * dely + delz * delz;
|
||||
f = lmp->atom->f;
|
||||
x = lmp->atom->x;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
delx = x[idx2][0] - x[idx1][0];
|
||||
dely = x[idx2][1] - x[idx1][1];
|
||||
delz = x[idx2][2] - x[idx1][2];
|
||||
rsq = delx * delx + dely * dely + delz * delz;
|
||||
fsingle = 0.0;
|
||||
|
||||
epair[1] = pair->eng_vdwl + pair->eng_coul;
|
||||
|
@ -1168,14 +1178,14 @@ TEST(PairStyle, single)
|
|||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
x = lmp->atom->x;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
delx = x[idx2][0] - x[idx1][0];
|
||||
dely = x[idx2][1] - x[idx1][1];
|
||||
delz = x[idx2][2] - x[idx1][2];
|
||||
rsq = delx * delx + dely * dely + delz * delz;
|
||||
f = lmp->atom->f;
|
||||
x = lmp->atom->x;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
delx = x[idx2][0] - x[idx1][0];
|
||||
dely = x[idx2][1] - x[idx1][1];
|
||||
delz = x[idx2][2] - x[idx1][2];
|
||||
rsq = delx * delx + dely * dely + delz * delz;
|
||||
fsingle = 0.0;
|
||||
|
||||
epair[2] = pair->eng_vdwl + pair->eng_coul;
|
||||
|
@ -1192,14 +1202,14 @@ TEST(PairStyle, single)
|
|||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
x = lmp->atom->x;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
delx = x[idx2][0] - x[idx1][0];
|
||||
dely = x[idx2][1] - x[idx1][1];
|
||||
delz = x[idx2][2] - x[idx1][2];
|
||||
rsq = delx * delx + dely * dely + delz * delz;
|
||||
f = lmp->atom->f;
|
||||
x = lmp->atom->x;
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
delx = x[idx2][0] - x[idx1][0];
|
||||
dely = x[idx2][1] - x[idx1][1];
|
||||
delz = x[idx2][2] - x[idx1][2];
|
||||
rsq = delx * delx + dely * dely + delz * delz;
|
||||
fsingle = 0.0;
|
||||
|
||||
epair[3] = pair->eng_vdwl + pair->eng_coul;
|
||||
|
@ -1231,8 +1241,9 @@ TEST(PairStyle, single)
|
|||
TEST(PairStyle, extract)
|
||||
{
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
|
@ -1247,8 +1258,8 @@ TEST(PairStyle, extract)
|
|||
GTEST_SKIP();
|
||||
}
|
||||
Pair *pair = lmp->force->pair;
|
||||
void *ptr = nullptr;
|
||||
int dim = 0;
|
||||
void *ptr = nullptr;
|
||||
int dim = 0;
|
||||
for (auto &extract : test_config.extract) {
|
||||
ptr = pair->extract(extract.first.c_str(), dim);
|
||||
EXPECT_NE(ptr, nullptr);
|
||||
|
|
|
@ -29,31 +29,31 @@ TestConfigReader::TestConfigReader(TestConfig &config) : YamlReader(), config(co
|
|||
{
|
||||
consumers["lammps_version"] = &TestConfigReader::lammps_version;
|
||||
consumers["date_generated"] = &TestConfigReader::date_generated;
|
||||
consumers["epsilon"] = &TestConfigReader::epsilon;
|
||||
consumers["prerequisites"] = &TestConfigReader::prerequisites;
|
||||
consumers["pre_commands"] = &TestConfigReader::pre_commands;
|
||||
consumers["post_commands"] = &TestConfigReader::post_commands;
|
||||
consumers["input_file"] = &TestConfigReader::input_file;
|
||||
consumers["extract"] = &TestConfigReader::extract;
|
||||
consumers["natoms"] = &TestConfigReader::natoms;
|
||||
consumers["init_stress"] = &TestConfigReader::init_stress;
|
||||
consumers["run_stress"] = &TestConfigReader::run_stress;
|
||||
consumers["init_forces"] = &TestConfigReader::init_forces;
|
||||
consumers["run_forces"] = &TestConfigReader::run_forces;
|
||||
consumers["epsilon"] = &TestConfigReader::epsilon;
|
||||
consumers["prerequisites"] = &TestConfigReader::prerequisites;
|
||||
consumers["pre_commands"] = &TestConfigReader::pre_commands;
|
||||
consumers["post_commands"] = &TestConfigReader::post_commands;
|
||||
consumers["input_file"] = &TestConfigReader::input_file;
|
||||
consumers["extract"] = &TestConfigReader::extract;
|
||||
consumers["natoms"] = &TestConfigReader::natoms;
|
||||
consumers["init_stress"] = &TestConfigReader::init_stress;
|
||||
consumers["run_stress"] = &TestConfigReader::run_stress;
|
||||
consumers["init_forces"] = &TestConfigReader::init_forces;
|
||||
consumers["run_forces"] = &TestConfigReader::run_forces;
|
||||
|
||||
consumers["pair_style"] = &TestConfigReader::pair_style;
|
||||
consumers["pair_coeff"] = &TestConfigReader::pair_coeff;
|
||||
consumers["init_vdwl"] = &TestConfigReader::init_vdwl;
|
||||
consumers["init_coul"] = &TestConfigReader::init_coul;
|
||||
consumers["run_vdwl"] = &TestConfigReader::run_vdwl;
|
||||
consumers["run_coul"] = &TestConfigReader::run_coul;
|
||||
consumers["init_vdwl"] = &TestConfigReader::init_vdwl;
|
||||
consumers["init_coul"] = &TestConfigReader::init_coul;
|
||||
consumers["run_vdwl"] = &TestConfigReader::run_vdwl;
|
||||
consumers["run_coul"] = &TestConfigReader::run_coul;
|
||||
|
||||
consumers["bond_style"] = &TestConfigReader::bond_style;
|
||||
consumers["bond_coeff"] = &TestConfigReader::bond_coeff;
|
||||
consumers["bond_style"] = &TestConfigReader::bond_style;
|
||||
consumers["bond_coeff"] = &TestConfigReader::bond_coeff;
|
||||
consumers["angle_style"] = &TestConfigReader::angle_style;
|
||||
consumers["angle_coeff"] = &TestConfigReader::angle_coeff;
|
||||
consumers["init_energy"] = &TestConfigReader::init_energy;
|
||||
consumers["run_energy"] = &TestConfigReader::run_energy;
|
||||
consumers["run_energy"] = &TestConfigReader::run_energy;
|
||||
consumers["equilibrium"] = &TestConfigReader::equilibrium;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,13 +22,13 @@ extern bool print_stats;
|
|||
extern bool verbose;
|
||||
extern std::string INPUT_FOLDER;
|
||||
|
||||
#define EXPECT_FP_LE_WITH_EPS(val1, val2, eps) \
|
||||
do { \
|
||||
const double diff = fabs(val1 - val2); \
|
||||
const double div = std::min(fabs(val1), fabs(val2)); \
|
||||
const double err = (div == 0.0) ? diff : diff / div; \
|
||||
stats.add(err); \
|
||||
EXPECT_PRED_FORMAT2(::testing::DoubleLE, err, eps); \
|
||||
#define EXPECT_FP_LE_WITH_EPS(val1, val2, eps) \
|
||||
do { \
|
||||
const double diff = fabs(val1 - val2); \
|
||||
const double div = std::min(fabs(val1), fabs(val2)); \
|
||||
const double err = (div == 0.0) ? diff : diff / div; \
|
||||
stats.add(err); \
|
||||
EXPECT_PRED_FORMAT2(::testing::DoubleLE, err, eps); \
|
||||
} while (0);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
|
||||
int parse_file(const std::string &infile)
|
||||
{
|
||||
basename = infile;
|
||||
basename = infile;
|
||||
std::size_t found = basename.rfind(".yaml");
|
||||
if (found > 0) basename = basename.substr(0, found);
|
||||
found = basename.find_last_of("/\\");
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
protected:
|
||||
bool consume_key_value(const std::string &key, const yaml_event_t &event)
|
||||
{
|
||||
auto it = consumers.find(key);
|
||||
auto it = consumers.find(key);
|
||||
ConsumerClass *consumer = dynamic_cast<ConsumerClass *>(this);
|
||||
|
||||
if (consumer) {
|
||||
|
@ -139,7 +139,7 @@ protected:
|
|||
case ACCEPT_KEY:
|
||||
switch (event.type) {
|
||||
case YAML_SCALAR_EVENT:
|
||||
key = (char *)event.data.scalar.value;
|
||||
key = (char *)event.data.scalar.value;
|
||||
state = ACCEPT_VALUE;
|
||||
break;
|
||||
case YAML_MAPPING_END_EVENT:
|
||||
|
@ -157,7 +157,7 @@ protected:
|
|||
switch (event.type) {
|
||||
case YAML_SCALAR_EVENT:
|
||||
accepted = true;
|
||||
state = ACCEPT_KEY;
|
||||
state = ACCEPT_KEY;
|
||||
break;
|
||||
default:
|
||||
std::cerr << "UNHANDLED YAML EVENT (value): " << event.type
|
||||
|
|
|
@ -32,33 +32,33 @@ protected:
|
|||
const char *args[] = {
|
||||
"PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
::testing::internal::GetCapturedStdout();
|
||||
|
||||
int npair = nelements * (nelements + 1) / 2;
|
||||
setfl.ielement = new int[nelements];
|
||||
setfl.mass = new double[nelements];
|
||||
int npair = nelements * (nelements + 1) / 2;
|
||||
setfl.ielement = new int[nelements];
|
||||
setfl.mass = new double[nelements];
|
||||
setfl.negativity = new double[nelements];
|
||||
setfl.ra = new double[nelements];
|
||||
setfl.ri = new double[nelements];
|
||||
setfl.Ec = new double[nelements];
|
||||
setfl.q0 = new double[nelements];
|
||||
setfl.rcutphiA = new double[npair];
|
||||
setfl.rcutphiR = new double[npair];
|
||||
setfl.Eb = new double[npair];
|
||||
setfl.r0 = new double[npair];
|
||||
setfl.alpha = new double[npair];
|
||||
setfl.beta = new double[npair];
|
||||
setfl.rcutq = new double[npair];
|
||||
setfl.Asigma = new double[npair];
|
||||
setfl.rq = new double[npair];
|
||||
setfl.rcutsigma = new double[npair];
|
||||
setfl.Ac = new double[npair];
|
||||
setfl.zeta = new double[npair];
|
||||
setfl.rs = new double[npair];
|
||||
setfl.tp = new int[npair];
|
||||
setfl.ra = new double[nelements];
|
||||
setfl.ri = new double[nelements];
|
||||
setfl.Ec = new double[nelements];
|
||||
setfl.q0 = new double[nelements];
|
||||
setfl.rcutphiA = new double[npair];
|
||||
setfl.rcutphiR = new double[npair];
|
||||
setfl.Eb = new double[npair];
|
||||
setfl.r0 = new double[npair];
|
||||
setfl.alpha = new double[npair];
|
||||
setfl.beta = new double[npair];
|
||||
setfl.rcutq = new double[npair];
|
||||
setfl.Asigma = new double[npair];
|
||||
setfl.rq = new double[npair];
|
||||
setfl.rcutsigma = new double[npair];
|
||||
setfl.Ac = new double[npair];
|
||||
setfl.zeta = new double[npair];
|
||||
setfl.rs = new double[npair];
|
||||
setfl.tp = new int[npair];
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
|
|
|
@ -54,7 +54,7 @@ protected:
|
|||
const char *args[] = {
|
||||
"PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
::testing::internal::GetCapturedStdout();
|
||||
|
|
|
@ -26,21 +26,21 @@ using ::testing::Eq;
|
|||
TEST(FmtLib, insert_string)
|
||||
{
|
||||
const char val[] = "word";
|
||||
auto text = fmt::format("word {}", val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word word"));
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_int)
|
||||
{
|
||||
const int val = 333;
|
||||
auto text = fmt::format("word {}", val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word 333"));
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_neg_int)
|
||||
{
|
||||
const int val = -333;
|
||||
auto text = fmt::format("word {}", val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word -333"));
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ TEST(FmtLib, insert_bigint)
|
|||
{
|
||||
#if defined(LAMMPS_BIGBIG) || defined(LAMMPS_SMALLBIG)
|
||||
const bigint val = 9945234592L;
|
||||
auto text = fmt::format("word {}", val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word 9945234592"));
|
||||
#else
|
||||
GTEST_SKIP();
|
||||
|
@ -59,7 +59,7 @@ TEST(FmtLib, insert_neg_bigint)
|
|||
{
|
||||
#if defined(LAMMPS_BIGBIG) || defined(LAMMPS_SMALLBIG)
|
||||
const bigint val = -9945234592L;
|
||||
auto text = fmt::format("word {}", val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word -9945234592"));
|
||||
#else
|
||||
GTEST_SKIP();
|
||||
|
@ -70,7 +70,7 @@ TEST(FmtLib, insert_tagint)
|
|||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
const tagint val = 9945234592L;
|
||||
auto text = fmt::format("word {}", val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word 9945234592"));
|
||||
#else
|
||||
GTEST_SKIP();
|
||||
|
@ -81,7 +81,7 @@ TEST(FmtLib, insert_neg_tagint)
|
|||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
const tagint val = -9945234592L;
|
||||
auto text = fmt::format("word {}", val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word -9945234592"));
|
||||
#else
|
||||
GTEST_SKIP();
|
||||
|
@ -92,7 +92,7 @@ TEST(FmtLib, insert_imageint)
|
|||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
const imageint val = 9945234592L;
|
||||
auto text = fmt::format("word {}", val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word 9945234592"));
|
||||
#else
|
||||
GTEST_SKIP();
|
||||
|
@ -103,7 +103,7 @@ TEST(FmtLib, insert_neg_imageint)
|
|||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
const imageint val = -9945234592L;
|
||||
auto text = fmt::format("word {}", val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word -9945234592"));
|
||||
#else
|
||||
GTEST_SKIP();
|
||||
|
@ -113,14 +113,14 @@ TEST(FmtLib, insert_neg_imageint)
|
|||
TEST(FmtLib, insert_double)
|
||||
{
|
||||
const double val = 1.5;
|
||||
auto text = fmt::format("word {}", val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word 1.5"));
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_neg_double)
|
||||
{
|
||||
const double val = -1.5;
|
||||
auto text = fmt::format("word {}", val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word -1.5"));
|
||||
}
|
||||
|
||||
|
|
|
@ -280,7 +280,7 @@ TEST(Utils, path_basename)
|
|||
TEST(Utils, getsyserror)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
errno = ENOENT;
|
||||
errno = ENOENT;
|
||||
std::string errmesg = utils::getsyserror();
|
||||
ASSERT_THAT(errmesg, Eq("No such file or directory"));
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue