LAMMPS
Published:
Notes while learning to use LAMMPS molecular dynamics code
Install LAMMPS
Windows
Use a pre-compiled Windows installer
Ubuntu Linux
In terminal, execute:
$ sudo apt-get install lammps-stable
Running LAMMPS
LAMMPS simulation input files are text files named in.filename
Run simulations in command line (terminal, shell, console) with
lmp -in in.filename
lmp < in.filename
-in
is necessary when running in parallel with mpirun
Input files
The in.filename
LAMMPS input file describes the system parameters, physics, logging, etc.
It is read line-by-line as it executes and will stop when an error occurs or the last line is reached. Thus, order of commands is important
Comments in the input file are made by placing a #
before the text to be commented.
Sample LAMMPS simulation
Sample LAMMPS simulation input file
Download the text file and move it to a working directory. Using a terminal within this directory, execute lmp -in in.logo.txt
This simulation produces two output files, log.lammps
, the simulation log, and tmp.dump
, the trajectory file
Most useful simulation commands
units
- Select the system of units to use for simulation parametersdump
- Define method and selection of output data to print out in thedump
read_data
- Read data fileminimize
- Energy minimization simulation
Variables
Force fields
LAMMPS Force Fields documentation
LAMMPS Data Format
Sample Data File with Annotations
A Data File
describes the system to be simulated, including system properties, atom and molecular topologies, atom coordinates. These files must be called by the read
command within a LAMMPS script.
First line is file description, next line is skipped. Every line after is read (unless commented with a #)
Data files consist of a mandatory three sections, header
, Masses
, and Atoms
. If necessary, additional sections must be included: Bonds
, Angles
, Dihedrals
, and Impropers
The header
section is placed at the top of the file, outlining the number of atoms, bonds, angles, dihedrals, types of atoms/bonds/angles/dihedrals, and simulation box dimensions
LAMMPS Description (1st line of file)
100 atoms (this must be the 3rd line, 1st 2 lines are ignored)
95 bonds (# of bonds to be simulated)
50 angles (include these lines even if number = 0)
30 dihedrals
20 impropers
5 atom types (# of nonbond atom types)
10 bond types (# of bond types = sets of bond coefficients)
18 angle types
20 dihedral types (do not include a bond,angle,dihedral,improper type
2 improper types line if number of bonds,angles,etc is 0)
-0.5 0.5 xlo xhi (for periodic systems this is box size,
-0.5 0.5 ylo yhi for non-periodic it is min/max extent of atoms)
-0.5 0.5 zlo zhi (do not include this line for 2-d simulations)
Following is an empty line then the Masses
of each atom type
Masses
1 mass
...
N mass (N = # of atom types)
then the Atoms
section. The structure of each line of the Atoms
section is
Atoms
1 molecule-tag atom-type q x y z nx ny nz (nx,ny,nz are optional -
... see "true flag" input command)
...
N molecule-tag atom-type q x y z nx ny nz (N = # of atoms)
See the documentation for explanations and examples of all remaining sections
Polymer simulation in lammps
MS State Polymer simulation tutorial
The above tutorial simulates a linear polymer chain constructed from 100 bonded atoms. The initial configuration file PE_cl100.txt
was prepared in MATLAB. Download PE_cl100.txt here
LAMMPS simulation script in.deform.polychain.txt
will perform the simulations defined in Hossain, Tschopp, et al. 2010, Polymer. This script performs equilibration and minimization of the system
Outputs are log.lammps
, log.PE_cl100
, and a number of dump.com_#.cfg
files. These describe how the simulation was ran, what its results were, and frames to visualize, correspondingly
The tutorial instructs to download several software to clean and visualize the dump files, but I found it easier to comment the included dump
command and write my own
dump 1 all atom 6 ${simname}.lammpstrj
This way it will produce a single output file that can be readily opened in VMD, my visualizer of choice
Adding water to simulation box
Fortran code to generate a simulated box of water
Converting GROMACS OPLS-AA topology to LAMMPS Data File
GRO2LAM v.1.25 - BETA - Python2.7 module to convert GROMACS topology to LAMMPS input file
LigParGen OPLS-AA topology generator
LigParGen is used to produce OPLS force field parameters for organic molecules (proteins, polymers, etc.)
The software may be used in a browser or by command-line on a local LigParGen server
Sample command-line execution for producing the structure and topology files of benzene and naming output files ‘Test1’:
LigParGen -s c1ccccc1 -r Test1 -c 0 -o 0 -l
Converting GRO structure and topology files to LAMMPS
Intermol is a program to convert files between several molecular dynamics software, including GROMACS and LAMMPS
References
Axel Kohlmeyer’s TopoTools and Tutorials - Useful software for preparing LAMMPS input files