Gromacs
File formats
tpr file
tpr file extension stands for portable binary run input file. This file contains the starting structure of your simulation, the molecular topology and all the simulation parameters. This file is in binary format it cannot be read with a normal editor. To read a portable binary run input file type:
1
% gmx dump -s topol.tpr | less
You can also compare two tpr files using:
1
% gmx check -s1 top1 -s2 top2 | more
trr file
Files with the trr file extension contain the trajectory of a simulation. In this file all the coordinates, velocities, forces and energies are printed as you told GROMACS in your mdp file. This file is in portable binary format an can be read with gmx dump.
1
% gmx dump -f traj.trr | less
You can also get a quick look in the contents of the file (number of frames etc.) using:
1
% gmx check -f traj.trr
Analysis
Radial distribution functions
-cn option for gmx rdf could produce the cumulative number RDF, i.e. the average number of particles within a distance r.
select atoms in rdf analysis
1
% gmx rdf -f run4.trr -s run4.tpr -o rdf_Li_Li.xvg -ref 'name "Li*"' -sel 'name "Li*"'
Plot
xvg plot
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
52
def gmx_xvg_plot_obj(fig, file, title='title', \
xlabel='xlabel', xmin=0, xmax=10, ylabel='ylabel', ymin=0, ymax=10, \
lc='r', ls='solid', legend_label='label'):
import numpy as np
import matplotlib.pyplot as plt
font = {'family' : 'DejaVu Sans', 'color' : 'black','weight' : 'normal','size': 24.0 }
plt.style.use("default")
linewidth=2
#ax1.spines['right'].set_visible(False) # remove right plot boundary
#ax1.spines['top'].set_visible(False) # remove top plot boundary
ax1.spines['left'].set_linewidth(linewidth) # make left axis thicker
ax1.spines['bottom'].set_linewidth(linewidth) # make bottom axis thicker
ax1.spines['right'].set_linewidth(linewidth) # make left axis thicker
ax1.spines['top'].set_linewidth(linewidth) # make bottom axis thicker
ax1.xaxis.set_tick_params(width=linewidth) # make x-axis tick marks thicker
ax1.yaxis.set_tick_params(width=linewidth) # make y-axis tick marks thicker
ax1.xaxis.set_tick_params(labelsize=font["size"])
ax1.yaxis.set_tick_params(labelsize=font["size"])
x, y = [], []
with open(file) as f:
for line in f:
cols = line.split()
if "title" in line and title == 'title':
title = ' '.join(line.split()[2:]).replace( '"', '')
elif "xaxis" in line and "label" in line and xlabel=='xlabel':
xlabel=eval(' '.join(line.split()[3:]))
elif "yaxis" in line and "label" in line and ylabel=='ylabel':
ylabel=' '.join(line.split()[3::]).replace( '"', '')
if len(cols) == 2 and "@" not in line:
x.append(float(cols[0]))
y.append(float(cols[1]))
if "D[ LIion]" in line:
diffusion=line
ax1.set_title(title,fontdict=font)
ax1.set_xlabel(xlabel,fontdict=font)
ax1.set_ylabel(ylabel,fontdict=font)
ax1.set_xlim(xmin,xmax)
ax1.set_ylim(ymin,ymax)
ax1.plot(x,y, c=lc, linestyle=ls, linewidth=linewidth+2, label=legend_label)
# plt.plot(x,y, c='r', linewidth=linewidth+3, label=label)
ax1.legend(handlelength=3,fontsize=12)
#fig.savefig(file+'.png', bbox_inches='tight')
return(fig)
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
os.chdir('/gdrive/MyDrive/sherlock/LiS/DME_Li2S6_1_96')
fig = plt.figure(figsize=(15, 5))
ax1 = fig.add_subplot(121)
kargs = {"file":'npt2_Li_O_DME_rdfcn.xvg',\
"title":'titleXX',\
"xlabel":'xlabel',"xmin": 0.00,"xmax":1,
"ylabel":'coordination number',"ymin": 0.00,"ymax":10,\
"lc":'r', "ls":'-',\
"legend_label":'Li-O_DME (DME)'}
fig=gmx_xvg_plot_obj(fig, **kargs)
os.chdir('/gdrive/MyDrive/sherlock/LiS/DME_Li2S6_TTE')
kargs = {"file":'npt2_Li_O_DME_rdfcn.xvg',\
"title":'title',\
"xlabel":'xlabel',"xmin": 0.00,"xmax":1,
"ylabel":'coordination number',"ymin": 0.00,"ymax":10,\
"lc":'#0000CC',"ls":'dashed',\
"legend_label":'Li-O_DME (DME/TTE)'}
fig=gmx_xvg_plot_obj(fig, **kargs)
kargs = {"file":'npt2_Li_O_TTE_rdfcn.xvg',\
"title":'title',\
"xlabel":'xlabel',"xmin": 0.00,"xmax":1,
"ylabel":'coordination number',"ymin": 0.00,"ymax":10,\
"lc":'gray', "ls":'dashdot',\
"legend_label":'Li-O_TTE (DME/TTE)'}
fig=gmx_xvg_plot_obj(fig, **kargs)
os.chdir('/gdrive/MyDrive/sherlock/LiS/DPE_Li2S6')
kargs = {"file":'npt2_Li_O_DPE_rdfcn.xvg',\
"title":'Li-O coordination',\
"xlabel":'xlabel',"xmin": 0.00,"xmax":1,
"ylabel":'coordination #',"ymin": 0.00,"ymax":10,\
"lc":'darkgreen', "ls":'dotted',\
"legend_label":'Li-O_DPE (DPE)'}
fig=gmx_xvg_plot_obj(fig, **kargs)