A simple, Python-based event-driven molecular dynamics simulation for hard-spheres. The simulation moves forward in time by calculating and moving to the time of the next 'event'. An event can be a collision between two particles, a particle and a wall or a graphical update checkpoint. The times associated with potential events are solved and placed in a priority queue. Particles move forward in time according to Newton’s Laws of Motion using a Velocity-Verlavet algorithm until the time of the first event in the priority queue is reached. If this is a collision event, then this is carried out and the queue is rebuilt based on the new system state. All collisions are treated as perfectly elastic.
This is a Pythonic version of the JavaScript EDMD code that I authored for the Visual Chemical Engineering (VCE) project. The JavaScript version is hosted on GitHub here.
Default conditions
./md.py
single particle and many sphere with infinite mass
python3 md_single.py -n 1
multiply the speeds with a 100 factor
python3 md.py -n 10 -s 100
Simulate 60 particles within a 500 x 500px simulation box and a maximum time step of size 10.0
./md.py -n 60 -x 500 -y 500 --dt 10.0
Display help and exit
./md.py --help
- Intelligent reconstruction of the event queue. This is currently rebuilt after every event, which is inefficient but acceptable for small scale simulations.
- Addition of particle interaction potentials.