diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e09b6e6..904cd511 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,6 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") add_compile_options(-xHost -ipo -qopenmp -O3 -fp-model fast=2) endif () -#add_compile_options(-xHost -O3 -fp-model fast=2) - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") include(googletest) include(doxygen) diff --git a/README.md b/README.md index 25385e08..ad75b2e8 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Final Assignment - Cmake 3.28.3 - Doxygen 1.9.8 (`sudo apt install doxygen`) - Libxerces (`sudo apt install libxerces-c-dev`) + ## Build ### Configuration @@ -33,12 +34,15 @@ Final Assignment cmake -S . -B build -DBUILD_TESTS=ON ``` -To build with Intel's C++ compiler (```icx```/```icpx```), set the following options (currently this is on the [`coolmuc_test`](https://github.com/jkr11/MolSim/tree/coolmuc_test) branch, but it works locally) +To build with Intel's C++ compiler (```icx```/```icpx```), set the following options (currently this is on the [ +`coolmuc_test`](https://github.com/jkr11/MolSim/tree/coolmuc_test) branch, but it works locally) ```bash cmake -S . -B build -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ``` -for other compilers add the necessary compiler id to the options. + +for other compilers add the necessary compiler id to the options. + ```bash cd build/tests make -j $(nproc) @@ -79,6 +83,7 @@ Using the build script in `/script/` - Please note that `$BUILD` and `$INPUT` are only available if the scripts are executed via source. ### CMake Options + ```console - ENABLE_BENCHMARK : enables benchmark mode with no printing of info and writing to files - BUILD_TESTS : enables and builds the tests/ directory in the build directory @@ -100,13 +105,34 @@ Using the build script in `/script/` ``` - Output is located in `./output/` -- Checkpoints as an input have to be explicitely stated in the input ```.xml``` file. I would recommend putting - checkpoint into `/input/`. - - Example: +- Checkpoints as an input have to be explicitely stated in the input ```.xml``` file. In order to verify against the + checkpoint schema, all checkpoint files must point to the valid schema. As this location is hardcoded, all checkpoints + work out of the box if they are in the `/input/` directory. If they are somewhere else, you have to adjust the schema + path in the header of the checkpoint file. + +- A quick example for checkpointing in Assignment 4 task 3: (in `build/src`) + +```bash + ./MolSim -f ../../input/week43checkpoint.xml -c ../../input/ + ..... This eventually writes the checkpoint after running ---------- +``` + +the add the following to week43.xml: ```xml -../input/checkpoint.xml/ + + ../../input/ + + + ... + +``` + +and run + +```bash + ./MolSim -f ../../input/week43.xml ``` - `--step_size` is relative to the passed simulation time and not the number of iterations diff --git a/input/week43periodic.xml b/input/week43periodic.xml index 6295cfbf..f8a2479f 100644 --- a/input/week43periodic.xml +++ b/input/week43periodic.xml @@ -43,7 +43,7 @@ 40 true - ../scripts/output/test.xml + ../input/testcheckpointdelete.xml false 0 diff --git a/src/calc/VerletIntegrator.h b/src/calc/VerletIntegrator.h index 4ed564b5..484afe0d 100644 --- a/src/calc/VerletIntegrator.h +++ b/src/calc/VerletIntegrator.h @@ -37,7 +37,7 @@ class VerletIntegrator { */ double current_time_; /** - * Parallelization strategy used + * Parallelisation strategy used, default is 3 so no parallelisation */ ParallelStrategy strategy_ = ParallelStrategy::STRATEGY_3; diff --git a/src/defs/Generators/MembraneGenerator.h b/src/defs/Generators/MembraneGenerator.h index 948573ce..983fea56 100644 --- a/src/defs/Generators/MembraneGenerator.h +++ b/src/defs/Generators/MembraneGenerator.h @@ -6,7 +6,6 @@ #define MEMBRANEGENERATOR_H #pragma once #include "ParticleGenerator.h" -#include "utils/SpdWrapper.h" /** * @brief Generates Particles to a container in the shape of a cuboid [dim1, diff --git a/src/defs/Particle.cpp b/src/defs/Particle.cpp index a54073d6..488cf1d2 100644 --- a/src/defs/Particle.cpp +++ b/src/defs/Particle.cpp @@ -7,7 +7,6 @@ #include "Particle.h" -#include "debug/debug_print.h" #include "utils/ArrayUtils.h" #include "utils/SpdWrapper.h" diff --git a/src/defs/Thermostat.h b/src/defs/Thermostat.h index de6f4558..c1af4f12 100644 --- a/src/defs/Thermostat.h +++ b/src/defs/Thermostat.h @@ -10,7 +10,7 @@ #include "containers/ParticleContainer.h" /** - * adjusts the temperature of the system at a given periodic frequency + * @brief adjusts the temperature of the system at a given periodic frequency */ class Thermostat { private: diff --git a/src/defs/containers/DirectSumContainer.cpp b/src/defs/containers/DirectSumContainer.cpp index cbff13dd..6e6b37b0 100644 --- a/src/defs/containers/DirectSumContainer.cpp +++ b/src/defs/containers/DirectSumContainer.cpp @@ -27,8 +27,6 @@ DirectSumContainer::DirectSumContainer(const std::vector& particles) } } -// DirectSumContainer::~DirectSumContainer(); - void DirectSumContainer::addParticle(const Particle& p) { particles_.push_back(p); } diff --git a/src/defs/containers/LinkedCellsContainer.cpp b/src/defs/containers/LinkedCellsContainer.cpp index a335ac0c..de600d4f 100644 --- a/src/defs/containers/LinkedCellsContainer.cpp +++ b/src/defs/containers/LinkedCellsContainer.cpp @@ -421,14 +421,13 @@ void LinkedCellsContainer::computeInteractiveForcesForceBuffer( // for some reason parallelising this makes it slower, no matter which // approach is used - // #pragma omp parallel for collapse(2) for (size_t j = 0; j < particle_count_; j++) { for (int i = 1; i < num_threads; i++) { - // #pragma omp critical - { force_buffers[0][j] = force_buffers[0][j] + force_buffers[i][j]; } + { + force_buffers[0][j] = force_buffers[0][j] + force_buffers[i][j]; + } } } - // #pragma omp barrier #pragma omp parallel for for (size_t i = 0; i < particles_.size(); ++i) { @@ -685,10 +684,6 @@ void LinkedCellsContainer::applyReflectiveBoundary(const size_t dimension) { pos); // if both of them are so small that // they would trigger the boundary, the // simulation itself is already broken - // SpdWrapper::get()->info( - // "double dist: {} at [{}, {}, {}] adn v=[{}, {}, {}]", - // double_dist_to_boundary, p->getX()[0], p->getX()[1], p->getX()[2], - // p->getV()[0], p->getV()[1], p->getV()[2]); if (double_dist_to_boundary < sigma_factor * p->getSigma()) { const double force = LennardJones::simpleForce(*p, double_dist_to_boundary); @@ -707,11 +702,6 @@ void LinkedCellsContainer::applyReflectiveBoundary(const size_t dimension) { "Applied Force=[{}, {}, {}] to Particle at [{}, {}, {}]", p->getF()[0], p->getF()[1], p->getF()[2], p->getX()[0], p->getX()[1], p->getX()[2]); - - // SpdWrapper::get()->info( - // "Applied Force=[{}, {}, {}] to Particle at [{}, {}, {}]", - // p->getF()[0], p->getF()[1], p->getF()[2], p->getX()[0], - // p->getX()[1], p->getX()[2]); } } } @@ -772,10 +762,6 @@ void LinkedCellsContainer::applyPeriodicBoundary(const size_t dimension) { const auto adjacent_cell_index = cellCoordToIndex(adjacent_cell_coordinates); - // // account for the dimension that is checked - // particle_distance_offset[problematic_dimension] = - // domain[problematic_dimension]; - // iterate over all pairs and calculate force for (const auto &p : cells_[cell_index]) { diff --git a/tests/CLArgumentParserTest.cpp b/tests/CLArgumentParserTest.cpp index 118c05d2..7fefd787 100644 --- a/tests/CLArgumentParserTest.cpp +++ b/tests/CLArgumentParserTest.cpp @@ -6,7 +6,7 @@ #include "../src/io/CLArgumentParser.h" -/* +/** * @brief Parse example CLI arguments correctly */ TEST(CLArgumentParser, parse) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 400355bf..05633e6c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,7 +19,8 @@ if (BUILD_TESTS) XmlReaderTest.cpp TruncatedLennardJones.cpp IndexForceTest.cpp - SingularGravityTest.cpp) + SingularGravityTest.cpp + MixingTest.cpp) target_link_libraries(MolSimTest MolSimLib GTest::gtest_main) include(GoogleTest) diff --git a/tests/CheckpointTest.cpp b/tests/CheckpointTest.cpp index 0b608010..7aa4c97b 100644 --- a/tests/CheckpointTest.cpp +++ b/tests/CheckpointTest.cpp @@ -82,7 +82,7 @@ TEST(Checkpoint, cuboid) { } } -/* +/** * Test whether membranes (and especially the particle neighbours) are correctly * translated into a checkpoint */ @@ -117,7 +117,6 @@ TEST(Checkpoint, membrane) { char arg01[] = "MolSim"; char arg11[] = "-f"; char arg21[] = "../../tests/checkpoint_output_membrane_test.xml"; - // char arg31[] = "-c"; char* argv1[] = {arg01, arg11, arg21}; auto [name1, step1, write_checkpoint1] = CLArgumentParser::parse(3, argv1); diff --git a/tests/DirectSumContainerTest.cpp b/tests/DirectSumContainerTest.cpp index b9f9159e..e5c3d622 100644 --- a/tests/DirectSumContainerTest.cpp +++ b/tests/DirectSumContainerTest.cpp @@ -5,7 +5,7 @@ #include "../src/defs/containers/DirectSumContainer.cpp" #include "testUtil.h" -/* +/** * Add particle changes internal vector length */ TEST(DirectSumContainer, addParticleAndSize) { @@ -20,7 +20,7 @@ TEST(DirectSumContainer, addParticleAndSize) { << "ParticleContainer particle count not matching after addParticle."; } -/* +/** * singleIterator iterates over each distinct particle exactly once */ TEST(DirectSumContainer, singleIterator) { @@ -42,7 +42,7 @@ TEST(DirectSumContainer, singleIterator) { EXPECT_VECTOR_EQ(vec, {p1, p2, p3}); } -/* +/** * pair_iterator iterates over each distinct pair of particles exactly once */ TEST(DirectSumContainer, pair_iterator) { diff --git a/tests/IndexForceTest.cpp b/tests/IndexForceTest.cpp index caba3c45..f23ef487 100644 --- a/tests/IndexForceTest.cpp +++ b/tests/IndexForceTest.cpp @@ -10,7 +10,7 @@ #include "debug/debug_print.h" #include "testUtil.h" -/* +/** * TruncatedLennardJones with distance >= sigma * c */ TEST(IndexForce, single_index) { diff --git a/tests/LennardJonesTest.cpp b/tests/LennardJonesTest.cpp index a84c6a84..cf995de2 100644 --- a/tests/LennardJonesTest.cpp +++ b/tests/LennardJonesTest.cpp @@ -32,20 +32,6 @@ TEST(LennardJones, directionalForce2) { "Directional force wrong", 1e-5); } -/* - * LennardJones directional force, arbitrary example 3 - */ -/* removed because this never happens in an actual simulation -TEST(LennardJones, directionalForce3) { - Particle p({0, 0, 0}, {0, 0, 0}, 0, 0, 0); - Particle q({0, 0, 0}, {0, 0, 0}, 0, 0, 0); - LennardJones lj; - - dvec3 f = lj.directionalForce(p, q); - DVEC3_NEAR(f, {0.0, 0.0, 0.0}, "Directional force wrong", 1e-5); -} -*/ - /* * LennardJones directional force, arbitrary example 4 */ diff --git a/tests/LinkedCellsContainerTest.cpp b/tests/LinkedCellsContainerTest.cpp index 903dd97d..08683fc6 100644 --- a/tests/LinkedCellsContainerTest.cpp +++ b/tests/LinkedCellsContainerTest.cpp @@ -309,7 +309,7 @@ TEST(LinkedCellsContainer, pairIterator) { << "Pair count does not match reference implementation"; } -/* +/** * boundaryIterator(...) goes over all particles in boundary */ TEST(LinkedCellsContainer, boundaryIterator) { @@ -374,7 +374,7 @@ TEST(LinkedCellsContainer, haloIterator) { } /** - * @brief Tests if the C18 strategy is equal + * @brief Tests if the C18 strategy is equal to the standard pair iterator */ TEST(LinkedCellsContainer, C18Strategy) { LinkedCellsConfig config = {.domain = {20, 20, 20}, @@ -425,7 +425,6 @@ TEST(LinkedCellsContainer, C18Strategy) { for (const auto& force : forces2) { f = f + force->directionalForce(p, q); } - // InfoVec("In PI: ", f); p.addF(f); q.subF(f); }); @@ -439,6 +438,9 @@ TEST(LinkedCellsContainer, C18Strategy) { } } +/** + * Checks if Force Buffer calculates the same result as the standard pair iterator + */ TEST(LinkedCellsContainer, ForceBufferIteration) { LinkedCellsConfig config = {.domain = {20, 20, 20}, .cutoff_radius = 3, @@ -474,7 +476,6 @@ TEST(LinkedCellsContainer, ForceBufferIteration) { for (const auto& force : forces) { f = f + force->directionalForce(p, q); } - // InfoVec("In PI: ", f); p.addF(f); q.subF(f); }); diff --git a/tests/MembraneTest.cpp b/tests/MembraneTest.cpp index 3d7f1743..133f569a 100644 --- a/tests/MembraneTest.cpp +++ b/tests/MembraneTest.cpp @@ -128,7 +128,6 @@ TEST(Membrane, LC3x3) { for (Particle& p : particles) { SpdWrapper::get()->info("Neighbours: {}", p.getNeighbours().size()); for (const auto& [fst, snd] : p.getNeighbours()) { - // check for expired pointer (legacy from weak_ptr impl, maybe we go back ASSERT_TRUE(snd); } } @@ -158,7 +157,11 @@ TEST(Membrane, LC3x3) { } } -TEST(Membrane, LC4x4) { +/** + * Tests various properties of the membrane structure on 4x4 particles using + * id's, also tests harmonic Force + */ +TEST(Membrane, LC4x4Harmonic) { constexpr LinkedCellsConfig linked_cells_config = { .domain = {20, 20, 20}, .cutoff_radius = 4.0, @@ -176,19 +179,8 @@ TEST(Membrane, LC4x4) { std::vector particles; std::vector> singular_forces; - // singular_forces.push_back(std::make_unique(-0.001, 2)); singular_forces.push_back(std::make_unique(300, 2.2)); - // std::vector> interactive_forces; - // interactive_forces.push_back(std::make_unique()); - - // std::vector> index_forces; - // IndexForceConfig index_force_config = { - // .ids = {5}, - // .end_time = 15, - // .force_values = {0, 0, 0.8}, - // }; - // index_forces.push_back(std::make_unique()); std::cout << "global id counter " << std::endl; MembraneGenerator membrane_generator({0, 0, 0}, {4, 4, 1}, 2.5, 1.0, {0, 0, 0}, 0.0, 1.0, 1.0, 1, true, {}); diff --git a/tests/MixingTest.cpp b/tests/MixingTest.cpp index a8df6eb3..449a2343 100644 --- a/tests/MixingTest.cpp +++ b/tests/MixingTest.cpp @@ -9,7 +9,7 @@ #include "../src/forces/TruncatedLennardJones.h" -/* +/** * LennardJones directional force, mixing 1 */ TEST(LennardJones, mixing) { @@ -22,7 +22,7 @@ TEST(LennardJones, mixing) { "Directional force wrong", 1e-5); } -/* +/** * TruncatedLennardJones directional force, mixing 1 */ TEST(TruncatedLennardJones, mixing1) { diff --git a/tests/ThermostatTest.cpp b/tests/ThermostatTest.cpp index 62958a9a..145593d9 100644 --- a/tests/ThermostatTest.cpp +++ b/tests/ThermostatTest.cpp @@ -245,7 +245,7 @@ TEST(Thermostat, heating) { EXPECT_NEAR(thermostat->getTemperature(*container), 10, 1e-6); } -/* +/** * this test the gradual thermostat, so when deltaT is set. In this case its 2.0 * as specified, so we would expect that it converges after at 3k iterations (a * lot earlier actually but this is good enough) if n_thermostat is 100 @@ -319,8 +319,6 @@ TEST(Thermostat, gradual) { double temp = thermostat->getTemperature(*container); std::cout << "Temperature " << temp << std::endl; thermostat->setTemperature(*container); - // EXPECT_NEAR(thermostat->getTemperature(*container), - // temp + thermostat->delta_temp, thermostat->delta_temp); } } diff --git a/tests/WallTest.cpp b/tests/WallTest.cpp index 7e777740..89b12561 100644 --- a/tests/WallTest.cpp +++ b/tests/WallTest.cpp @@ -49,6 +49,9 @@ TEST(Wall, immovable) { }); } +/** + * Tests that walls are excluded from Thermostats + */ TEST(Wall, excludedFromThermostat) { LinkedCellsContainer container( {.domain = {3, 3, 3}, // better safe than sorry diff --git a/tests/XmlReaderTest.cpp b/tests/XmlReaderTest.cpp index 5aae049f..5875a512 100644 --- a/tests/XmlReaderTest.cpp +++ b/tests/XmlReaderTest.cpp @@ -7,7 +7,7 @@ // #include "io/file/in/xml/input.cxx" // <- this is necessary at least on // clang #include "io/file/in/xml/input.hxx" -#include "io/file/out/checkpoint-schema.cxx" +#include "io/file/out/checkpoint-schema.cxx" // <- Same for this #include "io/file/out/checkpoint-schema.hxx" #include "spdlog/fmt/bundled/os.h" #include "testUtil.h"