The goal of this project is to faithfully emulate the native API of kwant.
To install from the Julia REPL, do
]add https://github.com/wrs28/Kwant.jl.git, which will look like
(v1.1) pkg> add https://github.com/wrs28/Kwant.jl.git
using Pkg and
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 Conda.add_channel("conda-forge") Conda.add("kwant")
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() a=1 lat = kwant.lattice.square(a) t=1.0 W=10 L=30 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 end # Hopping in x-direction if i > 0 syst[lat(i, j), lat(i - 1, j)] = -t end end end
Note that the Python
range(0,length=W). Alternate expressions for iterating can be found here.