Commit 908ee5bc authored by Joseph Weston's avatar Joseph Weston
Browse files

check for selfenergy leads in 'smatrix'

It is meaningful to calculate scattering matrix elements for
leads that are specified as modes, but not for leads specified
as selfenergies only.
parent f53e6fa6
......@@ -359,6 +359,15 @@ class SparseSolver(metaclass=abc.ABCMeta):
if len(in_leads) == 0 or len(out_leads) == 0:
raise ValueError("No output is requested.")
for direction, leads in [("in", in_leads), ("out", out_leads)]:
for lead in leads:
if system.is_selfenergy_lead(syst.leads[lead]):
raise ValueError(
f"lead {lead} is only defined by a self-energy, "
"so we cannot calculate scattering matrix elements for it. "
f"Specify '{direction}_leads' without '{lead}'."
)
linsys, lead_info = self._make_linear_sys(syst, in_leads, energy, args,
check_hermiticity, False,
params=params)
......
......@@ -955,6 +955,10 @@ def is_vectorized(syst):
return isinstance(syst, (FiniteVectorizedSystem, InfiniteVectorizedSystem))
def is_selfenergy_lead(lead):
return hasattr(lead, "selfenergy") and not hasattr(lead, "modes")
def _normalize_matrix_blocks(blocks, expected_shape, *, calling_function=None):
"""Normalize a sequence of matrices into a single 3D numpy array
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment