From cc5b67a9728ba8dd675ec0adf7462aa61791f9f9 Mon Sep 17 00:00:00 2001
From: Joseph Weston <joseph@weston.cloud>
Date: Tue, 29 Jan 2019 15:34:26 +0100
Subject: [PATCH] update whatsnew entry to include example with attached lead

---
 doc/source/pre/whatsnew/1.4.rst | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/doc/source/pre/whatsnew/1.4.rst b/doc/source/pre/whatsnew/1.4.rst
index 6c8ee054..c3c4168d 100644
--- a/doc/source/pre/whatsnew/1.4.rst
+++ b/doc/source/pre/whatsnew/1.4.rst
@@ -18,16 +18,26 @@ which calculates the Peierls phases for you::
   import numpy as np
   import kwant
 
-  def hopping(a, b, t, phi):
-    return -t * np.exp(-1j * phi(a, b))
+  def hopping(a, b, t, peierls):
+      return -t * peierls(a, b)
+
+  syst = make_system(hopping)
+  lead = make_lead(hopping)
+  lead.substitute(peierls='peierls_lead')
+  syst.attach_lead(lead)
+  syst = syst.finalized()
 
-  syst = make_system(hopping).finalized()
   gauge = kwant.physics.magnetic_gauge(syst)
 
-  def B(pos):
-    return np.exp(-np.sum(pos * pos))
+  def B_syst(pos):
+     return np.exp(-np.sum(pos * pos))
+
+  # B_syst in scattering region, 0 in lead.
+  # Ensure that the fields match at the system/lead interface!
+  peierls_syst, peierls_lead = gauge(B_syst, 0)
 
-  kwant.hamiltonian_submatrix(syst, params=dict(t=1, phi=gauge(B))
+  params = dict(t=1, peierls=peierls_syst, peierls_lead=peierls_lead)
+  kwant.hamiltonian_submatrix(syst, params=params)
 
 Note that the API for this functionality is provisional, and may be
 revised in a future version of Kwant.
-- 
GitLab