MD Engine
A Custom High-Performance Molecular Dynamics (MD) Simulation Engine.
Using OVITO for visualization.
Overview
A high-performance Molecular Dynamics (MD) engine built from scratch to simulate fluid thermodynamics. Instead of relying on pre-built solvers like LAMMPS, I engineered a hybrid architecture that distributes workload across hardware: bond and angle forces are solved using OpenMP threading on the CPU, while O(N2) non-bonded interactions are solved on custom CUDA kernels. The core physics utilizes a BAOAB Langevin integrator, selected over standard Velocity Verlet for its superior energy stability and accurate sampling of the canonical (NVT) ensemble.
The engine implements a custom spatial hashing algorithm (Cell Lists) to optimize neighbor searching, enabling real-time simulation of thousands of atoms. A key challenge was stabilizing "flexible" water models, where stiff bond vibrations often cause numerical explosions. I solved this by engineering a multi-stage "Relaxation Phase" that dynamically adjusts friction and timesteps to resolve high-energy atomic overlaps. The system accurately reproduces experimental benchmarks, matching the Radial Distribution Function (RDF) of liquid water with a primary peak at ~2.80 Å.
The engine outputs simulation trajectories in LAMMPS dump format, which can be visualized using tools like OVITO.
Highlights
- Built a hybrid CPU/GPU physics engine using C++20, OpenMP, and CUDA.C
- Engineered a custom spatial hashing (Cell Lists) algorithm for O(N) neighbor searching.
- Leveraged OpenMP and atomic operations to parallelize bonds and angle force calculations.
- Implemented the BAOAB integrator for thermodynamically accurate temperature control.
- Achieved experimental parity for Liquid Water density and structure (RDF).