-
Notifications
You must be signed in to change notification settings - Fork 0
/
convergence_alpha.py
72 lines (63 loc) · 2.46 KB
/
convergence_alpha.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
62
63
64
65
66
67
68
69
70
71
import matplotlib.pyplot as plt
import numpy as np
import pickle
import glob
import loadmat
direc = '/Users/ost051/Documents/PhD/ElectronPrecipitation/log/testing/2023.04.27_17_54_27_mixf=0/'
files = glob.glob(direc + '*.pickle')
elspec_0 = loadmat.loadmat(direc + 'ElSpec-iqt_IC_0.mat')["ElSpecOut"]
nax = 13
all_data = []
for i, f in enumerate(files[:nax]):
f = direc + 'IC_res_'+str(i)+'.pickle'
print(f)
with open(f, 'rb') as pf:
data = pickle.load(pf)
all_data = [*all_data, data[:4]]
fig,ax = plt.subplots()
for i, f in enumerate(files[:nax]):
data = all_data[i]
eff_rr = data[3][:, 1:]
if i>0:
data = all_data[i-1]
eff_rr_o = data[3][:, 1:]
else:
eff_rr_o = elspec_0["alpha"]
d_effrr_r = (eff_rr_o - eff_rr) / eff_rr
if i == 0:
ax.plot(i+1, np.sum(np.abs(d_effrr_r.flat))/len(d_effrr_r.flat), 'x', color = 'black', label = 'Mean')
ax.plot(i+1, np.max(np.abs(d_effrr_r.flat)), 'x', color = 'blue', label = 'Max')
else:
ax.plot(i+1, np.sum(np.abs(d_effrr_r.flat)) / len(d_effrr_r.flat), 'x', color='black')
ax.plot(i+1, np.max(np.abs(d_effrr_r.flat)), 'x', color='blue')
ax.plot(0, 0, 'x', alpha=0)
plt.title(r' Relative Variation in the Effective Recombination Rate between Iterations')
ax.set_ylabel(r"$\frac{\alpha_{eff, i-1}}{\alpha_{eff, i}} - 1$")
ax.set_xlabel("Iteration i")
ax.set_yscale('log')
ax.legend()
plt.savefig('/Users/ost051/Documents/PhD/ElectronPrecipitation/writing/plots/alpha_rel_dev_mixf0.png')
fig,ax = plt.subplots()
for i, f in enumerate(files[:nax]):
data = all_data[i]
ne = data[2][:, 0, 1:]
if i>0:
data = all_data[i-1]
ne_o = data[2][:, 0, 1:]
else:
ne_o = elspec_0["ne"]
d_effrr_r = (ne_o - ne) / ne
if i == 0:
ax.plot(i+1, np.sum(np.abs(d_effrr_r.flat))/len(d_effrr_r.flat), 'x', color = 'black', label = 'Mean')
ax.plot(i+1, np.max(np.abs(d_effrr_r.flat)), 'x', color = 'blue', label = 'Max')
else:
ax.plot(i+1, np.sum(np.abs(d_effrr_r.flat)) / len(d_effrr_r.flat), 'x', color='black')
ax.plot(i+1, np.max(np.abs(d_effrr_r.flat)), 'x', color='blue')
ax.plot(0, 0, 'x', alpha = 0)
plt.title(r' Relative Variation in Electron Density between Iterations')
ax.set_ylabel(r"$\frac{n_{e, i-1}}{n_{e, i}} - 1$")
ax.set_xlabel("Iteration i")
ax.set_yscale('log')
ax.legend()
plt.savefig('/Users/ost051/Documents/PhD/ElectronPrecipitation/writing/plots/ne_rel_dev.png')
plt.show()