Sorry, my code was not formatted correctly in my previous email.
Here it is again:
###############
import numpy
from kwant.wraparound import wraparound,plot_2d_bands
from matplotlib import pyplot
get_ipython().magic('matplotlib inline')
import sys
import itertools
import collections
import cmath
import numpy as np
import tinyarray as ta
from numpy import pi,sqrt,arccos,array
import kwant
from kwant.builder import herm_conj
def plot_bands_2d(syst, args=(), momenta=(31, 31, 31), kz=0):
"""Plot the bands of a system with two wrapped-around symmetries."""
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot
if not isinstance(syst, kwant.system.FiniteSystem):
raise TypeError("Need a system without symmetries.")
fig = pyplot.figure()
ax = fig.gca(projection='3d')
kxs = np.linspace(-np.pi, np.pi, momenta[0])
kys = np.linspace(-np.pi, np.pi, momenta[1])
def get_energies(kz=kz):
energies = [[np.sort(np.linalg.eigvalsh(syst.hamiltonian_submatrix(
args + (kx, ky, kz), sparse=False)).real) for ky in kys] for kx in
kxs]
return energies
energies = np.array(get_energies(kz=kz))
Colors=['orange','g','b','r','y']
mesh_x, mesh_y = np.meshgrid(kxs, kys)
for i in range(energies.shape[-1]):
ax.plot_wireframe(mesh_x, mesh_y, energies[:, :, i], rstride=1,
cstride=1,color=Colors[i])
ax.plot_surface(mesh_x, mesh_y, energies[:, :, i], rstride=1,
cstride=1,color=Colors[i])
#pyplot.show()
def make_sys():
def Onsite(site):
return array([[1,1],[1,-1]])
"""Create a builder for a periodic infinite sheet of graphene."""
lat =kwant.lattice.cubic(norbs=2)
sym = kwant.TranslationalSymmetry(lat.vec((1, 0,0)), lat.vec((0,
1,0)),lat.vec((0, 0,1)))
syst = kwant.Builder(sym)
syst[lat.shape(lambda p: True, (0, 0, 0))] = Onsite
syst[lat.neighbors()] = array([[1,1j],[-1j,1]])
return syst
sys=make_sys()
syst = wraparound(sys).finalized()
plot_bands_2d(syst,kz=-3)