Skip to content

Commit

Permalink
minor-fix: if statement to overcome cases where the electrodes is an …
Browse files Browse the repository at this point in the history
…empty list
  • Loading branch information
sofiasanz committed Nov 3, 2021
1 parent dfa33aa commit f5107fd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions hubbard/negf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ def _G(e, HC, elec_idx, SE, mode='DOS'):
GF = np.zeros([len(e), no], dtype=np.complex128)
elif mode == 'Full':
GF = np.zeros([len(e), no, no], dtype=np.complex128)

# This if statement overcomes cases where there are no electrodes
if np.array(SE).shape == (0,):

This comment has been minimized.

Copy link
@zerothi

zerothi Nov 4, 2021

Collaborator

This will fail if you have multiple electrodes with different sizes, also it is quite costly since it doubles SE memory consumption. Instead, wouldn't just checking for Se length be enough?

This comment has been minimized.

Copy link
@zerothi

zerothi Nov 4, 2021

Collaborator

Actually a test in hubbard with different size electrode would be useful to have :)

This comment has been minimized.

Copy link
@sofiasanz

sofiasanz Nov 9, 2021

Author Member

This will fail if you have multiple electrodes with different sizes, also it is quite costly since it doubles SE memory consumption. Instead, wouldn't just checking for Se length be enough?

Thank you for the comment! Actually I checked and I had an error, which I think it was also related to #106 (comment).
I fixed it in commit 3a3e4b1, where I corrected the shape of the nested lists that contained the self-energies.

Actually a test in hubbard with different size electrode would be useful to have :)

Yes! Indeed a good idea! I have uploaded an example of an interface between a 7AGNR and a 9AGNR for which is expected to have an interface state that arises from the different topologies between these two ribbons in commit 8c0113a.

SE = [SE]
for ie, e_i in enumerate(e):
inv_GF = e_i * np.identity(no) - HC
for idx, se in zip(elec_idx, SE[ie]):
inv_GF[idx, idx.T] -= se
if mode == 'DOS':
GF[ie] = np.linalg.inv(inv_GF)[np.arange(no), np.arange(no)]
elif mode == 'Full':
GF[ie] = np.linalg.inv(inv_GF)
if mode == 'DOS':
GF[ie] = np.linalg.inv(inv_GF)[np.arange(no), np.arange(no)]
elif mode == 'Full':
GF[ie] = np.linalg.inv(inv_GF)
return GF


Expand Down

0 comments on commit f5107fd

Please sign in to comment.