Multi Resolution Molecular Dynamics 0.4.0
Multi Resolution Molecular Dynamics
Loading...
Searching...
No Matches
Getting Started

This page covers building MRMD, the options you are likely to need, and running your first simulation.

The repository README.md carries the same instructions in a shorter form.

Requirements

MRMD needs only a compiler and CMake; every other mandatory dependency is fetched and built automatically during configuration.

  • A C++ compiler with C++20 support
  • CMake >= 3.25

Fetched automatically, at the pinned versions:

Dependency Purpose
Kokkos performance portability, backend selection
Cabana AoSoA particle containers and neighbor lists
CLI11 command line parsing in the examples
yaml-cpp configuration files
googletest unit tests

Found on the system rather than fetched, and therefore optional:

  • HDF5 — enables all H5MD input and output. Without it the H5MD paths of Tutorials 03 and 05 through 08 are unavailable and their tests are not registered.
  • MPI — enabled with MRMD_ENABLE_MPI.
  • Doxygen and optionally Graphviz — only needed to build this documentation.

Building

git clone https://github.com/XzzX/mrmd
cmake -S mrmd \
-B mrmd-build \
-DCMAKE_BUILD_TYPE=Release \
-DKokkos_ENABLE_SERIAL=ON \
-DKokkos_ENABLE_OPENMP=ON \
-DKokkos_ARCH_NATIVE=ON
cmake --build mrmd-build --parallel 8

Then run the first example:

cd mrmd-build/examples/00_IdealGas_NVE
./00_IdealGas_NVE

Every example accepts --help and takes its parameters from the command line, so you can shorten a run with --nsteps 10 while trying things out.

Build options

MRMD specific options:

Option Default Description
MRMD_BUILD_DOCS OFF Build this documentation (target docs)
MRMD_ENABLE_COVERAGE OFF Enable code coverage (clang only)
MRMD_ENABLE_HDF5 OFF Enable HDF5 / H5MD support
MRMD_ENABLE_TESTING ON Build tests and register them with ctest
MRMD_USE_SHARED_SPACE OFF Use Kokkos shared space
MRMD_VERBOSE_ASSERTS OFF Verbose asserts (CPU only)
MRMD_WERROR OFF Treat compiler warnings as errors
MRMD_VECTOR_LENGTH 1 Vector length of the AoSoA particle containers

In addition to the standard CMake build types, MRMD defines DebugOptimized, which combines the debug flags with -O3. It is useful together with MRMD_VERBOSE_ASSERTS and the Kokkos debug options when a simulation misbehaves but a plain Debug build is too slow to reach the problem.

Choosing a Kokkos backend

The target architecture and the execution backend are selected through Kokkos, not through MRMD. Enable one or more backends with Kokkos_ENABLE_* and name the architecture with Kokkos_ARCH_*.

For a CPU build using all cores of the build machine:

-DKokkos_ENABLE_SERIAL=ON -DKokkos_ENABLE_OPENMP=ON -DKokkos_ARCH_NATIVE=ON

For an Nvidia GPU:

-DKokkos_ENABLE_SERIAL=ON -DKokkos_ENABLE_OPENMP=ON -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON

Each example prints the execution space it was compiled for on startup, which is the quickest way to confirm the backend you intended is the one in use.

Running the tests

cd mrmd-build
ctest --parallel 4 --output-on-failure

The examples are part of the test suite: each is registered as Example.<name> and executed with a small step count, so a passing ctest run also means every tutorial on this site still compiles and runs.

Using MRMD as a library

cmake --install mrmd-build --prefix /path/to/install

Downstream CMake projects locate it with find_package and link the mrmd::mrmd target:

find_package(mrmd REQUIRED)
add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE mrmd::mrmd)

Point CMake at the install location with -DCMAKE_PREFIX_PATH=/path/to/install when configuring the downstream project.

Building this documentation

cmake -S mrmd -B mrmd-build -DMRMD_BUILD_DOCS=ON
cmake --build mrmd-build --target docs

The HTML output is written to mrmd-build/docs/html/index.html. The published copy lives at https://xzzx.github.io/mrmd/.

Next steps

Work through the Tutorials in order. They start from a minimal ideal gas and build up to a full multi-resolution production workflow, and each one is a complete, runnable program.