-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplotNEB.py
executable file
·61 lines (45 loc) · 1.51 KB
/
plotNEB.py
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
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
""" NEB plotter.
This script plots the NEB spline obtained from a VTST Tools NEB calculation.
The data is obtained from the nebef.dat file.
Author: Uthpala Herath
Usage:
plotNEB.py -n 29
"""
from scipy.interpolate import interp1d
import numpy as np
import matplotlib.pyplot as plt
import argparse
def plot_NEB(natoms=1):
""" This method plots a spline for the NEB obtained from the
nebef.dat file generated by VTST tools."""
# Open nebef.dat
fi = open("nebef.dat","r")
data = fi.readlines()
fi.close()
# save energy in list
y_dft = [float(i.split()[2]) for i in data]
x = np.arange(0, len(y_dft))
y_dft = np.array(y_dft)
# normalizing and shifting
y_dft = (y_dft - y_dft[0]) / natoms
# spline
f_dft = interp1d(x, y_dft, kind="cubic")
xnew = np.linspace(0, len(y_dft)-1, num=100, endpoint=True)
# plotting
plt.figure(figsize=(13, 9))
plt.plot(x, y_dft, "mo", label="Raw NEB points")
plt.plot(xnew, f_dft(xnew), "m-", label="Interpolated NEB")
plt.axhline(color="black", linestyle="--")
plt.xlabel("Reaction coordinate")
plt.ylabel("Energy (eV/atom)")
plt.legend(loc="best")
plt.grid(color="gainsboro", ls="--", lw=0.6)
plt.title("NEB")
plt.savefig("NEB.pdf")
#plt.show()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("-n","--natoms", type=int, help="Number of atoms",default=1)
args = parser.parse_args()
plot_NEB(args.natoms)