LAMMPS is a really popular code for doing classical molecular dynamics simulations. In this post, we will dive deep into the heart of molecular dynamics and also how to construct the input file for LAMMPS.

It is really important to know that when you try to learn any softwares, it is really important to understand the underlying physics. That means you should be able to match the input file to a particular physical system that you want to simulate, and you need to be able to tell all the assumptions in that physical model in order to determine its accuracy compared to the real system. You need to know pros and cons of all the assumptions and how they influence the accuracy of your simulation, that's the key in learning any software. Without understanding, all you get is just numbers, without meaning. It is this understanding that is crucial in computational chemistry, otherwise you can be replaced by the AI and automated systems.

Fundamentals of Molecular Dynamics

Molecular dynamics is really easy to explain: just treating all the nuclei as point particles, and using the Newtonian equation of motion to solve the time evolution of the system, In mathematical term, that means:


where: \(\vec{f}_i=-\frac{\partial U}{\partial \vec{r}_i}\) and \(U\) is the many-body potential of the whole system. This potential energy will be approximated by using classical force field (in classical MD) or ab-initio simulation (in Ab-Initio MD).

So in order to create the input file, we need to know:

  • Structure of the system
    • Types of atoms in the system
    • The box of the system (periodic boundary condition)
    • The coordinates of all the atoms (whether it is cartesian or ractional)
    • The initial velocity of all the atoms
  • Choice of the force field
    • In Classical MD, there are many different possibilies
    • But what I'm interested in is how to use DeePMD as the potential to conduct MD simulations
  • Settings for the time-evolution
    • time step
    • how many iterations we want to conduct (run)
  • Environment
    • thermostate

Based on these knowledge, we can begin constructing our system.

Building the input files for LAMMPS

In general, there are two input files which we need for LAMMPS: (1) the input file for specifying all the parameters that we need (usually called in.lammps (2) the structural file, which contains all the structural information about the system (usually called

Here is an example file of in.lammps:

boundary p p p
units           metal
atom_style      atomic

neighbor 2.0 bin
neigh_modify every 10 delay 0 check no

mass    1   1
mass    2   16
mass    3   207

pair_style deepmd graph.pb

velocity    all create 300.0 23456778

fix 1 all nvt temp 300.0 0.5
timestep        1
thermo          100
#thermo_modify lost warn
dump myDump2 all custom 1000 type x y z

run 100000
write_data lmp_pbWater.dat

And in below is the example file of (written by ASE)
162      atoms
3  atom types
0.0      10.649027999999999  xlo xhi
0.0      12.296438999999999  ylo yhi
0.0                      20  zlo zhi


1   3      10.611976730389317      12.281261505342298     0.14421639999999999
2   3        3.40217883344196     0.18510936306209999     0.25271199999999999
3   3      7.0938796064978398     0.53783837213903996      19.963010999999998
4   3      1.6040585085579595      3.1612538754066595    0.025070400000000003
5   3      5.2367321453709597      3.3484584287099701               0.3163494
6   3      8.7861238873168794      3.3167923930683902     0.23802740000000003
7   3    0.035780521099439994         6.4401701622453      19.889976599999997
8   3        3.23187414666168      6.3574113158792098      19.974749800000001
9   3      6.9956113345263597      6.3705788346179695      19.955363999999999
10   3      1.8640909468537195      9.6805229719140904      19.898860800000001

In the above I only show the coordinates of first 10 atoms, the lammps structure file can be generated by using ASE (Atomic Simulation Environment).