Using smatrix on a system with a SelfEnergyLead fails
I don't have time to make an example right now, but if you construct a system that has a kwant.builder.SelfEnergyLead
as one of the leads, and call kwant.smatrix
on it Kwant will raise an AttributeError
because the SelfEnergyLead
does not have a modes
method.
IMO this is a bug. As long as you have at least 1 lead that has modes
, I would expect everything to work.
A naïve fix is simple: simply evaluate the self-energy of the lead and add it to the scattering region Hamiltonian.
What is a bit trickier is how to handle lead numbering. Imagine I had 3 leads attached (0, 1, 2) and lead 1 is a self-energy lead.
When asking for submatrices of the scattering matrix we would be "unable" to use lead index 1, as we have no way of getting the scattering matrix elements to the SelfEnergyLead (because it does not have modes
defined).
What we could do is raise an exception if smatrix
is used and there is a SelfEnergyLead
and no in_lead
and out_leads
have been provided, notifying the user that they must specify this, omitting the self-energy lead. AFAICT this would solve the numbering problem.