An implementation of molecular dynamics simulation of the Lennard-Jones system in a box with real-time visualization. The code solves the N-body problem numerically and utilizes CUDA-enabled NVIDIA GPU's to significantly accelerate the calculations, allowing real-time simulation (~60 frames per second) of large systems containing thousands of particles. The code uses reduced variables and allows to study the thermodynamic properties of the Lennard-Jones system.
This implementation was inspired by the nbody example from NVIDIA CUDA SDK.
The code is separated into three parts:
- the core library
- a graphical user interface (GUI) program to run the box simulation and visualization
- an example of running the simulation from command line
- Adjust the number of particles, temperature and density, and the time step
- Switch between CPU or GPU (CUDA) based calculation
- Velocity Verlet integrator
- Microcanonical (EVN) or canonical-like (TVN, constant kinetic temperature dynamics) ensemble
- Periodic or hard-wall boundary conditions
- Real-time visualization of the system motion (in OpenGL)
- Calculation and visualization of the radial distribution function and the velocity distribution
- CMake v3.18+
For using CUDA-enabled GPUs
- NVIDIA CUDA Toolkit, tested on v10.2+
- CUDA-enabled GPU (otherwise only the CPU simulation can be used) with compute capability 3.0+
For the graphical user interface
- Qt5 framework and OpenGL support to run the GUI
The code is cross-platform and based on CMake. It has been tested on Microsoft Windows 10 (using Visual Studio or CLion IDE), Ubuntu 20.04 (via the command line), Mac OS 13.2 Ventura (both CLion IDE or command line)
Use the CMake to generate the project and build it. Make sure that CMake can find the CUDA toolkit and Qt5. An example on Unix:
mkdir build
cd build
cmake ../
make
# Run the GUI program
./src/gui/QtLennardJones
gaseous phase (T* = 1, ρ* = 0.01) | liquid phase (T* = 1, ρ* = 0.85) |
mixed phase (T* = 1, ρ* = 0.3) | solid phase (T* = 1, ρ* = 1.1) |
- The
helper-cuda.h
andhelper_string.h
CUDA headers that are either downloaded from GitHub at the CMake step or taken from CUDA SDK if it is installed in the system - Mersenne Twister random number generator by M. Matsutomo and T. Nishimura (implementation by R. J. Wagner)
- Qt5 framework for the GUI frontend (LGPL3)
- QCustomPlot Qt C++ widget for plotting and data visualization by Emanuel Eichhammer (GPL)
Copyright (C) 2013-2023 Volodymyr Vovchenko