Skip to content

Dominik16786/Molecular_dynamics_simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2D Molecular Dynamics Simulation (Lennard–Jones Fluid)

This repository contains a 2D molecular dynamics (MD) simulation of interacting particles using a Lennard–Jones (12–6) potential with periodic boundary conditions.

The project includes:

  • A C++ implementation used for numerical experiments and data generation
  • A Python implementation that reproduces the same physics and provides a real-time animation with energy and temperature plots

The simulation models a classical Lennard–Jones fluid and demonstrates thermostatting, energy conservation, velocity distributions, and particle trajectories.


Physical Model

Particles

  • Identical particles with mass ( m = 1 )
  • Motion restricted to two spatial dimensions
  • Periodic boundary conditions in a square simulation box

⚛️ Interaction Potential

The particles in this simulation interact via a shifted Lennard-Jones potential. To ensure numerical stability and prevent discontinuities, both the potential and its derivative are shifted to zero at the cutoff radius $r_c$.

The core potential is defined as:

$$ U(r) = 4 \left[ \left( \frac{1}{r} \right)^{12} - \left( \frac{1}{r} \right)^6 \right] $$

To guarantee the continuity of both energy and force, the implementation follows these conditions at the cutoff $r_c$:

  • Zero Potential: $U(r_c) = 0$
  • Zero Force: $\frac{dU}{dr} \Big|_{r=r_c} = 0$

Numerical Method

Time Integration

  • Velocity Verlet–type integration scheme
  • Includes a Nosé–Hoover–style thermostat
  • A thermostat variable dynamically adjusts the kinetic energy to control temperature

Thermostat Parameters

  • Q: thermostat mass (controls coupling strength)
  • T: target temperature (constant or time-dependent)

Repository Structure


C++ Implementation

Features

  • Square-lattice initialization
  • Maxwell–Boltzmann velocity distribution
  • Removal of center-of-mass velocity
  • Periodic boundary conditions (minimum image convention)
  • Lennard–Jones forces with cutoff shifting
  • Energy tracking (kinetic, potential, total)
  • Velocity histograms
  • Single-particle trajectories
  • Temperature ramps
  • Output to text files for analysis

About

2D molecular dynamics simulation of Lennard–Jones particles with C++ and Python, including real-time visualization, energy tracking, and thermostatting.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors