Tutorial

calculate_density_of_states.py

Code:

import guan
import numpy as np

hamiltonian = guan.hamiltonian_of_finite_size_system_along_two_directions_for_square_lattice(2,2)
fermi_energy_array = np.linspace(-4, 4, 400)
total_dos_array = guan.total_density_of_states_with_fermi_energy_array(fermi_energy_array, hamiltonian, broadening=0.1)
guan.plot(fermi_energy_array, total_dos_array, xlabel='E', ylabel='Total DOS', style='-')

fermi_energy = 0
N1 = 3
N2 = 4
hamiltonian = guan.hamiltonian_of_finite_size_system_along_two_directions_for_square_lattice(N1,N2)
LDOS = guan.local_density_of_states_for_square_lattice(fermi_energy, hamiltonian, N1=N1, N2=N2)
print('square lattice:\n', LDOS, '\n')
h00 = guan.hamiltonian_of_finite_size_system_along_one_direction(N2)
h01 = np.identity(N2)
LDOS = guan.local_density_of_states_for_square_lattice_using_dyson_equation(fermi_energy, h00=h00, h01=h01, N2=N2, N1=N1)
print(LDOS, '\n\n')
# guan.plot_contour(range(N1), range(N2), LDOS)

N1 = 3
N2 = 4
N3 = 5
hamiltonian = guan.hamiltonian_of_finite_size_system_along_three_directions_for_cubic_lattice(N1, N2, N3)
LDOS = guan.local_density_of_states_for_cubic_lattice(fermi_energy, hamiltonian, N1=N1, N2=N2, N3=N3)
print('cubic lattice:\n', LDOS, '\n')
h00 = guan.hamiltonian_of_finite_size_system_along_two_directions_for_square_lattice(N2, N3)
h01 = np.identity(N2*N3)
LDOS = guan.local_density_of_states_for_cubic_lattice_using_dyson_equation(fermi_energy, h00, h01, N3=N3, N2=N2, N1=N1)
print(LDOS)

Result:

square lattice:
 [[0.00953564 0.01270667 0.00953564] 
 [0.01588183 0.0285812  0.01588183]  
 [0.01588183 0.0285812  0.01588183]  
 [0.00953564 0.01270667 0.00953564]] 

[[0.00953564 0.01270667 0.00953564]  
 [0.01588183 0.0285812  0.01588183]  
 [0.01588183 0.0285812  0.01588183]  
 [0.00953564 0.01270667 0.00953564]] 


cubic lattice:
 [[[0.01287638 0.01306682 0.01287638]
  [0.01631291 0.01364158 0.01631291] 
  [0.01631291 0.01364158 0.01631291] 
  [0.01287638 0.01306682 0.01287638]]

 [[0.01673434 0.01131905 0.01673434] 
  [0.0263449  0.00528289 0.0263449 ] 
  [0.0263449  0.00528289 0.0263449 ] 
  [0.01673434 0.01131905 0.01673434]]

 [[0.01725157 0.00921113 0.01725157] 
  [0.03594581 0.01186383 0.03594581] 
  [0.03594581 0.01186383 0.03594581] 
  [0.01725157 0.00921113 0.01725157]]

 [[0.01673434 0.01131905 0.01673434] 
  [0.0263449  0.00528289 0.0263449 ] 
  [0.0263449  0.00528289 0.0263449 ] 
  [0.01673434 0.01131905 0.01673434]]

 [[0.01287638 0.01306682 0.01287638]
  [0.01631291 0.01364158 0.01631291]
  [0.01631291 0.01364158 0.01631291]
  [0.01287638 0.01306682 0.01287638]]]

[[[0.01287638 0.01306682 0.01287638]
  [0.01631291 0.01364158 0.01631291]
  [0.01631291 0.01364158 0.01631291]
  [0.01287638 0.01306682 0.01287638]]

 [[0.01673434 0.01131905 0.01673434]
  [0.0263449  0.00528289 0.0263449 ]
  [0.0263449  0.00528289 0.0263449 ]
  [0.01673434 0.01131905 0.01673434]]

 [[0.01725157 0.00921113 0.01725157]
  [0.03594581 0.01186383 0.03594581]
  [0.03594581 0.01186383 0.03594581]
  [0.01725157 0.00921113 0.01725157]]

 [[0.01673434 0.01131905 0.01673434]
  [0.0263449  0.00528289 0.0263449 ]
  [0.0263449  0.00528289 0.0263449 ]
  [0.01673434 0.01131905 0.01673434]]

 [[0.01287638 0.01306682 0.01287638]
  [0.01631291 0.01364158 0.01631291]
  [0.01631291 0.01364158 0.01631291]
  [0.01287638 0.01306682 0.01287638]]]