-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathplt_aeps_wfc_orb.py
141 lines (116 loc) · 3.38 KB
/
plt_aeps_wfc_orb.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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib as mpl
mpl.rcParams['axes.unicode_minus'] = False
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
from vaspwfc import vaspwfc
from aewfc import vasp_ae_wfc
from ase.io import read
atoms = read('POSCAR')
L = atoms.cell[-1, -1]
# the pseudo-wavefunction
ps_wfc = vaspwfc('WAVECAR', lgamma=True)
# the all-electron wavefunction
ae_wfc = vasp_ae_wfc(ps_wfc, aecut=-25)
which_band = 8
phi_ae = ae_wfc.get_ae_wfc(iband=which_band)
phi_ps = ps_wfc.get_ps_wfc(iband=which_band, norm=False, ngrid=ae_wfc._aegrid)
r_ps = np.arange(phi_ps.shape[-1]) * L / phi_ps.shape[-1]
r_ae = np.arange(phi_ae.shape[-1]) * L / phi_ae.shape[-1]
x, y = np.meshgrid(r_ps - L/2, r_ps - L/2)
orb_min = phi_ae[0].min()
orb_max = phi_ae[0].max()
################################################################################
fig = plt.figure(
figsize=(10, 2.4),
dpi=300,
)
axes = [plt.subplot(1, 3, ii+1) for ii in range(3)]
atoms_colors = {
'C': 'black',
'O': 'blue'
}
axes[0].pcolor(
x, y, np.roll(phi_ps[0,:,:], phi_ps.shape[1]//2, axis=0),
cmap='PiYG', zorder=1,
vmin=orb_min,
vmax=orb_max,
)
axes[1].pcolor(
x, y,
np.roll(phi_ae[0,:,:], phi_ae.shape[1]//2, axis=0) - \
np.roll(phi_ps[0,:,:], phi_ps.shape[1]//2, axis=0),
cmap='PiYG', zorder=1,
vmin=orb_min,
vmax=orb_max,
)
orb_map = axes[2].pcolor(
x, y, np.roll(phi_ae[0,:,:], phi_ae.shape[1]//2, axis=0),
cmap='PiYG', zorder=1,
vmin=orb_min,
vmax=orb_max,
)
# cax = axes[2].inset_axes([1.02, 0.25, 0.03, 0.5])
cax = axes[1].inset_axes([0.30, 0.02, 0.40, 0.04])
cbar = plt.colorbar(
orb_map, ax=axes[2], cax=cax,
orientation='horizontal',
extend='both',
ticks=[-0.01, 0, 0.01]
)
cbar.ax.tick_params(labelsize='x-small')
cbar.ax.xaxis.set_ticks_position('top')
wfc_labels = [
r'$\tilde\psi_\mathrm{ps}$',
r'$\psi_\mathrm{ae} - \tilde\psi_\mathrm{ps}$',
r'$\psi_\mathrm{ae}$'
]
paw_rc = {'C':0.809, 'O':0.822}
for ii in range(3):
ax = axes[ii]
ax.set_aspect(1.0)
atoms_handles = {}
for iatom in range(len(atoms)):
ss = atoms.get_chemical_symbols()[iatom]
cc = atoms_colors[ss]
l, = ax.plot(atoms.positions[iatom, -1] - L/2, [0],
ls='none',
marker='o', mfc='w', ms=3,
mew=1.0,
color=cc, label=ss,
zorder=2,
)
if ss not in atoms_handles:
atoms_handles[ss] = l
ax.add_artist(
Circle(
(atoms.positions[iatom,-1]-L/2, 0), radius=paw_rc[ss],
fill=False, lw=0.8, color='gray', alpha=0.5, ls='--'
)
)
if ii == 0:
leg1 = ax.legend(
atoms_handles.values(), atoms_handles.keys(),
loc='upper right', ncol=2,
fontsize='small',
)
ax.add_artist(leg1)
ax.text(0.50, 1.05,
wfc_labels[ii],
ha="center",
va="bottom",
# fontsize='small',
transform=ax.transAxes,
# bbox=dict(boxstyle='round', facecolor='w', alpha=0.5, lw=0.5,)
)
ax.set_xlim(-3, 3)
ax.set_ylim(-2, 2)
ax.set_xlabel(r'$z$ [$\AA$]')
ax.set_ylabel(r'$y$ [$\AA$]')
plt.tight_layout()
plt.savefig('orb_co2_homo.png')
# plt.show()
from subprocess import call
call('feh -xdF orb_co2_homo.png'.split())