From 3a8807c022e20bbda66fa9b7d942bd2aeb3cd5f6 Mon Sep 17 00:00:00 2001 From: Joseph Weston Date: Tue, 8 Jan 2019 09:59:10 +0100 Subject: [PATCH] format docstrings --- kwant/physics/dispersion.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/kwant/physics/dispersion.py b/kwant/physics/dispersion.py index a56ba332..4109be75 100644 --- a/kwant/physics/dispersion.py +++ b/kwant/physics/dispersion.py @@ -74,16 +74,14 @@ class Bands: ---------- k : float momentum - derivative_order : {0, 1, 2}, optional Maximal derivative order to calculate. Default is zero. - return_eigenvectors : bool, optional if set to True return the eigenvectors as last tuple element. By default, no eigenvectors are returned. Returns - ---------- + ------- energies : numpy float array, size nbands energies :math:E velocities : numpy float array, size nbands @@ -93,18 +91,18 @@ class Bands: eigenvectors : numpy float array, size nbands x nbands eigenvectors - The number of retured elements varies. If derivative_order > 0 - we return all derivatives up to the order derivative_order, - and total the number of returned elements is derivative_order + 1 - If 'return_eigenvectors=True', in addition the eigenvectors are + The number of returned elements varies. If derivative_order > 0 + we return all derivatives up to the order derivative_order, + and total the number of returned elements is derivative_order + 1 + If return_eigenvectors is True, in addition the eigenvectors are returned as the last element. In that case, the total number of - returned elements is derivative_order + 2. + returned elements is derivative_order + 2. Notes ----- - * All the output arrays are sorted from the lowest energy band - to the highest. - * The curvature E'' can be only calculated for non-degenerate bands. + * All the output arrays are sorted from the lowest energy band + to the highest. + * The curvature E'' can be only calculated for non-degenerate bands. """ # Equation to solve is # (V^\dagger e^{ik} + H + V e^{-ik}) \psi = E \psi @@ -137,6 +135,7 @@ class Bands: ph1p = eigenvectors.conjugate().transpose() @ h1 @ eigenvectors velocities = np.diag(ph1p).real output += (velocities,) + if derivative_order >= 2: # compute curvatures # ediff_{i,j} = 1 / (E_i - E_j) if i != j, else 0 ediff = energies.reshape((-1, 1)) - energies.reshape((1, -1)) @@ -149,6 +148,7 @@ class Bands: # np.diag(eigenvectors.conjugate().transpose() @ h2 @ eigenvectors # + 2 * ediff @ np.abs(ph1p)**2).real output += (curvatures,) + if derivative_order > 2: raise NotImplementedError('Derivatives of the energy dispersion ' + 'only implemented up to second order.') -- 2.18.1