-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_2xn.py
More file actions
86 lines (66 loc) · 1.7 KB
/
plot_2xn.py
File metadata and controls
86 lines (66 loc) · 1.7 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
from plot_common import *
prefix = 'plots/'
matplotlib.use('Agg')
plt.figure(figsize=(8.8/2.54,6.6/2.54))
plt.subplots_adjust(
left=0.125,
right=0.98,
bottom=0.125,
top=0.98
)
files_n = []
files_n += list(glob.glob(f'output/normal/n_*.h5'))
files_n += list(glob.glob(f'output/normal/n2-10000-0_*.h5'))
data_n = load(files_n)
markers = ['s', 'D', 'v', 'o', '^']
atom = 'n.xyz'
molecule = 'n2-10000-0.xyz'
basis = 'ccpvdz'
E1 = []
r = []
for k, v in data_n.items():
if k[0] != molecule or k[1] != basis:
continue
E1.append(v['e'].real)
ndet = k[3]
r.append(ndet)
E1 = np.array(E1)
r = np.array(r)
perm = np.argsort(r)
r = r[perm]
E1 = E1[perm]
E2 = []
r2 = []
for k, v in data_n.items():
if k[0] != atom or k[1] != basis:
continue
E2.append(v['e'].real)
ndet = k[3]
r2.append(ndet)
E2 = np.array(E2)
r2 = np.array(r2)
perm = np.argsort(r2)
r2 = r2[perm]
E2 = E2[perm]
assert np.allclose(r, r2)
plt.xscale('log')
x = r
y = E1-2*E2
plt.ylim(-0.01, 0.13)
plt.plot(x, y, color='k', marker='.', linewidth=1.0)
plt.xlabel(r'$\mathregular{N_D}$')
plt.ylabel(r'$\mathregular{E_{N_2} - 2\, E_N\quad[a.u.]}$')
plt.savefig(prefix+'fig7.pdf')
df_rows = r
df_cols = ['N_2', 'N']
df_data = np.full((len(df_rows), len(df_cols)), None)
df_data[:, 0] = E1
df_data[:, 1] = E2
if True:
import pandas as pd
from pathlib import Path
df = pd.DataFrame(df_data, df_rows, df_cols)
df.index.name = r"N_D \ molecule"
path = Path(prefix+"source_data.xlsx")
with pd.ExcelWriter(path, mode="a" if path.exists() else "w", engine="openpyxl", if_sheet_exists="replace" if path.exists() else None) as writer:
df.to_excel(writer, sheet_name="fig7", index=True)