File: cu_plot.py

package info (click to toggle)
gpaw 25.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 18,888 kB
  • sloc: python: 174,804; ansic: 17,564; cpp: 5,668; sh: 972; csh: 139; makefile: 45
file content (26 lines) | stat: -rw-r--r-- 757 bytes parent folder | download | duplicates (3)
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
# web-page: cu.png
import numpy as np
import matplotlib.pyplot as plt
from ase.io import read

fig, ax = plt.subplots(constrained_layout=True)

e0 = None
k = np.arange(8, 21, dtype=float)
for name in ['ITM', 'TM', 'FD-0.05', 'MV-0.2']:
    energies = []
    for n in k:
        e = read(f'Cu-{name}-{int(n)}.txt').get_potential_energy()
        energies.append(e)
    if e0 is None:
        e0 = e
    ax.plot(k**-2, (np.array(energies) - e0) * 1000, label=name)

ax.set_xlabel(r'$1/k^2$')
ax.set_ylabel(r'$\Delta E$ [meV]')
ax2 = ax.secondary_xaxis('top', functions=(lambda x: (x + 1e-10)**-0.5,
                                           lambda k: (k + 1e-10)**-2))
ax2.set_xlabel('Number of k-points (k)')
plt.legend()
plt.savefig('cu.png')
# plt.show()