Skip to content

Commit

Permalink
fixed error detected by pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
freude committed Jun 22, 2020
1 parent 8fd3882 commit 330700b
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 267 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ install:
# command to run tests
script:
- nosetests --with-coverage
- pylint --errors-only nanonet
- pylint --errors-only --generated-members=coolwarm,accumulate --ignored-modules=numpy,scipy --ignored-classes=numpy,spipy --extension-pkg-whitelist=numpy,scipy nanonet/
branches:
only:
- master
Expand Down
2 changes: 1 addition & 1 deletion nanonet/negf/continued_fraction_representation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from scipy.linalg import eig
from negf.hamiltonian_chain import fd
from nanonet.negf.hamiltonian_chain import fd


def t_order_frac(x):
Expand Down
1 change: 0 additions & 1 deletion nanonet/negf/invdisttree.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import division
import numpy as np
from scipy.spatial import cKDTree as KDTree
# http://docs.scipy.org/doc/scipy/reference/spatial.html

__date__ = "2010-11-09 Nov" # weights, doc

Expand Down
28 changes: 14 additions & 14 deletions nanonet/negf/surf_greens_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,14 @@ def main():
sys.path.insert(0, '/home/mk/TB_project/tb')
import nanonet.tb as tb

a = tb.Atom('A')
a = tb.Orbitals('A')
a.add_orbital('s', -0.7)
b = tb.Atom('B')
b = tb.Orbitals('B')
b.add_orbital('s', -0.5)
c = tb.Atom('C')
c = tb.Orbitals('C')
c.add_orbital('s', -0.3)

tb.Atom.orbital_sets = {'A': a, 'B': b, 'C': c}
tb.Orbitals.orbital_sets = {'A': a, 'B': b, 'C': c}

