Merge branch 'lammps:develop' into develop
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})
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
add_executable(test_library_open test_library_open.cpp test_main.cpp)
|
||||
target_link_libraries(test_library_open PRIVATE lammps GTest::GMock)
|
||||
add_test(NAME LibraryOpen COMMAND test_library_open)
|
||||
set_tests_properties(LibraryOpen PROPERTIES ENVIRONMENT "OMP_NUM_THREADS=4;OMP_PROC_BIND=false")
|
||||
|
||||
add_executable(test_library_commands test_library_commands.cpp test_main.cpp)
|
||||
target_link_libraries(test_library_commands PRIVATE lammps GTest::GMock)
|
||||
@ -16,7 +17,7 @@ add_executable(test_library_properties test_library_properties.cpp test_main.cpp
|
||||
target_link_libraries(test_library_properties PRIVATE lammps GTest::GMock)
|
||||
target_compile_definitions(test_library_properties PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_test(NAME LibraryProperties COMMAND test_library_properties)
|
||||
set_tests_properties(LibraryProperties PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
|
||||
set_tests_properties(LibraryProperties PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};OMP_NUM_THREADS=4;OMP_PROC_BIND=false")
|
||||
|
||||
add_executable(test_library_objects test_library_objects.cpp test_main.cpp)
|
||||
target_link_libraries(test_library_objects PRIVATE lammps GTest::GMock)
|
||||
|
||||
@ -2,10 +2,12 @@
|
||||
|
||||
#include "lammps.h"
|
||||
#define LAMMPS_LIB_MPI 1
|
||||
#include "info.h"
|
||||
#include "library.h"
|
||||
#include <cstdio> // for stdin, stdout
|
||||
#include <mpi.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
@ -78,9 +80,38 @@ TEST(lammps_open, with_args)
|
||||
TEST(lammps_open, with_kokkos)
|
||||
{
|
||||
if (!LAMMPS_NS::LAMMPS::is_installed_pkg("KOKKOS")) GTEST_SKIP();
|
||||
const char *args[] = {"liblammps", "-k", "on", "t", "2", "-sf", "kk", "-log", "none", nullptr};
|
||||
char **argv = (char **)args;
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
std::vector<char *> args = {(char *)"lammps", (char *)"-log", (char *)"none", (char *)"-echo",
|
||||
(char *)"screen", (char *)"-sf", (char *)"kk"};
|
||||
|
||||
char *one = (char *)"1";
|
||||
char *four = (char *)"4";
|
||||
char *tee = (char *)"t";
|
||||
char *gee = (char *)"g";
|
||||
char *kay = (char *)"-k";
|
||||
char *yes = (char *)"on";
|
||||
|
||||
args.push_back(kay);
|
||||
args.push_back(yes);
|
||||
|
||||
// when GPU support is enabled in KOKKOS, it *must* be used
|
||||
if (lammps_config_accelerator("KOKKOS", "api", "hip") ||
|
||||
lammps_config_accelerator("KOKKOS", "api", "cuda") ||
|
||||
lammps_config_accelerator("KOKKOS", "api", "sycl")) {
|
||||
args.push_back(gee);
|
||||
args.push_back(one);
|
||||
}
|
||||
|
||||
// use threads or serial
|
||||
args.push_back(tee);
|
||||
if (lammps_config_accelerator("KOKKOS", "api", "openmp")) {
|
||||
args.push_back(four);
|
||||
} else if (lammps_config_accelerator("KOKKOS", "api", "pthreads")) {
|
||||
args.push_back(four);
|
||||
} else {
|
||||
args.push_back(one);
|
||||
}
|
||||
int argc = args.size();
|
||||
char **argv = args.data();
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
void *alt_ptr;
|
||||
@ -225,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);
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "lmptype.h"
|
||||
#include "platform.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
@ -48,6 +49,7 @@ protected:
|
||||
if (verbose) std::cout << output;
|
||||
EXPECT_THAT(output, StartsWith("LAMMPS ("));
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
@ -465,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)
|
||||
@ -546,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);
|
||||
@ -657,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
|
||||
{
|
||||
@ -676,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;
|
||||
}
|
||||
@ -703,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);
|
||||
@ -720,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);
|
||||
@ -729,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);
|
||||
@ -739,17 +826,83 @@ 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();
|
||||
if (!lammps_config_accelerator("KOKKOS", "api", "openmp")) GTEST_SKIP();
|
||||
std::vector<char *> args = {(char *)"lammps", (char *)"-log", (char *)"none",
|
||||
(char *)"-echo", (char *)"screen", (char *)"-nocite",
|
||||
(char *)"-sf", (char *)"kk"};
|
||||
|
||||
// clang-format off
|
||||
const char *args[] = {"SystemSettings", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-k", "on", "t", "4", "-sf", "kk", nullptr};
|
||||
// clang-format on
|
||||
char **argv = (char **)args;
|
||||
int argc = (sizeof(args) / sizeof(char *)) - 1;
|
||||
char *one = (char *)"1";
|
||||
char *four = (char *)"4";
|
||||
char *tee = (char *)"t";
|
||||
char *gee = (char *)"g";
|
||||
char *kay = (char *)"-k";
|
||||
char *yes = (char *)"on";
|
||||
|
||||
args.push_back(kay);
|
||||
args.push_back(yes);
|
||||
|
||||
bool has_gpu = false;
|
||||
bool has_threads = false;
|
||||
|
||||
// when GPU support is enabled in KOKKOS, it *must* be used
|
||||
if (lammps_config_accelerator("KOKKOS", "api", "hip") ||
|
||||
lammps_config_accelerator("KOKKOS", "api", "cuda") ||
|
||||
lammps_config_accelerator("KOKKOS", "api", "sycl")) {
|
||||
has_gpu = true;
|
||||
args.push_back(gee);
|
||||
args.push_back(one);
|
||||
}
|
||||
|
||||
// use threads or serial
|
||||
args.push_back(tee);
|
||||
if (lammps_config_accelerator("KOKKOS", "api", "openmp")) {
|
||||
has_threads = true;
|
||||
args.push_back(four);
|
||||
} else if (lammps_config_accelerator("KOKKOS", "api", "pthreads")) {
|
||||
has_threads = true;
|
||||
args.push_back(four);
|
||||
} else {
|
||||
args.push_back(one);
|
||||
}
|
||||
int argc = args.size();
|
||||
char **argv = args.data();
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
void *lmp = lammps_open_no_mpi(argc, argv, nullptr);
|
||||
@ -758,7 +911,13 @@ TEST(SystemSettings, kokkos)
|
||||
EXPECT_THAT(output, StartsWith("LAMMPS ("));
|
||||
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "kokkos_active"), 1);
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "kokkos_nthreads"), 4);
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "kokkos_ngpus"), 0);
|
||||
if (has_threads)
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "kokkos_nthreads"), 4);
|
||||
else
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "kokkos_nthreads"), 1);
|
||||
if (has_gpu)
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "kokkos_ngpus"), 1);
|
||||
else
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "kokkos_ngpus"), 0);
|
||||
lammps_close(lmp);
|
||||
}
|
||||
|
||||
@ -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)
|
||||
@ -314,7 +315,7 @@ TEST_F(GroupTest, Dynamic)
|
||||
command("group ramp variable grow"););
|
||||
}
|
||||
|
||||
constexpr double EPSILON = 1.0e-13;
|
||||
static constexpr double EPSILON = 1.0e-13;
|
||||
|
||||
TEST_F(GroupTest, VariableFunctions)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -206,7 +206,7 @@ TEST_F(VariableTest, CreateDelete)
|
||||
TEST_FAILURE(".*ERROR: Invalid variable loop argument: -1.*",
|
||||
command("variable dummy loop -1"););
|
||||
TEST_FAILURE(".*ERROR: Illegal variable loop command.*", command("variable dummy loop 10 1"););
|
||||
TEST_FAILURE(".*ERROR: Unknown variable keyword: xxx.*", command("variable dummy xxxx"););
|
||||
TEST_FAILURE(".*ERROR: Unknown variable style: xxx.*", command("variable dummy xxxx"););
|
||||
TEST_FAILURE(".*ERROR: Cannot redefine variable as a different style.*",
|
||||
command("variable two string xxx"););
|
||||
TEST_FAILURE(".*ERROR: Cannot redefine variable as a different style.*",
|
||||
@ -287,6 +287,7 @@ TEST_F(VariableTest, AtomicSystem)
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("f_press[1]"), 0.0);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("c_press"), 0.0);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("c_press[2]"), 0.0);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("c_press[1+1]"), 0.0);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("1.5+3.25"), 4.75);
|
||||
ASSERT_DOUBLE_EQ(variable->compute_equal("-2.5*1.5"), -3.75);
|
||||
|
||||
@ -302,8 +303,18 @@ TEST_F(VariableTest, AtomicSystem)
|
||||
variable->compute_equal("v_self"););
|
||||
TEST_FAILURE(".*ERROR: Variable sum2: Inconsistent lengths in vector-style variable.*",
|
||||
variable->compute_equal("max(v_sum2)"););
|
||||
TEST_FAILURE("ERROR: Mismatched fix in variable formula.*",
|
||||
TEST_FAILURE(".*ERROR: Mismatched fix in variable formula.*",
|
||||
variable->compute_equal("f_press"););
|
||||
TEST_FAILURE(".*ERROR .*Variable formula compute vector is accessed out-of-range.*",
|
||||
variable->compute_equal("c_press[10]"););
|
||||
TEST_FAILURE(".*ERROR: Non digit character between brackets in variable.*",
|
||||
variable->compute_equal("c_press[axy]"););
|
||||
TEST_FAILURE(".*ERROR: Illegal value in brackets: stoll.*",
|
||||
variable->compute_equal("c_press[73786976294838206464]"););
|
||||
TEST_FAILURE(".*ERROR: Index between variable brackets must be positive.*",
|
||||
variable->compute_equal("c_press[-2]"););
|
||||
TEST_FAILURE(".*ERROR: Index between variable brackets must be positive.*",
|
||||
variable->compute_equal("c_press[0]"););
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, Expressions)
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
add_executable(test_lammps_class test_lammps_class.cpp)
|
||||
target_link_libraries(test_lammps_class PRIVATE lammps GTest::GMockMain)
|
||||
add_test(NAME LammpsClass COMMAND test_lammps_class)
|
||||
set_tests_properties(LammpsClass PROPERTIES ENVIRONMENT "OMP_NUM_THREADS=1")
|
||||
set_tests_properties(LammpsClass PROPERTIES ENVIRONMENT "OMP_NUM_THREADS=2;OMP_PROC_BIND=false")
|
||||
|
||||
add_executable(test_input_class test_input_class.cpp)
|
||||
target_link_libraries(test_input_class PRIVATE lammps GTest::GTestMain)
|
||||
|
||||
@ -253,6 +253,15 @@ protected:
|
||||
{
|
||||
LAMMPS::argv args = {"LAMMPS_test", "-log", "none", "-echo", "none", "-screen", "none",
|
||||
"-k", "on", "t", "1", "-sf", "kk"};
|
||||
|
||||
// when GPU support is enabled in KOKKOS, it *must* be used
|
||||
if (Info::has_accelerator_feature("KOKKOS", "api", "hip") ||
|
||||
Info::has_accelerator_feature("KOKKOS", "api", "cuda") ||
|
||||
Info::has_accelerator_feature("KOKKOS", "api", "sycl")) {
|
||||
args = {"LAMMPS_test", "-log", "none", "-echo", "none", "-screen", "none", "-k",
|
||||
"on", "t", "1", "g", "1", "-sf", "kk"};
|
||||
}
|
||||
|
||||
if (Info::has_accelerator_feature("KOKKOS", "api", "openmp")) args[10] = "2";
|
||||
|
||||
if (LAMMPS::is_installed_pkg("KOKKOS")) {
|
||||
|
||||
@ -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")
|
||||
@ -204,11 +204,7 @@ foreach(TEST ${FIX_TIMESTEP_TESTS})
|
||||
continue()
|
||||
endif()
|
||||
add_test(NAME ${TNAME} COMMAND test_fix_timestep ${TEST})
|
||||
if(WIN32)
|
||||
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};PYTHONPATH=${TEST_INPUT_FOLDER}\\\;${LAMMPS_PYTHON_DIR}")
|
||||
else()
|
||||
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};PYTHONPATH=${TEST_INPUT_FOLDER}:${LAMMPS_PYTHON_DIR}:$ENV{PYTHONPATH};PYTHONDONTWRITEBYTECODE=1")
|
||||
endif()
|
||||
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "${FORCE_TEST_ENVIRONMENT}")
|
||||
set_tests_properties(${TNAME} PROPERTIES LABELS "${TEST_TAGS}")
|
||||
endforeach()
|
||||
|
||||
@ -225,7 +221,7 @@ foreach(TEST ${DIHEDRAL_TESTS})
|
||||
continue()
|
||||
endif()
|
||||
add_test(NAME ${TNAME} COMMAND test_dihedral_style ${TEST})
|
||||
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};PYTHONPATH=${TEST_INPUT_FOLDER}:$ENV{PYTHONPATH};PYTHONDONTWRITEBYTECODE=1")
|
||||
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "${FORCE_TEST_ENVIRONMENT}")
|
||||
set_tests_properties(${TNAME} PROPERTIES LABELS "${TEST_TAGS}")
|
||||
endforeach()
|
||||
|
||||
@ -242,7 +238,7 @@ foreach(TEST ${IMPROPER_TESTS})
|
||||
continue()
|
||||
endif()
|
||||
add_test(NAME ${TNAME} COMMAND test_improper_style ${TEST})
|
||||
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};PYTHONPATH=${TEST_INPUT_FOLDER}:$ENV{PYTHONPATH};PYTHONDONTWRITEBYTECODE=1")
|
||||
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "${FORCE_TEST_ENVIRONMENT}")
|
||||
set_tests_properties(${TNAME} PROPERTIES LABELS "${TEST_TAGS}")
|
||||
endforeach()
|
||||
|
||||
@ -250,7 +246,7 @@ if(MLIAP_ENABLE_PYTHON AND (NOT WIN32))
|
||||
add_executable(test_mliappy_unified test_mliappy_unified.cpp)
|
||||
target_link_libraries(test_mliappy_unified PRIVATE lammps GTest::GMockMain)
|
||||
add_test(NAME TestMliapPyUnified COMMAND test_mliappy_unified)
|
||||
set_tests_properties(TestMliapPyUnified PROPERTIES ENVIRONMENT "PYTHONPATH=${LAMMPS_PYTHON_DIR};PYTHONDONTWRITEBYTECODE=1")
|
||||
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "${FORCE_TEST_ENVIRONMENT}")
|
||||
endif()
|
||||
|
||||
add_executable(test_pair_list test_pair_list.cpp)
|
||||
|
||||
@ -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.
|
||||
@ -530,6 +532,126 @@ TEST(AngleStyle, omp)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
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();
|
||||
|
||||
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);
|
||||
|
||||
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";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// relax error a bit for KOKKOS package
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
|
||||
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();
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
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 (!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);
|
||||
|
||||
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();
|
||||
@ -645,8 +767,13 @@ TEST(AngleStyle, single)
|
||||
"extra/angle/per/atom 2 extra/special/per/atom 2",
|
||||
nangletypes));
|
||||
|
||||
command("pair_style zero 8.0");
|
||||
command("pair_coeff * *");
|
||||
if (utils::strmatch(test_config.angle_style, "^spica")) {
|
||||
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("angle_style " + test_config.angle_style);
|
||||
Angle *angle = lmp->force->angle;
|
||||
|
||||
@ -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.
|
||||
@ -532,6 +534,112 @@ TEST(BondStyle, omp)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(BondStyle, 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();
|
||||
|
||||
LAMMPS::argv args = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-k", "on", "t", "4", "-sf", "kk"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
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";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// relax error a bit for KOKKOS package
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
|
||||
ErrorStats stats;
|
||||
auto bond = lmp->force->bond;
|
||||
|
||||
EXPECT_FORCES("init_forces (newton on)", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("init_stress (newton on)", bond->virial, test_config.init_stress, 10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats) std::cerr << "init_energy stats, newton on: " << stats << std::endl;
|
||||
|
||||
if (!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)", bond->virial, test_config.run_stress, 10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
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")
|
||||
// EXPECT_FP_LE_WITH_EPS(bond->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) {
|
||||
bond = lmp->force->bond;
|
||||
|
||||
EXPECT_FORCES("init_forces (newton off)", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("init_stress (newton off)", bond->virial, test_config.init_stress,
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats) std::cerr << "init_energy stats, newton off:" << stats << std::endl;
|
||||
|
||||
if (!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)", bond->virial, test_config.run_stress,
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
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")
|
||||
// EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon);
|
||||
|
||||
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
}
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(BondStyle, numdiff)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("EXTRA-FIX")) GTEST_SKIP();
|
||||
|
||||
@ -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.
|
||||
@ -534,6 +536,112 @@ TEST(DihedralStyle, omp)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(DihedralStyle, 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();
|
||||
|
||||
LAMMPS::argv args = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-k", "on", "t", "4", "-sf", "kk"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
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";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// relax error a bit for KOKKOS package
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
|
||||
ErrorStats stats;
|
||||
auto dihedral = lmp->force->dihedral;
|
||||
|
||||
EXPECT_FORCES("init_forces (newton on)", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("init_stress (newton on)", dihedral->virial, test_config.init_stress,
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(dihedral->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)", dihedral->virial, test_config.run_stress, 10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
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
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
//if (test_config.dihedral_style.substr(0, 6) != "hybrid")
|
||||
// EXPECT_FP_LE_WITH_EPS(dihedral->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) {
|
||||
dihedral = lmp->force->dihedral;
|
||||
|
||||
EXPECT_FORCES("init_forces (newton off)", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("init_stress (newton off)", dihedral->virial, test_config.init_stress,
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats) std::cerr << "init_energy stats, newton off:" << 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)", dihedral->virial, test_config.run_stress,
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
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
|
||||
// needs to be fixed in the main code somewhere. Not sure where, though.
|
||||
//if (test_config.dihedral_style.substr(0, 6) != "hybrid")
|
||||
// EXPECT_FP_LE_WITH_EPS(dihedral->energy, energy, epsilon);
|
||||
|
||||
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
}
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(DihedralStyle, numdiff)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("EXTRA-FIX")) GTEST_SKIP();
|
||||
|
||||
@ -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.
|
||||
@ -527,6 +529,109 @@ TEST(ImproperStyle, omp)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
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"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(args, test_config, true);
|
||||
|
||||
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";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// relax error a bit for KOKKOS package
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
|
||||
ErrorStats stats;
|
||||
auto improper = lmp->force->improper;
|
||||
|
||||
EXPECT_FORCES("init_forces (newton on)", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("init_stress (newton on)", improper->virial, test_config.init_stress,
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(improper->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)", improper->virial, test_config.run_stress, 10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
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")
|
||||
// EXPECT_FP_LE_WITH_EPS(improper->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) {
|
||||
improper = lmp->force->improper;
|
||||
|
||||
EXPECT_FORCES("init_forces (newton off)", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("init_stress (newton off)", improper->virial, test_config.init_stress,
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon);
|
||||
if (print_stats) std::cerr << "init_energy stats, newton off:" << 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)", improper->virial, test_config.run_stress,
|
||||
10 * epsilon);
|
||||
|
||||
stats.reset();
|
||||
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")
|
||||
// EXPECT_FP_LE_WITH_EPS(improper->energy, energy, epsilon);
|
||||
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
}
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
TEST(ImproperStyle, numdiff)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("EXTRA-FIX")) GTEST_SKIP();
|
||||
|
||||
91
unittest/force-styles/tests/angle-spica.yaml
Normal file
91
unittest/force-styles/tests/angle-spica.yaml
Normal file
@ -0,0 +1,91 @@
|
||||
---
|
||||
lammps_version: 7 Feb 2024
|
||||
tags:
|
||||
date_generated: Wed Jun 5 18:31:11 2024
|
||||
epsilon: 1e-12
|
||||
skip_tests:
|
||||
prerequisites: ! |
|
||||
atom full
|
||||
angle spica
|
||||
pair lj/spica
|
||||
pre_commands: ! |
|
||||
variable write_data_pair index ij
|
||||
post_commands: ! |
|
||||
pair_style lj/spica 8.0
|
||||
input_file: in.spica
|
||||
angle_style: spica
|
||||
angle_coeff: ! |
|
||||
1 33.5 110.1
|
||||
2 46.1 111.3
|
||||
3 40.0 120.0
|
||||
4 33.0 108.5
|
||||
equilibrium: 4 1.9216075064457565 1.9425514574696887 2.0943951023931953 1.8936822384138474
|
||||
extract: ! ""
|
||||
natoms: 29
|
||||
init_energy: 38.36438529349082
|
||||
init_stress: ! |2-
|
||||
6.2288484633192937e+01 -2.4958587357033732e+01 1.5261156310077459e+02 2.7527094178009044e+01 4.2708401447133369e+01 -2.5265950282815652e+01
|
||||
init_forces: ! |2
|
||||
1 1.7230431704651284e+01 4.0071311825737794e+01 2.5153895595391262e+01
|
||||
2 1.4681450443715043e+01 9.4049099264163125e+00 -2.0102364558934152e+01
|
||||
3 -1.9308548347980725e+01 -2.8460741684874360e+01 6.4339170989100403e+00
|
||||
4 -5.2290857572683347e+00 -9.4927850504411957e+00 1.8003472602849664e+00
|
||||
5 -1.6382493884699279e+01 -1.4784175400797803e+01 -6.1931262199840624e+00
|
||||
6 -5.4493064751680564e+01 7.5613258287794565e+01 6.9941734306087866e+01
|
||||
7 -4.7395486031142198e+01 3.7640428970968820e+00 -2.4566126298992822e+02
|
||||
8 4.8960191044380039e+01 -4.5712855041323763e+01 1.9415466008820243e+02
|
||||
9 -8.3924213860655783e+00 2.4590103192063562e+01 3.2878160380265854e+01
|
||||
10 6.8038129570966305e+01 -4.6569300903873433e+01 -7.6671701712056688e+01
|
||||
11 -2.1258622382772373e+01 -7.4008599257925383e+00 8.3610564111488799e+00
|
||||
12 5.9901920466154710e+00 -3.0542621446562030e+00 -7.5713636171526382e+00
|
||||
13 1.4189850824692691e+00 1.0835451791895949e+00 4.9993493214959894e-01
|
||||
14 1.1355220599075533e+01 2.4997321466757656e+00 -5.2256561116849181e+00
|
||||
15 1.3933035015335755e+00 -2.0786326583247088e+00 8.7283364302611144e+00
|
||||
16 4.5875574605935235e+01 -2.7754880718666161e+01 -1.0582764215323260e+02
|
||||
17 -4.2451226361036497e+01 2.8306085448648393e+01 1.1928362036932688e+02
|
||||
18 5.2926497658556788e-02 7.0441277800577096e-01 -2.9584690206819020e+00
|
||||
19 -8.6276212064612834e-01 -1.0756990560638664e+00 1.2826229074637665e+00
|
||||
20 7.9148971075772434e-01 3.3735689913016514e-01 1.7102043999486722e+00
|
||||
21 -5.9956840446092086e+00 -6.6440354071373493e+00 1.8013592125677949e+01
|
||||
22 -1.4065918957775763e+01 -4.6031498182035513e+00 -1.5782854315475038e+01
|
||||
23 2.0049558879496164e+01 1.1260925334020174e+01 -2.2177902350101499e+00
|
||||
24 3.2508269160599186e+00 -1.9979416528015960e+01 1.0409971951734974e+01
|
||||
25 -1.6060493526274090e+01 9.4218054960789366e-01 -1.2854339891002313e+01
|
||||
26 1.2797730884335980e+01 1.9024610945429981e+01 2.4201678955447798e+00
|
||||
27 5.3169168679178105e+00 -2.2776165356368182e+01 9.1726846500285717e+00
|
||||
28 -1.9217628865768805e+01 7.5096140408582208e+00 -1.2798872429928149e+01
|
||||
29 1.3910508062151619e+01 1.5274870243863951e+01 3.6205364526432242e+00
|
||||
run_energy: 38.176417113761396
|
||||
run_stress: ! |2-
|
||||
6.1357382915550481e+01 -2.4715660959892247e+01 1.5186466302604836e+02 2.7218614858138846e+01 4.2112515489269541e+01 -2.5607593286714120e+01
|
||||
run_forces: ! |2
|
||||
1 1.7145760907927180e+01 4.0174672565571342e+01 2.5205552180237635e+01
|
||||
2 1.4615170171901832e+01 9.2708448155131897e+00 -2.0078351161345097e+01
|
||||
3 -1.9027637897644411e+01 -2.8642960432918144e+01 6.2314807077302952e+00
|
||||
4 -5.2736618463889080e+00 -9.3424901289763778e+00 1.9422015848783882e+00
|
||||
5 -1.6468832074580213e+01 -1.4729606520686309e+01 -6.2023333708615995e+00
|
||||
6 -5.3718294227422540e+01 7.4801671388546964e+01 6.8368190594240389e+01
|
||||
7 -4.7118098933035071e+01 3.8739803262288781e+00 -2.4290995583077535e+02
|
||||
8 4.7876325968669121e+01 -4.4923173742504034e+01 1.9297993934786507e+02
|
||||
9 -8.3824572561250399e+00 2.4542635562122975e+01 3.2839238074098198e+01
|
||||
10 6.8198580866574645e+01 -4.6830380612887495e+01 -7.6629764788623447e+01
|
||||
11 -2.1232237676690062e+01 -7.3683045541850962e+00 8.3643364257797792e+00
|
||||
12 5.6908584692226185e+00 -2.9956405260312478e+00 -7.3282063658600993e+00
|
||||
13 1.3684378256951288e+00 9.7105537426706034e-01 5.7801503997630133e-01
|
||||
14 1.1379285236061559e+01 2.6704814459393837e+00 -5.2142720262734468e+00
|
||||
15 1.5246096380310767e+00 -1.9886210527177606e+00 8.4529064022347313e+00
|
||||
16 4.5766629638536287e+01 -2.7729192853260034e+01 -1.0555847936417963e+02
|
||||
17 -4.2311907917867423e+01 2.8269504758036135e+01 1.1894203420097222e+02
|
||||
18 4.5978604531469895e-02 6.0605282956542328e-01 -2.5489959663795330e+00
|
||||
19 -7.4282409641952973e-01 -9.2821937232343465e-01 1.1099668747784261e+00
|
||||
20 6.7850316938866917e-01 2.8824602749664086e-01 1.4733945401265087e+00
|
||||
21 -6.1707359561298754e+00 -6.7761831890615607e+00 1.8428059527969836e+01
|
||||
22 -1.3998960882672469e+01 -4.5334962854737153e+00 -1.5964259983712697e+01
|
||||
23 2.0157648747423554e+01 1.1323428247127397e+01 -2.4508469770619676e+00
|
||||
24 3.5283602170234043e+00 -2.0588385440875950e+01 1.0846305899711011e+01
|
||||
25 -1.6431076320543696e+01 1.1358029038847810e+00 -1.3239288833419160e+01
|
||||
26 1.2890779580326928e+01 1.9439960296533382e+01 2.3687830191265684e+00
|
||||
27 5.4188347979018312e+00 -2.2961492507008920e+01 9.2221110477962096e+00
|
||||
28 -1.9337322641186159e+01 7.5984768842531718e+00 -1.2868573316667142e+01
|
||||
29 1.3928283887490117e+01 1.5371333793823325e+01 3.6408125176375652e+00
|
||||
...
|
||||
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
|
||||
...
|
||||
@ -2,7 +2,7 @@
|
||||
lammps_version: 7 Feb 2024
|
||||
tags: slow
|
||||
date_generated: Wed Feb 28 17:07:42 2024
|
||||
epsilon: 2.5e-12
|
||||
epsilon: 2.5e-11
|
||||
skip_tests:
|
||||
prerequisites: ! |
|
||||
pair meam/ms
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
lammps_version: 7 Feb 2024
|
||||
tags:
|
||||
tags: unstable
|
||||
date_generated: Tue Apr 9 07:44:34 2024
|
||||
epsilon: 7.5e-13
|
||||
skip_tests:
|
||||
|
||||
@ -17,7 +17,10 @@ bond_coeff: ! |
|
||||
4 650.0 1.2 0.2
|
||||
5 450.0 1.0 0.0
|
||||
equilibrium: 5 1.5 1.1 1.3 1.2 1
|
||||
extract: ! ""
|
||||
extract: ! |
|
||||
k 1
|
||||
r0 1
|
||||
r1 1
|
||||
natoms: 29
|
||||
init_energy: -9395.519982389222
|
||||
init_stress: ! |-
|
||||
|
||||
233
unittest/force-styles/tests/data.spica
Normal file
233
unittest/force-styles/tests/data.spica
Normal file
@ -0,0 +1,233 @@
|
||||
LAMMPS data file via write_data, version 5 May 2020, timestep = 0
|
||||
|
||||
29 atoms
|
||||
5 atom types
|
||||
24 bonds
|
||||
5 bond types
|
||||
30 angles
|
||||
4 angle types
|
||||
31 dihedrals
|
||||
5 dihedral types
|
||||
2 impropers
|
||||
2 improper types
|
||||
|
||||
-6.024572 8.975428 xlo xhi
|
||||
-7.692866 7.307134 ylo yhi
|
||||
-8.086924 6.913076 zlo zhi
|
||||
|
||||
Masses
|
||||
|
||||
1 12.0107
|
||||
2 4.00794
|
||||
3 14.0067
|
||||
4 15.9994
|
||||
5 15.9994
|
||||
|
||||
PairIJ Coeffs # lj/spica
|
||||
|
||||
1 1 lj9_6 0.02 2.5
|
||||
1 2 lj9_6 0.01 1.58114
|
||||
1 3 lj9_6 0.02 2.82843
|
||||
1 4 lj9_6 0.0173205 2.78388
|
||||
1 5 lj9_6 0.0173205 2.78388
|
||||
2 2 lj12_4 0.005 1.0
|
||||
2 3 lj12_4 0.01 1.78885
|
||||
2 4 lj12_4 0.005 0.5
|
||||
2 5 lj12_4 0.00866025 1.76068 8
|
||||
3 3 lj12_6 0.02 3.2 8
|
||||
3 4 lj12_6 0.0173205 3.1496 8
|
||||
3 5 lj12_6 0.0173205 3.1496 8
|
||||
4 4 lj9_6 0.015 3.1 8
|
||||
4 5 lj9_6 0.015 3.1 8
|
||||
5 5 lj9_6 0.015 3.1 8
|
||||
|
||||
Bond Coeffs # zero
|
||||
|
||||
1 1.5
|
||||
2 1.1
|
||||
3 1.3
|
||||
4 1.2
|
||||
5 1
|
||||
|
||||
Angle Coeffs # spica
|
||||
|
||||
1 33.5 110.1
|
||||
2 46.1 111.3
|
||||
3 40 120
|
||||
4 33 108.5
|
||||
|
||||
Dihedral Coeffs # zero
|
||||
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
|
||||
Improper Coeffs # zero
|
||||
|
||||
1
|
||||
2
|
||||
|
||||
Atoms # full
|
||||
|
||||
10 2 1 7.0000000000000007e-02 2.0185283555536988e+00 -1.4283966846517357e+00 -9.6733527271133024e-01 0 0 0
|
||||
11 2 2 8.9999999999999997e-02 1.7929780509347666e+00 -1.9871047540768743e+00 -1.8840626643185674e+00 0 0 0
|
||||
12 2 1 -2.7000000000000002e-01 3.0030247876861225e+00 -4.8923319967572748e-01 -1.6188658531537248e+00 0 0 0
|
||||
13 2 2 8.9999999999999997e-02 4.0447273787895934e+00 -9.0131998547446246e-01 -1.6384447268320836e+00 0 0 0
|
||||
14 2 2 8.9999999999999997e-02 2.6033152817257075e+00 -4.0789761505963579e-01 -2.6554413538823063e+00 0 0 0
|
||||
2 1 2 3.1000000000000000e-01 3.0197083955402204e-01 2.9515239068888608e+00 -8.5689735572907566e-01 0 0 0
|
||||
3 1 1 -2.0000000000000000e-02 -6.9435377880558602e-01 1.2440473127136711e+00 -6.2233801468892025e-01 0 0 0
|
||||
4 1 2 8.9999999999999997e-02 -1.5771614164685133e+00 1.4915333140468066e+00 -1.2487126845040522e+00 0 0 0
|
||||
6 1 1 5.1000000000000001e-01 2.9412607937706009e-01 2.2719282656652909e-01 -1.2843094067857870e+00 0 0 0
|
||||
7 1 4 -5.1000000000000001e-01 3.4019871062879609e-01 -9.1277350075786561e-03 -2.4633113224304561e+00 0 0 0
|
||||
19 3 2 4.2359999999999998e-01 1.5349125211132961e+00 2.6315969880333707e+00 -4.2472859440220647e+00 0 0 0
|
||||
15 2 2 8.9999999999999997e-02 2.9756315249791303e+00 5.6334269722969288e-01 -1.2437650754599008e+00 0 0 0
|
||||
18 3 4 -8.4719999999999995e-01 2.1384791188033843e+00 3.0177261773770208e+00 -3.5160827596876225e+00 0 0 0
|
||||
20 3 2 4.2359999999999998e-01 2.7641167828863153e+00 3.6833419064000221e+00 -3.9380850623312638e+00 0 0 0
|
||||
8 2 3 -4.6999999999999997e-01 1.1641187171852805e+00 -4.8375305955385234e-01 -6.7659823767368688e-01 0 0 0
|
||||
9 2 2 3.1000000000000000e-01 1.3777459838125838e+00 -2.5366338669522998e-01 2.6877644730326306e-01 0 0 0
|
||||
16 2 1 5.1000000000000001e-01 2.6517554244980306e+00 -2.3957110424978438e+00 3.2908335999178327e-02 0 0 0
|
||||
17 2 4 -5.1000000000000001e-01 2.2309964792710639e+00 -2.1022918943319384e+00 1.1491948328949437e+00 0 0 0
|
||||
1 1 3 -4.6999999999999997e-01 -2.7993683669226832e-01 2.4726588069312840e+00 -1.7200860244148433e-01 0 0 0
|
||||
5 1 2 8.9999999999999997e-02 -8.9501761359359255e-01 9.3568128743071344e-01 4.0227731871484346e-01 0 0 0
|
||||
21 4 5 -8.4719999999999995e-01 4.9064454390208301e+00 -4.0751205255383196e+00 -3.6215576073601046e+00 0 0 0
|
||||
22 4 2 4.2359999999999998e-01 4.3687453488627543e+00 -4.2054270536772504e+00 -4.4651491269372565e+00 0 0 0
|
||||
23 4 2 4.2359999999999998e-01 5.7374928154769504e+00 -3.5763355905184966e+00 -3.8820297194230728e+00 0 0 0
|
||||
24 5 5 -8.4719999999999995e-01 2.0684115301174013e+00 3.1518221747664397e+00 3.1554242678474576e+00 0 0 0
|
||||
25 5 2 4.2359999999999998e-01 1.2998381073113014e+00 3.2755513587518097e+00 2.5092990173114837e+00 0 0 0
|
||||
26 5 2 4.2359999999999998e-01 2.5807438597688113e+00 4.0120175892854135e+00 3.2133398379059099e+00 0 0 0
|
||||
27 6 5 -8.4719999999999995e-01 -1.9613581876744359e+00 -4.3556300596085160e+00 2.1101467673534788e+00 0 0 0
|
||||
28 6 2 4.2359999999999998e-01 -2.7406520384725965e+00 -4.0207251278130975e+00 1.5828689861678511e+00 0 0 0
|
||||
29 6 2 4.2359999999999998e-01 -1.3108232656499081e+00 -3.5992986322410760e+00 2.2680459788743503e+00 0 0 0
|
||||
|
||||
Velocities
|
||||
|
||||
1 7.7867804888392077e-04 5.8970331623292821e-04 -2.2179517633030531e-04
|
||||
2 2.7129529964126462e-03 4.6286427111164284e-03 3.5805549693846352e-03
|
||||
3 -1.2736791029204805e-03 1.6108674226414498e-03 -3.3618185901550799e-04
|
||||
4 -9.2828595122009308e-04 -1.2537885319521818e-03 -4.1204974953432108e-03
|
||||
5 -1.1800848061603740e-03 7.5424401975844038e-04 6.9023177964912290e-05
|
||||
6 -3.0914004879905335e-04 1.2755385764678133e-03 7.9574303350202582e-04
|
||||
7 -1.1037894966874103e-04 -7.6764845099077425e-04 -7.7217630460203659e-04
|
||||
8 3.9060281273221989e-04 -8.1444231918053418e-04 1.5134641148324972e-04
|
||||
9 1.2475530960659720e-03 -2.6608454451432528e-03 1.1117602907112732e-03
|
||||
10 4.5008983776042893e-04 4.9530197647538077e-04 -2.3336234361093645e-04
|
||||
11 -3.6977669078869707e-04 -1.5289071951960539e-03 -2.9176389881837113e-03
|
||||
12 1.0850834530183159e-03 -6.4965897903201833e-04 -1.2971152622619948e-03
|
||||
13 4.0754559196230639e-03 3.5043502394946119e-03 -7.8324487687854666e-04
|
||||
14 -1.3837220448746613e-04 -4.0656048637594394e-03 -3.9333461173944500e-03
|
||||
15 -4.3301707382721859e-03 -3.1802661664634938e-03 3.2037919043360571e-03
|
||||
16 -9.6715751018414326e-05 -5.0016572678960377e-04 1.4945658875149626e-03
|
||||
17 6.5692180538157174e-04 3.6635779995305095e-04 8.3495414466050911e-04
|
||||
18 -6.0936815808025862e-04 -9.3774557532468582e-04 -3.3558072507805731e-04
|
||||
19 -6.9919768291957119e-04 -3.6060777270430031e-03 4.2833405289822791e-03
|
||||
20 4.7777805013736515e-03 5.1003745845520452e-03 1.8002873923729241e-03
|
||||
21 -9.5568188553430398e-04 1.6594630943762931e-04 -1.8199788009966615e-04
|
||||
22 -3.3137518957653462e-03 -2.8683968287936054e-03 3.6384389958326871e-03
|
||||
23 2.4209481134686401e-04 -4.5457709985051130e-03 2.7663581642115042e-03
|
||||
24 2.5447450568861086e-04 4.8412447786110117e-04 -4.8021914527341357e-04
|
||||
25 4.3722771097312743e-03 -4.5184411669545515e-03 2.5200952006556795e-03
|
||||
26 -1.9250110555001179e-03 -3.0342169883610837e-03 3.5062814567984532e-03
|
||||
27 -2.6510179146429716e-04 3.6306203629019116e-04 -5.6235585400647747e-04
|
||||
28 -2.3068708109787484e-04 -8.5663070212203200e-04 2.1302563179109169e-03
|
||||
29 -2.5054744388303732e-03 -1.6773997805290820e-04 2.8436699761004796e-03
|
||||
|
||||
Bonds
|
||||
|
||||
1 5 1 2
|
||||
2 3 1 3
|
||||
3 2 3 4
|
||||
4 2 3 5
|
||||
5 1 3 6
|
||||
6 3 6 8
|
||||
7 4 6 7
|
||||
8 5 8 9
|
||||
9 3 8 10
|
||||
10 2 10 11
|
||||
11 1 10 12
|
||||
12 1 10 16
|
||||
13 2 12 13
|
||||
14 2 12 14
|
||||
15 2 12 15
|
||||
16 4 16 17
|
||||
17 5 18 19
|
||||
18 5 18 20
|
||||
19 5 21 22
|
||||
20 5 21 23
|
||||
21 5 24 25
|
||||
22 5 24 26
|
||||
23 5 27 28
|
||||
24 5 27 29
|
||||
|
||||
Angles
|
||||
|
||||
1 4 2 1 3
|
||||
2 4 1 3 5
|
||||
3 4 1 3 4
|
||||
4 4 1 3 6
|
||||
5 4 4 3 5
|
||||
6 2 5 3 6
|
||||
7 2 4 3 6
|
||||
8 3 3 6 7
|
||||
9 3 3 6 8
|
||||
10 3 7 6 8
|
||||
11 2 6 8 9
|
||||
12 2 9 8 10
|
||||
13 3 6 8 10
|
||||
14 2 8 10 11
|
||||
15 3 8 10 16
|
||||
16 2 11 10 12
|
||||
17 1 12 10 16
|
||||
18 1 8 10 12
|
||||
19 2 11 10 16
|
||||
20 2 10 12 15
|
||||
21 2 10 12 14
|
||||
22 2 10 12 13
|
||||
23 4 13 12 15
|
||||
24 4 13 12 14
|
||||
25 4 14 12 15
|
||||
26 4 10 16 17
|
||||
27 1 19 18 20
|
||||
28 1 22 21 23
|
||||
29 1 25 24 26
|
||||
30 1 28 27 29
|
||||
|
||||
Dihedrals
|
||||
|
||||
1 2 2 1 3 6
|
||||
2 2 2 1 3 4
|
||||
3 3 2 1 3 5
|
||||
4 1 1 3 6 8
|
||||
5 1 1 3 6 7
|
||||
6 5 4 3 6 8
|
||||
7 5 4 3 6 7
|
||||
8 5 5 3 6 8
|
||||
9 5 5 3 6 7
|
||||
10 4 3 6 8 9
|
||||
11 3 3 6 8 10
|
||||
12 3 7 6 8 9
|
||||
13 4 7 6 8 10
|
||||
14 2 6 8 10 12
|
||||
15 2 6 8 10 16
|
||||
16 2 6 8 10 11
|
||||
17 2 9 8 10 12
|
||||
18 4 9 8 10 16
|
||||
19 5 9 8 10 11
|
||||
20 5 8 10 12 13
|
||||
21 1 8 10 12 14
|
||||
22 5 8 10 12 15
|
||||
23 4 8 10 16 17
|
||||
24 5 11 10 12 13
|
||||
25 5 11 10 12 14
|
||||
26 5 11 10 12 15
|
||||
27 2 11 10 16 17
|
||||
28 2 12 10 16 17
|
||||
29 5 16 10 12 13
|
||||
30 5 16 10 12 14
|
||||
31 5 16 10 12 15
|
||||
|
||||
Impropers
|
||||
|
||||
1 1 6 3 8 7
|
||||
2 2 8 6 10 9
|
||||
@ -1,8 +1,8 @@
|
||||
---
|
||||
lammps_version: 7 Feb 2024
|
||||
tags:
|
||||
tags:
|
||||
date_generated: Sat Apr 13 11:41:16 2024
|
||||
epsilon: 2.5e-13
|
||||
epsilon: 1.0e-11
|
||||
skip_tests:
|
||||
prerequisites: ! |
|
||||
atom full
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
lammps_version: 17 Feb 2022
|
||||
date_generated: Fri Mar 18 22:18:02 2022
|
||||
epsilon: 2.5e-13
|
||||
skip_tests:
|
||||
skip_tests: kokkos_omp
|
||||
prerequisites: ! |
|
||||
atom full
|
||||
improper class2
|
||||
|
||||
30
unittest/force-styles/tests/in.spica
Normal file
30
unittest/force-styles/tests/in.spica
Normal file
@ -0,0 +1,30 @@
|
||||
variable newton_pair index on
|
||||
variable newton_bond index on
|
||||
variable bond_factor index 0.10
|
||||
variable angle_factor index 0.25
|
||||
variable dihedral_factor index 0.50
|
||||
variable units index real
|
||||
variable input_dir index .
|
||||
variable data_file index ${input_dir}/data.spica
|
||||
variable pair_style index 'lj/spica 8.0'
|
||||
variable bond_style index zero
|
||||
variable angle_style index spica
|
||||
variable dihedral_style index zero
|
||||
variable improper_style index zero
|
||||
variable t_target index 100.0
|
||||
|
||||
atom_style full
|
||||
atom_modify map array
|
||||
neigh_modify delay 2 every 2 check no
|
||||
units ${units}
|
||||
timestep 0.1
|
||||
newton ${newton_pair} ${newton_bond}
|
||||
special_bonds lj/coul ${bond_factor} ${angle_factor} ${dihedral_factor}
|
||||
|
||||
pair_style ${pair_style}
|
||||
bond_style ${bond_style}
|
||||
angle_style ${angle_style}
|
||||
dihedral_style ${dihedral_style}
|
||||
improper_style ${improper_style}
|
||||
|
||||
read_data ${data_file}
|
||||
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
|
||||
...
|
||||
@ -88,7 +88,7 @@ static void create_molecule_files(const std::string &h2o_filename, const std::st
|
||||
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
|
||||
bool verbose = false;
|
||||
|
||||
const double EPSILON = 5.0e-14;
|
||||
static const double EPSILON = 5.0e-14;
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
using ::testing::Eq;
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -32,7 +32,7 @@ using testing::StrEq;
|
||||
|
||||
using utils::split_words;
|
||||
|
||||
const double EPSILON = 5.0e-14;
|
||||
static constexpr double EPSILON = 5.0e-14;
|
||||
|
||||
#define test_name test_info_->name()
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -11,11 +11,14 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fmt/format.h"
|
||||
#include "lmptype.h"
|
||||
#include "tokenizer.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using ::testing::Eq;
|
||||
|
||||
@ -334,46 +337,73 @@ TEST(ValueTokenizer, move_assignment)
|
||||
|
||||
TEST(ValueTokenizer, bad_integer)
|
||||
{
|
||||
ValueTokenizer values("f10 f11 f12");
|
||||
ValueTokenizer values("f10 f11 f12 0xff 109951162777 "
|
||||
"36893488147419103232 36893488147419103232");
|
||||
ASSERT_THROW(values.next_int(), InvalidIntegerException);
|
||||
ASSERT_THROW(values.next_bigint(), InvalidIntegerException);
|
||||
ASSERT_THROW(values.next_tagint(), InvalidIntegerException);
|
||||
ASSERT_THROW(values.next_int(), InvalidIntegerException);
|
||||
ASSERT_THROW(values.next_int(), InvalidIntegerException);
|
||||
ASSERT_THROW(values.next_tagint(), InvalidIntegerException);
|
||||
ASSERT_THROW(values.next_bigint(), InvalidIntegerException);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, bad_double)
|
||||
{
|
||||
ValueTokenizer values("1a.0");
|
||||
ValueTokenizer values("1a.0 --2.0 2.4d3 -1e20000 1.0e-1.0");
|
||||
ASSERT_THROW(values.next_double(), InvalidFloatException);
|
||||
ASSERT_THROW(values.next_double(), InvalidFloatException);
|
||||
ASSERT_THROW(values.next_double(), InvalidFloatException);
|
||||
ASSERT_THROW(values.next_double(), InvalidFloatException);
|
||||
ASSERT_THROW(values.next_double(), InvalidFloatException);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, valid_int)
|
||||
{
|
||||
ValueTokenizer values("10");
|
||||
ValueTokenizer values(fmt::format("10 {} {}", -MAXSMALLINT - 1, MAXSMALLINT));
|
||||
ASSERT_EQ(values.next_int(), 10);
|
||||
ASSERT_EQ(values.next_int(), -MAXSMALLINT - 1);
|
||||
ASSERT_EQ(values.next_int(), MAXSMALLINT);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, valid_tagint)
|
||||
{
|
||||
ValueTokenizer values("42");
|
||||
ValueTokenizer values(
|
||||
fmt::format("42 {} {} {} {}", -MAXSMALLINT - 1, MAXSMALLINT, -MAXTAGINT - 1, MAXTAGINT));
|
||||
ASSERT_EQ(values.next_tagint(), 42);
|
||||
ASSERT_EQ(values.next_tagint(), -MAXSMALLINT - 1);
|
||||
ASSERT_EQ(values.next_tagint(), MAXSMALLINT);
|
||||
ASSERT_EQ(values.next_tagint(), -MAXTAGINT - 1);
|
||||
ASSERT_EQ(values.next_tagint(), MAXTAGINT);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, valid_bigint)
|
||||
{
|
||||
ValueTokenizer values("42");
|
||||
ValueTokenizer values(
|
||||
fmt::format("42 {} {} {} {}", -MAXSMALLINT - 1, MAXSMALLINT, -MAXBIGINT - 1, MAXBIGINT));
|
||||
ASSERT_EQ(values.next_bigint(), 42);
|
||||
ASSERT_EQ(values.next_bigint(), -MAXSMALLINT - 1);
|
||||
ASSERT_EQ(values.next_bigint(), MAXSMALLINT);
|
||||
ASSERT_EQ(values.next_bigint(), -MAXBIGINT - 1);
|
||||
ASSERT_EQ(values.next_bigint(), MAXBIGINT);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, valid_double)
|
||||
{
|
||||
ValueTokenizer values("3.14");
|
||||
ValueTokenizer values("3.14 -0.00002 .1 0xff " + std::to_string(MAXBIGINT));
|
||||
ASSERT_DOUBLE_EQ(values.next_double(), 3.14);
|
||||
ASSERT_DOUBLE_EQ(values.next_double(), -0.00002);
|
||||
ASSERT_DOUBLE_EQ(values.next_double(), 0.1);
|
||||
ASSERT_DOUBLE_EQ(values.next_double(), 255);
|
||||
ASSERT_DOUBLE_EQ(values.next_double(), MAXBIGINT);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, valid_double_with_exponential)
|
||||
{
|
||||
ValueTokenizer values("3.14e22");
|
||||
ValueTokenizer values(fmt::format("3.14e22 {} {}", DBL_MAX, DBL_MIN));
|
||||
ASSERT_DOUBLE_EQ(values.next_double(), 3.14e22);
|
||||
ASSERT_DOUBLE_EQ(values.next_double(), DBL_MAX);
|
||||
ASSERT_DOUBLE_EQ(values.next_double(), DBL_MIN);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, contains)
|
||||
|
||||
Reference in New Issue
Block a user