-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfluctuations.py
More file actions
102 lines (65 loc) · 2.45 KB
/
Copy pathfluctuations.py
File metadata and controls
102 lines (65 loc) · 2.45 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/python
# Script 3/3
# This scripts performs basic statistical analysis and plots graphs of the fluctations of the instantaneous temperature and pressure of the system at every timestep.
###########
# MODULES #
###########
# Imports the necessary modules
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
################
# DATA LOADING #
################
# Loads in the data extracted by the previous script (gogoconvergence.sh)
temp = np.genfromtxt('tmp/temperature', dtype=None)
press = np.genfromtxt('tmp/pressure', dtype=None)
time = np.genfromtxt('tmp/fluct_timesteps', dtype=None)
###############
# TEMPERATURE #
###############
# Performs basic statistical analysis of the instantaneous temperature of the system at every timestep, and writes to the file "temperature_change".
avtemp = np.average(temp)
stdtemp = np.std(temp)
avpress = np.average(press)
stdpress = np.std(press)
filename = "temperature_change"
file = open(filename, 'w')
line_3 = ["The temperature of the system is ","", "(K):" '\n']
file.writelines(line_3),
line_4 = [str(avtemp),"(+/-)", str(stdtemp)]
file.writelines(line_4),
file.close()
# Plots the instantaneous temperature of the system at every timestep.
# does NOT show the graphs - uncomment #plt.show() to see the graphs.
with PdfPages('Temperature.pdf') as pdf:
plt.plot(time,temp, linestyle='--', dashes=(1, 1), )
plt.xlabel('Time (ps)')
plt.ylabel('Temperature (K)')
plt.legend(loc=2,frameon=False)
plt.tight_layout()
pdf.savefig()
#plt.show()
plt.close()
############
# PRESSURE #
############
# Performs basic statistical analysis of the instantaneous pressure of the system at every timestep and writes to the file "pressure_change".
filename = "pressure_change"
file = open(filename, 'w')
line_5 = ["The pressure of the system is ","", "(kAtm):" '\n']
file.writelines(line_5),
line_6 = [str(avpress),"(+/-)", str(stdpress)]
file.writelines(line_6),
file.close()
# Plots the instantaneous pressure of the system at every timestep.
# does NOT show the graphs - uncomment #plt.show() to see the graphs.
with PdfPages('Pressure.pdf') as pdf:
plt.plot(time,press, linestyle='--', dashes=(1, 1), )
plt.xlabel('Time (ps)')
plt.ylabel('Pressure (kAtm)')
plt.legend(loc=2,frameon=False)
plt.tight_layout()
pdf.savefig()
#plt.show()
plt.close()