Computational Mathematics, Science and Engineering

Sarkas: A Fast Pure-Python Molecular Dynamics Code

Posted on

Sarkas is a pure-python molecular dynamics (MD) code we are currently developing for wide (open source) use. To our knowledge, Sarkas is the first production-scale pure-Python molecular dynamics code designed for simulating plasmas. Current areas of application are strongly coupled plasmas which include dusty plasmas, ultracold neutral plasmas, and warm dense matter.

Sarkas offers the ease of use of Python while being highly performant with execution speeds comparable to or exceeding that of compiled languages (e.g., C). Sarkas’s high-performance originates from extensive use of Numpy arrays and Numba’s just-in-time compilation.

The documentation with tutorials on the current capabilities of Sarkas can be found here.

Applications

Binary Ultracold Neutral Plasmas

Our work showed that MD simulations can be used in tandem with experiments to study the complex phenomena in high energy density plasmas. In this work we used Sarkas to study temperature relaxation in binary ultracold neutral plasmas.

The plot below shows that MD simulations accurately describe experiments. This is importnat because it validates our interaction model between the particles in the experiment and further validates the experimental assumptions on the initial conditions. In addition, we demonstrated that the current theoretical models on temperature relaxation do not apply to ionic mixtures and are valid only when the mass difference between the dynamical species of the plasmas is very high.

More details of this work can be found in our papers: paper in Nature Communication, paper in Physics of Plasmas

Plasma Instabilities

Here, we show how MD can be used to study kinetic instabilities in plasmas. In the movie below, the vertical axis is particle velocity and the horizontal axis is space (that is, it is phase space). The plasma is mostly composed of particles in equilibrium (red points) with a bump on the tail (blue particles at large, positive velocity). This situation mimics a plasma with an injected pulse of fast particles in it. What is interesting about this MD simulation is that it resolves particles down to their atomic scale, while successfully generating longer wavelength instabilities, thereby spanning extreme length scales. This shows promise for using Sarkas to study a wider range of kinetic and hydrodynamic phenomena building from the atomistic level. Read more in our paper in Phys Rev Research

Dynamical Properties of Plasmas

As an example, MD simulations of strongly coupled plasmas enable access to a plasma’s static and dynamic properties. Static structural information is obtained through the radial distribution function g(r) using the particle positions. Dynamical properties such as transport processes are also available by computing the transport coefficients from the particle trajectories. As a example, in the figure below the results of dynamic structure factor S(k,ω) for a Yukawa plasma, and the resulting wave dispersion properties.

Performance and Capabilities

Interparticle interactions currently included are long-range Coulomb and intermediate- to short-range screened Coulomb (Yukawa interactions), quantum statistical potentials, generalized Lennard-Jones potential. The computational cell can be either 3D or 2D with periodic, reflecting or open boundary conditions. For short range potentials, O(N) scaling is achieved with a neighbor list (linked cell); conversely, for intermediate- to long-range forces the Particle-Particle Particle-Mesh (PPPM) algorithm is employed.

To illustrate performance of Sarkas we compared the execution times with a equivalent version of the code written entirely in C. The figure below compares C and Python timings of the two most computationally intensive parts of the code: the Linked-Cell-List algorithm used in the Particle-Particle part and charge assignment to a grid for the Particle-Mesh part. The times (Intel Xeon E5-2670v2, 2.6GHz) are for one step of the force calculation for 10^{4} – 10^{6} particles. The performance of Sarkas is similar to that of the C version, even with C’s O3 compiler optimization. This is a remarkable result considering that Sarkas is a pure Python (with Numba) code.

You can find more details on the speed and capabilities used in Sarkas in our paper in Computer Physics Communications. Details of this the theoretical and numerical aspects can be found in this paper.

Join us!

Are you interested in contributing to an open-source python package and learn physics at the same time? We have several projects available. Here are a couple of examples

Improve Sarkas’ speed by exporting the code to GPUs

Add more capabilities. We would like to add a thermal conductivity calculation to out suite, a quasi localized charge approximation calculation

Simplify the code by using other well established python packages such as astropy and plasmapy

Improve the post-processing module with machine learning techniques