Libra: An open-source "Methodology Discovery" Library

Classical Molecular Dynamics Tutorial


This tutorial shows how to run classical molecular dynamics (MD) simulations of atomistic systems under various conditions. In principle, you can use these examples as a template for your particular calculations (also meaning you'd need to modify only very few parameters). The working files showing how to use different objects are located in the /tests/test_md directory of the Libra package.

Before doing this tutorial, it is recommended to go through the Molecular Mechanics tutorial, because it explains the main components and the operations (the creation of molecular system, force fields, hamiltonians, setting up interactions, organizing MD workflow) of the run_aa_md_state.py file. This is the file we are to run in each sub-directory of the present tutorial. It is almost the same for all cases, except for few places in which we introduce certain variations.



Example 1: SubPc, case 1: NVE dynamics of the isolated system

This is the first example in this tutorial, so we'll discuss some common elements here. In the later examples, we will focus only on the distinctions between the cases.

The initial workflow for initialization is the following:

So far we have performed only the initialization. Now, we can proceed to actual dynamics. In fact, the rest of the script does two types of dynamics: cooling (optimization by a simulated annealing) and the production MD. In addition to the previous tutorials, we now utilize the State class of the libscript library. The State class is designed to represent a thermodynamic state of the system. That is it encodes the state (coordinates/velocities) of the system, as well as the state of the bath (thermostat/barostat). It also contains information about the macroscopic and miscroscopic observables: potential, kinetic, total energies, extended system-bath energy, current temperature, pressure, simulation cell shape and volume, and other variables.

Together with the State class, we use an auxiliary MD class, defined in the same header. This class is essentially a container for the MD settings. So, we first create an object of MD type and then pass it to the State object to tell it how to perform MD simulations:

md = MD({"max_step":1,"ensemble":"NVE","integrator":"DLML","terec_exp_size":10,"dt":20.0,"n_medium":1,"n_fast":1,"n_outer":1})

Here, we utilize a constructor that takes a Python dictionary and extracts values for the keywords relevant to/defined in the MD class.

The State class has several methods for setups, initialization, and actual simulations. Lets look closely at some of them:

The current micro/macroscopic descriptors of the State can be accessed via the exported variables:

Please see the header file or a corresponding section of the Documentation, for a more comprehensive list of variables

To summarize, the workflow of the simulation part is following:

To analyze the MD run and to assess its quality, we plot some of the obervables in Fig. 1. We also show a video of the MD simulation (10 ps).


a

b

c

d

e

Figure 1.SubPc-C60 system simulated in vacuum within the NVE ensemble for 10 ps. (a) MD movie; (b) temperature; (c) total energy; (d) extended energy (conserved invariant); (e) potential energy.

What we see:



Example 1: SubPc, case 2: NVT dynamics of the isolated system

We extend the previous case by actually adding a thermosat:

therm = Thermostat({"Temperature":278.0,"Q":100.0,"thermostat_type":"Nose-Hoover","nu_therm":0.01,"NHC_size":5})
ST.set_thermostat(therm)

and by setting the "md.ensemble" variable to "NVT":

md = MD({"max_step":100,"ensemble":"NVT","integrator":"DLML","terec_exp_size":10,"dt":20.0,"n_medium":1,"n_fast":1,"n_outer":1})

We also do several cycles of cooling, before the NVT simulation. The results are shown in Fig. 2


a

b

c

d

e

Figure 2.SubPc-C60 system simulated in vacuum within the NVT ensemble for 10 ps. The thermostat frequency parameter nu_therm = 0.01. (a) MD movie; (b) temperature; (c) total energy; (d) extended energy (conserved invariant); (e) potential energy.

What we see:



Example 1: SubPc, case 3: NVT dynamics of the isolated system, smaller thermostat frequency

Everything is same as in the previous case (case 2). The only difference is that we decrease the frequency of the thermosat (increase inertia):

therm = Thermostat({"Temperature":278.0,"Q":100.0,"thermostat_type":"Nose-Hoover","nu_therm":0.001,"NHC_size":5})

The results are shown in Fig. 3

a

b

c

d

e

Figure 3.SubPc-C60 system simulated in vacuum within the NVT ensemble for 10 ps. The thermostat frequency parameter nu_therm = 0.001. (a) MD movie; (b) temperature; (c) total energy; (d) extended energy (conserved invariant); (e) potential energy.

What we see:



Example 2: Au, case 1: NVT dynamics of isolated Au cluster in vacuum

Now, lets consider a different type of systems. Instead of organic, go to inorganic. So, try gold. This is a bigger crystal created with a script (see another tutorial) that generates a supercell good for modeling systems with Au(111) surface. Instead of molecular, go to crystalline. Well, we start with periodic-looking structure, but since there are no actual periodic boundary conditions applyed, the system is still a formally molecular one (isolated cluster).

Because this particular system consists of atoms, rather than molecules, there are no bonded interactions (bond stretching, angle bending, dihedrals, imporopers, etc). Moreover, the system is not charged, so there are no electrostatic interactions either. The only type of interactions remaining are the vdw interactions. So, the setup of the ForceField object can be simplified:

uff = ForceField({"mb_functional":"LJ_Coulomb","R_vdw_on":40.0,"R_vdw_off":55.0 })

The second important alteration made in comparison to the Example 1 scripts, is that the format of the input file defining molecular structure is different from the one we used before. The present file format follows closely the official pdb format. That is why we load it using the option "true_pdb" in the Load_Molecule function:

LoadMolecule.Load_Molecule(U, syst, "au.pdb", "true_pdb")

We start simulating the Au cluster using the default UFF Lennard-Jones (LJ) parameters for Au atom: `epsilon = 0.039` and `sigma = 3.293`. The results are shown in Fig. 4


a

b

c

d

e

Figure 4.Au system simulated in vacuum within the NVT ensemble for 10 ps. The thermostat frequency parameter nu_therm = 0.001. (a) MD movie; (b) temperature; (c) total energy; (d) extended energy (conserved invariant); (e) potential energy.

What we see:



Example 2: Au, case 2: NVT dynamics of isolated Au cluster in vacuum, larger `epsilon`

Ok. We now run one more simulation with the `epsilon` parameter of Au scaled by the factor of 10: `epsilon = 0.39`. The results are shown in Fig. 5


a

b

c

d

e

Figure 5.Au system simulated in vacuum within the NVT ensemble for 10 ps. The thermostat frequency parameter nu_therm = 0.001. Using a scaled `epsilon` value of 0.39 : (a) MD movie; (b) temperature; (c) total energy; (d) extended energy (conserved invariant); (e) potential energy.

What we see:



Example 2: Au, case 3: NVT dynamics of isolated Au cluster in vacuum, even larger `epsilon` and smaller `sigma`

Lets keep the parameters changing even more. We now set `epsilon = 2.8` and reduce `sigma` to `sigma = 3.0` (well, we could be just with the `epsilon` parameter alone, but I was curious to try a new thing). The results are shown in Fig. 6


a

b

c

d

e

Figure 6.Au system simulated in vacuum within the NVT ensemble for 10 ps. The thermostat frequency parameter nu_therm = 0.001. Using a scaled parameters: `epsilon = 2.8` and `sigma = 3.0` : (a) MD movie; (b) temperature; (c) total energy; (d) extended energy (conserved invariant); (e) potential energy.

What we see:



Example 2: Au, case 4: NVT dynamics of a periodic Au cluster, using scaled `epsilon`

So, we know how to produce a stable Au cluster in isolated molecule calculations. Now, it is time to switch to a bit more complex case - periodic systems. We will not run an MD with periodic boundary conditions (PBC), which means the atoms are always confined into the simulation box and they interact with their own replicas (and replicas of all other atoms) in the periodically translated nearby boxes.

We start with the scripts and parameters from the case 2: `epsilon = 0.39` and `sigma = 3.293`. On top of that we introduce two additions:

Everything else remains as before. The simulation results are summarized in Fig. 7


a

b

c

d

e

Figure 7.Au system simulated with PBC within the NVT ensemble for 10 ps. The thermostat frequency parameter nu_therm = 0.001. Using a scaled parameters: `epsilon = 0.39` and `sigma = 3.293` : (a) MD movie; (b) temperature; (c) total energy; (d) extended energy (conserved invariant); (e) potential energy.

What we see: