From cd9610fa22488ae0fb4063f9b138b06437d73cc3 Mon Sep 17 00:00:00 2001
From: Christoph Groth <christoph.groth@cea.fr>
Date: Thu, 29 Aug 2013 12:15:02 +0200
Subject: [PATCH] tutorial: explain discretization of the Hamiltonian

---
 doc/source/conf.py                     | 10 +++-
 doc/source/images/quantum_wire.py.diff |  4 +-
 doc/source/tutorial/introduction.rst   |  8 +++
 doc/source/tutorial/quantum_wire.py    |  5 +-
 doc/source/tutorial/tutorial1.rst      | 77 +++++++++++++++++++++++---
 5 files changed, 92 insertions(+), 12 deletions(-)

diff --git a/doc/source/conf.py b/doc/source/conf.py
index f4077fc..29f08e5 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -101,6 +101,14 @@ numpydoc_show_class_members = False
 
 # -- Options for HTML output ---------------------------------------------------
 
+# http://stackoverflow.com/questions/9728292/creating-latex-math-macros-within-sphinx
+pngmath_latex_preamble = r"""\newcommand{\bra}[1]{\left\langle#1\right|}
+\newcommand{\ket}[1]{\left|#1\right>}
+\newcommand{\braket}[2]{\left\langle#1|#2\right\rangle}
+\newcommand{\ri}{\text{i}}
+\newcommand{\rd}{\text{d}}
+"""
+
 # The theme to use for HTML and HTML Help pages.  Major themes that come with
 # Sphinx are currently 'default' and 'sphinxdoc'.
 html_theme = 'default'
