Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 32 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -100,13 +105,34 @@ Using the build script in `/script/`
```

- Output is located in `./output/<current_time>`
- 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/<name_of_your_choice.xml>
..... This eventually writes the checkpoint after running ----------
```

the add the following to week43.xml:

```xml

<checkpoint>../input/checkpoint.xml/</checkpoint>
<checkpoint>
<name>../../input/
<name_of_your_choice.xml>
</name>
...
</checkpoint>
```

and run

```bash
./MolSim -f ../../input/week43.xml
```

- `--step_size` is relative to the passed simulation time and not the number of iterations
Expand Down
2 changes: 1 addition & 1 deletion input/week43periodic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<t_end>40</t_end>
<twoD>true</twoD>
<checkpoint>
<name>../scripts/output/test.xml</name>
<name>../input/testcheckpointdelete.xml</name>
<is_membrane>false</is_membrane>
<domain>
<x>0</x>
Expand Down
2 changes: 1 addition & 1 deletion src/calc/VerletIntegrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion src/defs/Generators/MembraneGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/defs/Particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include "Particle.h"

#include "debug/debug_print.h"
#include "utils/ArrayUtils.h"
#include "utils/SpdWrapper.h"

Expand Down
2 changes: 1 addition & 1 deletion src/defs/Thermostat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions src/defs/containers/DirectSumContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ DirectSumContainer::DirectSumContainer(const std::vector<Particle>& particles)
}
}

// DirectSumContainer::~DirectSumContainer();

void DirectSumContainer::addParticle(const Particle& p) {
particles_.push_back(p);
}
Expand Down
20 changes: 3 additions & 17 deletions src/defs/containers/LinkedCellsContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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]);
}
}
}
Expand Down Expand Up @@ -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]) {
Expand Down
2 changes: 1 addition & 1 deletion tests/CLArgumentParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "../src/io/CLArgumentParser.h"

/*
/**
* @brief Parse example CLI arguments correctly
*/
TEST(CLArgumentParser, parse) {
Expand Down
3 changes: 2 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions tests/CheckpointTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ TEST(Checkpoint, cuboid) {
}
}

/*
/**
* Test whether membranes (and especially the particle neighbours) are correctly
* translated into a checkpoint
*/
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions tests/DirectSumContainerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "../src/defs/containers/DirectSumContainer.cpp"
#include "testUtil.h"

/*
/**
* Add particle changes internal vector length
*/
TEST(DirectSumContainer, addParticleAndSize) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tests/IndexForceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "debug/debug_print.h"
#include "testUtil.h"

/*
/**
* TruncatedLennardJones with distance >= sigma * c
*/
TEST(IndexForce, single_index) {
Expand Down
14 changes: 0 additions & 14 deletions tests/LennardJonesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
9 changes: 5 additions & 4 deletions tests/LinkedCellsContainerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ TEST(LinkedCellsContainer, pairIterator) {
<< "Pair count does not match reference implementation";
}

/*
/**
* boundaryIterator(...) goes over all particles in boundary
*/
TEST(LinkedCellsContainer, boundaryIterator) {
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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);
});
Expand All @@ -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,
Expand Down Expand Up @@ -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);
});
Expand Down
18 changes: 5 additions & 13 deletions tests/MembraneTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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,
Expand All @@ -176,19 +179,8 @@ TEST(Membrane, LC4x4) {
std::vector<Particle> particles;

std::vector<std::unique_ptr<SingularForce>> singular_forces;
// singular_forces.push_back(std::make_unique<SingularGravity>(-0.001, 2));
singular_forces.push_back(std::make_unique<HarmonicForce>(300, 2.2));

// std::vector<std::unique_ptr<InteractiveForce>> interactive_forces;
// interactive_forces.push_back(std::make_unique<TruncatedLennardJones>());

// std::vector<std::unique_ptr<IndexForce>> index_forces;
// IndexForceConfig index_force_config = {
// .ids = {5},
// .end_time = 15,
// .force_values = {0, 0, 0.8},
// };
// index_forces.push_back(std::make_unique<IndexForce>());
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, {});
Expand Down
4 changes: 2 additions & 2 deletions tests/MixingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "../src/forces/TruncatedLennardJones.h"


/*
/**
* LennardJones directional force, mixing 1
*/
TEST(LennardJones, mixing) {
Expand All @@ -22,7 +22,7 @@ TEST(LennardJones, mixing) {
"Directional force wrong", 1e-5);
}

/*
/**
* TruncatedLennardJones directional force, mixing 1
*/
TEST(TruncatedLennardJones, mixing1) {
Expand Down
4 changes: 1 addition & 3 deletions tests/ThermostatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

Expand Down
Loading