A simple molecular-dynamics simulation in Rust, using the Lennard-Jones potential for particle interactions. Particles are also confined within a Box, which also emits a Lennard-Jones potential. There is also a simple implementation of a harmonic oscillator centered at the origin. This Rust
code only generates the data in csv
format, analyzing can be done with whatever tool desired.
All cases bellow are inside the cases folder
The simple
simulation considers the particles are in a vacuum confined by walls.
The medium
simulation considers the particles inside a medium. The medium has a defined temperature and viscosity. Viscosity drags the particles and the temperature modulates random fluctuations which can move the particles.
The following example is with one particle at a distance from walls where they have no effect on it. Because of the high temperature, random fluctuations will push the particle out of equilibirum and into the Lennard-Jones potentials of the walls:
The harmonic
simulation considers a simple harmonic oscillator potential at the origin. This simulation was analyzed with Matlab, with this code.
Video plots were made with Matlab. The idea behind this Rust code is to generate and save the data in csv
format. The data can then be analyzed by other better suited languages, like Matlab
.
The video plots shown above were made with this Matlab code inside the analysis
folder.
- Download code.
- Adapt sims to your needs
- Build it and run it (I suggest doing it in release mode):
cargo build --release
cargo run --release
When data is saved to the data
folder, you can plot it and analyze it however you want!