In [1]:
%pylab inline
import sys, os
import QuickPlot
import matplotlib.pylab as pylab
pylab.rcParams['figure.figsize'] = 8, 6 # that's default image size for this interactive session
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
from ipywidgets.widgets import interactive, fixed, interact
%config InlineBackend.figure_format = 'retina'
In [10]:
hr = genfromtxt('NiO_hr.dat', skip_header=22)
print(hr.shape)
In [11]:
# This reads the hamiltonian elements for a specific unit cell coordinate.
# Wannier90 reports them by unit cell (x,y,z, i,j) where (1,0,0, 1,1) is the overlap of
# wavefunction 1 in the 0,0,0 cell with wavefunction 1 translated by one unit cell in the x direction.
def GetOneCell(x,y,z):
hrtrim = hr[(hr[:,0]==x) & (hr[:,1]==y) & (hr[:,2]==z)]
hrtrim = hrtrim[:,3:]
H = np.zeros((8,8), dtype='complex')
for r in hrtrim[:]:
i = int(r[0])-1
j = int(r[1])-1
overlap = complex(r[2], r[3])
H[i, j] = overlap
return H
In [12]:
# Print the eigenvalues for just the consideration of one unit cell.
H = GetOneCell(0,0,0)
print(eig(H)[0])
In [13]:
# Now do the same but considering the 6 nearest neighbors.
H = GetOneCell(0,0,0)
H += GetOneCell(1,0,0)
H += GetOneCell(0,1,0)
H += GetOneCell(0,0,1)
H += GetOneCell(-1,0,0)
H += GetOneCell(0,-1,0)
H += GetOneCell(0,0,-1)
print(eig(H)[0])
In [14]:
# Now build it using every element.
H = np.zeros((8,8), dtype='complex')
for r in hr[:]:
x = int(r[0])
y = int(r[1])
z = int(r[2])
i = int(r[3])-1
j = int(r[4])-1
overlap = complex(r[5], r[6])
H[i, j] += overlap
print(eig(H)[0])
In [47]:
# Print out the energy levels from greatest to least,
# along with <psi_m|psi_n> so we can see what orbitals
# they represent.
E = linalg.eig(H)[0]
psi = linalg.eig(H)[1]
for i in range(len(E)):
print(f'Energy = {np.abs(E[i]):0.2f} eV')
print(f'psi=(', end='')
normval=np.abs(psi[i]).sum()
for j in range(len(E)):
print(f'{np.abs(psi[i][j])/normval:0.2f}, ', end='')
print(')')
In [ ]: