From 6aaa14a78e706f0ac11c83670894a6ea7272ce0c Mon Sep 17 00:00:00 2001 From: Christoph Groth <christoph.groth@cea.fr> Date: Wed, 17 Apr 2013 15:55:55 +0200 Subject: [PATCH] bugfix: make args and kwargs work with leads --- kwant/builder.py | 2 +- kwant/solvers/common.py | 6 +++--- kwant/system.py | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/kwant/builder.py b/kwant/builder.py index 7f9eefa0..660ae1d0 100644 --- a/kwant/builder.py +++ b/kwant/builder.py @@ -1279,7 +1279,7 @@ class InfiniteSystem(system.InfiniteSystem): if hasattr(value, '__call__'): site_i = self.sites[i] site_j = self.sites[j] - site_i, site_j = self.symmetry.to_fd(site_i,site_j) + site_i, site_j = self.symmetry.to_fd(site_i, site_j) value = value(site_i, site_j, *args, **kwargs) if conj: value = herm_conj(value) diff --git a/kwant/solvers/common.py b/kwant/solvers/common.py index ccb4d111..5323b299 100644 --- a/kwant/solvers/common.py +++ b/kwant/solvers/common.py @@ -171,7 +171,7 @@ class SparseSolver(object): for leadnum, interface in enumerate(sys.lead_interfaces): lead = sys.leads[leadnum] if isinstance(lead, system.InfiniteSystem) and not force_realspace: - h = lead.slice_hamiltonian() + h = lead.slice_hamiltonian(args=args, kwargs=kwargs) if check_hermiticity: if not np.allclose(h, h.T.conj(), rtol=1e-13): @@ -180,7 +180,7 @@ class SparseSolver(object): raise ValueError(msg.format(leadnum)) h -= energy * np.identity(h.shape[0]) - v = lead.inter_slice_hopping() + v = lead.inter_slice_hopping(args=args, kwargs=kwargs) modes = physics.modes(h, v) lead_info.append(modes) @@ -237,7 +237,7 @@ class SparseSolver(object): # See comment about zero-shaped sparse matrices at the top. rhs.append(np.zeros((lhs.shape[1], 0))) else: - sigma = lead.self_energy(energy) + sigma = lead.self_energy(energy, args=args, kwargs=kwargs) lead_info.append(sigma) indices = np.r_[tuple(slice(offsets[i], offsets[i + 1]) for i in interface)] diff --git a/kwant/system.py b/kwant/system.py index bc3b1460..50e1eaf0 100644 --- a/kwant/system.py +++ b/kwant/system.py @@ -68,7 +68,8 @@ class FiniteSystem(System): Instance Variables ------------------ leads : sequence of lead objects - Each lead object has to provide a method ``self_energy(energy)``. + Each lead object has to provide a method + ``self_energy(energy, *args, **kwargs)``. lead_interfaces : sequence of sequences of integers Each sub-sequence contains the indices of the system sites to which the lead is connected. -- GitLab