@@ -141,7 +141,8 @@ def __init__(self,
141141 atom_norbs .append (int (self .model .idp .atom_norb [model .idp .chemical_symbol_to_type [atom .symbol ]]))
142142 self .atom_norbs = atom_norbs
143143
144- def initialize (self , kpoints , block_tridiagnal = False ,useBloch = False ,bloch_factor = None ,\
144+ def initialize (self , kpoints , block_tridiagnal = False , plot_blocks = False , \
145+ useBloch = False ,bloch_factor = None ,\
145146 use_saved_HS = False , saved_HS_path = None ):
146147 '''This function initializes the structure and Hamiltonian for a system with optional block tridiagonal
147148 and Bloch factor parameters.
@@ -152,6 +153,8 @@ def initialize(self, kpoints, block_tridiagnal=False,useBloch=False,bloch_factor
152153 Kpoints in the Brillouin zone
153154 block_tridiagnal, optional
154155 a boolean flag that determines whether the Hamiltonian matrix should be stored in a block-tridiagonal form.
156+ plot_blocks, optional
157+ a boolean flag that determines whether to visualize the block structure using `show_blocks`.
155158 useBloch, optional
156159 a boolean flag that determines whether Bloch boundary conditions should be used in the lead self energy calculations.
157160 bloch_factor
@@ -199,7 +202,7 @@ def initialize(self, kpoints, block_tridiagnal=False,useBloch=False,bloch_factor
199202 log .info (msg = "==" * 40 )
200203 else :
201204 self .saved_HS_path = self .results_path
202- self .Hamiltonian_initialized (kpoints ,useBloch ,bloch_factor ,block_tridiagnal ,\
205+ self .Hamiltonian_initialized (kpoints ,useBloch ,bloch_factor ,block_tridiagnal ,plot_blocks , \
203206 lead_atom_range ,structure_leads ,structure_leads_fold )
204207 log .info (msg = "--" * 40 )
205208 log .info (msg = f"The Hamiltonian has been initialized by model." )
@@ -211,7 +214,8 @@ def initialize(self, kpoints, block_tridiagnal=False,useBloch=False,bloch_factor
211214
212215
213216 def Hamiltonian_initialized (self ,kpoints :List [List [float ]],useBloch :bool ,bloch_factor :List [int ],\
214- block_tridiagnal :bool ,lead_atom_range :dict ,structure_leads :Atoms ,structure_leads_fold :Atoms ):
217+ block_tridiagnal :bool , plot_blocks :bool ,\
218+ lead_atom_range :dict ,structure_leads :Atoms ,structure_leads_fold :Atoms ):
215219 '''This function initializes the Hamiltonian for a device with leads, handling various calculations
216220 and checks along the way.
217221
@@ -236,6 +240,8 @@ def Hamiltonian_initialized(self,kpoints:List[List[float]],useBloch:bool,bloch_f
236240 should be stored in a block-tridiagonal form. If `block_tridiagnal` is set to `True`, the Hamiltonian
237241 matrix will be stored in a block-tridiagonal form. Otherwise, the Hamiltonian matrix will be stored in
238242 a full matrix format.
243+ plot_blocks : bool
244+ The `plot_blocks` parameter is a boolean flag that determines whether to visualize the block structure
239245 lead_atom_range : dict
240246 The `lead_atom_range` parameter indicates the range of leads. The key of the dictionary is the
241247 lead name, and the value is a list containing the start and end indices of the lead atoms.
@@ -432,7 +438,8 @@ def Hamiltonian_initialized(self,kpoints:List[List[float]],useBloch:bool,bloch_f
432438 leftmost_size = coupling_width ['lead_L' ]
433439 rightmost_size = coupling_width ['lead_R' ]
434440 hd , hu , hl , sd , su , sl , subblocks = self .get_block_tridiagonal (HD * self .h_factor ,SD .cdouble (),self .structase ,\
435- leftmost_size ,rightmost_size )
441+ leftmost_size ,rightmost_size ,
442+ plot_blocks = plot_blocks )
436443 HS_device .update ({"hd" :hd , "hu" :hu , "hl" :hl , "sd" :sd , "su" :su , "sl" :sl , \
437444 "subblocks" :subblocks , "block_tridiagonal" :True })
438445
@@ -637,7 +644,7 @@ def get_lead_structure(self,kk,natom,useBloch=False,bloch_factor=None):
637644
638645 return stru_lead , stru_lead_fold , bloch_sorted_indice , bloch_R_list
639646
640- def get_block_tridiagonal (self ,HK ,SK ,structase :ase .Atoms ,leftmost_size :int ,rightmost_size :int ):
647+ def get_block_tridiagonal (self ,HK ,SK ,structase :ase .Atoms ,leftmost_size :int ,rightmost_size :int , plot_blocks = False ):
641648 """
642649 Block-tridiagonalizes the Hamiltonian (HK) and overlap (SK) matrices for a given atomic structure.
643650 This method splits the input matrices into block tridiagonal form based on the atomic structure along the z-axis.
@@ -671,6 +678,8 @@ def get_block_tridiagonal(self,HK,SK,structase:ase.Atoms,leftmost_size:int,right
671678 List of lower-diagonal blocks of SK for each k-point.
672679 subblocks : list
673680 List of subblock sizes (number of orbitals in each block).
681+ plot_blocks : bool
682+ Whether to visualize the block structure using `show_blocks`.
674683 Notes
675684 -----
676685 - Uses optimized or fallback block splitting depending on the structure.
@@ -726,7 +735,9 @@ def get_block_tridiagonal(self,HK,SK,structase:ase.Atoms,leftmost_size:int,right
726735 log .info (msg = " occupation of subblocks: {} %" .format (num_total / (HK [0 ].shape [0 ]** 2 )* 100 ))
727736
728737 subblocks = subblocks [1 :]
729- show_blocks (subblocks ,HK [0 ],self .results_path )
738+
739+ if plot_blocks :
740+ show_blocks (subblocks ,HK [0 ],self .results_path )
730741
731742 return hd , hu , hl , sd , su , sl , subblocks
732743
0 commit comments