-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_energy.py
39 lines (28 loc) · 956 Bytes
/
plot_energy.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
import matplotlib.pyplot as plt
import matplotlib
font = {'weight' : 'bold',
'size' : 8}
matplotlib.rc('font', **font)
import numpy as np
data = np.fromregex('fort.2', r"\s*([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)", [('iteration', int), ('kinetic', float), ('potential', float), ('total', float), ('temperature', float)])
kinetic = data['kinetic']
potential = data['potential']
total = data['total']
fig = plt.figure()
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,
wspace=0.25,
hspace=0.25)
dt = 0.004
x = dt * np.arange(1,len(kinetic)+1)
plt.subplot(2,1,1)
plt.plot(x, kinetic)
plt.title('Kinetic energy')
plt.grid()
plt.subplot(2,1,2)
plt.plot(x, potential, label='Potential')
plt.plot(x, total, label='Total')
plt.title('Potential/total energy')
plt.xlabel("Time")
plt.grid()
plt.legend()
plt.savefig(f"energy.pdf", bbox_inches = 'tight', pad_inches = 0, dpi=300)