Molecular dynamics – what is it all about?
A fluid consisting of two different species of atoms (red and blue).
In my first blog post, I briefly announced that I would be working on molecular dynamics simulations in the course of my project this summer. Now that I have already run some small simulations on the Mare Nostrum supercomputer at the Barcelona Supercomputing Center for training purposes, I would like to share my experiences made with molecular dynamics so far and also explain in this short intermezzo what molecular dynamics is all about. Further below I will show a visualization of one of my exercise examples.
What is Molecular Dynamics?
Forces and Potential Energies
Molecular dynamics refers to a (family of) computer simulation technique(s) used to compute the movements of particles, particularly atoms and molecules. It is based on Newton’s 2nd law “F = m⋅a” (yes exactly the one he used to calculate the orbits of the celestial bodies) and computes the trajectories of particles by integrating these equations of motion numerically. In order to do so, we need to know the forces acting upon each atom due to interaction with all the other atoms of the system. It is, however, not trivial at all to obtain these forces.
Fortunately, the forces can be derived from a so-called potential (the forces are actually the negative gradient of the potential), which is a key ingredient for doing molecular dynamics. The potential is a function of the positions of the nuclei and there are at least two main approaches to compute this potential (function) for use in molecular dynamics, leading to the distinction between Classical Molecular Dynamics and Ab-initio Molecular Dynamics.
Classical vs. Ab-initio Molecular Dynamics
In classical MD, the electrons are abstracted away, leaving only the nuclei whose relative positions are used to calculate the potential energy (surface) and thus the force field needed for integration. In ab-initio MD on the other hand, the electrons are indeed taken into account, albeit in an approximated form, which allows for more accurate but also far more computationally intensive calculations. This is usually realized by means of Density Functional Theory, DFT for short, but that is a story of its own. A relatively recent approach is to fit potentials computed by DFT using machine learning methods and to use the resulting machine-learned force fields (ML-FF) for classical MD. This allows near ab-initio accuracy at much lower computational cost.
In my project, however, I will be using classical molecular dynamics as it is better suited for the types of structures and lengths of time scales as well as temperatures that I will analyze.
The last and probably most important step in molecular dynamics is post-processing: The trajectories of the particles by themselves are only a part of the whole, but in order to obtain relevant physical quantities of the system under study, it is common to calculate averages over all particles and/or time.
Simple MD Example
What you see here is a two dimensional simulation of a binary fluid (i.e. two atomic species) where the particles interact via a simple Lennard-Jones Potential. At the beginning of the simulation, the atoms are placed at two distinct regions of space, but after some time they will mix perfectly due to being allowed to interact with each other. Although this example does not represent the kinds of systems I will simulate during the Summer of HPC, as I will be dealing with materials in the solid state, to me it is still a nice visualization of how complex natural phenomena – such as diffusion – can be modeled and simulated using rather simple techniques.
Source Code for Visualization: https://lammpstutorials.github.io/tutorials/01-SimpleMolecularSimulation.html