@@ -195,7 +203,7 @@ r"""\makeatletter
     \renewcommand{\footrulewidth}{0.4pt}
   }
 \makeatother
-"""}
+""" + pngmath_latex_preamble}
 
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, documentclass [howto/manual]).
diff --git a/doc/source/images/quantum_wire.py.diff b/doc/source/images/quantum_wire.py.diff
index a4ac0f7..3edc8b0 100644
--- a/doc/source/images/quantum_wire.py.diff
+++ b/doc/source/images/quantum_wire.py.diff
@@ -8,7 +8,7 @@
  from matplotlib import pyplot
  import kwant
  
-@@ -65,7 +66,10 @@
+@@ -66,7 +67,10 @@
  sys.attach_lead(right_lead)
  
  # Plot it, to make sure it's OK
@@ -20,7 +20,7 @@
  
  # Finalize the system
  sys = sys.finalized()
-@@ -86,8 +90,13 @@
+@@ -87,8 +91,13 @@
  
  # Use matplotlib to write output
  # We should see conductance steps
diff --git a/doc/source/tutorial/introduction.rst b/doc/source/tutorial/introduction.rst
index 814b3dd..dca3ccd 100644
--- a/doc/source/tutorial/introduction.rst
+++ b/doc/source/tutorial/introduction.rst
@@ -1,6 +1,14 @@
 Introduction
 ============
 
+Quantum transport
+.................
+
+This introduction to the software Kwant is written for people that already have
+some experience with the theory of quantum transport.  Several introductions to
+the field are available, the most widely known is probably the book "Electronic
+transport in mesoscopic systems" by Supriyo Datta.
+
 The Python programming language
 ...............................
 
diff --git a/doc/source/tutorial/quantum_wire.py b/doc/source/tutorial/quantum_wire.py
index 35e1ac6..22e3909 100644
--- a/doc/source/tutorial/quantum_wire.py
+++ b/doc/source/tutorial/quantum_wire.py
@@ -34,13 +34,14 @@ L = 30
 
 for i in xrange(L):
     for j in xrange(W):
+        # On-site Hamiltonian
         sys[lat(i, j)] = 4 * t
 
-        # hoppig in y-direction
+        # Hopping in y-direction
         if j > 0:
             sys[lat(i, j), lat(i, j - 1)] = -t
 
-        #hopping in x-direction
+        # Hopping in x-direction
         if i > 0:
             sys[lat(i, j), lat(i - 1, j)] = -t
 #HIDDEN_END_zfvr
diff --git a/doc/source/tutorial/tutorial1.rst b/doc/source/tutorial/tutorial1.rst
index 71efbed..570382f 100644
--- a/doc/source/tutorial/tutorial1.rst
+++ b/doc/source/tutorial/tutorial1.rst
@@ -1,18 +1,60 @@
 First steps in Kwant: Setting up a simple system and computing transport
 ------------------------------------------------------------------------
 
-Transport through a quantum wire
-................................
+Discretization of a Schrödinger Hamiltonian
+...........................................
+
+As first example, we compute the transmission probability through a
+two-dimensional quantum wire.  The wire is governed by the two-dimensional
+Schrödinger equation
+
+.. math::
+    H = \frac{-\hbar^2}{2m}(\partial_x^2 + \partial_y^2) + V(y)
+
+with a hard-wall confinement :math:`V(y)` in y-direction.
+
+To be able to implement the quantum wire with Kwant, the continuous Hamiltonian
+:math:`H` has to be discretized thus turning it into a tight-binding
+model.  For simplicity, we discretize :math:`H` on the sites of a square
+lattice with lattice constant :math:`a`.  Each site with the integer
+lattice coordinates :math:`(i, j)` has the real-space coordinates :math:`(x, y)
+= (ai, aj)`.
+
+Introducing the discretized positional states
+
+.. math::
+    \ket{i, j} \equiv \ket{ai, aj} = \ket{x, y}
+
+the second-order differential operators can be expressed in the limit :math:`a
+\to 0` as
+
+.. math::
+    \partial_x^2 = \frac{1}{a^2} \sum_{i, j} \left(\ket{i+1, j}\bra{i, j} +
+    \ket{i, j}\bra{i+1, j} -2 \ket{i, j}\bra{i, j} \right),
+
+and an equivalent expression for :math:`\partial_y^2`.  Subsitituting them in
+the Hamiltonian gives us
+
+.. math::
+    H = \sum_{i,j} \big[ \left(V(ai, aj) + 4t\right)\ket{i,j}\bra{i,j}
+    - t \big( \ket{i+1,j}\bra{i,j} + \ket{i,j}\bra{i+1,j}
+    + \ket{i,j+1}\bra{i,j} + \ket{i,j}\bra{i,j+1} \big) \big]
 
-As first example, we compute the transmission probability
-through a two-dimensional quantum wire. For this we use a tight-binding
-model representing the two-dimensional Schroedinger equation
+with
 
 .. math::
+    t = \frac{\hbar^2}{2ma^2}.
+
+For finite :math:`a`, this discretized Hamiltonian approximates the continuous
+one to any required accuracy.  The approximation is good for all quantum states
+with a wave length considerably larger than :math:`a`.
 
-    H = \frac{-\hbar^2}{2 m} (\partial_x^2+\partial_y^2) + V(y)
+The remainder of this section demonstrates how to realize the discretized
+Hamiltonian in Kwant and how to perform transmission calculations.  For
+simplicity, we choose to work in such units that :math:`t = a = 1`.
 
-with a hard wall confinement :math:`V(y)` in y-direction.
+Transport through a quantum wire
+................................
 
 In order to use Kwant, we need to import it:
 
@@ -65,6 +107,27 @@ lattice points wide and `L` lattice points long:
     :start-after: #HIDDEN_BEGIN_zfvr
     :end-before: #HIDDEN_END_zfvr
 
+Observe how the above code corresponds directly to the terms of the discretized
+Hamiltonian:
+"On-site Hamiltonian" implements
+
+.. math::
+    \sum_{i,j} \left(V(ai, aj) + 4t\right)\ket{i,j}\bra{i,j}
+
+(with zero potential).  "Hopping in x-direction" implements
+
+.. math::
+    \sum_{i,j} -t \big( \ket{i+1,j}\bra{i,j} + \ket{i,j}\bra{i+1,j} \big),
+
+and "Hopping in y-direction" implements
+
+.. math::
+    \sum_{i,j} -t \big( \ket{i,j+1}\bra{i,j} + \ket{i,j}\bra{i,j+1} \big).
+
+The hard-wall confinement is realized by not having hoppings (and sites) beyond
+a certain region of space.
+
+
 Next, we define the leads. Leads are also constructed using
 `~kwant.builder.Builder`, but in this case, the
 system must have a translational symmetry:
-- 
GitLab