Commit 3a8807c0 authored by Joseph Weston's avatar Joseph Weston

format docstrings

parent 794dd08c
...@@ -74,16 +74,14 @@ class Bands: ...@@ -74,16 +74,14 @@ class Bands:
---------- ----------
k : float k : float
momentum momentum
derivative_order : {0, 1, 2}, optional derivative_order : {0, 1, 2}, optional
Maximal derivative order to calculate. Default is zero. Maximal derivative order to calculate. Default is zero.
return_eigenvectors : bool, optional return_eigenvectors : bool, optional
if set to `True` return the eigenvectors as last tuple element. if set to `True` return the eigenvectors as last tuple element.
By default, no eigenvectors are returned. By default, no eigenvectors are returned.
Returns Returns
---------- -------
energies : numpy float array, size ``nbands`` energies : numpy float array, size ``nbands``
energies :math:`E` energies :math:`E`
velocities : numpy float array, size ``nbands`` velocities : numpy float array, size ``nbands``
...@@ -93,18 +91,18 @@ class Bands: ...@@ -93,18 +91,18 @@ class Bands:
eigenvectors : numpy float array, size ``nbands x nbands`` eigenvectors : numpy float array, size ``nbands x nbands``
eigenvectors eigenvectors
The number of retured elements varies. If `derivative_order > 0` The number of returned elements varies. If ``derivative_order > 0``
we return all derivatives up to the order `derivative_order`, we return all derivatives up to the order ``derivative_order``,
and total the number of returned elements is `derivative_order + 1` and total the number of returned elements is ``derivative_order + 1``
If 'return_eigenvectors=True', in addition the eigenvectors are If ``return_eigenvectors`` is True, in addition the eigenvectors are
returned as the last element. In that case, the total number of 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 Notes
----- -----
* All the output arrays are sorted from the lowest energy band * All the output arrays are sorted from the lowest energy band
to the highest. to the highest.
* The curvature `E''` can be only calculated for non-degenerate bands. * The curvature `E''` can be only calculated for non-degenerate bands.
""" """
# Equation to solve is # Equation to solve is
# (V^\dagger e^{ik} + H + V e^{-ik}) \psi = E \psi # (V^\dagger e^{ik} + H + V e^{-ik}) \psi = E \psi
...@@ -137,6 +135,7 @@ class Bands: ...@@ -137,6 +135,7 @@ class Bands:
ph1p = eigenvectors.conjugate().transpose() @ h1 @ eigenvectors ph1p = eigenvectors.conjugate().transpose() @ h1 @ eigenvectors
velocities = np.diag(ph1p).real velocities = np.diag(ph1p).real
output += (velocities,) output += (velocities,)
if derivative_order >= 2: # compute curvatures if derivative_order >= 2: # compute curvatures
# ediff_{i,j} = 1 / (E_i - E_j) if i != j, else 0 # ediff_{i,j} = 1 / (E_i - E_j) if i != j, else 0
ediff = energies.reshape((-1, 1)) - energies.reshape((1, -1)) ediff = energies.reshape((-1, 1)) - energies.reshape((1, -1))
...@@ -149,6 +148,7 @@ class Bands: ...@@ -149,6 +148,7 @@ class Bands:
# np.diag(eigenvectors.conjugate().transpose() @ h2 @ eigenvectors # np.diag(eigenvectors.conjugate().transpose() @ h2 @ eigenvectors
# + 2 * ediff @ np.abs(ph1p)**2).real # + 2 * ediff @ np.abs(ph1p)**2).real
output += (curvatures,) output += (curvatures,)
if derivative_order > 2: if derivative_order > 2:
raise NotImplementedError('Derivatives of the energy dispersion ' + raise NotImplementedError('Derivatives of the energy dispersion ' +
'only implemented up to second order.') 'only implemented up to second order.')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment