Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • kwant/kwant
  • jbweston/kwant
  • anton-akhmerov/kwant
  • cwg/kwant
  • Mathieu/kwant
  • slavoutich/kwant
  • pacome/kwant
  • behrmann/kwant
  • michaelwimmer/kwant
  • albeercik/kwant
  • eunjongkim/kwant
  • basnijholt/kwant
  • r-j-skolasinski/kwant
  • sahmed95/kwant
  • pablopiskunow/kwant
  • mare/kwant
  • dvarjas/kwant
  • Paul/kwant
  • bbuijtendorp/kwant
  • tkloss/kwant
  • torosdahl/kwant
  • kel85uk/kwant
  • kpoyhonen/kwant
  • Fromeworld/kwant
  • quaeritis/kwant
  • marwahaha/kwant
  • fernandodfufrpe/kwant
  • oly/kwant
  • jiamingh/kwant
  • mehdi2369/kwant
  • ValFadeev/kwant
  • Kostas/kwant
  • chelseabaptiste03/kwant
33 results
Show changes
Showing
with 4006 additions and 752 deletions
:mod:`kwant.system` -- Low-level interface of systems
*****************************************************
.. currentmodule:: kwant.system
.. automodule:: kwant.system
This module is the binding link between constructing tight-binding systems and
doing calculations with these systems. It defines the interface which any
......@@ -14,6 +14,11 @@ Any system which is provided to a solver should be derived from the appropriate
class in this module, and every solver can assume that its input corresponds to
the interface defined here.
In practice, very often Kwant systems are finalized
`builders <kwant.builder.Builder>` (i.e.
`kwant.builder.FiniteSystem` or `kwant.builder.InfiniteSystem`) and offer some
additional attributes.
.. autosummary::
:toctree: generated/
......
:mod:`kwant.wraparound` -- Wrapping around translational symmetries
===================================================================
.. module:: kwant.wraparound
.. autosummary::
:toctree: generated/
wraparound
plot_2d_bands
Note for Kwant developers
-------------------------
Say you have modified SCRIPT.py in this directory. Make sure that the tutorial
image generation patches still apply by deleting doc/source/images/SCRIPT.py
and running ``make doc/source/images/SCRIPT.py`` in doc. Now examine the newly
created doc/source/images/SCRIPT.py. If you do not like the result or the
patch did not apply, edit doc/source/images/SCRIPT.py until you like it. You
can run `make html` during your edits to check things. Finally, even if you
did not edit the script, execute generate-diffs.sh in doc/source/images. If
the patches applied cleanly the diff files will usually stay unchanged.
# Tutorial 2.3.3. Nontrivial shapes
# =================================
#
# Physics background
# ------------------
# Flux-dependent transmission through a quantum ring
#
# Kwant features highlighted
# --------------------------
# - More complex shapes with lattices
# - Allows for discussion of subtleties of `attach_lead` (not in the
# example, but in the tutorial main text)
# - Modifcations of hoppings/sites after they have been added
from cmath import exp
from math import pi
import kwant
# For plotting
from matplotlib import pyplot
#HIDDEN_BEGIN_eusz
def make_system(a=1, t=1.0, W=10, r1=10, r2=20):
# Start with an empty tight-binding system and a single square lattice.
# `a` is the lattice constant (by default set to 1 for simplicity).
lat = kwant.lattice.square(a)
sys = kwant.Builder()
#### Define the scattering region. ####
# Now, we aim for a more complex shape, namely a ring (or annulus)
def ring(pos):
(x, y) = pos
rsq = x ** 2 + y ** 2
return (r1 ** 2 < rsq < r2 ** 2)
#HIDDEN_END_eusz
# and add the corresponding lattice points using the `shape`-function
#HIDDEN_BEGIN_lcak
sys[lat.shape(ring, (0, r1 + 1))] = 4 * t
sys[lat.neighbors()] = -t
#HIDDEN_END_lcak
# In order to introduce a flux through the ring, we introduce a phase on
# the hoppings on the line cut through one of the arms. Since we want to
# change the flux without modifying the Builder instance repeatedly, we
# define the modified hoppings as a function that takes the flux as its
# parameter phi.
#HIDDEN_BEGIN_lvkt
def fluxphase(site1, site2, phi):
return exp(1j * phi)
def crosses_branchcut(hop):
ix0, iy0 = hop[0].tag
# builder.HoppingKind with the argument (1, 0) below
# returns hoppings ordered as ((i+1, j), (i, j))
return iy0 < 0 and ix0 == 1 # ix1 == 0 then implied
# Modify only those hopings in x-direction that cross the branch cut
def hops_across_cut(sys):
for hop in kwant.builder.HoppingKind((1, 0), lat, lat)(sys):
if crosses_branchcut(hop):
yield hop
sys[hops_across_cut] = fluxphase
#HIDDEN_END_lvkt
#### Define the leads. ####
# left lead
#HIDDEN_BEGIN_qwgr
sym_lead = kwant.TranslationalSymmetry((-a, 0))
lead = kwant.Builder(sym_lead)
def lead_shape(pos):
(x, y) = pos
return (-W / 2 < y < W / 2)
lead[lat.shape(lead_shape, (0, 0))] = 4 * t
lead[lat.neighbors()] = -t
#HIDDEN_END_qwgr
#### Attach the leads and return the system. ####
#HIDDEN_BEGIN_skbz
sys.attach_lead(lead)
sys.attach_lead(lead.reversed())
#HIDDEN_END_skbz
return sys
def plot_conductance(sys, energy, fluxes):
# compute conductance
normalized_fluxes = [flux / (2 * pi) for flux in fluxes]
data = []
for flux in fluxes:
smatrix = kwant.smatrix(sys, energy, args=[flux])
data.append(smatrix.transmission(1, 0))
pyplot.figure()
pyplot.plot(normalized_fluxes, data)
pyplot.xlabel("flux [flux quantum]")
pyplot.ylabel("conductance [e^2/h]")
pyplot.show()
def main():
sys = make_system()
# Check that the system looks as intended.
kwant.plot(sys)
# Finalize the system.
sys = sys.finalized()
# We should see a conductance that is periodic with the flux quantum
plot_conductance(sys, energy=0.15, fluxes=[0.01 * i * 3 * 2 * pi
for i in xrange(100)])
# Call the main function if the script gets executed (as opposed to imported).
# See <http://docs.python.org/library/__main__.html>.
if __name__ == '__main__':
main()
# Tutorial 2.4.1. Band structure calculations
# ===========================================
#
# Physics background
# ------------------
# band structure of a simple quantum wire in tight-binding approximation
#
# Kwant features highlighted
# --------------------------
# - Computing the band structure of a finalized lead.
import kwant
# For plotting.
from matplotlib import pyplot
#HIDDEN_BEGIN_zxip
def make_lead(a=1, t=1.0, W=10):
# Start with an empty lead with a single square lattice
lat = kwant.lattice.square(a)
sym_lead = kwant.TranslationalSymmetry((-a, 0))
lead = kwant.Builder(sym_lead)
# build up one unit cell of the lead, and add the hoppings
# to the next unit cell
for j in xrange(W):
lead[lat(0, j)] = 4 * t
if j > 0:
lead[lat(0, j), lat(0, j - 1)] = -t
lead[lat(1, j), lat(0, j)] = -t
return lead
#HIDDEN_END_zxip
#HIDDEN_BEGIN_pejz
def main():
lead = make_lead().finalized()
kwant.plotter.bands(lead, show=False)
pyplot.xlabel("momentum [(lattice constant)^-1]")
pyplot.ylabel("energy [t]")
pyplot.show()
#HIDDEN_END_pejz
# Call the main function if the script gets executed (as opposed to imported).
# See <http://docs.python.org/library/__main__.html>.
if __name__ == '__main__':
main()
import matplotlib
import matplotlib.pyplot
from matplotlib_inline.backend_inline import set_matplotlib_formats
matplotlib.rcParams['figure.figsize'] = matplotlib.pyplot.figaspect(1) * 2
set_matplotlib_formats('svg')
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -3,9 +3,14 @@ Tutorial: learning Kwant through examples
.. toctree::
introduction
tutorial1
tutorial2
tutorial3
tutorial4
tutorial5
tutorial6
first_steps
spin_potential_shape
spectrum
graphene
superconductors
operators
plotting
kpm
discretize
magnetic_field
faq
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.