From f5107fd6472c14386ed0a34c9a2ad6f0e519c84b Mon Sep 17 00:00:00 2001 From: Sofia Sanz Wuhl Date: Wed, 3 Nov 2021 20:22:02 +0100 Subject: [PATCH] minor-fix: if statement to overcome cases where the electrodes is an empty list --- hubbard/negf.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hubbard/negf.py b/hubbard/negf.py index c80d92b8..3bcc1182 100644 --- a/hubbard/negf.py +++ b/hubbard/negf.py @@ -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,): + 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