From aa7b064d77452772e1cc5041dfc308d3250587e5 Mon Sep 17 00:00:00 2001
From: Christoph Groth <christoph.groth@cea.fr>
Date: Fri, 17 Jan 2014 15:42:28 +0100
Subject: [PATCH] allow attaching a lead to a builder that contains sites that
 are not commensurate with the leads's symmetry

---
 kwant/builder.py | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/kwant/builder.py b/kwant/builder.py
index 39689bff..0972b8d2 100644
--- a/kwant/builder.py
+++ b/kwant/builder.py
@@ -998,17 +998,24 @@ class Builder(object):
         # Check if site families of the lead are present in the system (catches
         # a common and a hard to find bug).
         families = set(site.family for site in H)
+        lead_only_families = families.copy()
         for site in self.H:
-            families.discard(site.family)
-            if not families:
+            lead_only_families.discard(site.family)
+            if not lead_only_families:
                 break
         else:
             msg = 'Sites with site families {0} do not appear in the system, ' \
                 'hence the system does not interrupt the lead.'
-            raise ValueError(msg.format(tuple(families)))
+            raise ValueError(msg.format(tuple(lead_only_families)))
+
+        all_doms = set()
+        for site in self.H:
+            if site.family not in families:
+                continue
+            ge = sym.which(site)
+            if sym.act(-ge, site) in H:
+                all_doms.add(ge[0])
 
-        all_doms = list(sym.which(site)[0]
-                        for site in self.H if sym.to_fd(site) in H)
         if origin is not None:
             orig_dom = sym.which(origin)[0]
             all_doms = [dom for dom in all_doms if dom <= orig_dom]
-- 
GitLab