Post-simulation analysis
Overview
Teaching: 15 min
Exercises: 15 minQuestions
How do we use LAMMPS
rerun
commands?What are the limitations of this command?
Objectives
Understand the use the LAMMPS
rerun
command.
LAMMPS reruns
In this section of the the course, we will be spending some time exploring the LAMMPS rerun
functionality.
This is an oft overlooked functionality that, when used correctly, can save a significant amount of compute time.
The LAMMPS rerun
command allows you to perform a pseudo-simulation from the outputs of a LAMMPS trajectory (or dump) file.
Reruns are easy to set up, especially if you have a copy of the simulation script that was used to generate the trajectory file being used, and are quick and inexpensive to run.
Reruns can be used to:
- Calculate thermodynamic properties of the system that were overlooked or not calculated in the initial simulation.
- Compute system properties (e.g. radial distribution functions, mean square displacement) using LAMMPS computes once the simulation is complete.
- Compute thermodynamic properties of a system as if it had been run using a different potential.
- Compute properties of a system that would have been costly to compute during the initial run.
In this section, we will explore how to use this functionality and its associated restrictions.
Exercise: Running a LAMMPS simulation from a trajectory file
For this course, we have prepared a number of exercises.
If you have not done so yet, you can get a copy of these exercises by running (make sure to run this from /work
):
git clone --depth=1 https://www.github.com/EPCCed/archer2-advanced-use-of-lammps.git
cd exercises/2-post-analysis/
Once this is downloaded, please cd exercises/2-post-analysis/
. In this directory you will find three files:
in.lj_start
is a LAMMPS input script to simulate a small Lennard-Jones gas and generate a LAMMPS trajectory file.in.lj_rerun
is a LAMMPS input script for running a simulation from the LAMMPS trajectory file generated by runningin.lj_start
run.slurm
is the Slurm submission script that will let us run our initial simulation.
To run the initial in.lj
simulation, run:
sbatch run.slurm
The simulation will generate a LAMMPS trajectory file called nvt.lammpstrj
that we will be using to run our rerun
simulation.
You can run the rerun
simulation from the serial nodes as this is a quick, not computationally intensive simulation that can be run on a single core.
To run the rerun simulation, comment the first srun
command and uncomment the second one.
In this example, we are using this rerun to generate two new bits of information:
- We are outputting a number of new thermodynamic outputs with our
thermo_style
command. - We are generating a radial distribution function (RDF) of the system.
Exploring RDF outputs
In
in.lj_rerun
, the RDF is being calculated every 100 timesteps. What happens if you calculate it every 500 timesteps instead? What about every 50 timesteps?NOTE: For the
fix ave/time
command, the first number defines the frequency at which snapshots are taken (i.e. how many timesteps elapse between each snapshot), the second number defines how many snapshots are taken, and the third number defines over how many timesteps averages should be calculated. For this exercise, you will want to keep the third number constant, and ensure that the product of the first and second numbers equals the third.Solution
Setting the snapshot frequency to 500 instead of 100 results in a similar (if perhaps noisier) RDF.
Setting the snapshot frequency to 50, however, results in no RDF being output. This is because the
nvt.lammpstrj
LAMMPS trajectory had atom positions output every 100 timesteps. LAMMPS cannot calculate what happened during the interim timesteps.This is one of the limitations of the
rerun
command: you will only get information from what you feed into it (unsurprisingly). However, even with that, it is a very powerful command.
Changing the potential
So far in this exercise, we have been using a truncated Lennard-Jones potential. What happens to the energy when the truncation distance is changed?
You can change the truncation distance by altering the
pair_style lj/cut 3.5
command. What happens to the total energy (etotal
) when you change the truncation distance from 3.5 sigma to 2.5 sigma? What about if you change it to 1.5 sigma?Solution
The total energy of the system should not change very much if the pairwise particle interactions are truncated at a distance of 2.5 sigma instead of 3.5 sigma. When the cutoff distance is dropped to 1.5 sigma, however, the energy should be noticeably different. This indicates that a distance of 2.5 sigma is “good enough” for truncating these Lennard-Jones interactions, but that a distance of 1.5 sigma is not.
Key Points
The LAMMPS
rerun
command is very powerful and can have many uses.However, this command is limited to the information that is fed into it – it can be used to extract information from an existing simulation trajectory but it is not a new simulation.