Commit 9fdd41e8 authored by Christoph Groth's avatar Christoph Groth

move tutorial script generation, reorganize doc/source

I assume that most people encounter the tutorial example scripts by
reading the documentation, and not by viewing the tutorial subdirectory
of a checked-out Kwant source.

That's the motivation for moving all the manipulations of tutorial
scripts from setup.py to doc/Makefile.  Previously, a successful 'make
html' would require a preceding execution of 'setup.py build_tut'.  Now,
a simple 'make html' is enough.

While at it, I reorganized where the example scripts and their outputs
are stored.  Everything is now in 'doc/source/code' with its three
subdirectories 'download' (to be shown to readers), 'include' (with
include markers), and 'figure' (figure generation & figures).  This
organization is clearer and also makes the generation of figures
separate from the tutorial.
parent 001dafbb
......@@ -8,13 +8,14 @@
/build
/dist
/doc/build
/doc/source/tutorial/*.py
/doc/source/reference/generated/
/doc/source/images/*.png
/doc/source/images/*.pdf
/doc/source/images/.*_flag
/doc/source/images/[a-zA-Z]*.py
/doc/source/images/*.txt
/doc/source/code/include/*.py
/doc/source/code/figure/*.png
/doc/source/code/figure/*.pdf
/doc/source/code/figure/.*_flag
/doc/source/code/figure/[a-zA-Z]*.py
/doc/source/code/figure/*.txt
/doc/source/code/download/
/build.conf
/kwant.egg-info/
/MANIFEST.in
......
# Makefile for Sphinx documentation
# Copyright 2011-2013 Kwant authors.
# Copyright 2011-2017 Kwant authors.
#
# This file is part of Kwant. It is subject to the license terms in the file
# LICENSE.rst found in the top-level directory of this distribution and at
......@@ -21,21 +21,23 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) sou
# We convert all SVG files to PDF for LaTeX output. For HTML output, we don't
# create PNGs but rather use the SVG files directly.
IMAGESOURCES = $(shell find source -name "*.svg")
GENERATEDPDF = $(patsubst %.svg,%.pdf,$(IMAGESOURCES))
FIGURESOURCES = $(shell find source -name "*.svg")
GENERATEDPDF = $(patsubst %.svg,%.pdf,$(FIGURESOURCES))
# Image generation from patched tutorial scripts
# Figure generation from patched tutorial scripts
#
# As make does not support the generation of multiple targets by a single
# invocation of a (non-implicit) rule, we use a trick: We pretend to be
# generating a single (empty) flag file per invocation. The image files are
# generating a single (empty) flag file per invocation. The figure files are
# generated as well, but only as side-effects. Each flag file is used to
# remember the time at which the corresponding image-generating script was run.
# remember the time at which the corresponding figure-generating script was run.
# This works perfectly unless the actual output files are deleted without
# deleting the corresponding flag file.
SCRIPTS = $(patsubst source/images/%.diff,%,$(wildcard source/images/*.py.diff))
FLAGS = $(patsubst %.py,source/images/.%_flag,$(SCRIPTS))
INCLUDES = $(patsubst %,source/tutorial/%,$(SCRIPTS))
FIGSCRIPTS = $(patsubst %.diff,%,$(notdir $(wildcard source/code/figure/*.py.diff)))
FIGURES = $(patsubst %.py,source/code/figure/.%_flag,$(FIGSCRIPTS))
SCRIPTS = $(sort $(FIGSCRIPTS) $(notdir $(wildcard source/code/include/*.py)))
INCLUDES = $(patsubst %,source/code/include/%,$(SCRIPTS))
DOWNLOADS = $(patsubst %,source/code/download/%,$(SCRIPTS))
.PHONY: help clean realclean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
......@@ -59,39 +61,40 @@ clean:
-rm -rf source/reference/generated
realclean: clean
-rm -f $(FLAGS)
-rm -f $(INCLUDES)
-rm -f $(patsubst %,source/images/%,$(SCRIPTS))
-rm -f $(patsubst %.py,source/images/%_*.png,$(SCRIPTS))
-rm -f $(patsubst %.py,source/images/%_*.pdf,$(SCRIPTS))
html: $(FLAGS) $(INCLUDES)
-rm -f $(FIGURES)
-rm -f $(patsubst %,source/code/include/%,$(FIGSCRIPTS))
-rm -f $(DOWNLOADS)
-rm -f $(patsubst %,source/code/figure/%,$(FIGSCRIPTS))
-rm -f $(patsubst %.py,source/code/figure/%_*.png,$(FIGSCRIPTS))
-rm -f $(patsubst %.py,source/code/figure/%_*.pdf,$(FIGSCRIPTS))
html: $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml: $(FLAGS) $(INCLUDES)
dirhtml: $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
pickle: $(FLAGS) $(INCLUDES)
pickle: $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json: $(FLAGS) $(INCLUDES)
json: $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp: $(FLAGS) $(INCLUDES)
htmlhelp: $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp: $(FLAGS) $(INCLUDES)
qthelp: $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
......@@ -100,7 +103,7 @@ qthelp: $(FLAGS) $(INCLUDES)
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/kwant.qhc"
latex: $(GENERATEDPDF) $(FLAGS) $(INCLUDES)
latex: $(GENERATEDPDF) $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
......@@ -129,16 +132,20 @@ doctest:
# Make tutorial scripts by extracting the (complete!) context of the "patches".
# We make sure not to use 'wiggle' here.
.SECONDARY:
source/tutorial/%.py: source/images/%.py.diff
source/code/include/%.py: source/code/figure/%.py.diff
@sed -n '/^[- ]/ s/^.//p' <$< >$@
@touch -r $< $@
# Make the image generation scripts by patching tutorial scripts. If the
source/code/download/%.py: source/code/include/%.py
@mkdir -p source/code/download
@grep -v '^#HIDDEN' <$< >$@
# Make the figure generation scripts by patching tutorial scripts. If the
# tutorial scripts haven't been modified, don't patch but directly extract the
# image generation scripts. This means that 'wiggle' is only needed when the
# figure generation scripts. This means that 'wiggle' is only needed when the
# tutorial scripts have been modified.
.SECONDARY:
source/images/%.py: source/tutorial/%.py
source/code/figure/%.py: source/code/include/%.py
@if [ $< -nt $@.diff ]; then \
cp $< $@; \
rm -f $@.porig; \
......@@ -153,20 +160,20 @@ source/images/%.py: source/tutorial/%.py
touch -r $@.diff $@; \
fi
# Make the image generation scripts also depend on the diffs.
# Make the figure generation scripts also depend on the diffs.
define makedep
source/images/$(1): source/images/$(1).diff
source/code/figure/$(1): source/code/figure/$(1).diff
endef
$(foreach name,$(SCRIPTS),$(eval $(call makedep,$(name))))
$(foreach name,$(FIGSCRIPTS),$(eval $(call makedep,$(name))))
# Run an image generation script. When successful, and if the script is newer
# Run an figure generation script. When successful, and if the script is newer
# than the corresponding diff, recreate the latter. Note that the
# corresponding tutorial script cannot be newer, since if it is, the image
# corresponding tutorial script cannot be newer, since if it is, the figure
# generation script is generated from it by patching.
source/images/.%_flag: source/images/%.py
source/code/figure/.%_flag: source/code/figure/%.py
cd $(dir $<) && python3 $(notdir $<)
@if [ ! -f $<.diff -o $< -nt $<.diff ]; then \
wiggle --diff --lines source/tutorial/$(notdir $<) $< >$<.diff; \
wiggle --diff --lines source/code/include/$(notdir $<) $< >$<.diff; \
touch -r $< $<.diff; \
fi
@rm -f $<.porig
......
......@@ -9,7 +9,7 @@ matplotlib.use('Agg')
################################################################
import sys
from distutils.util import get_platform
sys.path.insert(0, "../../../build/lib.{0}-{1}.{2}".format(
sys.path.insert(0, "../../../../build/lib.{0}-{1}.{2}".format(
get_platform(), *sys.version_info[:2]))
################################################################
......
......@@ -28,11 +28,11 @@ tight-binding band structures or construct systems with different/lower
symmetry. For example in just a few lines we can construct a two-band model that exhibits
a quantum anomalous spin Hall phase:
.. literalinclude:: ../../tutorial/plot_qahe.py
.. literalinclude:: ../../code/include/plot_qahe.py
:start-after: HIDDEN_BEGIN_model
:end-before: HIDDEN_END_model
From: :download:`QAHE example script <../../tutorial/plot_qahe.py>`
From: :download:`QAHE example script <../../code/download/plot_qahe.py>`
See the tutorial: :doc:`../../tutorial/discretize`
......@@ -71,13 +71,13 @@ The example below shows edge states of a quantum anomalous Hall phase
of the two-band model shown in the `above section
<#tools-for-continuum-hamiltonians>`_:
.. literalinclude:: ../../tutorial/plot_qahe.py
.. literalinclude:: ../../code/include/plot_qahe.py
:start-after: HIDDEN_BEGIN_current
:end-before: HIDDEN_END_current
.. image:: ../../images/plot_qahe_current.*
.. image:: ../../code/figure/plot_qahe_current.*
From: :download:`QAHE example script <../../tutorial/plot_qahe.py>`
From: :download:`QAHE example script <../../code/download/plot_qahe.py>`
Scattering states with discrete symmetries and conservation laws
----------------------------------------------------------------
......
......@@ -18,7 +18,7 @@ continuum models and for discretizing them into tight-binding models.
.. seealso::
The complete source code of this tutorial can be found in
:download:`tutorial/discretize.py <../../../tutorial/discretize.py>`
:download:`discretize.py </code/download/discretize.py>`
.. _tutorial_discretizer_introduction:
......@@ -60,7 +60,7 @@ symmetry that serves as a template.
(We will see how to use the template to build systems with a particular
shape later).
.. literalinclude:: discretize.py
.. literalinclude:: /code/include/discretize.py
:start-after: #HIDDEN_BEGIN_symbolic_discretization
:end-before: #HIDDEN_END_symbolic_discretization
......@@ -70,7 +70,7 @@ discretization process.
The builder produced by ``discretize`` may be printed to show the source code of its onsite and hopping functions (this is a special feature of builders returned by ``discretize``):
.. literalinclude:: ../images/discretizer_intro_verbose.txt
.. literalinclude:: /code/figure/discretizer_intro_verbose.txt
.. specialnote:: Technical details
......@@ -134,7 +134,7 @@ where :math:`V(x, y)` is some arbitrary potential.
First, use ``discretize`` to obtain a
builder that we will use as a template:
.. literalinclude:: discretize.py
.. literalinclude:: /code/include/discretize.py
:start-after: #HIDDEN_BEGIN_template
:end-before: #HIDDEN_END_template
......@@ -142,18 +142,18 @@ We now use this system with the `~kwant.builder.Builder.fill`
method of `~kwant.builder.Builder` to construct the system we
want to investigate:
.. literalinclude:: discretize.py
.. literalinclude:: /code/include/discretize.py
:start-after: #HIDDEN_BEGIN_fill
:end-before: #HIDDEN_END_fill
After finalizing this system, we can plot one of the system's
energy eigenstates:
.. literalinclude:: discretize.py
.. literalinclude:: /code/include/discretize.py
:start-after: #HIDDEN_BEGIN_plot_eigenstate
:end-before: #HIDDEN_END_plot_eigenstate
.. image:: ../images/discretizer_gs.*
.. image:: /code/figure/discretizer_gs.*
Note in the above that we provided the function ``V`` to
``syst.hamiltonian_submatrix`` using ``params=dict(V=potential)``, rather than
......@@ -171,32 +171,32 @@ model [1]_ [2]_, one can provide matrix input to `~kwant.continuum.discretize`
using ``identity`` and ``kron``. For example, the definition of the BHZ model can be
written succinctly as:
.. literalinclude:: discretize.py
.. literalinclude:: /code/include/discretize.py
:start-after: #HIDDEN_BEGIN_define_qsh
:end-before: #HIDDEN_END_define_qsh
We can then make a ribbon out of this template system:
.. literalinclude:: discretize.py
.. literalinclude:: /code/include/discretize.py
:start-after: #HIDDEN_BEGIN_define_qsh_build
:end-before: #HIDDEN_END_define_qsh_build
and plot its dispersion using `kwant.plotter.bands`:
.. literalinclude:: discretize.py
.. literalinclude:: /code/include/discretize.py
:start-after: #HIDDEN_BEGIN_plot_qsh_band
:end-before: #HIDDEN_END_plot_qsh_band
.. image:: ../images/discretizer_qsh_band.*
.. image:: /code/figure/discretizer_qsh_band.*
In the above we see the edge states of the quantum spin Hall effect, which
we can visualize using `kwant.plotter.map`:
.. literalinclude:: discretize.py
.. literalinclude:: /code/include/discretize.py
:start-after: #HIDDEN_BEGIN_plot_qsh_wf
:end-before: #HIDDEN_END_plot_qsh_wf
.. image:: ../images/discretizer_qsh_wf.*
.. image:: /code/figure/discretizer_qsh_wf.*
Limitations of discretization
......@@ -233,28 +233,28 @@ example. Let us start from the continuum Hamiltonian
We start by defining this model as a string and setting the value of the
:math:`α` parameter:
.. literalinclude:: discretize.py
.. literalinclude:: /code/include/discretize.py
:start-after: #HIDDEN_BEGIN_ls_def
:end-before: #HIDDEN_END_ls_def
Now we can use `kwant.continuum.lambdify` to obtain a function that computes
:math:`H(k)`:
.. literalinclude:: discretize.py
.. literalinclude:: /code/include/discretize.py
:start-after: #HIDDEN_BEGIN_ls_hk_cont
:end-before: #HIDDEN_END_ls_hk_cont
We can also construct a discretized approximation using
`kwant.continuum.discretize`, in a similar manner to previous examples:
.. literalinclude:: discretize.py
.. literalinclude:: /code/include/discretize.py
:start-after: #HIDDEN_BEGIN_ls_hk_tb
:end-before: #HIDDEN_END_ls_hk_tb
Below we can see the continuum and tight-binding dispersions for two
different values of the discretization grid spacing :math:`a`:
.. image:: ../images/discretizer_lattice_spacing.*
.. image:: /code/figure/discretizer_lattice_spacing.*
We clearly see that the smaller grid spacing is, the better we approximate
......@@ -279,20 +279,20 @@ It is possible to use ``identity`` (for identity matrix), ``kron`` (for Kronecke
expressions involving matrices. Matrices can also be provided explicitly using
square ``[]`` brackets. For example, all following expressions are equivalent:
.. literalinclude:: discretize.py
.. literalinclude:: /code/include/discretize.py
:start-after: #HIDDEN_BEGIN_subs_1
:end-before: #HIDDEN_END_subs_1
.. literalinclude:: ../images/discretizer_subs_1.txt
.. literalinclude:: /code/figure/discretizer_subs_1.txt
We can use the ``locals`` keyword parameter to substitute expressions
and numerical values:
.. literalinclude:: discretize.py
.. literalinclude:: /code/include/discretize.py
:start-after: #HIDDEN_BEGIN_subs_2
:end-before: #HIDDEN_END_subs_2
.. literalinclude:: ../images/discretizer_subs_2.txt
.. literalinclude:: /code/figure/discretizer_subs_2.txt
Symbolic expressions obtained in this way can be directly passed to all
``discretizer`` functions.
......
This diff is collapsed.
......@@ -62,11 +62,11 @@ Transport through a quantum wire
.. seealso::
The complete source code of this example can be found in
:download:`tutorial/quantum_wire.py <../../../tutorial/quantum_wire.py>`
:download:`quantum_wire.py </code/download/quantum_wire.py>`
In order to use Kwant, we need to import it:
.. literalinclude:: quantum_wire.py
.. literalinclude:: /code/include/quantum_wire.py
:start-after: #HIDDEN_BEGIN_dwhx
:end-before: #HIDDEN_END_dwhx
......@@ -76,7 +76,7 @@ The first step is now the definition of the system with scattering region and
leads. For this we make use of the `~kwant.builder.Builder` type that allows to
define a system in a convenient way. We need to create an instance of it:
.. literalinclude:: quantum_wire.py
.. literalinclude:: /code/include/quantum_wire.py
:start-after: #HIDDEN_BEGIN_goiq
:end-before: #HIDDEN_END_goiq
......@@ -92,7 +92,7 @@ Apart from `~kwant.builder.Builder` we also need to specify
what kind of sites we want to add to the system. Here we work with
a square lattice. For simplicity, we set the lattice constant to unity:
.. literalinclude:: quantum_wire.py
.. literalinclude:: /code/include/quantum_wire.py
:start-after: #HIDDEN_BEGIN_suwo
:end-before: #HIDDEN_END_suwo
......@@ -111,7 +111,7 @@ needed in Builder (more about that in the technical details below).
We now build a rectangular scattering region that is `W`
lattice points wide and `L` lattice points long:
.. literalinclude:: quantum_wire.py
.. literalinclude:: /code/include/quantum_wire.py
:start-after: #HIDDEN_BEGIN_zfvr
:end-before: #HIDDEN_END_zfvr
......@@ -140,7 +140,7 @@ Next, we define the leads. Leads are also constructed using
`~kwant.builder.Builder`, but in this case, the
system must have a translational symmetry:
.. literalinclude:: quantum_wire.py
.. literalinclude:: /code/include/quantum_wire.py
:start-after: #HIDDEN_BEGIN_xcmc
:end-before: #HIDDEN_END_xcmc
......@@ -155,7 +155,7 @@ as the hoppings inside one unit cell and to the next unit cell of the lead.
For a square lattice, and a lead in y-direction the unit cell is
simply a vertical line of points:
.. literalinclude:: quantum_wire.py
.. literalinclude:: /code/include/quantum_wire.py
:start-after: #HIDDEN_BEGIN_ndez
:end-before: #HIDDEN_END_ndez
......@@ -163,7 +163,7 @@ Note that here it doesn't matter if you add the hoppings to the next or the
previous unit cell -- the translational symmetry takes care of that. The
isolated, infinite is attached at the correct position using
.. literalinclude:: quantum_wire.py
.. literalinclude:: /code/include/quantum_wire.py
:start-after: #HIDDEN_BEGIN_fskr
:end-before: #HIDDEN_END_fskr
......@@ -175,7 +175,7 @@ We also want to add a lead on the right side. The only difference to
the left lead is that the vector of the translational
symmetry must point to the right, the remaining code is the same:
.. literalinclude:: quantum_wire.py
.. literalinclude:: /code/include/quantum_wire.py
:start-after: #HIDDEN_BEGIN_xhqc
:end-before: #HIDDEN_END_xhqc
......@@ -187,13 +187,13 @@ you do not need to worry about that.
Now we have finished building our system! We plot it, to make sure we didn't
make any mistakes:
.. literalinclude:: quantum_wire.py
.. literalinclude:: /code/include/quantum_wire.py
:start-after: #HIDDEN_BEGIN_wsgh
:end-before: #HIDDEN_END_wsgh
This should bring up this picture:
.. image:: /images/quantum_wire_syst.*
.. image:: /code/figure/quantum_wire_syst.*
The system is represented in the usual way for tight-binding systems:
dots represent the lattice points `(i, j)`, and for every
......@@ -203,14 +203,14 @@ fading color.
In order to use our system for a transport calculation, we need to finalize it
.. literalinclude:: quantum_wire.py
.. literalinclude:: /code/include/quantum_wire.py
:start-after: #HIDDEN_BEGIN_dngj
:end-before: #HIDDEN_END_dngj
Having successfully created a system, we now can immediately start to compute
its conductance as a function of energy:
.. literalinclude:: quantum_wire.py
.. literalinclude:: /code/include/quantum_wire.py
:start-after: #HIDDEN_BEGIN_buzn
:end-before: #HIDDEN_END_buzn
......@@ -227,13 +227,13 @@ Finally we can use ``matplotlib`` to make a plot of the computed data
(although writing to file and using an external viewer such as
gnuplot or xmgrace is just as viable)
.. literalinclude:: quantum_wire.py
.. literalinclude:: /code/include/quantum_wire.py
:start-after: #HIDDEN_BEGIN_lliv
:end-before: #HIDDEN_END_lliv
This should yield the result
.. image:: /images/quantum_wire_result.*
.. image:: /code/figure/quantum_wire_result.*
We see a conductance quantized in units of :math:`e^2/h`,
increasing in steps as the energy is increased. The
......@@ -333,7 +333,7 @@ Building the same system with less code
.. seealso::
The complete source code of this example can be found in
:download:`tutorial/quantum_wire_revisited.py <../../../tutorial/quantum_wire_revisited.py>`
:download:`quantum_wire_revisited.py </code/download/quantum_wire_revisited.py>`
Kwant allows for more than one way to build a system. The reason is that
`~kwant.builder.Builder` is essentially just a container that can be filled in
......@@ -350,14 +350,14 @@ We begin the program collecting all imports in the beginning of the
file and put the build-up of the system into a separate function
`make_system`:
.. literalinclude:: quantum_wire_revisited.py
.. literalinclude:: /code/include/quantum_wire_revisited.py
:start-after: #HIDDEN_BEGIN_xkzy
:end-before: #HIDDEN_END_xkzy
Previously, the scattering region was build using two ``for``-loops.
Instead, we now write:
.. literalinclude:: quantum_wire_revisited.py
.. literalinclude:: /code/include/quantum_wire_revisited.py
:start-after: #HIDDEN_BEGIN_vvjt
:end-before: #HIDDEN_END_vvjt
......@@ -375,7 +375,7 @@ hoppings. In this case, an iterable like for the lattice
points becomes a bit cumbersome, and we use instead another
feature of Kwant:
.. literalinclude:: quantum_wire_revisited.py
.. literalinclude:: /code/include/quantum_wire_revisited.py
:start-after: #HIDDEN_BEGIN_nooi
:end-before: #HIDDEN_END_nooi
......@@ -397,7 +397,7 @@ values for all the nth-nearest neighbors at once, one can similarly use
The left lead is constructed in an analogous way:
.. literalinclude:: quantum_wire_revisited.py
.. literalinclude:: /code/include/quantum_wire_revisited.py
:start-after: #HIDDEN_BEGIN_iepx
:end-before: #HIDDEN_END_iepx
......@@ -408,20 +408,20 @@ symmetry vector. Here, we only construct the left lead, and use the method
of a lead pointing in the opposite direction. Both leads are attached as
before and the finished system returned:
.. literalinclude:: quantum_wire_revisited.py
.. literalinclude:: /code/include/quantum_wire_revisited.py
:start-after: #HIDDEN_BEGIN_yxot
:end-before: #HIDDEN_END_yxot
The remainder of the script has been organized into two functions. One for the
plotting of the conductance.
.. literalinclude:: quantum_wire_revisited.py
.. literalinclude:: /code/include/quantum_wire_revisited.py
:start-after: #HIDDEN_BEGIN_ayuk
:end-before: #HIDDEN_END_ayuk
And one ``main`` function.
.. literalinclude:: quantum_wire_revisited.py
.. literalinclude:: /code/include/quantum_wire_revisited.py
:start-after: #HIDDEN_BEGIN_cjel
:end-before: #HIDDEN_END_cjel
......@@ -429,7 +429,7 @@ Finally, we use the following standard Python construct [#]_ to execute
``main`` if the program is used as a script (i.e. executed as
``python quantum_wire_revisited.py``):
.. literalinclude:: quantum_wire_revisited.py
.. literalinclude:: /code/include/quantum_wire_revisited.py
:start-after: #HIDDEN_BEGIN_ypbj
:end-before: #HIDDEN_END_ypbj
......@@ -455,7 +455,7 @@ The result of the example should be identical to the previous one.
using a tuple of sites. Hence it is worth noting
a subtle detail in
.. literalinclude:: quantum_wire_revisited.py
.. literalinclude:: /code/include/quantum_wire_revisited.py
:start-after: #HIDDEN_BEGIN_vvjt
:end-before: #HIDDEN_END_vvjt
......
......@@ -5,7 +5,7 @@ Beyond square lattices: graphene
.. seealso::
The complete source code of this example can be found in
:download:`tutorial/graphene.py <../../../tutorial/graphene.py>`
:download:`graphene.py </code/download/graphene.py>`
In the following example, we are going to calculate the
conductance through a graphene quantum dot with a p-n junction
......@@ -18,7 +18,7 @@ We begin by defining the honeycomb lattice of graphene. This is
in principle already done in `kwant.lattice.honeycomb`, but we do it
explicitly here to show how to define a new lattice:
.. literalinclude:: graphene.py
.. literalinclude:: /code/include/graphene.py
:start-after: #HIDDEN_BEGIN_hnla
:end-before: #HIDDEN_END_hnla
......@@ -31,7 +31,7 @@ itself forms a regular lattice of the same type as well, and those
In the next step we define the shape of the scattering region (circle again)
and add all lattice points using the ``shape``-functionality:
.. literalinclude:: graphene.py
.. literalinclude:: /code/include/graphene.py
:start-after: #HIDDEN_BEGIN_shzy
:end-before: #HIDDEN_END_shzy
......@@ -45,7 +45,7 @@ As a next step we add the hoppings, making use of
`~kwant.builder.HoppingKind`. For illustration purposes we define
the hoppings ourselves instead of using ``graphene.neighbors()``:
.. literalinclude:: graphene.py
.. literalinclude:: /code/include/graphene.py
:start-after: #HIDDEN_BEGIN_hsmc
:end-before: #HIDDEN_END_hsmc
......@@ -63,7 +63,7 @@ respect to the two primitive vectors ``[(1, 0), (sin_30, cos_30)]``.
Adding the hoppings however still works the same way:
.. literalinclude:: graphene.py
.. literalinclude:: /code/include/graphene.py
:start-after: #HIDDEN_BEGIN_bfwb
:end-before: #HIDDEN_END_bfwb
......@@ -72,7 +72,7 @@ do something crazy, and remove an atom in sublattice A
(which removes also the hoppings from/to this site) as well
as add an additional link:
.. literalinclude:: graphene.py
.. literalinclude:: /code/include/graphene.py
:start-after: #HIDDEN_BEGIN_efut
:end-before: #HIDDEN_END_efut
......@@ -81,7 +81,7 @@ is done by the sublattices `a` and `b`.
The leads are defined almost as before:
.. literalinclude:: graphene.py
.. literalinclude:: /code/include/graphene.py
:start-after: #HIDDEN_BEGIN_aakh
:end-before: #HIDDEN_END_aakh
......@@ -101,14 +101,14 @@ Later, we will compute some eigenvalues of the closed scattering region without
leads. This is why we postpone attaching the leads to the system. Instead,