apply clang-format settings to the c++ sources in the unittest tree
This commit is contained in:
@ -13,32 +13,32 @@
|
||||
|
||||
// unit tests for angle styles intended for molecular systems
|
||||
|
||||
#include "yaml_reader.h"
|
||||
#include "yaml_writer.h"
|
||||
#include "error_stats.h"
|
||||
#include "test_config.h"
|
||||
#include "test_config_reader.h"
|
||||
#include "test_main.h"
|
||||
#include "yaml_reader.h"
|
||||
#include "yaml_writer.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "lammps.h"
|
||||
#include "angle.h"
|
||||
#include "atom.h"
|
||||
#include "modify.h"
|
||||
#include "compute.h"
|
||||
#include "force.h"
|
||||
#include "angle.h"
|
||||
#include "info.h"
|
||||
#include "input.h"
|
||||
#include "lammps.h"
|
||||
#include "modify.h"
|
||||
#include "universe.h"
|
||||
|
||||
#include <mpi.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <mpi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
@ -46,12 +46,13 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using ::testing::StartsWith;
|
||||
using ::testing::HasSubstr;
|
||||
using ::testing::StartsWith;
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
static void delete_file(const std::string & filename) {
|
||||
static void delete_file(const std::string &filename)
|
||||
{
|
||||
remove(filename.c_str());
|
||||
};
|
||||
|
||||
@ -63,9 +64,7 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
delete lmp;
|
||||
}
|
||||
|
||||
LAMMPS *init_lammps(int argc, char **argv,
|
||||
const TestConfig &cfg,
|
||||
const bool newton=true)
|
||||
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool newton = true)
|
||||
{
|
||||
LAMMPS *lmp;
|
||||
|
||||
@ -164,8 +163,7 @@ void restart_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
command("angle_style " + cfg.angle_style);
|
||||
}
|
||||
|
||||
if ((cfg.angle_style.substr(0,6) == "hybrid")
|
||||
|| !lmp->force->angle->writedata) {
|
||||
if ((cfg.angle_style.substr(0, 6) == "hybrid") || !lmp->force->angle->writedata) {
|
||||
for (auto &angle_coeff : cfg.angle_coeff) {
|
||||
command("angle_coeff " + angle_coeff);
|
||||
}
|
||||
@ -226,8 +224,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -309,8 +306,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
// init_stress
|
||||
double *stress = lmp->force->angle->virial;
|
||||
snprintf(buf,bufsize,"% 23.16e % 23.16e % 23.16e % 23.16e % 23.16e % 23.16e",
|
||||
stress[0],stress[1],stress[2],stress[3],stress[4],stress[5]);
|
||||
snprintf(buf, bufsize, "% 23.16e % 23.16e % 23.16e % 23.16e % 23.16e % 23.16e", stress[0],
|
||||
stress[1], stress[2], stress[3], stress[4], stress[5]);
|
||||
writer.emit_block("init_stress", buf);
|
||||
|
||||
// init_forces
|
||||
@ -318,8 +315,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
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], f[i][2]);
|
||||
snprintf(buf, bufsize, "% 3d % 23.16e % 23.16e % 23.16e\n", (int)tag[i], f[i][0], f[i][1],
|
||||
f[i][2]);
|
||||
block += buf;
|
||||
}
|
||||
writer.emit_block("init_forces", block);
|
||||
@ -332,16 +329,16 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
// run_stress
|
||||
stress = lmp->force->angle->virial;
|
||||
snprintf(buf,bufsize,"% 23.16e % 23.16e % 23.16e % 23.16e % 23.16e % 23.16e",
|
||||
stress[0],stress[1],stress[2],stress[3],stress[4],stress[5]);
|
||||
snprintf(buf, bufsize, "% 23.16e % 23.16e % 23.16e % 23.16e % 23.16e % 23.16e", stress[0],
|
||||
stress[1], stress[2], stress[3], stress[4], stress[5]);
|
||||
writer.emit_block("run_stress", buf);
|
||||
|
||||
block.clear();
|
||||
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], f[i][2]);
|
||||
snprintf(buf, bufsize, "% 3d % 23.16e % 23.16e % 23.16e\n", (int)tag[i], f[i][0], f[i][1],
|
||||
f[i][2]);
|
||||
block += buf;
|
||||
}
|
||||
writer.emit_block("run_forces", block);
|
||||
@ -350,7 +347,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
return;
|
||||
}
|
||||
|
||||
TEST(AngleStyle, plain) {
|
||||
TEST(AngleStyle, plain)
|
||||
{
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
@ -364,8 +362,7 @@ TEST(AngleStyle, plain) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -389,8 +386,7 @@ TEST(AngleStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
Angle *angle = lmp->force->angle;
|
||||
double *stress = angle->virial;
|
||||
@ -401,13 +397,11 @@ TEST(AngleStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -423,8 +417,7 @@ TEST(AngleStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
stress = angle->virial;
|
||||
stats.reset();
|
||||
@ -434,16 +427,14 @@ TEST(AngleStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
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);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
@ -461,8 +452,7 @@ TEST(AngleStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
angle = lmp->force->angle;
|
||||
stress = angle->virial;
|
||||
@ -473,13 +463,11 @@ TEST(AngleStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 2 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 2 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 2 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats, newton off:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -493,8 +481,7 @@ TEST(AngleStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
stress = angle->virial;
|
||||
stats.reset();
|
||||
@ -504,16 +491,14 @@ TEST(AngleStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
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);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
}
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
@ -529,8 +514,7 @@ TEST(AngleStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "restart_forces stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl;
|
||||
|
||||
angle = lmp->force->angle;
|
||||
stress = angle->virial;
|
||||
@ -541,13 +525,11 @@ TEST(AngleStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "restart_stress stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "restart_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "restart_energy stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "restart_energy stats:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
data_lammps(lmp, test_config);
|
||||
@ -562,8 +544,7 @@ TEST(AngleStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "data_forces stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl;
|
||||
|
||||
angle = lmp->force->angle;
|
||||
stress = angle->virial;
|
||||
@ -574,23 +555,22 @@ TEST(AngleStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "data_stress stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "data_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "data_energy stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "data_energy stats:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(AngleStyle, omp) {
|
||||
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"};
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
@ -603,8 +583,7 @@ TEST(AngleStyle, omp) {
|
||||
std::cerr << "One or more prerequisite styles with /omp suffix\n"
|
||||
"are not available in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -628,8 +607,7 @@ TEST(AngleStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
Angle *angle = lmp->force->angle;
|
||||
double *stress = angle->virial;
|
||||
@ -641,13 +619,11 @@ TEST(AngleStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -663,8 +639,7 @@ TEST(AngleStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
stress = angle->virial;
|
||||
stats.reset();
|
||||
@ -674,8 +649,7 @@ TEST(AngleStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
@ -685,8 +659,7 @@ TEST(AngleStyle, omp) {
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
if (test_config.angle_style.substr(0, 6) != "hybrid")
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
@ -704,8 +677,7 @@ TEST(AngleStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
angle = lmp->force->angle;
|
||||
stress = angle->virial;
|
||||
@ -716,13 +688,11 @@ TEST(AngleStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats, newton off:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -735,8 +705,7 @@ TEST(AngleStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
stress = angle->virial;
|
||||
stats.reset();
|
||||
@ -746,8 +715,7 @@ TEST(AngleStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
@ -757,8 +725,7 @@ TEST(AngleStyle, omp) {
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
if (test_config.angle_style.substr(0, 6) != "hybrid")
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
}
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
@ -766,7 +733,8 @@ TEST(AngleStyle, omp) {
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(AngleStyle, single) {
|
||||
TEST(AngleStyle, single)
|
||||
{
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
@ -780,8 +748,7 @@ TEST(AngleStyle, single) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -904,8 +871,7 @@ TEST(AngleStyle, single) {
|
||||
EXPECT_FP_LE_WITH_EPS(eangle[1], esingle[1], epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(eangle[2], esingle[2], epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(eangle[3], esingle[3], epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "single_energy stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "single_energy stats:" << stats << std::endl;
|
||||
|
||||
int i = 0;
|
||||
for (auto &dist : test_config.equilibrium)
|
||||
|
||||
@ -13,32 +13,32 @@
|
||||
|
||||
// unit tests for bond styles intended for molecular systems
|
||||
|
||||
#include "yaml_reader.h"
|
||||
#include "yaml_writer.h"
|
||||
#include "error_stats.h"
|
||||
#include "test_config.h"
|
||||
#include "test_config_reader.h"
|
||||
#include "test_main.h"
|
||||
#include "yaml_reader.h"
|
||||
#include "yaml_writer.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "lammps.h"
|
||||
#include "atom.h"
|
||||
#include "modify.h"
|
||||
#include "bond.h"
|
||||
#include "compute.h"
|
||||
#include "force.h"
|
||||
#include "bond.h"
|
||||
#include "info.h"
|
||||
#include "input.h"
|
||||
#include "lammps.h"
|
||||
#include "modify.h"
|
||||
#include "universe.h"
|
||||
|
||||
#include <mpi.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <mpi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
@ -46,12 +46,13 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using ::testing::StartsWith;
|
||||
using ::testing::HasSubstr;
|
||||
using ::testing::StartsWith;
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
static void delete_file(const std::string & filename) {
|
||||
static void delete_file(const std::string &filename)
|
||||
{
|
||||
remove(filename.c_str());
|
||||
};
|
||||
|
||||
@ -63,9 +64,7 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
delete lmp;
|
||||
}
|
||||
|
||||
LAMMPS *init_lammps(int argc, char **argv,
|
||||
const TestConfig &cfg,
|
||||
const bool newton=true)
|
||||
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool newton = true)
|
||||
{
|
||||
LAMMPS *lmp;
|
||||
|
||||
@ -164,8 +163,7 @@ void restart_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
command("bond_style " + cfg.bond_style);
|
||||
}
|
||||
|
||||
if ((cfg.bond_style.substr(0,6) == "hybrid")
|
||||
|| !lmp->force->bond->writedata) {
|
||||
if ((cfg.bond_style.substr(0, 6) == "hybrid") || !lmp->force->bond->writedata) {
|
||||
for (auto &bond_coeff : cfg.bond_coeff) {
|
||||
command("bond_coeff " + bond_coeff);
|
||||
}
|
||||
@ -226,8 +224,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -309,8 +306,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
// init_stress
|
||||
double *stress = lmp->force->bond->virial;
|
||||
snprintf(buf,bufsize,"% 23.16e % 23.16e % 23.16e % 23.16e % 23.16e % 23.16e",
|
||||
stress[0],stress[1],stress[2],stress[3],stress[4],stress[5]);
|
||||
snprintf(buf, bufsize, "% 23.16e % 23.16e % 23.16e % 23.16e % 23.16e % 23.16e", stress[0],
|
||||
stress[1], stress[2], stress[3], stress[4], stress[5]);
|
||||
writer.emit_block("init_stress", buf);
|
||||
|
||||
// init_forces
|
||||
@ -318,8 +315,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
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], f[i][2]);
|
||||
snprintf(buf, bufsize, "% 3d % 23.16e % 23.16e % 23.16e\n", (int)tag[i], f[i][0], f[i][1],
|
||||
f[i][2]);
|
||||
block += buf;
|
||||
}
|
||||
writer.emit_block("init_forces", block);
|
||||
@ -332,16 +329,16 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
// run_stress
|
||||
stress = lmp->force->bond->virial;
|
||||
snprintf(buf,bufsize,"% 23.16e % 23.16e % 23.16e % 23.16e % 23.16e % 23.16e",
|
||||
stress[0],stress[1],stress[2],stress[3],stress[4],stress[5]);
|
||||
snprintf(buf, bufsize, "% 23.16e % 23.16e % 23.16e % 23.16e % 23.16e % 23.16e", stress[0],
|
||||
stress[1], stress[2], stress[3], stress[4], stress[5]);
|
||||
writer.emit_block("run_stress", buf);
|
||||
|
||||
block.clear();
|
||||
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], f[i][2]);
|
||||
snprintf(buf, bufsize, "% 3d % 23.16e % 23.16e % 23.16e\n", (int)tag[i], f[i][0], f[i][1],
|
||||
f[i][2]);
|
||||
block += buf;
|
||||
}
|
||||
writer.emit_block("run_forces", block);
|
||||
@ -350,7 +347,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
return;
|
||||
}
|
||||
|
||||
TEST(BondStyle, plain) {
|
||||
TEST(BondStyle, plain)
|
||||
{
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
@ -364,8 +362,7 @@ TEST(BondStyle, plain) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -389,8 +386,7 @@ TEST(BondStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
Bond *bond = lmp->force->bond;
|
||||
double *stress = bond->virial;
|
||||
@ -401,13 +397,11 @@ TEST(BondStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -423,8 +417,7 @@ TEST(BondStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
stress = bond->virial;
|
||||
stats.reset();
|
||||
@ -434,16 +427,14 @@ TEST(BondStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
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);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
@ -461,8 +452,7 @@ TEST(BondStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
bond = lmp->force->bond;
|
||||
stress = bond->virial;
|
||||
@ -473,13 +463,11 @@ TEST(BondStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 2 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 2 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 2 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats, newton off:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -493,8 +481,7 @@ TEST(BondStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
stress = bond->virial;
|
||||
stats.reset();
|
||||
@ -504,16 +491,14 @@ TEST(BondStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
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);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
}
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
@ -529,8 +514,7 @@ TEST(BondStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "restart_forces stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl;
|
||||
|
||||
bond = lmp->force->bond;
|
||||
stress = bond->virial;
|
||||
@ -541,13 +525,11 @@ TEST(BondStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "restart_stress stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "restart_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "restart_energy stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "restart_energy stats:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
data_lammps(lmp, test_config);
|
||||
@ -562,8 +544,7 @@ TEST(BondStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "data_forces stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl;
|
||||
|
||||
bond = lmp->force->bond;
|
||||
stress = bond->virial;
|
||||
@ -574,23 +555,22 @@ TEST(BondStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "data_stress stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "data_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "data_energy stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "data_energy stats:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(BondStyle, omp) {
|
||||
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"};
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
@ -603,8 +583,7 @@ TEST(BondStyle, omp) {
|
||||
std::cerr << "One or more prerequisite styles with /omp suffix\n"
|
||||
"are not available in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -628,8 +607,7 @@ TEST(BondStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
Bond *bond = lmp->force->bond;
|
||||
double *stress = bond->virial;
|
||||
@ -640,13 +618,11 @@ TEST(BondStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -662,8 +638,7 @@ TEST(BondStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
stress = bond->virial;
|
||||
stats.reset();
|
||||
@ -673,8 +648,7 @@ TEST(BondStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
@ -684,8 +658,7 @@ TEST(BondStyle, omp) {
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
if (test_config.bond_style.substr(0, 6) != "hybrid")
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
@ -703,8 +676,7 @@ TEST(BondStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
bond = lmp->force->bond;
|
||||
stress = bond->virial;
|
||||
@ -715,13 +687,11 @@ TEST(BondStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats, newton off:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -734,8 +704,7 @@ TEST(BondStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
stress = bond->virial;
|
||||
stats.reset();
|
||||
@ -745,8 +714,7 @@ TEST(BondStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
@ -756,8 +724,7 @@ TEST(BondStyle, omp) {
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
if (test_config.bond_style.substr(0, 6) != "hybrid")
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
}
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
@ -765,7 +732,8 @@ TEST(BondStyle, omp) {
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(BondStyle, single) {
|
||||
TEST(BondStyle, single)
|
||||
{
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
@ -779,8 +747,7 @@ TEST(BondStyle, single) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -1007,16 +974,14 @@ TEST(BondStyle, single) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[idx4][0], fsingle * delx2, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[idx4][1], fsingle * dely2, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[idx4][2], fsingle * delz2, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "single_force stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "single_force stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(ebond[0], esngl[0], epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(ebond[1], esngl[1], epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(ebond[2], esngl[2], epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(ebond[3], esngl[3], epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "single_energy stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "single_energy stats:" << stats << std::endl;
|
||||
|
||||
int i = 0;
|
||||
for (auto &dist : test_config.equilibrium)
|
||||
@ -1027,7 +992,8 @@ TEST(BondStyle, single) {
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
TEST(BondStyle, extract) {
|
||||
TEST(BondStyle, extract)
|
||||
{
|
||||
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
@ -1040,8 +1006,7 @@ TEST(BondStyle, extract) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
@ -12,17 +12,19 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "error_stats.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
|
||||
void ErrorStats::reset() {
|
||||
void ErrorStats::reset()
|
||||
{
|
||||
num = 0;
|
||||
maxidx = -1;
|
||||
sum = sumsq = maxerr = 0.0;
|
||||
}
|
||||
|
||||
void ErrorStats::add(const double &val) {
|
||||
void ErrorStats::add(const double &val)
|
||||
{
|
||||
++num;
|
||||
if (val > maxerr) {
|
||||
maxidx = num;
|
||||
@ -32,11 +34,13 @@ void ErrorStats::add(const double &val) {
|
||||
sumsq += val * val;
|
||||
}
|
||||
|
||||
double ErrorStats::avg() const {
|
||||
double ErrorStats::avg() const
|
||||
{
|
||||
return (num > 0) ? sum / num : 0.0;
|
||||
}
|
||||
|
||||
double ErrorStats::dev() const {
|
||||
double ErrorStats::dev() const
|
||||
{
|
||||
return (num > 0) ? sqrt(sumsq / num - sum / num * sum / num) : 0.0;
|
||||
}
|
||||
|
||||
@ -46,9 +50,7 @@ std::ostream &operator<<(std::ostream &out, const ErrorStats &stats)
|
||||
const std::streamsize width = out.width(10);
|
||||
const std::streamsize prec = out.precision(3);
|
||||
|
||||
out << std::scientific
|
||||
<< "Average: " << stats.avg()
|
||||
<< " StdDev: " << stats.dev()
|
||||
out << std::scientific << "Average: " << stats.avg() << " StdDev: " << stats.dev()
|
||||
<< " MaxErr: " << stats.max();
|
||||
|
||||
out.precision(prec);
|
||||
@ -57,4 +59,3 @@ std::ostream &operator<<(std::ostream &out, const ErrorStats &stats)
|
||||
|
||||
return out << " @ item: " << stats.idx();
|
||||
}
|
||||
|
||||
|
||||
@ -20,9 +20,7 @@ class ErrorStats {
|
||||
public:
|
||||
friend std::ostream &operator<<(std::ostream &out, const ErrorStats &stats);
|
||||
|
||||
ErrorStats() {
|
||||
reset();
|
||||
}
|
||||
ErrorStats() { reset(); }
|
||||
virtual ~ErrorStats() {}
|
||||
|
||||
void reset();
|
||||
|
||||
@ -13,32 +13,32 @@
|
||||
|
||||
// unit tests for pair styles intended for molecular systems
|
||||
|
||||
#include "yaml_reader.h"
|
||||
#include "yaml_writer.h"
|
||||
#include "error_stats.h"
|
||||
#include "test_config.h"
|
||||
#include "test_config_reader.h"
|
||||
#include "test_main.h"
|
||||
#include "yaml_reader.h"
|
||||
#include "yaml_writer.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "lammps.h"
|
||||
#include "atom.h"
|
||||
#include "modify.h"
|
||||
#include "compute.h"
|
||||
#include "force.h"
|
||||
#include "pair.h"
|
||||
#include "info.h"
|
||||
#include "input.h"
|
||||
#include "lammps.h"
|
||||
#include "modify.h"
|
||||
#include "pair.h"
|
||||
#include "universe.h"
|
||||
|
||||
#include <mpi.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <mpi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
@ -46,12 +46,13 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using ::testing::StartsWith;
|
||||
using ::testing::HasSubstr;
|
||||
using ::testing::StartsWith;
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
static void delete_file(const std::string & filename) {
|
||||
static void delete_file(const std::string &filename)
|
||||
{
|
||||
remove(filename.c_str());
|
||||
};
|
||||
|
||||
@ -63,9 +64,7 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
delete lmp;
|
||||
}
|
||||
|
||||
LAMMPS *init_lammps(int argc, char **argv,
|
||||
const TestConfig &cfg,
|
||||
const bool newton=true)
|
||||
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool newton = true)
|
||||
{
|
||||
LAMMPS *lmp;
|
||||
|
||||
@ -163,8 +162,7 @@ void restart_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
if (!lmp->force->pair) {
|
||||
command("pair_style " + cfg.pair_style);
|
||||
}
|
||||
if (!lmp->force->pair->restartinfo
|
||||
|| !lmp->force->pair->writedata) {
|
||||
if (!lmp->force->pair->restartinfo || !lmp->force->pair->writedata) {
|
||||
for (auto &pair_coeff : cfg.pair_coeff) {
|
||||
command("pair_coeff " + pair_coeff);
|
||||
}
|
||||
@ -225,8 +223,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto prerequisite : config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -303,8 +300,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
// init_stress
|
||||
double *stress = lmp->force->pair->virial;
|
||||
snprintf(buf,bufsize,"% 23.16e % 23.16e % 23.16e % 23.16e % 23.16e % 23.16e",
|
||||
stress[0],stress[1],stress[2],stress[3],stress[4],stress[5]);
|
||||
snprintf(buf, bufsize, "% 23.16e % 23.16e % 23.16e % 23.16e % 23.16e % 23.16e", stress[0],
|
||||
stress[1], stress[2], stress[3], stress[4], stress[5]);
|
||||
writer.emit_block("init_stress", buf);
|
||||
|
||||
// init_forces
|
||||
@ -312,8 +309,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
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], f[i][2]);
|
||||
snprintf(buf, bufsize, "% 3d % 23.16e % 23.16e % 23.16e\n", (int)tag[i], f[i][0], f[i][1],
|
||||
f[i][2]);
|
||||
block += buf;
|
||||
}
|
||||
writer.emit_block("init_forces", block);
|
||||
@ -329,16 +326,16 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
// run_stress
|
||||
stress = lmp->force->pair->virial;
|
||||
snprintf(buf,bufsize,"% 23.16e % 23.16e % 23.16e % 23.16e % 23.16e % 23.16e",
|
||||
stress[0],stress[1],stress[2],stress[3],stress[4],stress[5]);
|
||||
snprintf(buf, bufsize, "% 23.16e % 23.16e % 23.16e % 23.16e % 23.16e % 23.16e", stress[0],
|
||||
stress[1], stress[2], stress[3], stress[4], stress[5]);
|
||||
writer.emit_block("run_stress", buf);
|
||||
|
||||
block.clear();
|
||||
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], f[i][2]);
|
||||
snprintf(buf, bufsize, "% 3d % 23.16e % 23.16e % 23.16e\n", (int)tag[i], f[i][0], f[i][1],
|
||||
f[i][2]);
|
||||
block += buf;
|
||||
}
|
||||
writer.emit_block("run_forces", block);
|
||||
@ -347,7 +344,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
return;
|
||||
}
|
||||
|
||||
TEST(PairStyle, plain) {
|
||||
TEST(PairStyle, plain)
|
||||
{
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
@ -361,8 +359,7 @@ TEST(PairStyle, plain) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -386,8 +383,7 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
Pair *pair = lmp->force->pair;
|
||||
double *stress = pair->virial;
|
||||
@ -398,14 +394,12 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -421,8 +415,7 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 5 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 5 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
@ -432,8 +425,7 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
@ -441,8 +433,7 @@ TEST(PairStyle, plain) {
|
||||
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);
|
||||
EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl + pair->eng_coul), energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
@ -460,8 +451,7 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
pair = lmp->force->pair;
|
||||
stress = pair->virial;
|
||||
@ -472,14 +462,12 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 3 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 3 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 3 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats, newton off:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -493,8 +481,7 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 5 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 5 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
@ -504,8 +491,7 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
@ -513,8 +499,7 @@ TEST(PairStyle, plain) {
|
||||
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);
|
||||
EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl + pair->eng_coul), energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
}
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
@ -530,8 +515,7 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "restart_forces stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl;
|
||||
|
||||
pair = lmp->force->pair;
|
||||
stress = pair->virial;
|
||||
@ -542,14 +526,12 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "restart_stress stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "restart_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "restart_energy stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "restart_energy stats:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
data_lammps(lmp, test_config);
|
||||
@ -564,8 +546,7 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "data_forces stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl;
|
||||
|
||||
pair = lmp->force->pair;
|
||||
stress = pair->virial;
|
||||
@ -576,14 +557,12 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "data_stress stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "data_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "data_energy stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "data_energy stats:" << stats << std::endl;
|
||||
|
||||
if (pair->respa_enable) {
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
@ -607,8 +586,7 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 5 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 5 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats, r-RESPA:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats, r-RESPA:" << stats << std::endl;
|
||||
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
@ -618,8 +596,7 @@ TEST(PairStyle, plain) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats, r-RESPA:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats, r-RESPA:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
@ -627,18 +604,18 @@ TEST(PairStyle, plain) {
|
||||
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);
|
||||
EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl + pair->eng_coul), energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats, r-RESPA:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats, r-RESPA:" << stats << std::endl;
|
||||
}
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(PairStyle, omp) {
|
||||
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"};
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-pk", "omp", "4", "-sf", "omp"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
@ -651,8 +628,7 @@ TEST(PairStyle, omp) {
|
||||
std::cerr << "One or more prerequisite styles with /omp suffix\n"
|
||||
"are not available in this LAMMPS configuration:\n";
|
||||
for (auto prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -676,8 +652,7 @@ TEST(PairStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
Pair *pair = lmp->force->pair;
|
||||
double *stress = pair->virial;
|
||||
@ -688,14 +663,12 @@ TEST(PairStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -711,8 +684,7 @@ TEST(PairStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 5 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 5 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
|
||||
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
@ -722,8 +694,7 @@ TEST(PairStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
@ -731,8 +702,7 @@ TEST(PairStyle, omp) {
|
||||
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);
|
||||
EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl + pair->eng_coul), energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
@ -750,8 +720,7 @@ TEST(PairStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
pair = lmp->force->pair;
|
||||
stress = pair->virial;
|
||||
@ -762,14 +731,12 @@ TEST(PairStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats, newton off:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -782,8 +749,7 @@ TEST(PairStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 5 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 5 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
|
||||
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
@ -793,8 +759,7 @@ TEST(PairStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
@ -802,19 +767,19 @@ TEST(PairStyle, omp) {
|
||||
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);
|
||||
EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl + pair->eng_coul), energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
}
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(PairStyle, intel) {
|
||||
TEST(PairStyle, intel)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("USER-INTEL")) GTEST_SKIP();
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen",
|
||||
"-nocite", "-pk", "intel", "0", "mode", "double",
|
||||
"omp", "4", "lrt", "no", "-sf", "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 *);
|
||||
|
||||
@ -827,8 +792,7 @@ TEST(PairStyle, intel) {
|
||||
std::cerr << "One or more prerequisite styles with /intel suffix\n"
|
||||
"are not available in this LAMMPS configuration:\n";
|
||||
for (auto prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -848,8 +812,7 @@ TEST(PairStyle, intel) {
|
||||
// coulomb with tabulation. seems more like mixed precision or a bug
|
||||
for (auto post_cmd : test_config.post_commands) {
|
||||
if (post_cmd.find("pair_modify table") != std::string::npos) {
|
||||
if (post_cmd.find("pair_modify table 0") == std::string::npos)
|
||||
epsilon *= 1000000.0;
|
||||
if (post_cmd.find("pair_modify table 0") == std::string::npos) epsilon *= 1000000.0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -870,8 +833,7 @@ TEST(PairStyle, intel) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats:" << stats << std::endl;
|
||||
|
||||
Pair *pair = lmp->force->pair;
|
||||
double *stress = pair->virial;
|
||||
@ -882,14 +844,12 @@ TEST(PairStyle, intel) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -905,8 +865,7 @@ TEST(PairStyle, intel) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 5 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 5 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats:" << stats << std::endl;
|
||||
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
@ -916,8 +875,7 @@ TEST(PairStyle, intel) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
@ -926,22 +884,20 @@ TEST(PairStyle, intel) {
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon);
|
||||
|
||||
// rebo family of pair styles will have a large error in per-atom energy for USER-INTEL
|
||||
if (test_config.pair_style.find("rebo") != std::string::npos)
|
||||
epsilon *= 100000.0;
|
||||
if (test_config.pair_style.find("rebo") != std::string::npos) epsilon *= 100000.0;
|
||||
|
||||
EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl + pair->eng_coul), energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(PairStyle, opt) {
|
||||
TEST(PairStyle, opt)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("OPT")) GTEST_SKIP();
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen",
|
||||
"-nocite", "-sf", "opt"};
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite", "-sf", "opt"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
@ -954,8 +910,7 @@ TEST(PairStyle, opt) {
|
||||
std::cerr << "One or more prerequisite styles with /opt suffix\n"
|
||||
"are not available in this LAMMPS configuration:\n";
|
||||
for (auto prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -979,8 +934,7 @@ TEST(PairStyle, opt) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "init_forces stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_forces stats:" << stats << std::endl;
|
||||
|
||||
Pair *pair = lmp->force->pair;
|
||||
double *stress = pair->virial;
|
||||
@ -991,14 +945,12 @@ TEST(PairStyle, opt) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_stress stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "init_energy stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "init_energy stats:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
@ -1014,8 +966,7 @@ TEST(PairStyle, opt) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 5 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 5 * epsilon);
|
||||
}
|
||||
if (print_stats)
|
||||
std::cerr << "run_forces stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_forces stats:" << stats << std::endl;
|
||||
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
@ -1025,8 +976,7 @@ TEST(PairStyle, opt) {
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_stress stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
@ -1034,15 +984,15 @@ TEST(PairStyle, opt) {
|
||||
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);
|
||||
EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl + pair->eng_coul), energy, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "run_energy stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "run_energy stats:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(PairStyle, single) {
|
||||
TEST(PairStyle, single)
|
||||
{
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
@ -1056,8 +1006,7 @@ TEST(PairStyle, single) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -1075,8 +1024,8 @@ TEST(PairStyle, single) {
|
||||
|
||||
Pair *pair = lmp->force->pair;
|
||||
if (!pair->single_enable) {
|
||||
std::cerr << "Single method not available for pair style "
|
||||
<< test_config.pair_style << std::endl;
|
||||
std::cerr << "Single method not available for pair style " << test_config.pair_style
|
||||
<< std::endl;
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
@ -1085,9 +1034,9 @@ TEST(PairStyle, single) {
|
||||
|
||||
// The single function in EAM is different from what we assume
|
||||
// here, therefore we have to skip testing those pair styles.
|
||||
if ((test_config.pair_style.substr(0,3) == "eam")
|
||||
|| ((test_config.pair_style.substr(0,6) == "hybrid")
|
||||
&& (test_config.pair_style.find("eam") != std::string::npos))) {
|
||||
if ((test_config.pair_style.substr(0, 3) == "eam") ||
|
||||
((test_config.pair_style.substr(0, 6) == "hybrid") &&
|
||||
(test_config.pair_style.find("eam") != std::string::npos))) {
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
@ -1261,18 +1210,16 @@ TEST(PairStyle, single) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[idx2][0], fsingle * delx, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[idx2][1], fsingle * dely, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[idx2][2], fsingle * delz, epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "single_force stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "single_force stats:" << stats << std::endl;
|
||||
|
||||
if ((test_config.pair_style.find("coul/dsf") != std::string::npos)
|
||||
&& (test_config.pair_style.find("coul/wolf") != std::string::npos)) {
|
||||
if ((test_config.pair_style.find("coul/dsf") != std::string::npos) &&
|
||||
(test_config.pair_style.find("coul/wolf") != std::string::npos)) {
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(epair[0], esngl[0], epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(epair[1], esngl[1], epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(epair[2], esngl[2], epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(epair[3], esngl[3], epsilon);
|
||||
if (print_stats)
|
||||
std::cerr << "single_energy stats:" << stats << std::endl;
|
||||
if (print_stats) std::cerr << "single_energy stats:" << stats << std::endl;
|
||||
} else if (print_stats)
|
||||
std::cerr << "skipping single_energy test due to self energy\n";
|
||||
|
||||
@ -1281,7 +1228,8 @@ TEST(PairStyle, single) {
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
TEST(PairStyle, extract) {
|
||||
TEST(PairStyle, extract)
|
||||
{
|
||||
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
@ -1294,8 +1242,7 @@ TEST(PairStyle, extract) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
@ -61,26 +61,13 @@ public:
|
||||
std::vector<coord_t> init_forces;
|
||||
std::vector<coord_t> run_forces;
|
||||
|
||||
TestConfig() : lammps_version(""),
|
||||
date_generated(""),
|
||||
basename(""),
|
||||
epsilon(1.0e-14),
|
||||
input_file(""),
|
||||
pair_style("zero"),
|
||||
bond_style("zero"),
|
||||
angle_style("zero"),
|
||||
dihedral_style("zero"),
|
||||
improper_style("zero"),
|
||||
kspace_style("none"),
|
||||
natoms(0),
|
||||
init_energy(0),
|
||||
run_energy(0),
|
||||
init_vdwl(0),
|
||||
run_vdwl(0),
|
||||
init_coul(0),
|
||||
run_coul(0),
|
||||
init_stress({0,0,0,0,0,0}),
|
||||
run_stress({0,0,0,0,0,0}) {
|
||||
TestConfig() :
|
||||
lammps_version(""), date_generated(""), basename(""), epsilon(1.0e-14), input_file(""),
|
||||
pair_style("zero"), bond_style("zero"), angle_style("zero"), dihedral_style("zero"),
|
||||
improper_style("zero"), kspace_style("none"), natoms(0), init_energy(0), run_energy(0),
|
||||
init_vdwl(0), run_vdwl(0), init_coul(0), run_coul(0), init_stress({0, 0, 0, 0, 0, 0}),
|
||||
run_stress({0, 0, 0, 0, 0, 0})
|
||||
{
|
||||
prerequisites.clear();
|
||||
pre_commands.clear();
|
||||
post_commands.clear();
|
||||
|
||||
@ -11,22 +11,22 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "test_config.h"
|
||||
#include "test_config_reader.h"
|
||||
#include "yaml_reader.h"
|
||||
#include "test_config.h"
|
||||
#include "yaml.h"
|
||||
#include "yaml_reader.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
TestConfigReader::TestConfigReader(TestConfig & config)
|
||||
: YamlReader(), config(config) {
|
||||
TestConfigReader::TestConfigReader(TestConfig &config) : YamlReader(), config(config)
|
||||
{
|
||||
consumers["lammps_version"] = &TestConfigReader::lammps_version;
|
||||
consumers["date_generated"] = &TestConfigReader::date_generated;
|
||||
consumers["epsilon"] = &TestConfigReader::epsilon;
|
||||
@ -57,7 +57,8 @@ TestConfigReader::TestConfigReader(TestConfig & config)
|
||||
consumers["equilibrium"] = &TestConfigReader::equilibrium;
|
||||
}
|
||||
|
||||
void TestConfigReader::prerequisites(const yaml_event_t & event) {
|
||||
void TestConfigReader::prerequisites(const yaml_event_t &event)
|
||||
{
|
||||
config.prerequisites.clear();
|
||||
std::stringstream data((char *)event.data.scalar.value);
|
||||
std::string key, value;
|
||||
@ -69,7 +70,8 @@ void TestConfigReader::prerequisites(const yaml_event_t & event) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestConfigReader::pre_commands(const yaml_event_t & event) {
|
||||
void TestConfigReader::pre_commands(const yaml_event_t &event)
|
||||
{
|
||||
config.pre_commands.clear();
|
||||
std::stringstream data((char *)event.data.scalar.value);
|
||||
std::string line;
|
||||
@ -79,7 +81,8 @@ void TestConfigReader::pre_commands(const yaml_event_t & event) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestConfigReader::post_commands(const yaml_event_t & event) {
|
||||
void TestConfigReader::post_commands(const yaml_event_t &event)
|
||||
{
|
||||
config.post_commands.clear();
|
||||
std::stringstream data((char *)event.data.scalar.value);
|
||||
std::string line;
|
||||
@ -89,23 +92,28 @@ void TestConfigReader::post_commands(const yaml_event_t & event) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestConfigReader::lammps_version(const yaml_event_t & event) {
|
||||
void TestConfigReader::lammps_version(const yaml_event_t &event)
|
||||
{
|
||||
config.lammps_version = (char *)event.data.scalar.value;
|
||||
}
|
||||
|
||||
void TestConfigReader::date_generated(const yaml_event_t & event) {
|
||||
void TestConfigReader::date_generated(const yaml_event_t &event)
|
||||
{
|
||||
config.date_generated = (char *)event.data.scalar.value;
|
||||
}
|
||||
|
||||
void TestConfigReader::epsilon(const yaml_event_t & event) {
|
||||
void TestConfigReader::epsilon(const yaml_event_t &event)
|
||||
{
|
||||
config.epsilon = atof((char *)event.data.scalar.value);
|
||||
}
|
||||
|
||||
void TestConfigReader::input_file(const yaml_event_t & event) {
|
||||
void TestConfigReader::input_file(const yaml_event_t &event)
|
||||
{
|
||||
config.input_file = (char *)event.data.scalar.value;
|
||||
}
|
||||
|
||||
void TestConfigReader::extract(const yaml_event_t & event) {
|
||||
void TestConfigReader::extract(const yaml_event_t &event)
|
||||
{
|
||||
config.extract.clear();
|
||||
std::stringstream data((char *)event.data.scalar.value);
|
||||
std::string name;
|
||||
@ -117,29 +125,29 @@ void TestConfigReader::extract(const yaml_event_t & event) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestConfigReader::natoms(const yaml_event_t & event) {
|
||||
void TestConfigReader::natoms(const yaml_event_t &event)
|
||||
{
|
||||
config.natoms = atoi((char *)event.data.scalar.value);
|
||||
}
|
||||
|
||||
void TestConfigReader::init_stress(const yaml_event_t & event) {
|
||||
void TestConfigReader::init_stress(const yaml_event_t &event)
|
||||
{
|
||||
stress_t stress;
|
||||
sscanf((char *)event.data.scalar.value,
|
||||
"%lg %lg %lg %lg %lg %lg",
|
||||
&stress.xx, &stress.yy, &stress.zz,
|
||||
&stress.xy, &stress.xz, &stress.yz);
|
||||
sscanf((char *)event.data.scalar.value, "%lg %lg %lg %lg %lg %lg", &stress.xx, &stress.yy,
|
||||
&stress.zz, &stress.xy, &stress.xz, &stress.yz);
|
||||
config.init_stress = stress;
|
||||
}
|
||||
|
||||
void TestConfigReader::run_stress(const yaml_event_t & event) {
|
||||
void TestConfigReader::run_stress(const yaml_event_t &event)
|
||||
{
|
||||
stress_t stress;
|
||||
sscanf((char *)event.data.scalar.value,
|
||||
"%lg %lg %lg %lg %lg %lg",
|
||||
&stress.xx, &stress.yy, &stress.zz,
|
||||
&stress.xy, &stress.xz, &stress.yz);
|
||||
sscanf((char *)event.data.scalar.value, "%lg %lg %lg %lg %lg %lg", &stress.xx, &stress.yy,
|
||||
&stress.zz, &stress.xy, &stress.xz, &stress.yz);
|
||||
config.run_stress = stress;
|
||||
}
|
||||
|
||||
void TestConfigReader::init_forces(const yaml_event_t & event) {
|
||||
void TestConfigReader::init_forces(const yaml_event_t &event)
|
||||
{
|
||||
config.init_forces.clear();
|
||||
config.init_forces.resize(config.natoms + 1);
|
||||
std::stringstream data((const char *)event.data.scalar.value);
|
||||
@ -153,7 +161,8 @@ void TestConfigReader::init_forces(const yaml_event_t & event) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestConfigReader::run_forces(const yaml_event_t & event) {
|
||||
void TestConfigReader::run_forces(const yaml_event_t &event)
|
||||
{
|
||||
config.run_forces.clear();
|
||||
config.run_forces.resize(config.natoms + 1);
|
||||
std::stringstream data((char *)event.data.scalar.value);
|
||||
@ -167,11 +176,13 @@ void TestConfigReader::run_forces(const yaml_event_t & event) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestConfigReader::pair_style(const yaml_event_t & event) {
|
||||
void TestConfigReader::pair_style(const yaml_event_t &event)
|
||||
{
|
||||
config.pair_style = (char *)event.data.scalar.value;
|
||||
}
|
||||
|
||||
void TestConfigReader::pair_coeff(const yaml_event_t & event) {
|
||||
void TestConfigReader::pair_coeff(const yaml_event_t &event)
|
||||
{
|
||||
config.pair_coeff.clear();
|
||||
std::stringstream data((char *)event.data.scalar.value);
|
||||
std::string line;
|
||||
@ -181,11 +192,13 @@ void TestConfigReader::pair_coeff(const yaml_event_t & event) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestConfigReader::bond_style(const yaml_event_t & event) {
|
||||
void TestConfigReader::bond_style(const yaml_event_t &event)
|
||||
{
|
||||
config.bond_style = (char *)event.data.scalar.value;
|
||||
}
|
||||
|
||||
void TestConfigReader::bond_coeff(const yaml_event_t & event) {
|
||||
void TestConfigReader::bond_coeff(const yaml_event_t &event)
|
||||
{
|
||||
config.bond_coeff.clear();
|
||||
std::stringstream data((char *)event.data.scalar.value);
|
||||
std::string line;
|
||||
@ -195,11 +208,13 @@ void TestConfigReader::bond_coeff(const yaml_event_t & event) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestConfigReader::angle_style(const yaml_event_t & event) {
|
||||
void TestConfigReader::angle_style(const yaml_event_t &event)
|
||||
{
|
||||
config.angle_style = (char *)event.data.scalar.value;
|
||||
}
|
||||
|
||||
void TestConfigReader::angle_coeff(const yaml_event_t & event) {
|
||||
void TestConfigReader::angle_coeff(const yaml_event_t &event)
|
||||
{
|
||||
config.angle_coeff.clear();
|
||||
std::stringstream data((char *)event.data.scalar.value);
|
||||
std::string line;
|
||||
@ -209,7 +224,8 @@ void TestConfigReader::angle_coeff(const yaml_event_t & event) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestConfigReader::equilibrium(const yaml_event_t & event) {
|
||||
void TestConfigReader::equilibrium(const yaml_event_t &event)
|
||||
{
|
||||
std::stringstream data((char *)event.data.scalar.value);
|
||||
config.equilibrium.clear();
|
||||
double value;
|
||||
@ -222,27 +238,32 @@ void TestConfigReader::equilibrium(const yaml_event_t & event) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestConfigReader::init_vdwl(const yaml_event_t & event) {
|
||||
void TestConfigReader::init_vdwl(const yaml_event_t &event)
|
||||
{
|
||||
config.init_vdwl = atof((char *)event.data.scalar.value);
|
||||
}
|
||||
|
||||
void TestConfigReader::init_coul(const yaml_event_t & event) {
|
||||
void TestConfigReader::init_coul(const yaml_event_t &event)
|
||||
{
|
||||
config.init_coul = atof((char *)event.data.scalar.value);
|
||||
}
|
||||
|
||||
void TestConfigReader::run_vdwl(const yaml_event_t & event) {
|
||||
void TestConfigReader::run_vdwl(const yaml_event_t &event)
|
||||
{
|
||||
config.run_vdwl = atof((char *)event.data.scalar.value);
|
||||
}
|
||||
|
||||
void TestConfigReader::run_coul(const yaml_event_t & event) {
|
||||
void TestConfigReader::run_coul(const yaml_event_t &event)
|
||||
{
|
||||
config.run_coul = atof((char *)event.data.scalar.value);
|
||||
}
|
||||
|
||||
void TestConfigReader::init_energy(const yaml_event_t & event) {
|
||||
void TestConfigReader::init_energy(const yaml_event_t &event)
|
||||
{
|
||||
config.init_energy = atof((char *)event.data.scalar.value);
|
||||
}
|
||||
|
||||
void TestConfigReader::run_energy(const yaml_event_t & event) {
|
||||
void TestConfigReader::run_energy(const yaml_event_t &event)
|
||||
{
|
||||
config.run_energy = atof((char *)event.data.scalar.value);
|
||||
}
|
||||
|
||||
|
||||
@ -16,16 +16,15 @@
|
||||
#include "test_config_reader.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <mpi.h>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <mpi.h>
|
||||
|
||||
// common read_yaml_file function
|
||||
bool read_yaml_file(const char *infile, TestConfig &config)
|
||||
{
|
||||
auto reader = TestConfigReader(config);
|
||||
if (reader.parse_file(infile))
|
||||
return false;
|
||||
if (reader.parse_file(infile)) return false;
|
||||
|
||||
config.basename = reader.get_basename();
|
||||
return true;
|
||||
|
||||
@ -17,9 +17,9 @@
|
||||
#include "yaml.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
template <typename ConsumerClass> class YamlReader {
|
||||
private:
|
||||
@ -46,7 +46,8 @@ public:
|
||||
|
||||
std::string get_basename() const { return basename; }
|
||||
|
||||
int parse_file(const std::string & infile) {
|
||||
int parse_file(const std::string &infile)
|
||||
{
|
||||
basename = infile;
|
||||
std::size_t found = basename.rfind(".yaml");
|
||||
if (found > 0) basename = basename.substr(0, found);
|
||||
@ -58,8 +59,8 @@ public:
|
||||
yaml_event_t event;
|
||||
|
||||
if (!fp) {
|
||||
std::cerr << "Cannot open yaml file '" << infile
|
||||
<< "': " << strerror(errno) << std::endl;
|
||||
std::cerr << "Cannot open yaml file '" << infile << "': " << strerror(errno)
|
||||
<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
yaml_parser_initialize(&parser);
|
||||
@ -76,8 +77,8 @@ public:
|
||||
|
||||
if (accepted) {
|
||||
if (!consume_key_value(key, event)) {
|
||||
std::cerr << "Ignoring unknown key/value pair: " << key
|
||||
<< " = " << event.data.scalar.value << std::endl;
|
||||
std::cerr << "Ignoring unknown key/value pair: " << key << " = "
|
||||
<< event.data.scalar.value << std::endl;
|
||||
}
|
||||
}
|
||||
yaml_event_delete(&event);
|
||||
@ -89,7 +90,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool consume_key_value(const std::string & key, const yaml_event_t & event) {
|
||||
bool consume_key_value(const std::string &key, const yaml_event_t &event)
|
||||
{
|
||||
auto it = consumers.find(key);
|
||||
ConsumerClass *consumer = dynamic_cast<ConsumerClass *>(this);
|
||||
|
||||
@ -106,7 +108,8 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool consume_event(yaml_event_t & event) {
|
||||
bool consume_event(yaml_event_t &event)
|
||||
{
|
||||
accepted = false;
|
||||
switch (state) {
|
||||
case START:
|
||||
@ -144,8 +147,7 @@ protected:
|
||||
break;
|
||||
default:
|
||||
std::cerr << "UNHANDLED YAML EVENT (key): " << event.type
|
||||
<< "\nVALUE: " << event.data.scalar.value
|
||||
<< std::endl;
|
||||
<< "\nVALUE: " << event.data.scalar.value << std::endl;
|
||||
state = ERROR;
|
||||
break;
|
||||
}
|
||||
@ -159,8 +161,7 @@ protected:
|
||||
break;
|
||||
default:
|
||||
std::cerr << "UNHANDLED YAML EVENT (value): " << event.type
|
||||
<< "\nVALUE: " << event.data.scalar.value
|
||||
<< std::endl;
|
||||
<< "\nVALUE: " << event.data.scalar.value << std::endl;
|
||||
state = ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -14,10 +14,11 @@
|
||||
#include "yaml_writer.h"
|
||||
#include "yaml.h"
|
||||
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
YamlWriter::YamlWriter(const char * outfile) {
|
||||
YamlWriter::YamlWriter(const char *outfile)
|
||||
{
|
||||
yaml_emitter_initialize(&emitter);
|
||||
fp = fopen(outfile, "w");
|
||||
if (!fp) {
|
||||
@ -31,13 +32,13 @@ YamlWriter::YamlWriter(const char * outfile) {
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
yaml_document_start_event_initialize(&event, NULL, NULL, NULL, 0);
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
yaml_mapping_start_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_MAP_TAG,
|
||||
1, YAML_ANY_MAPPING_STYLE);
|
||||
yaml_mapping_start_event_initialize(&event, NULL, (yaml_char_t *)YAML_MAP_TAG, 1,
|
||||
YAML_ANY_MAPPING_STYLE);
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
}
|
||||
|
||||
YamlWriter::~YamlWriter() {
|
||||
YamlWriter::~YamlWriter()
|
||||
{
|
||||
yaml_mapping_end_event_initialize(&event);
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
yaml_document_end_event_initialize(&event, 0);
|
||||
@ -48,84 +49,65 @@ YamlWriter::~YamlWriter() {
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void YamlWriter::emit(const std::string &key, const double value) {
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *) key.c_str(),
|
||||
key.size(), 1, 0,
|
||||
void YamlWriter::emit(const std::string &key, const double value)
|
||||
{
|
||||
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *)key.c_str(), key.size(), 1, 0,
|
||||
YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
char buf[256];
|
||||
snprintf(buf, 256, "%.15g", value);
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *)buf,
|
||||
strlen(buf), 1, 0,
|
||||
YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)buf,
|
||||
strlen(buf), 1, 0, YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
}
|
||||
|
||||
void YamlWriter::emit(const std::string &key, const long value) {
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *) key.c_str(),
|
||||
key.size(), 1, 0,
|
||||
void YamlWriter::emit(const std::string &key, const long value)
|
||||
{
|
||||
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *)key.c_str(), key.size(), 1, 0,
|
||||
YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
char buf[256];
|
||||
snprintf(buf, 256, "%ld", value);
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *)buf,
|
||||
strlen(buf), 1, 0,
|
||||
YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)buf,
|
||||
strlen(buf), 1, 0, YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
}
|
||||
|
||||
void YamlWriter::emit(const std::string &key, const int value) {
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *) key.c_str(),
|
||||
key.size(), 1, 0,
|
||||
void YamlWriter::emit(const std::string &key, const int value)
|
||||
{
|
||||
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *)key.c_str(), key.size(), 1, 0,
|
||||
YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
char buf[256];
|
||||
snprintf(buf, 256, "%d", value);
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *)buf,
|
||||
strlen(buf), 1, 0,
|
||||
YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)buf,
|
||||
strlen(buf), 1, 0, YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
}
|
||||
|
||||
void YamlWriter::emit(const std::string &key, const std::string &value)
|
||||
{
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *) key.c_str(),
|
||||
key.size(), 1, 0,
|
||||
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *)key.c_str(), key.size(), 1, 0,
|
||||
YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *)value.c_str(),
|
||||
value.size(), 1, 0,
|
||||
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *)value.c_str(), value.size(), 1, 0,
|
||||
YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
}
|
||||
|
||||
void YamlWriter::emit_block(const std::string &key, const std::string &value) {
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *) key.c_str(),
|
||||
key.size(), 1, 0,
|
||||
void YamlWriter::emit_block(const std::string &key, const std::string &value)
|
||||
{
|
||||
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *)key.c_str(), key.size(), 1, 0,
|
||||
YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *)value.c_str(),
|
||||
value.size(), 1, 0,
|
||||
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG,
|
||||
(yaml_char_t *)value.c_str(), value.size(), 1, 0,
|
||||
YAML_LITERAL_SCALAR_STYLE);
|
||||
yaml_emitter_emit(&emitter, &event);
|
||||
}
|
||||
|
||||
@ -11,11 +11,11 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "MANYBODY/pair_eim.h"
|
||||
#include "lammps.h"
|
||||
#include "utils.h"
|
||||
#include "MANYBODY/pair_eim.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <mpi.h>
|
||||
|
||||
@ -27,8 +27,10 @@ protected:
|
||||
PairEIM::Setfl setfl;
|
||||
static const int nelements = 9;
|
||||
|
||||
void SetUp() override {
|
||||
const char *args[] = {"PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite" };
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {
|
||||
"PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
::testing::internal::CaptureStdout();
|
||||
@ -59,7 +61,8 @@ protected:
|
||||
setfl.tp = new int[npair];
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
void TearDown() override
|
||||
{
|
||||
delete[] setfl.ielement;
|
||||
delete[] setfl.mass;
|
||||
delete[] setfl.negativity;
|
||||
@ -88,7 +91,8 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(EIMPotentialFileReaderTest, global_line) {
|
||||
TEST_F(EIMPotentialFileReaderTest, global_line)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
EIMPotentialFileReader reader(lmp, "ffield.eim");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -99,7 +103,8 @@ TEST_F(EIMPotentialFileReaderTest, global_line) {
|
||||
ASSERT_DOUBLE_EQ(setfl.rsmall, 1.645);
|
||||
}
|
||||
|
||||
TEST_F(EIMPotentialFileReaderTest, element_line_sequential) {
|
||||
TEST_F(EIMPotentialFileReaderTest, element_line_sequential)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
EIMPotentialFileReader reader(lmp, "ffield.eim");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -123,7 +128,8 @@ TEST_F(EIMPotentialFileReaderTest, element_line_sequential) {
|
||||
ASSERT_DOUBLE_EQ(setfl.q0[1], 0.0000e+00);
|
||||
}
|
||||
|
||||
TEST_F(EIMPotentialFileReaderTest, element_line_random) {
|
||||
TEST_F(EIMPotentialFileReaderTest, element_line_random)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
EIMPotentialFileReader reader(lmp, "ffield.eim");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -138,7 +144,8 @@ TEST_F(EIMPotentialFileReaderTest, element_line_random) {
|
||||
ASSERT_DOUBLE_EQ(setfl.q0[0], 0.0000e+00);
|
||||
}
|
||||
|
||||
TEST_F(EIMPotentialFileReaderTest, pair_line) {
|
||||
TEST_F(EIMPotentialFileReaderTest, pair_line)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
EIMPotentialFileReader reader(lmp, "ffield.eim");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -160,7 +167,8 @@ TEST_F(EIMPotentialFileReaderTest, pair_line) {
|
||||
ASSERT_EQ(setfl.tp[0], 1);
|
||||
}
|
||||
|
||||
TEST_F(EIMPotentialFileReaderTest, pair_identical) {
|
||||
TEST_F(EIMPotentialFileReaderTest, pair_identical)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
EIMPotentialFileReader reader(lmp, "ffield.eim");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
|
||||
@ -11,23 +11,23 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "potential_file_reader.h"
|
||||
#include "lammps.h"
|
||||
#include "utils.h"
|
||||
#include "MANYBODY/pair_sw.h"
|
||||
#include "MANYBODY/pair_comb.h"
|
||||
#include "MANYBODY/pair_comb3.h"
|
||||
#include "MANYBODY/pair_eim.h"
|
||||
#include "MANYBODY/pair_gw.h"
|
||||
#include "MANYBODY/pair_gw_zbl.h"
|
||||
#include "MANYBODY/pair_nb3b_harmonic.h"
|
||||
#include "MANYBODY/pair_sw.h"
|
||||
#include "MANYBODY/pair_tersoff.h"
|
||||
#include "MANYBODY/pair_tersoff_mod.h"
|
||||
#include "MANYBODY/pair_tersoff_mod_c.h"
|
||||
#include "MANYBODY/pair_tersoff_zbl.h"
|
||||
#include "MANYBODY/pair_gw.h"
|
||||
#include "MANYBODY/pair_gw_zbl.h"
|
||||
#include "MANYBODY/pair_nb3b_harmonic.h"
|
||||
#include "MANYBODY/pair_vashishta.h"
|
||||
#include "MANYBODY/pair_eim.h"
|
||||
#include "lammps.h"
|
||||
#include "potential_file_reader.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <mpi.h>
|
||||
|
||||
@ -49,8 +49,10 @@ class PotentialFileReaderTest : public ::testing::Test {
|
||||
protected:
|
||||
LAMMPS *lmp;
|
||||
|
||||
void SetUp() override {
|
||||
const char *args[] = {"PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite" };
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {
|
||||
"PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
::testing::internal::CaptureStdout();
|
||||
@ -58,14 +60,16 @@ protected:
|
||||
::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
void TearDown() override
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
delete lmp;
|
||||
::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(PotentialFileReaderTest, Si) {
|
||||
TEST_F(PotentialFileReaderTest, Si)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
PotentialFileReader reader(lmp, "Si.sw", "Stillinger-Weber");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -74,7 +78,8 @@ TEST_F(PotentialFileReaderTest, Si) {
|
||||
ASSERT_EQ(utils::count_words(line), PairSW::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotentialFileReaderTest, Comb) {
|
||||
TEST_F(PotentialFileReaderTest, Comb)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
PotentialFileReader reader(lmp, "ffield.comb", "COMB");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -83,7 +88,8 @@ TEST_F(PotentialFileReaderTest, Comb) {
|
||||
ASSERT_EQ(utils::count_words(line), PairComb::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotentialFileReaderTest, Comb3) {
|
||||
TEST_F(PotentialFileReaderTest, Comb3)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
PotentialFileReader reader(lmp, "ffield.comb3", "COMB3");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -92,7 +98,8 @@ TEST_F(PotentialFileReaderTest, Comb3) {
|
||||
ASSERT_EQ(utils::count_words(line), PairComb3::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotentialFileReaderTest, Tersoff) {
|
||||
TEST_F(PotentialFileReaderTest, Tersoff)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
PotentialFileReader reader(lmp, "Si.tersoff", "Tersoff");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -101,7 +108,8 @@ TEST_F(PotentialFileReaderTest, Tersoff) {
|
||||
ASSERT_EQ(utils::count_words(line), PairTersoff::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotentialFileReaderTest, TersoffMod) {
|
||||
TEST_F(PotentialFileReaderTest, TersoffMod)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
PotentialFileReader reader(lmp, "Si.tersoff.mod", "Tersoff/Mod");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -110,7 +118,8 @@ TEST_F(PotentialFileReaderTest, TersoffMod) {
|
||||
ASSERT_EQ(utils::count_words(line), PairTersoffMOD::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotentialFileReaderTest, TersoffModC) {
|
||||
TEST_F(PotentialFileReaderTest, TersoffModC)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
PotentialFileReader reader(lmp, "Si.tersoff.modc", "Tersoff/ModC");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -119,7 +128,8 @@ TEST_F(PotentialFileReaderTest, TersoffModC) {
|
||||
ASSERT_EQ(utils::count_words(line), PairTersoffMODC::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotentialFileReaderTest, TersoffZBL) {
|
||||
TEST_F(PotentialFileReaderTest, TersoffZBL)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
PotentialFileReader reader(lmp, "SiC.tersoff.zbl", "Tersoff/ZBL");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -128,7 +138,8 @@ TEST_F(PotentialFileReaderTest, TersoffZBL) {
|
||||
ASSERT_EQ(utils::count_words(line), PairTersoffZBL::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotentialFileReaderTest, GW) {
|
||||
TEST_F(PotentialFileReaderTest, GW)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
PotentialFileReader reader(lmp, "SiC.gw", "GW");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -137,7 +148,8 @@ TEST_F(PotentialFileReaderTest, GW) {
|
||||
ASSERT_EQ(utils::count_words(line), PairGW::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotentialFileReaderTest, GWZBL) {
|
||||
TEST_F(PotentialFileReaderTest, GWZBL)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
PotentialFileReader reader(lmp, "SiC.gw.zbl", "GW/ZBL");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -146,7 +158,8 @@ TEST_F(PotentialFileReaderTest, GWZBL) {
|
||||
ASSERT_EQ(utils::count_words(line), PairGWZBL::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotentialFileReaderTest, Nb3bHarmonic) {
|
||||
TEST_F(PotentialFileReaderTest, Nb3bHarmonic)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
PotentialFileReader reader(lmp, "MOH.nb3b.harmonic", "NB3B Harmonic");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
@ -155,7 +168,8 @@ TEST_F(PotentialFileReaderTest, Nb3bHarmonic) {
|
||||
ASSERT_EQ(utils::count_words(line), PairNb3bHarmonic::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotentialFileReaderTest, Vashishta) {
|
||||
TEST_F(PotentialFileReaderTest, Vashishta)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
PotentialFileReader reader(lmp, "SiC.vashishta", "Vashishta");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
|
||||
@ -11,37 +11,41 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "lmptype.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include <string>
|
||||
#include "lmptype.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using ::testing::Eq;
|
||||
|
||||
// this tests a subset of {fmt} that is most relevant to LAMMPS
|
||||
|
||||
TEST(FmtLib, insert_string) {
|
||||
TEST(FmtLib, insert_string)
|
||||
{
|
||||
const char val[] = "word";
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word word"));
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_int) {
|
||||
TEST(FmtLib, insert_int)
|
||||
{
|
||||
const int val = 333;
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word 333"));
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_neg_int) {
|
||||
TEST(FmtLib, insert_neg_int)
|
||||
{
|
||||
const int val = -333;
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word -333"));
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_bigint) {
|
||||
TEST(FmtLib, insert_bigint)
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG) || defined(LAMMPS_SMALLBIG)
|
||||
const bigint val = 9945234592L;
|
||||
auto text = fmt::format("word {}", val);
|
||||
@ -51,7 +55,8 @@ TEST(FmtLib, insert_bigint) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_neg_bigint) {
|
||||
TEST(FmtLib, insert_neg_bigint)
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG) || defined(LAMMPS_SMALLBIG)
|
||||
const bigint val = -9945234592L;
|
||||
auto text = fmt::format("word {}", val);
|
||||
@ -61,7 +66,8 @@ TEST(FmtLib, insert_neg_bigint) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_tagint) {
|
||||
TEST(FmtLib, insert_tagint)
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
const tagint val = 9945234592L;
|
||||
auto text = fmt::format("word {}", val);
|
||||
@ -71,7 +77,8 @@ TEST(FmtLib, insert_tagint) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_neg_tagint) {
|
||||
TEST(FmtLib, insert_neg_tagint)
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
const tagint val = -9945234592L;
|
||||
auto text = fmt::format("word {}", val);
|
||||
@ -81,7 +88,8 @@ TEST(FmtLib, insert_neg_tagint) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_imageint) {
|
||||
TEST(FmtLib, insert_imageint)
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
const imageint val = 9945234592L;
|
||||
auto text = fmt::format("word {}", val);
|
||||
@ -91,7 +99,8 @@ TEST(FmtLib, insert_imageint) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_neg_imageint) {
|
||||
TEST(FmtLib, insert_neg_imageint)
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
const imageint val = -9945234592L;
|
||||
auto text = fmt::format("word {}", val);
|
||||
@ -101,24 +110,28 @@ TEST(FmtLib, insert_neg_imageint) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_double) {
|
||||
TEST(FmtLib, insert_double)
|
||||
{
|
||||
const double val = 1.5;
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word 1.5"));
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_neg_double) {
|
||||
TEST(FmtLib, insert_neg_double)
|
||||
{
|
||||
const double val = -1.5;
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word -1.5"));
|
||||
}
|
||||
|
||||
TEST(FmtLib, int_for_double) {
|
||||
TEST(FmtLib, int_for_double)
|
||||
{
|
||||
const double val = -1.5;
|
||||
ASSERT_THROW(fmt::format("word {:d}", val), std::exception);
|
||||
}
|
||||
|
||||
TEST(FmtLib, double_for_int) {
|
||||
TEST(FmtLib, double_for_int)
|
||||
{
|
||||
const int val = 15;
|
||||
ASSERT_THROW(fmt::format("word {:g}", val), std::exception);
|
||||
}
|
||||
|
||||
@ -11,100 +11,117 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "tokenizer.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using ::testing::Eq;
|
||||
|
||||
TEST(Tokenizer, empty_string) {
|
||||
TEST(Tokenizer, empty_string)
|
||||
{
|
||||
Tokenizer t("", " ");
|
||||
ASSERT_EQ(t.count(), 0);
|
||||
}
|
||||
|
||||
TEST(Tokenizer, whitespace_only) {
|
||||
TEST(Tokenizer, whitespace_only)
|
||||
{
|
||||
Tokenizer t(" ", " ");
|
||||
ASSERT_EQ(t.count(), 0);
|
||||
}
|
||||
|
||||
TEST(Tokenizer, single_word) {
|
||||
TEST(Tokenizer, single_word)
|
||||
{
|
||||
Tokenizer t("test", " ");
|
||||
ASSERT_EQ(t.count(), 1);
|
||||
}
|
||||
|
||||
TEST(Tokenizer, two_words) {
|
||||
TEST(Tokenizer, two_words)
|
||||
{
|
||||
Tokenizer t("test word", " ");
|
||||
ASSERT_EQ(t.count(), 2);
|
||||
}
|
||||
|
||||
TEST(Tokenizer, prefix_separators) {
|
||||
TEST(Tokenizer, prefix_separators)
|
||||
{
|
||||
Tokenizer t(" test word", " ");
|
||||
ASSERT_EQ(t.count(), 2);
|
||||
}
|
||||
|
||||
TEST(Tokenizer, postfix_separators) {
|
||||
TEST(Tokenizer, postfix_separators)
|
||||
{
|
||||
Tokenizer t("test word ", " ");
|
||||
ASSERT_EQ(t.count(), 2);
|
||||
}
|
||||
|
||||
TEST(Tokenizer, iterate_words) {
|
||||
TEST(Tokenizer, iterate_words)
|
||||
{
|
||||
Tokenizer t(" test word ", " ");
|
||||
ASSERT_THAT(t.next(), Eq("test"));
|
||||
ASSERT_THAT(t.next(), Eq("word"));
|
||||
ASSERT_EQ(t.count(), 2);
|
||||
}
|
||||
|
||||
TEST(Tokenizer, default_separators) {
|
||||
TEST(Tokenizer, default_separators)
|
||||
{
|
||||
Tokenizer t(" \r\n test \t word \f");
|
||||
ASSERT_THAT(t.next(), Eq("test"));
|
||||
ASSERT_THAT(t.next(), Eq("word"));
|
||||
ASSERT_EQ(t.count(), 2);
|
||||
}
|
||||
|
||||
TEST(Tokenizer, as_vector) {
|
||||
TEST(Tokenizer, as_vector)
|
||||
{
|
||||
Tokenizer t(" \r\n test \t word \f");
|
||||
std::vector<std::string> list = t.as_vector();
|
||||
ASSERT_THAT(list[0], Eq("test"));
|
||||
ASSERT_THAT(list[1], Eq("word"));
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, empty_string) {
|
||||
TEST(ValueTokenizer, empty_string)
|
||||
{
|
||||
ValueTokenizer values("");
|
||||
ASSERT_FALSE(values.has_next());
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, bad_integer) {
|
||||
TEST(ValueTokenizer, bad_integer)
|
||||
{
|
||||
ValueTokenizer values("f10");
|
||||
ASSERT_THROW(values.next_int(), InvalidIntegerException);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, bad_double) {
|
||||
TEST(ValueTokenizer, bad_double)
|
||||
{
|
||||
ValueTokenizer values("1a.0");
|
||||
ASSERT_THROW(values.next_double(), InvalidFloatException);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, valid_int) {
|
||||
TEST(ValueTokenizer, valid_int)
|
||||
{
|
||||
ValueTokenizer values("10");
|
||||
ASSERT_EQ(values.next_int(), 10);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, valid_tagint) {
|
||||
TEST(ValueTokenizer, valid_tagint)
|
||||
{
|
||||
ValueTokenizer values("42");
|
||||
ASSERT_EQ(values.next_tagint(), 42);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, valid_bigint) {
|
||||
TEST(ValueTokenizer, valid_bigint)
|
||||
{
|
||||
ValueTokenizer values("42");
|
||||
ASSERT_EQ(values.next_bigint(), 42);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, valid_double) {
|
||||
TEST(ValueTokenizer, valid_double)
|
||||
{
|
||||
ValueTokenizer values("3.14");
|
||||
ASSERT_DOUBLE_EQ(values.next_double(), 3.14);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, valid_double_with_exponential) {
|
||||
TEST(ValueTokenizer, valid_double_with_exponential)
|
||||
{
|
||||
ValueTokenizer values("3.14e22");
|
||||
ASSERT_DOUBLE_EQ(values.next_double(), 3.14e22);
|
||||
}
|
||||
|
||||
@ -11,215 +11,265 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "utils.h"
|
||||
#include <string>
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using ::testing::Eq;
|
||||
|
||||
TEST(Utils, trim_comment) {
|
||||
TEST(Utils, trim_comment)
|
||||
{
|
||||
auto trimmed = utils::trim_comment("some text # comment");
|
||||
ASSERT_THAT(trimmed, Eq("some text "));
|
||||
}
|
||||
|
||||
TEST(Utils, count_words) {
|
||||
TEST(Utils, count_words)
|
||||
{
|
||||
ASSERT_EQ(utils::count_words("some text # comment"), 4);
|
||||
}
|
||||
|
||||
TEST(Utils, count_words_non_default) {
|
||||
TEST(Utils, count_words_non_default)
|
||||
{
|
||||
ASSERT_EQ(utils::count_words("some text # comment", " #"), 3);
|
||||
}
|
||||
|
||||
TEST(Utils, trim_and_count_words) {
|
||||
TEST(Utils, trim_and_count_words)
|
||||
{
|
||||
ASSERT_EQ(utils::trim_and_count_words("some text # comment"), 2);
|
||||
}
|
||||
|
||||
TEST(Utils, count_words_with_extra_spaces) {
|
||||
TEST(Utils, count_words_with_extra_spaces)
|
||||
{
|
||||
ASSERT_EQ(utils::count_words(" some text # comment "), 4);
|
||||
}
|
||||
|
||||
TEST(Utils, valid_integer1) {
|
||||
TEST(Utils, valid_integer1)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_integer("10"));
|
||||
}
|
||||
|
||||
TEST(Utils, valid_integer2) {
|
||||
TEST(Utils, valid_integer2)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_integer("-10"));
|
||||
}
|
||||
|
||||
TEST(Utils, valid_integer3) {
|
||||
TEST(Utils, valid_integer3)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_integer("+10"));
|
||||
}
|
||||
|
||||
TEST(Utils, valid_double1) {
|
||||
TEST(Utils, valid_double1)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double("10.0"));
|
||||
}
|
||||
|
||||
TEST(Utils, valid_double2) {
|
||||
TEST(Utils, valid_double2)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double("1."));
|
||||
}
|
||||
|
||||
TEST(Utils, valid_double3) {
|
||||
TEST(Utils, valid_double3)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double(".0"));
|
||||
}
|
||||
|
||||
TEST(Utils, valid_double4) {
|
||||
TEST(Utils, valid_double4)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double("-10.0"));
|
||||
}
|
||||
|
||||
TEST(Utils, valid_double5) {
|
||||
TEST(Utils, valid_double5)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double("-1."));
|
||||
}
|
||||
|
||||
TEST(Utils, valid_double6) {
|
||||
TEST(Utils, valid_double6)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double("-.0"));
|
||||
}
|
||||
|
||||
TEST(Utils, valid_double7) {
|
||||
TEST(Utils, valid_double7)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double("+10.0"));
|
||||
}
|
||||
|
||||
TEST(Utils, valid_double8) {
|
||||
TEST(Utils, valid_double8)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double("+1."));
|
||||
}
|
||||
|
||||
TEST(Utils, valid_double9) {
|
||||
TEST(Utils, valid_double9)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double("+.0"));
|
||||
}
|
||||
|
||||
TEST(Utils, empty_not_an_integer) {
|
||||
TEST(Utils, empty_not_an_integer)
|
||||
{
|
||||
ASSERT_FALSE(utils::is_integer(""));
|
||||
}
|
||||
|
||||
TEST(Utils, empty_not_a_double) {
|
||||
TEST(Utils, empty_not_a_double)
|
||||
{
|
||||
ASSERT_FALSE(utils::is_double(""));
|
||||
}
|
||||
|
||||
TEST(Utils, text_not_an_integer) {
|
||||
TEST(Utils, text_not_an_integer)
|
||||
{
|
||||
ASSERT_FALSE(utils::is_integer("one"));
|
||||
}
|
||||
|
||||
TEST(Utils, text_not_a_double) {
|
||||
TEST(Utils, text_not_a_double)
|
||||
{
|
||||
ASSERT_FALSE(utils::is_double("half"));
|
||||
}
|
||||
|
||||
TEST(Utils, double_not_an_integer1) {
|
||||
TEST(Utils, double_not_an_integer1)
|
||||
{
|
||||
ASSERT_FALSE(utils::is_integer("10.0"));
|
||||
}
|
||||
|
||||
TEST(Utils, double_not_an_integer2) {
|
||||
TEST(Utils, double_not_an_integer2)
|
||||
{
|
||||
ASSERT_FALSE(utils::is_integer(".0"));
|
||||
}
|
||||
|
||||
TEST(Utils, double_not_an_integer3) {
|
||||
TEST(Utils, double_not_an_integer3)
|
||||
{
|
||||
ASSERT_FALSE(utils::is_integer("1."));
|
||||
}
|
||||
|
||||
TEST(Utils, integer_is_double1) {
|
||||
TEST(Utils, integer_is_double1)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double("10"));
|
||||
}
|
||||
|
||||
TEST(Utils, integer_is_double2) {
|
||||
TEST(Utils, integer_is_double2)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double("-10"));
|
||||
}
|
||||
|
||||
TEST(Utils, is_double_with_exponential) {
|
||||
TEST(Utils, is_double_with_exponential)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double("+1e02"));
|
||||
}
|
||||
|
||||
TEST(Utils, is_double_with_neg_exponential) {
|
||||
TEST(Utils, is_double_with_neg_exponential)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double("1.0e-22"));
|
||||
}
|
||||
|
||||
TEST(Utils, is_double_with_pos_exponential) {
|
||||
TEST(Utils, is_double_with_pos_exponential)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double(".1e+22"));
|
||||
}
|
||||
|
||||
TEST(Utils, signed_double_and_exponential) {
|
||||
TEST(Utils, signed_double_and_exponential)
|
||||
{
|
||||
ASSERT_TRUE(utils::is_double("-10E-22"));
|
||||
}
|
||||
|
||||
TEST(Utils, is_double_with_d_exponential) {
|
||||
TEST(Utils, is_double_with_d_exponential)
|
||||
{
|
||||
ASSERT_FALSE(utils::is_double("10d22"));
|
||||
}
|
||||
|
||||
TEST(Utils, is_double_with_neg_d_exponential) {
|
||||
TEST(Utils, is_double_with_neg_d_exponential)
|
||||
{
|
||||
ASSERT_FALSE(utils::is_double("10d-22"));
|
||||
}
|
||||
|
||||
TEST(Utils, signed_double_and_d_exponential) {
|
||||
TEST(Utils, signed_double_and_d_exponential)
|
||||
{
|
||||
ASSERT_FALSE(utils::is_double("-10D-22"));
|
||||
}
|
||||
|
||||
TEST(Utils, strmatch_beg) {
|
||||
TEST(Utils, strmatch_beg)
|
||||
{
|
||||
ASSERT_TRUE(utils::strmatch("rigid/small/omp", "^rigid"));
|
||||
}
|
||||
|
||||
TEST(Utils, strmatch_mid1) {
|
||||
TEST(Utils, strmatch_mid1)
|
||||
{
|
||||
ASSERT_TRUE(utils::strmatch("rigid/small/omp", "small"));
|
||||
}
|
||||
|
||||
TEST(Utils, strmatch_mid2) {
|
||||
TEST(Utils, strmatch_mid2)
|
||||
{
|
||||
ASSERT_TRUE(utils::strmatch("rigid/small/omp", "omp"));
|
||||
}
|
||||
|
||||
TEST(Utils, strmatch_end) {
|
||||
TEST(Utils, strmatch_end)
|
||||
{
|
||||
ASSERT_TRUE(utils::strmatch("rigid/small/omp", "/omp$"));
|
||||
}
|
||||
|
||||
TEST(Utils, no_strmatch_beg) {
|
||||
TEST(Utils, no_strmatch_beg)
|
||||
{
|
||||
ASSERT_FALSE(utils::strmatch("rigid/small/omp", "^small"));
|
||||
}
|
||||
|
||||
TEST(Utils, no_strmatch_mid) {
|
||||
TEST(Utils, no_strmatch_mid)
|
||||
{
|
||||
ASSERT_FALSE(utils::strmatch("rigid/small/omp", "none"));
|
||||
}
|
||||
|
||||
TEST(Utils, no_strmatch_end) {
|
||||
TEST(Utils, no_strmatch_end)
|
||||
{
|
||||
ASSERT_FALSE(utils::strmatch("rigid/small/omp", "/opt$"));
|
||||
}
|
||||
|
||||
TEST(Utils, strmatch_whole_line) {
|
||||
TEST(Utils, strmatch_whole_line)
|
||||
{
|
||||
ASSERT_TRUE(utils::strmatch("ITEM: UNITS\n", "^\\s*ITEM: UNITS\\s*$"));
|
||||
}
|
||||
|
||||
TEST(Utils, no_strmatch_whole_line) {
|
||||
TEST(Utils, no_strmatch_whole_line)
|
||||
{
|
||||
ASSERT_FALSE(utils::strmatch("ITEM: UNITS\n", "^\\s*ITEM: UNIT\\s*$"));
|
||||
}
|
||||
|
||||
TEST(Utils, strmatch_integer_in_line) {
|
||||
TEST(Utils, strmatch_integer_in_line)
|
||||
{
|
||||
ASSERT_TRUE(utils::strmatch(" 5 angles\n", "^\\s*\\d+\\s+angles\\s"));
|
||||
}
|
||||
|
||||
TEST(Utils, strmatch_float_in_line) {
|
||||
TEST(Utils, strmatch_float_in_line)
|
||||
{
|
||||
ASSERT_TRUE(utils::strmatch(" 5.0 angles\n", "^\\s*\\f+\\s+angles\\s"));
|
||||
}
|
||||
|
||||
TEST(Utils, strmatch_int_as_float_in_line) {
|
||||
TEST(Utils, strmatch_int_as_float_in_line)
|
||||
{
|
||||
ASSERT_TRUE(utils::strmatch(" 5 angles\n", "^\\s*\\f+\\s+angles\\s"));
|
||||
}
|
||||
|
||||
TEST(Utils, strmatch_char_range) {
|
||||
TEST(Utils, strmatch_char_range)
|
||||
{
|
||||
ASSERT_TRUE(utils::strmatch("rigid", "^[ip-s]+gid"));
|
||||
}
|
||||
|
||||
TEST(Utils, strmatch_opt_range) {
|
||||
TEST(Utils, strmatch_opt_range)
|
||||
{
|
||||
ASSERT_TRUE(utils::strmatch("rigid", "^[0-9]*[p-s]igid"));
|
||||
}
|
||||
|
||||
TEST(Utils, path_join) {
|
||||
TEST(Utils, path_join)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
ASSERT_THAT(utils::path_join("c:\\parent\\folder", "filename"), Eq("c:\\parent\\folder\\filename"));
|
||||
ASSERT_THAT(utils::path_join("c:\\parent\\folder", "filename"),
|
||||
Eq("c:\\parent\\folder\\filename"));
|
||||
#else
|
||||
ASSERT_THAT(utils::path_join("/parent/folder", "filename"), Eq("/parent/folder/filename"));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(Utils, path_basename) {
|
||||
TEST(Utils, path_basename)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
ASSERT_THAT(utils::path_basename("c:\\parent\\folder\\filename"), Eq("filename"));
|
||||
#else
|
||||
@ -227,7 +277,8 @@ TEST(Utils, path_basename) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(Utils, getsyserror) {
|
||||
TEST(Utils, getsyserror)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
errno = ENOENT;
|
||||
std::string errmesg = utils::getsyserror();
|
||||
@ -237,7 +288,8 @@ TEST(Utils, getsyserror) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(Utils, potential_file) {
|
||||
TEST(Utils, potential_file)
|
||||
{
|
||||
FILE *fp;
|
||||
fp = fopen("ctest.txt", "w");
|
||||
ASSERT_NE(fp, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user