shyam lochan bora
2018-08-09 06:14:32 UTC
Dear Sir,
I am using kwant in windows with the help of notepad++.
when I run the following program
import matplotlib
from matplotlib import pyplot
from mpl_toolkits import mplot3d
import numpy as np
from wraparound import wraparound
import kwant
def momentum_to_lattice(k):
B = np.array(graphene.prim_vecs).T
A = B.dot(np.linalg.inv(B.T.dot(B)))
return np.linalg.solve(A, k)
def dispersion_2D(syst, args=None, lim=1.5*np.pi, num_points=200):
"""A simple plot of 2D band structure."""
if args is None:
args = []
momenta = np.linspace(-lim, lim, num_points)
energies = []
for kx in momenta:
for ky in momenta:
lattice_k = momentum_to_lattice([kx, ky])
h = syst.hamiltonian_submatrix(args=(list(args) +
list(lattice_k)))
energies.append(np.linalg.eigvalsh(h))
energies = np.array(energies).reshape(num_points, num_points, -1)
emin, emax = np.min(energies), np.max(energies)
kx, ky = np.meshgrid(momenta, momenta)
fig = pyplot.figure()
axes = fig.add_subplot(1, 1, 1, projection='3d')
for band in range(energies.shape[-1]):
axes.plot_surface(kx, ky, energies[:, :, band], cstride=2,
rstride=2,
cmap=matplotlib.cm.RdBu_r, vmin=emin, vmax=emax,
linewidth=0.1)
graphene = kwant.lattice.general([[1, 0], [1/2, np.sqrt(3)/2]], # lattice
vectors
[[0, 0], [0, 1/np.sqrt(3)]]) #
Coordinates of the sites
a, b = graphene.sublattices
bulk_graphene =
kwant.Builder(kwant.TranslationalSymmetry(*graphene.prim_vecs))
bulk_graphene[graphene.shape((lambda pos: True), (0, 0))] = 0
bulk_graphene[graphene.neighbors(1)] = 1
dispersion_2D(wraparound(bulk_graphene).finalized())
zigzag_ribbon = kwant.Builder(kwant.TranslationalSymmetry([1, 0]))
zigzag_ribbon[graphene.shape((lambda pos: abs(pos[1]) < 9), (0, 0))] = 0
zigzag_ribbon[graphene.neighbors(1)] = 1
kwant.plotter.bands(zigzag_ribbon.finalized())
armchair_ribbon = kwant.Builder(kwant.TranslationalSymmetry([0,
np.sqrt(3)]))
armchair_ribbon[graphene.shape((lambda pos: abs(pos[0]) < 9), (0, 0))] = 0
armchair_ribbon[graphene.neighbors(1)] = 1
kwant.plotter.bands(armchair_ribbon.finalized(), fig_size=(12, 8))
zigzag_ribbon = kwant.Builder(kwant.TranslationalSymmetry([1, 0]))
zigzag_ribbon[a.shape((lambda pos: abs(pos[1]) < 9), (0, 0))] = 0.2
zigzag_ribbon[b.shape((lambda pos: abs(pos[1]) < 9), (0, 0))] = -0.2
zigzag_ribbon[graphene.neighbors(1)] = 1
kwant.plotter.bands(zigzag_ribbon.finalized(), fig_size=(12, 8))
The following error message appeared..
File "C:\Users\Shyam Lochan Bora\Desktop\new 1.py", line 5, in <module>
from wraparound import wraparound
ModuleNotFoundError: No module named 'wraparound'
Help me in this regard
I am using kwant in windows with the help of notepad++.
when I run the following program
import matplotlib
from matplotlib import pyplot
from mpl_toolkits import mplot3d
import numpy as np
from wraparound import wraparound
import kwant
def momentum_to_lattice(k):
B = np.array(graphene.prim_vecs).T
A = B.dot(np.linalg.inv(B.T.dot(B)))
return np.linalg.solve(A, k)
def dispersion_2D(syst, args=None, lim=1.5*np.pi, num_points=200):
"""A simple plot of 2D band structure."""
if args is None:
args = []
momenta = np.linspace(-lim, lim, num_points)
energies = []
for kx in momenta:
for ky in momenta:
lattice_k = momentum_to_lattice([kx, ky])
h = syst.hamiltonian_submatrix(args=(list(args) +
list(lattice_k)))
energies.append(np.linalg.eigvalsh(h))
energies = np.array(energies).reshape(num_points, num_points, -1)
emin, emax = np.min(energies), np.max(energies)
kx, ky = np.meshgrid(momenta, momenta)
fig = pyplot.figure()
axes = fig.add_subplot(1, 1, 1, projection='3d')
for band in range(energies.shape[-1]):
axes.plot_surface(kx, ky, energies[:, :, band], cstride=2,
rstride=2,
cmap=matplotlib.cm.RdBu_r, vmin=emin, vmax=emax,
linewidth=0.1)
graphene = kwant.lattice.general([[1, 0], [1/2, np.sqrt(3)/2]], # lattice
vectors
[[0, 0], [0, 1/np.sqrt(3)]]) #
Coordinates of the sites
a, b = graphene.sublattices
bulk_graphene =
kwant.Builder(kwant.TranslationalSymmetry(*graphene.prim_vecs))
bulk_graphene[graphene.shape((lambda pos: True), (0, 0))] = 0
bulk_graphene[graphene.neighbors(1)] = 1
dispersion_2D(wraparound(bulk_graphene).finalized())
zigzag_ribbon = kwant.Builder(kwant.TranslationalSymmetry([1, 0]))
zigzag_ribbon[graphene.shape((lambda pos: abs(pos[1]) < 9), (0, 0))] = 0
zigzag_ribbon[graphene.neighbors(1)] = 1
kwant.plotter.bands(zigzag_ribbon.finalized())
armchair_ribbon = kwant.Builder(kwant.TranslationalSymmetry([0,
np.sqrt(3)]))
armchair_ribbon[graphene.shape((lambda pos: abs(pos[0]) < 9), (0, 0))] = 0
armchair_ribbon[graphene.neighbors(1)] = 1
kwant.plotter.bands(armchair_ribbon.finalized(), fig_size=(12, 8))
zigzag_ribbon = kwant.Builder(kwant.TranslationalSymmetry([1, 0]))
zigzag_ribbon[a.shape((lambda pos: abs(pos[1]) < 9), (0, 0))] = 0.2
zigzag_ribbon[b.shape((lambda pos: abs(pos[1]) < 9), (0, 0))] = -0.2
zigzag_ribbon[graphene.neighbors(1)] = 1
kwant.plotter.bands(zigzag_ribbon.finalized(), fig_size=(12, 8))
The following error message appeared..
File "C:\Users\Shyam Lochan Bora\Desktop\new 1.py", line 5, in <module>
from wraparound import wraparound
ModuleNotFoundError: No module named 'wraparound'
Help me in this regard