Source code for py4mulas.berry_curvature

from typing import Union

import numpy as np

from .energy_kernels import BerryKernel
from .models import Kmodel
from .operators import KspaceOpera
from .responses import Kubo

__all__ = ["BerryCurvature"]


[docs] class BerryCurvature(Kubo): r"""Computes the k-space Berry curvature (oriented along a direction perpendicular to `alpha` and `beta`) for a single band. Attributes: model: An instance of :class:`~py4mulas.models.Kmodel` alpha: An instance of :class:`~py4mulas.operators.KspaceOpera`, a longitudinal in-plane direction beta: An instance of :class:`~py4mulas.operators.KspaceOpera`, a transversal in-plane direction Note: For spin or orbital berry curvature `alpha` or `beta` should be either a spin or orbital operator. """ def __init__( self, model: Kmodel, alpha: Union[str, KspaceOpera] = "x", beta: Union[str, KspaceOpera] = "y", ): super().__init__( model, alpha=alpha, beta=beta, kernel=BerryKernel(), kspace_options=None ) self.model = model self.k_args = [self.k_vectors[:, d] for d in range(self.dim)]
[docs] def __call__(self, band: int = 0) -> np.ndarray: _check_band(band, norbs=self.norbs) result = super().__call__(k_resolved=True) return result[:, band]
def _check_band(band=0, norbs=2): assert isinstance(band, int) assert 0 <= band < norbs