Skip to content

Commit

Permalink
added option of non-optimized block detection
Browse files Browse the repository at this point in the history
  • Loading branch information
freude committed Jun 29, 2020
1 parent 475faee commit 07971f3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions examples/si_nw_transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def main():
logging.info("{} Energy: {} eV".format(j, E))

# compute self-energies describing boundary conditions at the leads contacts
R, L = negf.surface_greens_function(E, hl, h0, hr, iterate=True, damp=damp)
R, L = negf.surface_greens_function(E, hl, h0, hr, iterate=False, damp=damp)

s01, s02 = h01[0].shape
s11, s12 = h01[-1].shape
Expand All @@ -77,7 +77,8 @@ def main():

# compute DOS
for jj in range(num_periods):
dos[j] = dos[j] + np.real(np.trace(1j * (grd[jj] - grd[jj].conj().T))) / num_periods
# dos[j] = dos[j] + np.real(np.trace(1j * (grd[jj] - grd[jj].conj().T))) / num_periods
dos[j] = dos[j] + np.real(np.trace(np.imag(grd[jj]))) / num_periods

# gamma_l = 1j * (L[:s01, :s02] - L[:s01, :s02].conj().T)
# gamma_r = 1j * (R[-s11:, -s12:] - R[-s11:, -s12:].conj().T)
Expand Down
4 changes: 2 additions & 2 deletions nanonet/negf/greens_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from scipy.sparse import csr_matrix


@profile
def surface_greens_function_poles(h_list):
"""
Computes eigenvalues and eigenvectors for the complex band structure problem.
Expand Down Expand Up @@ -50,7 +51,6 @@ def surface_greens_function_poles(h_list):
eigenvals = np.zeros(alpha.shape, dtype=np.complex)

for j, item in enumerate(zip(alpha, betha)):

if np.abs(item[1]) != 0.0:
eigenvals[j] = item[0] / item[1]
else:
Expand Down Expand Up @@ -107,7 +107,7 @@ def iterate_gf(E, h_0, h_l, h_r, gf, num_iter):

return gf


@profile
def surface_greens_function(E, h_l, h_0, h_r, iterate=True, damp=0.0001j):
"""
Computes surface self-energies using the eigenvalue decomposition.
Expand Down
4 changes: 3 additions & 1 deletion nanonet/negf/recursive_greens_functions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import copy
import numpy as np
import scipy.linalg as linalg


def mat_left_div(mat_a, mat_b):

ans, resid, rank, s = np.linalg.lstsq(mat_a, mat_b, rcond=-1)
# ans, resid, rank, s = linalg.lstsq(mat_a, mat_b, lapack_driver='gelsy')
ans, resid, rank, s = np.linalg.lstsq(mat_a, mat_b, rcond=None)

return ans

Expand Down
10 changes: 7 additions & 3 deletions nanonet/tb/hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from nanonet.tb.diatomic_matrix_element import me
from nanonet.tb.orbitals import Orbitals
from nanonet.tb.aux_functions import dict2xyz
from nanonet.tb.block_tridiagonalization import split_into_subblocks_optimized, cut_in_blocks
from nanonet.tb.block_tridiagonalization import split_into_subblocks_optimized, cut_in_blocks, split_into_subblocks
import nanonet.verbosity as verbosity


Expand Down Expand Up @@ -535,7 +535,7 @@ def get_site_coordinates(self):

return np.array(self._coords)

def get_hamiltonians_block_tridiagonal(self, left=None, right=None):
def get_hamiltonians_block_tridiagonal(self, left=None, right=None, optimized=True):

if left is None and right is None:
hl, h0, hr = self.get_hamiltonians()
Expand All @@ -544,7 +544,11 @@ def get_hamiltonians_block_tridiagonal(self, left=None, right=None):
h0 = self.h_matrix
hr = right

subblocks = split_into_subblocks_optimized(h0, hl, hr)
if optimized:
subblocks = split_into_subblocks_optimized(h0, hl, hr)
else:
subblocks = split_into_subblocks(h0, hl, hr)

h01, hl1, hr1 = cut_in_blocks(h0, subblocks)

return hl1, h01, hr1, subblocks

0 comments on commit 07971f3

Please sign in to comment.