Skip to content
Snippets Groups Projects
Commit 564d6b73 authored by Anton Akhmerov's avatar Anton Akhmerov Committed by Christoph Groth
Browse files

make use of plotter.bands in tutorial

parent 97bb012c
No related branches found
No related tags found
No related merge requests found
--- original
+++ modified
@@ -12,6 +12,7 @@
@@ -10,6 +10,7 @@
# For plotting
# For plotting.
from matplotlib import pyplot
+import _defs
def make_lead(a=1, t=1.0, W=10):
@@ -38,11 +39,19 @@
bands = kwant.physics.Bands(lead)
energies = [bands(k) for k in momenta]
# Start with an empty lead with a single square lattice
@@ -33,10 +34,19 @@
- pyplot.figure()
+ fig = pyplot.figure()
pyplot.plot(momenta, energies)
- pyplot.xlabel("momentum [in units of (lattice constant)^-1]")
- pyplot.ylabel("energy [in units of t]")
def main():
lead = make_lead().finalized()
- kwant.plotter.bands(lead, show=False)
- pyplot.xlabel("momentum in units of inverse lattice constant")
- pyplot.ylabel("energy in units of t")
- pyplot.show()
+ pyplot.xlabel("momentum [in units of (lattice constant)^-1]",
+ fig = kwant.plotter.bands(lead, show=False)
+ pyplot.xlabel("momentum in units of inverse lattice constant",
+ fontsize=_defs.mpl_label_size)
+ pyplot.ylabel("energy [in units of t]", fontsize=_defs.mpl_label_size)
+ pyplot.ylabel("energy in units of t", fontsize=_defs.mpl_label_size)
+ pyplot.setp(fig.get_axes()[0].get_xticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ pyplot.setp(fig.get_axes()[0].get_yticklabels(),
......@@ -29,6 +28,7 @@
+ fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
+ fig.savefig("band_structure_result.pdf")
+ fig.savefig("band_structure_result.png", dpi=_defs.dpi)
+
def main():
# Call the main function if the script gets executed (as opposed to imported).
......@@ -8,13 +8,13 @@
tau_x = tinyarray.array([[0, 1], [1, 0]])
tau_z = tinyarray.array([[1, 0], [0, -1]])
@@ -46,12 +47,19 @@
bands = kwant.physics.Bands(lead)
energies = [bands(k) for k in momenta]
@@ -46,11 +47,19 @@
# Make system and finalize it right away.
lead = make_lead().finalized()
- pyplot.figure()
+ fig = pyplot.figure()
pyplot.plot(momenta, energies)
- kwant.plotter.bands(lead, momenta=np.linspace(-1.5, 1.5, 101), show=False)
+ fig = kwant.plotter.bands(lead, momenta=np.linspace(-1.5, 1.5, 101),
+ show=False)
pyplot.xlabel("momentum [in untis of (lattice constant)^-1]")
pyplot.ylabel("energy [in units of t]")
pyplot.ylim([-0.8, 0.8])
......@@ -29,4 +29,4 @@
+ fig.savefig("superconductor_band_structure_result.png", dpi=_defs.dpi)
def main():
# Call the main function if the script gets executed (as opposed to imported).
......@@ -11,6 +11,7 @@ Plotting routine
plot
map
bands
Data-generating functions
-------------------------
......
......@@ -8,12 +8,9 @@
import kwant
from math import pi
# For plotting
# 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
......@@ -37,24 +34,12 @@ def make_lead(a=1, t=1.0, W=10):
#HIDDEN_BEGIN_pejz
def plot_bandstructure(lead, momenta):
bands = kwant.physics.Bands(lead)
energies = [bands(k) for k in momenta]
pyplot.figure()
pyplot.plot(momenta, energies)
pyplot.xlabel("momentum [in units of (lattice constant)^-1]")
pyplot.ylabel("energy [in units of t]")
pyplot.show()
def main():
lead = make_lead().finalized()
# list of momenta at which the bands should be computed
momenta = [-pi + 0.02 * pi * i for i in xrange(101)]
plot_bandstructure(lead, momenta)
kwant.plotter.bands(lead, show=False)
pyplot.xlabel("momentum in units of inverse lattice constant")
pyplot.ylabel("energy in units of t")
pyplot.show()
#HIDDEN_END_pejz
......
......@@ -44,28 +44,17 @@ def make_lead(a=1, t=1.0, mu=0.7, Delta=0.1, W=10):
#HIDDEN_END_nbvn
def plot_bandstructure(lead, momenta):
bands = kwant.physics.Bands(lead)
energies = [bands(k) for k in momenta]
def main():
# Make system and finalize it right away.
lead = make_lead().finalized()
pyplot.figure()
pyplot.plot(momenta, energies)
kwant.plotter.bands(lead, momenta=np.linspace(-1.5, 1.5, 101), show=False)
pyplot.xlabel("momentum [in untis of (lattice constant)^-1]")
pyplot.ylabel("energy [in units of t]")
pyplot.ylim([-0.8, 0.8])
pyplot.show()
def main():
# Make system and finalize it right away.
lead = make_lead().finalized()
# list of momenta at which the bands should be computed
momenta = np.linspace(-1.5, 1.5, 201)
plot_bandstructure(lead, momenta)
# Call the main function if the script gets executed (as opposed to imported).
# See <http://docs.python.org/library/__main__.html>.
if __name__ == '__main__':
......
......@@ -31,11 +31,11 @@ contained implicitly finalized versions of the attached leads. But now we are
working with a single lead and there is no scattering region. So we have to
finalized the ``Builder`` of our sole lead explicitly.
That finalized lead is then passed to `kwant.physics.Bands`. This
creates an object that behaves just like a function: when called with a
momentum ``k`` as parameter it returns the eigenenergies of the translational
invariant system for that momentum. Computing these eigenenergies for a range
of momenta then yields the bandstructure:
That finalized lead is then passed to `~kwant.plotter.bands`. This function
calculates energies of various bands at a range of momenta and plots the
calculated energies. It is really a convenience function, and if one needs to
do something more profound with the dispersion relation these energies may be
calculated directly. For now we just plot the bandstructure:
.. literalinclude:: band_structure.py
:start-after: #HIDDEN_BEGIN_pejz
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment