Julia binding to kwant
Author wrs28
3 Stars
Updated Last
3 Years Ago
Started In
March 2019


Kwant.jl is an interface with the kwant quantum transport package, using the PyCall pacakage.

The goal of this project is to faithfully emulate the native API of kwant.

To date, the implementation is in its very early stages, reproducing only the first few pages of the First Steps Tutorial. See the tutorials folder.


To install from the Julia REPL, do ]add, which will look like

(v1.1) pkg> add

or perhaps using Pkg and Pkg.add("").

It is easiest to make a new installation of kwant via the Conda.jl package (first do ]add Conda). This can be done with

using Conda

If you don't want to install a Julia-private instance of kwant, you can play some trickery with building PyCall to the same Python library (instructions here), but I don't recommend it.


To use the plotting routines that come with kwant, you must implicitly call using PyPlot. Then something like plot(syst) should plot the system. Dependeing on the environment and build, you may need to explicitly call gcf() to show the figure.

The first lines of the kwant tutorial read

import kwant
syst = kwant.Builder()
lat = kwant.lattice.square(a)
for i in range(L):
    for j in range(W):
        # On-site Hamiltonian
        syst[lat(i, j)] = 4 * t

        # Hopping in y-direction
        if j > 0:
            syst[lat(i, j), lat(i, j - 1)] = -t

        # Hopping in x-direction
        if i > 0:
            syst[lat(i, j), lat(i - 1, j)] = -t

while the first lines of the Julia implementation read

import Kwant
kwant = Kwant
syst = kwant.Builder()
a = 1
lat = kwant.lattice.square(a)
t = 1.0
W = 10
L = 30
for i in range(0,length=L)
    for j in range(0,length=W)
        # On-site Hamiltonian
        syst[lat(i, j)] = 4 * t

        # Hopping in y-direction
        if j > 0
            syst[lat(i,j),lat(i,j-1)] = -t

        # Hopping in x-direction
        if i > 0
            syst[lat(i, j), lat(i - 1, j)] = -t

Note that the Python range(W) becomes range(0,length=W). Alternate expressions for iterating can be found here.

Used By Packages

No packages found.