From b5a809413ee4bb88436929ced91140f57cb1ab96 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 16 Jun 2020 06:19:31 -0400 Subject: [PATCH 01/53] set units for potential file reader tests. allow verbose execution. --- .../formats/test_potential_file_reader.cpp | 69 ++++++++++++------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/unittest/formats/test_potential_file_reader.cpp b/unittest/formats/test_potential_file_reader.cpp index 199a4ad329..2e289a6a1f 100644 --- a/unittest/formats/test_potential_file_reader.cpp +++ b/unittest/formats/test_potential_file_reader.cpp @@ -23,16 +23,21 @@ #include "MANYBODY/pair_tersoff_mod_c.h" #include "MANYBODY/pair_tersoff_zbl.h" #include "MANYBODY/pair_vashishta.h" +#include "input.h" #include "lammps.h" #include "potential_file_reader.h" #include "utils.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include #include using namespace LAMMPS_NS; +// whether to print verbose output (i.e. not capturing LAMMPS screen output). +bool verbose = false; + const int LAMMPS_NS::PairSW::NPARAMS_PER_LINE; const int LAMMPS_NS::PairComb::NPARAMS_PER_LINE; const int LAMMPS_NS::PairComb3::NPARAMS_PER_LINE; @@ -55,24 +60,25 @@ protected: "PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite"}; char **argv = (char **)args; int argc = sizeof(args) / sizeof(char *); - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); } void TearDown() override { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); delete lmp; - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); } }; TEST_F(PotentialFileReaderTest, Si) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "Si.sw", "Stillinger-Weber"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairSW::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairSW::NPARAMS_PER_LINE); @@ -80,9 +86,10 @@ TEST_F(PotentialFileReaderTest, Si) TEST_F(PotentialFileReaderTest, Comb) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "ffield.comb", "COMB"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairComb::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairComb::NPARAMS_PER_LINE); @@ -90,9 +97,10 @@ TEST_F(PotentialFileReaderTest, Comb) TEST_F(PotentialFileReaderTest, Comb3) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "ffield.comb3", "COMB3"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairComb3::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairComb3::NPARAMS_PER_LINE); @@ -100,9 +108,10 @@ TEST_F(PotentialFileReaderTest, Comb3) TEST_F(PotentialFileReaderTest, Tersoff) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "Si.tersoff", "Tersoff"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairTersoff::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairTersoff::NPARAMS_PER_LINE); @@ -110,9 +119,10 @@ TEST_F(PotentialFileReaderTest, Tersoff) TEST_F(PotentialFileReaderTest, TersoffMod) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "Si.tersoff.mod", "Tersoff/Mod"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairTersoffMOD::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairTersoffMOD::NPARAMS_PER_LINE); @@ -120,9 +130,10 @@ TEST_F(PotentialFileReaderTest, TersoffMod) TEST_F(PotentialFileReaderTest, TersoffModC) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "Si.tersoff.modc", "Tersoff/ModC"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairTersoffMODC::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairTersoffMODC::NPARAMS_PER_LINE); @@ -130,9 +141,10 @@ TEST_F(PotentialFileReaderTest, TersoffModC) TEST_F(PotentialFileReaderTest, TersoffZBL) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "SiC.tersoff.zbl", "Tersoff/ZBL"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairTersoffZBL::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairTersoffZBL::NPARAMS_PER_LINE); @@ -140,9 +152,10 @@ TEST_F(PotentialFileReaderTest, TersoffZBL) TEST_F(PotentialFileReaderTest, GW) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "SiC.gw", "GW"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairGW::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairGW::NPARAMS_PER_LINE); @@ -150,9 +163,10 @@ TEST_F(PotentialFileReaderTest, GW) TEST_F(PotentialFileReaderTest, GWZBL) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "SiC.gw.zbl", "GW/ZBL"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairGWZBL::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairGWZBL::NPARAMS_PER_LINE); @@ -160,9 +174,10 @@ TEST_F(PotentialFileReaderTest, GWZBL) TEST_F(PotentialFileReaderTest, Nb3bHarmonic) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "MOH.nb3b.harmonic", "NB3B Harmonic"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairNb3bHarmonic::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairNb3bHarmonic::NPARAMS_PER_LINE); @@ -170,9 +185,10 @@ TEST_F(PotentialFileReaderTest, Nb3bHarmonic) TEST_F(PotentialFileReaderTest, Vashishta) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "SiC.vashishta", "Vashishta"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairVashishta::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairVashishta::NPARAMS_PER_LINE); @@ -182,5 +198,6 @@ int main(int argc, char **argv) { MPI_Init(&argc, &argv); ::testing::InitGoogleMock(&argc, argv); + if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; return RUN_ALL_TESTS(); } From 37a09998265d00ce144f74584c1296ea5dbf7715 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 16 Jun 2020 06:36:26 -0400 Subject: [PATCH 02/53] add units metadata check to legacy potential file reading method --- src/force.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/force.cpp b/src/force.cpp index 840d7e31ca..5824e35648 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -34,6 +34,7 @@ #include "improper.h" #include "kspace.h" #include "error.h" +#include "update.h" #include "utils.h" #include "fmt/format.h" @@ -1013,15 +1014,20 @@ tagint Force::tnumeric(const char *file, int line, char *str) FILE *Force::open_potential(const char *name) { std::string filepath = utils::get_potential_file_path(name); - std::string date; if(!filepath.empty()) { - date = utils::get_potential_date(filepath, "potential"); + std::string unit_style = update->unit_style; + std::string date = utils::get_potential_date(filepath, "potential"); + std::string units = utils::get_potential_units(filepath, "potential"); if(!date.empty()) { utils::logmesg(lmp, fmt::format("Reading potential file {} " "with DATE: {}\n", name, date)); } + if (!units.empty() && (units != unit_style)) { + error->one(FLERR, fmt::format("Potential file {} requires {} units " + "but {} units are in use", name, units, unit_style)); + } return fopen(filepath.c_str(), "r"); } return nullptr; From 436c7615e093afff6ca248ec6f48d694e2fd2925 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 16 Jun 2020 06:37:09 -0400 Subject: [PATCH 03/53] set metal units and add option to do verbose execution to EIM potential tester --- .../test_eim_potential_file_reader.cpp | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/unittest/formats/test_eim_potential_file_reader.cpp b/unittest/formats/test_eim_potential_file_reader.cpp index 0aaa236fea..ff09c74dc6 100644 --- a/unittest/formats/test_eim_potential_file_reader.cpp +++ b/unittest/formats/test_eim_potential_file_reader.cpp @@ -12,15 +12,20 @@ ------------------------------------------------------------------------- */ #include "MANYBODY/pair_eim.h" +#include "input.h" #include "lammps.h" #include "utils.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include #include using namespace LAMMPS_NS; +// whether to print verbose output (i.e. not capturing LAMMPS screen output). +bool verbose = false; + class EIMPotentialFileReaderTest : public ::testing::Test { protected: LAMMPS *lmp; @@ -33,9 +38,10 @@ protected: "PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite"}; char **argv = (char **)args; int argc = sizeof(args) / sizeof(char *); - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); - ::testing::internal::GetCapturedStdout(); + lmp->input->one("units metal"); + if (!verbose) ::testing::internal::GetCapturedStdout(); int npair = nelements * (nelements + 1) / 2; setfl.ielement = new int[nelements]; @@ -85,17 +91,17 @@ protected: delete[] setfl.rs; delete[] setfl.tp; - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); delete lmp; - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); } }; TEST_F(EIMPotentialFileReaderTest, global_line) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); EIMPotentialFileReader reader(lmp, "ffield.eim"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); reader.get_global(&setfl); ASSERT_DOUBLE_EQ(setfl.division, 2.0); @@ -105,9 +111,9 @@ TEST_F(EIMPotentialFileReaderTest, global_line) TEST_F(EIMPotentialFileReaderTest, element_line_sequential) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); EIMPotentialFileReader reader(lmp, "ffield.eim"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); reader.get_element(&setfl, 0, "Li"); ASSERT_EQ(setfl.ielement[0], 3); @@ -130,9 +136,9 @@ TEST_F(EIMPotentialFileReaderTest, element_line_sequential) TEST_F(EIMPotentialFileReaderTest, element_line_random) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); EIMPotentialFileReader reader(lmp, "ffield.eim"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); reader.get_element(&setfl, 0, "Id"); ASSERT_EQ(setfl.ielement[0], 53); @@ -146,9 +152,9 @@ TEST_F(EIMPotentialFileReaderTest, element_line_random) TEST_F(EIMPotentialFileReaderTest, pair_line) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); EIMPotentialFileReader reader(lmp, "ffield.eim"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); reader.get_pair(&setfl, 0, "Li", "Li"); ASSERT_DOUBLE_EQ(setfl.rcutphiA[0], 6.0490e+00); @@ -169,9 +175,9 @@ TEST_F(EIMPotentialFileReaderTest, pair_line) TEST_F(EIMPotentialFileReaderTest, pair_identical) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); EIMPotentialFileReader reader(lmp, "ffield.eim"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); reader.get_pair(&setfl, 0, "Li", "Na"); reader.get_pair(&setfl, 1, "Na", "Li"); @@ -195,5 +201,6 @@ int main(int argc, char **argv) { MPI_Init(&argc, &argv); ::testing::InitGoogleMock(&argc, argv); + if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; return RUN_ALL_TESTS(); } From 093c285475678c82b327836d9444faf7338c5af6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 16 Jun 2020 06:37:35 -0400 Subject: [PATCH 04/53] use GMock initializer instead of GTest --- unittest/force-styles/test_main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unittest/force-styles/test_main.cpp b/unittest/force-styles/test_main.cpp index fc59163a60..6c4973dfe7 100644 --- a/unittest/force-styles/test_main.cpp +++ b/unittest/force-styles/test_main.cpp @@ -14,6 +14,7 @@ #include "test_main.h" #include "test_config.h" #include "test_config_reader.h" +#include "gmock/gmock.h" #include "gtest/gtest.h" #include @@ -63,7 +64,7 @@ std::string INPUT_FOLDER = STRINGIFY(TEST_INPUT_FOLDER); int main(int argc, char **argv) { MPI_Init(&argc, &argv); - ::testing::InitGoogleTest(&argc, argv); + ::testing::InitGoogleMock(&argc, argv); if (argc < 2) { usage(std::cerr, argv[0]); From 73a7fb53ff4503e98a2b8769c7731d426e07f2a0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 16 Jun 2020 12:52:35 -0400 Subject: [PATCH 05/53] add infrastructure and first example for testing standalone LAMMPS input commands --- src/input.h | 1 + unittest/CMakeLists.txt | 3 +- unittest/commands/CMakeLists.txt | 4 + unittest/commands/test_simple_commands.cpp | 132 +++++++++++++++++++++ 4 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 unittest/commands/CMakeLists.txt create mode 100644 unittest/commands/test_simple_commands.cpp diff --git a/src/input.h b/src/input.h index 182c38b89d..a50f769561 100644 --- a/src/input.h +++ b/src/input.h @@ -24,6 +24,7 @@ class Input : protected Pointers { friend class Info; friend class Error; friend class Deprecated; + friend class SimpleCommandsTest_Echo_Test; public: int narg; // # of command args diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 99b5463a81..ab8c771dc8 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -1,10 +1,9 @@ include(GTest) add_subdirectory(force-styles) - add_subdirectory(utils) - add_subdirectory(formats) +add_subdirectory(commands) find_package(ClangFormat 8.0) diff --git a/unittest/commands/CMakeLists.txt b/unittest/commands/CMakeLists.txt new file mode 100644 index 0000000000..472337f1bc --- /dev/null +++ b/unittest/commands/CMakeLists.txt @@ -0,0 +1,4 @@ + +add_executable(test_simple_commands test_simple_commands.cpp) +target_link_libraries(test_simple_commands PRIVATE lammps GTest::GMock GTest::GTest) +add_test(NAME TestSimpleCommands COMMAND test_simple_commands WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/unittest/commands/test_simple_commands.cpp b/unittest/commands/test_simple_commands.cpp new file mode 100644 index 0000000000..196a4506b1 --- /dev/null +++ b/unittest/commands/test_simple_commands.cpp @@ -0,0 +1,132 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "input.h" +#include "lammps.h" +#include "utils.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include +#include +#include +#include +#include + +// whether to print verbose output (i.e. not capturing LAMMPS screen output). +bool verbose = false; + +namespace LAMMPS_NS { +using ::testing::Eq; + +class SimpleCommandsTest : public ::testing::Test { +protected: + LAMMPS *lmp; + + void SetUp() override + { + const char *args[] = {"SimpleCommandsTest", "-log", "none", "-echo", "screen", "-nocite"}; + char **argv = (char **)args; + int argc = sizeof(args) / sizeof(char *); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); + if (!verbose) ::testing::internal::GetCapturedStdout(); + } + + void TearDown() override + { + if (!verbose) ::testing::internal::CaptureStdout(); + delete lmp; + if (!verbose) ::testing::internal::GetCapturedStdout(); + } +}; + +TEST_F(SimpleCommandsTest, Echo) +{ + ASSERT_EQ(lmp->input->echo_screen, 1); + ASSERT_EQ(lmp->input->echo_log, 0); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("echo none"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->input->echo_screen, 0); + ASSERT_EQ(lmp->input->echo_log, 0); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("echo both"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->input->echo_screen, 1); + ASSERT_EQ(lmp->input->echo_log, 1); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("echo screen"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->input->echo_screen, 1); + ASSERT_EQ(lmp->input->echo_log, 0); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("echo log"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->input->echo_screen, 0); + ASSERT_EQ(lmp->input->echo_log, 1); +} + +TEST_F(SimpleCommandsTest, Log) +{ + ASSERT_EQ(lmp->logfile, nullptr); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("log simple_command_test.log"); + lmp->input->one("print 'test1'"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_NE(lmp->logfile, nullptr); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("log none"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->logfile, nullptr); + + std::string text; + std::ifstream in; + in.open("simple_command_test.log"); + in >> text; + in.close(); + ASSERT_THAT(text, Eq("test1")); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("log simple_command_test.log append"); + lmp->input->one("print 'test2'"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_NE(lmp->logfile, nullptr); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("log none"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->logfile, nullptr); + + in.open("simple_command_test.log"); + in >> text; + ASSERT_THAT(text, Eq("test1")); + in >> text; + ASSERT_THAT(text, Eq("test2")); + in.close(); + remove("simple_command_test.log"); +} +} // namespace LAMMPS_NS + +int main(int argc, char **argv) +{ + MPI_Init(&argc, &argv); + ::testing::InitGoogleMock(&argc, argv); + if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; + return RUN_ALL_TESTS(); +} From 47b589bdc62a4de209c5f5188773a3d34c06ba3b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 16 Jun 2020 18:30:04 -0400 Subject: [PATCH 06/53] add [[ noreturn ]] attributes to functions in the Error class that do not return --- src/error.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/error.h b/src/error.h index 23f7f64cf3..40c1559464 100644 --- a/src/error.h +++ b/src/error.h @@ -27,20 +27,20 @@ class Error : protected Pointers { public: Error(class LAMMPS *); - void universe_all(const std::string &, int, const std::string &); - void universe_one(const std::string &, int, const std::string &); + [[ noreturn ]] void universe_all(const std::string &, int, const std::string &); + [[ noreturn ]] void universe_one(const std::string &, int, const std::string &); void universe_warn(const std::string &, int, const std::string &); - void all(const std::string &, int, const std::string &); - void one(const std::string &, int, const std::string &); + [[ noreturn ]] void all(const std::string &, int, const std::string &); + [[ noreturn ]] void one(const std::string &, int, const std::string &); void warning(const std::string &, int, const std::string &, int = 1); void message(const std::string &, int, const std::string &, int = 1); - void done(int = 0); // 1 would be fully backwards compatible + [[ noreturn ]] void done(int = 0); // 1 would be fully backwards compatible #ifdef LAMMPS_EXCEPTIONS std::string get_last_error() const; ErrorType get_last_error_type() const; - void set_last_error(const std::string &msg, ErrorType type = ERROR_NORMAL); + void set_last_error(const std::string &msg, ErrorType type = ERROR_NORMAL); private: std::string last_error_message; From 188378872566a42112ad465d8d64993408cf9ecf Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 16 Jun 2020 20:59:58 -0400 Subject: [PATCH 07/53] update SNAP package inputs and reference logs to give consistent results in serial and parallel --- examples/snap/in.snap.Mo_Chen | 2 +- examples/snap/in.snap.Ta06A | 2 +- examples/snap/in.snap.W.2940 | 2 +- examples/snap/in.snap.WBe.PRB2019 | 2 +- examples/snap/in.snap.hybrid.WSNAP.HePair | 2 +- ...n.g++.1 => log.15Jun20.snap.Mo_Chen.g++.1} | 72 ++++++------ ...n.g++.4 => log.15Jun20.snap.Mo_Chen.g++.4} | 72 ++++++------ ...06A.g++.1 => log.15Jun20.snap.Ta06A.g++.1} | 71 ++++++------ ...06A.g++.4 => log.15Jun20.snap.Ta06A.g++.4} | 71 ++++++------ ...40.g++.1 => log.15Jun20.snap.W.2940.g++.1} | 73 ++++++------ ...40.g++.4 => log.15Jun20.snap.W.2940.g++.4} | 73 ++++++------ ...+.1 => log.15Jun20.snap.WBe.PRB2019.g++.1} | 85 +++++++------- ...+.4 => log.15Jun20.snap.WBe.PRB2019.g++.4} | 95 ++++++++-------- ...og.15Jun20.snap.hybrid.WSNAP.HePair.g++.1} | 86 +++++++-------- ...og.15Jun20.snap.hybrid.WSNAP.HePair.g++.4} | 104 +++++++++--------- 15 files changed, 403 insertions(+), 409 deletions(-) rename examples/snap/{log.27Nov18.snap.Mo_Chen.g++.1 => log.15Jun20.snap.Mo_Chen.g++.1} (50%) rename examples/snap/{log.27Nov18.snap.Mo_Chen.g++.4 => log.15Jun20.snap.Mo_Chen.g++.4} (50%) rename examples/snap/{log.27Nov18.snap.Ta06A.g++.1 => log.15Jun20.snap.Ta06A.g++.1} (58%) rename examples/snap/{log.27Nov18.snap.Ta06A.g++.4 => log.15Jun20.snap.Ta06A.g++.4} (58%) rename examples/snap/{log.27Nov18.snap.W.2940.g++.1 => log.15Jun20.snap.W.2940.g++.1} (57%) rename examples/snap/{log.27Nov18.snap.W.2940.g++.4 => log.15Jun20.snap.W.2940.g++.4} (57%) rename examples/snap/{log.18Sep19.snap.WBeSNAP.g++.1 => log.15Jun20.snap.WBe.PRB2019.g++.1} (54%) rename examples/snap/{log.18Sep19.snap.WBeSNAP.g++.4 => log.15Jun20.snap.WBe.PRB2019.g++.4} (51%) rename examples/snap/{log.27Nov18.snap.hybrid.WSNAP.HePair.g++.1 => log.15Jun20.snap.hybrid.WSNAP.HePair.g++.1} (64%) rename examples/snap/{log.27Nov18.snap.hybrid.WSNAP.HePair.g++.4 => log.15Jun20.snap.hybrid.WSNAP.HePair.g++.4} (59%) diff --git a/examples/snap/in.snap.Mo_Chen b/examples/snap/in.snap.Mo_Chen index bb9fb0900d..b58c510ea9 100644 --- a/examples/snap/in.snap.Mo_Chen +++ b/examples/snap/in.snap.Mo_Chen @@ -39,7 +39,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} diff --git a/examples/snap/in.snap.Ta06A b/examples/snap/in.snap.Ta06A index 0ca5275e97..59618786b9 100644 --- a/examples/snap/in.snap.Ta06A +++ b/examples/snap/in.snap.Ta06A @@ -39,7 +39,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} diff --git a/examples/snap/in.snap.W.2940 b/examples/snap/in.snap.W.2940 index 7e59b5198e..31aa958340 100644 --- a/examples/snap/in.snap.W.2940 +++ b/examples/snap/in.snap.W.2940 @@ -39,7 +39,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} diff --git a/examples/snap/in.snap.WBe.PRB2019 b/examples/snap/in.snap.WBe.PRB2019 index 6b342ea56f..8ef95b9f08 100644 --- a/examples/snap/in.snap.WBe.PRB2019 +++ b/examples/snap/in.snap.WBe.PRB2019 @@ -42,7 +42,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} diff --git a/examples/snap/in.snap.hybrid.WSNAP.HePair b/examples/snap/in.snap.hybrid.WSNAP.HePair index 1092c28119..9ad53d60db 100644 --- a/examples/snap/in.snap.hybrid.WSNAP.HePair +++ b/examples/snap/in.snap.hybrid.WSNAP.HePair @@ -42,7 +42,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} diff --git a/examples/snap/log.27Nov18.snap.Mo_Chen.g++.1 b/examples/snap/log.15Jun20.snap.Mo_Chen.g++.1 similarity index 50% rename from examples/snap/log.27Nov18.snap.Mo_Chen.g++.1 rename to examples/snap/log.15Jun20.snap.Mo_Chen.g++.1 index 0ca8406d10..5ba22dcaee 100644 --- a/examples/snap/log.27Nov18.snap.Mo_Chen.g++.1 +++ b/examples/snap/log.15Jun20.snap.Mo_Chen.g++.1 @@ -1,13 +1,13 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task -# Demonstrate SNAP Ta potential +# Demonstrate SNAP Mo potential # Initialize simulation variable nsteps index 100 variable nrep equal 4 variable a equal 3.160 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,21 +18,21 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.16 Lattice spacing in x,y,z = 3.16 3.16 3.16 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0 0 0) to (12.64 12.64 12.64) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0 0.0 0.0) to (12.64 12.64 12.64) 1 by 1 by 1 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.00029707 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 @@ -40,11 +40,11 @@ mass 1 183.84 include Mo_Chen_PRM2017.snap -# DATE: 2017-09-18 CONTRIBUTOR: Chi Chen CITATION: C. Chen, Z. Deng, R. Tran, H. Tang, I.-H. Chu, S. P. Ong, "Accurate force field for molybdenum by machine learning large materials data" Physical Review Materials 1, 04 3603 (2017) +# DATE: 2017-09-18 UNITS: metal CONTRIBUTOR: Chi Chen CITATION: C. Chen, Z. Deng, R. Tran, H. Tang, I.-H. Chu, S. P. Ong, "Accurate force field for molybdenum by machine learning large materials data" Physical Review Materials 1, 04 3603 (2017) # Generated by Materials Virtual Lab # Definition of SNAP potential. pair_style snap -pair_coeff * * Mo_Chen_PRM2017.snapcoeff Mo Mo_Chen_PRM2017.snapparam Mo +pair_coeff * * Mo_Chen_PRM2017.snapcoeff Mo_Chen_PRM2017.snapparam Mo Reading potential file Mo_Chen_PRM2017.snapcoeff with DATE: 2017-09-18 SNAP Element = Mo, Radius 0.5, Weight 1 Reading potential file Mo_Chen_PRM2017.snapparam with DATE: 2017-09-18 @@ -54,7 +54,7 @@ SNAP keyword twojmax 6 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -65,7 +65,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -81,33 +81,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 3.507 | 3.507 | 3.507 Mbytes +Per MPI rank memory allocation (min/avg/max) = 3.335 | 3.335 | 3.335 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -22.405975 0 -22.3675 2575.7657 - 10 294.77555 -22.405305 0 -22.3675 2756.6894 - 20 279.53011 -22.40335 0 -22.3675 3285.8272 - 30 255.52174 -22.40027 0 -22.3675 4122.8933 - 40 224.7299 -22.396321 0 -22.367499 5204.3499 - 50 189.67529 -22.391825 0 -22.367499 6449.1308 - 60 153.18862 -22.387145 0 -22.367499 7765.911 - 70 118.14998 -22.382652 0 -22.367499 9061.1616 - 80 87.224916 -22.378685 0 -22.367499 10247.68 - 90 62.623892 -22.37553 0 -22.367498 11250.067 - 100 45.9103 -22.373386 0 -22.367498 12011.726 -Loop time of 7.00873 on 1 procs for 100 steps with 128 atoms + 10 294.8148 -22.40531 0 -22.3675 2762.0942 + 20 279.68628 -22.40337 0 -22.3675 3306.7656 + 30 255.84798 -22.400312 0 -22.3675 4168.2979 + 40 225.22346 -22.396384 0 -22.367499 5281.9537 + 50 190.25143 -22.391899 0 -22.367499 6565.6626 + 60 153.66642 -22.387207 0 -22.367499 7927.3186 + 70 118.25575 -22.382665 0 -22.367499 9271.9554 + 80 86.616338 -22.378607 0 -22.367499 10510.959 + 90 60.935787 -22.375314 0 -22.367498 11568.261 + 100 42.815823 -22.37299 0 -22.367498 12385.433 +Loop time of 0.897752 on 1 procs for 100 steps with 128 atoms -Performance: 0.616 ns/day, 38.937 hours/ns, 14.268 timesteps/s -99.7% CPU use with 1 MPI tasks x 1 OpenMP threads +Performance: 4.812 ns/day, 4.988 hours/ns, 111.389 timesteps/s +99.9% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 7.0068 | 7.0068 | 7.0068 | 0.0 | 99.97 +Pair | 0.89711 | 0.89711 | 0.89711 | 0.0 | 99.93 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.00083661 | 0.00083661 | 0.00083661 | 0.0 | 0.01 -Output | 0.00025535 | 0.00025535 | 0.00025535 | 0.0 | 0.00 -Modify | 0.00034285 | 0.00034285 | 0.00034285 | 0.0 | 0.00 -Other | | 0.0005035 | | | 0.01 +Comm | 0.0002501 | 0.0002501 | 0.0002501 | 0.0 | 0.03 +Output | 0.00013161 | 0.00013161 | 0.00013161 | 0.0 | 0.01 +Modify | 0.00010276 | 0.00010276 | 0.00010276 | 0.0 | 0.01 +Other | | 0.0001559 | | | 0.02 Nlocal: 128 ave 128 max 128 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -123,4 +123,4 @@ Ave neighs/atom = 58 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:07 +Total wall time: 0:00:00 diff --git a/examples/snap/log.27Nov18.snap.Mo_Chen.g++.4 b/examples/snap/log.15Jun20.snap.Mo_Chen.g++.4 similarity index 50% rename from examples/snap/log.27Nov18.snap.Mo_Chen.g++.4 rename to examples/snap/log.15Jun20.snap.Mo_Chen.g++.4 index a8c3d6858c..2574882d08 100644 --- a/examples/snap/log.27Nov18.snap.Mo_Chen.g++.4 +++ b/examples/snap/log.15Jun20.snap.Mo_Chen.g++.4 @@ -1,13 +1,13 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task -# Demonstrate SNAP Ta potential +# Demonstrate SNAP Mo potential # Initialize simulation variable nsteps index 100 variable nrep equal 4 variable a equal 3.160 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,21 +18,21 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.16 Lattice spacing in x,y,z = 3.16 3.16 3.16 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0 0 0) to (12.64 12.64 12.64) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0 0.0 0.0) to (12.64 12.64 12.64) 1 by 2 by 2 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000289917 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 @@ -40,11 +40,11 @@ mass 1 183.84 include Mo_Chen_PRM2017.snap -# DATE: 2017-09-18 CONTRIBUTOR: Chi Chen CITATION: C. Chen, Z. Deng, R. Tran, H. Tang, I.-H. Chu, S. P. Ong, "Accurate force field for molybdenum by machine learning large materials data" Physical Review Materials 1, 04 3603 (2017) +# DATE: 2017-09-18 UNITS: metal CONTRIBUTOR: Chi Chen CITATION: C. Chen, Z. Deng, R. Tran, H. Tang, I.-H. Chu, S. P. Ong, "Accurate force field for molybdenum by machine learning large materials data" Physical Review Materials 1, 04 3603 (2017) # Generated by Materials Virtual Lab # Definition of SNAP potential. pair_style snap -pair_coeff * * Mo_Chen_PRM2017.snapcoeff Mo Mo_Chen_PRM2017.snapparam Mo +pair_coeff * * Mo_Chen_PRM2017.snapcoeff Mo_Chen_PRM2017.snapparam Mo Reading potential file Mo_Chen_PRM2017.snapcoeff with DATE: 2017-09-18 SNAP Element = Mo, Radius 0.5, Weight 1 Reading potential file Mo_Chen_PRM2017.snapparam with DATE: 2017-09-18 @@ -54,7 +54,7 @@ SNAP keyword twojmax 6 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -65,7 +65,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -81,33 +81,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 3.486 | 3.486 | 3.486 Mbytes +Per MPI rank memory allocation (min/avg/max) = 3.271 | 3.271 | 3.271 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -22.405975 0 -22.3675 2575.7657 - 10 294.63153 -22.405286 0 -22.3675 2753.4662 - 20 278.98535 -22.40328 0 -22.3675 3272.416 - 30 254.38916 -22.400125 0 -22.3675 4091.8933 - 40 222.91191 -22.396088 0 -22.367499 5148.5505 - 50 187.16984 -22.391504 0 -22.367499 6362.2454 - 60 150.08253 -22.386747 0 -22.367499 7643.2732 - 70 114.60307 -22.382197 0 -22.367499 8900.2448 - 80 83.449257 -22.378201 0 -22.367499 10047.619 - 90 58.862643 -22.375048 0 -22.367498 11012.233 - 100 42.41931 -22.372939 0 -22.367498 11740.641 -Loop time of 2.15419 on 4 procs for 100 steps with 128 atoms + 10 294.8148 -22.40531 0 -22.3675 2762.0942 + 20 279.68628 -22.40337 0 -22.3675 3306.7656 + 30 255.84798 -22.400312 0 -22.3675 4168.2979 + 40 225.22346 -22.396384 0 -22.367499 5281.9537 + 50 190.25143 -22.391899 0 -22.367499 6565.6626 + 60 153.66642 -22.387207 0 -22.367499 7927.3186 + 70 118.25575 -22.382665 0 -22.367499 9271.9554 + 80 86.616338 -22.378607 0 -22.367499 10510.959 + 90 60.935787 -22.375314 0 -22.367498 11568.261 + 100 42.815823 -22.37299 0 -22.367498 12385.433 +Loop time of 0.260783 on 4 procs for 100 steps with 128 atoms -Performance: 2.005 ns/day, 11.968 hours/ns, 46.421 timesteps/s -92.0% CPU use with 4 MPI tasks x 1 OpenMP threads +Performance: 16.566 ns/day, 1.449 hours/ns, 383.461 timesteps/s +97.1% CPU use with 4 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 1.7677 | 1.9028 | 1.9897 | 6.2 | 88.33 +Pair | 0.23045 | 0.23744 | 0.24455 | 1.2 | 91.05 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.15367 | 0.24295 | 0.38029 | 17.6 | 11.28 -Output | 0.00034404 | 0.0012512 | 0.0017219 | 1.6 | 0.06 -Modify | 0.00018859 | 0.00021273 | 0.00023699 | 0.0 | 0.01 -Other | | 0.007011 | | | 0.33 +Comm | 0.014524 | 0.021267 | 0.027713 | 3.7 | 8.15 +Output | 0.00014997 | 0.00040495 | 0.0011623 | 0.0 | 0.16 +Modify | 4.2439e-05 | 4.6909e-05 | 5.0068e-05 | 0.0 | 0.02 +Other | | 0.00162 | | | 0.62 Nlocal: 32 ave 32 max 32 min Histogram: 4 0 0 0 0 0 0 0 0 0 @@ -123,4 +123,4 @@ Ave neighs/atom = 58 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:02 +Total wall time: 0:00:00 diff --git a/examples/snap/log.27Nov18.snap.Ta06A.g++.1 b/examples/snap/log.15Jun20.snap.Ta06A.g++.1 similarity index 58% rename from examples/snap/log.27Nov18.snap.Ta06A.g++.1 rename to examples/snap/log.15Jun20.snap.Ta06A.g++.1 index 76cdc8641a..e85235a055 100644 --- a/examples/snap/log.27Nov18.snap.Ta06A.g++.1 +++ b/examples/snap/log.15Jun20.snap.Ta06A.g++.1 @@ -1,4 +1,4 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task # Demonstrate SNAP Ta potential @@ -7,7 +7,7 @@ LAMMPS (27 Nov 2018) variable nsteps index 100 variable nrep equal 4 variable a equal 3.316 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,28 +18,28 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.316 Lattice spacing in x,y,z = 3.316 3.316 3.316 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0 0 0) to (13.264 13.264 13.264) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0 0.0 0.0) to (13.264 13.264 13.264) 1 by 1 by 1 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000350714 secs + create_atoms CPU = 0.000 seconds mass 1 180.88 # choose potential include Ta06A.snap -# DATE: 2014-09-05 CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) # Definition of SNAP potential Ta_Cand06A # Assumes 1 LAMMPS atom type @@ -56,7 +56,7 @@ pair_style hybrid/overlay zbl 4 4.8 snap pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff 1 1 zbl 73 ${zblz} pair_coeff 1 1 zbl 73 73 -pair_coeff * * snap Ta06A.snapcoeff Ta Ta06A.snapparam Ta +pair_coeff * * snap Ta06A.snapcoeff Ta06A.snapparam Ta Reading potential file Ta06A.snapcoeff with DATE: 2014-09-05 SNAP Element = Ta, Radius 0.5, Weight 1 Reading potential file Ta06A.snapparam with DATE: 2014-09-05 @@ -64,14 +64,13 @@ SNAP keyword rcutfac 4.67637 SNAP keyword twojmax 6 SNAP keyword rfac0 0.99363 SNAP keyword rmin0 0 -SNAP keyword diagonalstyle 3 SNAP keyword bzeroflag 0 SNAP keyword quadraticflag 0 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -82,7 +81,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -103,33 +102,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 4.138 | 4.138 | 4.138 Mbytes +Per MPI rank memory allocation (min/avg/max) = 3.967 | 3.967 | 3.967 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -11.85157 0 -11.813095 2717.1661 - 10 295.96579 -11.851053 0 -11.813095 2696.1559 - 20 284.32535 -11.84956 0 -11.813095 2301.3713 - 30 266.04602 -11.847215 0 -11.813095 1832.1745 - 40 242.2862 -11.844168 0 -11.813095 1492.6765 - 50 214.48968 -11.840603 0 -11.813094 1312.8908 - 60 184.32523 -11.836734 0 -11.813094 1284.582 - 70 153.58055 -11.832791 0 -11.813094 1374.4457 - 80 124.04276 -11.829003 0 -11.813094 1537.703 - 90 97.37622 -11.825582 0 -11.813094 1734.9662 - 100 75.007873 -11.822714 0 -11.813094 1930.8005 -Loop time of 5.03244 on 1 procs for 100 steps with 128 atoms + 10 296.01467 -11.851059 0 -11.813095 2697.4796 + 20 284.53666 -11.849587 0 -11.813095 2289.1527 + 30 266.51577 -11.847275 0 -11.813095 1851.7131 + 40 243.05007 -11.844266 0 -11.813095 1570.684 + 50 215.51032 -11.840734 0 -11.813094 1468.1899 + 60 185.48331 -11.836883 0 -11.813094 1524.8757 + 70 154.6736 -11.832931 0 -11.813094 1698.3351 + 80 124.79303 -11.829099 0 -11.813094 1947.0715 + 90 97.448054 -11.825592 0 -11.813094 2231.9563 + 100 74.035418 -11.822589 0 -11.813094 2515.8526 +Loop time of 0.702618 on 1 procs for 100 steps with 128 atoms -Performance: 0.858 ns/day, 27.958 hours/ns, 19.871 timesteps/s -98.9% CPU use with 1 MPI tasks x 1 OpenMP threads +Performance: 6.148 ns/day, 3.903 hours/ns, 142.325 timesteps/s +99.7% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 5.0308 | 5.0308 | 5.0308 | 0.0 | 99.97 +Pair | 0.70188 | 0.70188 | 0.70188 | 0.0 | 99.90 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.00070858 | 0.00070858 | 0.00070858 | 0.0 | 0.01 -Output | 0.00024676 | 0.00024676 | 0.00024676 | 0.0 | 0.00 -Modify | 0.0002749 | 0.0002749 | 0.0002749 | 0.0 | 0.01 -Other | | 0.0004299 | | | 0.01 +Comm | 0.00025487 | 0.00025487 | 0.00025487 | 0.0 | 0.04 +Output | 0.00015402 | 0.00015402 | 0.00015402 | 0.0 | 0.02 +Modify | 0.00011039 | 0.00011039 | 0.00011039 | 0.0 | 0.02 +Other | | 0.000217 | | | 0.03 Nlocal: 128 ave 128 max 128 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -145,4 +144,4 @@ Ave neighs/atom = 58 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:05 +Total wall time: 0:00:00 diff --git a/examples/snap/log.27Nov18.snap.Ta06A.g++.4 b/examples/snap/log.15Jun20.snap.Ta06A.g++.4 similarity index 58% rename from examples/snap/log.27Nov18.snap.Ta06A.g++.4 rename to examples/snap/log.15Jun20.snap.Ta06A.g++.4 index 4cc5b82c9b..0dc0c3f21b 100644 --- a/examples/snap/log.27Nov18.snap.Ta06A.g++.4 +++ b/examples/snap/log.15Jun20.snap.Ta06A.g++.4 @@ -1,4 +1,4 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task # Demonstrate SNAP Ta potential @@ -7,7 +7,7 @@ LAMMPS (27 Nov 2018) variable nsteps index 100 variable nrep equal 4 variable a equal 3.316 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,28 +18,28 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.316 Lattice spacing in x,y,z = 3.316 3.316 3.316 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0 0 0) to (13.264 13.264 13.264) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0 0.0 0.0) to (13.264 13.264 13.264) 1 by 2 by 2 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000299692 secs + create_atoms CPU = 0.000 seconds mass 1 180.88 # choose potential include Ta06A.snap -# DATE: 2014-09-05 CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) # Definition of SNAP potential Ta_Cand06A # Assumes 1 LAMMPS atom type @@ -56,7 +56,7 @@ pair_style hybrid/overlay zbl 4 4.8 snap pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff 1 1 zbl 73 ${zblz} pair_coeff 1 1 zbl 73 73 -pair_coeff * * snap Ta06A.snapcoeff Ta Ta06A.snapparam Ta +pair_coeff * * snap Ta06A.snapcoeff Ta06A.snapparam Ta Reading potential file Ta06A.snapcoeff with DATE: 2014-09-05 SNAP Element = Ta, Radius 0.5, Weight 1 Reading potential file Ta06A.snapparam with DATE: 2014-09-05 @@ -64,14 +64,13 @@ SNAP keyword rcutfac 4.67637 SNAP keyword twojmax 6 SNAP keyword rfac0 0.99363 SNAP keyword rmin0 0 -SNAP keyword diagonalstyle 3 SNAP keyword bzeroflag 0 SNAP keyword quadraticflag 0 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -82,7 +81,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -103,33 +102,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 4.118 | 4.118 | 4.118 Mbytes +Per MPI rank memory allocation (min/avg/max) = 3.903 | 3.903 | 3.903 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -11.85157 0 -11.813095 2717.1661 - 10 295.8664 -11.85104 0 -11.813095 2702.935 - 20 283.95868 -11.849513 0 -11.813095 2301.3242 - 30 265.29535 -11.847119 0 -11.813095 1870.3173 - 40 241.09337 -11.844015 0 -11.813095 1568.1549 - 50 212.86732 -11.840395 0 -11.813094 1409.2092 - 60 182.35256 -11.836481 0 -11.813094 1389.0527 - 70 151.38968 -11.83251 0 -11.813094 1474.9232 - 80 121.80051 -11.828715 0 -11.813094 1627.6911 - 90 95.262635 -11.825311 0 -11.813094 1812.9327 - 100 73.194645 -11.822481 0 -11.813094 1995.2199 -Loop time of 1.4959 on 4 procs for 100 steps with 128 atoms + 10 296.01467 -11.851059 0 -11.813095 2697.4796 + 20 284.53666 -11.849587 0 -11.813095 2289.1527 + 30 266.51577 -11.847275 0 -11.813095 1851.7131 + 40 243.05007 -11.844266 0 -11.813095 1570.684 + 50 215.51032 -11.840734 0 -11.813094 1468.1899 + 60 185.48331 -11.836883 0 -11.813094 1524.8757 + 70 154.6736 -11.832931 0 -11.813094 1698.3351 + 80 124.79303 -11.829099 0 -11.813094 1947.0715 + 90 97.448054 -11.825592 0 -11.813094 2231.9563 + 100 74.035418 -11.822589 0 -11.813094 2515.8526 +Loop time of 0.230164 on 4 procs for 100 steps with 128 atoms -Performance: 2.888 ns/day, 8.311 hours/ns, 66.850 timesteps/s -94.6% CPU use with 4 MPI tasks x 1 OpenMP threads +Performance: 18.769 ns/day, 1.279 hours/ns, 434.473 timesteps/s +93.5% CPU use with 4 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 1.2973 | 1.3263 | 1.3444 | 1.6 | 88.66 +Pair | 0.1824 | 0.19154 | 0.21822 | 3.5 | 83.22 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.14155 | 0.16475 | 0.19518 | 5.0 | 11.01 -Output | 0.00055361 | 0.0006234 | 0.00078511 | 0.0 | 0.04 -Modify | 0.00016427 | 0.00020635 | 0.00032949 | 0.0 | 0.01 -Other | | 0.004009 | | | 0.27 +Comm | 0.010843 | 0.037176 | 0.046129 | 7.9 | 16.15 +Output | 0.00014973 | 0.00028926 | 0.00070024 | 0.0 | 0.13 +Modify | 5.3883e-05 | 5.6803e-05 | 6.1989e-05 | 0.0 | 0.02 +Other | | 0.001104 | | | 0.48 Nlocal: 32 ave 32 max 32 min Histogram: 4 0 0 0 0 0 0 0 0 0 @@ -145,4 +144,4 @@ Ave neighs/atom = 58 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:01 +Total wall time: 0:00:00 diff --git a/examples/snap/log.27Nov18.snap.W.2940.g++.1 b/examples/snap/log.15Jun20.snap.W.2940.g++.1 similarity index 57% rename from examples/snap/log.27Nov18.snap.W.2940.g++.1 rename to examples/snap/log.15Jun20.snap.W.2940.g++.1 index d2c540c709..599fdf6380 100644 --- a/examples/snap/log.27Nov18.snap.W.2940.g++.1 +++ b/examples/snap/log.15Jun20.snap.W.2940.g++.1 @@ -1,13 +1,13 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task -# Demonstrate SNAP Ta potential +# Demonstrate SNAP W potential # Initialize simulation variable nsteps index 100 variable nrep equal 4 variable a equal 3.1803 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,28 +18,28 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.1803 Lattice spacing in x,y,z = 3.1803 3.1803 3.1803 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0 0 0) to (12.7212 12.7212 12.7212) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0 0.0 0.0) to (12.7212 12.7212 12.7212) 1 by 1 by 1 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000316143 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 # choose potential include W_2940_2017_2.snap -# DATE: 2017-02-20 CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] +# DATE: 2017-02-20 UNITS: metal CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] # # Definition of SNAP+ZBL potential. variable zblcutinner equal 4 @@ -54,7 +54,7 @@ pair_style hybrid/overlay zbl 4 4.8 snap pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff 1 1 zbl 74 ${zblz} pair_coeff 1 1 zbl 74 74 -pair_coeff * * snap W_2940_2017_2.snapcoeff W W_2940_2017_2.snapparam W +pair_coeff * * snap W_2940_2017_2.snapcoeff W_2940_2017_2.snapparam W Reading potential file W_2940_2017_2.snapcoeff with DATE: 2017-02-20 SNAP Element = W, Radius 0.5, Weight 1 Reading potential file W_2940_2017_2.snapparam with DATE: 2017-02-20 @@ -62,7 +62,6 @@ SNAP keyword rcutfac 4.73442 SNAP keyword twojmax 8 SNAP keyword rfac0 0.99363 SNAP keyword rmin0 0 -SNAP keyword diagonalstyle 3 SNAP keyword bzeroflag 0 SNAP keyword quadraticflag 0 @@ -70,7 +69,7 @@ SNAP keyword quadraticflag 0 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -81,7 +80,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -102,33 +101,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 5.15 | 5.15 | 5.15 Mbytes +Per MPI rank memory allocation (min/avg/max) = 4.268 | 4.268 | 4.268 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -11.028325 0 -10.98985 3010.497 - 10 293.40666 -11.027479 0 -10.989849 3246.0559 - 20 274.27375 -11.025025 0 -10.989849 3927.9497 - 30 244.50457 -11.021207 0 -10.989849 4983.5484 - 40 207.0784 -11.016407 0 -10.989849 6299.9473 - 50 165.74442 -11.011105 0 -10.989848 7736.5123 - 60 124.62181 -11.005831 0 -10.989848 9140.8587 - 70 87.744792 -11.001101 0 -10.989848 10366.489 - 80 58.605244 -10.997364 0 -10.989848 11289.914 - 90 39.754503 -10.994946 0 -10.989848 11824.945 - 100 32.524085 -10.994019 0 -10.989848 11932.118 -Loop time of 18.7678 on 1 procs for 100 steps with 128 atoms + 10 293.10848 -11.027441 0 -10.989849 3259.9445 + 20 273.14727 -11.024881 0 -10.989849 3979.8968 + 30 242.20285 -11.020912 0 -10.989849 5089.0797 + 40 203.51992 -11.01595 0 -10.989849 6462.9419 + 50 161.14556 -11.010515 0 -10.989848 7948.1798 + 60 119.47232 -11.00517 0 -10.989848 9380.8543 + 70 82.729175 -11.000458 0 -10.989848 10606.025 + 80 54.483648 -10.996835 0 -10.989848 11496.424 + 90 37.225263 -10.994622 0 -10.989847 11967.579 + 100 32.094224 -10.993964 0 -10.989847 11987.181 +Loop time of 2.29953 on 1 procs for 100 steps with 128 atoms -Performance: 0.230 ns/day, 104.265 hours/ns, 5.328 timesteps/s -99.8% CPU use with 1 MPI tasks x 1 OpenMP threads +Performance: 1.879 ns/day, 12.775 hours/ns, 43.487 timesteps/s +99.7% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 18.766 | 18.766 | 18.766 | 0.0 | 99.99 +Pair | 2.2988 | 2.2988 | 2.2988 | 0.0 | 99.97 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.00081968 | 0.00081968 | 0.00081968 | 0.0 | 0.00 -Output | 0.00028563 | 0.00028563 | 0.00028563 | 0.0 | 0.00 -Modify | 0.0003283 | 0.0003283 | 0.0003283 | 0.0 | 0.00 -Other | | 0.0005233 | | | 0.00 +Comm | 0.00027108 | 0.00027108 | 0.00027108 | 0.0 | 0.01 +Output | 0.00014758 | 0.00014758 | 0.00014758 | 0.0 | 0.01 +Modify | 0.00010991 | 0.00010991 | 0.00010991 | 0.0 | 0.00 +Other | | 0.0001643 | | | 0.01 Nlocal: 128 ave 128 max 128 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -144,4 +143,4 @@ Ave neighs/atom = 58 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:18 +Total wall time: 0:00:02 diff --git a/examples/snap/log.27Nov18.snap.W.2940.g++.4 b/examples/snap/log.15Jun20.snap.W.2940.g++.4 similarity index 57% rename from examples/snap/log.27Nov18.snap.W.2940.g++.4 rename to examples/snap/log.15Jun20.snap.W.2940.g++.4 index cdd063de28..149eea3352 100644 --- a/examples/snap/log.27Nov18.snap.W.2940.g++.4 +++ b/examples/snap/log.15Jun20.snap.W.2940.g++.4 @@ -1,13 +1,13 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task -# Demonstrate SNAP Ta potential +# Demonstrate SNAP W potential # Initialize simulation variable nsteps index 100 variable nrep equal 4 variable a equal 3.1803 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,28 +18,28 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.1803 Lattice spacing in x,y,z = 3.1803 3.1803 3.1803 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0 0 0) to (12.7212 12.7212 12.7212) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0 0.0 0.0) to (12.7212 12.7212 12.7212) 1 by 2 by 2 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000297546 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 # choose potential include W_2940_2017_2.snap -# DATE: 2017-02-20 CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] +# DATE: 2017-02-20 UNITS: metal CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] # # Definition of SNAP+ZBL potential. variable zblcutinner equal 4 @@ -54,7 +54,7 @@ pair_style hybrid/overlay zbl 4 4.8 snap pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff 1 1 zbl 74 ${zblz} pair_coeff 1 1 zbl 74 74 -pair_coeff * * snap W_2940_2017_2.snapcoeff W W_2940_2017_2.snapparam W +pair_coeff * * snap W_2940_2017_2.snapcoeff W_2940_2017_2.snapparam W Reading potential file W_2940_2017_2.snapcoeff with DATE: 2017-02-20 SNAP Element = W, Radius 0.5, Weight 1 Reading potential file W_2940_2017_2.snapparam with DATE: 2017-02-20 @@ -62,7 +62,6 @@ SNAP keyword rcutfac 4.73442 SNAP keyword twojmax 8 SNAP keyword rfac0 0.99363 SNAP keyword rmin0 0 -SNAP keyword diagonalstyle 3 SNAP keyword bzeroflag 0 SNAP keyword quadraticflag 0 @@ -70,7 +69,7 @@ SNAP keyword quadraticflag 0 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -81,7 +80,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -102,33 +101,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 5.13 | 5.13 | 5.13 Mbytes +Per MPI rank memory allocation (min/avg/max) = 4.167 | 4.167 | 4.167 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -11.028325 0 -10.98985 3010.497 - 10 293.22504 -11.027456 0 -10.989849 3258.275 - 20 273.60084 -11.024939 0 -10.989849 3973.9038 - 30 243.15327 -11.021034 0 -10.989849 5077.9172 - 40 205.01905 -11.016142 0 -10.989849 6448.4941 - 50 163.10914 -11.010767 0 -10.989848 7935.6835 - 60 121.67854 -11.005453 0 -10.989848 9378.9959 - 70 84.846972 -11.000729 0 -10.989848 10626.301 - 80 56.127265 -10.997046 0 -10.989848 11551.687 - 90 38.025013 -10.994724 0 -10.989847 12069.936 - 100 31.768127 -10.993922 0 -10.989847 12145.648 -Loop time of 5.38055 on 4 procs for 100 steps with 128 atoms + 10 293.10848 -11.027441 0 -10.989849 3259.9445 + 20 273.14727 -11.024881 0 -10.989849 3979.8968 + 30 242.20285 -11.020912 0 -10.989849 5089.0797 + 40 203.51992 -11.01595 0 -10.989849 6462.9419 + 50 161.14556 -11.010515 0 -10.989848 7948.1798 + 60 119.47232 -11.00517 0 -10.989848 9380.8543 + 70 82.729175 -11.000458 0 -10.989848 10606.025 + 80 54.483648 -10.996835 0 -10.989848 11496.424 + 90 37.225263 -10.994622 0 -10.989847 11967.579 + 100 32.094224 -10.993964 0 -10.989847 11987.181 +Loop time of 0.700403 on 4 procs for 100 steps with 128 atoms -Performance: 0.803 ns/day, 29.892 hours/ns, 18.585 timesteps/s -96.1% CPU use with 4 MPI tasks x 1 OpenMP threads +Performance: 6.168 ns/day, 3.891 hours/ns, 142.775 timesteps/s +95.9% CPU use with 4 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 4.8254 | 5.0245 | 5.2817 | 7.7 | 93.38 +Pair | 0.59296 | 0.62019 | 0.6504 | 2.8 | 88.55 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.093845 | 0.34915 | 0.5466 | 29.1 | 6.49 -Output | 0.00032616 | 0.0011846 | 0.0037167 | 4.2 | 0.02 -Modify | 0.00022507 | 0.00025326 | 0.0002687 | 0.0 | 0.00 -Other | | 0.005432 | | | 0.10 +Comm | 0.048731 | 0.078938 | 0.10647 | 7.8 | 11.27 +Output | 0.00015879 | 0.00024194 | 0.00048518 | 0.0 | 0.03 +Modify | 6.4373e-05 | 6.9439e-05 | 7.7963e-05 | 0.0 | 0.01 +Other | | 0.0009654 | | | 0.14 Nlocal: 32 ave 32 max 32 min Histogram: 4 0 0 0 0 0 0 0 0 0 @@ -144,4 +143,4 @@ Ave neighs/atom = 58 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:05 +Total wall time: 0:00:00 diff --git a/examples/snap/log.18Sep19.snap.WBeSNAP.g++.1 b/examples/snap/log.15Jun20.snap.WBe.PRB2019.g++.1 similarity index 54% rename from examples/snap/log.18Sep19.snap.WBeSNAP.g++.1 rename to examples/snap/log.15Jun20.snap.WBe.PRB2019.g++.1 index 2b889e036b..71320a642c 100644 --- a/examples/snap/log.18Sep19.snap.WBeSNAP.g++.1 +++ b/examples/snap/log.15Jun20.snap.WBe.PRB2019.g++.1 @@ -1,4 +1,5 @@ -LAMMPS (7 Aug 2019) +LAMMPS (15 Jun 2020) + using 1 OpenMP thread(s) per MPI task # Demonstrate SNAP W-Be potential # Initialize simulation @@ -6,7 +7,7 @@ LAMMPS (7 Aug 2019) variable nsteps index 100 variable nrep equal 4 variable a equal 3.1803 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -17,33 +18,33 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.1803 Lattice spacing in x,y,z = 3.1803 3.1803 3.1803 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 2 box -Created orthogonal box = (0 0 0) to (12.7212 12.7212 12.7212) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 2 box +Created orthogonal box = (0.0 0.0 0.0) to (12.7212 12.7212 12.7212) 1 by 1 by 1 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - create_atoms CPU = 0.000234842 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 mass 2 9.012182 -set group all type/fraction 2 0.05 3590153 # Change 5% of W to He - 5 settings made for type/fraction -group tungsten type 1 +set group all type/fraction 2 0.05 3590153 # Change 5% of W to He + 5 settings made for type/fractiongroup tungsten type 1 123 atoms in group tungsten -group beryllium type 2 +group beryllium type 2 5 atoms in group beryllium # choose potential include WBe_Wood_PRB2019.snap +# DATE: 2019-09-18 UNITS: metal CONTRIBUTOR: Mary Alice Cusentino mcusent@sandia.gov CITATION: M.A. Wood, M.A. Cusentino, B.D. Wirth, and A.P. Thompson, "Data-driven material models for atomistic simulation", Physical Review B 99, 184305 (2019) # Definition of SNAP+ZBL potential. variable zblcutinner equal 4 variable zblcutouter equal 4.8 @@ -77,7 +78,7 @@ SNAP keyword quadraticflag 0 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -88,7 +89,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -112,43 +113,43 @@ Neighbor list info ... Per MPI rank memory allocation (min/avg/max) = 4.268 | 4.268 | 4.268 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -8.5980876 0 -8.5596125 -35284.855 - 10 299.29029 -8.5979965 0 -8.5596125 -35299.259 - 20 288.99334 -8.5966759 0 -8.5596124 -35004.093 - 30 269.91027 -8.5942284 0 -8.5596123 -34447.077 - 40 243.57361 -8.5908505 0 -8.5596121 -33687.105 - 50 212.21385 -8.5868284 0 -8.5596119 -32821.864 - 60 178.77144 -8.5825391 0 -8.5596116 -31971.17 - 70 146.71854 -8.578428 0 -8.5596113 -31245.51 - 80 119.50956 -8.5749383 0 -8.5596111 -30724.137 - 90 99.872785 -8.5724197 0 -8.559611 -30440.244 - 100 89.604584 -8.5711027 0 -8.5596109 -30392.805 -Loop time of 3.16831 on 1 procs for 100 steps with 128 atoms + 10 296.32664 -8.5976164 0 -8.5596124 -35188.339 + 20 282.41417 -8.595832 0 -8.5596123 -34782.293 + 30 259.69014 -8.5929175 0 -8.5596121 -34113.316 + 40 230.50415 -8.5891741 0 -8.5596119 -33260.777 + 50 197.88816 -8.5849908 0 -8.5596116 -32309.975 + 60 165.27259 -8.5808076 0 -8.5596113 -31365.766 + 70 136.15697 -8.5770733 0 -8.5596111 -30542.657 + 80 113.58947 -8.5741788 0 -8.5596109 -29939.23 + 90 99.477916 -8.572369 0 -8.5596109 -29619.939 + 100 94.121939 -8.5716822 0 -8.559611 -29598.002 +Loop time of 2.26616 on 1 procs for 100 steps with 128 atoms -Performance: 1.364 ns/day, 17.602 hours/ns, 31.563 timesteps/s -199.5% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 1.906 ns/day, 12.590 hours/ns, 44.128 timesteps/s +99.3% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 3.1672 | 3.1672 | 3.1672 | 0.0 | 99.97 -Neigh | 0.00030208 | 0.00030208 | 0.00030208 | 0.0 | 0.01 -Comm | 0.00029612 | 0.00029612 | 0.00029612 | 0.0 | 0.01 -Output | 0.00019813 | 0.00019813 | 0.00019813 | 0.0 | 0.01 -Modify | 0.00014448 | 0.00014448 | 0.00014448 | 0.0 | 0.00 -Other | | 0.0001433 | | | 0.00 +Pair | 2.2531 | 2.2531 | 2.2531 | 0.0 | 99.42 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.0002594 | 0.0002594 | 0.0002594 | 0.0 | 0.01 +Output | 0.012544 | 0.012544 | 0.012544 | 0.0 | 0.55 +Modify | 0.00010347 | 0.00010347 | 0.00010347 | 0.0 | 0.00 +Other | | 0.0001583 | | | 0.01 Nlocal: 128 ave 128 max 128 min Histogram: 1 0 0 0 0 0 0 0 0 0 Nghost: 727 ave 727 max 727 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 3710 ave 3710 max 3710 min +Neighs: 3712 ave 3712 max 3712 min Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 7420 ave 7420 max 7420 min +FullNghs: 7424 ave 7424 max 7424 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Total # of neighbors = 7420 -Ave neighs/atom = 57.9688 -Neighbor list builds = 1 +Total # of neighbors = 7424 +Ave neighs/atom = 58 +Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:03 +Total wall time: 0:00:02 diff --git a/examples/snap/log.18Sep19.snap.WBeSNAP.g++.4 b/examples/snap/log.15Jun20.snap.WBe.PRB2019.g++.4 similarity index 51% rename from examples/snap/log.18Sep19.snap.WBeSNAP.g++.4 rename to examples/snap/log.15Jun20.snap.WBe.PRB2019.g++.4 index d8cdae6810..fa24dae5c3 100644 --- a/examples/snap/log.18Sep19.snap.WBeSNAP.g++.4 +++ b/examples/snap/log.15Jun20.snap.WBe.PRB2019.g++.4 @@ -1,4 +1,5 @@ -LAMMPS (7 Aug 2019) +LAMMPS (15 Jun 2020) + using 1 OpenMP thread(s) per MPI task # Demonstrate SNAP W-Be potential # Initialize simulation @@ -6,7 +7,7 @@ LAMMPS (7 Aug 2019) variable nsteps index 100 variable nrep equal 4 variable a equal 3.1803 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -17,33 +18,33 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.1803 Lattice spacing in x,y,z = 3.1803 3.1803 3.1803 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 2 box -Created orthogonal box = (0 0 0) to (12.7212 12.7212 12.7212) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 2 box +Created orthogonal box = (0.0 0.0 0.0) to (12.7212 12.7212 12.7212) 1 by 2 by 2 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - create_atoms CPU = 0.000317097 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 mass 2 9.012182 -set group all type/fraction 2 0.05 3590153 # Change 5% of W to He - 5 settings made for type/fraction -group tungsten type 1 +set group all type/fraction 2 0.05 3590153 # Change 5% of W to He + 5 settings made for type/fractiongroup tungsten type 1 123 atoms in group tungsten -group beryllium type 2 +group beryllium type 2 5 atoms in group beryllium # choose potential include WBe_Wood_PRB2019.snap +# DATE: 2019-09-18 UNITS: metal CONTRIBUTOR: Mary Alice Cusentino mcusent@sandia.gov CITATION: M.A. Wood, M.A. Cusentino, B.D. Wirth, and A.P. Thompson, "Data-driven material models for atomistic simulation", Physical Review B 99, 184305 (2019) # Definition of SNAP+ZBL potential. variable zblcutinner equal 4 variable zblcutouter equal 4.8 @@ -77,7 +78,7 @@ SNAP keyword quadraticflag 0 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -88,7 +89,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -112,43 +113,43 @@ Neighbor list info ... Per MPI rank memory allocation (min/avg/max) = 4.167 | 4.167 | 4.167 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -8.5980876 0 -8.5596125 -35284.855 - 10 296.24946 -8.5976065 0 -8.5596124 -35140.29 - 20 282.27904 -8.5958147 0 -8.5596123 -34710.3 - 30 259.54978 -8.5928995 0 -8.5596121 -34060.43 - 40 230.41412 -8.5891626 0 -8.5596119 -33258.275 - 50 197.85135 -8.5849861 0 -8.5596116 -32389.527 - 60 165.21732 -8.5808005 0 -8.5596113 -31550.426 - 70 135.94024 -8.5770455 0 -8.5596111 -30839.006 - 80 113.06617 -8.5741117 0 -8.5596109 -30339.177 - 90 98.542347 -8.572249 0 -8.5596109 -30094.29 - 100 92.524343 -8.5714774 0 -8.5596111 -30091.988 -Loop time of 0.813674 on 4 procs for 100 steps with 128 atoms + 10 296.32664 -8.5976164 0 -8.5596124 -35188.339 + 20 282.41417 -8.595832 0 -8.5596123 -34782.293 + 30 259.69014 -8.5929175 0 -8.5596121 -34113.316 + 40 230.50415 -8.5891741 0 -8.5596119 -33260.777 + 50 197.88816 -8.5849908 0 -8.5596116 -32309.975 + 60 165.27259 -8.5808076 0 -8.5596113 -31365.766 + 70 136.15697 -8.5770733 0 -8.5596111 -30542.657 + 80 113.58947 -8.5741788 0 -8.5596109 -29939.23 + 90 99.477916 -8.572369 0 -8.5596109 -29619.939 + 100 94.121939 -8.5716822 0 -8.559611 -29598.002 +Loop time of 0.668977 on 4 procs for 100 steps with 128 atoms -Performance: 5.309 ns/day, 4.520 hours/ns, 122.899 timesteps/s -99.7% CPU use with 4 MPI tasks x no OpenMP threads +Performance: 6.458 ns/day, 3.717 hours/ns, 149.482 timesteps/s +97.2% CPU use with 4 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.79079 | 0.79788 | 0.80888 | 0.8 | 98.06 -Neigh | 7.1049e-05 | 8.0049e-05 | 9.2983e-05 | 0.0 | 0.01 -Comm | 0.0041246 | 0.01515 | 0.022235 | 5.5 | 1.86 -Output | 0.000144 | 0.00017095 | 0.00024796 | 0.0 | 0.02 -Modify | 4.4823e-05 | 5.8889e-05 | 7.2718e-05 | 0.0 | 0.01 -Other | | 0.000338 | | | 0.04 +Pair | 0.57811 | 0.60637 | 0.63609 | 2.6 | 90.64 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.031571 | 0.061612 | 0.090021 | 8.3 | 9.21 +Output | 0.00015521 | 0.00021636 | 0.00038552 | 0.0 | 0.03 +Modify | 5.4836e-05 | 6.1393e-05 | 7.2956e-05 | 0.0 | 0.01 +Other | | 0.0007139 | | | 0.11 -Nlocal: 32 ave 37 max 28 min -Histogram: 1 0 0 1 1 0 0 0 0 1 -Nghost: 431 ave 435 max 426 min -Histogram: 1 0 0 0 0 1 1 0 0 1 -Neighs: 927 ave 1071 max 821 min -Histogram: 1 0 1 0 1 0 0 0 0 1 -FullNghs: 1854 ave 2144 max 1624 min -Histogram: 1 0 0 1 1 0 0 0 0 1 +Nlocal: 32 ave 32 max 32 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Nghost: 431 ave 431 max 431 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Neighs: 928 ave 928 max 928 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +FullNghs: 1856 ave 1856 max 1856 min +Histogram: 4 0 0 0 0 0 0 0 0 0 -Total # of neighbors = 7416 -Ave neighs/atom = 57.9375 -Neighbor list builds = 1 +Total # of neighbors = 7424 +Ave neighs/atom = 58 +Neighbor list builds = 0 Dangerous builds = 0 Total wall time: 0:00:00 diff --git a/examples/snap/log.27Nov18.snap.hybrid.WSNAP.HePair.g++.1 b/examples/snap/log.15Jun20.snap.hybrid.WSNAP.HePair.g++.1 similarity index 64% rename from examples/snap/log.27Nov18.snap.hybrid.WSNAP.HePair.g++.1 rename to examples/snap/log.15Jun20.snap.hybrid.WSNAP.HePair.g++.1 index 7d49043aa0..00161f4d4a 100644 --- a/examples/snap/log.27Nov18.snap.hybrid.WSNAP.HePair.g++.1 +++ b/examples/snap/log.15Jun20.snap.hybrid.WSNAP.HePair.g++.1 @@ -1,13 +1,13 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task -# Demonstrate SNAP Ta potential +# Demonstrate SNAP W with tabulated He-He and W-He using hybrid pair style # Initialize simulation variable nsteps index 100 variable nrep equal 4 variable a equal 3.1803 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,34 +18,33 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.1803 Lattice spacing in x,y,z = 3.1803 3.1803 3.1803 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 2 box -Created orthogonal box = (0 0 0) to (12.7212 12.7212 12.7212) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 2 box +Created orthogonal box = (0.0 0.0 0.0) to (12.7212 12.7212 12.7212) 1 by 1 by 1 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000426054 secs + create_atoms CPU = 0.001 seconds mass 1 183.84 mass 2 4.0026 -set group all type/fraction 2 0.05 3590153 # Change 5% of W to He - 5 settings made for type/fraction -group tungsten type 1 +set group all type/fraction 2 0.05 3590153 # Change 5% of W to He + 5 settings made for type/fractiongroup tungsten type 1 123 atoms in group tungsten -group helium type 2 +group helium type 2 5 atoms in group helium # choose potential include W_2940_2017_2_He_JW2013.snap -# DATE: 2017-02-20 CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] +# DATE: 2017-02-20 UNITS: metal CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] # # Definition of SNAP+ZBL+Tabulated potential. variable zblcutinner equal 4 @@ -60,7 +59,7 @@ pair_style hybrid/overlay zbl 4 4.8 snap table spline 10000 table spline 10000 pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff 1 1 zbl 74 ${zblz} pair_coeff 1 1 zbl 74 74 -pair_coeff * * snap W_2940_2017_2.snapcoeff W W_2940_2017_2.snapparam W NULL +pair_coeff * * snap W_2940_2017_2.snapcoeff W_2940_2017_2.snapparam W NULL Reading potential file W_2940_2017_2.snapcoeff with DATE: 2017-02-20 SNAP Element = W, Radius 0.5, Weight 1 Reading potential file W_2940_2017_2.snapparam with DATE: 2017-02-20 @@ -68,24 +67,23 @@ SNAP keyword rcutfac 4.73442 SNAP keyword twojmax 8 SNAP keyword rfac0 0.99363 SNAP keyword rmin0 0 -SNAP keyword diagonalstyle 3 SNAP keyword bzeroflag 0 SNAP keyword quadraticflag 0 pair_coeff 2 2 table 1 He_He_JW2013.table HeHe Reading potential file He_He_JW2013.table with DATE: 2017-02-20 WARNING: 1 of 4999 force values in table are inconsistent with -dE/dr. - Should only be flagged at inflection points (src/pair_table.cpp:481) + Should only be flagged at inflection points (src/pair_table.cpp:467) pair_coeff 1 2 table 2 W_He_JW2013.table WHe Reading potential file W_He_JW2013.table with DATE: 2017-02-20 WARNING: 3 of 325 force values in table are inconsistent with -dE/dr. - Should only be flagged at inflection points (src/pair_table.cpp:481) + Should only be flagged at inflection points (src/pair_table.cpp:467) #Hybrid/overlay will take all pair styles and add their contributions equally, order of pair_coeff doesnt matter here #This is not the case for pair_style hybrid ... where only one pair_coeff is read for each type combination, order matters here. # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -96,7 +94,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -137,33 +135,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 7.676 | 7.676 | 7.676 Mbytes +Per MPI rank memory allocation (min/avg/max) = 6.789 | 6.789 | 6.789 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -10.438105 0 -10.39963 -5445.2808 - 10 290.48923 -10.436885 0 -10.399629 -5646.4813 - 20 271.18868 -10.434409 0 -10.399629 -5654.4646 - 30 246.2601 -10.431212 0 -10.399629 -5281.8873 - 40 218.69918 -10.427677 0 -10.399629 -4343.3636 - 50 189.12519 -10.423885 0 -10.399629 -2903.1138 - 60 155.55701 -10.419579 0 -10.399629 -1402.2278 - 70 118.83581 -10.414869 0 -10.399629 -146.36141 - 80 85.903126 -10.410645 0 -10.399628 857.74986 - 90 65.223651 -10.407993 0 -10.399628 1494.2746 - 100 59.833542 -10.407302 0 -10.399628 1938.9164 -Loop time of 17.6435 on 1 procs for 100 steps with 128 atoms + 10 292.90716 -10.437195 0 -10.39963 -5400.8323 + 20 275.59696 -10.434975 0 -10.399629 -5055.199 + 30 250.28699 -10.431729 0 -10.399629 -4317.4619 + 40 218.58148 -10.427662 0 -10.399629 -3069.0256 + 50 182.80754 -10.423074 0 -10.399629 -1514.9501 + 60 144.77789 -10.418197 0 -10.399629 134.6083 + 70 108.06164 -10.413487 0 -10.399628 1747.8913 + 80 79.630821 -10.409841 0 -10.399628 2913.2733 + 90 62.795831 -10.407682 0 -10.399628 3646.2528 + 100 57.450965 -10.406996 0 -10.399628 4022.2665 +Loop time of 2.15336 on 1 procs for 100 steps with 128 atoms -Performance: 0.245 ns/day, 98.019 hours/ns, 5.668 timesteps/s -98.9% CPU use with 1 MPI tasks x 1 OpenMP threads +Performance: 2.006 ns/day, 11.963 hours/ns, 46.439 timesteps/s +99.9% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 17.641 | 17.641 | 17.641 | 0.0 | 99.99 -Neigh | 0.00054359 | 0.00054359 | 0.00054359 | 0.0 | 0.00 -Comm | 0.00080729 | 0.00080729 | 0.00080729 | 0.0 | 0.00 -Output | 0.00026512 | 0.00026512 | 0.00026512 | 0.0 | 0.00 -Modify | 0.00033879 | 0.00033879 | 0.00033879 | 0.0 | 0.00 -Other | | 0.0005448 | | | 0.00 +Pair | 2.1524 | 2.1524 | 2.1524 | 0.0 | 99.96 +Neigh | 0.00030732 | 0.00030732 | 0.00030732 | 0.0 | 0.01 +Comm | 0.00026202 | 0.00026202 | 0.00026202 | 0.0 | 0.01 +Output | 0.00013041 | 0.00013041 | 0.00013041 | 0.0 | 0.01 +Modify | 0.00010085 | 0.00010085 | 0.00010085 | 0.0 | 0.00 +Other | | 0.0001643 | | | 0.01 Nlocal: 128 ave 128 max 128 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -179,4 +177,4 @@ Ave neighs/atom = 53.5156 Neighbor list builds = 1 Dangerous builds = 0 -Total wall time: 0:00:17 +Total wall time: 0:00:02 diff --git a/examples/snap/log.27Nov18.snap.hybrid.WSNAP.HePair.g++.4 b/examples/snap/log.15Jun20.snap.hybrid.WSNAP.HePair.g++.4 similarity index 59% rename from examples/snap/log.27Nov18.snap.hybrid.WSNAP.HePair.g++.4 rename to examples/snap/log.15Jun20.snap.hybrid.WSNAP.HePair.g++.4 index 05db710266..413aa10baa 100644 --- a/examples/snap/log.27Nov18.snap.hybrid.WSNAP.HePair.g++.4 +++ b/examples/snap/log.15Jun20.snap.hybrid.WSNAP.HePair.g++.4 @@ -1,13 +1,13 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task -# Demonstrate SNAP Ta potential +# Demonstrate SNAP W with tabulated He-He and W-He using hybrid pair style # Initialize simulation variable nsteps index 100 variable nrep equal 4 variable a equal 3.1803 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,34 +18,33 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.1803 Lattice spacing in x,y,z = 3.1803 3.1803 3.1803 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 2 box -Created orthogonal box = (0 0 0) to (12.7212 12.7212 12.7212) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 2 box +Created orthogonal box = (0.0 0.0 0.0) to (12.7212 12.7212 12.7212) 1 by 2 by 2 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000303984 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 mass 2 4.0026 -set group all type/fraction 2 0.05 3590153 # Change 5% of W to He - 5 settings made for type/fraction -group tungsten type 1 +set group all type/fraction 2 0.05 3590153 # Change 5% of W to He + 5 settings made for type/fractiongroup tungsten type 1 123 atoms in group tungsten -group helium type 2 +group helium type 2 5 atoms in group helium # choose potential include W_2940_2017_2_He_JW2013.snap -# DATE: 2017-02-20 CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] +# DATE: 2017-02-20 UNITS: metal CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] # # Definition of SNAP+ZBL+Tabulated potential. variable zblcutinner equal 4 @@ -60,7 +59,7 @@ pair_style hybrid/overlay zbl 4 4.8 snap table spline 10000 table spline 10000 pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff 1 1 zbl 74 ${zblz} pair_coeff 1 1 zbl 74 74 -pair_coeff * * snap W_2940_2017_2.snapcoeff W W_2940_2017_2.snapparam W NULL +pair_coeff * * snap W_2940_2017_2.snapcoeff W_2940_2017_2.snapparam W NULL Reading potential file W_2940_2017_2.snapcoeff with DATE: 2017-02-20 SNAP Element = W, Radius 0.5, Weight 1 Reading potential file W_2940_2017_2.snapparam with DATE: 2017-02-20 @@ -68,24 +67,23 @@ SNAP keyword rcutfac 4.73442 SNAP keyword twojmax 8 SNAP keyword rfac0 0.99363 SNAP keyword rmin0 0 -SNAP keyword diagonalstyle 3 SNAP keyword bzeroflag 0 SNAP keyword quadraticflag 0 pair_coeff 2 2 table 1 He_He_JW2013.table HeHe Reading potential file He_He_JW2013.table with DATE: 2017-02-20 WARNING: 1 of 4999 force values in table are inconsistent with -dE/dr. - Should only be flagged at inflection points (src/pair_table.cpp:481) + Should only be flagged at inflection points (src/pair_table.cpp:467) pair_coeff 1 2 table 2 W_He_JW2013.table WHe Reading potential file W_He_JW2013.table with DATE: 2017-02-20 WARNING: 3 of 325 force values in table are inconsistent with -dE/dr. - Should only be flagged at inflection points (src/pair_table.cpp:481) + Should only be flagged at inflection points (src/pair_table.cpp:467) #Hybrid/overlay will take all pair styles and add their contributions equally, order of pair_coeff doesnt matter here #This is not the case for pair_style hybrid ... where only one pair_coeff is read for each type combination, order matters here. # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -96,7 +94,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -137,46 +135,46 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 7.656 | 7.656 | 7.656 Mbytes +Per MPI rank memory allocation (min/avg/max) = 6.687 | 6.69 | 6.692 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -10.438105 0 -10.39963 -5445.2808 - 10 292.13979 -10.437097 0 -10.39963 -5516.3963 - 20 272.55728 -10.434585 0 -10.399629 -5460.4268 - 30 245.06559 -10.431059 0 -10.399629 -5016.6351 - 40 212.79459 -10.42692 0 -10.399629 -3924.2175 - 50 178.03903 -10.422462 0 -10.399629 -2354.5485 - 60 141.62155 -10.417791 0 -10.399628 -595.41345 - 70 107.24843 -10.413383 0 -10.399628 1138.4107 - 80 79.985938 -10.409886 0 -10.399628 2392.1106 - 90 62.568933 -10.407652 0 -10.399628 3141.7027 - 100 56.697933 -10.406899 0 -10.399628 3583.9538 -Loop time of 4.7853 on 4 procs for 100 steps with 128 atoms + 10 292.90716 -10.437195 0 -10.39963 -5400.8323 + 20 275.59696 -10.434975 0 -10.399629 -5055.199 + 30 250.28699 -10.431729 0 -10.399629 -4317.4619 + 40 218.58148 -10.427662 0 -10.399629 -3069.0256 + 50 182.80754 -10.423074 0 -10.399629 -1514.9501 + 60 144.77789 -10.418197 0 -10.399629 134.6083 + 70 108.06164 -10.413487 0 -10.399628 1747.8913 + 80 79.630821 -10.409841 0 -10.399628 2913.2733 + 90 62.795831 -10.407682 0 -10.399628 3646.2528 + 100 57.450965 -10.406996 0 -10.399628 4022.2665 +Loop time of 0.652565 on 4 procs for 100 steps with 128 atoms -Performance: 0.903 ns/day, 26.585 hours/ns, 20.897 timesteps/s -97.3% CPU use with 4 MPI tasks x 1 OpenMP threads +Performance: 6.620 ns/day, 3.625 hours/ns, 153.241 timesteps/s +96.1% CPU use with 4 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 4.394 | 4.5813 | 4.7463 | 5.9 | 95.74 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.035261 | 0.19515 | 0.38629 | 28.5 | 4.08 -Output | 0.00031662 | 0.00060844 | 0.0014563 | 0.0 | 0.01 -Modify | 0.00018692 | 0.0001924 | 0.00020123 | 0.0 | 0.00 -Other | | 0.008012 | | | 0.17 +Pair | 0.5462 | 0.57357 | 0.59096 | 2.3 | 87.89 +Neigh | 8.2016e-05 | 8.3506e-05 | 8.4877e-05 | 0.0 | 0.01 +Comm | 0.060158 | 0.07569 | 0.10482 | 6.5 | 11.60 +Output | 0.00015974 | 0.00035232 | 0.00092149 | 0.0 | 0.05 +Modify | 5.6982e-05 | 6.777e-05 | 7.3671e-05 | 0.0 | 0.01 +Other | | 0.002799 | | | 0.43 -Nlocal: 32 ave 32 max 32 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -Nghost: 431 ave 431 max 431 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -Neighs: 856.25 ave 885 max 818 min -Histogram: 1 0 0 0 1 0 0 0 1 1 -FullNghs: 1712.5 ave 1738 max 1658 min -Histogram: 1 0 0 0 0 0 0 0 2 1 +Nlocal: 32 ave 33 max 31 min +Histogram: 1 0 0 0 0 2 0 0 0 1 +Nghost: 431 ave 432 max 430 min +Histogram: 1 0 0 0 0 2 0 0 0 1 +Neighs: 856.25 ave 949 max 794 min +Histogram: 1 1 0 0 0 1 0 0 0 1 +FullNghs: 1712.5 ave 1854 max 1604 min +Histogram: 1 0 1 0 0 1 0 0 0 1 Total # of neighbors = 6850 Ave neighs/atom = 53.5156 -Neighbor list builds = 0 +Neighbor list builds = 1 Dangerous builds = 0 -Total wall time: 0:00:04 +Total wall time: 0:00:00 From 49af2c25ec73ec4370adb998f50a543ac55c3eec Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 00:11:18 -0400 Subject: [PATCH 08/53] add tester for atom styles --- unittest/formats/CMakeLists.txt | 5 ++ unittest/formats/test_atom_styles.cpp | 113 ++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 unittest/formats/test_atom_styles.cpp diff --git a/unittest/formats/CMakeLists.txt b/unittest/formats/CMakeLists.txt index 848fc0b6c7..96b3abee62 100644 --- a/unittest/formats/CMakeLists.txt +++ b/unittest/formats/CMakeLists.txt @@ -1,8 +1,13 @@ + add_executable(test_potential_file_reader test_potential_file_reader.cpp) target_link_libraries(test_potential_file_reader PRIVATE lammps GTest::GMock GTest::GTest) add_test(NAME PotentialFileReader COMMAND test_potential_file_reader WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set_tests_properties(PotentialFileReader PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}") +add_executable(test_atom_styles test_atom_styles.cpp) +target_link_libraries(test_atom_styles PRIVATE lammps GTest::GMock GTest::GTest) +add_test(NAME AtomStyles COMMAND test_atom_styles WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + if (PKG_MANYBODY) add_executable(test_eim_potential_file_reader test_eim_potential_file_reader.cpp) target_link_libraries(test_eim_potential_file_reader PRIVATE lammps GTest::GMock GTest::GTest) diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp new file mode 100644 index 0000000000..f927e336a4 --- /dev/null +++ b/unittest/formats/test_atom_styles.cpp @@ -0,0 +1,113 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "atom.h" +#include "input.h" +#include "lammps.h" +#include "utils.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include +#include +#include + +// whether to print verbose output (i.e. not capturing LAMMPS screen output). +bool verbose = false; + +namespace LAMMPS_NS { +using ::testing::Eq; + +class AtomStyleTest : public ::testing::Test { +protected: + LAMMPS *lmp; + + void SetUp() override + { + const char *args[] = {"SimpleCommandsTest", "-log", "none", "-echo", "screen", "-nocite"}; + char **argv = (char **)args; + int argc = sizeof(args) / sizeof(char *); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); + if (!verbose) ::testing::internal::GetCapturedStdout(); + } + + void TearDown() override + { + if (!verbose) ::testing::internal::CaptureStdout(); + delete lmp; + if (!verbose) ::testing::internal::GetCapturedStdout(); + } +}; + +TEST_F(AtomStyleTest, atomic) +{ + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 0); + ASSERT_EQ(lmp->atom->nlocal, 0); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_EQ(lmp->atom->nmax, 1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->nellipsoids, 0); + ASSERT_EQ(lmp->atom->nlines, 0); + ASSERT_EQ(lmp->atom->ntris, 0); + ASSERT_EQ(lmp->atom->nbodies, 0); + ASSERT_EQ(lmp->atom->nbonds, 0); + ASSERT_EQ(lmp->atom->nangles, 0); + ASSERT_EQ(lmp->atom->ndihedrals, 0); + ASSERT_EQ(lmp->atom->nimpropers, 0); + ASSERT_EQ(lmp->atom->ntypes, 0); + ASSERT_EQ(lmp->atom->nbondtypes, 0); + ASSERT_EQ(lmp->atom->nangletypes, 0); + ASSERT_EQ(lmp->atom->ndihedraltypes, 0); + ASSERT_EQ(lmp->atom->nimpropertypes, 0); + ASSERT_EQ(lmp->atom->bond_per_atom, 0); + ASSERT_EQ(lmp->atom->angle_per_atom, 0); + ASSERT_EQ(lmp->atom->dihedral_per_atom, 0); + ASSERT_EQ(lmp->atom->improper_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_bond_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_angle_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_dihedral_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_improper_per_atom, 0); + + ASSERT_EQ(lmp->atom->tag, nullptr); + ASSERT_EQ(lmp->atom->type, nullptr); + ASSERT_EQ(lmp->atom->mask, nullptr); + ASSERT_EQ(lmp->atom->image, nullptr); + ASSERT_EQ(lmp->atom->x, nullptr); + ASSERT_EQ(lmp->atom->v, nullptr); + ASSERT_EQ(lmp->atom->f, nullptr); + ASSERT_EQ(lmp->atom->rmass, nullptr); + ASSERT_EQ(lmp->atom->q, nullptr); + ASSERT_EQ(lmp->atom->mu, nullptr); + // ASSERT_NE(lmp->atom->,nullptr); + // ASSERT_EQ(lmp->atom->firstgroup, -1); + // ASSERT_EQ(lmp->atom->firstgroupname, nullptr); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("atom_style charge"); + lmp->input->one("atom_style atomic"); + if (!verbose) ::testing::internal::GetCapturedStdout(); +} + +} // namespace LAMMPS_NS + +int main(int argc, char **argv) +{ + MPI_Init(&argc, &argv); + ::testing::InitGoogleMock(&argc, argv); + if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; + return RUN_ALL_TESTS(); +} From db469b5cfdb34a6d950a4e9a9e4d8ef2b5b8f5c2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 01:24:36 -0400 Subject: [PATCH 09/53] plug memory leak in AtomVec classes --- src/atom_vec.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 708fedd15e..03b70fc54c 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -90,9 +90,47 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) AtomVec::~AtomVec() { + int datatype,cols,maxcols; + void *pdata; + for (int i = 0; i < nargcopy; i++) delete [] argcopy[i]; delete [] argcopy; + for (int i = 0; i < ngrow; i++) { + pdata = mgrow.pdata[i]; + datatype = mgrow.datatype[i]; + cols = mgrow.cols[i]; + const int nthreads = threads[i] ? comm->nthreads : 1; + if (datatype == Atom::DOUBLE) { + if (cols == 0) + memory->destroy(*((double **) pdata)); + else if (cols > 0) + memory->destroy(*((double ***) pdata)); + else { + maxcols = *(mgrow.maxcols[i]); + memory->destroy(*((double ***) pdata)); + } + } else if (datatype == Atom::INT) { + if (cols == 0) + memory->destroy(*((int **) pdata)); + else if (cols > 0) + memory->destroy(*((int ***) pdata)); + else { + maxcols = *(mgrow.maxcols[i]); + memory->destroy(*((int ***) pdata)); + } + } else if (datatype == Atom::BIGINT) { + if (cols == 0) + memory->destroy(*((bigint **) pdata)); + else if (cols > 0) + memory->destroy(*((bigint ***) pdata)); + else { + maxcols = *(mgrow.maxcols[i]); + memory->destroy(*((bigint ***) pdata)); + } + } + } + destroy_method(&mgrow); destroy_method(&mcopy); destroy_method(&mcomm); From 32c1dcf44f8c017f0de95c71882742eca8efde1b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 01:25:06 -0400 Subject: [PATCH 10/53] improve match for "id" first checks --- src/atom_vec.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 03b70fc54c..fbf6cfd043 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -2373,9 +2373,9 @@ void AtomVec::setup_fields() { int n,cols; - if (strstr(fields_data_atom,"id ") != fields_data_atom) + if (!utils::strmatch(fields_data_atom,"^id ")) error->all(FLERR,"Atom style fields_data_atom must have id as first field"); - if (strstr(fields_data_vel,"id v") != fields_data_vel) + if (!utils::strmatch(fields_data_vel,"^id v")) error->all(FLERR,"Atom style fields_data_vel must have " "'id v' as first fields"); From d990c1e7c00129582c286ec656a6e23e750d912f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 01:25:22 -0400 Subject: [PATCH 11/53] simplify through using {fmt} --- src/atom_vec.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index fbf6cfd043..7753a5f689 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -2507,31 +2507,21 @@ int AtomVec::process_fields(char *str, const char *default_str, Method *method) for (match = 0; match < nperatom; match++) if (strcmp(field, peratom[match].name) == 0) break; - if (match == nperatom) { - char str[128]; - sprintf(str,"Peratom field %s not recognized", field); - error->all(FLERR,str); - } + if (match == nperatom) + error->all(FLERR,fmt::format("Peratom field {} not recognized", field)); index[i] = match; // error if field appears multiple times for (match = 0; match < i; match++) - if (index[i] == index[match]) { - char str[128]; - sprintf(str,"Peratom field %s is repeated", field); - error->all(FLERR,str); - } + if (index[i] == index[match]) + error->all(FLERR,fmt::format("Peratom field {} is repeated", field)); // error if field is in default str for (match = 0; match < ndef; match++) - if (strcmp(field, def_words[match].c_str()) == 0) { - char str[128]; - sprintf(str,"Peratom field %s is a default", field); - error->all(FLERR,str); - } - + if (strcmp(field, def_words[match].c_str()) == 0) + error->all(FLERR,fmt::format("Peratom field {} is a default", field)); } method->index = index; From 61ace42e72c781acafcae9644980d9e41f6fa413 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 01:25:56 -0400 Subject: [PATCH 12/53] check status of all per-atom fields --- unittest/formats/test_atom_styles.cpp | 257 +++++++++++++++++++++++++- 1 file changed, 249 insertions(+), 8 deletions(-) diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp index f927e336a4..fdfb78fa76 100644 --- a/unittest/formats/test_atom_styles.cpp +++ b/unittest/formats/test_atom_styles.cpp @@ -82,24 +82,265 @@ TEST_F(AtomStyleTest, atomic) ASSERT_EQ(lmp->atom->extra_dihedral_per_atom, 0); ASSERT_EQ(lmp->atom->extra_improper_per_atom, 0); - ASSERT_EQ(lmp->atom->tag, nullptr); - ASSERT_EQ(lmp->atom->type, nullptr); - ASSERT_EQ(lmp->atom->mask, nullptr); - ASSERT_EQ(lmp->atom->image, nullptr); - ASSERT_EQ(lmp->atom->x, nullptr); - ASSERT_EQ(lmp->atom->v, nullptr); - ASSERT_EQ(lmp->atom->f, nullptr); - ASSERT_EQ(lmp->atom->rmass, nullptr); + ASSERT_NE(lmp->atom->tag, nullptr); + ASSERT_NE(lmp->atom->type, nullptr); + ASSERT_NE(lmp->atom->mask, nullptr); + ASSERT_NE(lmp->atom->image, nullptr); + ASSERT_NE(lmp->atom->x, nullptr); + ASSERT_NE(lmp->atom->v, nullptr); + ASSERT_NE(lmp->atom->f, nullptr); ASSERT_EQ(lmp->atom->q, nullptr); ASSERT_EQ(lmp->atom->mu, nullptr); + ASSERT_EQ(lmp->atom->omega, nullptr); + ASSERT_EQ(lmp->atom->angmom, nullptr); + ASSERT_EQ(lmp->atom->torque, nullptr); + ASSERT_EQ(lmp->atom->radius, nullptr); + ASSERT_EQ(lmp->atom->rmass, nullptr); + ASSERT_EQ(lmp->atom->ellipsoid, nullptr); + ASSERT_EQ(lmp->atom->line, nullptr); + ASSERT_EQ(lmp->atom->tri, nullptr); + ASSERT_EQ(lmp->atom->body, nullptr); + ASSERT_EQ(lmp->atom->molecule, nullptr); + ASSERT_EQ(lmp->atom->molindex, nullptr); + ASSERT_EQ(lmp->atom->molatom, nullptr); + ASSERT_EQ(lmp->atom->num_bond, nullptr); + ASSERT_EQ(lmp->atom->bond_type, nullptr); + ASSERT_EQ(lmp->atom->bond_atom, nullptr); + ASSERT_EQ(lmp->atom->num_angle, nullptr); + ASSERT_EQ(lmp->atom->angle_type, nullptr); + ASSERT_EQ(lmp->atom->angle_atom1, nullptr); + ASSERT_EQ(lmp->atom->angle_atom2, nullptr); + ASSERT_EQ(lmp->atom->angle_atom3, nullptr); + ASSERT_EQ(lmp->atom->num_dihedral, nullptr); + ASSERT_EQ(lmp->atom->dihedral_type, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom1, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom2, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom3, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom4, nullptr); + ASSERT_EQ(lmp->atom->num_improper, nullptr); + ASSERT_EQ(lmp->atom->improper_type, nullptr); + ASSERT_EQ(lmp->atom->improper_atom1, nullptr); + ASSERT_EQ(lmp->atom->improper_atom2, nullptr); + ASSERT_EQ(lmp->atom->improper_atom3, nullptr); + ASSERT_EQ(lmp->atom->improper_atom4, nullptr); + ASSERT_EQ(lmp->atom->maxspecial, 1); + ASSERT_EQ(lmp->atom->nspecial, nullptr); + ASSERT_EQ(lmp->atom->special, nullptr); + ASSERT_EQ(lmp->atom->vfrac, nullptr); + ASSERT_EQ(lmp->atom->s0, nullptr); + ASSERT_EQ(lmp->atom->x0, nullptr); + ASSERT_EQ(lmp->atom->sp, nullptr); + ASSERT_EQ(lmp->atom->fm, nullptr); + ASSERT_EQ(lmp->atom->fm_long, nullptr); + ASSERT_EQ(lmp->atom->spin, nullptr); + ASSERT_EQ(lmp->atom->eradius, nullptr); + ASSERT_EQ(lmp->atom->ervel, nullptr); + ASSERT_EQ(lmp->atom->erforce, nullptr); + ASSERT_EQ(lmp->atom->ervelforce, nullptr); + ASSERT_EQ(lmp->atom->cs, nullptr); + ASSERT_EQ(lmp->atom->csforce, nullptr); + ASSERT_EQ(lmp->atom->vforce, nullptr); + ASSERT_EQ(lmp->atom->etag, nullptr); + ASSERT_EQ(lmp->atom->uCond, nullptr); + ASSERT_EQ(lmp->atom->uMech, nullptr); + ASSERT_EQ(lmp->atom->uChem, nullptr); + ASSERT_EQ(lmp->atom->uCG, nullptr); + ASSERT_EQ(lmp->atom->uCGnew, nullptr); + ASSERT_EQ(lmp->atom->duChem, nullptr); + ASSERT_EQ(lmp->atom->dpdTheta, nullptr); + ASSERT_EQ(lmp->atom->cc, nullptr); + ASSERT_EQ(lmp->atom->cc_flux, nullptr); + ASSERT_EQ(lmp->atom->edpd_temp, nullptr); + ASSERT_EQ(lmp->atom->edpd_flux, nullptr); + ASSERT_EQ(lmp->atom->edpd_cv, nullptr); + ASSERT_EQ(lmp->atom->length, nullptr); + ASSERT_EQ(lmp->atom->buckling, nullptr); + ASSERT_EQ(lmp->atom->bond_nt, nullptr); + ASSERT_EQ(lmp->atom->contact_radius, nullptr); + ASSERT_EQ(lmp->atom->smd_data_9, nullptr); + ASSERT_EQ(lmp->atom->smd_stress, nullptr); + ASSERT_EQ(lmp->atom->eff_plastic_strain, nullptr); + ASSERT_EQ(lmp->atom->eff_plastic_strain_rate, nullptr); + ASSERT_EQ(lmp->atom->damage, nullptr); + ASSERT_EQ(lmp->atom->rho, nullptr); + ASSERT_EQ(lmp->atom->drho, nullptr); + ASSERT_EQ(lmp->atom->esph, nullptr); + ASSERT_EQ(lmp->atom->desph, nullptr); + ASSERT_EQ(lmp->atom->cv, nullptr); + ASSERT_EQ(lmp->atom->vest, nullptr); + ASSERT_EQ(lmp->atom->nmolecule, 0); + ASSERT_EQ(lmp->atom->molecules, nullptr); + ASSERT_EQ(lmp->atom->nivector, 0); + ASSERT_EQ(lmp->atom->ndvector, 0); + ASSERT_EQ(lmp->atom->iname, nullptr); + ASSERT_EQ(lmp->atom->dname, nullptr); + ASSERT_EQ(lmp->atom->mass, nullptr); + ASSERT_EQ(lmp->atom->mass_setflag, nullptr); + ASSERT_EQ(lmp->atom->nextra_grow, 0); + ASSERT_EQ(lmp->atom->nextra_restart, 0); + ASSERT_EQ(lmp->atom->nextra_border, 0); + ASSERT_EQ(lmp->atom->nextra_grow_max, 0); + ASSERT_EQ(lmp->atom->nextra_restart_max, 0); + ASSERT_EQ(lmp->atom->nextra_border_max, 0); + ASSERT_EQ(lmp->atom->nextra_store, 0); + ASSERT_EQ(lmp->atom->extra_grow, nullptr); + ASSERT_EQ(lmp->atom->extra_restart, nullptr); + ASSERT_EQ(lmp->atom->extra_border, nullptr); + ASSERT_EQ(lmp->atom->extra, nullptr); + ASSERT_EQ(lmp->atom->sametag, nullptr); + ASSERT_EQ(lmp->atom->map_style, 0); + ASSERT_EQ(lmp->atom->map_user, 0); + ASSERT_EQ(lmp->atom->map_tag_max, -1); + +#if 0 // ASSERT_NE(lmp->atom->,nullptr); // ASSERT_EQ(lmp->atom->firstgroup, -1); // ASSERT_EQ(lmp->atom->firstgroupname, nullptr); +#endif if (!verbose) ::testing::internal::CaptureStdout(); lmp->input->one("atom_style charge"); lmp->input->one("atom_style atomic"); if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 0); + ASSERT_EQ(lmp->atom->nlocal, 0); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_EQ(lmp->atom->nmax, 1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->nellipsoids, 0); + ASSERT_EQ(lmp->atom->nlines, 0); + ASSERT_EQ(lmp->atom->ntris, 0); + ASSERT_EQ(lmp->atom->nbodies, 0); + ASSERT_EQ(lmp->atom->nbonds, 0); + ASSERT_EQ(lmp->atom->nangles, 0); + ASSERT_EQ(lmp->atom->ndihedrals, 0); + ASSERT_EQ(lmp->atom->nimpropers, 0); + ASSERT_EQ(lmp->atom->ntypes, 0); + ASSERT_EQ(lmp->atom->nbondtypes, 0); + ASSERT_EQ(lmp->atom->nangletypes, 0); + ASSERT_EQ(lmp->atom->ndihedraltypes, 0); + ASSERT_EQ(lmp->atom->nimpropertypes, 0); + ASSERT_EQ(lmp->atom->bond_per_atom, 0); + ASSERT_EQ(lmp->atom->angle_per_atom, 0); + ASSERT_EQ(lmp->atom->dihedral_per_atom, 0); + ASSERT_EQ(lmp->atom->improper_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_bond_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_angle_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_dihedral_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_improper_per_atom, 0); + + ASSERT_NE(lmp->atom->tag, nullptr); + ASSERT_NE(lmp->atom->type, nullptr); + ASSERT_NE(lmp->atom->mask, nullptr); + ASSERT_NE(lmp->atom->image, nullptr); + ASSERT_NE(lmp->atom->x, nullptr); + ASSERT_NE(lmp->atom->v, nullptr); + ASSERT_NE(lmp->atom->f, nullptr); + ASSERT_EQ(lmp->atom->q, nullptr); + ASSERT_EQ(lmp->atom->mu, nullptr); + ASSERT_EQ(lmp->atom->omega, nullptr); + ASSERT_EQ(lmp->atom->angmom, nullptr); + ASSERT_EQ(lmp->atom->torque, nullptr); + ASSERT_EQ(lmp->atom->radius, nullptr); + ASSERT_EQ(lmp->atom->rmass, nullptr); + ASSERT_EQ(lmp->atom->ellipsoid, nullptr); + ASSERT_EQ(lmp->atom->line, nullptr); + ASSERT_EQ(lmp->atom->tri, nullptr); + ASSERT_EQ(lmp->atom->body, nullptr); + ASSERT_EQ(lmp->atom->molecule, nullptr); + ASSERT_EQ(lmp->atom->molindex, nullptr); + ASSERT_EQ(lmp->atom->molatom, nullptr); + ASSERT_EQ(lmp->atom->num_bond, nullptr); + ASSERT_EQ(lmp->atom->bond_type, nullptr); + ASSERT_EQ(lmp->atom->bond_atom, nullptr); + ASSERT_EQ(lmp->atom->num_angle, nullptr); + ASSERT_EQ(lmp->atom->angle_type, nullptr); + ASSERT_EQ(lmp->atom->angle_atom1, nullptr); + ASSERT_EQ(lmp->atom->angle_atom2, nullptr); + ASSERT_EQ(lmp->atom->angle_atom3, nullptr); + ASSERT_EQ(lmp->atom->num_dihedral, nullptr); + ASSERT_EQ(lmp->atom->dihedral_type, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom1, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom2, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom3, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom4, nullptr); + ASSERT_EQ(lmp->atom->num_improper, nullptr); + ASSERT_EQ(lmp->atom->improper_type, nullptr); + ASSERT_EQ(lmp->atom->improper_atom1, nullptr); + ASSERT_EQ(lmp->atom->improper_atom2, nullptr); + ASSERT_EQ(lmp->atom->improper_atom3, nullptr); + ASSERT_EQ(lmp->atom->improper_atom4, nullptr); + ASSERT_EQ(lmp->atom->maxspecial, 1); + ASSERT_EQ(lmp->atom->nspecial, nullptr); + ASSERT_EQ(lmp->atom->special, nullptr); + ASSERT_EQ(lmp->atom->vfrac, nullptr); + ASSERT_EQ(lmp->atom->s0, nullptr); + ASSERT_EQ(lmp->atom->x0, nullptr); + ASSERT_EQ(lmp->atom->sp, nullptr); + ASSERT_EQ(lmp->atom->fm, nullptr); + ASSERT_EQ(lmp->atom->fm_long, nullptr); + ASSERT_EQ(lmp->atom->spin, nullptr); + ASSERT_EQ(lmp->atom->eradius, nullptr); + ASSERT_EQ(lmp->atom->ervel, nullptr); + ASSERT_EQ(lmp->atom->erforce, nullptr); + ASSERT_EQ(lmp->atom->ervelforce, nullptr); + ASSERT_EQ(lmp->atom->cs, nullptr); + ASSERT_EQ(lmp->atom->csforce, nullptr); + ASSERT_EQ(lmp->atom->vforce, nullptr); + ASSERT_EQ(lmp->atom->etag, nullptr); + ASSERT_EQ(lmp->atom->uCond, nullptr); + ASSERT_EQ(lmp->atom->uMech, nullptr); + ASSERT_EQ(lmp->atom->uChem, nullptr); + ASSERT_EQ(lmp->atom->uCG, nullptr); + ASSERT_EQ(lmp->atom->uCGnew, nullptr); + ASSERT_EQ(lmp->atom->duChem, nullptr); + ASSERT_EQ(lmp->atom->dpdTheta, nullptr); + ASSERT_EQ(lmp->atom->cc, nullptr); + ASSERT_EQ(lmp->atom->cc_flux, nullptr); + ASSERT_EQ(lmp->atom->edpd_temp, nullptr); + ASSERT_EQ(lmp->atom->edpd_flux, nullptr); + ASSERT_EQ(lmp->atom->edpd_cv, nullptr); + ASSERT_EQ(lmp->atom->length, nullptr); + ASSERT_EQ(lmp->atom->buckling, nullptr); + ASSERT_EQ(lmp->atom->bond_nt, nullptr); + ASSERT_EQ(lmp->atom->contact_radius, nullptr); + ASSERT_EQ(lmp->atom->smd_data_9, nullptr); + ASSERT_EQ(lmp->atom->smd_stress, nullptr); + ASSERT_EQ(lmp->atom->eff_plastic_strain, nullptr); + ASSERT_EQ(lmp->atom->eff_plastic_strain_rate, nullptr); + ASSERT_EQ(lmp->atom->damage, nullptr); + ASSERT_EQ(lmp->atom->rho, nullptr); + ASSERT_EQ(lmp->atom->drho, nullptr); + ASSERT_EQ(lmp->atom->esph, nullptr); + ASSERT_EQ(lmp->atom->desph, nullptr); + ASSERT_EQ(lmp->atom->cv, nullptr); + ASSERT_EQ(lmp->atom->vest, nullptr); + ASSERT_EQ(lmp->atom->nmolecule, 0); + ASSERT_EQ(lmp->atom->molecules, nullptr); + ASSERT_EQ(lmp->atom->nivector, 0); + ASSERT_EQ(lmp->atom->ndvector, 0); + ASSERT_EQ(lmp->atom->iname, nullptr); + ASSERT_EQ(lmp->atom->dname, nullptr); + ASSERT_EQ(lmp->atom->mass, nullptr); + ASSERT_EQ(lmp->atom->mass_setflag, nullptr); + ASSERT_EQ(lmp->atom->nextra_grow, 0); + ASSERT_EQ(lmp->atom->nextra_restart, 0); + ASSERT_EQ(lmp->atom->nextra_border, 0); + ASSERT_EQ(lmp->atom->nextra_grow_max, 0); + ASSERT_EQ(lmp->atom->nextra_restart_max, 0); + ASSERT_EQ(lmp->atom->nextra_border_max, 0); + ASSERT_EQ(lmp->atom->nextra_store, 0); + ASSERT_EQ(lmp->atom->extra_grow, nullptr); + ASSERT_EQ(lmp->atom->extra_restart, nullptr); + ASSERT_EQ(lmp->atom->extra_border, nullptr); + ASSERT_EQ(lmp->atom->extra, nullptr); + ASSERT_EQ(lmp->atom->sametag, nullptr); + ASSERT_EQ(lmp->atom->map_style, 0); + ASSERT_EQ(lmp->atom->map_user, 0); + ASSERT_EQ(lmp->atom->map_tag_max, -1); } } // namespace LAMMPS_NS From 39b61fbdbec5cb8644bb78a24ebb1f0d68a53b64 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 01:30:41 -0400 Subject: [PATCH 13/53] add exit() to one() functions since compilers may not recognize that MPI_Abort() does not return. --- src/error.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/error.cpp b/src/error.cpp index 392624f40b..7458f816c0 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -107,6 +107,7 @@ void Error::universe_one(const std::string &file, int line, const std::string &s throw LAMMPSAbortException(mesg, universe->uworld); #else MPI_Abort(universe->uworld,1); + exit(1); // to trick "smart" compilers into believing this does not return #endif } @@ -205,6 +206,7 @@ void Error::one(const std::string &file, int line, const std::string &str) if (screen) fflush(screen); if (logfile) fflush(logfile); MPI_Abort(world,1); + exit(1); // to trick "smart" compilers into believing this does not return #endif } From e88bb9dd592f25c030fa6c13aa7f75c8af270b76 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 01:42:05 -0400 Subject: [PATCH 14/53] call MPI_Finalize() so we don't have spurious memory leaks from MPI reported by valgrind --- unittest/commands/test_simple_commands.cpp | 5 ++++- unittest/force-styles/test_main.cpp | 5 ++++- unittest/formats/test_atom_styles.cpp | 5 ++++- unittest/formats/test_eim_potential_file_reader.cpp | 5 ++++- unittest/formats/test_potential_file_reader.cpp | 5 ++++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/unittest/commands/test_simple_commands.cpp b/unittest/commands/test_simple_commands.cpp index 196a4506b1..1f5d4b5493 100644 --- a/unittest/commands/test_simple_commands.cpp +++ b/unittest/commands/test_simple_commands.cpp @@ -128,5 +128,8 @@ int main(int argc, char **argv) MPI_Init(&argc, &argv); ::testing::InitGoogleMock(&argc, argv); if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; - return RUN_ALL_TESTS(); + + int rv = RUN_ALL_TESTS(); + MPI_Finalize(); + return rv; } diff --git a/unittest/force-styles/test_main.cpp b/unittest/force-styles/test_main.cpp index 6c4973dfe7..6ff5194076 100644 --- a/unittest/force-styles/test_main.cpp +++ b/unittest/force-styles/test_main.cpp @@ -110,5 +110,8 @@ int main(int argc, char **argv) return 1; } } - return RUN_ALL_TESTS(); + + int rv = RUN_ALL_TESTS(); + MPI_Finalize(); + return rv; } diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp index fdfb78fa76..429d25f89f 100644 --- a/unittest/formats/test_atom_styles.cpp +++ b/unittest/formats/test_atom_styles.cpp @@ -350,5 +350,8 @@ int main(int argc, char **argv) MPI_Init(&argc, &argv); ::testing::InitGoogleMock(&argc, argv); if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; - return RUN_ALL_TESTS(); + + int rv = RUN_ALL_TESTS(); + MPI_Finalize(); + return rv; } diff --git a/unittest/formats/test_eim_potential_file_reader.cpp b/unittest/formats/test_eim_potential_file_reader.cpp index ff09c74dc6..fce179621e 100644 --- a/unittest/formats/test_eim_potential_file_reader.cpp +++ b/unittest/formats/test_eim_potential_file_reader.cpp @@ -202,5 +202,8 @@ int main(int argc, char **argv) MPI_Init(&argc, &argv); ::testing::InitGoogleMock(&argc, argv); if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; - return RUN_ALL_TESTS(); + + int rv = RUN_ALL_TESTS(); + MPI_Finalize(); + return rv; } diff --git a/unittest/formats/test_potential_file_reader.cpp b/unittest/formats/test_potential_file_reader.cpp index 2e289a6a1f..d168ca22c0 100644 --- a/unittest/formats/test_potential_file_reader.cpp +++ b/unittest/formats/test_potential_file_reader.cpp @@ -199,5 +199,8 @@ int main(int argc, char **argv) MPI_Init(&argc, &argv); ::testing::InitGoogleMock(&argc, argv); if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; - return RUN_ALL_TESTS(); + + int rv = RUN_ALL_TESTS(); + MPI_Finalize(); + return rv; } From 73c7ed1e9c56c77f69cd6da04cd55dd88e3eaeaa Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 01:42:41 -0400 Subject: [PATCH 15/53] start test for atom style charge --- unittest/formats/test_atom_styles.cpp | 153 +++++++++++++++++++++++++- 1 file changed, 147 insertions(+), 6 deletions(-) diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp index 429d25f89f..f34a21ef85 100644 --- a/unittest/formats/test_atom_styles.cpp +++ b/unittest/formats/test_atom_styles.cpp @@ -192,16 +192,11 @@ TEST_F(AtomStyleTest, atomic) ASSERT_EQ(lmp->atom->map_user, 0); ASSERT_EQ(lmp->atom->map_tag_max, -1); -#if 0 - // ASSERT_NE(lmp->atom->,nullptr); - // ASSERT_EQ(lmp->atom->firstgroup, -1); - // ASSERT_EQ(lmp->atom->firstgroupname, nullptr); -#endif - if (!verbose) ::testing::internal::CaptureStdout(); lmp->input->one("atom_style charge"); lmp->input->one("atom_style atomic"); if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); ASSERT_NE(lmp->atom->avec, nullptr); ASSERT_EQ(lmp->atom->natoms, 0); @@ -343,6 +338,152 @@ TEST_F(AtomStyleTest, atomic) ASSERT_EQ(lmp->atom->map_tag_max, -1); } +TEST_F(AtomStyleTest, charge) +{ + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("atom_style charge"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("charge")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 0); + ASSERT_EQ(lmp->atom->nlocal, 0); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_EQ(lmp->atom->nmax, 1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->nellipsoids, 0); + ASSERT_EQ(lmp->atom->nlines, 0); + ASSERT_EQ(lmp->atom->ntris, 0); + ASSERT_EQ(lmp->atom->nbodies, 0); + ASSERT_EQ(lmp->atom->nbonds, 0); + ASSERT_EQ(lmp->atom->nangles, 0); + ASSERT_EQ(lmp->atom->ndihedrals, 0); + ASSERT_EQ(lmp->atom->nimpropers, 0); + ASSERT_EQ(lmp->atom->ntypes, 0); + ASSERT_EQ(lmp->atom->nbondtypes, 0); + ASSERT_EQ(lmp->atom->nangletypes, 0); + ASSERT_EQ(lmp->atom->ndihedraltypes, 0); + ASSERT_EQ(lmp->atom->nimpropertypes, 0); + ASSERT_EQ(lmp->atom->bond_per_atom, 0); + ASSERT_EQ(lmp->atom->angle_per_atom, 0); + ASSERT_EQ(lmp->atom->dihedral_per_atom, 0); + ASSERT_EQ(lmp->atom->improper_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_bond_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_angle_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_dihedral_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_improper_per_atom, 0); + + ASSERT_NE(lmp->atom->tag, nullptr); + ASSERT_NE(lmp->atom->type, nullptr); + ASSERT_NE(lmp->atom->mask, nullptr); + ASSERT_NE(lmp->atom->image, nullptr); + ASSERT_NE(lmp->atom->x, nullptr); + ASSERT_NE(lmp->atom->v, nullptr); + ASSERT_NE(lmp->atom->f, nullptr); + ASSERT_NE(lmp->atom->q, nullptr); + ASSERT_EQ(lmp->atom->mu, nullptr); + ASSERT_EQ(lmp->atom->omega, nullptr); + ASSERT_EQ(lmp->atom->angmom, nullptr); + ASSERT_EQ(lmp->atom->torque, nullptr); + ASSERT_EQ(lmp->atom->radius, nullptr); + ASSERT_EQ(lmp->atom->rmass, nullptr); + ASSERT_EQ(lmp->atom->ellipsoid, nullptr); + ASSERT_EQ(lmp->atom->line, nullptr); + ASSERT_EQ(lmp->atom->tri, nullptr); + ASSERT_EQ(lmp->atom->body, nullptr); + ASSERT_EQ(lmp->atom->molecule, nullptr); + ASSERT_EQ(lmp->atom->molindex, nullptr); + ASSERT_EQ(lmp->atom->molatom, nullptr); + ASSERT_EQ(lmp->atom->num_bond, nullptr); + ASSERT_EQ(lmp->atom->bond_type, nullptr); + ASSERT_EQ(lmp->atom->bond_atom, nullptr); + ASSERT_EQ(lmp->atom->num_angle, nullptr); + ASSERT_EQ(lmp->atom->angle_type, nullptr); + ASSERT_EQ(lmp->atom->angle_atom1, nullptr); + ASSERT_EQ(lmp->atom->angle_atom2, nullptr); + ASSERT_EQ(lmp->atom->angle_atom3, nullptr); + ASSERT_EQ(lmp->atom->num_dihedral, nullptr); + ASSERT_EQ(lmp->atom->dihedral_type, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom1, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom2, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom3, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom4, nullptr); + ASSERT_EQ(lmp->atom->num_improper, nullptr); + ASSERT_EQ(lmp->atom->improper_type, nullptr); + ASSERT_EQ(lmp->atom->improper_atom1, nullptr); + ASSERT_EQ(lmp->atom->improper_atom2, nullptr); + ASSERT_EQ(lmp->atom->improper_atom3, nullptr); + ASSERT_EQ(lmp->atom->improper_atom4, nullptr); + ASSERT_EQ(lmp->atom->maxspecial, 1); + ASSERT_EQ(lmp->atom->nspecial, nullptr); + ASSERT_EQ(lmp->atom->special, nullptr); + ASSERT_EQ(lmp->atom->vfrac, nullptr); + ASSERT_EQ(lmp->atom->s0, nullptr); + ASSERT_EQ(lmp->atom->x0, nullptr); + ASSERT_EQ(lmp->atom->sp, nullptr); + ASSERT_EQ(lmp->atom->fm, nullptr); + ASSERT_EQ(lmp->atom->fm_long, nullptr); + ASSERT_EQ(lmp->atom->spin, nullptr); + ASSERT_EQ(lmp->atom->eradius, nullptr); + ASSERT_EQ(lmp->atom->ervel, nullptr); + ASSERT_EQ(lmp->atom->erforce, nullptr); + ASSERT_EQ(lmp->atom->ervelforce, nullptr); + ASSERT_EQ(lmp->atom->cs, nullptr); + ASSERT_EQ(lmp->atom->csforce, nullptr); + ASSERT_EQ(lmp->atom->vforce, nullptr); + ASSERT_EQ(lmp->atom->etag, nullptr); + ASSERT_EQ(lmp->atom->uCond, nullptr); + ASSERT_EQ(lmp->atom->uMech, nullptr); + ASSERT_EQ(lmp->atom->uChem, nullptr); + ASSERT_EQ(lmp->atom->uCG, nullptr); + ASSERT_EQ(lmp->atom->uCGnew, nullptr); + ASSERT_EQ(lmp->atom->duChem, nullptr); + ASSERT_EQ(lmp->atom->dpdTheta, nullptr); + ASSERT_EQ(lmp->atom->cc, nullptr); + ASSERT_EQ(lmp->atom->cc_flux, nullptr); + ASSERT_EQ(lmp->atom->edpd_temp, nullptr); + ASSERT_EQ(lmp->atom->edpd_flux, nullptr); + ASSERT_EQ(lmp->atom->edpd_cv, nullptr); + ASSERT_EQ(lmp->atom->length, nullptr); + ASSERT_EQ(lmp->atom->buckling, nullptr); + ASSERT_EQ(lmp->atom->bond_nt, nullptr); + ASSERT_EQ(lmp->atom->contact_radius, nullptr); + ASSERT_EQ(lmp->atom->smd_data_9, nullptr); + ASSERT_EQ(lmp->atom->smd_stress, nullptr); + ASSERT_EQ(lmp->atom->eff_plastic_strain, nullptr); + ASSERT_EQ(lmp->atom->eff_plastic_strain_rate, nullptr); + ASSERT_EQ(lmp->atom->damage, nullptr); + ASSERT_EQ(lmp->atom->rho, nullptr); + ASSERT_EQ(lmp->atom->drho, nullptr); + ASSERT_EQ(lmp->atom->esph, nullptr); + ASSERT_EQ(lmp->atom->desph, nullptr); + ASSERT_EQ(lmp->atom->cv, nullptr); + ASSERT_EQ(lmp->atom->vest, nullptr); + ASSERT_EQ(lmp->atom->nmolecule, 0); + ASSERT_EQ(lmp->atom->molecules, nullptr); + ASSERT_EQ(lmp->atom->nivector, 0); + ASSERT_EQ(lmp->atom->ndvector, 0); + ASSERT_EQ(lmp->atom->iname, nullptr); + ASSERT_EQ(lmp->atom->dname, nullptr); + ASSERT_EQ(lmp->atom->mass, nullptr); + ASSERT_EQ(lmp->atom->mass_setflag, nullptr); + ASSERT_EQ(lmp->atom->nextra_grow, 0); + ASSERT_EQ(lmp->atom->nextra_restart, 0); + ASSERT_EQ(lmp->atom->nextra_border, 0); + ASSERT_EQ(lmp->atom->nextra_grow_max, 0); + ASSERT_EQ(lmp->atom->nextra_restart_max, 0); + ASSERT_EQ(lmp->atom->nextra_border_max, 0); + ASSERT_EQ(lmp->atom->nextra_store, 0); + ASSERT_EQ(lmp->atom->extra_grow, nullptr); + ASSERT_EQ(lmp->atom->extra_restart, nullptr); + ASSERT_EQ(lmp->atom->extra_border, nullptr); + ASSERT_EQ(lmp->atom->extra, nullptr); + ASSERT_EQ(lmp->atom->sametag, nullptr); + ASSERT_EQ(lmp->atom->map_style, 0); + ASSERT_EQ(lmp->atom->map_user, 0); + ASSERT_EQ(lmp->atom->map_tag_max, -1); +} + } // namespace LAMMPS_NS int main(int argc, char **argv) From 34e46cc336a1e9c2c5216f8dd4362c863dbcc9c9 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 07:41:00 -0400 Subject: [PATCH 16/53] add workaround to USER-SCAFACOS package CMake script for linker error in FMM with GNU gcc 10.0 --- cmake/Modules/Packages/USER-SCAFACOS.cmake | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/cmake/Modules/Packages/USER-SCAFACOS.cmake b/cmake/Modules/Packages/USER-SCAFACOS.cmake index a6851210b2..e4735e31b3 100644 --- a/cmake/Modules/Packages/USER-SCAFACOS.cmake +++ b/cmake/Modules/Packages/USER-SCAFACOS.cmake @@ -19,22 +19,27 @@ if(DOWNLOAD_SCAFACOS) include(CheckFortranCompilerFlag) check_fortran_compiler_flag("-fallow-argument-mismatch" GNUFortran_ARGUMENT_MISMATCH_FLAG) if(GNUFortran_ARGUMENT_MISMATCH_FLAG) - set(APPEND_Fortran_FLAG "-fallow-argument-mismatch") + set(APPEND_Fortran_FLAGS "-fallow-argument-mismatch") + endif() + include(CheckCCompilerFlag) + check_c_compiler_flag("-fcommon" GNUC_NO_EXTERN_MISSING_FLAG) + if(GNUC_NO_EXTERN_MISSING_FLAG) + set(APPEND_C_FLAGS "-fcommon") endif() if(CMAKE_Fortran_FLAGS) - set(SCAFACOS_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${APPEND_Fortran_FLAG}") + set(SCAFACOS_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${APPEND_Fortran_FLAGS}") else() - set(SCAFACOS_Fortran_FLAGS "${CMAKE_Fortran_${CMAKE_BUILD_TYPE}_FLAGS} ${APPEND_Fortran_FLAG}") + set(SCAFACOS_Fortran_FLAGS "${CMAKE_Fortran_${CMAKE_BUILD_TYPE}_FLAGS} ${APPEND_Fortran_FLAGS}") endif() if(CMAKE_CXX_FLAGS) - set(SCAFACOS_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - else() - set(SCAFACOS_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS}") + set(SCAFACOS_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + else() + set(SCAFACOS_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS}") endif() if(CMAKE_C_FLAGS) - set(SCAFACOS_C_FLAGS "${CMAKE_C_FLAGS}") - else() - set(SCAFACOS_C_FLAGS "${CMAKE_C_${CMAKE_BUILD_TYPE}_FLAGS}") + set(SCAFACOS_C_FLAGS "${CMAKE_C_FLAGS} ${APPEND_C_FLAGS}") + else() + set(SCAFACOS_C_FLAGS "${CMAKE_C_${CMAKE_BUILD_TYPE}_FLAGS} ${APPEND_C_FLAGS}") endif() include(ExternalProject) From 27f1ce71fd7f2c646d2f5d1e0fbf0114b4dd37ec Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 07:42:50 -0400 Subject: [PATCH 17/53] now also check all 'xxx_flag' variables --- unittest/formats/test_atom_styles.cpp | 144 ++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp index f34a21ef85..c1ac0f37d3 100644 --- a/unittest/formats/test_atom_styles.cpp +++ b/unittest/formats/test_atom_styles.cpp @@ -82,6 +82,54 @@ TEST_F(AtomStyleTest, atomic) ASSERT_EQ(lmp->atom->extra_dihedral_per_atom, 0); ASSERT_EQ(lmp->atom->extra_improper_per_atom, 0); + ASSERT_EQ(lmp->atom->sphere_flag, 0); + ASSERT_EQ(lmp->atom->ellipsoid_flag, 0); + ASSERT_EQ(lmp->atom->line_flag, 0); + ASSERT_EQ(lmp->atom->tri_flag, 0); + ASSERT_EQ(lmp->atom->body_flag, 0); + ASSERT_EQ(lmp->atom->peri_flag, 0); + ASSERT_EQ(lmp->atom->electron_flag, 0); + ASSERT_EQ(lmp->atom->wavepacket_flag, 0); + ASSERT_EQ(lmp->atom->sph_flag, 0); + ASSERT_EQ(lmp->atom->molecule_flag, 0); + ASSERT_EQ(lmp->atom->molindex_flag, 0); + ASSERT_EQ(lmp->atom->molatom_flag, 0); + ASSERT_EQ(lmp->atom->q_flag, 0); + ASSERT_EQ(lmp->atom->mu_flag, 0); + ASSERT_EQ(lmp->atom->rmass_flag, 0); + ASSERT_EQ(lmp->atom->radius_flag, 0); + ASSERT_EQ(lmp->atom->omega_flag, 0); + ASSERT_EQ(lmp->atom->torque_flag, 0); + ASSERT_EQ(lmp->atom->angmom_flag, 0); + ASSERT_EQ(lmp->atom->vfrac_flag, 0); + ASSERT_EQ(lmp->atom->spin_flag, 0); + ASSERT_EQ(lmp->atom->eradius_flag, 0); + ASSERT_EQ(lmp->atom->ervel_flag, 0); + ASSERT_EQ(lmp->atom->erforce_flag, 0); + ASSERT_EQ(lmp->atom->cs_flag, 0); + ASSERT_EQ(lmp->atom->csforce_flag, 0); + ASSERT_EQ(lmp->atom->vforce_flag, 0); + ASSERT_EQ(lmp->atom->ervelforce_flag, 0); + ASSERT_EQ(lmp->atom->etag_flag, 0); + ASSERT_EQ(lmp->atom->rho_flag, 0); + ASSERT_EQ(lmp->atom->esph_flag, 0); + ASSERT_EQ(lmp->atom->cv_flag, 0); + ASSERT_EQ(lmp->atom->vest_flag, 0); + ASSERT_EQ(lmp->atom->dpd_flag, 0); + ASSERT_EQ(lmp->atom->edpd_flag, 0); + ASSERT_EQ(lmp->atom->tdpd_flag, 0); + ASSERT_EQ(lmp->atom->mesont_flag, 0); + ASSERT_EQ(lmp->atom->sp_flag, 0); + ASSERT_EQ(lmp->atom->x0_flag, 0); + ASSERT_EQ(lmp->atom->smd_flag, 0); + ASSERT_EQ(lmp->atom->damage_flag, 0); + ASSERT_EQ(lmp->atom->contact_radius_flag, 0); + ASSERT_EQ(lmp->atom->smd_data_9_flag, 0); + ASSERT_EQ(lmp->atom->smd_stress_flag, 0); + ASSERT_EQ(lmp->atom->eff_plastic_strain_flag, 0); + ASSERT_EQ(lmp->atom->eff_plastic_strain_rate_flag, 0); + ASSERT_EQ(lmp->atom->pdscale, 1.0); + ASSERT_NE(lmp->atom->tag, nullptr); ASSERT_NE(lmp->atom->type, nullptr); ASSERT_NE(lmp->atom->mask, nullptr); @@ -227,6 +275,54 @@ TEST_F(AtomStyleTest, atomic) ASSERT_EQ(lmp->atom->extra_dihedral_per_atom, 0); ASSERT_EQ(lmp->atom->extra_improper_per_atom, 0); + ASSERT_EQ(lmp->atom->sphere_flag, 0); + ASSERT_EQ(lmp->atom->ellipsoid_flag, 0); + ASSERT_EQ(lmp->atom->line_flag, 0); + ASSERT_EQ(lmp->atom->tri_flag, 0); + ASSERT_EQ(lmp->atom->body_flag, 0); + ASSERT_EQ(lmp->atom->peri_flag, 0); + ASSERT_EQ(lmp->atom->electron_flag, 0); + ASSERT_EQ(lmp->atom->wavepacket_flag, 0); + ASSERT_EQ(lmp->atom->sph_flag, 0); + ASSERT_EQ(lmp->atom->molecule_flag, 0); + ASSERT_EQ(lmp->atom->molindex_flag, 0); + ASSERT_EQ(lmp->atom->molatom_flag, 0); + ASSERT_EQ(lmp->atom->q_flag, 0); + ASSERT_EQ(lmp->atom->mu_flag, 0); + ASSERT_EQ(lmp->atom->rmass_flag, 0); + ASSERT_EQ(lmp->atom->radius_flag, 0); + ASSERT_EQ(lmp->atom->omega_flag, 0); + ASSERT_EQ(lmp->atom->torque_flag, 0); + ASSERT_EQ(lmp->atom->angmom_flag, 0); + ASSERT_EQ(lmp->atom->vfrac_flag, 0); + ASSERT_EQ(lmp->atom->spin_flag, 0); + ASSERT_EQ(lmp->atom->eradius_flag, 0); + ASSERT_EQ(lmp->atom->ervel_flag, 0); + ASSERT_EQ(lmp->atom->erforce_flag, 0); + ASSERT_EQ(lmp->atom->cs_flag, 0); + ASSERT_EQ(lmp->atom->csforce_flag, 0); + ASSERT_EQ(lmp->atom->vforce_flag, 0); + ASSERT_EQ(lmp->atom->ervelforce_flag, 0); + ASSERT_EQ(lmp->atom->etag_flag, 0); + ASSERT_EQ(lmp->atom->rho_flag, 0); + ASSERT_EQ(lmp->atom->esph_flag, 0); + ASSERT_EQ(lmp->atom->cv_flag, 0); + ASSERT_EQ(lmp->atom->vest_flag, 0); + ASSERT_EQ(lmp->atom->dpd_flag, 0); + ASSERT_EQ(lmp->atom->edpd_flag, 0); + ASSERT_EQ(lmp->atom->tdpd_flag, 0); + ASSERT_EQ(lmp->atom->mesont_flag, 0); + ASSERT_EQ(lmp->atom->sp_flag, 0); + ASSERT_EQ(lmp->atom->x0_flag, 0); + ASSERT_EQ(lmp->atom->smd_flag, 0); + ASSERT_EQ(lmp->atom->damage_flag, 0); + ASSERT_EQ(lmp->atom->contact_radius_flag, 0); + ASSERT_EQ(lmp->atom->smd_data_9_flag, 0); + ASSERT_EQ(lmp->atom->smd_stress_flag, 0); + ASSERT_EQ(lmp->atom->eff_plastic_strain_flag, 0); + ASSERT_EQ(lmp->atom->eff_plastic_strain_rate_flag, 0); + ASSERT_EQ(lmp->atom->pdscale, 1.0); + ASSERT_NE(lmp->atom->tag, nullptr); ASSERT_NE(lmp->atom->type, nullptr); ASSERT_NE(lmp->atom->mask, nullptr); @@ -373,6 +469,54 @@ TEST_F(AtomStyleTest, charge) ASSERT_EQ(lmp->atom->extra_dihedral_per_atom, 0); ASSERT_EQ(lmp->atom->extra_improper_per_atom, 0); + ASSERT_EQ(lmp->atom->sphere_flag, 0); + ASSERT_EQ(lmp->atom->ellipsoid_flag, 0); + ASSERT_EQ(lmp->atom->line_flag, 0); + ASSERT_EQ(lmp->atom->tri_flag, 0); + ASSERT_EQ(lmp->atom->body_flag, 0); + ASSERT_EQ(lmp->atom->peri_flag, 0); + ASSERT_EQ(lmp->atom->electron_flag, 0); + ASSERT_EQ(lmp->atom->wavepacket_flag, 0); + ASSERT_EQ(lmp->atom->sph_flag, 0); + ASSERT_EQ(lmp->atom->molecule_flag, 0); + ASSERT_EQ(lmp->atom->molindex_flag, 0); + ASSERT_EQ(lmp->atom->molatom_flag, 0); + ASSERT_EQ(lmp->atom->q_flag, 1); + ASSERT_EQ(lmp->atom->mu_flag, 0); + ASSERT_EQ(lmp->atom->rmass_flag, 0); + ASSERT_EQ(lmp->atom->radius_flag, 0); + ASSERT_EQ(lmp->atom->omega_flag, 0); + ASSERT_EQ(lmp->atom->torque_flag, 0); + ASSERT_EQ(lmp->atom->angmom_flag, 0); + ASSERT_EQ(lmp->atom->vfrac_flag, 0); + ASSERT_EQ(lmp->atom->spin_flag, 0); + ASSERT_EQ(lmp->atom->eradius_flag, 0); + ASSERT_EQ(lmp->atom->ervel_flag, 0); + ASSERT_EQ(lmp->atom->erforce_flag, 0); + ASSERT_EQ(lmp->atom->cs_flag, 0); + ASSERT_EQ(lmp->atom->csforce_flag, 0); + ASSERT_EQ(lmp->atom->vforce_flag, 0); + ASSERT_EQ(lmp->atom->ervelforce_flag, 0); + ASSERT_EQ(lmp->atom->etag_flag, 0); + ASSERT_EQ(lmp->atom->rho_flag, 0); + ASSERT_EQ(lmp->atom->esph_flag, 0); + ASSERT_EQ(lmp->atom->cv_flag, 0); + ASSERT_EQ(lmp->atom->vest_flag, 0); + ASSERT_EQ(lmp->atom->dpd_flag, 0); + ASSERT_EQ(lmp->atom->edpd_flag, 0); + ASSERT_EQ(lmp->atom->tdpd_flag, 0); + ASSERT_EQ(lmp->atom->mesont_flag, 0); + ASSERT_EQ(lmp->atom->sp_flag, 0); + ASSERT_EQ(lmp->atom->x0_flag, 0); + ASSERT_EQ(lmp->atom->smd_flag, 0); + ASSERT_EQ(lmp->atom->damage_flag, 0); + ASSERT_EQ(lmp->atom->contact_radius_flag, 0); + ASSERT_EQ(lmp->atom->smd_data_9_flag, 0); + ASSERT_EQ(lmp->atom->smd_stress_flag, 0); + ASSERT_EQ(lmp->atom->eff_plastic_strain_flag, 0); + ASSERT_EQ(lmp->atom->eff_plastic_strain_rate_flag, 0); + ASSERT_EQ(lmp->atom->pdscale, 1.0); + ASSERT_NE(lmp->atom->tag, nullptr); ASSERT_NE(lmp->atom->type, nullptr); ASSERT_NE(lmp->atom->mask, nullptr); From 2d52a09d084aa10b8472e4e84b9e827946a5197e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 13:01:29 -0400 Subject: [PATCH 18/53] patch the source code to the ScaFaCoS lib with a proper fix instead of working around it with compiler flags --- cmake/Modules/Packages/USER-SCAFACOS.cmake | 38 +++++----------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/cmake/Modules/Packages/USER-SCAFACOS.cmake b/cmake/Modules/Packages/USER-SCAFACOS.cmake index e4735e31b3..dc5c400c36 100644 --- a/cmake/Modules/Packages/USER-SCAFACOS.cmake +++ b/cmake/Modules/Packages/USER-SCAFACOS.cmake @@ -14,45 +14,23 @@ endif() option(DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" ${DOWNLOAD_SCAFACOS_DEFAULT}) if(DOWNLOAD_SCAFACOS) message(STATUS "ScaFaCoS download requested - we will build our own") - # create variables to pass our compiler flags along to the subsystem compile - # need to apply -fallow-argument-mismatch, if the fortran compiler supports it - include(CheckFortranCompilerFlag) - check_fortran_compiler_flag("-fallow-argument-mismatch" GNUFortran_ARGUMENT_MISMATCH_FLAG) - if(GNUFortran_ARGUMENT_MISMATCH_FLAG) - set(APPEND_Fortran_FLAGS "-fallow-argument-mismatch") - endif() - include(CheckCCompilerFlag) - check_c_compiler_flag("-fcommon" GNUC_NO_EXTERN_MISSING_FLAG) - if(GNUC_NO_EXTERN_MISSING_FLAG) - set(APPEND_C_FLAGS "-fcommon") - endif() - if(CMAKE_Fortran_FLAGS) - set(SCAFACOS_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${APPEND_Fortran_FLAGS}") - else() - set(SCAFACOS_Fortran_FLAGS "${CMAKE_Fortran_${CMAKE_BUILD_TYPE}_FLAGS} ${APPEND_Fortran_FLAGS}") - endif() - if(CMAKE_CXX_FLAGS) - set(SCAFACOS_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - else() - set(SCAFACOS_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS}") - endif() - if(CMAKE_C_FLAGS) - set(SCAFACOS_C_FLAGS "${CMAKE_C_FLAGS} ${APPEND_C_FLAGS}") - else() - set(SCAFACOS_C_FLAGS "${CMAKE_C_${CMAKE_BUILD_TYPE}_FLAGS} ${APPEND_C_FLAGS}") - endif() + + # version 1.0.1 needs a patch to compile and linke cleanly with GCC 10 and later. + file(DOWNLOAD https://download.lammps.org/thirdparty/scafacos-1.0.1-fix.diff ${CMAKE_CURRENT_BINARY_DIR}/scafacos-1.0.1.fix.diff + EXPECTED_HASH MD5=4baa1333bb28fcce102d505e1992d032) include(ExternalProject) ExternalProject_Add(scafacos_build URL https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz URL_MD5 bd46d74e3296bd8a444d731bb10c1738 + PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_BINARY_DIR}/scafacos-1.0.1.fix.diff CONFIGURE_COMMAND /configure --prefix= --disable-doc --enable-fcs-solvers=fmm,p2nfft,direct,ewald,p3m --with-internal-fftw --with-internal-pfft --with-internal-pnfft ${CONFIGURE_REQUEST_PIC} - FC=${CMAKE_MPI_Fortran_COMPILER} FCFLAGS=${SCAFACOS_Fortran_FLAGS} - CXX=${CMAKE_MPI_CXX_COMPILER} CXXFLAGS=${SCAFACOS_CXX_FLAGS} - CC=${CMAKE_MPI_C_COMPILER} CFLAGS=${SCAFACOS_C_FLAGS} + FC=${CMAKE_MPI_Fortran_COMPILER} + CXX=${CMAKE_MPI_CXX_COMPILER} + CC=${CMAKE_MPI_C_COMPILER} F77= BUILD_BYPRODUCTS /lib/libfcs.a From 8a93c84e741ce6d1a4bb7b015b2aa8b321df2035 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 15:03:36 -0400 Subject: [PATCH 19/53] make formatting consistent with lj/cut --- doc/src/pair_mdf.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/src/pair_mdf.rst b/doc/src/pair_mdf.rst index 983e817f1d..9cb9eaa6b2 100644 --- a/doc/src/pair_mdf.rst +++ b/doc/src/pair_mdf.rst @@ -85,7 +85,8 @@ standard 12-6 Lennard-Jones written in the epsilon/sigma form: .. math:: - E(r) = 4\epsilon\biggl[\bigl(\frac{\sigma}{r}\bigr)^{12} - \bigl(\frac{\sigma}{r}\bigr)^6\biggr] + E(r) = 4 \epsilon \left[ \left(\frac{\sigma}{r}\right)^{12} - + \left(\frac{\sigma}{r}\right)^6 \right] Either the first two or all of the following coefficients must be defined for each pair of atoms types via the pair_coeff command as in @@ -141,7 +142,7 @@ given or both left out: **Mixing, shift, table, tail correction, restart, rRESPA info**\ : For atom type pairs I,J and I != J, the :math:`\epsilon` and -:math:`sigma` coefficients and cutoff distances for the lj/mdf pair +:math:`\sigma` coefficients and cutoff distances for the lj/mdf pair style can be mixed. The default mix value is *geometric*\ . See the "pair_modify" command for details. The other two pair styles buck/mdf and lennard/mdf do not support mixing, so all I,J pairs of coefficients From afe874ac5bcc0fc28a8ba4babd7fbe6908b0faac Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 18:11:45 -0400 Subject: [PATCH 20/53] add test for using write_data/read_data for atom style atomic --- unittest/formats/test_atom_styles.cpp | 89 +++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp index c1ac0f37d3..f02ed42d80 100644 --- a/unittest/formats/test_atom_styles.cpp +++ b/unittest/formats/test_atom_styles.cpp @@ -40,6 +40,13 @@ protected: if (!verbose) ::testing::internal::CaptureStdout(); lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_NE(lmp, nullptr); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units real"); + lmp->input->one("dimension 3"); + lmp->input->one("pair_style zero 4.0"); + lmp->input->one("region box block -4 4 -4 4 -4 4"); + if (!verbose) ::testing::internal::GetCapturedStdout(); } void TearDown() override @@ -47,6 +54,7 @@ protected: if (!verbose) ::testing::internal::CaptureStdout(); delete lmp; if (!verbose) ::testing::internal::GetCapturedStdout(); + remove("test_atom_styles.data"); } }; @@ -432,6 +440,87 @@ TEST_F(AtomStyleTest, atomic) ASSERT_EQ(lmp->atom->map_style, 0); ASSERT_EQ(lmp->atom->map_user, 0); ASSERT_EQ(lmp->atom->map_tag_max, -1); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("atom_modify map hash"); + lmp->input->one("create_box 2 box"); + lmp->input->one("create_atoms 1 single -2.0 2.0 0.1"); + lmp->input->one("create_atoms 1 single -2.0 -2.0 -0.1"); + lmp->input->one("create_atoms 2 single 2.0 2.0 -0.1"); + lmp->input->one("create_atoms 2 single 2.0 -2.0 0.1"); + lmp->input->one("mass 1 4.0"); + lmp->input->one("mass 2 2.4"); + lmp->input->one("pair_coeff * *"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 4); + ASSERT_EQ(lmp->atom->nlocal, 4); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->ntypes, 2); + + ASSERT_NE(lmp->atom->mass, nullptr); + ASSERT_NE(lmp->atom->mass_setflag, nullptr); + ASSERT_NE(lmp->atom->sametag, nullptr); + ASSERT_EQ(lmp->atom->map_style, 2); + ASSERT_EQ(lmp->atom->map_user, 2); + ASSERT_EQ(lmp->atom->map_tag_max, 4); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("write_data test_atom_styles.data nocoeff"); + lmp->input->one("clear"); + lmp->input->one("atom_style atomic"); + lmp->input->one("pair_style zero 4.0"); + lmp->input->one("atom_modify map array"); + lmp->input->one("units real"); + lmp->input->one("read_data test_atom_styles.data"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 4); + ASSERT_EQ(lmp->atom->nlocal, 4); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->ntypes, 2); + + double **x = lmp->atom->x; + double **v = lmp->atom->v; + ASSERT_DOUBLE_EQ(x[0][0],-2.0); + ASSERT_DOUBLE_EQ(x[0][1],2.0); + ASSERT_DOUBLE_EQ(x[0][2],0.1); + ASSERT_DOUBLE_EQ(x[1][0],-2.0); + ASSERT_DOUBLE_EQ(x[1][1],-2.0); + ASSERT_DOUBLE_EQ(x[1][2],-0.1); + ASSERT_DOUBLE_EQ(x[2][0],2.0); + ASSERT_DOUBLE_EQ(x[2][1],2.0); + ASSERT_DOUBLE_EQ(x[2][2],-0.1); + ASSERT_DOUBLE_EQ(x[3][0],2.0); + ASSERT_DOUBLE_EQ(x[3][1],-2.0); + ASSERT_DOUBLE_EQ(x[3][2],0.1); + ASSERT_DOUBLE_EQ(v[0][0],0.0); + ASSERT_DOUBLE_EQ(v[0][1],0.0); + ASSERT_DOUBLE_EQ(v[0][2],0.0); + ASSERT_DOUBLE_EQ(v[1][0],0.0); + ASSERT_DOUBLE_EQ(v[1][1],0.0); + ASSERT_DOUBLE_EQ(v[1][2],0.0); + ASSERT_DOUBLE_EQ(v[2][0],0.0); + ASSERT_DOUBLE_EQ(v[2][1],0.0); + ASSERT_DOUBLE_EQ(v[2][2],0.0); + ASSERT_DOUBLE_EQ(v[3][0],0.0); + ASSERT_DOUBLE_EQ(v[3][1],0.0); + ASSERT_DOUBLE_EQ(v[3][2],0.0); + + ASSERT_DOUBLE_EQ(lmp->atom->mass[1], 4.0); + ASSERT_DOUBLE_EQ(lmp->atom->mass[2], 2.4); + ASSERT_EQ(lmp->atom->mass_setflag[1], 1); + ASSERT_EQ(lmp->atom->mass_setflag[2], 1); + ASSERT_EQ(lmp->atom->map_style, 1); + ASSERT_EQ(lmp->atom->map_user, 1); + ASSERT_EQ(lmp->atom->map_tag_max, 4); } TEST_F(AtomStyleTest, charge) From 5bb9700124f33b772353a14abd5a4ef42e7f065c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 18:12:12 -0400 Subject: [PATCH 21/53] ensure that a LAMMPS instance could be created and the eim pair style is available --- unittest/formats/test_eim_potential_file_reader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/unittest/formats/test_eim_potential_file_reader.cpp b/unittest/formats/test_eim_potential_file_reader.cpp index fce179621e..3efa7a3143 100644 --- a/unittest/formats/test_eim_potential_file_reader.cpp +++ b/unittest/formats/test_eim_potential_file_reader.cpp @@ -12,6 +12,7 @@ ------------------------------------------------------------------------- */ #include "MANYBODY/pair_eim.h" +#include "info.h" #include "input.h" #include "lammps.h" #include "utils.h" @@ -42,6 +43,11 @@ protected: lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); lmp->input->one("units metal"); if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_NE(lmp, nullptr); + + // check if the prerequisite eim pair style is available + Info *info = new Info(lmp); + ASSERT_TRUE(info->has_style("pair", "eim")); int npair = nelements * (nelements + 1) / 2; setfl.ielement = new int[nelements]; From a200756d7b7163ddafdc62341958555915c1160c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 20:40:04 -0400 Subject: [PATCH 22/53] remove a bunch of redundant tests and add checking for restarts and consecutive atom ids --- unittest/formats/test_atom_styles.cpp | 271 +++++++------------------- 1 file changed, 75 insertions(+), 196 deletions(-) diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp index f02ed42d80..bed60fb1c7 100644 --- a/unittest/formats/test_atom_styles.cpp +++ b/unittest/formats/test_atom_styles.cpp @@ -55,6 +55,7 @@ protected: delete lmp; if (!verbose) ::testing::internal::GetCapturedStdout(); remove("test_atom_styles.data"); + remove("test_atom_styles.restart"); } }; @@ -261,185 +262,14 @@ TEST_F(AtomStyleTest, atomic) ASSERT_EQ(lmp->atom->nmax, 1); ASSERT_EQ(lmp->atom->tag_enable, 1); ASSERT_EQ(lmp->atom->molecular, 0); - ASSERT_EQ(lmp->atom->nellipsoids, 0); - ASSERT_EQ(lmp->atom->nlines, 0); - ASSERT_EQ(lmp->atom->ntris, 0); - ASSERT_EQ(lmp->atom->nbodies, 0); - ASSERT_EQ(lmp->atom->nbonds, 0); - ASSERT_EQ(lmp->atom->nangles, 0); - ASSERT_EQ(lmp->atom->ndihedrals, 0); - ASSERT_EQ(lmp->atom->nimpropers, 0); ASSERT_EQ(lmp->atom->ntypes, 0); - ASSERT_EQ(lmp->atom->nbondtypes, 0); - ASSERT_EQ(lmp->atom->nangletypes, 0); - ASSERT_EQ(lmp->atom->ndihedraltypes, 0); - ASSERT_EQ(lmp->atom->nimpropertypes, 0); - ASSERT_EQ(lmp->atom->bond_per_atom, 0); - ASSERT_EQ(lmp->atom->angle_per_atom, 0); - ASSERT_EQ(lmp->atom->dihedral_per_atom, 0); - ASSERT_EQ(lmp->atom->improper_per_atom, 0); - ASSERT_EQ(lmp->atom->extra_bond_per_atom, 0); - ASSERT_EQ(lmp->atom->extra_angle_per_atom, 0); - ASSERT_EQ(lmp->atom->extra_dihedral_per_atom, 0); - ASSERT_EQ(lmp->atom->extra_improper_per_atom, 0); - ASSERT_EQ(lmp->atom->sphere_flag, 0); - ASSERT_EQ(lmp->atom->ellipsoid_flag, 0); - ASSERT_EQ(lmp->atom->line_flag, 0); - ASSERT_EQ(lmp->atom->tri_flag, 0); - ASSERT_EQ(lmp->atom->body_flag, 0); - ASSERT_EQ(lmp->atom->peri_flag, 0); - ASSERT_EQ(lmp->atom->electron_flag, 0); - ASSERT_EQ(lmp->atom->wavepacket_flag, 0); - ASSERT_EQ(lmp->atom->sph_flag, 0); ASSERT_EQ(lmp->atom->molecule_flag, 0); ASSERT_EQ(lmp->atom->molindex_flag, 0); ASSERT_EQ(lmp->atom->molatom_flag, 0); - ASSERT_EQ(lmp->atom->q_flag, 0); - ASSERT_EQ(lmp->atom->mu_flag, 0); - ASSERT_EQ(lmp->atom->rmass_flag, 0); - ASSERT_EQ(lmp->atom->radius_flag, 0); - ASSERT_EQ(lmp->atom->omega_flag, 0); - ASSERT_EQ(lmp->atom->torque_flag, 0); - ASSERT_EQ(lmp->atom->angmom_flag, 0); - ASSERT_EQ(lmp->atom->vfrac_flag, 0); - ASSERT_EQ(lmp->atom->spin_flag, 0); - ASSERT_EQ(lmp->atom->eradius_flag, 0); - ASSERT_EQ(lmp->atom->ervel_flag, 0); - ASSERT_EQ(lmp->atom->erforce_flag, 0); - ASSERT_EQ(lmp->atom->cs_flag, 0); - ASSERT_EQ(lmp->atom->csforce_flag, 0); - ASSERT_EQ(lmp->atom->vforce_flag, 0); - ASSERT_EQ(lmp->atom->ervelforce_flag, 0); - ASSERT_EQ(lmp->atom->etag_flag, 0); - ASSERT_EQ(lmp->atom->rho_flag, 0); - ASSERT_EQ(lmp->atom->esph_flag, 0); - ASSERT_EQ(lmp->atom->cv_flag, 0); - ASSERT_EQ(lmp->atom->vest_flag, 0); - ASSERT_EQ(lmp->atom->dpd_flag, 0); - ASSERT_EQ(lmp->atom->edpd_flag, 0); - ASSERT_EQ(lmp->atom->tdpd_flag, 0); - ASSERT_EQ(lmp->atom->mesont_flag, 0); - ASSERT_EQ(lmp->atom->sp_flag, 0); - ASSERT_EQ(lmp->atom->x0_flag, 0); - ASSERT_EQ(lmp->atom->smd_flag, 0); - ASSERT_EQ(lmp->atom->damage_flag, 0); - ASSERT_EQ(lmp->atom->contact_radius_flag, 0); - ASSERT_EQ(lmp->atom->smd_data_9_flag, 0); - ASSERT_EQ(lmp->atom->smd_stress_flag, 0); - ASSERT_EQ(lmp->atom->eff_plastic_strain_flag, 0); - ASSERT_EQ(lmp->atom->eff_plastic_strain_rate_flag, 0); - ASSERT_EQ(lmp->atom->pdscale, 1.0); - ASSERT_NE(lmp->atom->tag, nullptr); - ASSERT_NE(lmp->atom->type, nullptr); - ASSERT_NE(lmp->atom->mask, nullptr); - ASSERT_NE(lmp->atom->image, nullptr); - ASSERT_NE(lmp->atom->x, nullptr); - ASSERT_NE(lmp->atom->v, nullptr); - ASSERT_NE(lmp->atom->f, nullptr); + ASSERT_EQ(lmp->atom->q_flag, 0); ASSERT_EQ(lmp->atom->q, nullptr); - ASSERT_EQ(lmp->atom->mu, nullptr); - ASSERT_EQ(lmp->atom->omega, nullptr); - ASSERT_EQ(lmp->atom->angmom, nullptr); - ASSERT_EQ(lmp->atom->torque, nullptr); - ASSERT_EQ(lmp->atom->radius, nullptr); - ASSERT_EQ(lmp->atom->rmass, nullptr); - ASSERT_EQ(lmp->atom->ellipsoid, nullptr); - ASSERT_EQ(lmp->atom->line, nullptr); - ASSERT_EQ(lmp->atom->tri, nullptr); - ASSERT_EQ(lmp->atom->body, nullptr); - ASSERT_EQ(lmp->atom->molecule, nullptr); - ASSERT_EQ(lmp->atom->molindex, nullptr); - ASSERT_EQ(lmp->atom->molatom, nullptr); - ASSERT_EQ(lmp->atom->num_bond, nullptr); - ASSERT_EQ(lmp->atom->bond_type, nullptr); - ASSERT_EQ(lmp->atom->bond_atom, nullptr); - ASSERT_EQ(lmp->atom->num_angle, nullptr); - ASSERT_EQ(lmp->atom->angle_type, nullptr); - ASSERT_EQ(lmp->atom->angle_atom1, nullptr); - ASSERT_EQ(lmp->atom->angle_atom2, nullptr); - ASSERT_EQ(lmp->atom->angle_atom3, nullptr); - ASSERT_EQ(lmp->atom->num_dihedral, nullptr); - ASSERT_EQ(lmp->atom->dihedral_type, nullptr); - ASSERT_EQ(lmp->atom->dihedral_atom1, nullptr); - ASSERT_EQ(lmp->atom->dihedral_atom2, nullptr); - ASSERT_EQ(lmp->atom->dihedral_atom3, nullptr); - ASSERT_EQ(lmp->atom->dihedral_atom4, nullptr); - ASSERT_EQ(lmp->atom->num_improper, nullptr); - ASSERT_EQ(lmp->atom->improper_type, nullptr); - ASSERT_EQ(lmp->atom->improper_atom1, nullptr); - ASSERT_EQ(lmp->atom->improper_atom2, nullptr); - ASSERT_EQ(lmp->atom->improper_atom3, nullptr); - ASSERT_EQ(lmp->atom->improper_atom4, nullptr); - ASSERT_EQ(lmp->atom->maxspecial, 1); - ASSERT_EQ(lmp->atom->nspecial, nullptr); - ASSERT_EQ(lmp->atom->special, nullptr); - ASSERT_EQ(lmp->atom->vfrac, nullptr); - ASSERT_EQ(lmp->atom->s0, nullptr); - ASSERT_EQ(lmp->atom->x0, nullptr); - ASSERT_EQ(lmp->atom->sp, nullptr); - ASSERT_EQ(lmp->atom->fm, nullptr); - ASSERT_EQ(lmp->atom->fm_long, nullptr); - ASSERT_EQ(lmp->atom->spin, nullptr); - ASSERT_EQ(lmp->atom->eradius, nullptr); - ASSERT_EQ(lmp->atom->ervel, nullptr); - ASSERT_EQ(lmp->atom->erforce, nullptr); - ASSERT_EQ(lmp->atom->ervelforce, nullptr); - ASSERT_EQ(lmp->atom->cs, nullptr); - ASSERT_EQ(lmp->atom->csforce, nullptr); - ASSERT_EQ(lmp->atom->vforce, nullptr); - ASSERT_EQ(lmp->atom->etag, nullptr); - ASSERT_EQ(lmp->atom->uCond, nullptr); - ASSERT_EQ(lmp->atom->uMech, nullptr); - ASSERT_EQ(lmp->atom->uChem, nullptr); - ASSERT_EQ(lmp->atom->uCG, nullptr); - ASSERT_EQ(lmp->atom->uCGnew, nullptr); - ASSERT_EQ(lmp->atom->duChem, nullptr); - ASSERT_EQ(lmp->atom->dpdTheta, nullptr); - ASSERT_EQ(lmp->atom->cc, nullptr); - ASSERT_EQ(lmp->atom->cc_flux, nullptr); - ASSERT_EQ(lmp->atom->edpd_temp, nullptr); - ASSERT_EQ(lmp->atom->edpd_flux, nullptr); - ASSERT_EQ(lmp->atom->edpd_cv, nullptr); - ASSERT_EQ(lmp->atom->length, nullptr); - ASSERT_EQ(lmp->atom->buckling, nullptr); - ASSERT_EQ(lmp->atom->bond_nt, nullptr); - ASSERT_EQ(lmp->atom->contact_radius, nullptr); - ASSERT_EQ(lmp->atom->smd_data_9, nullptr); - ASSERT_EQ(lmp->atom->smd_stress, nullptr); - ASSERT_EQ(lmp->atom->eff_plastic_strain, nullptr); - ASSERT_EQ(lmp->atom->eff_plastic_strain_rate, nullptr); - ASSERT_EQ(lmp->atom->damage, nullptr); - ASSERT_EQ(lmp->atom->rho, nullptr); - ASSERT_EQ(lmp->atom->drho, nullptr); - ASSERT_EQ(lmp->atom->esph, nullptr); - ASSERT_EQ(lmp->atom->desph, nullptr); - ASSERT_EQ(lmp->atom->cv, nullptr); - ASSERT_EQ(lmp->atom->vest, nullptr); - ASSERT_EQ(lmp->atom->nmolecule, 0); - ASSERT_EQ(lmp->atom->molecules, nullptr); - ASSERT_EQ(lmp->atom->nivector, 0); - ASSERT_EQ(lmp->atom->ndvector, 0); - ASSERT_EQ(lmp->atom->iname, nullptr); - ASSERT_EQ(lmp->atom->dname, nullptr); - ASSERT_EQ(lmp->atom->mass, nullptr); - ASSERT_EQ(lmp->atom->mass_setflag, nullptr); - ASSERT_EQ(lmp->atom->nextra_grow, 0); - ASSERT_EQ(lmp->atom->nextra_restart, 0); - ASSERT_EQ(lmp->atom->nextra_border, 0); - ASSERT_EQ(lmp->atom->nextra_grow_max, 0); - ASSERT_EQ(lmp->atom->nextra_restart_max, 0); - ASSERT_EQ(lmp->atom->nextra_border_max, 0); - ASSERT_EQ(lmp->atom->nextra_store, 0); - ASSERT_EQ(lmp->atom->extra_grow, nullptr); - ASSERT_EQ(lmp->atom->extra_restart, nullptr); - ASSERT_EQ(lmp->atom->extra_border, nullptr); - ASSERT_EQ(lmp->atom->extra, nullptr); - ASSERT_EQ(lmp->atom->sametag, nullptr); - ASSERT_EQ(lmp->atom->map_style, 0); - ASSERT_EQ(lmp->atom->map_user, 0); - ASSERT_EQ(lmp->atom->map_tag_max, -1); if (!verbose) ::testing::internal::CaptureStdout(); lmp->input->one("atom_modify map hash"); @@ -469,6 +299,7 @@ TEST_F(AtomStyleTest, atomic) ASSERT_EQ(lmp->atom->map_user, 2); ASSERT_EQ(lmp->atom->map_tag_max, 4); if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("pair_coeff * *"); lmp->input->one("write_data test_atom_styles.data nocoeff"); lmp->input->one("clear"); lmp->input->one("atom_style atomic"); @@ -489,30 +320,30 @@ TEST_F(AtomStyleTest, atomic) double **x = lmp->atom->x; double **v = lmp->atom->v; - ASSERT_DOUBLE_EQ(x[0][0],-2.0); - ASSERT_DOUBLE_EQ(x[0][1],2.0); - ASSERT_DOUBLE_EQ(x[0][2],0.1); - ASSERT_DOUBLE_EQ(x[1][0],-2.0); - ASSERT_DOUBLE_EQ(x[1][1],-2.0); - ASSERT_DOUBLE_EQ(x[1][2],-0.1); - ASSERT_DOUBLE_EQ(x[2][0],2.0); - ASSERT_DOUBLE_EQ(x[2][1],2.0); - ASSERT_DOUBLE_EQ(x[2][2],-0.1); - ASSERT_DOUBLE_EQ(x[3][0],2.0); - ASSERT_DOUBLE_EQ(x[3][1],-2.0); - ASSERT_DOUBLE_EQ(x[3][2],0.1); - ASSERT_DOUBLE_EQ(v[0][0],0.0); - ASSERT_DOUBLE_EQ(v[0][1],0.0); - ASSERT_DOUBLE_EQ(v[0][2],0.0); - ASSERT_DOUBLE_EQ(v[1][0],0.0); - ASSERT_DOUBLE_EQ(v[1][1],0.0); - ASSERT_DOUBLE_EQ(v[1][2],0.0); - ASSERT_DOUBLE_EQ(v[2][0],0.0); - ASSERT_DOUBLE_EQ(v[2][1],0.0); - ASSERT_DOUBLE_EQ(v[2][2],0.0); - ASSERT_DOUBLE_EQ(v[3][0],0.0); - ASSERT_DOUBLE_EQ(v[3][1],0.0); - ASSERT_DOUBLE_EQ(v[3][2],0.0); + ASSERT_DOUBLE_EQ(x[0][0], -2.0); + ASSERT_DOUBLE_EQ(x[0][1], 2.0); + ASSERT_DOUBLE_EQ(x[0][2], 0.1); + ASSERT_DOUBLE_EQ(x[1][0], -2.0); + ASSERT_DOUBLE_EQ(x[1][1], -2.0); + ASSERT_DOUBLE_EQ(x[1][2], -0.1); + ASSERT_DOUBLE_EQ(x[2][0], 2.0); + ASSERT_DOUBLE_EQ(x[2][1], 2.0); + ASSERT_DOUBLE_EQ(x[2][2], -0.1); + ASSERT_DOUBLE_EQ(x[3][0], 2.0); + ASSERT_DOUBLE_EQ(x[3][1], -2.0); + ASSERT_DOUBLE_EQ(x[3][2], 0.1); + ASSERT_DOUBLE_EQ(v[0][0], 0.0); + ASSERT_DOUBLE_EQ(v[0][1], 0.0); + ASSERT_DOUBLE_EQ(v[0][2], 0.0); + ASSERT_DOUBLE_EQ(v[1][0], 0.0); + ASSERT_DOUBLE_EQ(v[1][1], 0.0); + ASSERT_DOUBLE_EQ(v[1][2], 0.0); + ASSERT_DOUBLE_EQ(v[2][0], 0.0); + ASSERT_DOUBLE_EQ(v[2][1], 0.0); + ASSERT_DOUBLE_EQ(v[2][2], 0.0); + ASSERT_DOUBLE_EQ(v[3][0], 0.0); + ASSERT_DOUBLE_EQ(v[3][1], 0.0); + ASSERT_DOUBLE_EQ(v[3][2], 0.0); ASSERT_DOUBLE_EQ(lmp->atom->mass[1], 4.0); ASSERT_DOUBLE_EQ(lmp->atom->mass[2], 2.4); @@ -521,6 +352,54 @@ TEST_F(AtomStyleTest, atomic) ASSERT_EQ(lmp->atom->map_style, 1); ASSERT_EQ(lmp->atom->map_user, 1); ASSERT_EQ(lmp->atom->map_tag_max, 4); + ASSERT_EQ(lmp->atom->tag_consecutive(), 1); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("pair_coeff * *"); + lmp->input->one("group two id 2:4:2"); + lmp->input->one("delete_atoms group two compress no"); + lmp->input->one("write_restart test_atom_styles.restart"); + lmp->input->one("clear"); + lmp->input->one("read_restart test_atom_styles.restart"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 2); + ASSERT_EQ(lmp->atom->nlocal, 2); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->ntypes, 2); + ASSERT_EQ(lmp->atom->tag_consecutive(), 0); + + x = lmp->atom->x; + v = lmp->atom->v; + ASSERT_DOUBLE_EQ(x[0][0], -2.0); + ASSERT_DOUBLE_EQ(x[0][1], 2.0); + ASSERT_DOUBLE_EQ(x[0][2], 0.1); + ASSERT_DOUBLE_EQ(x[1][0], 2.0); + ASSERT_DOUBLE_EQ(x[1][1], 2.0); + ASSERT_DOUBLE_EQ(x[1][2], -0.1); + ASSERT_DOUBLE_EQ(v[0][0], 0.0); + ASSERT_DOUBLE_EQ(v[0][1], 0.0); + ASSERT_DOUBLE_EQ(v[0][2], 0.0); + ASSERT_DOUBLE_EQ(v[1][0], 0.0); + ASSERT_DOUBLE_EQ(v[1][1], 0.0); + ASSERT_DOUBLE_EQ(v[1][2], 0.0); + + ASSERT_DOUBLE_EQ(lmp->atom->mass[1], 4.0); + ASSERT_DOUBLE_EQ(lmp->atom->mass[2], 2.4); + ASSERT_EQ(lmp->atom->mass_setflag[1], 1); + ASSERT_EQ(lmp->atom->mass_setflag[2], 1); + ASSERT_EQ(lmp->atom->map_style, 1); + ASSERT_EQ(lmp->atom->map_user, 1); + ASSERT_EQ(lmp->atom->map_tag_max, 3); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("reset_ids"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->atom->map_tag_max, 2); + ASSERT_EQ(lmp->atom->tag_consecutive(), 1); } TEST_F(AtomStyleTest, charge) From 753eb9b76d8e70cb6cd93cc2b4ded3c69cedd67e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 21:17:42 -0400 Subject: [PATCH 23/53] add tests for atom style charge --- unittest/formats/CMakeLists.txt | 8 +- unittest/formats/test_atom_styles.cpp | 132 ++++++++++++++++++++++++++ 2 files changed, 136 insertions(+), 4 deletions(-) diff --git a/unittest/formats/CMakeLists.txt b/unittest/formats/CMakeLists.txt index 96b3abee62..aaf6731855 100644 --- a/unittest/formats/CMakeLists.txt +++ b/unittest/formats/CMakeLists.txt @@ -1,13 +1,13 @@ +add_executable(test_atom_styles test_atom_styles.cpp) +target_link_libraries(test_atom_styles PRIVATE lammps GTest::GMock GTest::GTest) +add_test(NAME AtomStyles COMMAND test_atom_styles WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + add_executable(test_potential_file_reader test_potential_file_reader.cpp) target_link_libraries(test_potential_file_reader PRIVATE lammps GTest::GMock GTest::GTest) add_test(NAME PotentialFileReader COMMAND test_potential_file_reader WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set_tests_properties(PotentialFileReader PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}") -add_executable(test_atom_styles test_atom_styles.cpp) -target_link_libraries(test_atom_styles PRIVATE lammps GTest::GMock GTest::GTest) -add_test(NAME AtomStyles COMMAND test_atom_styles WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - if (PKG_MANYBODY) add_executable(test_eim_potential_file_reader test_eim_potential_file_reader.cpp) target_link_libraries(test_eim_potential_file_reader PRIVATE lammps GTest::GMock GTest::GTest) diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp index bed60fb1c7..93ff1c4b1d 100644 --- a/unittest/formats/test_atom_styles.cpp +++ b/unittest/formats/test_atom_styles.cpp @@ -594,6 +594,138 @@ TEST_F(AtomStyleTest, charge) ASSERT_EQ(lmp->atom->map_style, 0); ASSERT_EQ(lmp->atom->map_user, 0); ASSERT_EQ(lmp->atom->map_tag_max, -1); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("create_box 2 box"); + lmp->input->one("create_atoms 1 single -2.0 2.0 0.1"); + lmp->input->one("create_atoms 1 single -2.0 -2.0 -0.1"); + lmp->input->one("create_atoms 2 single 2.0 2.0 -0.1"); + lmp->input->one("create_atoms 2 single 2.0 -2.0 0.1"); + lmp->input->one("mass 1 4.0"); + lmp->input->one("mass 2 2.4"); + lmp->input->one("set atom 1 charge -0.5"); + lmp->input->one("set atom 2 charge 0.5"); + lmp->input->one("set atom 3 charge -1.0"); + lmp->input->one("set atom 4 charge 1.0"); + lmp->input->one("pair_coeff * *"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("charge")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 4); + ASSERT_EQ(lmp->atom->nlocal, 4); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->ntypes, 2); + + ASSERT_NE(lmp->atom->mass, nullptr); + ASSERT_NE(lmp->atom->mass_setflag, nullptr); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("pair_coeff * *"); + lmp->input->one("write_data test_atom_styles.data nocoeff"); + lmp->input->one("clear"); + lmp->input->one("atom_style charge"); + lmp->input->one("pair_style zero 4.0"); + lmp->input->one("units real"); + lmp->input->one("atom_modify map array"); + lmp->input->one("read_data test_atom_styles.data"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("charge")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 4); + ASSERT_EQ(lmp->atom->nlocal, 4); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->ntypes, 2); + ASSERT_EQ(lmp->atom->q_flag, 1); + ASSERT_NE(lmp->atom->sametag, nullptr); + ASSERT_EQ(lmp->atom->tag_consecutive(), 1); + ASSERT_EQ(lmp->atom->map_style, 1); + ASSERT_EQ(lmp->atom->map_user, 1); + ASSERT_EQ(lmp->atom->map_tag_max, 4); + + double **x = lmp->atom->x; + double **v = lmp->atom->v; + double *q = lmp->atom->q; + ASSERT_DOUBLE_EQ(x[0][0], -2.0); + ASSERT_DOUBLE_EQ(x[0][1], 2.0); + ASSERT_DOUBLE_EQ(x[0][2], 0.1); + ASSERT_DOUBLE_EQ(x[1][0], -2.0); + ASSERT_DOUBLE_EQ(x[1][1], -2.0); + ASSERT_DOUBLE_EQ(x[1][2], -0.1); + ASSERT_DOUBLE_EQ(x[2][0], 2.0); + ASSERT_DOUBLE_EQ(x[2][1], 2.0); + ASSERT_DOUBLE_EQ(x[2][2], -0.1); + ASSERT_DOUBLE_EQ(x[3][0], 2.0); + ASSERT_DOUBLE_EQ(x[3][1], -2.0); + ASSERT_DOUBLE_EQ(x[3][2], 0.1); + ASSERT_DOUBLE_EQ(v[0][0], 0.0); + ASSERT_DOUBLE_EQ(v[0][1], 0.0); + ASSERT_DOUBLE_EQ(v[0][2], 0.0); + ASSERT_DOUBLE_EQ(v[1][0], 0.0); + ASSERT_DOUBLE_EQ(v[1][1], 0.0); + ASSERT_DOUBLE_EQ(v[1][2], 0.0); + ASSERT_DOUBLE_EQ(v[2][0], 0.0); + ASSERT_DOUBLE_EQ(v[2][1], 0.0); + ASSERT_DOUBLE_EQ(v[2][2], 0.0); + ASSERT_DOUBLE_EQ(v[3][0], 0.0); + ASSERT_DOUBLE_EQ(v[3][1], 0.0); + ASSERT_DOUBLE_EQ(v[3][2], 0.0); + ASSERT_DOUBLE_EQ(q[0], -0.5); + ASSERT_DOUBLE_EQ(q[1], 0.5); + ASSERT_DOUBLE_EQ(q[2], -1.0); + ASSERT_DOUBLE_EQ(q[3], 1.0); + + ASSERT_DOUBLE_EQ(lmp->atom->mass[1], 4.0); + ASSERT_DOUBLE_EQ(lmp->atom->mass[2], 2.4); + ASSERT_EQ(lmp->atom->mass_setflag[1], 1); + ASSERT_EQ(lmp->atom->mass_setflag[2], 1); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("pair_coeff * *"); + lmp->input->one("group two id 2:4:2"); + lmp->input->one("delete_atoms group two compress no"); + lmp->input->one("write_restart test_atom_styles.restart"); + lmp->input->one("clear"); + lmp->input->one("read_restart test_atom_styles.restart"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("charge")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 2); + ASSERT_EQ(lmp->atom->nlocal, 2); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->ntypes, 2); + ASSERT_EQ(lmp->atom->tag_consecutive(), 0); + ASSERT_EQ(lmp->atom->map_tag_max, 3); + + x = lmp->atom->x; + v = lmp->atom->v; + q = lmp->atom->q; + ASSERT_DOUBLE_EQ(x[0][0], -2.0); + ASSERT_DOUBLE_EQ(x[0][1], 2.0); + ASSERT_DOUBLE_EQ(x[0][2], 0.1); + ASSERT_DOUBLE_EQ(x[1][0], 2.0); + ASSERT_DOUBLE_EQ(x[1][1], 2.0); + ASSERT_DOUBLE_EQ(x[1][2], -0.1); + ASSERT_DOUBLE_EQ(v[0][0], 0.0); + ASSERT_DOUBLE_EQ(v[0][1], 0.0); + ASSERT_DOUBLE_EQ(v[0][2], 0.0); + ASSERT_DOUBLE_EQ(v[1][0], 0.0); + ASSERT_DOUBLE_EQ(v[1][1], 0.0); + ASSERT_DOUBLE_EQ(v[1][2], 0.0); + ASSERT_DOUBLE_EQ(q[0], -0.5); + ASSERT_DOUBLE_EQ(q[1], -1.0); + + ASSERT_DOUBLE_EQ(lmp->atom->mass[1], 4.0); + ASSERT_DOUBLE_EQ(lmp->atom->mass[2], 2.4); + ASSERT_EQ(lmp->atom->mass_setflag[1], 1); + ASSERT_EQ(lmp->atom->mass_setflag[2], 1); } } // namespace LAMMPS_NS From d6ca98cb440e6b863090a53a76d05caa0a2e4cf8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 23:47:55 -0400 Subject: [PATCH 24/53] don't validate compiler flags provided with CMAKE_TUNE_FLAGS anymore closes #2084 --- cmake/CMakeLists.txt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index b34e3a4d1f..e323e3dfa1 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -335,15 +335,8 @@ endforeach() set(CMAKE_TUNE_FLAGS "${CMAKE_TUNE_DEFAULT}" CACHE STRING "Compiler specific optimization or instrumentation") separate_arguments(CMAKE_TUNE_FLAGS) -include(CheckCXXCompilerFlag) foreach(_FLAG ${CMAKE_TUNE_FLAGS}) - string(REGEX REPLACE "[=\"]" "" _FLAGX ${_FLAG}) - check_cxx_compiler_flag("${_FLAG}" COMPILER_SUPPORTS${_FLAGX}) - if(COMPILER_SUPPORTS${_FLAGX}) - target_compile_options(lammps PRIVATE ${_FLAG}) - else() - message(WARNING "${_FLAG} found in CMAKE_TUNE_FLAGS, but not supported by the compiler, skipping") - endif() + target_compile_options(lammps PRIVATE ${_FLAG}) endforeach() ######################################################################## # Basic system tests (standard libraries, headers, functions, types) # From 547137f7370b4852c83430ce6894a2411a93b9d4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Jun 2020 23:48:09 -0400 Subject: [PATCH 25/53] remove unused code --- src/atom_vec.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 7753a5f689..85fdbbbbfe 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -90,7 +90,7 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) AtomVec::~AtomVec() { - int datatype,cols,maxcols; + int datatype,cols; void *pdata; for (int i = 0; i < nargcopy; i++) delete [] argcopy[i]; @@ -100,14 +100,12 @@ AtomVec::~AtomVec() pdata = mgrow.pdata[i]; datatype = mgrow.datatype[i]; cols = mgrow.cols[i]; - const int nthreads = threads[i] ? comm->nthreads : 1; if (datatype == Atom::DOUBLE) { if (cols == 0) memory->destroy(*((double **) pdata)); else if (cols > 0) memory->destroy(*((double ***) pdata)); else { - maxcols = *(mgrow.maxcols[i]); memory->destroy(*((double ***) pdata)); } } else if (datatype == Atom::INT) { @@ -116,7 +114,6 @@ AtomVec::~AtomVec() else if (cols > 0) memory->destroy(*((int ***) pdata)); else { - maxcols = *(mgrow.maxcols[i]); memory->destroy(*((int ***) pdata)); } } else if (datatype == Atom::BIGINT) { @@ -125,7 +122,6 @@ AtomVec::~AtomVec() else if (cols > 0) memory->destroy(*((bigint ***) pdata)); else { - maxcols = *(mgrow.maxcols[i]); memory->destroy(*((bigint ***) pdata)); } } From 41995b4665bdb2706540d247a08ff849e1388ab1 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 11:45:26 -0400 Subject: [PATCH 26/53] avoid false positives about memory leaks in force tester tools --- unittest/force-styles/angle_style.cpp | 2 +- unittest/force-styles/bond_style.cpp | 2 +- unittest/force-styles/pair_style.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/unittest/force-styles/angle_style.cpp b/unittest/force-styles/angle_style.cpp index b38d23ce55..dd4588fa74 100644 --- a/unittest/force-styles/angle_style.cpp +++ b/unittest/force-styles/angle_style.cpp @@ -87,8 +87,8 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new if (!info->has_style(prerequisite.first, style)) ++nfail; } + delete info; if (nfail > 0) { - delete info; cleanup_lammps(lmp, cfg); return nullptr; } diff --git a/unittest/force-styles/bond_style.cpp b/unittest/force-styles/bond_style.cpp index c2db3b608b..7ba4a08705 100644 --- a/unittest/force-styles/bond_style.cpp +++ b/unittest/force-styles/bond_style.cpp @@ -87,8 +87,8 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new if (!info->has_style(prerequisite.first, style)) ++nfail; } + delete info; if (nfail > 0) { - delete info; cleanup_lammps(lmp, cfg); return nullptr; } diff --git a/unittest/force-styles/pair_style.cpp b/unittest/force-styles/pair_style.cpp index 81acd872b0..9354ad7f03 100644 --- a/unittest/force-styles/pair_style.cpp +++ b/unittest/force-styles/pair_style.cpp @@ -87,8 +87,8 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new if (!info->has_style(prerequisite.first, style)) ++nfail; } + delete info; if (nfail > 0) { - delete info; cleanup_lammps(lmp, cfg); return nullptr; } From b0842a3fea26f04b59959331d91b6c070804a168 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 11:45:56 -0400 Subject: [PATCH 27/53] tell GNU gcc to not try to optimize the atom style tester tool --- unittest/formats/test_atom_styles.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp index 93ff1c4b1d..e12bc5c1fc 100644 --- a/unittest/formats/test_atom_styles.cpp +++ b/unittest/formats/test_atom_styles.cpp @@ -22,6 +22,20 @@ #include #include +#if !defined(_FORTIFY_SOURCE) || (_FORTIFY_SOURCE == 0) +# if defined(__INTEL_COMPILER) +# define _do_nothing +# elif defined(__GNUC__) +# if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) +# pragma GCC optimize ("no-var-tracking-assignments","O0") +# else +# pragma GCC optimize ("no-var-tracking-assignments") +# endif +# else +# define _do_nothing +# endif +#endif + // whether to print verbose output (i.e. not capturing LAMMPS screen output). bool verbose = false; From b866ea68f663086a0ca21054579217b19241a4f2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 11:46:42 -0400 Subject: [PATCH 28/53] make sanitizers an explicit cmake option (again) so we can set the flags properly --- cmake/CMakeLists.txt | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index e323e3dfa1..e3569b1188 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -57,7 +57,6 @@ check_for_autogen_files(${LAMMPS_SOURCE_DIR}) # compiler tests # these need ot be done early (before further tests). ##################################################################### -include(CheckCCompilerFlag) include(CheckIncludeFileCXX) # set required compiler flags and compiler/CPU arch specific optimizations @@ -83,15 +82,6 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -# GNU compiler specific features for testing -if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) - mark_as_advanced(ENABLE_COVERAGE) - if(ENABLE_COVERAGE) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - endif() -endif() - ######################################################################## # User input options # ######################################################################## @@ -248,6 +238,28 @@ if(BUILD_OMP) target_link_libraries(lammps PRIVATE OpenMP::OpenMP_CXX) endif() +# Compiler specific features for testing +if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) + mark_as_advanced(ENABLE_COVERAGE) + if(ENABLE_COVERAGE) + target_compile_options(lammps PUBLIC --coverage) + target_link_options(lammps PUBLIC --coverage) + endif() +endif() +if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) + set(ENABLE_SANITIZER "none" CACHE STRING "Select a code sanitizer option (none (default), address, thread, undefined)") + mark_as_advanced(ENABLE_SANITIZER) + set(ENABLE_SANITIZER_VALUES none address thread undefined) + set_property(CACHE ENABLE_SANITIZER PROPERTY STRINGS ${ENABLE_SANITIZER_VALUES}) + validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES) + string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER) + if (NOT ENABLE_SANITIZER STREQUAL "none") + target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + endif() +endif() + if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE) enable_language(C) find_package(LAPACK) From 8816d7fe3e9b34587c3a40aef0880a4d2b7daaba Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 11:52:33 -0400 Subject: [PATCH 29/53] plug small memory leak in pair style eam/cd --- src/MANYBODY/pair_eam_cd.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/MANYBODY/pair_eam_cd.cpp b/src/MANYBODY/pair_eam_cd.cpp index eb8fc4e768..102e2a62f3 100644 --- a/src/MANYBODY/pair_eam_cd.cpp +++ b/src/MANYBODY/pair_eam_cd.cpp @@ -62,7 +62,7 @@ PairEAMCD::~PairEAMCD() { memory->destroy(rhoB); memory->destroy(D_values); - if (hcoeff) delete[] hcoeff; + delete[] hcoeff; } void PairEAMCD::compute(int eflag, int vflag) @@ -521,6 +521,7 @@ void PairEAMCD::read_h_coeff(char *filename) if ((int)values.count() != nhcoeff + 1 || nhcoeff < 1) error->one(FLERR, "Failed to read h(x) function coefficients in EAM file."); + delete[] hcoeff; hcoeff = new double[nhcoeff]; int i = 0; @@ -534,7 +535,10 @@ void PairEAMCD::read_h_coeff(char *filename) } MPI_Bcast(&nhcoeff, 1, MPI_INT, 0, world); - if (comm->me != 0) hcoeff = new double[nhcoeff]; + if (comm->me != 0) { + delete[] hcoeff; + hcoeff = new double[nhcoeff]; + } MPI_Bcast(hcoeff, nhcoeff, MPI_DOUBLE, 0, world); } From 786473a1896e9002015cc4b08d9b82f6f72acf61 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 12:39:23 -0400 Subject: [PATCH 30/53] allow sanitizers also be active for force style test codes --- unittest/force-styles/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/unittest/force-styles/CMakeLists.txt b/unittest/force-styles/CMakeLists.txt index c7937336f2..535e1fb2f1 100644 --- a/unittest/force-styles/CMakeLists.txt +++ b/unittest/force-styles/CMakeLists.txt @@ -15,6 +15,11 @@ if(BUILD_MPI) else() target_link_libraries(style_tests PUBLIC mpi_stubs) endif() +# propagate sanitizer options to test tools +if (NOT ENABLE_SANITIZER STREQUAL "none") + target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) +endif() # unit test for error stats class add_executable(test_error_stats test_error_stats.cpp) From 5e597e551b7c9bf815c91642d7f35b23a8b5a53f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 12:39:40 -0400 Subject: [PATCH 31/53] avoid false positive --- unittest/formats/test_eim_potential_file_reader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/unittest/formats/test_eim_potential_file_reader.cpp b/unittest/formats/test_eim_potential_file_reader.cpp index 3efa7a3143..bf0d9ba8dd 100644 --- a/unittest/formats/test_eim_potential_file_reader.cpp +++ b/unittest/formats/test_eim_potential_file_reader.cpp @@ -48,6 +48,7 @@ protected: // check if the prerequisite eim pair style is available Info *info = new Info(lmp); ASSERT_TRUE(info->has_style("pair", "eim")); + delete info; int npair = nelements * (nelements + 1) / 2; setfl.ielement = new int[nelements]; From bfe42e3fbe351ac7dc04efca90d281b2d289196b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 12:40:08 -0400 Subject: [PATCH 32/53] make sure delete gc[n] is safe --- src/KSPACE/msm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KSPACE/msm.cpp b/src/KSPACE/msm.cpp index 1520c2c607..70a36984d7 100644 --- a/src/KSPACE/msm.cpp +++ b/src/KSPACE/msm.cpp @@ -685,7 +685,7 @@ void MSM::allocate() nxlo_out[n],nxhi_out[n],nylo_out[n],nyhi_out[n],nzlo_out[n],nzhi_out[n], procneigh[0][0],procneigh[0][1],procneigh[1][0], procneigh[1][1],procneigh[2][0],procneigh[2][1]); - } + } else cg[n] = nullptr; } } From a42c68892fb537726b8ea1f8b2546b89713ef672 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 13:09:58 -0400 Subject: [PATCH 33/53] address memory leak and C versus C++ programming issues in pair style polymorphic --- src/MANYBODY/pair_polymorphic.cpp | 58 ++++++++++++--------- src/MANYBODY/pair_polymorphic.h | 86 +++++++++++++++++-------------- 2 files changed, 81 insertions(+), 63 deletions(-) diff --git a/src/MANYBODY/pair_polymorphic.cpp b/src/MANYBODY/pair_polymorphic.cpp index a3f6d08522..502580719a 100644 --- a/src/MANYBODY/pair_polymorphic.cpp +++ b/src/MANYBODY/pair_polymorphic.cpp @@ -47,26 +47,26 @@ PairPolymorphic::PairPolymorphic(LAMMPS *lmp) : Pair(lmp) one_coeff = 1; nelements = 0; - elements = NULL; - match = NULL; - pairParameters = NULL; - tripletParameters = NULL; - elem2param = NULL; - elem3param = NULL; - map = NULL; + elements = nullptr; + match = nullptr; + pairParameters = nullptr; + tripletParameters = nullptr; + elem2param = nullptr; + elem3param = nullptr; + map = nullptr; epsilon = 0.0; neighsize = 0; - firstneighV = NULL; - firstneighW = NULL; - firstneighW1 = NULL; - delxV = NULL; - delyV = NULL; - delzV = NULL; - drV = NULL; - delxW = NULL; - delyW = NULL; - delzW = NULL; - drW = NULL; + firstneighV = nullptr; + firstneighW = nullptr; + firstneighW1 = nullptr; + delxV = nullptr; + delyV = nullptr; + delzV = nullptr; + drV = nullptr; + delxW = nullptr; + delyW = nullptr; + delzW = nullptr; + drW = nullptr; } /* ---------------------------------------------------------------------- @@ -79,8 +79,10 @@ PairPolymorphic::~PairPolymorphic() for (int i = 0; i < nelements; i++) delete [] elements[i]; delete [] elements; delete [] match; - memory->destroy(pairParameters); - memory->destroy(tripletParameters); + + delete [] pairParameters; + delete [] tripletParameters; + memory->destroy(elem2param); memory->destroy(elem3param); if (allocated) { @@ -487,7 +489,7 @@ void PairPolymorphic::coeff(int narg, char **arg) delete [] elements; } elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = NULL; + for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; nelements = 0; for (i = 3; i < narg; i++) { @@ -581,6 +583,7 @@ void PairPolymorphic::read_file(char *file) eta = values.next_int(); // map the elements in the potential file to LAMMPS atom types + delete [] match; match = new int[nelements]; for (int i = 0; i < nelements; i++) { @@ -617,8 +620,10 @@ void PairPolymorphic::read_file(char *file) // cutoffs npair = nelements*(nelements+1)/2; ntriple = nelements*nelements*nelements; - pairParameters = (PairParameters*) memory->srealloc(pairParameters,npair*sizeof(PairParameters), "pair:pairParameters"); - tripletParameters = (TripletParameters*) memory->srealloc(tripletParameters,ntriple*sizeof(TripletParameters), "pair:tripletParameters"); + delete [] pairParameters; + delete [] tripletParameters; + pairParameters = new PairParameters[npair]; + tripletParameters = new TripletParameters[ntriple]; for (int i = 0; i < npair; i++) { PairParameters & p = pairParameters[i]; @@ -641,9 +646,12 @@ void PairPolymorphic::read_file(char *file) MPI_Bcast(&ntriple, 1, MPI_INT, 0, world); if(comm->me != 0) { + delete [] match; match = new int[nelements]; - pairParameters = (PairParameters*) memory->srealloc(pairParameters,npair*sizeof(PairParameters), "pair:pairParameters"); - tripletParameters = (TripletParameters*) memory->srealloc(tripletParameters,ntriple*sizeof(TripletParameters), "pair:tripletParameters"); + delete [] pairParameters; + delete [] tripletParameters; + pairParameters = new PairParameters[npair]; + tripletParameters = new TripletParameters[ntriple]; } MPI_Bcast(match, nelements, MPI_INT, 0, world); diff --git a/src/MANYBODY/pair_polymorphic.h b/src/MANYBODY/pair_polymorphic.h index b4ff169b76..18956699d7 100644 --- a/src/MANYBODY/pair_polymorphic.h +++ b/src/MANYBODY/pair_polymorphic.h @@ -50,14 +50,14 @@ class PairPolymorphic : public Pair { xmax = 0.0; xmaxsq = xmax*xmax; vmax = 0.0; - xs = NULL; - ys = NULL; - ys1 = NULL; - ys2 = NULL; - ys3 = NULL; - ys4 = NULL; - ys5 = NULL; - ys6 = NULL; + xs = nullptr; + ys = nullptr; + ys1 = nullptr; + ys2 = nullptr; + ys3 = nullptr; + ys4 = nullptr; + ys5 = nullptr; + ys6 = nullptr; } tabularFunction(int n) { size = n; @@ -88,14 +88,14 @@ class PairPolymorphic : public Pair { ys6 = new double[n]; } virtual ~tabularFunction() { - if (xs) delete [] xs; - if (ys) delete [] ys; - if (ys1) delete [] ys1; - if (ys2) delete [] ys2; - if (ys3) delete [] ys3; - if (ys4) delete [] ys4; - if (ys5) delete [] ys5; - if (ys6) delete [] ys6; + delete [] xs; + delete [] ys; + delete [] ys1; + delete [] ys2; + delete [] ys3; + delete [] ys4; + delete [] ys5; + delete [] ys6; } void set_xrange(double x1, double x2) { xmin = x1; @@ -198,21 +198,21 @@ class PairPolymorphic : public Pair { void resize(int n) { if (n != size) { size = n; - if (xs) delete [] xs; + delete [] xs; xs = new double[n]; - if (ys) delete [] ys; + delete [] ys; ys = new double[n]; - if (ys1) delete [] ys1; + delete [] ys1; ys1 = new double[n]; - if (ys2) delete [] ys2; + delete [] ys2; ys2 = new double[n]; - if (ys3) delete [] ys3; + delete [] ys3; ys3 = new double[n]; - if (ys4) delete [] ys4; + delete [] ys4; ys4 = new double[n]; - if (ys5) delete [] ys5; + delete [] ys5; ys5 = new double[n]; - if (ys6) delete [] ys6; + delete [] ys6; ys6 = new double[n]; } } @@ -248,35 +248,45 @@ class PairPolymorphic : public Pair { } int size; double xmin,xmax,xmaxsq,rdx,vmax; - double * ys, * ys1, * ys2, * ys3, * ys4, * ys5, * ys6; - double * xs; + double *ys, *ys1, *ys2, *ys3, *ys4, *ys5, *ys6; + double *xs; }; struct PairParameters { double cut; double cutsq; double xi; - class tabularFunction * U; - class tabularFunction * V; - class tabularFunction * W; - class tabularFunction * F; + class tabularFunction *U; + class tabularFunction *V; + class tabularFunction *W; + class tabularFunction *F; PairParameters() { cut = 0.0; cutsq = 0.0; xi = 1.0; - U = NULL; - V = NULL; - W = NULL; - F = NULL; + U = nullptr; + V = nullptr; + W = nullptr; + F = nullptr; }; + ~PairParameters() { + delete U; + delete V; + delete W; + delete F; + } }; struct TripletParameters { - class tabularFunction * P; - class tabularFunction * G; + class tabularFunction *P; + class tabularFunction *G; TripletParameters() { - P = NULL; - G = NULL; + P = nullptr; + G = nullptr; }; + ~TripletParameters() { + delete P; + delete G; + } }; double epsilon; From dfe860c4bb7ca2bea5c483084a157bf527ae366d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 13:34:34 -0400 Subject: [PATCH 34/53] update coding style --- unittest/formats/test_atom_styles.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp index e12bc5c1fc..614a72e678 100644 --- a/unittest/formats/test_atom_styles.cpp +++ b/unittest/formats/test_atom_styles.cpp @@ -23,17 +23,17 @@ #include #if !defined(_FORTIFY_SOURCE) || (_FORTIFY_SOURCE == 0) -# if defined(__INTEL_COMPILER) -# define _do_nothing -# elif defined(__GNUC__) -# if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) -# pragma GCC optimize ("no-var-tracking-assignments","O0") -# else -# pragma GCC optimize ("no-var-tracking-assignments") -# endif -# else -# define _do_nothing -# endif +#if defined(__INTEL_COMPILER) +#define _do_nothing +#elif defined(__GNUC__) +#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) +#pragma GCC optimize("no-var-tracking-assignments", "O0") +#else +#pragma GCC optimize("no-var-tracking-assignments") +#endif +#else +#define _do_nothing +#endif #endif // whether to print verbose output (i.e. not capturing LAMMPS screen output). @@ -691,7 +691,7 @@ TEST_F(AtomStyleTest, charge) ASSERT_DOUBLE_EQ(q[0], -0.5); ASSERT_DOUBLE_EQ(q[1], 0.5); ASSERT_DOUBLE_EQ(q[2], -1.0); - ASSERT_DOUBLE_EQ(q[3], 1.0); + ASSERT_DOUBLE_EQ(q[3], 1.0); ASSERT_DOUBLE_EQ(lmp->atom->mass[1], 4.0); ASSERT_DOUBLE_EQ(lmp->atom->mass[2], 2.4); From b83fab92bf0ffeca3cbe49744cc65ebdecac1449 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 13:35:07 -0400 Subject: [PATCH 35/53] document coding style and sanitizing options --- doc/src/Build_development.rst | 86 ++++++++++++++++++++++++++--------- 1 file changed, 64 insertions(+), 22 deletions(-) diff --git a/doc/src/Build_development.rst b/doc/src/Build_development.rst index cf7d8c7955..deb9d5b3cb 100644 --- a/doc/src/Build_development.rst +++ b/doc/src/Build_development.rst @@ -8,8 +8,8 @@ useful during development, testing or debugging. .. _compilation: -Verify compilation flags ------------------------- +Monitor compilation flags +------------------------- Sometimes it is necessary to verify the complete sequence of compilation flags generated by the CMake build. To enable a more verbose output during @@ -19,7 +19,8 @@ compilation you can use the following option. -D CMAKE_VERBOSE_MAKEFILE=value # value = no (default) or yes -Another way of doing this without reconfiguration is calling make with variable VERBOSE set to 1: +Another way of doing this without reconfiguration is calling make with +variable VERBOSE set to 1: .. code-block:: bash @@ -33,25 +34,26 @@ Address, Undefined Behavior, and Thread Sanitizer Support --------------------------------------------------------- Compilers such as GCC and Clang support generating instrumented binaries -which use different sanitizer libraries to detect problems in code +which use different sanitizer libraries to detect problems in the code during run-time. They can detect issues like: - `memory leaks `_ - `undefined behavior `_ - `data races `_ -Please note that this kind of instrumentation usually comes with a small -performance hit (much less than using tools like `Valgrind -`_). The to enable these features additional -compiler flags need to be added to the compilation and linking stages. -This is most easily done through setting the ``CMAKE_TUNE_FLAGS`` -variable during configuration. Examples: +Please note that this kind of instrumentation usually comes with a +performance hit (but much less than using tools like `Valgrind +`_ with a more low level approach). The to enable +these features additional compiler flags need to be added to the +compilation and linking stages. This is done through setting the +``ENABLE_SANITIZER`` variable during configuration. Examples: .. code-block:: bash - -D CMAKE_TUNE_FLAGS=-fsanitize=address # enable address sanitizer / memory leak checker - -D CMAKE_TUNE_FLAGS=-fsanitize=undefined # enable undefined behavior sanitizer - -D CMAKE_TUNE_FLAGS=-fsanitize=thread # enable thread sanitizer + -D ENABLE_SANITIZER=none # no sanitizer active (default) + -D ENABLE_SANITIZER=address # enable address sanitizer / memory leak checker + -D ENABLE_SANITIZER=undefined # enable undefined behavior sanitizer + -D ENABLE_SANITIZER=thread # enable thread sanitizer ---------- @@ -86,19 +88,21 @@ The output of this command will be looking something like this:: [...]$ ctest Test project /home/akohlmey/compile/lammps/build-testing Start 1: MolPairStyle:hybrid-overlay - 1/26 Test #1: MolPairStyle:hybrid-overlay ......... Passed 0.02 sec + 1/109 Test #1: MolPairStyle:hybrid-overlay ......... Passed 0.02 sec Start 2: MolPairStyle:hybrid - 2/26 Test #2: MolPairStyle:hybrid ................. Passed 0.01 sec + 2/109 Test #2: MolPairStyle:hybrid ................. Passed 0.01 sec Start 3: MolPairStyle:lj_class2 [...] - Start 25: AngleStyle:harmonic - 25/26 Test #25: AngleStyle:harmonic ................. Passed 0.01 sec - Start 26: AngleStyle:zero - 26/26 Test #26: AngleStyle:zero ..................... Passed 0.01 sec + Start 107: PotentialFileReader + 107/109 Test #107: PotentialFileReader ................ Passed 0.04 sec + Start 108: EIMPotentialFileReader + 108/109 Test #108: EIMPotentialFileReader ............. Passed 0.03 sec + Start 109: TestSimpleCommands + 109/109 Test #109: TestSimpleCommands ................. Passed 0.02 sec 100% tests passed, 0 tests failed out of 26 - Total Test time (real) = 0.27 sec + Total Test time (real) = 25.57 sec The ``ctest`` command has many options, the most important ones are: @@ -193,8 +197,8 @@ In this particular case, 5 out of 6 sets of tests were conducted, the tests for the ``lj/cut/opt`` pair style was skipped, since the tests executable did not include it. To learn what individual tests are performed, you (currently) need to read the source code. You can use code coverage -recording (see next section) to confirm how well the tests cover the individual -source files. +recording (see next section) to confirm how well the tests cover the code +paths in the individual source files. The force style test programs have a common set of options: @@ -211,6 +215,14 @@ The force style test programs have a common set of options: * - -v - verbose output: also print the executed LAMMPS commands +The ``ctest`` tool has no mechanism to directly pass flags to the individual +test programs, but a workaround has been implmented where these flags can be +set in an environment variable ``TEST_ARGS``. Example: + +.. code-block:: bash + + env TEST_ARGS=-s ctest -V -R BondStyle + To add a test for a style that is not yet covered, it is usually best to copy a YAML file for a similar style to a new file, edit the details of the style (how to call it, how to set its coefficients) and then @@ -244,6 +256,16 @@ and working. of mis-compiled code (or an undesired large loss of precision due to significant reordering of operations and thus less error cancellation). +Tests for other components and utility functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Additional tests that validate utility functions or specific components +of LAMMPS are implemented as standalone executable which may, or may not +require creating a suitable LAMMPS instance. These tests are more specific +and do not require YAML format input files. To add a test, either an +existing source file needs to be extended or a new file added, which in turn +requires additions to the ``CMakeLists.txt`` file in the source folder. + Collect and visualize code coverage metrics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -306,3 +328,23 @@ The images below illustrate how the data is presented. :target: JPG/coverage-file-branches.png Source page with branches + +Coding style utilities +---------------------- + +To aid with enforcing some of the coding style conventions in LAMMPS +some additional build targets have been added. These require Python 3.5 +or later and will only work on Unix-like operating and file systems. +The following options are available. + +.. code-block:: bash + + make check-whitespace # generate coverage report in HTML format + make fix-whitespace # generate coverage report in XML format + make check-permissions # delete folder with HTML format coverage report + make fix-permissions # delete all collected coverage data and HTML output + +For the code in the ``unittest`` tree we are using the `clang-format` +tool (Clang version 8.0 or later is required). If available, the source +code files in the ``unittest`` tree can be updated to conform to the +formatting settings using ``make format-tests``. From fcdd2c50268f5ce9a1621db8890f9f3a41a12717 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 16:13:02 -0400 Subject: [PATCH 36/53] prevent memory leaks in pair style tersoff/table --- src/USER-MISC/pair_tersoff_table.cpp | 41 +++++++++++++++++----------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/USER-MISC/pair_tersoff_table.cpp b/src/USER-MISC/pair_tersoff_table.cpp index 57c897bdfc..8ab64b1d5a 100644 --- a/src/USER-MISC/pair_tersoff_table.cpp +++ b/src/USER-MISC/pair_tersoff_table.cpp @@ -61,14 +61,21 @@ PairTersoffTable::PairTersoffTable(LAMMPS *lmp) : Pair(lmp) manybody_flag = 1; nelements = 0; - elements = NULL; + elements = nullptr; nparams = maxparam = 0; - params = NULL; - elem2param = NULL; + params = nullptr; + elem2param = nullptr; allocated = 0; - preGtetaFunction = preGtetaFunctionDerived = NULL; - preCutoffFunction = preCutoffFunctionDerived = NULL; + preGtetaFunction = preGtetaFunctionDerived = nullptr; + preCutoffFunction = preCutoffFunctionDerived = nullptr; + exponential = nullptr; + gtetaFunction = nullptr; + gtetaFunctionDerived = nullptr; + cutoffFunction = nullptr; + cutoffFunctionDerived = nullptr; + betaZetaPower = nullptr; + betaZetaPowerDerived = nullptr; } /* ---------------------------------------------------------------------- @@ -88,9 +95,9 @@ PairTersoffTable::~PairTersoffTable() memory->destroy(cutsq); delete [] map; - deallocateGrids(); - deallocatePreLoops(); } + deallocateGrids(); + deallocatePreLoops(); } /* ---------------------------------------------------------------------- */ @@ -525,13 +532,15 @@ void PairTersoffTable::deallocatePreLoops(void) void PairTersoffTable::allocatePreLoops(void) { - memory->create(preGtetaFunction,leadingDimensionInteractionList,leadingDimensionInteractionList,"tersofftable:preGtetaFunction"); - - memory->create(preGtetaFunctionDerived,leadingDimensionInteractionList,leadingDimensionInteractionList,"tersofftable:preGtetaFunctionDerived"); - - memory->create(preCutoffFunction,leadingDimensionInteractionList,"tersofftable:preCutoffFunction"); - - memory->create(preCutoffFunctionDerived,leadingDimensionInteractionList,"tersofftable:preCutoffFunctionDerived"); + deallocatePreLoops(); + memory->create(preGtetaFunction,leadingDimensionInteractionList, + leadingDimensionInteractionList,"tersofftable:preGtetaFunction"); + memory->create(preGtetaFunctionDerived,leadingDimensionInteractionList, + leadingDimensionInteractionList,"tersofftable:preGtetaFunctionDerived"); + memory->create(preCutoffFunction,leadingDimensionInteractionList, + "tersofftable:preCutoffFunction"); + memory->create(preCutoffFunctionDerived,leadingDimensionInteractionList, + "tersofftable:preCutoffFunctionDerived"); } void PairTersoffTable::deallocateGrids() @@ -557,6 +566,8 @@ void PairTersoffTable::allocateGrids(void) double r, minMu, maxLambda, maxCutoff; double const PI=acos(-1.0); + deallocateGrids(); + // exponential // find min and max argument @@ -569,9 +580,7 @@ void PairTersoffTable::allocateGrids(void) maxCutoff=cutmax; minArgumentExponential=minMu*GRIDSTART; - numGridPointsExponential=(int)((maxLambda*maxCutoff-minArgumentExponential)*GRIDDENSITY_EXP)+2; - memory->create(exponential,numGridPointsExponential,"tersofftable:exponential"); r = minArgumentExponential; From 328709513bd5d74f4b0653b221c3508ef6face8b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 16:31:05 -0400 Subject: [PATCH 37/53] plug memory leaks in pair style comb and comb3 --- src/MANYBODY/pair_comb.cpp | 12 ++++++++++++ src/MANYBODY/pair_comb3.cpp | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 201b325bf3..d966fa723f 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -1335,6 +1335,18 @@ void PairComb::sm_table() // allocate arrays + memory->sfree(sht_first); + memory->destroy(intype); + memory->destroy(fafb); + memory->destroy(dfafb); + memory->destroy(ddfafb); + memory->destroy(phin); + memory->destroy(dphin); + memory->destroy(erpaw); + memory->destroy(NCo); + memory->destroy(bbij); + memory->destroy(sht_num); + memory->create(intype,n,n,"pair:intype"); memory->create(fafb,ncoul,nntypes,"pair:fafb"); memory->create(dfafb,ncoul,nntypes,"pair:dfafb"); diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index 5b039c8eb5..e5f729f19a 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -2258,6 +2258,26 @@ void PairComb3::tables() int n = nelements; + memory->destroy(intype); + memory->destroy(erpaw); + memory->destroy(fafb); + memory->destroy(dfafb); + memory->destroy(ddfafb); + memory->destroy(phin); + memory->destroy(dphin); + memory->destroy(afb); + memory->destroy(dafb); + memory->destroy(vvdw); + memory->destroy(vdvdw); + memory->destroy(dpl); + memory->destroy(bbij); + memory->destroy(xcctmp); + memory->destroy(xchtmp); + memory->destroy(xcotmp); + memory->destroy(NCo); + memory->destroy(sht_num); + memory->sfree(sht_first); + dra = 0.001; drin = 0.100; drbuf = 0.100; From 02ffa46fa7b0343ddfe39782a0cbe54d048cd6b9 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 17:12:51 -0400 Subject: [PATCH 38/53] simplify memory management and plug leaks in pair style bop --- src/MANYBODY/pair_bop.cpp | 57 +++++++++++---------------------------- src/MANYBODY/pair_bop.h | 2 -- 2 files changed, 15 insertions(+), 44 deletions(-) diff --git a/src/MANYBODY/pair_bop.cpp b/src/MANYBODY/pair_bop.cpp index d922cf6d33..21630ad001 100644 --- a/src/MANYBODY/pair_bop.cpp +++ b/src/MANYBODY/pair_bop.cpp @@ -257,12 +257,8 @@ PairBOP::~PairBOP() memory->destroy(gfunc6); memory->destroy(gpara); } - if(allocate_sigma) { - destroy_sigma(); - } - if(allocate_pi) { - destroy_pi(); - } + memory->destroy(bt_sg); + memory->destroy(bt_pi); } /* ---------------------------------------------------------------------- */ @@ -635,8 +631,6 @@ void PairBOP::coeff(int narg, char **arg) bop_step=0; nb_pi=0; nb_sg=0; - allocate_sigma=0; - allocate_pi=0; allocate_neigh=0; update_list=0; maxnall=0; @@ -768,19 +762,18 @@ void PairBOP::gneigh() int *type = atom->type; if(allocate_neigh==0) { - memory->create (BOP_index,nall,"BOP_index"); - memory->create (BOP_index3,nall,"BOP_index3"); - memory->create (BOP_total,nall,"BOP_total"); - memory->create (BOP_total3,nall,"BOP_total"); - if (otfly==0) memory->create (cos_index,nall,"cos_index"); + memory->create(BOP_index,nall,"BOP_index"); + memory->create(BOP_index3,nall,"BOP_index3"); + memory->create(BOP_total,nall,"BOP_total"); + memory->create(BOP_total3,nall,"BOP_total"); + if (otfly==0) memory->create(cos_index,nall,"cos_index"); allocate_neigh=1; - } - else { - memory->grow (BOP_index,nall,"BOP_index"); - memory->grow (BOP_index3,nall,"BOP_index3"); - memory->grow (BOP_total,nall,"BOP_total"); - memory->grow (BOP_total3,nall,"BOP_total3"); - if (otfly==0) memory->grow (cos_index,nall,"cos_index"); + } else { + memory->grow(BOP_index,nall,"BOP_index"); + memory->grow(BOP_index3,nall,"BOP_index3"); + memory->grow(BOP_total,nall,"BOP_total"); + memory->grow(BOP_total3,nall,"BOP_total3"); + if (otfly==0) memory->grow(cos_index,nall,"cos_index"); allocate_neigh=1; } ilist = list->ilist; @@ -1140,10 +1133,6 @@ double PairBOP::sigmaBo(int itmp, int jtmp) if(nb_sg==0) { nb_sg=(maxneigh)*(maxneigh/2); } - if(allocate_sigma) { - destroy_sigma(); - } - create_sigma(nb_sg); sigB=0; if(itmpdestroy(bt_pi); bt_pi = (B_PI *) memory->smalloc(n_tot*sizeof(B_PI),"BOP:bt_pi"); - allocate_pi=1; } void PairBOP::create_sigma(int n_tot) -{ - bt_sg = (B_SG *) memory->smalloc(n_tot*sizeof(B_SG),"BOP:bt_sg"); - allocate_sigma=1; -} - -void PairBOP::destroy_pi() -{ - memory->destroy(bt_pi); - allocate_pi=0; -} - -void PairBOP::destroy_sigma() { memory->destroy(bt_sg); - allocate_sigma=0; + bt_sg = (B_SG *) memory->smalloc(n_tot*sizeof(B_SG),"BOP:bt_sg"); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_bop.h b/src/MANYBODY/pair_bop.h index 2d6962e27c..d61c969094 100644 --- a/src/MANYBODY/pair_bop.h +++ b/src/MANYBODY/pair_bop.h @@ -58,8 +58,6 @@ class PairBOP : public Pair { int ***elem2param; int nparams; int bop_step; - int allocate_pi; - int allocate_sigma; int allocate_neigh; int nb_pi,nb_sg; int ago1; From f78671c1a4d81e5907e929c9341d784e03881bd6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Jun 2020 23:43:16 -0400 Subject: [PATCH 39/53] reorganize memory (de-)allocation and fix substantial memory leak in MSM --- src/KSPACE/msm.cpp | 195 ++++++++++++++++++++++----------------------- 1 file changed, 95 insertions(+), 100 deletions(-) diff --git a/src/KSPACE/msm.cpp b/src/KSPACE/msm.cpp index 70a36984d7..abc8ca1150 100644 --- a/src/KSPACE/msm.cpp +++ b/src/KSPACE/msm.cpp @@ -28,6 +28,8 @@ #include "domain.h" #include "memory.h" #include "error.h" +#include "utils.h" +#include "fmt/format.h" #include "math_const.h" @@ -63,9 +65,6 @@ MSM::MSM(LAMMPS *lmp) : KSpace(lmp), factors[0] = 2; MPI_Comm_rank(world,&me); - procneigh_levels = NULL; - world_levels = NULL; - active_flag = NULL; phi1d = dphi1d = NULL; @@ -81,15 +80,7 @@ MSM::MSM(LAMMPS *lmp) : KSpace(lmp), v0_direct_top = v1_direct_top = v2_direct_top = NULL; v3_direct_top = v4_direct_top = v5_direct_top = NULL; - cg_all = cg_peratom_all = NULL; - cg = cg_peratom = NULL; - ngrid = NULL; - cg = NULL; - cg_peratom = NULL; - procneigh_levels = NULL; - world_levels = NULL; - active_flag = NULL; alpha = betax = betay = betaz = NULL; nx_msm = ny_msm = nz_msm = NULL; @@ -150,10 +141,7 @@ MSM::~MSM() void MSM::init() { - if (me == 0) { - if (screen) fprintf(screen,"MSM initialization ...\n"); - if (logfile) fprintf(logfile,"MSM initialization ...\n"); - } + if (me == 0) utils::logmesg(lmp,"MSM initialization ...\n"); // error check @@ -169,13 +157,8 @@ void MSM::init() if ((slabflag == 1) && (me == 0)) error->warning(FLERR,"Slab correction not needed for MSM"); - if (order < 4 || order > 10) { - char str[128]; - sprintf(str,"MSM order must be 4, 6, 8, or 10"); - error->all(FLERR,str); - } - - if (order%2 != 0) error->all(FLERR,"MSM order must be 4, 6, 8, or 10"); + if ((order < 4) || (order > 10) || (order%2 != 0)) + error->all(FLERR,"MSM order must be 4, 6, 8, or 10"); if (sizeof(FFT_SCALAR) != 8) error->all(FLERR,"Cannot (yet) use single precision with MSM " @@ -221,33 +204,14 @@ void MSM::init() MPI_Allreduce(&ngrid[0],&ngrid_max,1,MPI_INT,MPI_MAX,world); if (me == 0) { - if (screen) { - fprintf(screen," 3d grid size/proc = %d\n", - ngrid_max); - fprintf(screen," estimated absolute RMS force accuracy = %g\n", - estimated_error); - fprintf(screen," estimated relative force accuracy = %g\n", - estimated_error/two_charge_force); - } - if (logfile) { - fprintf(logfile," 3d grid size/proc = %d\n", - ngrid_max); - fprintf(logfile," estimated absolute RMS force accuracy = %g\n", - estimated_error); - fprintf(logfile," estimated relative force accuracy = %g\n", - estimated_error/two_charge_force); - } - } - - if (me == 0) { - if (screen) { - fprintf(screen," grid = %d %d %d\n",nx_msm[0],ny_msm[0],nz_msm[0]); - fprintf(screen," order = %d\n",order); - } - if (logfile) { - fprintf(logfile," grid = %d %d %d\n",nx_msm[0],ny_msm[0],nz_msm[0]); - fprintf(logfile," order = %d\n",order); - } + std::string mesg = fmt::format(" 3d grid size/proc = {}\n", ngrid_max); + mesg += fmt::format(" estimated absolute RMS force accuracy = {}\n", + estimated_error); + mesg += fmt::format(" estimated relative force accuracy = {}\n", + estimated_error/two_charge_force); + mesg += fmt::format(" grid = {} {} {}\n",nx_msm[0],ny_msm[0],nz_msm[0]); + mesg += fmt::format(" order = {}\n",order); + utils::logmesg(lmp,mesg); } } @@ -398,7 +362,6 @@ void MSM::setup() nmax_direct = 8*(nxhi_direct+1)*(nyhi_direct+1)*(nzhi_direct+1); - deallocate(); if (peratom_allocate_flag) deallocate_peratom(); // compute direct sum interaction weights @@ -649,6 +612,8 @@ void MSM::compute(int eflag, int vflag) void MSM::allocate() { + deallocate(); + // interpolation coeffs order_allocated = order; @@ -670,9 +635,9 @@ void MSM::allocate() // allocate memory for each grid level for (int n=0; ncreate3d_offset(qgrid[n],nzlo_out[n],nzhi_out[n], nylo_out[n],nyhi_out[n],nxlo_out[n],nxhi_out[n],"msm:qgrid"); - memory->create3d_offset(egrid[n],nzlo_out[n],nzhi_out[n], nylo_out[n],nyhi_out[n],nxlo_out[n],nxhi_out[n],"msm:egrid"); @@ -695,24 +660,23 @@ void MSM::allocate() void MSM::deallocate() { + delete cg_all; + cg_all = nullptr; + memory->destroy2d_offset(phi1d,-order_allocated); memory->destroy2d_offset(dphi1d,-order_allocated); - if (cg_all) delete cg_all; - for (int n=0; ndestroy3d_offset(qgrid[n],nzlo_out[n],nylo_out[n],nxlo_out[n]); + memory->destroy3d_offset(qgrid[n],nzlo_out[n],nylo_out[n],nxlo_out[n]); + memory->destroy3d_offset(egrid[n],nzlo_out[n],nylo_out[n],nxlo_out[n]); - if (egrid[n]) - memory->destroy3d_offset(egrid[n],nzlo_out[n],nylo_out[n],nxlo_out[n]); + if (world_levels[n] != MPI_COMM_NULL) + MPI_Comm_free(&world_levels[n]); + world_levels[n] = MPI_COMM_NULL; + active_flag[n] = 0; - if (world_levels) - if (world_levels[n] != MPI_COMM_NULL) - MPI_Comm_free(&world_levels[n]); - - if (cg) - if (cg[n]) delete cg[n]; + delete cg[n]; + cg[n] = nullptr; } } @@ -801,6 +765,7 @@ void MSM::deallocate_peratom() void MSM::allocate_levels() { + deallocate_levels(); ngrid = new int[levels]; cg = new GridComm*[levels]; @@ -850,21 +815,21 @@ void MSM::allocate_levels() v5grid = new double***[levels]; for (int n=0; ndestroy(procneigh_levels); delete [] world_levels; @@ -919,6 +886,50 @@ void MSM::deallocate_levels() delete [] v3grid; delete [] v4grid; delete [] v5grid; + + world_levels = nullptr; + active_flag = nullptr; + cg = nullptr; + cg_peratom = nullptr; + + alpha = nullptr; + betax = nullptr; + betay = nullptr; + betaz = nullptr; + + nx_msm = nullptr; + ny_msm = nullptr; + nz_msm = nullptr; + + nxlo_in = nullptr; + nylo_in = nullptr; + nzlo_in = nullptr; + + nxhi_in = nullptr; + nyhi_in = nullptr; + nzhi_in = nullptr; + + nxlo_out = nullptr; + nylo_out = nullptr; + nzlo_out = nullptr; + + nxhi_out = nullptr; + nyhi_out = nullptr; + nzhi_out = nullptr; + + delxinv = nullptr; + delyinv = nullptr; + delzinv = nullptr; + + qgrid = nullptr; + egrid = nullptr; + + v0grid = nullptr; + v1grid = nullptr; + v2grid = nullptr; + v3grid = nullptr; + v4grid = nullptr; + v5grid = nullptr; } /* ---------------------------------------------------------------------- @@ -1053,9 +1064,9 @@ void MSM::set_grid_global() double *p_cutoff = (double *) force->pair->extract("cut_coul",itmp); *p_cutoff = cutoff; - char str[128]; - sprintf(str,"Adjusting Coulombic cutoff for MSM, new cutoff = %g",cutoff); - if (me == 0) error->warning(FLERR,str); + if (me == 0) + error->warning(FLERR,fmt::format("Adjusting Coulombic cutoff for " + "MSM, new cutoff = {}", cutoff)); } if (triclinic == 0) { @@ -1094,7 +1105,6 @@ void MSM::set_grid_global() if (!domain->nonperiodic) levels -= 1; - deallocate_levels(); allocate_levels(); // find number of grid levels in each direction @@ -1318,8 +1328,8 @@ void MSM::set_grid_local() void MSM::set_proc_grid(int n) { - for (int i=0; i<3; i++) - myloc[i] = comm->myloc[i]; + for (int i=0; i<3; i++) + myloc[i] = comm->myloc[i]; // size of inner MSM grid owned by this proc @@ -1362,6 +1372,7 @@ void MSM::set_proc_grid(int n) // define a new MPI communicator for this grid level that only includes active procs + if(world_levels[n] != MPI_COMM_NULL) MPI_Comm_free(&world_levels[n]); MPI_Comm_split(world,color,me,&world_levels[n]); if (!active_flag[n]) return; @@ -1479,16 +1490,13 @@ void MSM::particle_map() void MSM::make_rho() { - //fprintf(screen,"MSM aninterpolation\n\n"); - int i,l,m,n,nx,ny,nz,mx,my,mz; double dx,dy,dz,x0,y0,z0; // clear 3d density array - double ***qgridn = qgrid[0]; - - memset(&(qgridn[nzlo_out[0]][nylo_out[0]][nxlo_out[0]]),0,ngrid[0]*sizeof(double)); + double ***qgrid0 = qgrid[0]; + memset(&(qgrid0[nzlo_out[0]][nylo_out[0]][nxlo_out[0]]),0,ngrid[0]*sizeof(double)); // loop over my charges, add their contribution to nearby grid points // (nx,ny,nz) = global coords of grid pt to "lower left" of charge @@ -1519,7 +1527,7 @@ void MSM::make_rho() x0 = y0*phi1d[1][m]; for (l = nlower; l <= nupper; l++) { mx = l+nx; - qgridn[mz][my][mx] += x0*phi1d[0][l]; + qgrid0[mz][my][mx] += x0*phi1d[0][l]; } } } @@ -1534,8 +1542,6 @@ void MSM::make_rho() void MSM::direct(int n) { - //fprintf(screen,"Direct contribution on level %i\n\n",n); - double ***qgridn = qgrid[n]; double ***egridn = egrid[n]; double ***v0gridn = v0grid[n]; @@ -1768,8 +1774,6 @@ void MSM::direct(int n) void MSM::direct_peratom(int n) { - //fprintf(screen,"Direct contribution on level %i\n\n",n); - double ***qgridn = qgrid[n]; double ***v0gridn = v0grid[n]; double ***v1gridn = v1grid[n]; @@ -1892,8 +1896,6 @@ void MSM::direct_peratom(int n) void MSM::direct_top(int n) { - //fprintf(screen,"Direct contribution on level %i\n\n",n); - double ***qgridn = qgrid[n]; double ***egridn = egrid[n]; double ***v0gridn = v0grid[n]; @@ -2257,8 +2259,6 @@ void MSM::direct_peratom_top(int n) void MSM::restriction(int n) { - //fprintf(screen,"Restricting from level %i to %i\n\n",n,n+1); - const int p = order-1; double ***qgrid1 = qgrid[n]; @@ -2281,8 +2281,7 @@ void MSM::restriction(int n) // zero out charge on coarser grid - memset(&(qgrid2[nzlo_out[n+1]][nylo_out[n+1]][nxlo_out[n+1]]),0, - ngrid[n+1]*sizeof(double)); + memset(&(qgrid2[nzlo_out[n+1]][nylo_out[n+1]][nxlo_out[n+1]]),0,ngrid[n+1]*sizeof(double)); for (kp = nzlo_in[n+1]; kp <= nzhi_in[n+1]; kp++) for (jp = nylo_in[n+1]; jp <= nyhi_in[n+1]; jp++) @@ -2331,8 +2330,6 @@ void MSM::restriction(int n) void MSM::prolongation(int n) { - //fprintf(screen,"Prolongating from level %i to %i\n\n",n+1,n); - const int p = order-1; double ***egrid1 = egrid[n]; @@ -2721,8 +2718,6 @@ void MSM::unpack_reverse(int flag, double *buf, int nlist, int *list) void MSM::fieldforce() { - //fprintf(screen,"MSM interpolation\n\n"); - double ***egridn = egrid[0]; int i,l,m,n,nx,ny,nz,mx,my,mz; From e934f7bac3714386fbc8e76c3b25ccea928684f3 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Jun 2020 00:20:20 -0400 Subject: [PATCH 40/53] try to work around linker issues with older CMake versions and using coverage or sanitizers --- cmake/CMakeLists.txt | 24 ++++++++++++++++++++---- unittest/force-styles/CMakeLists.txt | 6 ++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index e3569b1188..f75a5ea914 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -243,8 +243,16 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) mark_as_advanced(ENABLE_COVERAGE) if(ENABLE_COVERAGE) - target_compile_options(lammps PUBLIC --coverage) - target_link_options(lammps PUBLIC --coverage) + if(CMAKE_VERSION VERSION_LESS 3.13) + if(CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") + endif() + else() + target_compile_options(lammps PUBLIC --coverage) + target_link_options(lammps PUBLIC --coverage) + endif() endif() endif() if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) @@ -255,8 +263,16 @@ if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQU validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES) string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER) if (NOT ENABLE_SANITIZER STREQUAL "none") - target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) - target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + if(CMAKE_VERSION VERSION_LESS 3.13) + if(CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} -fsanitize=${ENABLE_SANITIZER}") + endif() + else() + target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + endif() endif() endif() diff --git a/unittest/force-styles/CMakeLists.txt b/unittest/force-styles/CMakeLists.txt index 535e1fb2f1..aed715ee65 100644 --- a/unittest/force-styles/CMakeLists.txt +++ b/unittest/force-styles/CMakeLists.txt @@ -17,8 +17,10 @@ else() endif() # propagate sanitizer options to test tools if (NOT ENABLE_SANITIZER STREQUAL "none") - target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) - target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) + target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) + endif() endif() # unit test for error stats class From 343241cb63a4f714379312c63f68ce04f6a30d2b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Jun 2020 00:43:11 -0400 Subject: [PATCH 41/53] relax some test epsilons --- unittest/force-styles/tests/manybody-pair-tersoff_table.yaml | 2 +- unittest/force-styles/tests/mol-pair-lj_class2_coul_cut.yaml | 2 +- unittest/force-styles/tests/mol-pair-lj_class2_coul_long.yaml | 2 +- unittest/force-styles/tests/mol-pair-lj_class2_coul_table.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/unittest/force-styles/tests/manybody-pair-tersoff_table.yaml b/unittest/force-styles/tests/manybody-pair-tersoff_table.yaml index 51220b8c8e..10c28f7335 100644 --- a/unittest/force-styles/tests/manybody-pair-tersoff_table.yaml +++ b/unittest/force-styles/tests/manybody-pair-tersoff_table.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Wed May 27 12:29:41 202 -epsilon: 5e-12 +epsilon: 5e-11 prerequisites: ! | pair tersoff/table pre_commands: ! | diff --git a/unittest/force-styles/tests/mol-pair-lj_class2_coul_cut.yaml b/unittest/force-styles/tests/mol-pair-lj_class2_coul_cut.yaml index 5f09340637..4f2f6d86df 100644 --- a/unittest/force-styles/tests/mol-pair-lj_class2_coul_cut.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_class2_coul_cut.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Sat May 30 18:04:12 202 -epsilon: 5e-13 +epsilon: 5e-12 prerequisites: ! | atom full pair lj/class2/coul/cut diff --git a/unittest/force-styles/tests/mol-pair-lj_class2_coul_long.yaml b/unittest/force-styles/tests/mol-pair-lj_class2_coul_long.yaml index b358010160..c77348089d 100644 --- a/unittest/force-styles/tests/mol-pair-lj_class2_coul_long.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_class2_coul_long.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Fri May 15 19:08:06 202 -epsilon: 5.0e-13 +epsilon: 5.0e-12 prerequisites: ! | atom full pair lj/class2/coul/long diff --git a/unittest/force-styles/tests/mol-pair-lj_class2_coul_table.yaml b/unittest/force-styles/tests/mol-pair-lj_class2_coul_table.yaml index 4e85b29b2a..d7857de99b 100644 --- a/unittest/force-styles/tests/mol-pair-lj_class2_coul_table.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_class2_coul_table.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Fri May 15 19:08:06 202 -epsilon: 5.0e-13 +epsilon: 5.0e-12 prerequisites: ! | atom full pair lj/class2/coul/long From a4de04d8234366e45318d07f59941b2aee10d5a2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Jun 2020 00:44:09 -0400 Subject: [PATCH 42/53] make certain that allocated buffers in Comm::rendezvous_all2all() are not NULL --- src/comm.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/comm.cpp b/src/comm.cpp index b00308a6e5..2ac933fe45 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -977,7 +977,7 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, memory->create(procs_a2a,nprocs,"rendezvous:procs"); inbuf_a2a = (char *) memory->smalloc((bigint) n*insize, "rendezvous:inbuf"); - memset(inbuf_a2a,0,(bigint)n*insize*sizeof(char)); + memset(inbuf_a2a,0,(bigint)(n+1)*insize*sizeof(char)); memory->create(offsets,nprocs,"rendezvous:offsets"); for (int i = 0; i < nprocs; i++) procs_a2a[i] = 0; @@ -1039,7 +1039,7 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, // all2all comm of inbuf from caller decomp to rendezvous decomp - char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize, + char *inbuf_rvous = (char *) memory->smalloc((bigint) (nrvous+1)*insize, "rendezvous:inbuf"); memset(inbuf_rvous,0,(bigint) nrvous*insize*sizeof(char)); @@ -1079,7 +1079,7 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, if (!outorder) { memory->create(procs_a2a,nprocs,"rendezvous_a2a:procs"); - outbuf_a2a = (char *) memory->smalloc((bigint) nrvous_out*outsize, + outbuf_a2a = (char *) memory->smalloc((bigint) (nrvous_out+1)*outsize, "rendezvous:outbuf"); memory->create(offsets,nprocs,"rendezvous:offsets"); @@ -1139,7 +1139,7 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, // all2all comm of outbuf from rendezvous decomp back to caller decomp // caller will free outbuf - outbuf = (char *) memory->smalloc((bigint) nout*outsize,"rendezvous:outbuf"); + outbuf = (char *) memory->smalloc((bigint)(nout+1)*outsize,"rendezvous:outbuf"); MPI_Alltoallv(outbuf_a2a,sendcount,sdispls,MPI_CHAR, outbuf,recvcount,rdispls,MPI_CHAR,world); From 0249cf7510f7d9b8264ebddea2e84c2c35039ef1 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Jun 2020 01:10:45 -0400 Subject: [PATCH 43/53] better and more general version of the previous commit --- src/comm.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/comm.cpp b/src/comm.cpp index 2ac933fe45..8fad736af6 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -901,7 +901,7 @@ rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, if (inorder) nrvous = irregular->create_data_grouped(n,procs); else nrvous = irregular->create_data(n,procs); - char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize, + char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize+1, "rendezvous:inbuf"); irregular->exchange_data(inbuf,insize,inbuf_rvous); @@ -936,7 +936,7 @@ rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, nout = irregular->create_data_grouped(nrvous_out,procs_rvous); else nout = irregular->create_data(nrvous_out,procs_rvous); - outbuf = (char *) memory->smalloc((bigint) nout*outsize, + outbuf = (char *) memory->smalloc((bigint) nout*outsize+1, "rendezvous:outbuf"); irregular->exchange_data(outbuf_rvous,outsize,outbuf); @@ -975,9 +975,9 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, if (!inorder) { memory->create(procs_a2a,nprocs,"rendezvous:procs"); - inbuf_a2a = (char *) memory->smalloc((bigint) n*insize, + inbuf_a2a = (char *) memory->smalloc((bigint) n*insize+1, "rendezvous:inbuf"); - memset(inbuf_a2a,0,(bigint)(n+1)*insize*sizeof(char)); + memset(inbuf_a2a,0,(bigint)n*insize*sizeof(char)); memory->create(offsets,nprocs,"rendezvous:offsets"); for (int i = 0; i < nprocs; i++) procs_a2a[i] = 0; @@ -1039,7 +1039,7 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, // all2all comm of inbuf from caller decomp to rendezvous decomp - char *inbuf_rvous = (char *) memory->smalloc((bigint) (nrvous+1)*insize, + char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize+1, "rendezvous:inbuf"); memset(inbuf_rvous,0,(bigint) nrvous*insize*sizeof(char)); @@ -1079,7 +1079,7 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, if (!outorder) { memory->create(procs_a2a,nprocs,"rendezvous_a2a:procs"); - outbuf_a2a = (char *) memory->smalloc((bigint) (nrvous_out+1)*outsize, + outbuf_a2a = (char *) memory->smalloc((bigint) nrvous_out*outsize+1, "rendezvous:outbuf"); memory->create(offsets,nprocs,"rendezvous:offsets"); @@ -1139,7 +1139,7 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, // all2all comm of outbuf from rendezvous decomp back to caller decomp // caller will free outbuf - outbuf = (char *) memory->smalloc((bigint)(nout+1)*outsize,"rendezvous:outbuf"); + outbuf = (char *) memory->smalloc((bigint) nout*outsize+1,"rendezvous:outbuf"); MPI_Alltoallv(outbuf_a2a,sendcount,sdispls,MPI_CHAR, outbuf,recvcount,rdispls,MPI_CHAR,world); From 8f4e18ba3a0d0cc2a7061c824944a70f7d162601 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Jun 2020 11:30:38 -0400 Subject: [PATCH 44/53] change logic of selecting and allowing sanitizer options to be compatible with unsupported compilers --- cmake/CMakeLists.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f75a5ea914..e5dc5b194d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -255,14 +255,15 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") endif() endif() endif() -if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) - set(ENABLE_SANITIZER "none" CACHE STRING "Select a code sanitizer option (none (default), address, thread, undefined)") - mark_as_advanced(ENABLE_SANITIZER) - set(ENABLE_SANITIZER_VALUES none address thread undefined) - set_property(CACHE ENABLE_SANITIZER PROPERTY STRINGS ${ENABLE_SANITIZER_VALUES}) - validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES) - string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER) - if (NOT ENABLE_SANITIZER STREQUAL "none") + +set(ENABLE_SANITIZER "none" CACHE STRING "Select a code sanitizer option (none (default), address, thread, undefined)") +mark_as_advanced(ENABLE_SANITIZER) +set(ENABLE_SANITIZER_VALUES none address thread undefined) +set_property(CACHE ENABLE_SANITIZER PROPERTY STRINGS ${ENABLE_SANITIZER_VALUES}) +validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES) +string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER) +if(NOT ENABLE_SANITIZER STREQUAL "none") + if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) if(CMAKE_VERSION VERSION_LESS 3.13) if(CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}") @@ -273,6 +274,9 @@ if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQU target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) endif() + else() + message(WARNING "ENABLE_SANITIZER option not supported by ${CMAKE_CXX_COMPILER_ID} compilers. Ignoring.") + set(ENABLE_SANITIZER "none") endif() endif() From 4d630904b4b69f00e07125b76cf6adf3880c1940 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Jun 2020 11:43:59 -0400 Subject: [PATCH 45/53] relax a few more test criteria to be compatible with intel compilers --- unittest/force-styles/tests/atomic-pair-eim.yaml | 2 +- unittest/force-styles/tests/manybody-pair-airebo.yaml | 2 +- .../force-styles/tests/manybody-pair-polymorphic_tersoff.yaml | 2 +- unittest/force-styles/tests/manybody-pair-tersoff_mod.yaml | 2 +- unittest/force-styles/tests/manybody-pair-tersoff_mod_c.yaml | 2 +- unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml | 2 +- unittest/force-styles/tests/mol-pair-coul_dsf.yaml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/unittest/force-styles/tests/atomic-pair-eim.yaml b/unittest/force-styles/tests/atomic-pair-eim.yaml index c3469c753a..56d18874f2 100644 --- a/unittest/force-styles/tests/atomic-pair-eim.yaml +++ b/unittest/force-styles/tests/atomic-pair-eim.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Tue May 26 21:02:07 202 -epsilon: 5.0e-12 +epsilon: 1.0e-11 prerequisites: ! | pair eim pre_commands: ! "" diff --git a/unittest/force-styles/tests/manybody-pair-airebo.yaml b/unittest/force-styles/tests/manybody-pair-airebo.yaml index 5c0da81381..bf86ee82d0 100644 --- a/unittest/force-styles/tests/manybody-pair-airebo.yaml +++ b/unittest/force-styles/tests/manybody-pair-airebo.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Wed May 27 16:13:46 202 -epsilon: 2e-7 +epsilon: 5e-6 prerequisites: ! | pair airebo pre_commands: ! | diff --git a/unittest/force-styles/tests/manybody-pair-polymorphic_tersoff.yaml b/unittest/force-styles/tests/manybody-pair-polymorphic_tersoff.yaml index 2f2aa14608..3cd409e95c 100644 --- a/unittest/force-styles/tests/manybody-pair-polymorphic_tersoff.yaml +++ b/unittest/force-styles/tests/manybody-pair-polymorphic_tersoff.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Thu May 28 20:29:01 202 -epsilon: 1e-12 +epsilon: 1e-11 prerequisites: ! | pair polymorphic pre_commands: ! | diff --git a/unittest/force-styles/tests/manybody-pair-tersoff_mod.yaml b/unittest/force-styles/tests/manybody-pair-tersoff_mod.yaml index ae9970c15d..3d67aee32d 100644 --- a/unittest/force-styles/tests/manybody-pair-tersoff_mod.yaml +++ b/unittest/force-styles/tests/manybody-pair-tersoff_mod.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Wed May 27 10:27:56 202 -epsilon: 1e-12 +epsilon: 5e-11 prerequisites: ! | pair tersoff/mod pre_commands: ! | diff --git a/unittest/force-styles/tests/manybody-pair-tersoff_mod_c.yaml b/unittest/force-styles/tests/manybody-pair-tersoff_mod_c.yaml index 871e7b88da..1d138480cf 100644 --- a/unittest/force-styles/tests/manybody-pair-tersoff_mod_c.yaml +++ b/unittest/force-styles/tests/manybody-pair-tersoff_mod_c.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Wed May 27 10:28:17 202 -epsilon: 5e-13 +epsilon: 1e-12 prerequisites: ! | pair tersoff/mod/c pre_commands: ! | diff --git a/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml b/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml index d161c10b23..dba684ab3e 100644 --- a/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml +++ b/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Wed May 27 10:29:02 202 -epsilon: 5e-12 +epsilon: 5e-11 prerequisites: ! | pair tersoff/zbl pre_commands: ! | diff --git a/unittest/force-styles/tests/mol-pair-coul_dsf.yaml b/unittest/force-styles/tests/mol-pair-coul_dsf.yaml index 496e5997ca..7a93ee81c7 100644 --- a/unittest/force-styles/tests/mol-pair-coul_dsf.yaml +++ b/unittest/force-styles/tests/mol-pair-coul_dsf.yaml @@ -1,7 +1,7 @@ --- lammps_version: 2 Jun 2020 date_generated: Sun Jun 14 14:42:09 202 -epsilon: 2e-13 +epsilon: 1e-12 prerequisites: ! | atom full pair coul/dsf From 4a447f1809162b54e80285dda9b3fb1a868ae4b7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Jun 2020 12:31:31 -0400 Subject: [PATCH 46/53] move deleting all array data associated with an atom style to AtomVec base class destructor --- src/atom.cpp | 109 ----------------------------------------------- src/atom_vec.cpp | 8 ++++ 2 files changed, 8 insertions(+), 109 deletions(-) diff --git a/src/atom.cpp b/src/atom.cpp index 471061cd5e..11f26af6c3 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -249,115 +249,6 @@ Atom::~Atom() delete [] peratom[i].name; memory->sfree(peratom); - // -------------------------------------------------------------------- - // 2nd customization section: customize by adding new per-atom variables - // delete atom arrays - - memory->destroy(tag); - memory->destroy(type); - memory->destroy(mask); - memory->destroy(image); - memory->destroy(x); - memory->destroy(v); - memory->destroy(f); - - memory->destroy(molecule); - memory->destroy(molindex); - memory->destroy(molatom); - - memory->destroy(q); - memory->destroy(mu); - memory->destroy(omega); - memory->destroy(angmom); - memory->destroy(torque); - memory->destroy(radius); - memory->destroy(rmass); - memory->destroy(ellipsoid); - memory->destroy(line); - memory->destroy(tri); - memory->destroy(body); - - memory->destroy(sp); - memory->destroy(fm); - memory->destroy(fm_long); - - memory->destroy(vfrac); - memory->destroy(s0); - memory->destroy(x0); - - memory->destroy(spin); - memory->destroy(eradius); - memory->destroy(ervel); - memory->destroy(erforce); - memory->destroy(ervelforce); - memory->destroy(cs); - memory->destroy(csforce); - memory->destroy(vforce); - memory->destroy(etag); - - memory->destroy(rho); - memory->destroy(drho); - memory->destroy(esph); - memory->destroy(desph); - memory->destroy(cv); - memory->destroy(vest); - - // USER-MESONT package - memory->destroy(length); - memory->destroy(buckling); - memory->destroy(bond_nt); - - memory->destroy(contact_radius); - memory->destroy(smd_data_9); - memory->destroy(smd_stress); - memory->destroy(eff_plastic_strain); - memory->destroy(eff_plastic_strain_rate); - memory->destroy(damage); - - memory->destroy(dpdTheta); - memory->destroy(uCond); - memory->destroy(uMech); - memory->destroy(uChem); - memory->destroy(uCG); - memory->destroy(uCGnew); - memory->destroy(duChem); - - memory->destroy(cc); - memory->destroy(cc_flux); - memory->destroy(edpd_temp); - memory->destroy(edpd_flux); - memory->destroy(edpd_cv); - - memory->destroy(nspecial); - memory->destroy(special); - - memory->destroy(num_bond); - memory->destroy(bond_type); - memory->destroy(bond_atom); - - memory->destroy(num_angle); - memory->destroy(angle_type); - memory->destroy(angle_atom1); - memory->destroy(angle_atom2); - memory->destroy(angle_atom3); - - memory->destroy(num_dihedral); - memory->destroy(dihedral_type); - memory->destroy(dihedral_atom1); - memory->destroy(dihedral_atom2); - memory->destroy(dihedral_atom3); - memory->destroy(dihedral_atom4); - - memory->destroy(num_improper); - memory->destroy(improper_type); - memory->destroy(improper_atom1); - memory->destroy(improper_atom2); - memory->destroy(improper_atom3); - memory->destroy(improper_atom4); - - // end of customization section - // -------------------------------------------------------------------- - // delete custom atom arrays for (int i = 0; i < nivector; i++) { diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 85fdbbbbfe..6a294d3ccf 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -96,6 +96,14 @@ AtomVec::~AtomVec() for (int i = 0; i < nargcopy; i++) delete [] argcopy[i]; delete [] argcopy; + memory->destroy(atom->tag); + memory->destroy(atom->type); + memory->destroy(atom->mask); + memory->destroy(atom->image); + memory->destroy(atom->x); + memory->destroy(atom->v); + memory->destroy(atom->f); + for (int i = 0; i < ngrow; i++) { pdata = mgrow.pdata[i]; datatype = mgrow.datatype[i]; From 08cb7664a3f1b183c46ee2291c6be1a9602e99b3 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Jun 2020 12:31:47 -0400 Subject: [PATCH 47/53] renumber customization comments --- src/atom.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/atom.cpp b/src/atom.cpp index 11f26af6c3..42ff9d4613 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -321,7 +321,7 @@ void Atom::peratom_create() nperatom = maxperatom = 0; // -------------------------------------------------------------------- - // 3rd customization section: add peratom variables here, order does not matter + // 2nd customization section: add peratom variables here, order does not matter // register tagint & imageint variables as INT or BIGINT int tagintsize = INT; @@ -562,7 +562,7 @@ void Atom::add_peratom_vary(const char *name, void *address, void Atom::set_atomflag_defaults() { // -------------------------------------------------------------------- - // 4th customization section: customize by adding new flag + // 3rd customization section: customize by adding new flag // identical list as 2nd customization in atom.h sphere_flag = ellipsoid_flag = line_flag = tri_flag = body_flag = 0; @@ -2353,7 +2353,7 @@ void Atom::remove_custom(int flag, int index) void *Atom::extract(char *name) { // -------------------------------------------------------------------- - // 5th customization section: customize by adding new variable name + // 4th customization section: customize by adding new variable name if (strcmp(name,"mass") == 0) return (void *) mass; From 3cdf0e286ef4b41f3893570965cfbb5fd186c232 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Jun 2020 12:32:11 -0400 Subject: [PATCH 48/53] add comments to explain why 1 item is added to rendezvous buffers. --- src/comm.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/comm.cpp b/src/comm.cpp index 8fad736af6..111c4c1de4 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -901,6 +901,8 @@ rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, if (inorder) nrvous = irregular->create_data_grouped(n,procs); else nrvous = irregular->create_data(n,procs); + // add 1 item to the allocated buffer size, so the returned pointer is not NULL + char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize+1, "rendezvous:inbuf"); irregular->exchange_data(inbuf,insize,inbuf_rvous); @@ -936,6 +938,8 @@ rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, nout = irregular->create_data_grouped(nrvous_out,procs_rvous); else nout = irregular->create_data(nrvous_out,procs_rvous); + // add 1 item to the allocated buffer size, so the returned pointer is not NULL + outbuf = (char *) memory->smalloc((bigint) nout*outsize+1, "rendezvous:outbuf"); irregular->exchange_data(outbuf_rvous,outsize,outbuf); @@ -975,6 +979,9 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, if (!inorder) { memory->create(procs_a2a,nprocs,"rendezvous:procs"); + + // add 1 item to the allocated buffer size, so the returned pointer is not NULL + inbuf_a2a = (char *) memory->smalloc((bigint) n*insize+1, "rendezvous:inbuf"); memset(inbuf_a2a,0,(bigint)n*insize*sizeof(char)); @@ -1038,6 +1045,7 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, } // all2all comm of inbuf from caller decomp to rendezvous decomp + // add 1 item to the allocated buffer size, so the returned pointer is not NULL char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize+1, "rendezvous:inbuf"); @@ -1079,6 +1087,8 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, if (!outorder) { memory->create(procs_a2a,nprocs,"rendezvous_a2a:procs"); + // add 1 item to the allocated buffer size, so the returned pointer is not NULL + outbuf_a2a = (char *) memory->smalloc((bigint) nrvous_out*outsize+1, "rendezvous:outbuf"); memory->create(offsets,nprocs,"rendezvous:offsets"); @@ -1138,6 +1148,7 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, // all2all comm of outbuf from rendezvous decomp back to caller decomp // caller will free outbuf + // add 1 item to the allocated buffer size, so the returned pointer is not NULL outbuf = (char *) memory->smalloc((bigint) nout*outsize+1,"rendezvous:outbuf"); From a40f4873fbb275ae261e439acbade0e0bda0bd16 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Fri, 19 Jun 2020 10:35:42 -0600 Subject: [PATCH 49/53] comment out debug options and make some tallies bigints --- src/REPLICA/fix_hyper_local.cpp | 53 +++++++++++++++++++-------------- src/REPLICA/fix_hyper_local.h | 14 ++++----- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/REPLICA/fix_hyper_local.cpp b/src/REPLICA/fix_hyper_local.cpp index 9625eb158e..8e14affef8 100644 --- a/src/REPLICA/fix_hyper_local.cpp +++ b/src/REPLICA/fix_hyper_local.cpp @@ -62,7 +62,8 @@ FixHyperLocal::FixHyperLocal(LAMMPS *lmp, int narg, char **arg) : hyperflag = 2; scalar_flag = 1; vector_flag = 1; - size_vector = 28; + size_vector = 26; + //size_vector = 28; // can add 2 for debugging local_flag = 1; size_local_rows = 0; size_local_cols = 0; @@ -194,7 +195,9 @@ FixHyperLocal::FixHyperLocal(LAMMPS *lmp, int narg, char **arg) : bound_upper = 1.0 + boundfrac; lastreset = update->ntimestep; - overcount = 0; + // two DEBUG quantities + // myboost = 0.0; + // overcount = 0; } /* ---------------------------------------------------------------------- */ @@ -481,7 +484,8 @@ void FixHyperLocal::pre_reverse(int /* eflag */, int /* vflag */) double **x = atom->x; - overcount = 0; + // DEBUG quantity + // overcount = 0; m = 0; for (iold = 0; iold < nlocal_old; iold++) { @@ -499,8 +503,8 @@ void FixHyperLocal::pre_reverse(int /* eflag */, int /* vflag */) maxbondlen = MAX(r,maxbondlen); r0 = blist[m].r0; estrain = fabs(r-r0) / r0; - // DEBUG quantity - could remove this line and output option - if (estrain >= qfactor) overcount++; + // DEBUG quantity + // if (estrain >= qfactor) overcount++; maxstrain[i] = MAX(maxstrain[i],estrain); maxstrain[j] = MAX(maxstrain[j],estrain); if (estrain > halfstrain) { @@ -679,8 +683,8 @@ void FixHyperLocal::pre_reverse(int /* eflag */, int /* vflag */) int negstrain = 0; mybias = 0.0; - // DEBUG - one line - myboost = 0; + // DEBUG quantity + // myboost = 0; for (int ibias = 0; ibias < nbias; ibias++) { m = bias[ibias]; @@ -688,8 +692,8 @@ void FixHyperLocal::pre_reverse(int /* eflag */, int /* vflag */) j = blist[m].j; if (maxstrain[i] >= qfactor) { - // DEBUG - one line - myboost += 1.0; + // DEBUG quantity + // myboost += 1.0; nobias++; continue; } @@ -714,8 +718,8 @@ void FixHyperLocal::pre_reverse(int /* eflag */, int /* vflag */) if (ebias < 0.0) negstrain++; mybias += vbias; - // DEBUG - one line - myboost += exp(beta * biascoeff[m]*vbias); + // DEBUG quantity + // myboost += exp(beta * biascoeff[m]*vbias); } //time7 = MPI_Wtime(); @@ -1467,7 +1471,8 @@ double FixHyperLocal::compute_scalar() double FixHyperLocal::compute_vector(int i) { - // 28 vector outputs returned for i = 0-27 + // 26 vector outputs returned for i = 0-25 + // can add 2 more for debugging // i = 0 = average boost for all bonds on this step // i = 1 = # of biased bonds on this step @@ -1502,7 +1507,7 @@ double FixHyperLocal::compute_vector(int i) // i = 24 = cumulative # of atoms in events since fix created // i = 25 = cumulative # of new bonds formed since fix created - // these 2 were added for debugging - could be removed at some point + // these 2 can be added for debugging // i = 26 = average boost for biased bonds on this step // i = 27 = current count of bonds with strain >= q @@ -1580,17 +1585,17 @@ double FixHyperLocal::compute_vector(int i) } if (i == 11) { - int allbias_running,allnobias_running; - MPI_Allreduce(&nbias_running,&allbias_running,1,MPI_INT,MPI_SUM,world); - MPI_Allreduce(&nobias_running,&allnobias_running,1,MPI_INT,MPI_SUM,world); + bigint allbias_running,allnobias_running; + MPI_Allreduce(&nbias_running,&allbias_running,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&nobias_running,&allnobias_running,1,MPI_LMP_BIGINT,MPI_SUM,world); if (allbias_running) return 1.0*allnobias_running / allbias_running; return 0.0; } if (i == 12) { - int allbias_running,allnegstrain_running; - MPI_Allreduce(&nbias_running,&allbias_running,1,MPI_INT,MPI_SUM,world); - MPI_Allreduce(&negstrain_running,&allnegstrain_running,1,MPI_INT, + bigint allbias_running,allnegstrain_running; + MPI_Allreduce(&nbias_running,&allbias_running,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&negstrain_running,&allnegstrain_running,1,MPI_LMP_BIGINT, MPI_SUM,world); if (allbias_running) return 1.0*allnegstrain_running / allbias_running; return 0.0; @@ -1654,13 +1659,14 @@ double FixHyperLocal::compute_vector(int i) if (i == 24) return (double) nevent_atom; if (i == 25) { - int allnewbond; - MPI_Allreduce(&nnewbond,&allnewbond,1,MPI_INT,MPI_SUM,world); + bigint allnewbond; + MPI_Allreduce(&nnewbond,&allnewbond,1,MPI_LMP_BIGINT,MPI_SUM,world); return (double) allnewbond; } - // these two options were added for debugging + // these two options can be added for debugging + /* if (i == 26) { double allboost; MPI_Allreduce(&myboost,&allboost,1,MPI_DOUBLE,MPI_SUM,world); @@ -1675,7 +1681,8 @@ double FixHyperLocal::compute_vector(int i) MPI_Allreduce(&overcount,&allovercount,1,MPI_INT,MPI_SUM,world); return (double) allovercount; } - + */ + return 0.0; } diff --git a/src/REPLICA/fix_hyper_local.h b/src/REPLICA/fix_hyper_local.h index 6e8fee61d9..4fb54d166c 100644 --- a/src/REPLICA/fix_hyper_local.h +++ b/src/REPLICA/fix_hyper_local.h @@ -72,9 +72,9 @@ class FixHyperLocal : public FixHyper { double cutbondsq,dcutsq; double beta,invvmax,invqfactorsq; - // DEBUG - 2 lines - int overcount; - double myboost; + // two DEBUG quantities + // double myboost; + // int overcount; // flags @@ -95,14 +95,14 @@ class FixHyperLocal : public FixHyper { double time_bondbuild; // CPU time for bond builds bigint allbonds; // current total # of bonds - int nnewbond; // running tally of # of new bonds created int maxbondperatom; // max # of bonds any atom ever has int nevent; // # of events that trigger bond rebuild int nevent_atom; // # of atoms that experienced an event - int nbias_running; // running count of biased bonds - int nobias_running; // ditto for bonds with bias = 0, b/c too long - int negstrain_running; // ditto for bonds with negative strain + bigint nnewbond; // running tally of # of new bonds created + bigint nbias_running; // running count of biased bonds + bigint nobias_running; // ditto for bonds with bias = 0, b/c too long + bigint negstrain_running; // ditto for bonds with negative strain double mybias; // sum of bias potentials for biased bonds double maxbondlen; // cummulative max length of any bond From c7874fca869d0e856a7290caeb33558fb7a7d169 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Fri, 19 Jun 2020 12:18:11 -0600 Subject: [PATCH 50/53] Switched the sign of spherical harmonics for m odd --- doc/src/compute_orientorder_atom.rst | 25 +++++++++++------ src/compute_orientorder_atom.cpp | 42 +++++++++++----------------- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/doc/src/compute_orientorder_atom.rst b/doc/src/compute_orientorder_atom.rst index 7b894b886e..a312ceb17a 100644 --- a/doc/src/compute_orientorder_atom.rst +++ b/doc/src/compute_orientorder_atom.rst @@ -48,14 +48,17 @@ For each atom, :math:`Q_l` is a real number defined as follows: \bar{Y}_{lm} = & \frac{1}{nnn}\sum_{j = 1}^{nnn} Y_{lm}( \theta( {\bf r}_{ij} ), \phi( {\bf r}_{ij} ) ) \\ Q_l = & \sqrt{\frac{4 \pi}{2 l + 1} \sum_{m = -l}^{m = l} \bar{Y}_{lm} \bar{Y}^*_{lm}} -The first equation defines the spherical harmonic order parameters. +The first equation defines the local order parameters as averages +of the spherical harmonics :math:`Y_{lm}` for each neighbor. These are complex number components of the 3D analog of the 2D order parameter :math:`q_n`, which is implemented as LAMMPS compute :doc:`hexorder/atom `. The summation is over the *nnn* nearest neighbors of the central atom. -The angles theta and phi are the standard spherical polar angles +The angles :math:`theta` and :math:`phi` are the standard spherical polar angles defining the direction of the bond vector :math:`r_{ij}`. +The phase and sign of :math:`Y_{lm}` follow the standard conventions, +so that :math:`{\rm sign}(Y_{ll}(0,0)) = (-1)^l`. The second equation defines :math:`Q_l`, which is a rotationally invariant non-negative amplitude obtained by summing over all the components of degree *l*\ . @@ -98,8 +101,8 @@ structures are given in Table I of :ref:`Steinhardt `, and these can be reproduced with this keyword. The optional keyword *components* will output the components of the -normalized complex vector :math:`\bar{Y}_{lm}` of degree *ldegree*\ , which must be -explicitly included in the keyword *degrees*\ . This option can be used +*normalized* complex vector :math:`\hat{Y}_{lm} = \bar{Y}_{lm}/|\bar{Y}_{lm}|` of degree *ldegree*\, +which must be included in the list of order parameters to be computed. This option can be used in conjunction with :doc:`compute coord_atom ` to calculate the ten Wolde's criterion to identify crystal-like particles, as discussed in :ref:`ten Wolde `. @@ -141,11 +144,15 @@ If the keyword *wl/hat* is set to yes, then the :math:`\hat{W}_l` values for each atom will be added to the output array, which are real numbers. If the keyword *components* is set, then the real and imaginary parts -of each component of (normalized) :math:`\bar{Y}_{lm}` will be added to the -output array in the following order: :math:`Re(\bar{Y}_{-m}) Im(\bar{Y}_{-m}) -Re(\bar{Y}_{-m+1}) Im(\bar{Y}_{-m+1}) ... Re(\bar{Y}_m) Im(\bar{Y}_m)`. This -way, the per-atom array will have a total of *nlvalues*\ +2\*(2\ *l*\ +1) -columns. +of each component of *normalized* :math:`\hat{Y}_{lm}` will be added to the +output array in the following order: :math:`{\rm Re}(\hat{Y}_{-m}), {\rm Im}(\hat{Y}_{-m}), +{\rm Re}(\hat{Y}_{-m+1}), {\rm Im}(\hat{Y}_{-m+1}), \dots , {\rm Re}(\hat{Y}_m), {\rm Im}(\hat{Y}_m)`. + +In summary, the per-atom array will contain *nlvalues* columns, followed by +an additional *nlvalues* columns if *wl* is set to yes, followed by +an additional *nlvalues* columns if *wl/hat* is set to yes, followed +by an additional 2\*(2\* *ldegree*\ +1) columns if the *components* +keyword is set. These values can be accessed by any command that uses per-atom values from a compute as input. See the :doc:`Howto output ` doc diff --git a/src/compute_orientorder_atom.cpp b/src/compute_orientorder_atom.cpp index 3dafd08a0f..7a6cc96280 100644 --- a/src/compute_orientorder_atom.cpp +++ b/src/compute_orientorder_atom.cpp @@ -456,21 +456,26 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, for (int il = 0; il < nqlist; il++) { int l = qlist[il]; + // calculate spherical harmonics + // Ylm, -l <= m <= l + // sign convention: sign(Yll(0,0)) = (-1)^l + qnm_r[il][l] += polar_prefactor(l, 0, costheta); double expphim_r = expphi_r; double expphim_i = expphi_i; for(int m = 1; m <= +l; m++) { + double prefactor = polar_prefactor(l, m, costheta); - double c_r = prefactor * expphim_r; - double c_i = prefactor * expphim_i; - qnm_r[il][m+l] += c_r; - qnm_i[il][m+l] += c_i; + double ylm_r = prefactor * expphim_r; + double ylm_i = prefactor * expphim_i; + qnm_r[il][m+l] += ylm_r; + qnm_i[il][m+l] += ylm_i; if(m & 1) { - qnm_r[il][-m+l] -= c_r; - qnm_i[il][-m+l] += c_i; + qnm_r[il][-m+l] -= ylm_r; + qnm_i[il][-m+l] += ylm_i; } else { - qnm_r[il][-m+l] += c_r; - qnm_i[il][-m+l] -= c_i; + qnm_r[il][-m+l] += ylm_r; + qnm_i[il][-m+l] -= ylm_i; } double tmp_r = expphim_r*expphi_r - expphim_i*expphi_i; double tmp_i = expphim_r*expphi_i + expphim_i*expphi_r; @@ -505,19 +510,6 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, qn[jj++] = qnormfac * sqrt(qm_sum); } - // TODO: - // 1. [done]Need to allocate extra memory in qnarray[] for this option - // 2. [done]Need to add keyword option - // 3. [done]Need to calculate Clebsch-Gordan/Wigner 3j coefficients - // (Can try getting them from boop.py first) - // 5. [done]Compare to bcc values in /Users/athomps/netapp/codes/MatMiner/matminer/matminer/featurizers/boop.py - // 6. [done]I get the right answer for W_l, but need to make sure that factor of 1/sqrt(l+1) is right for cglist - // 7. Add documentation - // 8. [done] run valgrind - // 9. [done] Add Wlhat - // 10. Update memory_usage() - // 11. Add exact FCC values for W_4, W_4_hat - // calculate W_l if (wlflag) { @@ -554,7 +546,6 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, idxcg_count++; } } - // Whats = [w/(q/np.sqrt(np.pi * 4 / (2 * l + 1)))**3 if abs(q) > 1.0e-6 else 0.0 for l,q,w in zip(range(1,max_l+1),Qs,Ws)] if (qn[il] < QEPSILON) qn[jj++] = 0.0; else { @@ -565,7 +556,7 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, } } - // Calculate components of Q_l, for l=qlcomp + // Calculate components of Q_l/|Q_l|, for l=qlcomp if (qlcompflag) { int il = iqlcomp; @@ -619,6 +610,7 @@ double ComputeOrientOrderAtom::polar_prefactor(int l, int m, double costheta) /* ---------------------------------------------------------------------- associated legendre polynomial + sign convention: P(l,l) = (2l-1)!!(-sqrt(1-x^2))^l ------------------------------------------------------------------------- */ double ComputeOrientOrderAtom::associated_legendre(int l, int m, double x) @@ -628,9 +620,9 @@ double ComputeOrientOrderAtom::associated_legendre(int l, int m, double x) double p(1.0), pm1(0.0), pm2(0.0); if (m != 0) { - const double sqx = sqrt(1.0-x*x); + const double msqx = -sqrt(1.0-x*x); for (int i=1; i < m+1; ++i) - p *= static_cast(2*i-1) * sqx; + p *= static_cast(2*i-1) * msqx; } for (int i=m+1; i < l+1; ++i) { From a862a8c764f8c0503d5a08899d98341568890b55 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Jun 2020 15:37:53 -0400 Subject: [PATCH 51/53] use {fmt} --- src/MOLECULE/bond_fene.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/MOLECULE/bond_fene.cpp b/src/MOLECULE/bond_fene.cpp index 91c0877478..f87f12a3b1 100644 --- a/src/MOLECULE/bond_fene.cpp +++ b/src/MOLECULE/bond_fene.cpp @@ -23,6 +23,7 @@ #include "memory.h" #include "error.h" #include "utils.h" +#include "fmt/format.h" using namespace LAMMPS_NS; @@ -82,13 +83,11 @@ void BondFENE::compute(int eflag, int vflag) // if r -> r0, then rlogarg < 0.0 which is an error // issue a warning and reset rlogarg = epsilon // if r > 2*r0 something serious is wrong, abort + printf("r = %g r0 = %g rlogarg = %g\n",sqrt(rsq),sqrt(r0sq),rlogarg); if (rlogarg < 0.1) { - char str[128]; - sprintf(str,"FENE bond too long: " BIGINT_FORMAT " " - TAGINT_FORMAT " " TAGINT_FORMAT " %g", - update->ntimestep,atom->tag[i1],atom->tag[i2],sqrt(rsq)); - error->warning(FLERR,str,0); + error->warning(FLERR,fmt::format("FENE bond too long: {} {} {} {}", + update->ntimestep,atom->tag[i1],atom->tag[i2],sqrt(rsq))); if (rlogarg <= -3.0) error->one(FLERR,"Bad FENE bond"); rlogarg = 0.1; } From bb40613db3cbc5d08665227906614f6812b09637 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Jun 2020 15:38:36 -0400 Subject: [PATCH 52/53] convert input degrees to internal radians for create_atoms rotate --- src/create_atoms.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 526a2069e6..3732662295 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -193,7 +193,7 @@ void CreateAtoms::command(int narg, char **arg) if (iarg+5 > narg) error->all(FLERR,"Illegal create_atoms command"); double thetaone; double axisone[3]; - thetaone = force->numeric(FLERR,arg[iarg+1]); + thetaone = force->numeric(FLERR,arg[iarg+1]) / 180.0 * MY_PI;; axisone[0] = force->numeric(FLERR,arg[iarg+2]); axisone[1] = force->numeric(FLERR,arg[iarg+3]); axisone[2] = force->numeric(FLERR,arg[iarg+4]); From 641f924161cbe3254e7ca9e64dbc60f25690f364 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Fri, 19 Jun 2020 14:44:13 -0600 Subject: [PATCH 53/53] Port changes to Kokkos package --- .../compute_orientorder_atom_kokkos.cpp | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp index d00dc3e238..fa613ad699 100644 --- a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp +++ b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp @@ -462,27 +462,31 @@ void ComputeOrientOrderAtomKokkos::calc_boop1(int ncount, int ii, in for (int il = 0; il < nqlist; il++) { const int l = d_qlist[il]; + // calculate spherical harmonics + // Ylm, -l <= m <= l + // sign convention: sign(Yll(0,0)) = (-1)^l + //d_qnm(ii,il,l).re += polar_prefactor(l, 0, costheta); const double polar_pf = polar_prefactor(l, 0, costheta); Kokkos::atomic_add(&(d_qnm(ii,il,l).re), polar_pf); SNAcomplex expphim = {expphi.re,expphi.im}; for(int m = 1; m <= +l; m++) { const double prefactor = polar_prefactor(l, m, costheta); - SNAcomplex c = {prefactor * expphim.re, prefactor * expphim.im}; - //d_qnm(ii,il,m+l).re += c.re; - //d_qnm(ii,il,m+l).im += c.im; - Kokkos::atomic_add(&(d_qnm(ii,il,m+l).re), c.re); - Kokkos::atomic_add(&(d_qnm(ii,il,m+l).im), c.im); + SNAcomplex ylm = {prefactor * expphim.re, prefactor * expphim.im}; + //d_qnm(ii,il,m+l).re += ylm.re; + //d_qnm(ii,il,m+l).im += ylm.im; + Kokkos::atomic_add(&(d_qnm(ii,il,m+l).re), ylm.re); + Kokkos::atomic_add(&(d_qnm(ii,il,m+l).im), ylm.im); if(m & 1) { - //d_qnm(ii,il,-m+l).re -= c.re; - //d_qnm(ii,il,-m+l).im += c.im; - Kokkos::atomic_add(&(d_qnm(ii,il,-m+l).re), -c.re); - Kokkos::atomic_add(&(d_qnm(ii,il,-m+l).im), c.im); + //d_qnm(ii,il,-m+l).re -= ylm.re; + //d_qnm(ii,il,-m+l).im += ylm.im; + Kokkos::atomic_add(&(d_qnm(ii,il,-m+l).re), -ylm.re); + Kokkos::atomic_add(&(d_qnm(ii,il,-m+l).im), ylm.im); } else { - //d_qnm(ii,il,-m+l).re += c.re; - //d_qnm(ii,il,-m+l).im -= c.im; - Kokkos::atomic_add(&(d_qnm(ii,il,-m+l).re), c.re); - Kokkos::atomic_add(&(d_qnm(ii,il,-m+l).im), -c.im); + //d_qnm(ii,il,-m+l).re += ylm.re; + //d_qnm(ii,il,-m+l).im -= ylm.im; + Kokkos::atomic_add(&(d_qnm(ii,il,-m+l).re), ylm.re); + Kokkos::atomic_add(&(d_qnm(ii,il,-m+l).im), -ylm.im); } SNAcomplex tmp; tmp.re = expphim.re*expphi.re - expphim.im*expphi.im; @@ -565,7 +569,6 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co idxcg_count++; } } - // Whats = [w/(q/np.sqrt(np.pi * 4 / (2 * l + 1)))**3 if abs(q) > 1.0e-6 else 0.0 for l,q,w in zip(range(1,max_l+1),Qs,Ws)] if (d_qnarray(i,il) < QEPSILON) d_qnarray(i,jj++) = 0.0; else { @@ -576,7 +579,7 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co } } - // Calculate components of Q_l, for l=qlcomp + // Calculate components of Q_l/|Q_l|, for l=qlcomp if (qlcompflag) { const int il = iqlcomp; @@ -623,6 +626,7 @@ double ComputeOrientOrderAtomKokkos::polar_prefactor(int l, int m, d /* ---------------------------------------------------------------------- associated legendre polynomial + sign convention: P(l,l) = (2l-1)!!(-sqrt(1-x^2))^l ------------------------------------------------------------------------- */ template @@ -634,9 +638,9 @@ double ComputeOrientOrderAtomKokkos::associated_legendre(int l, int double p(1.0), pm1(0.0), pm2(0.0); if (m != 0) { - const double sqx = sqrt(1.0-x*x); + const double msqx = -sqrt(1.0-x*x); for (int i=1; i < m+1; ++i) - p *= static_cast(2*i-1) * sqx; + p *= static_cast(2*i-1) * msqx; } for (int i=m+1; i < l+1; ++i) {