Skip to content
Snippets Groups Projects
Commit a3bce5d8 authored by Christoph Groth's avatar Christoph Groth
Browse files

bugfix: make args and kwargs work for bandstructure calculations

parent 2c2715eb
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,10 @@ class Bands(object): ...@@ -20,6 +20,10 @@ class Bands(object):
sys : `kwant.system.InfiniteSystem` sys : `kwant.system.InfiniteSystem`
The low level infinite system for which the energies are to be The low level infinite system for which the energies are to be
calculated. calculated.
args : tuple, defaults to empty
Positional arguments to pass to the ``hamiltonian`` method.
kwargs : dictionary, defaults to empty
Keyword arguments to pass to the ``hamiltonian`` method.
Notes Notes
----- -----
...@@ -37,11 +41,11 @@ class Bands(object): ...@@ -37,11 +41,11 @@ class Bands(object):
>>> pyplot.show() >>> pyplot.show()
""" """
def __init__(self, sys): def __init__(self, sys, args=(), kwargs={}):
self.ham = sys.slice_hamiltonian() self.ham = sys.slice_hamiltonian(args=args, kwargs=kwargs)
if not np.allclose(self.ham, self.ham.T.conj()): if not np.allclose(self.ham, self.ham.T.conj()):
raise ValueError('The slice Hamiltonian is not Hermitian.') raise ValueError('The slice Hamiltonian is not Hermitian.')
hop = sys.inter_slice_hopping() hop = sys.inter_slice_hopping(args=args, kwargs=kwargs)
self.hop = np.empty(self.ham.shape, dtype=complex) self.hop = np.empty(self.ham.shape, dtype=complex)
self.hop[:, : hop.shape[1]] = hop self.hop[:, : hop.shape[1]] = hop
self.hop[:, hop.shape[1]:] = 0 self.hop[:, hop.shape[1]:] = 0
......
...@@ -850,13 +850,18 @@ def map(sys, value, colorbar=True, cmap=None, ...@@ -850,13 +850,18 @@ def map(sys, value, colorbar=True, cmap=None,
return output_fig(fig, file=file, show=show) return output_fig(fig, file=file, show=show)
def bands(sys, momenta=65, file=None, show=True, dpi=None, fig_size=None): def bands(sys, momenta=65, args=(), kwargs={},
file=None, show=True, dpi=None, fig_size=None):
"""Plot band structure of a translationally invariant 1D system. """Plot band structure of a translationally invariant 1D system.
Parameters Parameters
---------- ----------
sys : kwant.system.InfiniteSystem sys : kwant.system.InfiniteSystem
A system bands of which are to be plotted. A system bands of which are to be plotted.
args : tuple, defaults to empty
Positional arguments to pass to the ``hamiltonian`` method.
kwargs : dictionary, defaults to empty
Keyword arguments to pass to the ``hamiltonian`` method.
momenta : int or 1D array-like momenta : int or 1D array-like
Either a number of sampling points on the interval [-pi, pi], or an Either a number of sampling points on the interval [-pi, pi], or an
array of points at which the band structure has to be evaluated. array of points at which the band structure has to be evaluated.
...@@ -885,7 +890,7 @@ def bands(sys, momenta=65, file=None, show=True, dpi=None, fig_size=None): ...@@ -885,7 +890,7 @@ def bands(sys, momenta=65, file=None, show=True, dpi=None, fig_size=None):
if momenta.ndim != 1: if momenta.ndim != 1:
momenta = np.linspace(-np.pi, np.pi, momenta) momenta = np.linspace(-np.pi, np.pi, momenta)
bands = physics.Bands(sys) bands = physics.Bands(sys, args=args, kwargs=kwargs)
energies = [bands(k) for k in momenta] energies = [bands(k) for k in momenta]
fig = Figure() fig = Figure()
......
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