Home Post Processing of the thermodynamics data using python code
Post
Cancel

Post Processing of the thermodynamics data using python code

Post Processing

There are lots of option available for analyzing the LAMMPS output data, out of many options few methods are illustrated here

Using Python Script

Plotting T,P,E,Rho Vs time

Follow this github repository github for more details about the code. Here, sample code is given for the analysis of our log.lammps file generated by our previously obtained simulations.

Before running the Code do the following

1
2
- Install python3
- Install the package using "pip install lammps-logfile"

Sample code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import lammps_logfile
import matplotlib.pyplot as plt
from lammps_logfile import running_mean
log = lammps_logfile.File("log.lammpsr")
plt.figure(figsize=(8,8))
print(log.get_keywords())
data = lammps_logfile.File("log.lammps")	
plt.subplot(221)
for j in range(log.get_num_partial_logs()):
	x = (log.get("Step", run_num=j)/1000000)
	y = log.get("Temp", run_num=j)
	plt.cla()
	plt.plot(x, y)
	plt.xlabel("$time(ns)$")
	plt.ylabel("$Temperature(K)$")
	plt.tight_layout()
	temp_avg = running_mean(y,100)
	plt.plot(x, temp_avg)			
plt.subplot(222)    
for k in range(log.get_num_partial_logs()):
	x = log.get("Step", run_num=k)/1000000
	y = log.get("Press", run_num=k)
	plt.cla()
	plt.plot(x, y)
	plt.xlabel("$time(ns)$")
	plt.ylabel("$Pressure(Atm)$") 
	press_avg = running_mean(y,100)
	plt.plot(x, press_avg)        
plt.subplot(223)    
for l in range(log.get_num_partial_logs()):
	x = log.get("Step", run_num=l)/1000000
	y = log.get("TotEng", run_num=l)
	plt.cla()
	plt.plot(x, y)
	plt.xlabel("$time(ns)$")
	plt.ylabel("$TotEng(Kcal/mole)$")
	toteng_avg = running_mean(y,100)
	plt.plot(x, toteng_avg)    
plt.subplot(224)    
for m in range(log.get_num_partial_logs()):
	x = log.get("Step", run_num=m)/1000000
	y = log.get("Density", run_num=m)
	plt.cla()
	plt.plot(x, y)
	plt.xlabel("$time(ns)$")
	plt.ylabel("$Density(g/A^3)$")  
	density_avg = running_mean(y,100)
	plt.plot(x, density_avg)           	
plt.tight_layout()
plt.show()

Above code, print four graphs with all the data points and the running average taking 100 data points.

image

Calculating RDF using VMD

There are many articles available on RDF, here we have discussed step wise method to plot RDF in VMD

  • Load data files and .dcd to VMD
  • Then go to Analysis menu then select RDF
  • Then follow the prompt and fill the required data.
This post is licensed under CC BY 4.0 by the author.
Contents