From 1baef676298446b5ecd466163ecf64909d49d061 Mon Sep 17 00:00:00 2001
From: Christoph Groth <christoph.groth@cea.fr>
Date: Mon, 15 Apr 2013 15:56:15 +0200
Subject: [PATCH] tutorial: simplify superconductor_transport.py

---
 .../images/superconductor_transport.py.diff   |  2 +-
 .../tutorial/superconductor_transport.py      | 26 +++++--------------
 doc/source/tutorial/tutorial5.rst             |  9 ++++---
 3 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/doc/source/images/superconductor_transport.py.diff b/doc/source/images/superconductor_transport.py.diff
index 993e4445..477a2534 100644
--- a/doc/source/images/superconductor_transport.py.diff
+++ b/doc/source/images/superconductor_transport.py.diff
@@ -8,7 +8,7 @@
  
  
  def make_system(a=1, W=10, L=10, barrier=1.5, barrierpos=(3, 4),
-@@ -94,19 +95,23 @@
+@@ -82,19 +83,23 @@
                      smatrix.transmission(0, 0) +
                      smatrix.transmission(1, 0))
  
diff --git a/doc/source/tutorial/superconductor_transport.py b/doc/source/tutorial/superconductor_transport.py
index e33512ae..a6eb1e0e 100644
--- a/doc/source/tutorial/superconductor_transport.py
+++ b/doc/source/tutorial/superconductor_transport.py
@@ -35,11 +35,9 @@ def make_system(a=1, W=10, L=10, barrier=1.5, barrierpos=(3, 4),
     sys[(lat_h(x, y) for x in range(barrierpos[0], barrierpos[1])
          for y in range(W))] = mu - 4 * t - barrier
 
-    # hoppings in x and y-directions, for both electrons and holes
-    sys[kwant.builder.HoppingKind((1, 0), lat_e, lat_e)] = -t
-    sys[kwant.builder.HoppingKind((0, 1), lat_e, lat_e)] = -t
-    sys[kwant.builder.HoppingKind((1, 0), lat_h, lat_h)] = t
-    sys[kwant.builder.HoppingKind((0, 1), lat_h, lat_h)] = t
+    # hoppings for both electrons and holes
+    sys[lat_e.nearest] = -t
+    sys[lat_h.nearest] = t
 
     # Superconducting order parameter enters as hopping between
     # electrons and holes
@@ -55,16 +53,12 @@ def make_system(a=1, W=10, L=10, barrier=1.5, barrierpos=(3, 4),
     # left electron lead
     lead0 = kwant.Builder(sym_left)
     lead0[(lat_e(0, j) for j in xrange(W))] = 4 * t - mu
-    # hoppings in x and y-direction
-    lead0[kwant.builder.HoppingKind((1, 0), lat_e, lat_e)] = -t
-    lead0[kwant.builder.HoppingKind((0, 1), lat_e, lat_e)] = -t
+    lead0[lat_e.nearest] = -t
 
     # left hole lead
     lead1 = kwant.Builder(sym_left)
     lead1[(lat_h(0, j) for j in xrange(W))] = mu - 4 * t
-    # hoppings in x and y-direction
-    lead1[kwant.builder.HoppingKind((1, 0), lat_h, lat_h)] = t
-    lead1[kwant.builder.HoppingKind((0, 1), lat_h, lat_h)] = t
+    lead1[lat_h.nearest] = t
 #HIDDEN_END_ttth
 
     # Then the lead to the right
@@ -73,14 +67,8 @@ def make_system(a=1, W=10, L=10, barrier=1.5, barrierpos=(3, 4),
 #HIDDEN_BEGIN_mhiw
     sym_right = kwant.TranslationalSymmetry((a, 0))
     lead2 = kwant.Builder(sym_right)
-
-    lead2[(lat_e(0, j) for j in xrange(W))] = 4 * t - mu
-    lead2[(lat_h(0, j) for j in xrange(W))] = mu - 4 * t
-    # hoppings in x and y-direction
-    lead2[kwant.builder.HoppingKind((1, 0), lat_e, lat_e)] = -t
-    lead2[kwant.builder.HoppingKind((0, 1), lat_e, lat_e)] = -t
-    lead2[kwant.builder.HoppingKind((1, 0), lat_h, lat_h)] = t
-    lead2[kwant.builder.HoppingKind((0, 1), lat_h, lat_h)] = t
+    lead2 += lead0
+    lead2 += lead1
     lead2[((lat_e(0, j), lat_h(0, j)) for j in xrange(W))] = Delta
 #HIDDEN_END_mhiw
 
diff --git a/doc/source/tutorial/tutorial5.rst b/doc/source/tutorial/tutorial5.rst
index 8f147b44..f9c12251 100644
--- a/doc/source/tutorial/tutorial5.rst
+++ b/doc/source/tutorial/tutorial5.rst
@@ -86,9 +86,9 @@ square lattices representing electron and hole degrees of freedom:
     :end-before: #HIDDEN_END_zuuw
 
 Note that since these two lattices have identical spatial parameters, the
-argument `name` to `~kwant.lattice.square` has to be different for two lattices.
+argument `name` to `~kwant.lattice.square` has to be different.
 Any diagonal entry (kinetic energy, potentials, ...) in the BdG
-Hamiltonian then corresponds to on-site energies or hoppings within
+Hamiltonian corresponds to on-site energies or hoppings within
 the *same* lattice, whereas any off-diagonal entry (essentially, the
 superconducting order parameter :math:`\Delta`) corresponds
 to a hopping between *different* lattices:
@@ -115,8 +115,9 @@ system:
 This separation into two different leads allows us then later to compute the
 reflection probablities between electrons and holes explicitely.
 
-On the superconducting side, we cannot do this separation, and can
-only define a single lead coupling electrons and holes:
+On the superconducting side, we cannot do this separation, and can only define a
+single lead coupling electrons and holes (The `+=` operator adds all the sites
+and hoppings present in one builder to another):
 
 .. literalinclude:: superconductor_transport.py
     :start-after: #HIDDEN_BEGIN_mhiw
-- 
GitLab