Members:
- Lukas Baader
- Severin Schmidmeier
- Tony Wang
- Link: https://github.com/wngTn/MolSim
- Branch: main
- Revision: -
In this assignment we have used the compiler g++ 11.1.0.
⚠️ If you have slow internet: We fetch three packages with FetchContent, thus the initial CMake-build may take some time (~1min)
⚠️ File structure: Please put thebuilddirectory (the directory you executemake) directly in the root project path, else the automatically generated files will not work properly. Like such:MolSim . ├── CMakeLists.txt ├── Doxyfile ├── README.md ├── build/ ├── cmake/ ├── doc_pages/ ├── input/ ├── libs/ ├── media/ ├── src/ └── test/
We decided to include the googletest library with CMakes FetchContent. Thus, it is required to have reasonably fast and stable internet to successfully build with CMake (Deutsche Bahn-wifi with 20 Mb/s download speed is still enough).
The CMake does not automatically enable building the tests. Therefore, to run the tests,
you have to explicitly turn on the option. Thereafter, you can head to your build folder, go to the test subfolder
and run ctest.
- Create the build directory and cd into it:
mkdir build && cd build - Build everything, including the tests in the build directory by turning on the option:
cmake .. -DBUILD_TEST=ON- Compile everything, including the tests:
make # use "make -j6" for faster compilation- Change directory to
testand runctest:
cd test && ctestIf you do not want to compile the tests, you can turn off the build option in the CMake by executing cmake without any arguments (Step 2):
cmake .. # Makefile won't build the tests anymoreAs suggested we chose spdlog as our logging tool and implemented a simple logger in MolSim. We put the logging there, because we have easy access to all the data we want to log. Also, we decided against an asynchronous logger, as the basic logger is really fast already and with the execution mode flag we introduced a way to enable this task when needed:
./MolSim [...] -m debug
The log file and all future log files are saved here:
build/
├── ...
└── logs/
├── molsim.log
└── future.log
The input format is JSON. You can declare several shapes in an array. For every shape of those you have to specify the following:
| Property | Possible Values |
|---|---|
| type | "cuboid", "sphere" |
| pos | [<double>, <double>, <double>] |
| vel | [<double>, <double>, <double>] |
| radius Only for "spheres" |
<double> |
| N | [<int>, <int>, <int>] |
| distance | <double> |
| mass | <double> |
| brownian factor | <double> |
| brownianDIM | <int> |
🚧 There are two implementations for generating spheres, one is suited for LJP, one not. Currently the one working for LJP is used
Here is an example for an input file, which creates two "cuboid" shapes:
This is the ./input/files/input_assignment_2.json file.
{
"shapes":
[
{
"type": "cuboid",
"pos": [0.0,0.0,0.0],
"vel": [0.0,0.0,0.0],
"N": [40,8,1],
"distance": 1.1225,
"mass": 1.0,
"brownianFactor": 0.1,
"brownianDIM": 2
},
{
"type": "cuboid",
"pos": [15.0,15.0, 0.0],
"vel": [0.0,-10.0,0.0],
"N": [8,8,1],
"distance": 1.1225,
"mass": 1.0,
"brownianFactor": 0.1,
"brownianDIM": 2
}
]
}If you use the "sphere" type, you have to additionally provide a radius!
For example:
{
"shapes":
[
{
"type": "sphere",
"pos": [0.0,0.0,0.0],
"vel": [0.0, 0.0,0.0],
"radius": 1.0,
"distance": 1.1225,
"mass": 1.0,
"brownianFactor": 0.0,
"brownianDIM": 3
},
{
"type": "cuboid",
"pos": [15.0,1.0,1.0],
"vel": [-175.0,-0.5,-0.5],
"N": [12,12,12],
"distance": 1.1225,
"mass": 50.0,
"brownianFactor": 0.0,
"brownianDIM": 3
}
]
}
⚠️ If you do not comply to these specifications, it may lead to unexpected behavior
In this assignment, our input format has changed a little, to give you - our sacred and precious user - even more functionality!
First and foremost, build and Compile our program as usual:
mkdir build && cd build
cmake ..
makeThe general program call is now:
./MolSim [-i <input_file>] [-g <generator input>] [-e <end_time>] [-d <delta_t>] [-w <writer>] [-c <calculator>] [-b <brownian_motion_velocity_mean>] [-r] [-m <execution_mode>]| Flag | Possible Values | Explanation | Default |
|---|---|---|---|
i |
path/to/file |
This is the relative or absolute path to your input_file. |
None |
g |
path/to/file |
Specify an input file used for the ParticleGenerator. | None |
e |
<double> | The end_time value | 1000 |
d |
<double> | The delta_t value | 0.14 |
w |
v, vtk, x, xyz | Specifies the output writer, consequently also the output file format | v (vtk) |
c |
g, grav, gravitation, lj, lennardjones | Declares what forces between the particles should be calculated | lj (lennardjones) |
b |
<double> | The brownian motion velocity mean. Will be discarded for the JSON file generated particles | None |
r |
None | Specifies whether random particles should be generated. | None |
m |
normal, debug, benchmark | Specifies which execution mode should be used. Debug to enable logging, normal to disable logging or benchmark to disable all output files | normal |
⚠️ Random generated files only support the input file format of assignment 1. Also, you will need Python 3 to use it.
Example:
./MolSim -g ../input/files/input_assignment_2.json -e 5 -d 0.0002This will use:
- input_assignment_2.json as
input_filefor the ParticleGenerator - 5 as
end_time, - 0.0002 as
delta_t - vtk as
writer(default) - lennardjones as
calculator(default) - 0.1 as
brownian motion velocity mean(set in the input_file) - normal execution mode (default)
Another example:
./MolSim -i ../input/files/eingabe-sonne.txt -c grav -m debugThis will use:
- eingabe-sonne.txt as
input_file - because file format of assignment 1 is used, the t flag is omitted
- 1000 as
end_time(default) - 0.14 as
delta_tdefault) - vtk as
writer(default) - gravitation as
calculator - No
brownian motion velocity mean - debug execution mode
In our benchmarks we have used three datasets: a small, medium and large dataset:
- Small dataset contains 120 particles
- Medium dataset contains 432 particles
- Large dataset contains 768 particles
- Build and compile the program. Your current work directory should be the build directory:
pwd
/path/to/build-
Benchmarking with the small dataset:
- Generate the small dataset:
python ../input/generate_json.py --size small - We have used 1 as
end_timeand 0.0002 as ourdelta_t:./MolSim -g ../input/files/automatic_generated_input_s.json -e 5 -d 0.0002 -m benchmark
- Generate the small dataset:
-
Benchmarking the medium dataset:
- Generate the medium dataset:
python ../input/generate_json.py --size medium - Specify the correct
end_timeanddelta_tvalue:./MolSim -g ../input/files/automatic_generated_input_m.json -e 5 -d 0.0002 -m benchmark
- Generate the medium dataset:
-
Benchmarking the large dataset:
- Generate the small dataset:
python ../input/generate_json.py --size small - Specify the correct
end_timeanddelta_tvalue:./MolSim -g ../input/files/automatic_generated_input_l.json -e 5 -d 0.0002 -m benchmark
- Generate the small dataset:
📝 Careful: Make sure to enable the benchmark mode (-m benchmark) and specify the correct
end_timeanddelta_tvalues.Also, the large dataset might take some minutes (~3-4min) to finish
PS: Be aware to set your build type to RELEASE (not DEBUG 🙂)
We have tested our benchmarks on three different machines:
- Intel Core i5-4460 CPU @ 3.20GHz, 4 Cores - 8 GB RAM (Native Linux)
- Intel Core i5-8265 U CPU @ 1.80GHz, 4 Cores - 8 GB RAM (Native Linux)
- Macbook Pro (M1 Pro, 2021) - 16 GB RAM (macOS)
There we compared:
- Compile-Time (we used
make -j4) - Setup-Time
- Runtime
Here is the animation of two colliding blocks from the worksheet:
We also generated a sphere and shot a single particle with high speed into it:
In this assignment we managed to run the program on the new MacBook Pro with the M1 Pro processor.
To run the program on macOS with an M1 (Pro) processor you have to follow the following steps:
- Install homebrew (taken from https://brew.sh/)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"- Install xerces-c:
brew install xerces-c- Install GCC 11.1.0:
brew install gcc- Create a build directory and cd into it:
mkdir build && cd build- Execute CMake and set gcc and g++ compiler you just installed:
cmake .. -DCMAKE_C_COMPILER=<path to your gcc-11> -DCMAKE_CXX_COMPILER=<path to your g++-11>If you have installed gcc via homebrew on an M1 (Pro),
then the default path to your gcc-11 is: /opt/homebrew/Cellar/gcc/11.2.0_1/bin/gcc-11.
The default path to your g++-11 is: /opt/homebrew/Cellar/gcc/11.2.0_1/bin/g++-11.
- And finally you can compile everything:
make -j📝 NOTE
We use ANSI escape sequences for our console output. If you do not see any color and see seemingly random sequences, switch to a Unix operating system :).