tb.set_tb_params(PARAMS_A_A={'ss_sigma': -0.5},
PARAMS_B_B={'ss_sigma': -0.5},
Expand Down Expand Up @@ -338,7 +338,7 @@ def main():

for E in energy:
print("============Eigenval decompositions============")
L, R, _, _, _ = surface_greens_function(E, h_l, h_0, h_r)
L, R = surface_greens_function(E, h_l, h_0, h_r)
print("==============Schur decomposition==============")
L1, R1 = surface_greens_function_poles_Shur(E, h_l, h_0, h_r)
sgf_l.append(L)
Expand Down Expand Up @@ -373,7 +373,7 @@ def main1():
sys.path.insert(0, '/home/mk/TB_project/tb')
import nanonet.tb as tb

tb.Atom.orbital_sets = {'Si': 'SiliconSP3D5S', 'H': 'HydrogenS'}
tb.Orbitals.orbital_sets = {'Si': 'SiliconSP3D5S', 'H': 'HydrogenS'}
h = tb.Hamiltonian(xyz='/home/mk/NEGF_project/SiNW.xyz', nn_distance=2.4)
h.initialize()
h.set_periodic_bc([[0, 0, 5.50]])
Expand All @@ -397,7 +397,7 @@ def main1():

for j, E in enumerate(energy):
# L, R = surface_greens_function_poles_Shur(j, E, h_l, h_0, h_r)
L, R, _, _, _ = surface_greens_function(E, h_l, h_0, h_r)
L, R = surface_greens_function(E, h_l, h_0, h_r)

test_gf = E * np.identity(num_sites) - h_0 - L - R

Expand Down Expand Up @@ -505,7 +505,7 @@ def inverse_bs_problem():
# h.initialize()
# h.set_periodic_bc([[0, 0, 3.0]])

tb.Atom.orbital_sets = {'Si': 'SiliconSP3D5S', 'H': 'HydrogenS'}
tb.Orbitals.orbital_sets = {'Si': 'SiliconSP3D5S', 'H': 'HydrogenS'}
h = tb.Hamiltonian(xyz='/home/mk/TB_project/input_samples/SiNW.xyz', nn_distance=2.4)
h.initialize()
h.set_periodic_bc([[0, 0, 5.50]])
Expand Down Expand Up @@ -551,10 +551,10 @@ def main2():
sys.path.insert(0, '/home/mk/TB_project/tb')
import nanonet.tb as tb

a = tb.Atom('A')
a = tb.Orbitals('A')
a.add_orbital('s', -0.7)

tb.Atom.orbital_sets = {'A': a}
tb.Orbitals.orbital_sets = {'A': a}

tb.set_tb_params(PARAMS_A_A={'ss_sigma': -0.5},
PARAMS_B_B={'ss_sigma': -0.5},
Expand All @@ -578,7 +578,7 @@ def main2():
sgf_r = []

for E in energy:
L, R, _, _, _ = surface_greens_function(E, h_l, h_0, h_r)
L, R = surface_greens_function(E, h_l, h_0, h_r)
# L, R = surface_greens_function_poles_Shur(E, h_l, h_0, h_r)
sgf_l.append(L)
sgf_r.append(R)
Expand Down Expand Up @@ -607,10 +607,10 @@ def main3():
sys.path.insert(0, '/home/mk/TB_project/tb')
import nanonet.tb as tb

a = tb.Atom('A')
a = tb.Orbitals('A')
a.add_orbital('s', -0.7)

tb.Atom.orbital_sets = {'A': a}
tb.Orbitals.orbital_sets = {'A': a}

tb.set_tb_params(PARAMS_A_A={'ss_sigma': -0.5},
PARAMS_B_B={'ss_sigma': -0.5},
Expand All @@ -634,7 +634,7 @@ def main3():
sgf_r = []

for E in energy:
L, R, _, _, _ = surface_greens_function(E, h_l, h_0, h_r)
L, R = surface_greens_function(E, h_l, h_0, h_r)
# L, R = surface_greens_function_poles_Shur(E, h_l, h_0, h_r)
sgf_l.append(L)
sgf_r.append(R)
Expand Down
168 changes: 84 additions & 84 deletions nanonet/tb/aux_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,90 +310,90 @@ def print_dict(dictionary):
return out


def split_into_subblocks(h_0, h_l, h_r):
"""
Split Hamiltonian matrix and coupling matrices into subblocks
:param h_0: Hamiltonian matrix
:param h_l: left inter-cell coupling matrices
:param h_r: right inter-cell coupling matrices
:return h_0_s, h_l_s, h_r_s: lists of subblocks
"""

def find_nonzero_lines(mat, order):

if order == 'top':
line = mat.shape[0]
while line > 0:
if np.count_nonzero(mat[line - 1, :]) == 0:
line -= 1
else:
break
elif order == 'bottom':
line = -1
while line < mat.shape[0] - 1:
if np.count_nonzero(mat[line + 1, :]) == 0:
line += 1
else:
line = mat.shape[0] - (line + 1)
break
elif order == 'left':
line = mat.shape[1]
while line > 0:
if np.count_nonzero(mat[:, line - 1]) == 0:
line -= 1
else:
break
elif order == 'right':
line = -1
while line < mat.shape[1] - 1:
if np.count_nonzero(mat[:, line + 1]) == 0:
line += 1
else:
line = mat.shape[1] - (line + 1)
break
else:
raise ValueError('Wrong value of the parameter order')

return line

h_0_s = []
h_l_s = []
h_r_s = []

if isinstance(h_l, np.ndarray) and isinstance(h_r, np.ndarray):
h_r_h = find_nonzero_lines(h_r, 'bottom')
h_r_v = find_nonzero_lines(h_r[-h_r_h:, :], 'left')
h_l_h = find_nonzero_lines(h_l, 'top')
h_l_v = find_nonzero_lines(h_l[:h_l_h, :], 'right')

if isinstance(h_l, int) and isinstance(h_r, int):
h_l_h = h_l
h_r_v = h_l
h_r_h = h_r
h_l_v = h_r

edge, edge1 = compute_edge(h_0)

left_block = max(h_l_h, h_r_v)
right_block = max(h_r_h, h_l_v)

from nanonet.tb.sorting_algorithms import split_matrix_0, cut_in_blocks, split_matrix

blocks = split_matrix_0(h_0, left=left_block, right=right_block)
h_0_s, h_l_s, h_r_s = cut_in_blocks(h_0, blocks)

# blocks = compute_blocks(left_block, right_block, edge, edge1)
# j1 = 0
#
# for j, block in enumerate(blocks):
# h_0_s.append(h_0[j1:block + j1, j1:block + j1])
# if j < len(blocks) - 1:
# h_l_s.append(h_0[block + j1:block + j1 + blocks[j + 1], j1:block + j1])
# h_r_s.append(h_0[j1:block + j1, j1 + block:j1 + block + blocks[j + 1]])
# j1 += block

return h_0_s, h_l_s, h_r_s, blocks
# def split_into_subblocks(h_0, h_l, h_r):
# """
# Split Hamiltonian matrix and coupling matrices into subblocks
#
# :param h_0: Hamiltonian matrix
# :param h_l: left inter-cell coupling matrices
# :param h_r: right inter-cell coupling matrices
# :return h_0_s, h_l_s, h_r_s: lists of subblocks
# """
#
# def find_nonzero_lines(mat, order):
#
# if order == 'top':
# line = mat.shape[0]
# while line > 0:
# if np.count_nonzero(mat[line - 1, :]) == 0:
# line -= 1
# else:
# break
# elif order == 'bottom':
# line = -1
# while line < mat.shape[0] - 1:
# if np.count_nonzero(mat[line + 1, :]) == 0:
# line += 1
# else:
# line = mat.shape[0] - (line + 1)
# break
# elif order == 'left':
# line = mat.shape[1]
# while line > 0:
# if np.count_nonzero(mat[:, line - 1]) == 0:
# line -= 1
# else:
# break
# elif order == 'right':
# line = -1
# while line < mat.shape[1] - 1:
# if np.count_nonzero(mat[:, line + 1]) == 0:
# line += 1
# else:
# line = mat.shape[1] - (line + 1)
# break
# else:
# raise ValueError('Wrong value of the parameter order')
#
# return line
#
# h_0_s = []
# h_l_s = []
# h_r_s = []
#
# if isinstance(h_l, np.ndarray) and isinstance(h_r, np.ndarray):
# h_r_h = find_nonzero_lines(h_r, 'bottom')
# h_r_v = find_nonzero_lines(h_r[-h_r_h:, :], 'left')
# h_l_h = find_nonzero_lines(h_l, 'top')
# h_l_v = find_nonzero_lines(h_l[:h_l_h, :], 'right')
#
# if isinstance(h_l, int) and isinstance(h_r, int):
# h_l_h = h_l
# h_r_v = h_l
# h_r_h = h_r
# h_l_v = h_r
#
# edge, edge1 = compute_edge(h_0)
#
# left_block = max(h_l_h, h_r_v)
# right_block = max(h_r_h, h_l_v)
#
# from nanonet.tb.sorting_algorithms import split_matrix_0, cut_in_blocks, split_matrix
#
# blocks = split_matrix_0(h_0, left=left_block, right=right_block)
# h_0_s, h_l_s, h_r_s = cut_in_blocks(h_0, blocks)
#
# # blocks = compute_blocks(left_block, right_block, edge, edge1)
# # j1 = 0
# #
# # for j, block in enumerate(blocks):
# # h_0_s.append(h_0[j1:block + j1, j1:block + j1])
# # if j < len(blocks) - 1:
# # h_l_s.append(h_0[block + j1:block + j1 + blocks[j + 1], j1:block + j1])
# # h_r_s.append(h_0[j1:block + j1, j1 + block:j1 + block + blocks[j + 1]])
# # j1 += block
#
# return h_0_s, h_l_s, h_r_s, blocks


def compute_edge(mat):
Expand Down
72 changes: 0 additions & 72 deletions nanonet/tb/gf.py

This file was deleted.

0 comments on commit 330700b

Please sign in to comment.