This is an event-driven molecular dynamics (EDMD) code for hard spheres. It uses neighbor lists [1] and an efficient event calendar [2] for efficiency.
See http://arxiv.org/abs/2201.01100 for a complete description and benchmarking.
If you use this code, please cite:
Efficient event-driven simulations of hard spheres
F. Smallenburg, European Physical Journal E 45, 22 (2022).
Configuration files created by these codes (.sph format) can be visualized with Colloid Visualization Tool.
Four simulation codes are included, in their respective subfolders. Three of these are variations of a microcanonical simulation code, simulating a constant number
- Cell contains a simulation code where collision checks are based on a cell list.
- Multi contains a simulation code where collision checks are based on a neighbor list, and is more typically more efficient than the Cell code at sufficiently high densities.
- Single contains a simulation code where collision checks are based on a neighbor list, and only a single event is scheduled per particle. This is typically more efficient than the Multi code.
- Additionally, a separate simulation code Grow is included in which the particles grow over time until a desired packing fraction is reached. This can be helpful for creating initial configurations.
Each code consists of a single code file plus a header file. A makefile is included for each code, as well as sample initial configurations. All simulation parameters are defined as global variables near the top of the main code file.
We simulate systems of
- Lengths are measured in units of the maximum particle size
$\sigma$ . - Mass is measured in units of a reference mass
$m$ , which is typically chosen to be the mass of a particle with diameter$\sigma$ . - Time is measured in units of
$\tau = \sqrt{\beta m \sigma^2}$ . Here,$\beta = 1/k_B T$ with$k_B$ Boltzmann's constant. Note that the simulation assumes that no particles with a diameter greater than$1 \sigma$ exist in the simulation, and uses this assumption in the creation of the cell list. Hence, all particles necessarily have a diameter$\sigma_i \leq \sigma$ . By default, the simulation code sets the mass of all particles to be equal to$m$ when loading an initial configuration, but mass is taken into account when determining the effect of collisions. Hence, other choices for the mass can readily be implemented by adapting the initialization functions.
The simulation code measures the pressure
where
Additionally, as a check on conservation of energy, the simulation measures the temperature of the system, using the equipartition theorem
The temperature is reported in units of
The configuration files from the simulation are written in a simple text-based format, which can contain multiple snapshots per file. For each frame, the format consists of
- One line containing just the number of particles
- One line containing the box size, specifying the box length
$L_x$ ,$L_y$ , and$L_z$ along the three axes, separated by whitespace. - One line per particle containing: a letter indicating particle type, three numbers indicating the real-space particle coordinates, and one number indicating the particle radius. The movie files that are created by the simulation code include multiple of these frames consecutively in a single text file. Note that although the code assumes periodic boundary conditions, coordinates of particles that leave the box during the simulation will be printed as being outside of the simulation box, to allow for analysis of long-time dynamics. Hence, any structural analysis or visualization should apply periodic boundary conditions explicitly.
The simulation codes can read in snapshots in this format as initial configurations. Periodic boundaries will be applied to the snapshot at the start of the simulation. Note that the simulation code assumes that all box lengths, positions, and radii are given in units of
Adaptation to different configuration file formats can be done via modification of the loadparticles, write, and outputsnapshot functions.