Merge branch 'lammps:develop' into alphataubio-kokkos-fixes
This commit is contained in:
@ -28,6 +28,11 @@ add_library(GTest::GMock ALIAS gmock)
|
||||
add_library(GTest::GTestMain ALIAS gtest_main)
|
||||
add_library(GTest::GMockMain ALIAS gmock_main)
|
||||
|
||||
option(SKIP_DEATH_TESTS "Do not run 'death tests' to reduce false positives in valgrind" OFF)
|
||||
mark_as_advanced(SKIP_DEATH_TESTS)
|
||||
if(SKIP_DEATH_TESTS)
|
||||
add_compile_definitions(LAMMPS_SKIP_DEATH_TESTS)
|
||||
endif()
|
||||
# import
|
||||
foreach(_FLAG ${CMAKE_TUNE_FLAGS})
|
||||
add_compile_options(${_FLAG})
|
||||
|
||||
@ -256,4 +256,5 @@ TEST(lammps_open_no_mpi, lammps_error)
|
||||
lammps_error(handle, 0, "test_warning");
|
||||
output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, HasSubstr("WARNING: test_warning"));
|
||||
lammps_close(handle);
|
||||
}
|
||||
|
||||
@ -49,6 +49,7 @@ protected:
|
||||
if (verbose) std::cout << output;
|
||||
EXPECT_THAT(output, StartsWith("LAMMPS ("));
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
@ -466,6 +467,33 @@ TEST_F(LibraryProperties, global)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
map_style = *(int *)lammps_extract_global(lmp, "map_style");
|
||||
EXPECT_EQ(map_style, Atom::MAP_ARRAY);
|
||||
|
||||
EXPECT_EQ(lammps_extract_global_datatype(lmp, "xlattice"), LAMMPS_DOUBLE);
|
||||
EXPECT_EQ(lammps_extract_global_datatype(lmp, "ylattice"), LAMMPS_DOUBLE);
|
||||
EXPECT_EQ(lammps_extract_global_datatype(lmp, "zlattice"), LAMMPS_DOUBLE);
|
||||
auto *xlattice = (double *)lammps_extract_global(lmp, "xlattice");
|
||||
auto *ylattice = (double *)lammps_extract_global(lmp, "ylattice");
|
||||
auto *zlattice = (double *)lammps_extract_global(lmp, "zlattice");
|
||||
EXPECT_NE(xlattice, nullptr);
|
||||
EXPECT_NE(ylattice, nullptr);
|
||||
EXPECT_NE(zlattice, nullptr);
|
||||
EXPECT_DOUBLE_EQ(*xlattice, 1.0);
|
||||
EXPECT_DOUBLE_EQ(*ylattice, 1.0);
|
||||
EXPECT_DOUBLE_EQ(*zlattice, 1.0);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lammps_command(lmp, "clear");
|
||||
lammps_command(lmp, "units real");
|
||||
lammps_command(lmp, "lattice fcc 2.0");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
xlattice = (double *)lammps_extract_global(lmp, "xlattice");
|
||||
ylattice = (double *)lammps_extract_global(lmp, "ylattice");
|
||||
zlattice = (double *)lammps_extract_global(lmp, "zlattice");
|
||||
EXPECT_NE(xlattice, nullptr);
|
||||
EXPECT_NE(ylattice, nullptr);
|
||||
EXPECT_NE(zlattice, nullptr);
|
||||
EXPECT_DOUBLE_EQ(*xlattice, 2.0);
|
||||
EXPECT_DOUBLE_EQ(*ylattice, 2.0);
|
||||
EXPECT_DOUBLE_EQ(*zlattice, 2.0);
|
||||
};
|
||||
|
||||
TEST_F(LibraryProperties, pair1)
|
||||
@ -547,13 +575,22 @@ TEST_F(LibraryProperties, neighlist)
|
||||
lammps_command(lmp, "run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
int nhisto =
|
||||
*(double *)lammps_extract_fix(lmp, "dist", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR, 0, 0);
|
||||
int nskip = *(double *)lammps_extract_fix(lmp, "dist", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR, 1, 0);
|
||||
double minval =
|
||||
*(double *)lammps_extract_fix(lmp, "dist", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR, 2, 0);
|
||||
double maxval =
|
||||
*(double *)lammps_extract_fix(lmp, "dist", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR, 3, 0);
|
||||
void *ptr = lammps_extract_fix(lmp, "dist", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR, 0, 0);
|
||||
int nhisto = *(double *)ptr;
|
||||
lammps_free(ptr);
|
||||
|
||||
ptr = lammps_extract_fix(lmp, "dist", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR, 1, 0);
|
||||
int nskip = *(double *)ptr;
|
||||
lammps_free(ptr);
|
||||
|
||||
ptr = lammps_extract_fix(lmp, "dist", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR, 2, 0);
|
||||
double minval = *(double *)ptr;
|
||||
lammps_free(ptr);
|
||||
|
||||
ptr = lammps_extract_fix(lmp, "dist", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR, 3, 0);
|
||||
double maxval = *(double *)ptr;
|
||||
lammps_free(ptr);
|
||||
|
||||
// 21 pair distances counted, none skipped, smallest 1.0, largest 2.1
|
||||
EXPECT_EQ(nhisto, 21);
|
||||
EXPECT_EQ(nskip, 0);
|
||||
@ -658,11 +695,10 @@ TEST_F(LibraryProperties, has_error)
|
||||
class AtomProperties : public ::testing::Test {
|
||||
protected:
|
||||
void *lmp;
|
||||
int ntypes, nlocal, nall;
|
||||
|
||||
AtomProperties() = default;
|
||||
;
|
||||
AtomProperties() = default;
|
||||
~AtomProperties() override = default;
|
||||
;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
@ -677,11 +713,30 @@ protected:
|
||||
if (verbose) std::cout << output;
|
||||
EXPECT_THAT(output, StartsWith("LAMMPS ("));
|
||||
::testing::internal::CaptureStdout();
|
||||
lammps_command(lmp, "fix props all property/atom i_one i2_two 2 d_three d2_four 2");
|
||||
lammps_command(lmp, "fix rmass all property/atom mol q rmass ghost yes");
|
||||
lammps_command(lmp, "region box block 0 2 0 2 0 2");
|
||||
lammps_command(lmp, "create_box 1 box");
|
||||
lammps_command(lmp, "mass 1 3.0");
|
||||
lammps_command(lmp, "create_atoms 1 single 1.0 1.0 1.5");
|
||||
lammps_command(lmp, "create_atoms 1 single 0.2 0.1 0.1");
|
||||
lammps_command(lmp, "set group all mass 2.0");
|
||||
lammps_command(lmp, "set atom 1 charge -1");
|
||||
lammps_command(lmp, "set atom 2 charge 1");
|
||||
lammps_command(lmp, "set atom 1 mol 2");
|
||||
lammps_command(lmp, "set atom 2 mol 1");
|
||||
lammps_command(lmp, "set atom 1 i_one -3");
|
||||
lammps_command(lmp, "set atom 2 i_one 3");
|
||||
lammps_command(lmp, "set atom 1 d_three -1.3");
|
||||
lammps_command(lmp, "set atom 2 d_three 3.5");
|
||||
lammps_command(lmp, "set atom 1 i_two[1] -3");
|
||||
lammps_command(lmp, "set atom 2 i_two[2] 3");
|
||||
lammps_command(lmp, "set atom * d_four[1] -1.3");
|
||||
lammps_command(lmp, "set atom * d_four[2] 3.5");
|
||||
ntypes = lammps_extract_setting(lmp, "ntypes");
|
||||
nlocal = lammps_extract_setting(lmp, "nlocal");
|
||||
nall = lammps_extract_setting(lmp, "nall");
|
||||
|
||||
output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
}
|
||||
@ -704,14 +759,42 @@ TEST_F(AtomProperties, invalid)
|
||||
TEST_F(AtomProperties, mass)
|
||||
{
|
||||
EXPECT_EQ(lammps_extract_atom_datatype(lmp, "mass"), LAMMPS_DOUBLE);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "mass", 0), ntypes + 1);
|
||||
auto *mass = (double *)lammps_extract_atom(lmp, "mass");
|
||||
ASSERT_NE(mass, nullptr);
|
||||
ASSERT_DOUBLE_EQ(mass[1], 3.0);
|
||||
EXPECT_EQ(lammps_extract_atom_datatype(lmp, "rmass"), LAMMPS_DOUBLE);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "rmass", 0), nall);
|
||||
mass = (double *)lammps_extract_atom(lmp, "rmass");
|
||||
ASSERT_NE(mass, nullptr);
|
||||
ASSERT_DOUBLE_EQ(mass[0], 2.0);
|
||||
ASSERT_DOUBLE_EQ(mass[1], 2.0);
|
||||
}
|
||||
|
||||
TEST_F(AtomProperties, charge)
|
||||
{
|
||||
EXPECT_EQ(lammps_extract_atom_datatype(lmp, "q"), LAMMPS_DOUBLE);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "rmass", 0), nall);
|
||||
auto *charge = (double *)lammps_extract_atom(lmp, "q");
|
||||
ASSERT_NE(charge, nullptr);
|
||||
ASSERT_DOUBLE_EQ(charge[0], -1.0);
|
||||
ASSERT_DOUBLE_EQ(charge[1], 1.0);
|
||||
}
|
||||
|
||||
TEST_F(AtomProperties, molecule)
|
||||
{
|
||||
EXPECT_EQ(lammps_extract_atom_datatype(lmp, "molecule"), LAMMPS_TAGINT);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "molecule", 0), nall);
|
||||
auto *molecule = (tagint *)lammps_extract_atom(lmp, "molecule");
|
||||
ASSERT_NE(molecule, nullptr);
|
||||
ASSERT_EQ(molecule[0], 2);
|
||||
ASSERT_EQ(molecule[1], 1);
|
||||
}
|
||||
|
||||
TEST_F(AtomProperties, id)
|
||||
{
|
||||
EXPECT_EQ(lammps_extract_atom_datatype(lmp, "id"), LAMMPS_TAGINT);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "id", 0), nall);
|
||||
auto *id = (tagint *)lammps_extract_atom(lmp, "id");
|
||||
ASSERT_NE(id, nullptr);
|
||||
ASSERT_EQ(id[0], 1);
|
||||
@ -721,6 +804,7 @@ TEST_F(AtomProperties, id)
|
||||
TEST_F(AtomProperties, type)
|
||||
{
|
||||
EXPECT_EQ(lammps_extract_atom_datatype(lmp, "type"), LAMMPS_INT);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "type", 0), nall);
|
||||
int *type = (int *)lammps_extract_atom(lmp, "type");
|
||||
ASSERT_NE(type, nullptr);
|
||||
ASSERT_EQ(type[0], 1);
|
||||
@ -730,6 +814,8 @@ TEST_F(AtomProperties, type)
|
||||
TEST_F(AtomProperties, position)
|
||||
{
|
||||
EXPECT_EQ(lammps_extract_atom_datatype(lmp, "x"), LAMMPS_DOUBLE_2D);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "x", LMP_SIZE_ROWS), nall);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "x", LMP_SIZE_COLS), 3);
|
||||
auto **x = (double **)lammps_extract_atom(lmp, "x");
|
||||
ASSERT_NE(x, nullptr);
|
||||
EXPECT_DOUBLE_EQ(x[0][0], 1.0);
|
||||
@ -740,6 +826,41 @@ TEST_F(AtomProperties, position)
|
||||
EXPECT_DOUBLE_EQ(x[1][2], 0.1);
|
||||
}
|
||||
|
||||
TEST_F(AtomProperties, custom)
|
||||
{
|
||||
EXPECT_EQ(lammps_extract_atom_datatype(lmp, "i_one"), LAMMPS_INT);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "i_one", 0), nlocal);
|
||||
auto *one = (int *)lammps_extract_atom(lmp, "i_one");
|
||||
ASSERT_NE(one, nullptr);
|
||||
EXPECT_EQ(lammps_extract_atom_datatype(lmp, "i2_two"), LAMMPS_INT_2D);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "i2_two", LMP_SIZE_ROWS), nlocal);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "i2_two", LMP_SIZE_COLS), 2);
|
||||
auto **two = (int **)lammps_extract_atom(lmp, "i2_two");
|
||||
ASSERT_NE(two, nullptr);
|
||||
EXPECT_EQ(lammps_extract_atom_datatype(lmp, "d_three"), LAMMPS_DOUBLE);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "d_three", 0), nlocal);
|
||||
auto *three = (double *)lammps_extract_atom(lmp, "d_three");
|
||||
ASSERT_NE(three, nullptr);
|
||||
EXPECT_EQ(lammps_extract_atom_datatype(lmp, "d2_four"), LAMMPS_DOUBLE_2D);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "d2_four", LMP_SIZE_ROWS), nlocal);
|
||||
EXPECT_EQ(lammps_extract_atom_size(lmp, "d2_four", LMP_SIZE_COLS), 2);
|
||||
auto **four = (double **)lammps_extract_atom(lmp, "d2_four");
|
||||
ASSERT_NE(four, nullptr);
|
||||
|
||||
EXPECT_EQ(one[0], -3);
|
||||
EXPECT_EQ(one[1], 3);
|
||||
EXPECT_EQ(two[0][0], -3);
|
||||
EXPECT_EQ(two[0][1], 0);
|
||||
EXPECT_EQ(two[1][0], 0);
|
||||
EXPECT_EQ(two[1][1], 3);
|
||||
EXPECT_DOUBLE_EQ(three[0], -1.3);
|
||||
EXPECT_DOUBLE_EQ(three[1], 3.5);
|
||||
EXPECT_DOUBLE_EQ(four[0][0], -1.3);
|
||||
EXPECT_DOUBLE_EQ(four[0][1], 3.5);
|
||||
EXPECT_DOUBLE_EQ(four[1][0], -1.3);
|
||||
EXPECT_DOUBLE_EQ(four[1][1], 3.5);
|
||||
}
|
||||
|
||||
TEST(SystemSettings, kokkos)
|
||||
{
|
||||
if (!lammps_config_has_package("KOKKOS")) GTEST_SKIP();
|
||||
|
||||
@ -229,6 +229,7 @@ TEST_F(GroupTest, SelectRestart)
|
||||
command("group five subtract all half xxx"););
|
||||
TEST_FAILURE(".*ERROR: Group ID xxx does not exist.*",
|
||||
command("group five intersect half top xxx"););
|
||||
delete[] flags;
|
||||
}
|
||||
|
||||
TEST_F(GroupTest, Molecular)
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "info.h"
|
||||
#include "input.h"
|
||||
#include "output.h"
|
||||
#include "platform.h"
|
||||
#include "update.h"
|
||||
#include "utils.h"
|
||||
#include "variable.h"
|
||||
@ -214,9 +215,9 @@ TEST_F(SimpleCommandsTest, Quit)
|
||||
TEST_FAILURE(".*ERROR: Expected integer .*", command("quit xxx"););
|
||||
|
||||
// the following tests must be skipped with OpenMPI or MPICH 4.1 and later due to using threads
|
||||
if (platform::mpi_vendor() == "Open MPI") GTEST_SKIP();
|
||||
if (platform::mpi_vendor() == "Open MPI") GTEST_SKIP() << "OpenMPI";
|
||||
#if defined(MPICH_NUMVERSION)
|
||||
if (MPICH_NUMVERSION >= 40100000) GTEST_SKIP();
|
||||
if (MPICH_NUMVERSION >= 40100000) GTEST_SKIP() << "MPICH with threads";
|
||||
#endif
|
||||
ASSERT_EXIT(command("quit"), ExitedWithCode(0), "");
|
||||
ASSERT_EXIT(command("quit 9"), ExitedWithCode(9), "");
|
||||
@ -412,7 +413,7 @@ TEST_F(SimpleCommandsTest, Plugin)
|
||||
{
|
||||
const char *bindir = getenv("LAMMPS_PLUGIN_BIN_DIR");
|
||||
const char *config = getenv("CMAKE_CONFIG_TYPE");
|
||||
if (!bindir) GTEST_SKIP();
|
||||
if (!bindir) GTEST_SKIP() << "LAMMPS_PLUGIN_BIN_DIR not set";
|
||||
std::string loadfmt = platform::path_join("plugin load ", bindir);
|
||||
if (config) loadfmt = platform::path_join(loadfmt, config);
|
||||
loadfmt = platform::path_join(loadfmt, "{}plugin.so");
|
||||
@ -556,6 +557,50 @@ TEST_F(SimpleCommandsTest, CiteMe)
|
||||
// no new citation. no CITE-CITE-CITE- lines
|
||||
ASSERT_THAT(text, Not(ContainsRegex(".*CITE-CITE-CITE-CITE.*")));
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, Geturl)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("EXTRA-COMMAND")) GTEST_SKIP();
|
||||
platform::unlink("index.html");
|
||||
platform::unlink("myindex.html");
|
||||
if (Info::has_curl_support()) {
|
||||
BEGIN_CAPTURE_OUTPUT();
|
||||
command("geturl https://www.lammps.org/index.html");
|
||||
command("geturl https://www.lammps.org/index.html output myindex.html");
|
||||
END_CAPTURE_OUTPUT();
|
||||
EXPECT_TRUE(platform::file_is_readable("index.html"));
|
||||
EXPECT_TRUE(platform::file_is_readable("myindex.html"));
|
||||
FILE *fp = fopen("index.html", "wb");
|
||||
fputs("just testing\n", fp);
|
||||
fclose(fp);
|
||||
BEGIN_CAPTURE_OUTPUT();
|
||||
command("geturl https://www.lammps.org/index.html overwrite no");
|
||||
END_CAPTURE_OUTPUT();
|
||||
char checkme[20];
|
||||
fp = fopen("index.html", "rb");
|
||||
fgets(checkme, 19, fp);
|
||||
fclose(fp);
|
||||
EXPECT_EQ(strcmp(checkme, "just testing\n"), 0);
|
||||
BEGIN_CAPTURE_OUTPUT();
|
||||
command("geturl https://www.lammps.org/index.html overwrite yes");
|
||||
END_CAPTURE_OUTPUT();
|
||||
fp = fopen("index.html", "rb");
|
||||
fgets(checkme, 19, fp);
|
||||
fclose(fp);
|
||||
EXPECT_NE(strcmp(checkme, "just testing\n"), 0);
|
||||
TEST_FAILURE(".*ERROR: Illegal geturl command: missing argument.*", command("geturl "););
|
||||
TEST_FAILURE(".*ERROR: URL 'dummy' is not a supported URL.*", command("geturl dummy"););
|
||||
TEST_FAILURE(".*ERROR on proc 0: Download of xxx.txt failed with: "
|
||||
"HTTP response code said error 404.*",
|
||||
command("geturl https://www.lammps.org/xxx.txt"););
|
||||
} else {
|
||||
TEST_FAILURE(".*ERROR: LAMMPS has not been compiled with libcurl support*",
|
||||
command("geturl https:://www.lammps.org/index.html"););
|
||||
}
|
||||
platform::unlink("index.html");
|
||||
platform::unlink("myindex.html");
|
||||
}
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
||||
@ -66,7 +66,7 @@ endif()
|
||||
if(WIN32)
|
||||
set(FORCE_TEST_ENVIRONMENT PYTHONPATH=${TEST_INPUT_FOLDER})
|
||||
else()
|
||||
set(FORCE_TEST_ENVIRONMENT PYTHONPATH=${TEST_INPUT_FOLDER}:$ENV{PYTHONPATH})
|
||||
set(FORCE_TEST_ENVIRONMENT PYTHONPATH=${TEST_INPUT_FOLDER}:${LAMMPS_PYTHON_DIR}:$ENV{PYTHONPATH})
|
||||
endif()
|
||||
list(APPEND FORCE_TEST_ENVIRONMENT "PYTHONUNBUFFERED=1")
|
||||
list(APPEND FORCE_TEST_ENVIRONMENT "PYTHONDONTWRITEBYTECODE=1")
|
||||
|
||||
@ -88,10 +88,9 @@ for header in headers:
|
||||
style = m[1]
|
||||
if upper.match(style):
|
||||
continue
|
||||
if style in ['reax/c', 'reax/c/omp', 'reax/c/kk',
|
||||
'reax/c/kk/device', 'reax/c/kk/host',
|
||||
'reax/c/species', 'reax/c/bonds',
|
||||
'reax/c/species/kk', 'reax/c/bonds/kk', 'meam/c']:
|
||||
if style in ['lj/sdk', 'lj/sdk/coul/long', 'lj/sdk/coul/msm', 'sdk', 'lj/sdk/gpu',
|
||||
'lj/sdk/coul/long/gpu', 'lj/sdk/omp', 'lj/sdk/coul/long/omp', 'sdk/omp',
|
||||
'lj/sdk/coul/msm/omp', 'lj/sdk/kk', 'lj/sdk/coul/long/kk', 'sdk/kk']:
|
||||
continue
|
||||
|
||||
# detect, process, and flag suffix styles:
|
||||
@ -176,11 +175,12 @@ def check_tests(name,styles,yaml,search,skip=()):
|
||||
|
||||
counter = 0
|
||||
counter += check_tests('pair',pair,'*-pair-*.yaml',
|
||||
'.*pair_style:\\s*((\\S+).*)?',skip=('meam','lj/sf'))
|
||||
'.*pair_style:\\s*((\\S+).*)?',
|
||||
skip=('lj/sf','lj/sdk', 'lj/sdk/coul/long', 'lj/sdk/coul/msm'))
|
||||
counter += check_tests('bond',bond,'bond-*.yaml',
|
||||
'.*bond_style:\\s*((\\S+).*)?')
|
||||
counter += check_tests('angle',angle,'angle-*.yaml',
|
||||
'.*angle_style:\\s*((\\S+).*)?')
|
||||
'.*angle_style:\\s*((\\S+).*)?', skip=('sdk'))
|
||||
counter += check_tests('dihedral',dihedral,'dihedral-*.yaml',
|
||||
'.*dihedral_style:\\s*((\\S+).*)?')
|
||||
counter += check_tests('improper',improper,'improper-*.yaml',
|
||||
|
||||
@ -362,8 +362,9 @@ TEST(AngleStyle, plain)
|
||||
EXPECT_STRESS("run_stress (newton on)", angle->virial, test_config.run_stress, epsilon);
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
double energy = 0.0;
|
||||
if (icompute) energy = icompute->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;
|
||||
@ -393,8 +394,8 @@ TEST(AngleStyle, plain)
|
||||
EXPECT_STRESS("run_stress (newton off)", angle->virial, test_config.run_stress, epsilon);
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) energy = icompute->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;
|
||||
@ -480,8 +481,9 @@ TEST(AngleStyle, omp)
|
||||
EXPECT_STRESS("run_stress (newton on)", angle->virial, test_config.run_stress, 10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
double energy = 0.0;
|
||||
if (icompute) energy = icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for OPENMP with angle style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
@ -515,8 +517,8 @@ TEST(AngleStyle, omp)
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) energy = icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for OPENMP with angle style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
@ -532,124 +534,124 @@ TEST(AngleStyle, omp)
|
||||
|
||||
TEST(AngleStyle, kokkos_omp)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("KOKKOS")) GTEST_SKIP();
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
if (!Info::has_accelerator_feature("KOKKOS", "api", "openmp")) GTEST_SKIP();
|
||||
if (!LAMMPS::is_installed_pkg("KOKKOS")) GTEST_SKIP();
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
if (!Info::has_accelerator_feature("KOKKOS", "api", "openmp")) GTEST_SKIP();
|
||||
|
||||
LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-k", "on", "t", "4", "-sf", "kk"};
|
||||
LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-k", "on", "t", "4", "-sf", "kk"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles with /kk suffix\n"
|
||||
"are not available in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles with /kk suffix\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();
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
EXPECT_THAT(output, StartsWith("LAMMPS ("));
|
||||
EXPECT_THAT(output, HasSubstr("Loop time"));
|
||||
EXPECT_THAT(output, StartsWith("LAMMPS ("));
|
||||
EXPECT_THAT(output, HasSubstr("Loop time"));
|
||||
|
||||
// abort if running in parallel and not all atoms are local
|
||||
const int nlocal = lmp->atom->nlocal;
|
||||
ASSERT_EQ(lmp->atom->natoms, nlocal);
|
||||
// abort if running in parallel and not all atoms are local
|
||||
const int nlocal = lmp->atom->nlocal;
|
||||
ASSERT_EQ(lmp->atom->natoms, nlocal);
|
||||
|
||||
// relax error a bit for KOKKOS package
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
// relax error a bit for KOKKOS package
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
|
||||
ErrorStats stats;
|
||||
auto angle = lmp->force->angle;
|
||||
ErrorStats stats;
|
||||
auto angle = lmp->force->angle;
|
||||
|
||||
EXPECT_FORCES("init_forces (newton on)", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("init_stress (newton on)", angle->virial, test_config.init_stress, epsilon);
|
||||
|
||||
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 (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
EXPECT_FORCES("run_forces (newton on)", lmp->atom, test_config.run_forces, 10 * epsilon);
|
||||
EXPECT_STRESS("run_stress (newton on)", angle->virial, test_config.run_stress, epsilon);
|
||||
|
||||
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 (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(args, 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) {
|
||||
angle = lmp->force->angle;
|
||||
|
||||
EXPECT_FORCES("init_forces (newton off)", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("init_stress (newton off)", angle->virial, test_config.init_stress,
|
||||
2 * epsilon);
|
||||
EXPECT_FORCES("init_forces (newton on)", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("init_stress (newton on)", angle->virial, test_config.init_stress, epsilon);
|
||||
|
||||
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 on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
EXPECT_FORCES("run_forces (newton off)", lmp->atom, test_config.run_forces, 10 * epsilon);
|
||||
EXPECT_STRESS("run_stress (newton off)", angle->virial, test_config.run_stress, epsilon);
|
||||
EXPECT_FORCES("run_forces (newton on)", lmp->atom, test_config.run_forces, 10 * epsilon);
|
||||
EXPECT_STRESS("run_stress (newton on)", angle->virial, test_config.run_stress, epsilon);
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
double energy = 0.0;
|
||||
if (icompute) energy = icompute->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 on: " << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
restart_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
lmp = init_lammps(args, test_config, false);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
angle = lmp->force->angle;
|
||||
EXPECT_FORCES("restart_forces", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("restart_stress", angle->virial, test_config.init_stress, epsilon);
|
||||
// skip over these tests if newton bond is forced to be on
|
||||
if (lmp->force->newton_bond == 0) {
|
||||
angle = lmp->force->angle;
|
||||
|
||||
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;
|
||||
EXPECT_FORCES("init_forces (newton off)", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("init_stress (newton off)", angle->virial, test_config.init_stress,
|
||||
2 * epsilon);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
data_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
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;
|
||||
|
||||
angle = lmp->force->angle;
|
||||
EXPECT_FORCES("data_forces", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("data_stress", angle->virial, test_config.init_stress, epsilon);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
run_lammps(lmp);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
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;
|
||||
EXPECT_FORCES("run_forces (newton off)", lmp->atom, test_config.run_forces, 10 * epsilon);
|
||||
EXPECT_STRESS("run_stress (newton off)", angle->virial, test_config.run_stress, epsilon);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
stats.reset();
|
||||
icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) energy = icompute->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 (!verbose) ::testing::internal::CaptureStdout();
|
||||
restart_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
angle = lmp->force->angle;
|
||||
EXPECT_FORCES("restart_forces", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("restart_stress", angle->virial, test_config.init_stress, epsilon);
|
||||
|
||||
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 (!verbose) ::testing::internal::CaptureStdout();
|
||||
data_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
angle = lmp->force->angle;
|
||||
EXPECT_FORCES("data_forces", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("data_stress", angle->virial, test_config.init_stress, epsilon);
|
||||
|
||||
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 (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
|
||||
TEST(AngleStyle, numdiff)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("EXTRA-FIX")) GTEST_SKIP();
|
||||
@ -766,11 +768,11 @@ TEST(AngleStyle, single)
|
||||
nangletypes));
|
||||
|
||||
if (utils::strmatch(test_config.angle_style, "^spica")) {
|
||||
command("pair_style lj/spica 8.0");
|
||||
command("pair_coeff * * lj9_6 0.02 2.5");
|
||||
command("pair_style lj/spica 8.0");
|
||||
command("pair_coeff * * lj9_6 0.02 2.5");
|
||||
} else {
|
||||
command("pair_style zero 8.0");
|
||||
command("pair_coeff * *");
|
||||
command("pair_style zero 8.0");
|
||||
command("pair_coeff * *");
|
||||
}
|
||||
|
||||
command("angle_style " + test_config.angle_style);
|
||||
|
||||
@ -362,8 +362,9 @@ TEST(BondStyle, plain)
|
||||
EXPECT_STRESS("run_stress (newton on)", bond->virial, test_config.run_stress, epsilon);
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
double energy = 0.0;
|
||||
if (icompute) energy = icompute->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;
|
||||
@ -393,8 +394,8 @@ TEST(BondStyle, plain)
|
||||
EXPECT_STRESS("run_stress (newton off)", bond->virial, test_config.run_stress, epsilon);
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) energy = icompute->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;
|
||||
@ -482,8 +483,9 @@ TEST(BondStyle, omp)
|
||||
EXPECT_STRESS("run_stress (newton on)", bond->virial, test_config.run_stress, 10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
double energy = 0.0;
|
||||
if (icompute) energy = icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for OPENMP with bond style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
@ -517,8 +519,8 @@ TEST(BondStyle, omp)
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) energy = icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for OPENMP with bond style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
@ -584,13 +586,13 @@ TEST(BondStyle, kokkos_omp)
|
||||
EXPECT_STRESS("run_stress (newton on)", bond->virial, test_config.run_stress, 10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon);
|
||||
|
||||
// FIXME: this is currently broken ??? for KOKKOS with bond style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
//if (test_config.bond_style.substr(0, 6) != "hybrid")
|
||||
// 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;
|
||||
@ -621,13 +623,13 @@ TEST(BondStyle, kokkos_omp)
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon);
|
||||
|
||||
// FIXME: this is currently broken ??? for KOKKOS with bond style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
//if (test_config.bond_style.substr(0, 6) != "hybrid")
|
||||
// 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;
|
||||
|
||||
@ -363,8 +363,9 @@ TEST(DihedralStyle, plain)
|
||||
EXPECT_STRESS("run_stress (newton on)", dihedral->virial, test_config.run_stress, epsilon);
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
double energy = 0.0;
|
||||
if (icompute) energy = icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.run_energy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(dihedral->energy, energy, epsilon);
|
||||
if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
@ -394,8 +395,8 @@ TEST(DihedralStyle, plain)
|
||||
EXPECT_STRESS("run_stress (newton off)", dihedral->virial, test_config.run_stress, epsilon);
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) energy = icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.run_energy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(dihedral->energy, energy, epsilon);
|
||||
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
@ -484,8 +485,9 @@ TEST(DihedralStyle, omp)
|
||||
EXPECT_STRESS("run_stress (newton on)", dihedral->virial, test_config.run_stress, 10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
double energy = 0.0;
|
||||
if (icompute) energy = icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for OPENMP with dihedral style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
@ -519,8 +521,8 @@ TEST(DihedralStyle, omp)
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) energy = icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for OPENMP with dihedral style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
@ -587,8 +589,8 @@ TEST(DihedralStyle, kokkos_omp)
|
||||
EXPECT_STRESS("run_stress (newton on)", dihedral->virial, test_config.run_stress, 10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.run_energy, epsilon);
|
||||
|
||||
// FIXME: this is currently broken ??? for KOKKOS with dihedral style hybrid
|
||||
@ -623,8 +625,8 @@ TEST(DihedralStyle, kokkos_omp)
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.run_energy, epsilon);
|
||||
|
||||
// FIXME: this is currently broken ??? for KOKKOS with dihedral style hybrid
|
||||
|
||||
@ -356,8 +356,9 @@ TEST(ImproperStyle, plain)
|
||||
EXPECT_STRESS("run_stress (newton on)", improper->virial, test_config.run_stress, epsilon);
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
double energy = 0.0;
|
||||
if (icompute) energy = icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.run_energy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(improper->energy, energy, epsilon);
|
||||
if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
@ -387,8 +388,8 @@ TEST(ImproperStyle, plain)
|
||||
EXPECT_STRESS("run_stress (newton off)", improper->virial, test_config.run_stress, epsilon);
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) energy = icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.run_energy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(improper->energy, energy, epsilon);
|
||||
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
@ -477,8 +478,9 @@ TEST(ImproperStyle, omp)
|
||||
EXPECT_STRESS("run_stress (newton on)", improper->virial, test_config.run_stress, 10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
double energy = 0.0;
|
||||
if (icompute) energy = icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for OPENMP with improper style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
@ -512,8 +514,8 @@ TEST(ImproperStyle, omp)
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) energy = icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.run_energy, epsilon);
|
||||
// TODO: this is currently broken for OPENMP with improper style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
@ -532,8 +534,9 @@ TEST(ImproperStyle, kokkos_omp)
|
||||
if (!LAMMPS::is_installed_pkg("KOKKOS")) GTEST_SKIP();
|
||||
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
|
||||
|
||||
LAMMPS::argv args = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-k", "on", "t", "4", "-sf", "kk"};
|
||||
LAMMPS::argv args = {"ImproperStyle", "-log", "none", "-echo", "screen",
|
||||
"-nocite", "-k", "on", "t", "4",
|
||||
"-sf", "kk"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
@ -579,12 +582,12 @@ TEST(ImproperStyle, kokkos_omp)
|
||||
EXPECT_STRESS("run_stress (newton on)", improper->virial, test_config.run_stress, 10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
int id = lmp->modify->find_compute("sum");
|
||||
double energy = lmp->modify->compute[id]->compute_scalar();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.run_energy, epsilon);
|
||||
// FIXME: this is currently broken ??? for KOKKOS with improper style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
//if (test_config.improper_style.substr(0, 6) != "hybrid")
|
||||
// if (test_config.improper_style.substr(0, 6) != "hybrid")
|
||||
// EXPECT_FP_LE_WITH_EPS(improper->energy, energy, epsilon);
|
||||
if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
@ -614,12 +617,12 @@ TEST(ImproperStyle, kokkos_omp)
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
id = lmp->modify->find_compute("sum");
|
||||
energy = lmp->modify->compute[id]->compute_scalar();
|
||||
icompute = lmp->modify->get_compute_by_id("sum");
|
||||
if (icompute) icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.run_energy, epsilon);
|
||||
// FIXME: this is currently broken ??? for KOKKOS with improper style hybrid
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
//if (test_config.improper_style.substr(0, 6) != "hybrid")
|
||||
// if (test_config.improper_style.substr(0, 6) != "hybrid")
|
||||
// EXPECT_FP_LE_WITH_EPS(improper->energy, energy, epsilon);
|
||||
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
}
|
||||
|
||||
94
unittest/force-styles/tests/atomic-pair-meam_2nn.yaml
Normal file
94
unittest/force-styles/tests/atomic-pair-meam_2nn.yaml
Normal file
@ -0,0 +1,94 @@
|
||||
---
|
||||
lammps_version: 27 Jun 2024
|
||||
tags: slow
|
||||
date_generated: Mon Aug 12 23:46:29 2024
|
||||
epsilon: 7.5e-12
|
||||
skip_tests:
|
||||
prerequisites: ! |
|
||||
pair meam
|
||||
pre_commands: ! |
|
||||
variable newton_pair delete
|
||||
if "$(is_active(package,gpu)) > 0.0" then "variable newton_pair index off" else "variable newton_pair index on"
|
||||
post_commands: ! ""
|
||||
input_file: in.metal
|
||||
pair_style: meam
|
||||
pair_coeff: ! |
|
||||
* * library_2nn.meam Mo Co Ni V Fe Al Cr MoCoNiVFeAlCr_2nn.meam Al Fe
|
||||
extract: ! |
|
||||
scale 2
|
||||
natoms: 32
|
||||
init_vdwl: -107.8522149524573
|
||||
init_coul: 0
|
||||
init_stress: ! |2-
|
||||
1.2463236806083357e+02 1.1490760469914052e+02 1.1210986693967126e+02 4.5246703121600254e+00 1.5804990408656899e-01 -1.0693137368246819e+00
|
||||
init_forces: ! |2
|
||||
1 1.2075570172666517e+00 2.5197974317501539e+00 -1.1088011670080028e-01
|
||||
2 -3.3640367719428432e-01 -1.3590821195539500e+00 1.1852344345133097e+00
|
||||
3 -6.2806484546469510e-01 3.5552480351430327e+00 -8.6421390688238175e-01
|
||||
4 4.7711098978942779e-01 -3.4532546721455060e-02 -1.0749843970666426e+00
|
||||
5 4.3030664720301770e-01 5.1385242342775950e+00 8.2781327426872553e-01
|
||||
6 1.3194251358883464e+00 1.8639650645916612e+00 -5.6832606883092055e-03
|
||||
7 -2.3101654115192791e+00 2.5604433342094270e+00 -7.2965336827545177e-02
|
||||
8 -1.8813107076039852e+00 -1.2147517281060345e+00 9.1262468920677720e-01
|
||||
9 -9.2706604883232924e-01 -2.1158693513637439e+00 -1.3343286591119883e+00
|
||||
10 -1.2821535869049376e+00 -3.0144489221384694e+00 -3.5351352564615675e+00
|
||||
11 -1.1335834282333026e+00 -3.5120338530097337e+00 2.0722646325441860e+00
|
||||
12 6.4102096458389779e-01 -3.1447615079722784e+00 2.8312043748924653e-01
|
||||
13 4.8280521904552287e-01 4.1076155220214972e-01 -9.1798823388030248e-01
|
||||
14 5.2653610661583794e-01 -6.2290703152681082e-01 1.7010115724137842e+00
|
||||
15 -7.3641720930753107e-01 5.2449888785562826e-01 -5.7457875359317656e-01
|
||||
16 4.8060957088965059e+00 -2.9601876033250800e+00 1.1513035413632531e+00
|
||||
17 1.5694265313688991e+00 3.9656667881189716e+00 8.0446307564172925e-01
|
||||
18 -3.3186946470767591e+00 -8.6416688843237033e-01 -1.6953623479817574e+00
|
||||
19 -3.1787673821310061e+00 -1.7128622766062167e+00 7.7068620510115116e-01
|
||||
20 4.1206254122568498e-01 5.5320100762335822e-01 -1.0482557707854925e+00
|
||||
21 3.6799553509965177e+00 3.0633923824191367e+00 8.3540419264329346e-01
|
||||
22 1.5509924103292916e-01 -1.5860895423323973e+00 -5.2078426108068854e-01
|
||||
23 1.6690346472590076e+00 3.0244758709213864e+00 -2.6993164884520335e+00
|
||||
24 2.7830638197025031e+00 2.1704432957797124e+00 1.5951786296349422e+00
|
||||
25 1.1508577091031484e+00 1.5739606526872121e-01 -9.6724308968747430e-01
|
||||
26 -2.4314196195337345e+00 -3.4972804822539008e+00 3.8662445702731656e+00
|
||||
27 4.5531493691138225e-01 -1.5956356316240030e+00 -7.4218682495610788e-01
|
||||
28 4.4529948322420981e-01 1.2688271559426214e+00 1.6734044826622807e+00
|
||||
29 1.2911541277019456e+00 2.3661170344126576e+00 2.8686172020066049e-02
|
||||
30 -9.9889060576019295e-01 -4.6769358116081083e-01 -1.7331648652075726e+00
|
||||
31 -5.8657575753077518e-01 -3.0113072080749070e+00 1.5141156316363609e+00
|
||||
32 -3.7526132507226246e+00 -2.4291478663140555e+00 -1.3244839720484307e+00
|
||||
run_vdwl: -107.86391929010357
|
||||
run_coul: 0
|
||||
run_stress: ! |2-
|
||||
1.2460641049604875e+02 1.1489405545508679e+02 1.1208055821712979e+02 4.5163937877216895e+00 1.5653915791901030e-01 -1.0648087528149703e+00
|
||||
run_forces: ! |2
|
||||
1 1.1982098120356077e+00 2.5189328855072604e+00 -1.1287702452749815e-01
|
||||
2 -3.3687377087795833e-01 -1.3586209740811037e+00 1.1846521390335771e+00
|
||||
3 -6.2753830023054646e-01 3.5498286732562088e+00 -8.6687524917664438e-01
|
||||
4 4.7826567877044829e-01 -3.4121646796145377e-02 -1.0736928010657518e+00
|
||||
5 4.2811167601152211e-01 5.1314869297038621e+00 8.3060267964198453e-01
|
||||
6 1.3208187793397210e+00 1.8625472163098040e+00 -7.4819094990931792e-03
|
||||
7 -2.3094312610266461e+00 2.5633891705072460e+00 -7.6399655653619072e-02
|
||||
8 -1.8837407578170451e+00 -1.2156052045450962e+00 9.1286334428885407e-01
|
||||
9 -9.2471341949015073e-01 -2.1184369065447348e+00 -1.3364985140770174e+00
|
||||
10 -1.2721630503503110e+00 -3.0114962329744257e+00 -3.5263496371870358e+00
|
||||
11 -1.1318567093029339e+00 -3.5131937929878601e+00 2.0685184872229150e+00
|
||||
12 6.4283915487501542e-01 -3.1426999031486584e+00 2.8276405878848243e-01
|
||||
13 4.8147178381451605e-01 4.0909344645359752e-01 -9.1491947204999780e-01
|
||||
14 5.2717854675953901e-01 -6.1739345398595136e-01 1.6974867980998318e+00
|
||||
15 -7.3576171999402440e-01 5.2489698626317516e-01 -5.7379291089028683e-01
|
||||
16 4.7935839321755500e+00 -2.9564377955739980e+00 1.1474171610401691e+00
|
||||
17 1.5710240367830319e+00 3.9643450325630152e+00 8.0512925186266537e-01
|
||||
18 -3.3181837050932246e+00 -8.6170982332414536e-01 -1.6970394219132037e+00
|
||||
19 -3.1767253119645460e+00 -1.7127744387001036e+00 7.6855380453281508e-01
|
||||
20 4.1060102803733067e-01 5.5359035731950390e-01 -1.0479411326306367e+00
|
||||
21 3.6756962936149260e+00 3.0553305228004728e+00 8.3488981594478473e-01
|
||||
22 1.5767159306162337e-01 -1.5836157386417897e+00 -5.1851130094038789e-01
|
||||
23 1.6744622235966600e+00 3.0245852385275738e+00 -2.6903790641330296e+00
|
||||
24 2.7816283497560637e+00 2.1691013258915732e+00 1.5966190075740303e+00
|
||||
25 1.1516228298127233e+00 1.5822163881139706e-01 -9.6685328121235659e-01
|
||||
26 -2.4248886427889236e+00 -3.4895861283958003e+00 3.8642894795477014e+00
|
||||
27 4.5573198082914618e-01 -1.5947345127964880e+00 -7.4500594054811942e-01
|
||||
28 4.4593808568247761e-01 1.2697079835157221e+00 1.6721660405011940e+00
|
||||
29 1.2888412883019529e+00 2.3653376970915940e+00 3.1784610920160050e-02
|
||||
30 -9.9801461169527850e-01 -4.6739204892503866e-01 -1.7314911367261039e+00
|
||||
31 -5.8942505089994013e-01 -3.0120820634848813e+00 1.5135338593175718e+00
|
||||
32 -3.7543807617263241e+00 -2.4304944396157859e+00 -1.3251620860859517e+00
|
||||
...
|
||||
158
unittest/force-styles/tests/manybody-pair-meam_2nn.yaml
Normal file
158
unittest/force-styles/tests/manybody-pair-meam_2nn.yaml
Normal file
@ -0,0 +1,158 @@
|
||||
---
|
||||
lammps_version: 27 Jun 2024
|
||||
tags:
|
||||
date_generated: Mon Aug 12 23:46:30 2024
|
||||
epsilon: 1e-10
|
||||
skip_tests:
|
||||
prerequisites: ! |
|
||||
pair meam
|
||||
pre_commands: ! |
|
||||
variable newton_pair delete
|
||||
if "$(is_active(package,gpu)) > 0.0" then "variable newton_pair index off" else "variable newton_pair index on"
|
||||
post_commands: ! ""
|
||||
input_file: in.manybody
|
||||
pair_style: meam
|
||||
pair_coeff: ! |
|
||||
* * library_2nn.meam Mo Co Ni V Fe Al Cr MoCoNiVFeAlCr_2nn.meam Mo Co Ni V Fe Al Al Cr
|
||||
extract: ! |
|
||||
scale 2
|
||||
natoms: 64
|
||||
init_vdwl: -171.6598108945207
|
||||
init_coul: 0
|
||||
init_stress: ! |2-
|
||||
1.5000244906093522e+02 1.4784843433112908e+02 1.8878670411728504e+02 -8.0067412186590516e+01 4.9436569287006911e+01 -6.3087814983498935e+00
|
||||
init_forces: ! |2
|
||||
1 -7.1478062494427608e+00 8.9470631373989686e+00 1.2867076958451909e+01
|
||||
2 -2.4212649493151468e+00 -9.6728792684791065e-01 -3.3304329963633963e+00
|
||||
3 6.4848908706964559e-01 -3.0922904703144066e-01 -1.2907971225248811e+00
|
||||
4 -5.6196991461628514e+00 7.1359699271239716e+00 9.0972001100265203e+00
|
||||
5 -1.6195236884746755e-01 3.9199449957842525e-02 -6.2883860122844171e-01
|
||||
6 -1.5805790911218078e+00 4.4492239034421193e+00 -2.0398891620744237e+00
|
||||
7 -3.8798221590432125e-01 -1.6545871333896967e+00 9.0324680518469669e-01
|
||||
8 7.9363816055289904e-01 6.1824005482731988e-02 -1.6309845411647025e-01
|
||||
9 -2.2954942065869219e+00 -7.9024873733503611e+00 -3.8191534736978525e+00
|
||||
10 -1.7993666410176701e+00 -3.9011465984634430e-01 -5.7869053315792431e+00
|
||||
11 1.2215654397550209e+00 -1.9370045833863268e+00 4.4048146287686379e-01
|
||||
12 -3.4292676729601550e+00 2.2733881756133276e+00 2.9392529088566115e+00
|
||||
13 4.5115278000799872e+00 6.6981319436890248e+00 4.9899159082724438e+00
|
||||
14 -5.9773130776866932e+00 8.2557215198071852e+00 -5.2407868913628617e+00
|
||||
15 -1.2027583728097232e+01 1.3022892568361190e+01 -1.5743562165049745e+01
|
||||
16 -6.0763429695166087e+00 -6.4700120430132362e+00 7.8723845263304844e+00
|
||||
17 4.7461818315219615e+00 7.2302450160421889e+00 -7.1645864402130810e+00
|
||||
18 -1.2006934037682315e+00 1.5747953628762406e+00 3.0746356656855400e-01
|
||||
19 -8.2267447167560248e-01 -1.8948255375154346e+00 -2.0644747973250368e+00
|
||||
20 -8.3641381932677703e+00 8.3156413660247903e+00 9.4554276133774291e+00
|
||||
21 2.1118140016295754e+00 1.0561827448202914e+00 -1.2268263317226191e-02
|
||||
22 -1.3597168647428347e+01 1.1689442133622299e+01 -1.5081510933867492e+01
|
||||
23 5.7470185446091915e-01 2.2533886904750862e+00 -1.5167484918069787e-01
|
||||
24 5.6537153879688118e-01 -4.9250695521262944e-01 1.0194056516804058e+00
|
||||
25 1.1176322749567416e+00 -2.5922087196599990e+00 7.2933671986944804e+00
|
||||
26 -5.7844708519961341e-01 1.7598945696608131e-01 -2.4732114752503931e-01
|
||||
27 1.4346566000770689e+00 -1.6637820012674229e-01 -7.1397620578881038e-01
|
||||
28 -1.9785045508166956e+00 3.9212428764563784e-01 1.5888384587634231e+01
|
||||
29 -1.1095973727391237e+00 9.0621514884138865e-01 -1.0181359621613952e+00
|
||||
30 -3.6953630084534685e+00 2.9356058686478623e+00 -3.3200607026175493e+00
|
||||
31 -3.5618178236777709e+00 2.9114366912742460e+00 -4.8416747420203157e+00
|
||||
32 -1.0703281880135609e+00 -1.5360815098054366e+00 7.5267703261299868e-01
|
||||
33 1.5184402897993658e+01 -1.2701610267365300e+01 1.7424804353753583e+01
|
||||
34 -4.1192353954536437e-01 5.8745054971033006e-01 -8.2976974741830423e-01
|
||||
35 1.3054479188427639e+00 -1.5927505416628623e-01 -1.2710780170161512e-01
|
||||
36 2.7248190035725308e+00 -2.2043789700568239e+00 5.8013602072515491e+00
|
||||
37 -9.1462209213424406e-01 8.0854296376822021e-01 -1.4785090160387857e+00
|
||||
38 1.9542033359812513e-01 -7.5295933226541456e-01 -1.9091095301836998e+00
|
||||
39 3.8018260071019760e+00 -4.6603401077846938e+00 -1.0628697024648432e+01
|
||||
40 1.9067027162571921e+00 -1.1752006196356417e+00 -1.0252979984098372e+00
|
||||
41 -8.3754676014344664e-01 -1.2153428434650497e+00 1.1188558500842400e+00
|
||||
42 -3.8933658846549819e+00 -2.2152395496573902e+00 -2.5602126289490967e+00
|
||||
43 -6.8854047024894760e-01 -2.9319214924354333e+00 -1.4631791261633504e+00
|
||||
44 8.5218477982593477e+00 -6.8810090921457290e+00 1.0187290735115324e+01
|
||||
45 -3.0924071537246300e-01 9.1220533597528664e-01 -1.2346580841779158e+00
|
||||
46 7.5746414213522040e-01 -1.8742046752551333e+00 1.9277474955397174e+00
|
||||
47 2.9366718645633076e+00 -9.8575609933154573e-01 -2.7043416310644499e+00
|
||||
48 4.9725672512275743e-01 -3.3956354220228357e-02 -6.1911879885571830e-01
|
||||
49 -5.4150794645243776e+00 -1.4450638682187991e+01 -5.9938360420574543e+00
|
||||
50 1.3271959102712154e+00 2.0763670271342720e+00 -2.5991939606221295e+00
|
||||
51 -2.6906428258237114e-01 1.0705407597316392e+00 9.4064901870909412e-01
|
||||
52 1.2698795538660745e+01 -1.1300577473527605e+01 1.6556209847933758e+01
|
||||
53 8.6276789549363464e+00 9.8339484163762432e+00 1.0666926587793320e+01
|
||||
54 8.0931294031442675e+00 -8.1575897043679078e+00 -1.1245679577771291e+01
|
||||
55 4.5659821210337785e+00 -5.4989692710718217e+00 -1.1117397718423149e+01
|
||||
56 6.7084121901543969e-01 3.3641183661003804e-01 -8.3326234809442234e-01
|
||||
57 3.9369712899260995e-01 -1.4018048616517627e+00 1.8319333464072913e+00
|
||||
58 6.1170451084776922e-01 7.5284186820631160e-01 -8.1520587122885435e-01
|
||||
59 3.2101692882893973e+00 1.5229322414026976e+00 -3.2984122041847894e+00
|
||||
60 2.0592353420349880e+00 -3.4994339669342516e+00 3.4334851296038265e+00
|
||||
61 2.2458738611493695e-03 9.5499626624233147e-01 -2.3855438551780955e-01
|
||||
62 -6.0105218595375396e+00 6.5524532804893409e+00 -5.8577792525744528e+00
|
||||
63 6.6185389719229342e+00 -7.2873587003214997e+00 -6.5502473418296780e+00
|
||||
64 -7.8336212891466195e-01 -3.2881136726111850e-02 2.0731714291698640e+00
|
||||
run_vdwl: -171.73142278874246
|
||||
run_coul: 0
|
||||
run_stress: ! |2-
|
||||
1.4973126318273444e+02 1.4750342125030221e+02 1.8860856816901264e+02 -7.9847562933619415e+01 4.9388866191108008e+01 -5.7694232837869039e+00
|
||||
run_forces: ! |2
|
||||
1 -7.1585253825910558e+00 8.9053915883225656e+00 1.2844669475069658e+01
|
||||
2 -2.4402593150947820e+00 -9.8770982897939419e-01 -3.3507467176903361e+00
|
||||
3 6.3650551722404791e-01 -3.0996706649471656e-01 -1.2792558787223647e+00
|
||||
4 -5.6101274223679081e+00 7.1006937008797992e+00 9.0552029245951680e+00
|
||||
5 -1.6604667819268432e-01 3.9519127167668811e-02 -6.2489164790485574e-01
|
||||
6 -1.4990519305213854e+00 4.4181760147769671e+00 -1.9724933863250651e+00
|
||||
7 -3.7052619782279644e-01 -1.6156914030259517e+00 8.5825721764767737e-01
|
||||
8 7.8930794208484056e-01 5.7485989089765037e-02 -1.5791455724230258e-01
|
||||
9 -2.3795405523862265e+00 -7.9820255092187899e+00 -3.8903921530255192e+00
|
||||
10 -1.8051779511520116e+00 -4.0312341164010018e-01 -5.7330317598070284e+00
|
||||
11 1.2099314114505173e+00 -1.9266110475849156e+00 4.3865911960539611e-01
|
||||
12 -3.4303484616430073e+00 2.2804239991575774e+00 2.9454722081915139e+00
|
||||
13 4.6052639558733475e+00 6.7539412845978211e+00 5.0798009112371609e+00
|
||||
14 -5.9951341097151465e+00 8.2509375569583447e+00 -5.2558134187527479e+00
|
||||
15 -1.1975327455033419e+01 1.2964020810814365e+01 -1.5657084305960888e+01
|
||||
16 -6.0085123130264986e+00 -6.4131331201126107e+00 7.8294149090677809e+00
|
||||
17 4.7378790481762199e+00 7.2106410747641476e+00 -7.0747318513827819e+00
|
||||
18 -1.2208179487209998e+00 1.5896046594521813e+00 3.2328719577936549e-01
|
||||
19 -8.4833102929118198e-01 -1.9144777361552021e+00 -2.0814385229178582e+00
|
||||
20 -8.3060159694428517e+00 8.2457783667884534e+00 9.3962444192711008e+00
|
||||
21 2.0783081095278111e+00 9.8444269254979688e-01 -8.0184225548496579e-02
|
||||
22 -1.3562256802610046e+01 1.1662128722418604e+01 -1.5071007179691101e+01
|
||||
23 5.8227759009590618e-01 2.2693559079956924e+00 -1.4716460013221938e-01
|
||||
24 5.8145875142270687e-01 -4.8729786513751472e-01 1.0109546493383947e+00
|
||||
25 1.1004842507837185e+00 -2.5713518049293529e+00 7.2391313077562911e+00
|
||||
26 -5.7777859718315894e-01 1.7868103090705781e-01 -2.3910776267224568e-01
|
||||
27 1.4393992901069925e+00 -1.7812959354937266e-01 -7.0805240877158171e-01
|
||||
28 -2.0408458628805874e+00 4.3162776707698597e-01 1.5894824805334625e+01
|
||||
29 -1.1093473214362350e+00 9.1550373850522526e-01 -1.0158881505035249e+00
|
||||
30 -3.6577662101254007e+00 2.8975695875593503e+00 -3.3056453064242750e+00
|
||||
31 -3.5568841859882561e+00 2.9013060677555078e+00 -4.8361502961714189e+00
|
||||
32 -1.0553259326658586e+00 -1.5179309659074374e+00 7.3374534103817646e-01
|
||||
33 1.5087431858313199e+01 -1.2655448593824781e+01 1.7371416840900455e+01
|
||||
34 -4.0555899434603232e-01 5.9945126501870671e-01 -8.3058575914748900e-01
|
||||
35 1.3122942243365687e+00 -1.5060805215592607e-01 -1.2729109577566639e-01
|
||||
36 2.6615361237010502e+00 -2.1515643400737776e+00 5.7399200415685110e+00
|
||||
37 -9.2720595040604947e-01 7.9997518657950717e-01 -1.4848089034064551e+00
|
||||
38 2.0402572291090582e-01 -7.4520184048365734e-01 -1.8843881574754946e+00
|
||||
39 3.7758957422531889e+00 -4.6103409596094078e+00 -1.0614749854342170e+01
|
||||
40 1.9281574625919398e+00 -1.1933100101884735e+00 -1.0378882246891563e+00
|
||||
41 -8.0246664433367820e-01 -1.1892044096377596e+00 1.1707276311170298e+00
|
||||
42 -3.9075019621204725e+00 -2.2375014726430114e+00 -2.5840516644847193e+00
|
||||
43 -6.9871748601621009e-01 -2.9298038237483959e+00 -1.4740848862529630e+00
|
||||
44 8.5167202516633083e+00 -6.8868580119727945e+00 1.0184770592036692e+01
|
||||
45 -3.3631930091756468e-01 8.8801123108851998e-01 -1.2543966895292440e+00
|
||||
46 7.4700828774509165e-01 -1.8569638352289362e+00 1.9751168925467499e+00
|
||||
47 2.9489399596707808e+00 -9.9105124910027753e-01 -2.6925123691809203e+00
|
||||
48 4.9759349370384398e-01 -3.4495475251494767e-02 -6.1657361032457225e-01
|
||||
49 -5.4728910617395696e+00 -1.4526190326826807e+01 -6.0859532714341196e+00
|
||||
50 1.3286905681614272e+00 2.0771086221398427e+00 -2.5974663166985912e+00
|
||||
51 -2.8921698897573539e-01 1.0839448403891534e+00 9.5801514467399540e-01
|
||||
52 1.2685244909045485e+01 -1.1266694983172416e+01 1.6520036928327187e+01
|
||||
53 8.6769281370583116e+00 9.9143456133926779e+00 1.0766418740290172e+01
|
||||
54 8.0735219599723180e+00 -8.1292327021531232e+00 -1.1209935449470830e+01
|
||||
55 4.5259884551939926e+00 -5.4776254533648601e+00 -1.1023994706802366e+01
|
||||
56 6.7055637888550557e-01 3.2646065284597842e-01 -8.2930560782933593e-01
|
||||
57 4.0053053723703291e-01 -1.4326275011328715e+00 1.8156009892224521e+00
|
||||
58 6.2335522987289660e-01 7.6457904519749642e-01 -8.2966286239098086e-01
|
||||
59 3.2382162312458891e+00 1.5435945597021004e+00 -3.3031316903727248e+00
|
||||
60 2.0118292099572499e+00 -3.4843792468087305e+00 3.3824144154037938e+00
|
||||
61 1.7004641558338716e-02 9.7008202227542040e-01 -2.1505989264639899e-01
|
||||
62 -5.9888421033889561e+00 6.5314584617002929e+00 -5.8280114512416663e+00
|
||||
63 6.6388004947382555e+00 -7.3175409884025360e+00 -6.5945771007975402e+00
|
||||
64 -7.2841762442693003e-01 1.7851440647814954e-02 2.0653209939206341e+00
|
||||
...
|
||||
@ -232,6 +232,7 @@ TEST_F(FileOperationsTest, read_lines_from_file)
|
||||
rv = utils::read_lines_from_file(fp, 2, MAX_BUF_SIZE / 2, buf, me, world);
|
||||
ASSERT_EQ(rv, 1);
|
||||
delete[] buf;
|
||||
if (me == 0) fclose(fp);
|
||||
}
|
||||
|
||||
TEST_F(FileOperationsTest, logmesg)
|
||||
|
||||
@ -87,6 +87,16 @@ TEST_F(TextFileReaderTest, nofp)
|
||||
ASSERT_THROW({ TextFileReader reader(nullptr, "test"); }, FileReaderException);
|
||||
}
|
||||
|
||||
TEST_F(TextFileReaderTest, buffer)
|
||||
{
|
||||
test_files();
|
||||
auto *reader = new TextFileReader("text_reader_two.file", "test");
|
||||
reader->set_bufsize(4096);
|
||||
auto *line = reader->next_line();
|
||||
ASSERT_THROW({ reader->set_bufsize(20); }, FileReaderException);
|
||||
delete reader;
|
||||
}
|
||||
|
||||
TEST_F(TextFileReaderTest, usefp)
|
||||
{
|
||||
test_files();
|
||||
|
||||
@ -4,9 +4,9 @@ MODULE keepstuff
|
||||
TYPE(LAMMPS), SAVE :: lmp
|
||||
INTEGER, SAVE :: mycomm
|
||||
CHARACTER(LEN=40), DIMENSION(3), PARAMETER :: demo_input = &
|
||||
[ CHARACTER(LEN=40) :: &
|
||||
'region box block 0 $x 0 2 0 2', &
|
||||
'create_box 1 box', &
|
||||
[ CHARACTER(LEN=40) :: &
|
||||
'region box block 0 $x 0 2 0 2', &
|
||||
'create_box 1 box', &
|
||||
'create_atoms 1 single 1.0 1.0 ${zpos}' ]
|
||||
CHARACTER(LEN=40), DIMENSION(3), PARAMETER :: big_input = &
|
||||
[ CHARACTER(LEN=40) :: &
|
||||
@ -14,15 +14,26 @@ MODULE keepstuff
|
||||
'create_box 1 box', &
|
||||
'create_atoms 1 single 1.0 1.0 ${zpos}' ]
|
||||
CHARACTER(LEN=40), DIMENSION(2), PARAMETER :: cont_input = &
|
||||
[ CHARACTER(LEN=40) :: &
|
||||
'create_atoms 1 single &', &
|
||||
[ CHARACTER(LEN=40) :: &
|
||||
'create_atoms 1 single &', &
|
||||
' 0.2 0.1 0.1' ]
|
||||
CHARACTER(LEN=60), DIMENSION(18), PARAMETER :: prop_input = &
|
||||
[ CHARACTER(LEN=60) :: 'fix 1 all nve', 'mass 1 3.0', &
|
||||
'fix 2 all property/atom mol q rmass ghost yes', &
|
||||
'fix 3 all property/atom i_one i2_two 2 d_three d2_four 2', &
|
||||
'set group all mass 2.0', 'set atom 1 charge -1', &
|
||||
'set atom 2 charge 1', 'set atom 1 mol 2', 'set atom 2 mol 1', &
|
||||
'set atom 1 i_one -3', 'set atom 2 i_one 3', &
|
||||
'set atom 1 d_three -1.3', 'set atom 2 d_three 3.5', &
|
||||
'set atom 1 i_two[1] -3', 'set atom 2 i_two[2] 3', &
|
||||
'set atom * d_four[1] -1.3', 'set atom * d_four[2] 3.5', &
|
||||
'run 0 post no' ]
|
||||
CHARACTER(LEN=40), DIMENSION(1), PARAMETER :: more_input = &
|
||||
[ CHARACTER(LEN=40) :: 'create_atoms 1 single 0.5 0.5 0.5' ]
|
||||
CHARACTER(LEN=40), DIMENSION(3), PARAMETER :: pair_input = &
|
||||
[ CHARACTER(LEN=40) :: &
|
||||
'pair_style lj/cut 2.5', &
|
||||
'pair_coeff 1 1 1.0 1.0', &
|
||||
[ CHARACTER(LEN=40) :: &
|
||||
'pair_style lj/cut 2.5', &
|
||||
'pair_coeff 1 1 1.0 1.0', &
|
||||
'mass 1 2.0' ]
|
||||
|
||||
INTERFACE
|
||||
@ -63,4 +74,3 @@ CONTAINS
|
||||
END FUNCTION f2c_string
|
||||
|
||||
END MODULE keepstuff
|
||||
|
||||
|
||||
@ -24,12 +24,13 @@ END SUBROUTINE f_lammps_close
|
||||
|
||||
SUBROUTINE f_lammps_setup_extract_atom() BIND(C)
|
||||
USE LIBLAMMPS
|
||||
USE keepstuff, ONLY : lmp, big_input, cont_input, pair_input
|
||||
USE keepstuff, ONLY : lmp, big_input, cont_input, pair_input, prop_input
|
||||
IMPLICIT NONE
|
||||
|
||||
CALL lmp%commands_list(big_input)
|
||||
CALL lmp%commands_list(cont_input)
|
||||
CALL lmp%commands_list(pair_input)
|
||||
CALL lmp%commands_list(prop_input)
|
||||
END SUBROUTINE f_lammps_setup_extract_atom
|
||||
|
||||
FUNCTION f_lammps_extract_atom_mass() BIND(C)
|
||||
@ -44,6 +45,19 @@ FUNCTION f_lammps_extract_atom_mass() BIND(C)
|
||||
f_lammps_extract_atom_mass = mass(1)
|
||||
END FUNCTION f_lammps_extract_atom_mass
|
||||
|
||||
FUNCTION f_lammps_extract_atom_mass_size() BIND(C)
|
||||
USE, INTRINSIC :: ISO_C_BINDING, ONLY : c_double, c_int
|
||||
USE LIBLAMMPS
|
||||
USE keepstuff, ONLY : lmp
|
||||
IMPLICIT NONE
|
||||
INTEGER(c_int) :: f_lammps_extract_atom_mass_size, ntypes
|
||||
REAL(c_double), DIMENSION(:), POINTER :: mass => NULL()
|
||||
|
||||
ntypes = lmp%extract_setting('ntypes')
|
||||
mass = lmp%extract_atom('mass')
|
||||
f_lammps_extract_atom_mass_size = SIZE(mass)
|
||||
END FUNCTION f_lammps_extract_atom_mass_size
|
||||
|
||||
FUNCTION f_lammps_extract_atom_tag_int(i) BIND(C)
|
||||
USE, INTRINSIC :: ISO_C_BINDING, ONLY : c_double, c_int
|
||||
USE LIBLAMMPS
|
||||
@ -83,6 +97,18 @@ FUNCTION f_lammps_extract_atom_type(i) BIND(C)
|
||||
f_lammps_extract_atom_type = atype(i)
|
||||
END FUNCTION f_lammps_extract_atom_type
|
||||
|
||||
FUNCTION f_lammps_extract_atom_type_size() BIND(C)
|
||||
USE, INTRINSIC :: ISO_C_BINDING, ONLY : c_int
|
||||
USE LIBLAMMPS
|
||||
USE keepstuff, ONLY : lmp
|
||||
IMPLICIT NONE
|
||||
INTEGER(c_int) :: f_lammps_extract_atom_type_size
|
||||
INTEGER(c_int), DIMENSION(:), POINTER :: atype => NULL()
|
||||
|
||||
atype = lmp%extract_atom('type')
|
||||
f_lammps_extract_atom_type_size = size(atype)
|
||||
END FUNCTION f_lammps_extract_atom_type_size
|
||||
|
||||
FUNCTION f_lammps_extract_atom_mask(i) BIND(C)
|
||||
USE, INTRINSIC :: ISO_C_BINDING, ONLY : c_int
|
||||
USE LIBLAMMPS
|
||||
@ -109,6 +135,19 @@ SUBROUTINE f_lammps_extract_atom_x(i, x) BIND(C)
|
||||
x = xptr(:,i)
|
||||
END SUBROUTINE f_lammps_extract_atom_x
|
||||
|
||||
FUNCTION f_lammps_extract_atom_x_size(i) BIND(C)
|
||||
USE, INTRINSIC :: ISO_C_BINDING, ONLY : c_double, c_int
|
||||
USE LIBLAMMPS
|
||||
USE keepstuff, ONLY : lmp
|
||||
IMPLICIT NONE
|
||||
INTEGER(c_int), INTENT(IN), VALUE :: i
|
||||
INTEGER(c_int) :: f_lammps_extract_atom_x_size
|
||||
REAL(c_double), DIMENSION(:,:), POINTER :: xptr => NULL()
|
||||
|
||||
xptr = lmp%extract_atom('x')
|
||||
f_lammps_extract_atom_x_size = SIZE(xptr, i)
|
||||
END FUNCTION f_lammps_extract_atom_x_size
|
||||
|
||||
SUBROUTINE f_lammps_extract_atom_v(i, v) BIND(C)
|
||||
USE, INTRINSIC :: ISO_C_BINDING, ONLY : c_double, c_int
|
||||
USE LIBLAMMPS
|
||||
@ -121,3 +160,16 @@ SUBROUTINE f_lammps_extract_atom_v(i, v) BIND(C)
|
||||
vptr = lmp%extract_atom('v')
|
||||
v = vptr(:,i)
|
||||
END SUBROUTINE f_lammps_extract_atom_v
|
||||
|
||||
FUNCTION f_lammps_extract_atom_v_size(i) BIND(C)
|
||||
USE, INTRINSIC :: ISO_C_BINDING, ONLY : c_double, c_int
|
||||
USE LIBLAMMPS
|
||||
USE keepstuff, ONLY : lmp
|
||||
IMPLICIT NONE
|
||||
INTEGER(c_int), INTENT(IN), VALUE :: i
|
||||
INTEGER(c_int) :: f_lammps_extract_atom_v_size
|
||||
REAL(c_double), DIMENSION(:,:), POINTER :: xptr => NULL()
|
||||
|
||||
xptr = lmp%extract_atom('v')
|
||||
f_lammps_extract_atom_v_size = SIZE(xptr, i)
|
||||
END FUNCTION f_lammps_extract_atom_v_size
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// unit tests for extracting Atom class data from a LAMMPS instance through the
|
||||
// Fortran wrapper
|
||||
|
||||
#include "atom.h"
|
||||
#include "lammps.h"
|
||||
#include "library.h"
|
||||
#include <cstdint>
|
||||
@ -16,12 +17,16 @@ void *f_lammps_with_args();
|
||||
void f_lammps_close();
|
||||
void f_lammps_setup_extract_atom();
|
||||
double f_lammps_extract_atom_mass();
|
||||
int f_lammps_extract_atom_mass_size();
|
||||
int f_lammps_extract_atom_tag_int(int);
|
||||
int64_t f_lammps_extract_atom_tag_int64(int64_t);
|
||||
int f_lammps_extract_atom_type(int);
|
||||
int f_lammps_extract_atom_type_size();
|
||||
int f_lammps_extract_atom_mask(int);
|
||||
void f_lammps_extract_atom_x(int, double *);
|
||||
int f_lammps_extract_atom_x_size(int);
|
||||
void f_lammps_extract_atom_v(int, double *);
|
||||
int f_lammps_extract_atom_v_size(int);
|
||||
}
|
||||
|
||||
class LAMMPS_extract_atom : public ::testing::Test {
|
||||
@ -50,7 +55,9 @@ protected:
|
||||
TEST_F(LAMMPS_extract_atom, mass)
|
||||
{
|
||||
f_lammps_setup_extract_atom();
|
||||
EXPECT_DOUBLE_EQ(f_lammps_extract_atom_mass(), 2.0);
|
||||
int ntypes = lmp->atom->ntypes;
|
||||
EXPECT_DOUBLE_EQ(f_lammps_extract_atom_mass(), 3.0);
|
||||
EXPECT_EQ(f_lammps_extract_atom_mass_size(), ntypes + 1);
|
||||
};
|
||||
|
||||
TEST_F(LAMMPS_extract_atom, tag)
|
||||
@ -68,8 +75,10 @@ TEST_F(LAMMPS_extract_atom, tag)
|
||||
TEST_F(LAMMPS_extract_atom, type)
|
||||
{
|
||||
f_lammps_setup_extract_atom();
|
||||
int nall = lmp->atom->nlocal + lmp->atom->nghost;
|
||||
EXPECT_EQ(f_lammps_extract_atom_type(1), 1);
|
||||
EXPECT_EQ(f_lammps_extract_atom_type(2), 1);
|
||||
EXPECT_EQ(f_lammps_extract_atom_type_size(), nall);
|
||||
};
|
||||
|
||||
TEST_F(LAMMPS_extract_atom, mask)
|
||||
@ -86,6 +95,7 @@ TEST_F(LAMMPS_extract_atom, mask)
|
||||
TEST_F(LAMMPS_extract_atom, x)
|
||||
{
|
||||
f_lammps_setup_extract_atom();
|
||||
int nall = lmp->atom->nlocal + lmp->atom->nghost;
|
||||
double x1[3];
|
||||
double x2[3];
|
||||
f_lammps_extract_atom_x(1, x1);
|
||||
@ -96,11 +106,15 @@ TEST_F(LAMMPS_extract_atom, x)
|
||||
EXPECT_DOUBLE_EQ(x2[0], 0.2);
|
||||
EXPECT_DOUBLE_EQ(x2[1], 0.1);
|
||||
EXPECT_DOUBLE_EQ(x2[2], 0.1);
|
||||
// in Fortran row and column are swapped
|
||||
EXPECT_EQ(f_lammps_extract_atom_x_size(1), 3);
|
||||
EXPECT_EQ(f_lammps_extract_atom_x_size(2), nall);
|
||||
}
|
||||
|
||||
TEST_F(LAMMPS_extract_atom, v)
|
||||
{
|
||||
f_lammps_setup_extract_atom();
|
||||
int nall = lmp->atom->nlocal + lmp->atom->nghost;
|
||||
double v1[3];
|
||||
double v2[3];
|
||||
f_lammps_extract_atom_v(1, v1);
|
||||
@ -117,4 +131,13 @@ TEST_F(LAMMPS_extract_atom, v)
|
||||
EXPECT_DOUBLE_EQ(v1[0], 1.0);
|
||||
EXPECT_DOUBLE_EQ(v1[1], 2.0);
|
||||
EXPECT_DOUBLE_EQ(v1[2], 3.0);
|
||||
// in Fortran row and column are swapped!
|
||||
EXPECT_EQ(f_lammps_extract_atom_v_size(1), 3);
|
||||
EXPECT_EQ(f_lammps_extract_atom_v_size(2), lmp->atom->nlocal);
|
||||
lammps_command(lmp, "comm_modify vel yes");
|
||||
lammps_command(lmp, "run 0 post no");
|
||||
EXPECT_EQ(f_lammps_extract_atom_v_size(1), 3);
|
||||
EXPECT_EQ(f_lammps_extract_atom_v_size(2), nall);
|
||||
}
|
||||
|
||||
// TODO: write tests for custom properties
|
||||
|
||||
@ -85,10 +85,19 @@ TEST_F(LAMMPS_thermo, last_thermo)
|
||||
f_lammps_last_thermo_setup();
|
||||
EXPECT_EQ(f_lammps_last_thermo_step(), 15);
|
||||
EXPECT_EQ(f_lammps_last_thermo_num(), 6);
|
||||
EXPECT_STREQ(f_lammps_last_thermo_string(1), "Step");
|
||||
EXPECT_STREQ(f_lammps_last_thermo_string(2), "Temp");
|
||||
EXPECT_STREQ(f_lammps_last_thermo_string(3), "E_pair");
|
||||
EXPECT_STREQ(f_lammps_last_thermo_string(6), "Press");
|
||||
char *thermostr;
|
||||
thermostr = (char *)f_lammps_last_thermo_string(1);
|
||||
EXPECT_STREQ(thermostr, "Step");
|
||||
free(thermostr);
|
||||
thermostr = (char *)f_lammps_last_thermo_string(2);
|
||||
EXPECT_STREQ(thermostr, "Temp");
|
||||
free(thermostr);
|
||||
thermostr = (char *)f_lammps_last_thermo_string(3);
|
||||
EXPECT_STREQ(thermostr, "E_pair");
|
||||
free(thermostr);
|
||||
thermostr = (char *)f_lammps_last_thermo_string(6);
|
||||
EXPECT_STREQ(thermostr, "Press");
|
||||
free(thermostr);
|
||||
#if defined(LAMMPS_SMALLSMALL)
|
||||
EXPECT_EQ(f_lammps_last_thermo_type(1), multitype::LAMMPS_INT);
|
||||
#else
|
||||
|
||||
@ -656,6 +656,9 @@ create_atoms 1 single &
|
||||
self.assertEqual(self.lmp.extract_global("map_tag_max"), -1)
|
||||
self.assertEqual(self.lmp.extract_global("sortfreq"), 1000)
|
||||
self.assertEqual(self.lmp.extract_global("nextsort"), 0)
|
||||
self.assertEqual(self.lmp.extract_global("xlattice"), 1.0)
|
||||
self.assertEqual(self.lmp.extract_global("ylattice"), 1.0)
|
||||
self.assertEqual(self.lmp.extract_global("zlattice"), 1.0)
|
||||
|
||||
# set and initialize r-RESPA
|
||||
self.lmp.command("run_style respa 3 5 2 pair 2 kspace 3")
|
||||
|
||||
@ -155,67 +155,104 @@ class PythonNumpy(unittest.TestCase):
|
||||
self.assertEqual(values[1,0], 1.5)
|
||||
self.assertEqual(values[1,3], 1.5)
|
||||
|
||||
def testExtractAtomDeprecated(self):
|
||||
self.lmp.command("units lj")
|
||||
self.lmp.command("atom_style atomic")
|
||||
self.lmp.command("atom_modify map array")
|
||||
self.lmp.command("region box block 0 2 0 2 0 2")
|
||||
self.lmp.command("create_box 1 box")
|
||||
|
||||
x = [
|
||||
1.0, 1.0, 1.0,
|
||||
1.0, 1.0, 1.5
|
||||
]
|
||||
|
||||
types = [1, 1]
|
||||
|
||||
self.assertEqual(self.lmp.create_atoms(2, id=None, type=types, x=x), 2)
|
||||
nlocal = self.lmp.extract_global("nlocal", LAMMPS_INT)
|
||||
self.assertEqual(nlocal, 2)
|
||||
|
||||
ident = self.lmp.numpy.extract_atom_iarray("id", nlocal, dim=1)
|
||||
self.assertEqual(len(ident), 2)
|
||||
|
||||
ntypes = self.lmp.extract_global("ntypes", LAMMPS_INT)
|
||||
self.assertEqual(ntypes, 1)
|
||||
|
||||
x = self.lmp.numpy.extract_atom_darray("x", nlocal, dim=3)
|
||||
v = self.lmp.numpy.extract_atom_darray("v", nlocal, dim=3)
|
||||
self.assertEqual(len(x), 2)
|
||||
self.assertTrue((x[0] == (1.0, 1.0, 1.0)).all())
|
||||
self.assertTrue((x[1] == (1.0, 1.0, 1.5)).all())
|
||||
self.assertEqual(len(v), 2)
|
||||
|
||||
def testExtractAtom(self):
|
||||
self.lmp.command("units lj")
|
||||
self.lmp.command("atom_style atomic")
|
||||
self.lmp.command("atom_modify map array")
|
||||
self.lmp.command("region box block 0 2 0 2 0 2")
|
||||
self.lmp.command("create_box 1 box")
|
||||
self.lmp.command("create_box 2 box")
|
||||
|
||||
x = [
|
||||
1.0, 1.0, 1.0,
|
||||
1.0, 1.0, 1.5
|
||||
]
|
||||
x = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.5, 1.5, 1.0, 1.0 ]
|
||||
types = [1, 2, 1]
|
||||
ids = [1, 2, 3]
|
||||
self.assertEqual(self.lmp.create_atoms(3, id=ids, type=types, x=x), 3)
|
||||
self.lmp.command("mass * 2.0")
|
||||
self.lmp.command("pair_style zero 1.1")
|
||||
self.lmp.command("pair_coeff * *")
|
||||
self.lmp.command("fix props all property/atom i_one i2_two 2 d_three d2_four 2");
|
||||
self.lmp.command("fix rmass all property/atom mol q rmass ghost yes");
|
||||
self.lmp.command("fix 1 all nve")
|
||||
self.lmp.command("run 0 post no")
|
||||
ntypes = self.lmp.extract_setting("ntypes");
|
||||
nlocal = self.lmp.extract_setting("nlocal");
|
||||
nall = self.lmp.extract_setting("nall");
|
||||
self.assertEqual(nlocal, 3)
|
||||
self.assertEqual(ntypes, 2)
|
||||
self.assertEqual(nall, 63)
|
||||
|
||||
types = [1, 1]
|
||||
self.lmp.command("set atom 1 charge -1");
|
||||
self.lmp.command("set atom 2 charge 1");
|
||||
self.lmp.command("set atom 3 charge 0");
|
||||
self.lmp.command("set atom * mol 2");
|
||||
self.lmp.command("set atom 2 mol 1");
|
||||
self.lmp.command("set atom 1 i_one -3");
|
||||
self.lmp.command("set atom 2 i_one 3");
|
||||
self.lmp.command("set atom 2 d_three -1.3");
|
||||
self.lmp.command("set atom 3 d_three 3.5");
|
||||
self.lmp.command("set atom 1 i_two[1] -3");
|
||||
self.lmp.command("set atom 2 i_two[2] 3");
|
||||
self.lmp.command("set atom * d_four[1] -1.3");
|
||||
self.lmp.command("set atom * d_four[2] 3.5");
|
||||
self.lmp.command("run 0 post no")
|
||||
|
||||
self.assertEqual(self.lmp.create_atoms(2, id=None, type=types, x=x), 2)
|
||||
nlocal = self.lmp.extract_global("nlocal")
|
||||
self.assertEqual(nlocal, 2)
|
||||
mass = self.lmp.numpy.extract_atom("mass")
|
||||
self.assertEqual(len(mass), ntypes + 1)
|
||||
self.assertTrue((mass == (0.0, 2.0, 2.0)).all())
|
||||
|
||||
rmass = self.lmp.numpy.extract_atom("rmass")
|
||||
self.assertEqual(len(rmass), nall)
|
||||
self.assertTrue((rmass[0:3] == (0.0, 0.0, 0.0)).all())
|
||||
|
||||
charge = self.lmp.numpy.extract_atom("q")
|
||||
self.assertEqual(len(charge), nall)
|
||||
self.assertTrue((charge[0:3] == (-1.0, 1.0, 0.0)).all())
|
||||
|
||||
molecule = self.lmp.numpy.extract_atom("molecule")
|
||||
self.assertEqual(len(molecule), nall)
|
||||
self.assertTrue((molecule[0:3] == (2, 1, 2)).all())
|
||||
|
||||
ident = self.lmp.numpy.extract_atom("id")
|
||||
self.assertEqual(len(ident), 2)
|
||||
self.assertEqual(len(ident), nall)
|
||||
self.assertTrue((ident[0:3] == (1, 2, 3)).all())
|
||||
|
||||
ntypes = self.lmp.extract_global("ntypes")
|
||||
self.assertEqual(ntypes, 1)
|
||||
atype = self.lmp.numpy.extract_atom("type")
|
||||
self.assertEqual(len(atype), nall)
|
||||
self.assertTrue((atype[0:3] == (1, 2, 1)).all())
|
||||
|
||||
x = self.lmp.numpy.extract_atom("x")
|
||||
v = self.lmp.numpy.extract_atom("v")
|
||||
self.assertEqual(len(x), 2)
|
||||
self.assertEqual(len(x), nall)
|
||||
self.assertEqual(len(x[0]), 3)
|
||||
self.assertTrue((x[0] == (1.0, 1.0, 1.0)).all())
|
||||
self.assertTrue((x[1] == (1.0, 1.0, 1.5)).all())
|
||||
self.assertEqual(len(v), 2)
|
||||
self.assertTrue((x[2] == (1.5, 1.0, 1.0)).all())
|
||||
self.assertEqual(len(v), nlocal)
|
||||
self.assertEqual(len(v[0]), 3)
|
||||
|
||||
self.lmp.command("comm_modify vel yes");
|
||||
self.lmp.command("run 0 post no")
|
||||
|
||||
v = self.lmp.numpy.extract_atom("v")
|
||||
self.assertEqual(len(v), nall)
|
||||
|
||||
one = self.lmp.numpy.extract_atom("i_one")
|
||||
two = self.lmp.numpy.extract_atom("i2_two")
|
||||
three = self.lmp.numpy.extract_atom("d_three")
|
||||
four = self.lmp.numpy.extract_atom("d2_four")
|
||||
self.assertEqual(len(one), nlocal)
|
||||
self.assertTrue((one == (-3, 3, 0)).all())
|
||||
self.assertEqual(len(two), nlocal)
|
||||
self.assertEqual(len(two[0]), 2)
|
||||
self.assertTrue((two[0] == (-3, 0)).all())
|
||||
self.assertTrue((two[1] == (0, 3)).all())
|
||||
self.assertTrue((two[2] == (0, 0)).all())
|
||||
self.assertEqual(len(three), nlocal)
|
||||
self.assertTrue((three == (0.0, -1.3, 3.5)).all())
|
||||
self.assertEqual(len(four), nlocal)
|
||||
self.assertEqual(len(four[0]), 2)
|
||||
self.assertTrue((four[0] == (-1.3, 3.5)).all())
|
||||
self.assertTrue((four[1] == (-1.3, 3.5)).all())
|
||||
self.assertTrue((four[2] == (-1.3, 3.5)).all())
|
||||
|
||||
@unittest.skipIf(not has_full,"Gather bonds test")
|
||||
def testGatherBond_newton_on(self):
|
||||
|
||||
@ -32,6 +32,12 @@ using LAMMPS_NS::LAMMPSException;
|
||||
|
||||
using ::testing::ContainsRegex;
|
||||
|
||||
#if defined(LAMMPS_SKIP_DEATH_TESTS)
|
||||
#define TEST_FAILURE(errmsg, ...) \
|
||||
{ \
|
||||
; \
|
||||
}
|
||||
#else
|
||||
#define TEST_FAILURE(errmsg, ...) \
|
||||
{ \
|
||||
::testing::internal::CaptureStdout(); \
|
||||
@ -39,6 +45,7 @@ using ::testing::ContainsRegex;
|
||||
auto mesg = ::testing::internal::GetCapturedStdout(); \
|
||||
ASSERT_THAT(mesg, ContainsRegex(errmsg)); \
|
||||
}
|
||||
#endif
|
||||
|
||||
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
|
||||
extern bool verbose;
|
||||
|
||||
Reference in New Issue
Block a user