-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmd_utils.py
More file actions
40 lines (33 loc) · 1.06 KB
/
Copy pathmd_utils.py
File metadata and controls
40 lines (33 loc) · 1.06 KB
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
import csv
import numpy as np
from matplotlib import pyplot as plt
def gen_line_array (N,F):
a=np.arange(1,N+1)
b=F*a/N
c=b[::-1]
return np.vstack((a,b,c))
def gen_sin_array (N,F):
a=np.arange(1,N+1)
b=F*np.sin((a/(N/(np.pi/2))))
c=b[::-1]
return np.vstack((a,b,c))
def plot_data(state_fname, plot_fname):
with open(state_fname) as csv_file:
csv_reader = csv.DictReader(csv_file, fieldnames=['step', 'energy'], delimiter=",")
next(csv_reader, None) # skip headers
steps = []
energies = []
n = 0
for row in csv_reader:
steps.append(int(row['step']))
energies.append(float(row['energy']))
n += 1
steps = np.array(steps)
energies = np.array(energies)
fig, ax1 = plt.subplots()
ax1.plot(steps, energies, lw=1, label="Potential energy")
ax1.set_xlabel("Step")
ax1.set_ylabel("Potential energy [kJ/mole]")
plt.savefig(plot_fname)
plt.close()
#print("Plot saved in {} file".format(plot_fname))