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;
|
||||
|
||||
@ -74,7 +73,7 @@ LAMMPS *init_lammps(int argc, char **argv,
|
||||
// check if prerequisite styles are available
|
||||
Info *info = new Info(lmp);
|
||||
int nfail = 0;
|
||||
for (auto& prerequisite : cfg.prerequisites) {
|
||||
for (auto &prerequisite : cfg.prerequisites) {
|
||||
std::string style = prerequisite.second;
|
||||
|
||||
// this is a test for angle styles, so if the suffixed
|
||||
@ -86,19 +85,19 @@ LAMMPS *init_lammps(int argc, char **argv,
|
||||
}
|
||||
}
|
||||
|
||||
if (!info->has_style(prerequisite.first,style)) ++nfail;
|
||||
if (!info->has_style(prerequisite.first, style)) ++nfail;
|
||||
}
|
||||
if (nfail > 0) {
|
||||
delete info;
|
||||
cleanup_lammps(lmp,cfg);
|
||||
cleanup_lammps(lmp, cfg);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// utility lambdas to improve readability
|
||||
auto command = [&](const std::string & line) {
|
||||
auto command = [&](const std::string &line) {
|
||||
lmp->input->one(line.c_str());
|
||||
};
|
||||
auto parse_input_script = [&](const std::string & filename) {
|
||||
auto parse_input_script = [&](const std::string &filename) {
|
||||
lmp->input->file(filename.c_str());
|
||||
};
|
||||
|
||||
@ -110,7 +109,7 @@ LAMMPS *init_lammps(int argc, char **argv,
|
||||
|
||||
command("variable input_dir index " + INPUT_FOLDER);
|
||||
|
||||
for (auto& pre_command : cfg.pre_commands) {
|
||||
for (auto &pre_command : cfg.pre_commands) {
|
||||
command(pre_command);
|
||||
}
|
||||
|
||||
@ -119,11 +118,11 @@ LAMMPS *init_lammps(int argc, char **argv,
|
||||
|
||||
command("angle_style " + cfg.angle_style);
|
||||
|
||||
for (auto& angle_coeff : cfg.angle_coeff) {
|
||||
for (auto &angle_coeff : cfg.angle_coeff) {
|
||||
command("angle_coeff " + angle_coeff);
|
||||
}
|
||||
|
||||
for (auto& post_command : cfg.post_commands) {
|
||||
for (auto &post_command : cfg.post_commands) {
|
||||
command(post_command);
|
||||
}
|
||||
|
||||
@ -138,7 +137,7 @@ LAMMPS *init_lammps(int argc, char **argv,
|
||||
void run_lammps(LAMMPS *lmp)
|
||||
{
|
||||
// utility lambda to improve readability
|
||||
auto command = [&](const std::string & line) {
|
||||
auto command = [&](const std::string &line) {
|
||||
lmp->input->one(line.c_str());
|
||||
};
|
||||
|
||||
@ -153,7 +152,7 @@ void run_lammps(LAMMPS *lmp)
|
||||
void restart_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
{
|
||||
// utility lambda to improve readability
|
||||
auto command = [&](const std::string & line) {
|
||||
auto command = [&](const std::string &line) {
|
||||
lmp->input->one(line.c_str());
|
||||
};
|
||||
|
||||
@ -164,14 +163,13 @@ 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) {
|
||||
for (auto& angle_coeff : cfg.angle_coeff) {
|
||||
if ((cfg.angle_style.substr(0, 6) == "hybrid") || !lmp->force->angle->writedata) {
|
||||
for (auto &angle_coeff : cfg.angle_coeff) {
|
||||
command("angle_coeff " + angle_coeff);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& post_command : cfg.post_commands) {
|
||||
for (auto &post_command : cfg.post_commands) {
|
||||
command(post_command);
|
||||
}
|
||||
|
||||
@ -181,10 +179,10 @@ void restart_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
{
|
||||
// utility lambdas to improve readability
|
||||
auto command = [&](const std::string & line) {
|
||||
auto command = [&](const std::string &line) {
|
||||
lmp->input->one(line.c_str());
|
||||
};
|
||||
auto parse_input_script = [&](const std::string & filename) {
|
||||
auto parse_input_script = [&](const std::string &filename) {
|
||||
lmp->input->file(filename.c_str());
|
||||
};
|
||||
|
||||
@ -194,7 +192,7 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
command("variable newton_bond delete");
|
||||
command("variable newton_bond index on");
|
||||
|
||||
for (auto& pre_command : cfg.pre_commands) {
|
||||
for (auto &pre_command : cfg.pre_commands) {
|
||||
command(pre_command);
|
||||
}
|
||||
|
||||
@ -204,10 +202,10 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file;
|
||||
parse_input_script(input_file);
|
||||
|
||||
for (auto& angle_coeff : cfg.angle_coeff) {
|
||||
for (auto &angle_coeff : cfg.angle_coeff) {
|
||||
command("angle_coeff " + angle_coeff);
|
||||
}
|
||||
for (auto& post_command : cfg.post_commands) {
|
||||
for (auto &post_command : cfg.post_commands) {
|
||||
command(post_command);
|
||||
}
|
||||
command("run 0 post no");
|
||||
@ -218,16 +216,15 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
{
|
||||
// initialize system geometry
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite" };
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args)/sizeof(char *);
|
||||
LAMMPS *lmp = init_lammps(argc,argv,config);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS *lmp = init_lammps(argc, argv, config);
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto& prerequisite : config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style "
|
||||
<< prerequisite.second << "\n";
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -245,7 +242,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
// date_generated
|
||||
std::time_t now = time(NULL);
|
||||
block = ctime(&now);
|
||||
block = block.substr(0,block.find("\n")-1);
|
||||
block = block.substr(0, block.find("\n") - 1);
|
||||
writer.emit("date_generated", block);
|
||||
|
||||
// epsilon
|
||||
@ -253,21 +250,21 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
// prerequisites
|
||||
block.clear();
|
||||
for (auto& prerequisite : config.prerequisites) {
|
||||
for (auto &prerequisite : config.prerequisites) {
|
||||
block += prerequisite.first + " " + prerequisite.second + "\n";
|
||||
}
|
||||
writer.emit_block("prerequisites", block);
|
||||
|
||||
// pre_commands
|
||||
block.clear();
|
||||
for (auto& command : config.pre_commands) {
|
||||
for (auto &command : config.pre_commands) {
|
||||
block += command + "\n";
|
||||
}
|
||||
writer.emit_block("pre_commands", block);
|
||||
|
||||
// post_commands
|
||||
block.clear();
|
||||
for (auto& command : config.post_commands) {
|
||||
for (auto &command : config.post_commands) {
|
||||
block += command + "\n";
|
||||
}
|
||||
writer.emit_block("post_commands", block);
|
||||
@ -280,7 +277,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
// angle_coeff
|
||||
block.clear();
|
||||
for (auto& angle_coeff : config.angle_coeff) {
|
||||
for (auto &angle_coeff : config.angle_coeff) {
|
||||
block += angle_coeff + "\n";
|
||||
}
|
||||
writer.emit_block("angle_coeff", block);
|
||||
@ -288,15 +285,15 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
// equilibrium angle
|
||||
std::stringstream eqstr;
|
||||
eqstr << lmp->atom->nangletypes;
|
||||
for (int i=0; i < lmp->atom->nangletypes; ++i) {
|
||||
eqstr << " " << lmp->force->angle->equilibrium_angle(i+1);
|
||||
for (int i = 0; i < lmp->atom->nangletypes; ++i) {
|
||||
eqstr << " " << lmp->force->angle->equilibrium_angle(i + 1);
|
||||
}
|
||||
writer.emit("equilibrium", eqstr.str());
|
||||
|
||||
// extract
|
||||
block.clear();
|
||||
std::stringstream outstr;
|
||||
for (auto& data : config.extract) {
|
||||
for (auto &data : config.extract) {
|
||||
outstr << data.first << " " << data.second << std::endl;
|
||||
}
|
||||
writer.emit_block("extract", outstr.str());
|
||||
@ -309,17 +306,17 @@ 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
|
||||
block.clear();
|
||||
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]);
|
||||
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]);
|
||||
block += buf;
|
||||
}
|
||||
writer.emit_block("init_forces", block);
|
||||
@ -332,40 +329,40 @@ 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]);
|
||||
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]);
|
||||
block += buf;
|
||||
}
|
||||
writer.emit_block("run_forces", block);
|
||||
|
||||
cleanup_lammps(lmp,config);
|
||||
cleanup_lammps(lmp, config);
|
||||
return;
|
||||
}
|
||||
|
||||
TEST(AngleStyle, plain) {
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite" };
|
||||
TEST(AngleStyle, plain)
|
||||
{
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args)/sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc,argv,test_config,true);
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
if (!lmp) {
|
||||
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";
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -375,22 +372,21 @@ TEST(AngleStyle, plain) {
|
||||
|
||||
// abort if running in parallel and not all atoms are local
|
||||
const int nlocal = lmp->atom->nlocal;
|
||||
ASSERT_EQ(lmp->atom->natoms,nlocal);
|
||||
ASSERT_EQ(lmp->atom->natoms, nlocal);
|
||||
|
||||
double epsilon = test_config.epsilon;
|
||||
double **f=lmp->atom->f;
|
||||
tagint *tag=lmp->atom->tag;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
ErrorStats stats;
|
||||
stats.reset();
|
||||
const std::vector<coord_t> &f_ref = test_config.init_forces;
|
||||
ASSERT_EQ(nlocal+1,f_ref.size());
|
||||
for (int i=0; i < nlocal; ++i) {
|
||||
ASSERT_EQ(nlocal + 1, f_ref.size());
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon);
|
||||
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);
|
||||
@ -416,15 +410,14 @@ TEST(AngleStyle, plain) {
|
||||
f = lmp->atom->f;
|
||||
stress = angle->virial;
|
||||
const std::vector<coord_t> &f_run = test_config.run_forces;
|
||||
ASSERT_EQ(nlocal+1,f_run.size());
|
||||
ASSERT_EQ(nlocal + 1, f_run.size());
|
||||
stats.reset();
|
||||
for (int i=0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10*epsilon);
|
||||
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);
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10 * epsilon);
|
||||
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,52 +427,47 @@ 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);
|
||||
lmp = init_lammps(argc,argv,test_config,false);
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// skip over these tests if newton bond is forced to be on
|
||||
if (lmp->force->newton_bond == 0) {
|
||||
|
||||
f=lmp->atom->f;
|
||||
tag=lmp->atom->tag;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
for (int i=0; i < nlocal; ++i) {
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon);
|
||||
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;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 2*epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 2*epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 2*epsilon);
|
||||
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;
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 2 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 2 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 2 * epsilon);
|
||||
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;
|
||||
|
||||
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);
|
||||
@ -488,13 +476,12 @@ TEST(AngleStyle, plain) {
|
||||
f = lmp->atom->f;
|
||||
stress = angle->virial;
|
||||
stats.reset();
|
||||
for (int i=0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10*epsilon);
|
||||
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);
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10 * epsilon);
|
||||
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,33 +491,30 @@ 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();
|
||||
restart_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f=lmp->atom->f;
|
||||
tag=lmp->atom->tag;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
ASSERT_EQ(nlocal+1,f_ref.size());
|
||||
for (int i=0; i < nlocal; ++i) {
|
||||
ASSERT_EQ(nlocal + 1, f_ref.size());
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon);
|
||||
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,29 +525,26 @@ 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);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f=lmp->atom->f;
|
||||
tag=lmp->atom->tag;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
ASSERT_EQ(nlocal+1,f_ref.size());
|
||||
for (int i=0; i < nlocal; ++i) {
|
||||
ASSERT_EQ(nlocal + 1, f_ref.size());
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon);
|
||||
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,37 +555,35 @@ 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);
|
||||
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 *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc,argv,test_config,true);
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
if (!lmp) {
|
||||
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";
|
||||
"are not available in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -614,40 +593,37 @@ TEST(AngleStyle, omp) {
|
||||
|
||||
// abort if running in parallel and not all atoms are local
|
||||
const int nlocal = lmp->atom->nlocal;
|
||||
ASSERT_EQ(lmp->atom->natoms,nlocal);
|
||||
ASSERT_EQ(lmp->atom->natoms, nlocal);
|
||||
|
||||
// relax error a bit for USER-OMP package
|
||||
double epsilon = 5.0*test_config.epsilon;
|
||||
double **f=lmp->atom->f;
|
||||
tagint *tag=lmp->atom->tag;
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
double **f = lmp->atom->f;
|
||||
tagint *tag = lmp->atom->tag;
|
||||
const std::vector<coord_t> &f_ref = test_config.init_forces;
|
||||
ErrorStats stats;
|
||||
stats.reset();
|
||||
for (int i=0; i < nlocal; ++i) {
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon);
|
||||
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;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10*epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10*epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10*epsilon);
|
||||
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;
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
|
||||
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;
|
||||
|
||||
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);
|
||||
@ -656,26 +632,24 @@ TEST(AngleStyle, omp) {
|
||||
f = lmp->atom->f;
|
||||
stress = angle->virial;
|
||||
const std::vector<coord_t> &f_run = test_config.run_forces;
|
||||
ASSERT_EQ(nlocal+1,f_run.size());
|
||||
ASSERT_EQ(nlocal + 1, f_run.size());
|
||||
stats.reset();
|
||||
for (int i=0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10*epsilon);
|
||||
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);
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10 * epsilon);
|
||||
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();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10*epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10*epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10*epsilon);
|
||||
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;
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
|
||||
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;
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
@ -683,46 +657,42 @@ TEST(AngleStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for USER-OMP with angle style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
if (test_config.angle_style.substr(0,6) != "hybrid")
|
||||
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);
|
||||
lmp = init_lammps(argc,argv,test_config,false);
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(argc, argv, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
// skip over these tests if newton bond is forced to be on
|
||||
if (lmp->force->newton_bond == 0) {
|
||||
|
||||
f=lmp->atom->f;
|
||||
tag=lmp->atom->tag;
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
for (int i=0; i < nlocal; ++i) {
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon);
|
||||
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;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10*epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10*epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10*epsilon);
|
||||
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;
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
|
||||
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;
|
||||
|
||||
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);
|
||||
@ -730,24 +700,22 @@ TEST(AngleStyle, omp) {
|
||||
|
||||
f = lmp->atom->f;
|
||||
stats.reset();
|
||||
for (int i=0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10*epsilon);
|
||||
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);
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10 * epsilon);
|
||||
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();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10*epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10*epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10*epsilon);
|
||||
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;
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
|
||||
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;
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
@ -755,33 +723,32 @@ TEST(AngleStyle, omp) {
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for USER-OMP with angle style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
if (test_config.angle_style.substr(0,6) != "hybrid")
|
||||
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();
|
||||
cleanup_lammps(lmp,test_config);
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(AngleStyle, single) {
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite" };
|
||||
TEST(AngleStyle, single)
|
||||
{
|
||||
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args)/sizeof(char *);
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
// create a LAMMPS instance with standard settings to detect the number of atom types
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc,argv,test_config);
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
if (!lmp) {
|
||||
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";
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
@ -792,13 +759,13 @@ TEST(AngleStyle, single) {
|
||||
if (molecular != 1) {
|
||||
std::cerr << "Only simple molecular atom styles are supported\n";
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp,test_config);
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
// utility lambda to improve readability
|
||||
auto command = [&](const std::string & line) {
|
||||
auto command = [&](const std::string &line) {
|
||||
lmp->input->one(line.c_str());
|
||||
};
|
||||
|
||||
@ -810,7 +777,7 @@ TEST(AngleStyle, single) {
|
||||
|
||||
command("variable input_dir index " + INPUT_FOLDER);
|
||||
|
||||
for (auto& pre_command : test_config.pre_commands) {
|
||||
for (auto &pre_command : test_config.pre_commands) {
|
||||
command(pre_command);
|
||||
}
|
||||
|
||||
@ -827,7 +794,7 @@ TEST(AngleStyle, single) {
|
||||
char buf[10];
|
||||
std::string cmd("create_box 1 box");
|
||||
cmd += " angle/types ";
|
||||
snprintf(buf,10,"%d",nangletypes);
|
||||
snprintf(buf, 10, "%d", nangletypes);
|
||||
cmd += buf;
|
||||
cmd += " extra/angle/per/atom 2";
|
||||
cmd += " extra/special/per/atom 2";
|
||||
@ -839,7 +806,7 @@ TEST(AngleStyle, single) {
|
||||
command("angle_style " + test_config.angle_style);
|
||||
Angle *angle = lmp->force->angle;
|
||||
|
||||
for (auto& angle_coeff : test_config.angle_coeff) {
|
||||
for (auto &angle_coeff : test_config.angle_coeff) {
|
||||
command("angle_coeff " + angle_coeff);
|
||||
}
|
||||
|
||||
@ -850,7 +817,7 @@ TEST(AngleStyle, single) {
|
||||
command("create_atoms 1 single 5.0 0.75 0.4 units box");
|
||||
command("create_bonds single/angle 1 1 2 3");
|
||||
|
||||
for (auto& post_command : test_config.post_commands) {
|
||||
for (auto &post_command : test_config.post_commands) {
|
||||
command(post_command);
|
||||
}
|
||||
|
||||
@ -904,14 +871,13 @@ 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)
|
||||
EXPECT_NEAR(dist,angle->equilibrium_angle(++i),0.00001);
|
||||
EXPECT_NEAR(dist, angle->equilibrium_angle(++i), 0.00001);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp,test_config);
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user