qolossal package
Abstract Hamiltonian
Abstract Hamiltonian class for large systems.
Copyright © 2019-2023 HQS Quantum Simulations GmbH. All Rights Reserved.
- class qolossal.abstractHamiltonian.Hamiltonian[source]
Bases:
ABC
Abstract base class for a general Hamiltonian.
This class does not implement any Hamiltonian. Nonetheless it provides all methods for calculating the properties of systems. This is possible since, within the linear method based on the Chebyshev expansion, only the dot product of the Hamiltonian on a state is needed to compute observables.
Empty constructor.
The attributes defined below are of general character, i.e. will have definite values in all actual implementations of the Hamiltonian, and are needed for the various calculations performed by the methods defined in this class.
disDict: dictionary defining disorder. Will be translated to a HQSchema. disLocPot: local disorder potential. scaling: chebyshev scaling object. chebyshev: chebyshev expansion object. dim: number of sites in the system. Can double in spinful OR BCS cases. realDim: real number of sites. velocity_operator: velocity operator in the x-, y- and z- directions. total_volume: total volume of the system. is_complex: flag for complex Hamiltonians
- __init__() None [source]
Empty constructor.
The attributes defined below are of general character, i.e. will have definite values in all actual implementations of the Hamiltonian, and are needed for the various calculations performed by the methods defined in this class.
disDict: dictionary defining disorder. Will be translated to a HQSchema. disLocPot: local disorder potential. scaling: chebyshev scaling object. chebyshev: chebyshev expansion object. dim: number of sites in the system. Can double in spinful OR BCS cases. realDim: real number of sites. velocity_operator: velocity operator in the x-, y- and z- directions. total_volume: total volume of the system. is_complex: flag for complex Hamiltonians
- property dtype: Type
Dtype convenience function.
- Returns:
complex or float depending on the flag is_complex
- Return type:
Type
- abstract dot(v: ndarray, out: ndarray) ndarray [source]
Empty dot product. Abstract method: it has to be overloaded.
- Parameters:
v (np.ndarray) – Vector to dot.
out (np.ndarray) – preallocated output array.
- Raises:
NotImplementedError – In any case, since this method HAS to be overwritten by children classes.
- _dot_scaling(v: ndarray, out: ndarray) ndarray [source]
Dot product including scaling.
This dot product is needed for evaluating moments of quantities that have not been yet implemented in the lattice solver.
- Parameters:
v (np.ndarray) – Vector to dot.
out (np.ndarray) – preallocated output array.
- Returns:
Dot product of H with v.
- Return type:
np.ndarray
- _set_scaling_and_cheby(lower_spectral_bound: float = -1, upper_spectral_bound: float = 1, delta: float = 0, force_complex: bool = False) None [source]
Set the scaling and corresponding chebyshev objects.
- Parameters:
lower_spectral_bound (float) – Lower bound of the spectral range. Defaults to -1.
upper_spectral_bound (float) – Upper bound of the spectral range. Defaults to 1.
delta (float) – Spectral buffer for Hamiltonian scaling.
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- _set_cheby(force_complex: bool = False) None [source]
Set the chebyshev object.
- Parameters:
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- generateSelector(what: str = 'all') ndarray [source]
Trivial selector generator given a certain input configuration.
This method is just an empty placeholder, it will have to be specified for each Hamiltonian implementation.
- Parameters:
what (str) – input configuration. Not used in this method.
- Returns:
array of 1’s.
- Return type:
np.ndarray
Warning
RuntimeWarning: warn all the time, since this function is always selecting everything.
- getBoundsLanczos(Order: int, tolerance: float = 1e-11) ndarray [source]
Get spectrum boundaries for the current Hamiltonian with the Lanczos method.
- Parameters:
Order (int) – Order of the Lanczos expansion
tolerance (float) – Tolerance for the expansion. Defaults to 1e-11.
- Returns:
Boundaries of the spectrum.
- Return type:
np.ndarray
- scaleH(delta: float = 0.1, LanczOrder: int | None = None, energyBounds: list | ndarray | None = None) None [source]
Rescale Hamiltonian to have spectrum between -1 and 1.
- Parameters:
delta (float) – Controls the extra compression of the band. This will be rescaled to be (-1 + delta/2, 1 - delta/2). Defaults to 0.1.
LanczOrder (Optional[int]) – Order of the Lanczos expansion used to determine the bandwidth. Cannot be set together with energyBounds.
energyBounds (Optional[Union[list, np.ndarray]]) – lower and upper energy boundaries to determine scaling. Cannot be set together with LanczOrder.
- Raises:
ValueError – If delta is not in (0, 2).
ValueError – If both LanczOrder and energyBounds are set.
- scale2real(x: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr [source]
Apply scaling to transform scaled frequencies to real ones.
- Parameters:
x (qt.fl_cmplx_or_ndarr) – array of scaled energies within (-1, 1).
- Returns:
Real energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- scale2transformed(z: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr [source]
Apply scaling to transform real frequencies to scaled ones.
- Parameters:
z (qt.fl_cmplx_or_ndarr) – real energies array.
- Returns:
Scaled energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- parseDisDict(parse_dict: dict) None [source]
Parse disorder input dictionary.
The disorder dictionary specifies the properties of the disorder:
type: kind of disorder, e.g. onsite (only type implemented for now).
distribution: random distribution of disorder potential.
sigma: standard deviation of the disorder distribution.
avg: mean of distribution.
Note
This will become obsolete with the introduction of a Schema for the disDict.
- Parameters:
parse_dict (dict) – Dictionary containing information about the disorder.
- Raises:
ValueError – if the dictionary cannot be parsed
- getTrResolvent(NSamples: int, Order: int, rescale: bool = True, use_KPM: bool = True, verbose: int = 2, selector: ndarray | None = None) Callable [source]
Returns a function evaluating the trace of the resolvent.
This method computes the Chebyshev moments for a given order and given number of stochastic samples to evaluate the trace. Can be used to evaluate the trace of the resolvent,
\[\mathrm{Tr} \left[ \frac{1}{z - \hat{H}} \right]\]for a given ‘frequency’ \(z\) without the need to recompute the Chebyshev expansion. This is useful if it is not a priori clear on how many frequencies the trace of the resolvent needs to be evaluated.
The trace of the resolvent will be evaluated at the given frequencies. For real frequencies the retarded resolvent is chosen.
NOTE: The trace is estimated as the average over all (normalized) stochastic samples. Hence, multiply the result by the linear size of the Hamiltonian to get the “true” estimate for the trace.
NOTE: If the number of samples is larger that the size of the selected subspace, the trace is computed exactly (apart from the normalization, see above).
- Parameters:
NSamples (int) – Number of stochastic samples to approximate the trace.
Order (int) – Order of the Chebyshev expanbsion to approximate the resolvent.
rescale (bool) – Whether generated function transforms input into interval (-1, 1). Defaults to True.
use_KPM (bool) – Flag controlling the use of KPM.
verbose (int) – Controls verbosity of output and warnings. Defaults to 2.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Returns:
Function evaluating the trace of the resolvent for a given frequency.
- Return type:
Callable
- _get_DOS_moments(NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray [source]
Calculates the moments of the Chebyshev expansion of the density of states.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the density of states
- Return type:
np.ndarray
- getDOS(NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray] [source]
Calculates DoS through stochastic averaging of Chebyshev expansion.
This density of states integrates to 1, i.e. it is defined as:
\[\rho(E) = \frac{1}{N} \sum\limits_i \delta(E - E_i) = \frac{1}{N} {\rm Tr} \left[ \delta(E - \hat{H}) \right]\]with \(E_i\) the eigenvalues of the Hamiltonian and N the number of orbitals.
More details on the calculation are readily available in the literature. For example: https://doi.org/10.1016/j.physrep.2020.12.001
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of frequencies to evaluate the DoS at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
DoS and corresponding frequencies.
- Return type:
tuple
- getGF(selector: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | bytes | _NestedSequence[bool | int | float | complex | str | bytes], Order: int, NOmegas: int, NSamplesDis: int = 1, verbose: int = 2, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray] [source]
Calculate the retarded Green’s Function in the real space basis.
This calculation is performed the same way as for the DOS, the only difference being the states used for evaluating the moments: in this case we directly use the real space basis.
- Parameters:
selector (Union[str, ArrayLike]) – specifies what to compute (‘diag’, ‘full’, or array of row-column pairs)
Order (int) – Order of the Chebyshev expansion.
NOmegas (int) – Number of frequencies to evaluate.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
GF and corresponding frequencies.
- Return type:
tuple[np.ndarray, np.ndarray]
- _get_conductivity_moments(tensor_element: str, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray [source]
Calculates the moments of the Chebyshev expansion of the conductivity.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Moments associated with the conductivity
- Return type:
np.ndarray
- getConductivity(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray] [source]
Calculates the conductivity of the system from the Kubo-Greenwood formula.
This routine follows the method presented in https://doi.org/10.1016/j.physrep.2020.12.001
In short: a Chebyshev expansion of the zero temperature Kubo formula is performed. This translates into the expansion of the function \(\delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H})\) \(\hat{V}_{\beta}\), where \(E\) is the energy, \(\hat{H}\) is the Hamiltonian and \(\hat{V}\) is the velocity operator in the direction \(\alpha\,{\rm and }\,\beta\). The conductivity reads
\[\sigma(E) = \frac{\pi \hbar e^2}{\Omega} {\rm Tr}\left[ \delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H}) \right]\]The temperature dependent result is obtained by simply convolving the zero temperature result by a ‘Fermi window’, i.e. minus the derivative of the Fermi function with respect to the energy.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getConductivityMu(tensor_element: str, NSamples: int, Order: int, mu: float | ndarray, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex | ndarray [source]
Calculates the conductivity of the system defined by H at a single chemical potential.
Given a Hamiltonian, the corresponding conductivity can be calculated as
\[\sigma(\mu) = \frac{\pi \Omega}{\Delta E^2} \braket{\phi^L|\phi^R}\]where \(\Omega\) is the volume of the system, \(\Delta E\) is the scaling applied to the Hamiltonian to ensure the spectrum lies within (-1, 1) and the vectors \(\phi\) are
\[ \begin{align}\begin{aligned}\ket{\phi^L} = \sum_n Im[G^+_n(\mu)] T_n(\tilde{H}) V \ket{r}\\\ket{\phi^R} = \sum_n Im[G^+_n(\mu)] V T_n(\tilde{H}) \ket{r}\end{aligned}\end{align} \]where \(\ket{r}\) is the random vector, \(V\) is the velocity operator, \(G^+_n\) is the n-th GF coefficient and \(T_n(\tilde{H})\) is the m-th Chebyshev polynomial.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
mu (Union[float, np.ndarray]) – Energy(ies) (as in chemical potential) at which to evaluate the conductivity.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the DOS.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity at the specified chemical potential(s).
- Return type:
qt.fl_cmplx_or_ndarr
- getConductivity_KB(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray] [source]
Calculates the conductivity of the system evaluating the Kubo-Bastin formula.
This routine follows the method presented in https://doi.org/10.1103/PhysRevLett.114.116602
In short: a Chebyshev expansion of the Kubo-Bastin formula is performed. This translates into the expansion of the function:
\[v_\alpha \delta(\varepsilon - \hat{H}) \hat{v}_\beta \frac{dG^+(\varepsilon)} {d\varepsilon} - \hat{v}_\alpha \frac{dG^-(\varepsilon)}{d\varepsilon} \hat{v}_\beta \delta(\varepsilon - \hat{H})\]where \(\varepsilon\) is the energy, \(\hat{H}\) is the Hamiltonian, \(\hat{v}\) is the velocity operator and \(\alpha, \beta\) indicate the direction. The modus operandi is exactly the same as for the other conductivity calculations based on the Chebyshev expansion.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- _get_expectation_value_moments(A: Callable, expectation_value_dtype: type, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray [source]
Calculates the moments of the Chebyshev expansion of an operator’s expectation value.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
A (Callable) – Linear operator.
expectation_value_dtype (type) – dtype of the linear operator.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the expectation value of operator A.
- Return type:
np.ndarray
- getExpectationValue(A: Callable, dtype: type, T: float, mu: float, NSamples: int, Order: int, NPadeFreq: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex [source]
Calculates the expectation value of an operator through Chebyshev expansion.
This is done by performing the Chebyshev expansion of
\[\langle \hat{A} \rangle = {\rm Tr} \left[ \hat{A} f(\hat{H}) \right]\]where \(\hat{A}\) is the operator, \(\hat{H}\) is the hamiltonian and f is the fermi function. This expression is expanded in terms of Chebyshev polynomials. The integral over the energies is performed via the resummation of the Fermi-Pade’ expansion of the Fermi function.
- Parameters:
A (Callable) – Linear operator.
dtype (type) – dtype of the linear operator.
T (float) – temperature in Kelvins. Must be greater than 0.
mu (float) – chemical potential.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NPadeFreq (int) – Number of Pade frequencies to evaluate the approximation to the Fermi function.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if temperature is too small.
- Returns:
expectation value of operator A.
- Return type:
Union[float, complex]
- getConductivityOptical(tensor_element: str, T: float, mu: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray] [source]
Calculates the complex optical conductivity of the system.
In short: a Chebyshev expansion of the Kubo formula is performed. The procedure is similar to the one presented in https://journals.aps.org/prb/abstract/10.1103/PhysRevB.94.235405
Details on the routine can be found in the internal notes. In particular, eq. 32 of the notes is implemented.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
mu (float) – Chemical potential.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- _abc_impl = <_abc._abc_data object>
Abstract Hamiltonian based on Lattice Builder
Abstract Hamiltonian class interfacing directly to the Lattice Builder.
Copyright © 2019-2023 HQS Quantum Simulations GmbH. All Rights Reserved.
- class qolossal.abstractHamiltonian_LB.HamiltonianLB(input_dict: dict, disDict: dict | None = None)[source]
Bases:
Hamiltonian
Abstract Hamiltonian class that takes care of the interface with the LatticeBuilder.
Initialization of the class.
This init takes care of validation and building of the system coresponding to the input dictionary and will extract the general information needed by most Hamiltonians. The Hamiltonian itself will have to be extracted by each the specific implementation. Note that this class is still abstract as no dot product is defined.
- Parameters:
input_dict (dict) – Input dictionary for the Lattice Builder to construct the Hamiltonian
disDict (Optional[dict]) – dictionary specifying the disorder.
- Raises:
ValueError – if the input_dict or dis dictionaries cannot be validated.
- __init__(input_dict: dict, disDict: dict | None = None) None [source]
Initialization of the class.
This init takes care of validation and building of the system coresponding to the input dictionary and will extract the general information needed by most Hamiltonians. The Hamiltonian itself will have to be extracted by each the specific implementation. Note that this class is still abstract as no dot product is defined.
- Parameters:
input_dict (dict) – Input dictionary for the Lattice Builder to construct the Hamiltonian
disDict (Optional[dict]) – dictionary specifying the disorder.
- Raises:
ValueError – if the input_dict or dis dictionaries cannot be validated.
- is_complex: bool
- realDim: int
- dim: int
- velocity_operator: tuple[Callable, Callable, Callable] | None
- total_volume: float
- abstract set_Hamiltonian(kpt: ndarray | None = None, mu: float = 0, Bz: float = 0) None [source]
Hamiltonian setter method.
- Parameters:
kpt (Optional[np.ndarray]) – Bloch vector determining phase-shift at periodic boundaries.
mu (float) – additional chemical potential.
Bz (float) – additional Bz field.
- Raises:
NotImplementedError – If the method is not overloaded in the children classes.
- getH() csr_array [source]
Getter function for Hamiltonian in sparse format.
- Returns:
Hamiltonian matrix in sparse row format.
- Return type:
csr_array
- Raises:
RuntimeError – if the Hamiltonian is not available.
- todense() ndarray [source]
Getter function for Hamiltonian in dense format.
- Returns:
Hamiltonian matrix in dense format.
- Return type:
np.ndarray
- generateSelector(what: str = 'all') ndarray [source]
Generate selector given a certain input configuration.
- Parameters:
what (str) – input configuration.
- Returns:
array composed of 1’s and 0’s selecting the correct sublattice.
- Return type:
np.ndarray
- Raises:
ValueError – if the argument ‘what’ is invalid.
Warning
RuntimeWarning: if the selection is inconsistent with the system and a default choice is made.
- getSpectral(num_kpoints: float, Order: int, NOmegas: int, NSamplesDis: int = 1, verbose: int = 2, eWindow: list | ndarray | None = None) tuple [source]
Calculate the spectral function.
This calculation is performed the same way as for the GF, the only difference being the states used for evaluating the moments: in this case we directly use the Bloch functions. The band structure is then simply \(-\operatorname{Im}[G_{kk}]/\pi\) for k’s along the correct k path.
- Parameters:
num_kpoints (float) – number of kpoints for the spectral function calculation.
Order (int) – Order of the Chebyshev expansion.
NOmegas (int) – Number of frequencies to evaluate.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
spectral function, frequencies and corresponding k-path information.
- Return type:
tuple
- getMu(T: float, dos: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1, verbose: int = 2) float [source]
Calculate the chemical potential.
We calculate the chemical potential as the \(\mu\) which satisfies
\[N = \int\limits dE f(E-\mu) \rho(E)\]where \(N\) is the number of particles in the system, f is the fermi function and \(\rho(E)\) is the density of states.
In the case of BCS systems, the DOS depends on the chemical potential. This is therefore calculated for every chemical potential and the corresponding number of particles is obtained. A bisection is used starting from the boundaries of the Hamiltonian and honing in on the chemical potential resulting in a number of particles closest to the desired one. Starting from the two values giving slightly more and slightly less particles than needed, a linear extrapolation is finally performed to approximate the energy that results in the occupation closest to the desired one.
TODO: it is probably better to split this calculation in the “one-shot” version and the self-consistent one, suitable for BCS systems.
- Parameters:
T (float) – Temperature.
dos (Optional[np.ndarray]) – precoumputed DoS. Will be the 1st one to be used in the BCS case.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
verbose (int) – controls the verbosity of the method.
- Raises:
ValueError – if the input is not consistent.
- Returns:
Chemical potential.
- Return type:
float
- getCarrierDensity(dos: ndarray, w: ndarray, mu: float, T: float) float [source]
Calculate the carrier density.
The calculation is performed by integrating the DoS time the occupation for frequencies larger than the chemical potential and normalizing this by the system’s volume. The formula reads:
\[n = \frac{1}{\Omega} \int\limits_{-\infty}^{\mu} f(E-\mu) \rho(E)\]where \(\Omega\) is the total volume, \(\mu\) is the chemical potential, f is the fermi function and \(\rho(E)\) is the density of states.
- Parameters:
dos (np.ndarray) – Density of states.
w (np.ndarray) – Energies for which the DOS is defined.
mu (float) – Chemical potential.
T (float) – Temperature.
- Raises:
ValueError – If dos and w are not compatible.
- Returns:
Carrier density in \(Å^{-D}\) with D the dimensionality of the system.
- Return type:
float
- getChargeSusceptibility(T: float, mu: float, dos: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1) float [source]
Calculate the linear DC electric charge susceptibility.
This is equal to
\[\chi_e = \frac{2 \pi}{\Omega} \frac{\partial N}{\partial \mu}\]where \(\Omega\) is the total volume, N is the number of particles and \(\mu\) the chemical potential.
The routine simply computes the numerical derivative of the number of particles with respect to the chemical potential as an average of energies close to it.
TODO: add possibility to select sublattices, if deemed useful
- Parameters:
T (float) – Temperature.
mu (float) – Chemical potential.
dos (Optional[np.ndarray]) – precoumputed DoS.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
- Raises:
ValueError – if the input is not consistent.
- Returns:
static charge susceptibility of the system.
- Return type:
float
- getMagneticSusceptibility(T: float, mu: float, dos_u: ndarray | None = None, dos_d: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1) float [source]
Calculate the linear static magnetic susceptibility.
This is equal to
\[\chi_m = \frac{2 \pi}{\Omega} \frac{\partial S_z}{\partial B_z}\]where \(\Omega\) is the total volume, \(S_z\) is the spin operator in the z direction and \(B_z\) the magnetic field.
The routine simply computes the numerical derivative of the spin expectation value with respect to the applied B field.
TODO: add possibility to select sublattices, if deemed useful
- Parameters:
T (float) – Temperature.
mu (float) – Chemical potential.
dos_u (Optional[np.ndarray]) – precoumputed DoS of spin up electrons.
dos_d (Optional[np.ndarray]) – precoumputed DoS of spin down electrons.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
- Raises:
ValueError – if the input is not consistent.
- Returns:
static magnetic susceptibility of the system.
- Return type:
float
- getLinearResponse(A: Callable, P: Callable, dtype: type, T: float, mu: float, NSamples: int, Order: int, NPadeFreq: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex [source]
Calculates the static linear response of an observable to a perturbation.
This is done by expanding
\[\chi^A_P = \frac{2 \pi}{\Omega} \frac{\partial \langle \hat{A} \rangle}{\partial \varepsilon}\]where \(\hat{A}\) is the observable, \(\hat{P}\) the perturbation and \(\varepsilon\) its strength, i.e. the perturbation enters the Hamiltonian as \(\hat{H}' = \varepsilon \hat{P}\) with \(\varepsilon << 1\).
- Parameters:
A (Callable) – Linear operator associated with the observable.
P (Callable) – Perturbation in linear operator form.
dtype (type) – dtype of the linear operators.
T (float) – temperature in Kelvins. Must be greater than 0.
mu (float) – chemical potential.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NPadeFreq (int) – Number of Pade frequencies to evaluate the approximation to the Fermi function.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if temperature is too small.
- Returns:
expectation value of operator A.
- Return type:
Union[float, complex]
- getOperator(operator: str) tuple[Callable, type] [source]
Provide basic operators.
- Operators available:
±number operator and its left version
±spin operator and its left version
±position and its left version
- Parameters:
operator (str) – operator to be returned.
- Raises:
NotImplementedError – if the requested operator has not been implemented.
- Returns:
- tuple contining the operator as a callable acting on an input
array and the dtype of the operator.
- Return type:
tuple[Callable, type]
- _abc_impl = <_abc._abc_data object>
- _dot_scaling(v: ndarray, out: ndarray) ndarray
Dot product including scaling.
This dot product is needed for evaluating moments of quantities that have not been yet implemented in the lattice solver.
- Parameters:
v (np.ndarray) – Vector to dot.
out (np.ndarray) – preallocated output array.
- Returns:
Dot product of H with v.
- Return type:
np.ndarray
- _get_DOS_moments(NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of the density of states.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the density of states
- Return type:
np.ndarray
- _get_conductivity_moments(tensor_element: str, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of the conductivity.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Moments associated with the conductivity
- Return type:
np.ndarray
- _get_expectation_value_moments(A: Callable, expectation_value_dtype: type, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of an operator’s expectation value.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
A (Callable) – Linear operator.
expectation_value_dtype (type) – dtype of the linear operator.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the expectation value of operator A.
- Return type:
np.ndarray
- _set_cheby(force_complex: bool = False) None
Set the chebyshev object.
- Parameters:
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- _set_scaling_and_cheby(lower_spectral_bound: float = -1, upper_spectral_bound: float = 1, delta: float = 0, force_complex: bool = False) None
Set the scaling and corresponding chebyshev objects.
- Parameters:
lower_spectral_bound (float) – Lower bound of the spectral range. Defaults to -1.
upper_spectral_bound (float) – Upper bound of the spectral range. Defaults to 1.
delta (float) – Spectral buffer for Hamiltonian scaling.
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- abstract dot(v: ndarray, out: ndarray) ndarray
Empty dot product. Abstract method: it has to be overloaded.
- Parameters:
v (np.ndarray) – Vector to dot.
out (np.ndarray) – preallocated output array.
- Raises:
NotImplementedError – In any case, since this method HAS to be overwritten by children classes.
- property dtype: Type
Dtype convenience function.
- Returns:
complex or float depending on the flag is_complex
- Return type:
Type
- getBoundsLanczos(Order: int, tolerance: float = 1e-11) ndarray
Get spectrum boundaries for the current Hamiltonian with the Lanczos method.
- Parameters:
Order (int) – Order of the Lanczos expansion
tolerance (float) – Tolerance for the expansion. Defaults to 1e-11.
- Returns:
Boundaries of the spectrum.
- Return type:
np.ndarray
- getConductivity(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculates the conductivity of the system from the Kubo-Greenwood formula.
This routine follows the method presented in https://doi.org/10.1016/j.physrep.2020.12.001
In short: a Chebyshev expansion of the zero temperature Kubo formula is performed. This translates into the expansion of the function \(\delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H})\) \(\hat{V}_{\beta}\), where \(E\) is the energy, \(\hat{H}\) is the Hamiltonian and \(\hat{V}\) is the velocity operator in the direction \(\alpha\,{\rm and }\,\beta\). The conductivity reads
\[\sigma(E) = \frac{\pi \hbar e^2}{\Omega} {\rm Tr}\left[ \delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H}) \right]\]The temperature dependent result is obtained by simply convolving the zero temperature result by a ‘Fermi window’, i.e. minus the derivative of the Fermi function with respect to the energy.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getConductivityMu(tensor_element: str, NSamples: int, Order: int, mu: float | ndarray, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex | ndarray
Calculates the conductivity of the system defined by H at a single chemical potential.
Given a Hamiltonian, the corresponding conductivity can be calculated as
\[\sigma(\mu) = \frac{\pi \Omega}{\Delta E^2} \braket{\phi^L|\phi^R}\]where \(\Omega\) is the volume of the system, \(\Delta E\) is the scaling applied to the Hamiltonian to ensure the spectrum lies within (-1, 1) and the vectors \(\phi\) are
\[ \begin{align}\begin{aligned}\ket{\phi^L} = \sum_n Im[G^+_n(\mu)] T_n(\tilde{H}) V \ket{r}\\\ket{\phi^R} = \sum_n Im[G^+_n(\mu)] V T_n(\tilde{H}) \ket{r}\end{aligned}\end{align} \]where \(\ket{r}\) is the random vector, \(V\) is the velocity operator, \(G^+_n\) is the n-th GF coefficient and \(T_n(\tilde{H})\) is the m-th Chebyshev polynomial.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
mu (Union[float, np.ndarray]) – Energy(ies) (as in chemical potential) at which to evaluate the conductivity.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the DOS.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity at the specified chemical potential(s).
- Return type:
qt.fl_cmplx_or_ndarr
- getConductivityOptical(tensor_element: str, T: float, mu: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray]
Calculates the complex optical conductivity of the system.
In short: a Chebyshev expansion of the Kubo formula is performed. The procedure is similar to the one presented in https://journals.aps.org/prb/abstract/10.1103/PhysRevB.94.235405
Details on the routine can be found in the internal notes. In particular, eq. 32 of the notes is implemented.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
mu (float) – Chemical potential.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getConductivity_KB(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray]
Calculates the conductivity of the system evaluating the Kubo-Bastin formula.
This routine follows the method presented in https://doi.org/10.1103/PhysRevLett.114.116602
In short: a Chebyshev expansion of the Kubo-Bastin formula is performed. This translates into the expansion of the function:
\[v_\alpha \delta(\varepsilon - \hat{H}) \hat{v}_\beta \frac{dG^+(\varepsilon)} {d\varepsilon} - \hat{v}_\alpha \frac{dG^-(\varepsilon)}{d\varepsilon} \hat{v}_\beta \delta(\varepsilon - \hat{H})\]where \(\varepsilon\) is the energy, \(\hat{H}\) is the Hamiltonian, \(\hat{v}\) is the velocity operator and \(\alpha, \beta\) indicate the direction. The modus operandi is exactly the same as for the other conductivity calculations based on the Chebyshev expansion.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getDOS(NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculates DoS through stochastic averaging of Chebyshev expansion.
This density of states integrates to 1, i.e. it is defined as:
\[\rho(E) = \frac{1}{N} \sum\limits_i \delta(E - E_i) = \frac{1}{N} {\rm Tr} \left[ \delta(E - \hat{H}) \right]\]with \(E_i\) the eigenvalues of the Hamiltonian and N the number of orbitals.
More details on the calculation are readily available in the literature. For example: https://doi.org/10.1016/j.physrep.2020.12.001
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of frequencies to evaluate the DoS at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
DoS and corresponding frequencies.
- Return type:
tuple
- getExpectationValue(A: Callable, dtype: type, T: float, mu: float, NSamples: int, Order: int, NPadeFreq: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex
Calculates the expectation value of an operator through Chebyshev expansion.
This is done by performing the Chebyshev expansion of
\[\langle \hat{A} \rangle = {\rm Tr} \left[ \hat{A} f(\hat{H}) \right]\]where \(\hat{A}\) is the operator, \(\hat{H}\) is the hamiltonian and f is the fermi function. This expression is expanded in terms of Chebyshev polynomials. The integral over the energies is performed via the resummation of the Fermi-Pade’ expansion of the Fermi function.
- Parameters:
A (Callable) – Linear operator.
dtype (type) – dtype of the linear operator.
T (float) – temperature in Kelvins. Must be greater than 0.
mu (float) – chemical potential.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NPadeFreq (int) – Number of Pade frequencies to evaluate the approximation to the Fermi function.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if temperature is too small.
- Returns:
expectation value of operator A.
- Return type:
Union[float, complex]
- getGF(selector: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | bytes | _NestedSequence[bool | int | float | complex | str | bytes], Order: int, NOmegas: int, NSamplesDis: int = 1, verbose: int = 2, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculate the retarded Green’s Function in the real space basis.
This calculation is performed the same way as for the DOS, the only difference being the states used for evaluating the moments: in this case we directly use the real space basis.
- Parameters:
selector (Union[str, ArrayLike]) – specifies what to compute (‘diag’, ‘full’, or array of row-column pairs)
Order (int) – Order of the Chebyshev expansion.
NOmegas (int) – Number of frequencies to evaluate.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
GF and corresponding frequencies.
- Return type:
tuple[np.ndarray, np.ndarray]
- getTrResolvent(NSamples: int, Order: int, rescale: bool = True, use_KPM: bool = True, verbose: int = 2, selector: ndarray | None = None) Callable
Returns a function evaluating the trace of the resolvent.
This method computes the Chebyshev moments for a given order and given number of stochastic samples to evaluate the trace. Can be used to evaluate the trace of the resolvent,
\[\mathrm{Tr} \left[ \frac{1}{z - \hat{H}} \right]\]for a given ‘frequency’ \(z\) without the need to recompute the Chebyshev expansion. This is useful if it is not a priori clear on how many frequencies the trace of the resolvent needs to be evaluated.
The trace of the resolvent will be evaluated at the given frequencies. For real frequencies the retarded resolvent is chosen.
NOTE: The trace is estimated as the average over all (normalized) stochastic samples. Hence, multiply the result by the linear size of the Hamiltonian to get the “true” estimate for the trace.
NOTE: If the number of samples is larger that the size of the selected subspace, the trace is computed exactly (apart from the normalization, see above).
- Parameters:
NSamples (int) – Number of stochastic samples to approximate the trace.
Order (int) – Order of the Chebyshev expanbsion to approximate the resolvent.
rescale (bool) – Whether generated function transforms input into interval (-1, 1). Defaults to True.
use_KPM (bool) – Flag controlling the use of KPM.
verbose (int) – Controls verbosity of output and warnings. Defaults to 2.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Returns:
Function evaluating the trace of the resolvent for a given frequency.
- Return type:
Callable
- parseDisDict(parse_dict: dict) None
Parse disorder input dictionary.
The disorder dictionary specifies the properties of the disorder:
type: kind of disorder, e.g. onsite (only type implemented for now).
distribution: random distribution of disorder potential.
sigma: standard deviation of the disorder distribution.
avg: mean of distribution.
Note
This will become obsolete with the introduction of a Schema for the disDict.
- Parameters:
parse_dict (dict) – Dictionary containing information about the disorder.
- Raises:
ValueError – if the dictionary cannot be parsed
- scale2real(x: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr
Apply scaling to transform scaled frequencies to real ones.
- Parameters:
x (qt.fl_cmplx_or_ndarr) – array of scaled energies within (-1, 1).
- Returns:
Real energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- scale2transformed(z: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr
Apply scaling to transform real frequencies to scaled ones.
- Parameters:
z (qt.fl_cmplx_or_ndarr) – real energies array.
- Returns:
Scaled energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- scaleH(delta: float = 0.1, LanczOrder: int | None = None, energyBounds: list | ndarray | None = None) None
Rescale Hamiltonian to have spectrum between -1 and 1.
- Parameters:
delta (float) – Controls the extra compression of the band. This will be rescaled to be (-1 + delta/2, 1 - delta/2). Defaults to 0.1.
LanczOrder (Optional[int]) – Order of the Lanczos expansion used to determine the bandwidth. Cannot be set together with energyBounds.
energyBounds (Optional[Union[list, np.ndarray]]) – lower and upper energy boundaries to determine scaling. Cannot be set together with LanczOrder.
- Raises:
ValueError – If delta is not in (0, 2).
ValueError – If both LanczOrder and energyBounds are set.
- scaleH_inv() None
Rescale Hamiltonian to have original spectrum.
- scrambleW() None
Function that scrambles the disorder vector.
- disDict: dict
- disLocPot: np.ndarray
- scaling: lsc.chebyshev_scaling
- chebyshev: lsc.chebyshev
Hamiltonians
Hamiltonian classes implementation for large systems.
Copyright © 2019-2023 HQS Quantum Simulations GmbH. All Rights Reserved.
- class qolossal.Hamiltonians.HamiltonianSparse(input_dict: dict, disDict: dict | None = None)[source]
Bases:
HamiltonianLB
Hamiltonian implementation in full sparse matrix representation.
This implementation is based on the representation of the Hamiltonian in sparse matrix form.
The parent class takes care of the interface with the Lattice Builder, saving the lattice builder instance in the object, for easy access and extracting all the important properties of the system to be used within the package’s methods.
Initialization of the HamiltonianSparse class.
- Parameters:
input_dict (dict) – Input dictionary for the Lattice Builder to construct the Hamiltonian
disDict (Optional[dict]) – dictionary specifying the disorder.
- __init__(input_dict: dict, disDict: dict | None = None) None [source]
Initialization of the HamiltonianSparse class.
- Parameters:
input_dict (dict) – Input dictionary for the Lattice Builder to construct the Hamiltonian
disDict (Optional[dict]) – dictionary specifying the disorder.
- set_Hamiltonian(kpt: ndarray | None = None, mu: float = 0, Bz: float = 0) None [source]
Hamiltonian setter method.
- Parameters:
kpt (Optional[np.ndarray]) – Bloch vector determining phase-shift at periodic boundaries.
mu (float) – additional chemical potential.
Bz (float) – additional Bz field.
- dot(v: ndarray, out: ndarray) ndarray [source]
Calculate the scalar product of H.
- Parameters:
v (np.ndarray) – vector to dot the Hamiltonian into.
out (np.ndarray) – preallocated output array.
- Returns:
Dot product of H with v
- Return type:
np.ndarray
- _abc_impl = <_abc._abc_data object>
- _dot_scaling(v: ndarray, out: ndarray) ndarray
Dot product including scaling.
This dot product is needed for evaluating moments of quantities that have not been yet implemented in the lattice solver.
- Parameters:
v (np.ndarray) – Vector to dot.
out (np.ndarray) – preallocated output array.
- Returns:
Dot product of H with v.
- Return type:
np.ndarray
- _get_DOS_moments(NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of the density of states.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the density of states
- Return type:
np.ndarray
- _get_conductivity_moments(tensor_element: str, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of the conductivity.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Moments associated with the conductivity
- Return type:
np.ndarray
- _get_expectation_value_moments(A: Callable, expectation_value_dtype: type, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of an operator’s expectation value.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
A (Callable) – Linear operator.
expectation_value_dtype (type) – dtype of the linear operator.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the expectation value of operator A.
- Return type:
np.ndarray
- _set_cheby(force_complex: bool = False) None
Set the chebyshev object.
- Parameters:
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- _set_scaling_and_cheby(lower_spectral_bound: float = -1, upper_spectral_bound: float = 1, delta: float = 0, force_complex: bool = False) None
Set the scaling and corresponding chebyshev objects.
- Parameters:
lower_spectral_bound (float) – Lower bound of the spectral range. Defaults to -1.
upper_spectral_bound (float) – Upper bound of the spectral range. Defaults to 1.
delta (float) – Spectral buffer for Hamiltonian scaling.
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- property dtype: Type
Dtype convenience function.
- Returns:
complex or float depending on the flag is_complex
- Return type:
Type
- generateSelector(what: str = 'all') ndarray
Generate selector given a certain input configuration.
- Parameters:
what (str) – input configuration.
- Returns:
array composed of 1’s and 0’s selecting the correct sublattice.
- Return type:
np.ndarray
- Raises:
ValueError – if the argument ‘what’ is invalid.
Warning
RuntimeWarning: if the selection is inconsistent with the system and a default choice is made.
- getBoundsLanczos(Order: int, tolerance: float = 1e-11) ndarray
Get spectrum boundaries for the current Hamiltonian with the Lanczos method.
- Parameters:
Order (int) – Order of the Lanczos expansion
tolerance (float) – Tolerance for the expansion. Defaults to 1e-11.
- Returns:
Boundaries of the spectrum.
- Return type:
np.ndarray
- getCarrierDensity(dos: ndarray, w: ndarray, mu: float, T: float) float
Calculate the carrier density.
The calculation is performed by integrating the DoS time the occupation for frequencies larger than the chemical potential and normalizing this by the system’s volume. The formula reads:
\[n = \frac{1}{\Omega} \int\limits_{-\infty}^{\mu} f(E-\mu) \rho(E)\]where \(\Omega\) is the total volume, \(\mu\) is the chemical potential, f is the fermi function and \(\rho(E)\) is the density of states.
- Parameters:
dos (np.ndarray) – Density of states.
w (np.ndarray) – Energies for which the DOS is defined.
mu (float) – Chemical potential.
T (float) – Temperature.
- Raises:
ValueError – If dos and w are not compatible.
- Returns:
Carrier density in \(Å^{-D}\) with D the dimensionality of the system.
- Return type:
float
- getChargeSusceptibility(T: float, mu: float, dos: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1) float
Calculate the linear DC electric charge susceptibility.
This is equal to
\[\chi_e = \frac{2 \pi}{\Omega} \frac{\partial N}{\partial \mu}\]where \(\Omega\) is the total volume, N is the number of particles and \(\mu\) the chemical potential.
The routine simply computes the numerical derivative of the number of particles with respect to the chemical potential as an average of energies close to it.
TODO: add possibility to select sublattices, if deemed useful
- Parameters:
T (float) – Temperature.
mu (float) – Chemical potential.
dos (Optional[np.ndarray]) – precoumputed DoS.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
- Raises:
ValueError – if the input is not consistent.
- Returns:
static charge susceptibility of the system.
- Return type:
float
- getConductivity(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculates the conductivity of the system from the Kubo-Greenwood formula.
This routine follows the method presented in https://doi.org/10.1016/j.physrep.2020.12.001
In short: a Chebyshev expansion of the zero temperature Kubo formula is performed. This translates into the expansion of the function \(\delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H})\) \(\hat{V}_{\beta}\), where \(E\) is the energy, \(\hat{H}\) is the Hamiltonian and \(\hat{V}\) is the velocity operator in the direction \(\alpha\,{\rm and }\,\beta\). The conductivity reads
\[\sigma(E) = \frac{\pi \hbar e^2}{\Omega} {\rm Tr}\left[ \delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H}) \right]\]The temperature dependent result is obtained by simply convolving the zero temperature result by a ‘Fermi window’, i.e. minus the derivative of the Fermi function with respect to the energy.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getConductivityMu(tensor_element: str, NSamples: int, Order: int, mu: float | ndarray, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex | ndarray
Calculates the conductivity of the system defined by H at a single chemical potential.
Given a Hamiltonian, the corresponding conductivity can be calculated as
\[\sigma(\mu) = \frac{\pi \Omega}{\Delta E^2} \braket{\phi^L|\phi^R}\]where \(\Omega\) is the volume of the system, \(\Delta E\) is the scaling applied to the Hamiltonian to ensure the spectrum lies within (-1, 1) and the vectors \(\phi\) are
\[ \begin{align}\begin{aligned}\ket{\phi^L} = \sum_n Im[G^+_n(\mu)] T_n(\tilde{H}) V \ket{r}\\\ket{\phi^R} = \sum_n Im[G^+_n(\mu)] V T_n(\tilde{H}) \ket{r}\end{aligned}\end{align} \]where \(\ket{r}\) is the random vector, \(V\) is the velocity operator, \(G^+_n\) is the n-th GF coefficient and \(T_n(\tilde{H})\) is the m-th Chebyshev polynomial.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
mu (Union[float, np.ndarray]) – Energy(ies) (as in chemical potential) at which to evaluate the conductivity.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the DOS.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity at the specified chemical potential(s).
- Return type:
qt.fl_cmplx_or_ndarr
- getConductivityOptical(tensor_element: str, T: float, mu: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray]
Calculates the complex optical conductivity of the system.
In short: a Chebyshev expansion of the Kubo formula is performed. The procedure is similar to the one presented in https://journals.aps.org/prb/abstract/10.1103/PhysRevB.94.235405
Details on the routine can be found in the internal notes. In particular, eq. 32 of the notes is implemented.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
mu (float) – Chemical potential.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getConductivity_KB(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray]
Calculates the conductivity of the system evaluating the Kubo-Bastin formula.
This routine follows the method presented in https://doi.org/10.1103/PhysRevLett.114.116602
In short: a Chebyshev expansion of the Kubo-Bastin formula is performed. This translates into the expansion of the function:
\[v_\alpha \delta(\varepsilon - \hat{H}) \hat{v}_\beta \frac{dG^+(\varepsilon)} {d\varepsilon} - \hat{v}_\alpha \frac{dG^-(\varepsilon)}{d\varepsilon} \hat{v}_\beta \delta(\varepsilon - \hat{H})\]where \(\varepsilon\) is the energy, \(\hat{H}\) is the Hamiltonian, \(\hat{v}\) is the velocity operator and \(\alpha, \beta\) indicate the direction. The modus operandi is exactly the same as for the other conductivity calculations based on the Chebyshev expansion.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getDOS(NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculates DoS through stochastic averaging of Chebyshev expansion.
This density of states integrates to 1, i.e. it is defined as:
\[\rho(E) = \frac{1}{N} \sum\limits_i \delta(E - E_i) = \frac{1}{N} {\rm Tr} \left[ \delta(E - \hat{H}) \right]\]with \(E_i\) the eigenvalues of the Hamiltonian and N the number of orbitals.
More details on the calculation are readily available in the literature. For example: https://doi.org/10.1016/j.physrep.2020.12.001
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of frequencies to evaluate the DoS at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
DoS and corresponding frequencies.
- Return type:
tuple
- getExpectationValue(A: Callable, dtype: type, T: float, mu: float, NSamples: int, Order: int, NPadeFreq: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex
Calculates the expectation value of an operator through Chebyshev expansion.
This is done by performing the Chebyshev expansion of
\[\langle \hat{A} \rangle = {\rm Tr} \left[ \hat{A} f(\hat{H}) \right]\]where \(\hat{A}\) is the operator, \(\hat{H}\) is the hamiltonian and f is the fermi function. This expression is expanded in terms of Chebyshev polynomials. The integral over the energies is performed via the resummation of the Fermi-Pade’ expansion of the Fermi function.
- Parameters:
A (Callable) – Linear operator.
dtype (type) – dtype of the linear operator.
T (float) – temperature in Kelvins. Must be greater than 0.
mu (float) – chemical potential.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NPadeFreq (int) – Number of Pade frequencies to evaluate the approximation to the Fermi function.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if temperature is too small.
- Returns:
expectation value of operator A.
- Return type:
Union[float, complex]
- getGF(selector: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | bytes | _NestedSequence[bool | int | float | complex | str | bytes], Order: int, NOmegas: int, NSamplesDis: int = 1, verbose: int = 2, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculate the retarded Green’s Function in the real space basis.
This calculation is performed the same way as for the DOS, the only difference being the states used for evaluating the moments: in this case we directly use the real space basis.
- Parameters:
selector (Union[str, ArrayLike]) – specifies what to compute (‘diag’, ‘full’, or array of row-column pairs)
Order (int) – Order of the Chebyshev expansion.
NOmegas (int) – Number of frequencies to evaluate.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
GF and corresponding frequencies.
- Return type:
tuple[np.ndarray, np.ndarray]
- getH() csr_array
Getter function for Hamiltonian in sparse format.
- Returns:
Hamiltonian matrix in sparse row format.
- Return type:
csr_array
- Raises:
RuntimeError – if the Hamiltonian is not available.
- getLinearResponse(A: Callable, P: Callable, dtype: type, T: float, mu: float, NSamples: int, Order: int, NPadeFreq: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex
Calculates the static linear response of an observable to a perturbation.
This is done by expanding
\[\chi^A_P = \frac{2 \pi}{\Omega} \frac{\partial \langle \hat{A} \rangle}{\partial \varepsilon}\]where \(\hat{A}\) is the observable, \(\hat{P}\) the perturbation and \(\varepsilon\) its strength, i.e. the perturbation enters the Hamiltonian as \(\hat{H}' = \varepsilon \hat{P}\) with \(\varepsilon << 1\).
- Parameters:
A (Callable) – Linear operator associated with the observable.
P (Callable) – Perturbation in linear operator form.
dtype (type) – dtype of the linear operators.
T (float) – temperature in Kelvins. Must be greater than 0.
mu (float) – chemical potential.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NPadeFreq (int) – Number of Pade frequencies to evaluate the approximation to the Fermi function.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if temperature is too small.
- Returns:
expectation value of operator A.
- Return type:
Union[float, complex]
- getMagneticSusceptibility(T: float, mu: float, dos_u: ndarray | None = None, dos_d: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1) float
Calculate the linear static magnetic susceptibility.
This is equal to
\[\chi_m = \frac{2 \pi}{\Omega} \frac{\partial S_z}{\partial B_z}\]where \(\Omega\) is the total volume, \(S_z\) is the spin operator in the z direction and \(B_z\) the magnetic field.
The routine simply computes the numerical derivative of the spin expectation value with respect to the applied B field.
TODO: add possibility to select sublattices, if deemed useful
- Parameters:
T (float) – Temperature.
mu (float) – Chemical potential.
dos_u (Optional[np.ndarray]) – precoumputed DoS of spin up electrons.
dos_d (Optional[np.ndarray]) – precoumputed DoS of spin down electrons.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
- Raises:
ValueError – if the input is not consistent.
- Returns:
static magnetic susceptibility of the system.
- Return type:
float
- getMu(T: float, dos: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1, verbose: int = 2) float
Calculate the chemical potential.
We calculate the chemical potential as the \(\mu\) which satisfies
\[N = \int\limits dE f(E-\mu) \rho(E)\]where \(N\) is the number of particles in the system, f is the fermi function and \(\rho(E)\) is the density of states.
In the case of BCS systems, the DOS depends on the chemical potential. This is therefore calculated for every chemical potential and the corresponding number of particles is obtained. A bisection is used starting from the boundaries of the Hamiltonian and honing in on the chemical potential resulting in a number of particles closest to the desired one. Starting from the two values giving slightly more and slightly less particles than needed, a linear extrapolation is finally performed to approximate the energy that results in the occupation closest to the desired one.
TODO: it is probably better to split this calculation in the “one-shot” version and the self-consistent one, suitable for BCS systems.
- Parameters:
T (float) – Temperature.
dos (Optional[np.ndarray]) – precoumputed DoS. Will be the 1st one to be used in the BCS case.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
verbose (int) – controls the verbosity of the method.
- Raises:
ValueError – if the input is not consistent.
- Returns:
Chemical potential.
- Return type:
float
- getOperator(operator: str) tuple[Callable, type]
Provide basic operators.
- Operators available:
±number operator and its left version
±spin operator and its left version
±position and its left version
- Parameters:
operator (str) – operator to be returned.
- Raises:
NotImplementedError – if the requested operator has not been implemented.
- Returns:
- tuple contining the operator as a callable acting on an input
array and the dtype of the operator.
- Return type:
tuple[Callable, type]
- getSpectral(num_kpoints: float, Order: int, NOmegas: int, NSamplesDis: int = 1, verbose: int = 2, eWindow: list | ndarray | None = None) tuple
Calculate the spectral function.
This calculation is performed the same way as for the GF, the only difference being the states used for evaluating the moments: in this case we directly use the Bloch functions. The band structure is then simply \(-\operatorname{Im}[G_{kk}]/\pi\) for k’s along the correct k path.
- Parameters:
num_kpoints (float) – number of kpoints for the spectral function calculation.
Order (int) – Order of the Chebyshev expansion.
NOmegas (int) – Number of frequencies to evaluate.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
spectral function, frequencies and corresponding k-path information.
- Return type:
tuple
- getTrResolvent(NSamples: int, Order: int, rescale: bool = True, use_KPM: bool = True, verbose: int = 2, selector: ndarray | None = None) Callable
Returns a function evaluating the trace of the resolvent.
This method computes the Chebyshev moments for a given order and given number of stochastic samples to evaluate the trace. Can be used to evaluate the trace of the resolvent,
\[\mathrm{Tr} \left[ \frac{1}{z - \hat{H}} \right]\]for a given ‘frequency’ \(z\) without the need to recompute the Chebyshev expansion. This is useful if it is not a priori clear on how many frequencies the trace of the resolvent needs to be evaluated.
The trace of the resolvent will be evaluated at the given frequencies. For real frequencies the retarded resolvent is chosen.
NOTE: The trace is estimated as the average over all (normalized) stochastic samples. Hence, multiply the result by the linear size of the Hamiltonian to get the “true” estimate for the trace.
NOTE: If the number of samples is larger that the size of the selected subspace, the trace is computed exactly (apart from the normalization, see above).
- Parameters:
NSamples (int) – Number of stochastic samples to approximate the trace.
Order (int) – Order of the Chebyshev expanbsion to approximate the resolvent.
rescale (bool) – Whether generated function transforms input into interval (-1, 1). Defaults to True.
use_KPM (bool) – Flag controlling the use of KPM.
verbose (int) – Controls verbosity of output and warnings. Defaults to 2.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Returns:
Function evaluating the trace of the resolvent for a given frequency.
- Return type:
Callable
- parseDisDict(parse_dict: dict) None
Parse disorder input dictionary.
The disorder dictionary specifies the properties of the disorder:
type: kind of disorder, e.g. onsite (only type implemented for now).
distribution: random distribution of disorder potential.
sigma: standard deviation of the disorder distribution.
avg: mean of distribution.
Note
This will become obsolete with the introduction of a Schema for the disDict.
- Parameters:
parse_dict (dict) – Dictionary containing information about the disorder.
- Raises:
ValueError – if the dictionary cannot be parsed
- scale2real(x: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr
Apply scaling to transform scaled frequencies to real ones.
- Parameters:
x (qt.fl_cmplx_or_ndarr) – array of scaled energies within (-1, 1).
- Returns:
Real energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- scale2transformed(z: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr
Apply scaling to transform real frequencies to scaled ones.
- Parameters:
z (qt.fl_cmplx_or_ndarr) – real energies array.
- Returns:
Scaled energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- scaleH(delta: float = 0.1, LanczOrder: int | None = None, energyBounds: list | ndarray | None = None) None
Rescale Hamiltonian to have spectrum between -1 and 1.
- Parameters:
delta (float) – Controls the extra compression of the band. This will be rescaled to be (-1 + delta/2, 1 - delta/2). Defaults to 0.1.
LanczOrder (Optional[int]) – Order of the Lanczos expansion used to determine the bandwidth. Cannot be set together with energyBounds.
energyBounds (Optional[Union[list, np.ndarray]]) – lower and upper energy boundaries to determine scaling. Cannot be set together with LanczOrder.
- Raises:
ValueError – If delta is not in (0, 2).
ValueError – If both LanczOrder and energyBounds are set.
- scaleH_inv() None
Rescale Hamiltonian to have original spectrum.
- scrambleW() None
Function that scrambles the disorder vector.
- todense() ndarray
Getter function for Hamiltonian in dense format.
- Returns:
Hamiltonian matrix in dense format.
- Return type:
np.ndarray
- lb: LB
- is_spinflip: bool
- disDict: dict
- disLocPot: np.ndarray
- scaling: lsc.chebyshev_scaling
- chebyshev: lsc.chebyshev
- dim: int
- realDim: int
- velocity_operator: tuple[Callable, Callable, Callable] | None
- total_volume: float
- is_complex: bool
- class qolossal.Hamiltonians.HamiltonianDense(input_dict: dict, disDict: dict | None = None)[source]
Bases:
HamiltonianLB
Hamiltonian implementation in full dense matrix representation.
This implementation is based on the representation of the Hamiltonian in dense matrix form. It is the exact same as the HamiltonianSparse implementation, but with dense matrices and corresponding arithmetics methods.
The parent class takes care of the interface with the Lattice Builder, saving the lattice builder instance in the object, for easy access and extracting all the important properties of the system to be used within the package’s methods.
Initialization of the HamiltonianDense class.
- Parameters:
input_dict (dict) – Input dictionary for the Lattice Builder to construct the Hamiltonian
disDict (Optional[dict]) – dictionary specifying the disorder.
- __init__(input_dict: dict, disDict: dict | None = None) None [source]
Initialization of the HamiltonianDense class.
- Parameters:
input_dict (dict) – Input dictionary for the Lattice Builder to construct the Hamiltonian
disDict (Optional[dict]) – dictionary specifying the disorder.
- set_Hamiltonian(kpt: ndarray | None = None, mu: float = 0, Bz: float = 0) None [source]
Hamiltonian setter method.
- Parameters:
kpt (Optional[np.ndarray]) – Bloch vector determining phase-shift at periodic boundaries.
mu (float) – additional chemical potential.
Bz (float) – additional Bz field.
- dot(v: ndarray, out: ndarray) ndarray [source]
Calculate the scalar product of H.
- Parameters:
v (np.ndarray) – vector to dot the Hamiltonian into.
out (np.ndarray) – preallocated output array.
- Returns:
Dot product of H with v
- Return type:
np.ndarray
- _abc_impl = <_abc._abc_data object>
- _dot_scaling(v: ndarray, out: ndarray) ndarray
Dot product including scaling.
This dot product is needed for evaluating moments of quantities that have not been yet implemented in the lattice solver.
- Parameters:
v (np.ndarray) – Vector to dot.
out (np.ndarray) – preallocated output array.
- Returns:
Dot product of H with v.
- Return type:
np.ndarray
- _get_DOS_moments(NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of the density of states.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the density of states
- Return type:
np.ndarray
- _get_conductivity_moments(tensor_element: str, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of the conductivity.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Moments associated with the conductivity
- Return type:
np.ndarray
- _get_expectation_value_moments(A: Callable, expectation_value_dtype: type, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of an operator’s expectation value.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
A (Callable) – Linear operator.
expectation_value_dtype (type) – dtype of the linear operator.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the expectation value of operator A.
- Return type:
np.ndarray
- _set_cheby(force_complex: bool = False) None
Set the chebyshev object.
- Parameters:
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- _set_scaling_and_cheby(lower_spectral_bound: float = -1, upper_spectral_bound: float = 1, delta: float = 0, force_complex: bool = False) None
Set the scaling and corresponding chebyshev objects.
- Parameters:
lower_spectral_bound (float) – Lower bound of the spectral range. Defaults to -1.
upper_spectral_bound (float) – Upper bound of the spectral range. Defaults to 1.
delta (float) – Spectral buffer for Hamiltonian scaling.
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- property dtype: Type
Dtype convenience function.
- Returns:
complex or float depending on the flag is_complex
- Return type:
Type
- generateSelector(what: str = 'all') ndarray
Generate selector given a certain input configuration.
- Parameters:
what (str) – input configuration.
- Returns:
array composed of 1’s and 0’s selecting the correct sublattice.
- Return type:
np.ndarray
- Raises:
ValueError – if the argument ‘what’ is invalid.
Warning
RuntimeWarning: if the selection is inconsistent with the system and a default choice is made.
- getBoundsLanczos(Order: int, tolerance: float = 1e-11) ndarray
Get spectrum boundaries for the current Hamiltonian with the Lanczos method.
- Parameters:
Order (int) – Order of the Lanczos expansion
tolerance (float) – Tolerance for the expansion. Defaults to 1e-11.
- Returns:
Boundaries of the spectrum.
- Return type:
np.ndarray
- getCarrierDensity(dos: ndarray, w: ndarray, mu: float, T: float) float
Calculate the carrier density.
The calculation is performed by integrating the DoS time the occupation for frequencies larger than the chemical potential and normalizing this by the system’s volume. The formula reads:
\[n = \frac{1}{\Omega} \int\limits_{-\infty}^{\mu} f(E-\mu) \rho(E)\]where \(\Omega\) is the total volume, \(\mu\) is the chemical potential, f is the fermi function and \(\rho(E)\) is the density of states.
- Parameters:
dos (np.ndarray) – Density of states.
w (np.ndarray) – Energies for which the DOS is defined.
mu (float) – Chemical potential.
T (float) – Temperature.
- Raises:
ValueError – If dos and w are not compatible.
- Returns:
Carrier density in \(Å^{-D}\) with D the dimensionality of the system.
- Return type:
float
- getChargeSusceptibility(T: float, mu: float, dos: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1) float
Calculate the linear DC electric charge susceptibility.
This is equal to
\[\chi_e = \frac{2 \pi}{\Omega} \frac{\partial N}{\partial \mu}\]where \(\Omega\) is the total volume, N is the number of particles and \(\mu\) the chemical potential.
The routine simply computes the numerical derivative of the number of particles with respect to the chemical potential as an average of energies close to it.
TODO: add possibility to select sublattices, if deemed useful
- Parameters:
T (float) – Temperature.
mu (float) – Chemical potential.
dos (Optional[np.ndarray]) – precoumputed DoS.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
- Raises:
ValueError – if the input is not consistent.
- Returns:
static charge susceptibility of the system.
- Return type:
float
- getConductivity(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculates the conductivity of the system from the Kubo-Greenwood formula.
This routine follows the method presented in https://doi.org/10.1016/j.physrep.2020.12.001
In short: a Chebyshev expansion of the zero temperature Kubo formula is performed. This translates into the expansion of the function \(\delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H})\) \(\hat{V}_{\beta}\), where \(E\) is the energy, \(\hat{H}\) is the Hamiltonian and \(\hat{V}\) is the velocity operator in the direction \(\alpha\,{\rm and }\,\beta\). The conductivity reads
\[\sigma(E) = \frac{\pi \hbar e^2}{\Omega} {\rm Tr}\left[ \delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H}) \right]\]The temperature dependent result is obtained by simply convolving the zero temperature result by a ‘Fermi window’, i.e. minus the derivative of the Fermi function with respect to the energy.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getConductivityMu(tensor_element: str, NSamples: int, Order: int, mu: float | ndarray, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex | ndarray
Calculates the conductivity of the system defined by H at a single chemical potential.
Given a Hamiltonian, the corresponding conductivity can be calculated as
\[\sigma(\mu) = \frac{\pi \Omega}{\Delta E^2} \braket{\phi^L|\phi^R}\]where \(\Omega\) is the volume of the system, \(\Delta E\) is the scaling applied to the Hamiltonian to ensure the spectrum lies within (-1, 1) and the vectors \(\phi\) are
\[ \begin{align}\begin{aligned}\ket{\phi^L} = \sum_n Im[G^+_n(\mu)] T_n(\tilde{H}) V \ket{r}\\\ket{\phi^R} = \sum_n Im[G^+_n(\mu)] V T_n(\tilde{H}) \ket{r}\end{aligned}\end{align} \]where \(\ket{r}\) is the random vector, \(V\) is the velocity operator, \(G^+_n\) is the n-th GF coefficient and \(T_n(\tilde{H})\) is the m-th Chebyshev polynomial.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
mu (Union[float, np.ndarray]) – Energy(ies) (as in chemical potential) at which to evaluate the conductivity.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the DOS.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity at the specified chemical potential(s).
- Return type:
qt.fl_cmplx_or_ndarr
- getConductivityOptical(tensor_element: str, T: float, mu: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray]
Calculates the complex optical conductivity of the system.
In short: a Chebyshev expansion of the Kubo formula is performed. The procedure is similar to the one presented in https://journals.aps.org/prb/abstract/10.1103/PhysRevB.94.235405
Details on the routine can be found in the internal notes. In particular, eq. 32 of the notes is implemented.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
mu (float) – Chemical potential.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getConductivity_KB(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray]
Calculates the conductivity of the system evaluating the Kubo-Bastin formula.
This routine follows the method presented in https://doi.org/10.1103/PhysRevLett.114.116602
In short: a Chebyshev expansion of the Kubo-Bastin formula is performed. This translates into the expansion of the function:
\[v_\alpha \delta(\varepsilon - \hat{H}) \hat{v}_\beta \frac{dG^+(\varepsilon)} {d\varepsilon} - \hat{v}_\alpha \frac{dG^-(\varepsilon)}{d\varepsilon} \hat{v}_\beta \delta(\varepsilon - \hat{H})\]where \(\varepsilon\) is the energy, \(\hat{H}\) is the Hamiltonian, \(\hat{v}\) is the velocity operator and \(\alpha, \beta\) indicate the direction. The modus operandi is exactly the same as for the other conductivity calculations based on the Chebyshev expansion.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getDOS(NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculates DoS through stochastic averaging of Chebyshev expansion.
This density of states integrates to 1, i.e. it is defined as:
\[\rho(E) = \frac{1}{N} \sum\limits_i \delta(E - E_i) = \frac{1}{N} {\rm Tr} \left[ \delta(E - \hat{H}) \right]\]with \(E_i\) the eigenvalues of the Hamiltonian and N the number of orbitals.
More details on the calculation are readily available in the literature. For example: https://doi.org/10.1016/j.physrep.2020.12.001
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of frequencies to evaluate the DoS at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
DoS and corresponding frequencies.
- Return type:
tuple
- getExpectationValue(A: Callable, dtype: type, T: float, mu: float, NSamples: int, Order: int, NPadeFreq: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex
Calculates the expectation value of an operator through Chebyshev expansion.
This is done by performing the Chebyshev expansion of
\[\langle \hat{A} \rangle = {\rm Tr} \left[ \hat{A} f(\hat{H}) \right]\]where \(\hat{A}\) is the operator, \(\hat{H}\) is the hamiltonian and f is the fermi function. This expression is expanded in terms of Chebyshev polynomials. The integral over the energies is performed via the resummation of the Fermi-Pade’ expansion of the Fermi function.
- Parameters:
A (Callable) – Linear operator.
dtype (type) – dtype of the linear operator.
T (float) – temperature in Kelvins. Must be greater than 0.
mu (float) – chemical potential.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NPadeFreq (int) – Number of Pade frequencies to evaluate the approximation to the Fermi function.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if temperature is too small.
- Returns:
expectation value of operator A.
- Return type:
Union[float, complex]
- getGF(selector: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | bytes | _NestedSequence[bool | int | float | complex | str | bytes], Order: int, NOmegas: int, NSamplesDis: int = 1, verbose: int = 2, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculate the retarded Green’s Function in the real space basis.
This calculation is performed the same way as for the DOS, the only difference being the states used for evaluating the moments: in this case we directly use the real space basis.
- Parameters:
selector (Union[str, ArrayLike]) – specifies what to compute (‘diag’, ‘full’, or array of row-column pairs)
Order (int) – Order of the Chebyshev expansion.
NOmegas (int) – Number of frequencies to evaluate.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
GF and corresponding frequencies.
- Return type:
tuple[np.ndarray, np.ndarray]
- getH() csr_array
Getter function for Hamiltonian in sparse format.
- Returns:
Hamiltonian matrix in sparse row format.
- Return type:
csr_array
- Raises:
RuntimeError – if the Hamiltonian is not available.
- getLinearResponse(A: Callable, P: Callable, dtype: type, T: float, mu: float, NSamples: int, Order: int, NPadeFreq: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex
Calculates the static linear response of an observable to a perturbation.
This is done by expanding
\[\chi^A_P = \frac{2 \pi}{\Omega} \frac{\partial \langle \hat{A} \rangle}{\partial \varepsilon}\]where \(\hat{A}\) is the observable, \(\hat{P}\) the perturbation and \(\varepsilon\) its strength, i.e. the perturbation enters the Hamiltonian as \(\hat{H}' = \varepsilon \hat{P}\) with \(\varepsilon << 1\).
- Parameters:
A (Callable) – Linear operator associated with the observable.
P (Callable) – Perturbation in linear operator form.
dtype (type) – dtype of the linear operators.
T (float) – temperature in Kelvins. Must be greater than 0.
mu (float) – chemical potential.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NPadeFreq (int) – Number of Pade frequencies to evaluate the approximation to the Fermi function.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if temperature is too small.
- Returns:
expectation value of operator A.
- Return type:
Union[float, complex]
- getMagneticSusceptibility(T: float, mu: float, dos_u: ndarray | None = None, dos_d: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1) float
Calculate the linear static magnetic susceptibility.
This is equal to
\[\chi_m = \frac{2 \pi}{\Omega} \frac{\partial S_z}{\partial B_z}\]where \(\Omega\) is the total volume, \(S_z\) is the spin operator in the z direction and \(B_z\) the magnetic field.
The routine simply computes the numerical derivative of the spin expectation value with respect to the applied B field.
TODO: add possibility to select sublattices, if deemed useful
- Parameters:
T (float) – Temperature.
mu (float) – Chemical potential.
dos_u (Optional[np.ndarray]) – precoumputed DoS of spin up electrons.
dos_d (Optional[np.ndarray]) – precoumputed DoS of spin down electrons.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
- Raises:
ValueError – if the input is not consistent.
- Returns:
static magnetic susceptibility of the system.
- Return type:
float
- getMu(T: float, dos: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1, verbose: int = 2) float
Calculate the chemical potential.
We calculate the chemical potential as the \(\mu\) which satisfies
\[N = \int\limits dE f(E-\mu) \rho(E)\]where \(N\) is the number of particles in the system, f is the fermi function and \(\rho(E)\) is the density of states.
In the case of BCS systems, the DOS depends on the chemical potential. This is therefore calculated for every chemical potential and the corresponding number of particles is obtained. A bisection is used starting from the boundaries of the Hamiltonian and honing in on the chemical potential resulting in a number of particles closest to the desired one. Starting from the two values giving slightly more and slightly less particles than needed, a linear extrapolation is finally performed to approximate the energy that results in the occupation closest to the desired one.
TODO: it is probably better to split this calculation in the “one-shot” version and the self-consistent one, suitable for BCS systems.
- Parameters:
T (float) – Temperature.
dos (Optional[np.ndarray]) – precoumputed DoS. Will be the 1st one to be used in the BCS case.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
verbose (int) – controls the verbosity of the method.
- Raises:
ValueError – if the input is not consistent.
- Returns:
Chemical potential.
- Return type:
float
- getOperator(operator: str) tuple[Callable, type]
Provide basic operators.
- Operators available:
±number operator and its left version
±spin operator and its left version
±position and its left version
- Parameters:
operator (str) – operator to be returned.
- Raises:
NotImplementedError – if the requested operator has not been implemented.
- Returns:
- tuple contining the operator as a callable acting on an input
array and the dtype of the operator.
- Return type:
tuple[Callable, type]
- getSpectral(num_kpoints: float, Order: int, NOmegas: int, NSamplesDis: int = 1, verbose: int = 2, eWindow: list | ndarray | None = None) tuple
Calculate the spectral function.
This calculation is performed the same way as for the GF, the only difference being the states used for evaluating the moments: in this case we directly use the Bloch functions. The band structure is then simply \(-\operatorname{Im}[G_{kk}]/\pi\) for k’s along the correct k path.
- Parameters:
num_kpoints (float) – number of kpoints for the spectral function calculation.
Order (int) – Order of the Chebyshev expansion.
NOmegas (int) – Number of frequencies to evaluate.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
spectral function, frequencies and corresponding k-path information.
- Return type:
tuple
- getTrResolvent(NSamples: int, Order: int, rescale: bool = True, use_KPM: bool = True, verbose: int = 2, selector: ndarray | None = None) Callable
Returns a function evaluating the trace of the resolvent.
This method computes the Chebyshev moments for a given order and given number of stochastic samples to evaluate the trace. Can be used to evaluate the trace of the resolvent,
\[\mathrm{Tr} \left[ \frac{1}{z - \hat{H}} \right]\]for a given ‘frequency’ \(z\) without the need to recompute the Chebyshev expansion. This is useful if it is not a priori clear on how many frequencies the trace of the resolvent needs to be evaluated.
The trace of the resolvent will be evaluated at the given frequencies. For real frequencies the retarded resolvent is chosen.
NOTE: The trace is estimated as the average over all (normalized) stochastic samples. Hence, multiply the result by the linear size of the Hamiltonian to get the “true” estimate for the trace.
NOTE: If the number of samples is larger that the size of the selected subspace, the trace is computed exactly (apart from the normalization, see above).
- Parameters:
NSamples (int) – Number of stochastic samples to approximate the trace.
Order (int) – Order of the Chebyshev expanbsion to approximate the resolvent.
rescale (bool) – Whether generated function transforms input into interval (-1, 1). Defaults to True.
use_KPM (bool) – Flag controlling the use of KPM.
verbose (int) – Controls verbosity of output and warnings. Defaults to 2.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Returns:
Function evaluating the trace of the resolvent for a given frequency.
- Return type:
Callable
- parseDisDict(parse_dict: dict) None
Parse disorder input dictionary.
The disorder dictionary specifies the properties of the disorder:
type: kind of disorder, e.g. onsite (only type implemented for now).
distribution: random distribution of disorder potential.
sigma: standard deviation of the disorder distribution.
avg: mean of distribution.
Note
This will become obsolete with the introduction of a Schema for the disDict.
- Parameters:
parse_dict (dict) – Dictionary containing information about the disorder.
- Raises:
ValueError – if the dictionary cannot be parsed
- scale2real(x: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr
Apply scaling to transform scaled frequencies to real ones.
- Parameters:
x (qt.fl_cmplx_or_ndarr) – array of scaled energies within (-1, 1).
- Returns:
Real energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- scale2transformed(z: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr
Apply scaling to transform real frequencies to scaled ones.
- Parameters:
z (qt.fl_cmplx_or_ndarr) – real energies array.
- Returns:
Scaled energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- scaleH(delta: float = 0.1, LanczOrder: int | None = None, energyBounds: list | ndarray | None = None) None
Rescale Hamiltonian to have spectrum between -1 and 1.
- Parameters:
delta (float) – Controls the extra compression of the band. This will be rescaled to be (-1 + delta/2, 1 - delta/2). Defaults to 0.1.
LanczOrder (Optional[int]) – Order of the Lanczos expansion used to determine the bandwidth. Cannot be set together with energyBounds.
energyBounds (Optional[Union[list, np.ndarray]]) – lower and upper energy boundaries to determine scaling. Cannot be set together with LanczOrder.
- Raises:
ValueError – If delta is not in (0, 2).
ValueError – If both LanczOrder and energyBounds are set.
- scaleH_inv() None
Rescale Hamiltonian to have original spectrum.
- scrambleW() None
Function that scrambles the disorder vector.
- todense() ndarray
Getter function for Hamiltonian in dense format.
- Returns:
Hamiltonian matrix in dense format.
- Return type:
np.ndarray
- lb: LB
- is_spinflip: bool
- disDict: dict
- disLocPot: np.ndarray
- scaling: lsc.chebyshev_scaling
- chebyshev: lsc.chebyshev
- dim: int
- realDim: int
- velocity_operator: tuple[Callable, Callable, Callable] | None
- total_volume: float
- is_complex: bool
- class qolossal.Hamiltonians.HamiltonianTensor(input_dict: dict, disDict: dict | None = None)[source]
Bases:
HamiltonianLB
Hamiltonian in tensor representation.
This implementation expresses the Hamiltonian exactly like in the Lattice Builder, namely by storing, for each bond within the lattice definition, the intra(inter) unit-cell bond matrix and the expander matrix needed to map this bond matrix onto the whole space. This means that the contribution to the full Hamiltonian of each bond is:
\[{\rm E}_x \otimes {\rm E}_y \otimes {\rm E}_z \otimes B\]where \({\rm E_i}\) is the expander in the i-th direction and \(B\) is the bond matrix.
Because of this, calculating the contribution to the dot product \(H\cdot v\) from each bond is
\[({\rm E}_x \otimes {\rm E}_y \otimes {\rm E}_z \otimes B) \cdot v\]which is simple to calculate once we express (reshape) v as a multidimensional array with the correct matching dimension to x, y, z and unit-cell.
Initialization of the HamiltonianTensor class.
- Parameters:
input_dict (dict) – Input dictionary for the Lattice Builder to construct the Hamiltonian
disDict (Optional[dict]) – dictionary specifying the disorder.
- Raises:
NotImplementedError – if the system is spinful or has BCS terms.
- __init__(input_dict: dict, disDict: dict | None = None) None [source]
Initialization of the HamiltonianTensor class.
- Parameters:
input_dict (dict) – Input dictionary for the Lattice Builder to construct the Hamiltonian
disDict (Optional[dict]) – dictionary specifying the disorder.
- Raises:
NotImplementedError – if the system is spinful or has BCS terms.
- set_Hamiltonian(kpt: ndarray | None = None, mu: float = 0, Bz: float = 0) None [source]
Hamiltonian setter method.
- Raises:
NotImplementedError – if Bz != 0.
- Parameters:
kpt (Optional[np.ndarray]) – Bloch vector determining phase-shift at periodic boundaries.
mu (float) – additional chemical potential.
Bz (float) – additional Bz field.
- dot(v: ndarray, out: ndarray) ndarray [source]
Calculate the scalar product of H.
- Parameters:
v (np.ndarray) – vector to dot the Hamiltonian into.
out (np.ndarray) – preallocated output array.
- Returns:
Dot product of H with v
- Return type:
np.ndarray
- _abc_impl = <_abc._abc_data object>
- _dot_scaling(v: ndarray, out: ndarray) ndarray
Dot product including scaling.
This dot product is needed for evaluating moments of quantities that have not been yet implemented in the lattice solver.
- Parameters:
v (np.ndarray) – Vector to dot.
out (np.ndarray) – preallocated output array.
- Returns:
Dot product of H with v.
- Return type:
np.ndarray
- _get_DOS_moments(NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of the density of states.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the density of states
- Return type:
np.ndarray
- _get_conductivity_moments(tensor_element: str, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of the conductivity.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Moments associated with the conductivity
- Return type:
np.ndarray
- _get_expectation_value_moments(A: Callable, expectation_value_dtype: type, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of an operator’s expectation value.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
A (Callable) – Linear operator.
expectation_value_dtype (type) – dtype of the linear operator.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the expectation value of operator A.
- Return type:
np.ndarray
- _set_cheby(force_complex: bool = False) None
Set the chebyshev object.
- Parameters:
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- _set_scaling_and_cheby(lower_spectral_bound: float = -1, upper_spectral_bound: float = 1, delta: float = 0, force_complex: bool = False) None
Set the scaling and corresponding chebyshev objects.
- Parameters:
lower_spectral_bound (float) – Lower bound of the spectral range. Defaults to -1.
upper_spectral_bound (float) – Upper bound of the spectral range. Defaults to 1.
delta (float) – Spectral buffer for Hamiltonian scaling.
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- property dtype: Type
Dtype convenience function.
- Returns:
complex or float depending on the flag is_complex
- Return type:
Type
- generateSelector(what: str = 'all') ndarray
Generate selector given a certain input configuration.
- Parameters:
what (str) – input configuration.
- Returns:
array composed of 1’s and 0’s selecting the correct sublattice.
- Return type:
np.ndarray
- Raises:
ValueError – if the argument ‘what’ is invalid.
Warning
RuntimeWarning: if the selection is inconsistent with the system and a default choice is made.
- getBoundsLanczos(Order: int, tolerance: float = 1e-11) ndarray
Get spectrum boundaries for the current Hamiltonian with the Lanczos method.
- Parameters:
Order (int) – Order of the Lanczos expansion
tolerance (float) – Tolerance for the expansion. Defaults to 1e-11.
- Returns:
Boundaries of the spectrum.
- Return type:
np.ndarray
- getCarrierDensity(dos: ndarray, w: ndarray, mu: float, T: float) float
Calculate the carrier density.
The calculation is performed by integrating the DoS time the occupation for frequencies larger than the chemical potential and normalizing this by the system’s volume. The formula reads:
\[n = \frac{1}{\Omega} \int\limits_{-\infty}^{\mu} f(E-\mu) \rho(E)\]where \(\Omega\) is the total volume, \(\mu\) is the chemical potential, f is the fermi function and \(\rho(E)\) is the density of states.
- Parameters:
dos (np.ndarray) – Density of states.
w (np.ndarray) – Energies for which the DOS is defined.
mu (float) – Chemical potential.
T (float) – Temperature.
- Raises:
ValueError – If dos and w are not compatible.
- Returns:
Carrier density in \(Å^{-D}\) with D the dimensionality of the system.
- Return type:
float
- getChargeSusceptibility(T: float, mu: float, dos: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1) float
Calculate the linear DC electric charge susceptibility.
This is equal to
\[\chi_e = \frac{2 \pi}{\Omega} \frac{\partial N}{\partial \mu}\]where \(\Omega\) is the total volume, N is the number of particles and \(\mu\) the chemical potential.
The routine simply computes the numerical derivative of the number of particles with respect to the chemical potential as an average of energies close to it.
TODO: add possibility to select sublattices, if deemed useful
- Parameters:
T (float) – Temperature.
mu (float) – Chemical potential.
dos (Optional[np.ndarray]) – precoumputed DoS.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
- Raises:
ValueError – if the input is not consistent.
- Returns:
static charge susceptibility of the system.
- Return type:
float
- getConductivity(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculates the conductivity of the system from the Kubo-Greenwood formula.
This routine follows the method presented in https://doi.org/10.1016/j.physrep.2020.12.001
In short: a Chebyshev expansion of the zero temperature Kubo formula is performed. This translates into the expansion of the function \(\delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H})\) \(\hat{V}_{\beta}\), where \(E\) is the energy, \(\hat{H}\) is the Hamiltonian and \(\hat{V}\) is the velocity operator in the direction \(\alpha\,{\rm and }\,\beta\). The conductivity reads
\[\sigma(E) = \frac{\pi \hbar e^2}{\Omega} {\rm Tr}\left[ \delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H}) \right]\]The temperature dependent result is obtained by simply convolving the zero temperature result by a ‘Fermi window’, i.e. minus the derivative of the Fermi function with respect to the energy.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getConductivityMu(tensor_element: str, NSamples: int, Order: int, mu: float | ndarray, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex | ndarray
Calculates the conductivity of the system defined by H at a single chemical potential.
Given a Hamiltonian, the corresponding conductivity can be calculated as
\[\sigma(\mu) = \frac{\pi \Omega}{\Delta E^2} \braket{\phi^L|\phi^R}\]where \(\Omega\) is the volume of the system, \(\Delta E\) is the scaling applied to the Hamiltonian to ensure the spectrum lies within (-1, 1) and the vectors \(\phi\) are
\[ \begin{align}\begin{aligned}\ket{\phi^L} = \sum_n Im[G^+_n(\mu)] T_n(\tilde{H}) V \ket{r}\\\ket{\phi^R} = \sum_n Im[G^+_n(\mu)] V T_n(\tilde{H}) \ket{r}\end{aligned}\end{align} \]where \(\ket{r}\) is the random vector, \(V\) is the velocity operator, \(G^+_n\) is the n-th GF coefficient and \(T_n(\tilde{H})\) is the m-th Chebyshev polynomial.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
mu (Union[float, np.ndarray]) – Energy(ies) (as in chemical potential) at which to evaluate the conductivity.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the DOS.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity at the specified chemical potential(s).
- Return type:
qt.fl_cmplx_or_ndarr
- getConductivityOptical(tensor_element: str, T: float, mu: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray]
Calculates the complex optical conductivity of the system.
In short: a Chebyshev expansion of the Kubo formula is performed. The procedure is similar to the one presented in https://journals.aps.org/prb/abstract/10.1103/PhysRevB.94.235405
Details on the routine can be found in the internal notes. In particular, eq. 32 of the notes is implemented.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
mu (float) – Chemical potential.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getConductivity_KB(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray]
Calculates the conductivity of the system evaluating the Kubo-Bastin formula.
This routine follows the method presented in https://doi.org/10.1103/PhysRevLett.114.116602
In short: a Chebyshev expansion of the Kubo-Bastin formula is performed. This translates into the expansion of the function:
\[v_\alpha \delta(\varepsilon - \hat{H}) \hat{v}_\beta \frac{dG^+(\varepsilon)} {d\varepsilon} - \hat{v}_\alpha \frac{dG^-(\varepsilon)}{d\varepsilon} \hat{v}_\beta \delta(\varepsilon - \hat{H})\]where \(\varepsilon\) is the energy, \(\hat{H}\) is the Hamiltonian, \(\hat{v}\) is the velocity operator and \(\alpha, \beta\) indicate the direction. The modus operandi is exactly the same as for the other conductivity calculations based on the Chebyshev expansion.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getDOS(NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculates DoS through stochastic averaging of Chebyshev expansion.
This density of states integrates to 1, i.e. it is defined as:
\[\rho(E) = \frac{1}{N} \sum\limits_i \delta(E - E_i) = \frac{1}{N} {\rm Tr} \left[ \delta(E - \hat{H}) \right]\]with \(E_i\) the eigenvalues of the Hamiltonian and N the number of orbitals.
More details on the calculation are readily available in the literature. For example: https://doi.org/10.1016/j.physrep.2020.12.001
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of frequencies to evaluate the DoS at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
DoS and corresponding frequencies.
- Return type:
tuple
- getExpectationValue(A: Callable, dtype: type, T: float, mu: float, NSamples: int, Order: int, NPadeFreq: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex
Calculates the expectation value of an operator through Chebyshev expansion.
This is done by performing the Chebyshev expansion of
\[\langle \hat{A} \rangle = {\rm Tr} \left[ \hat{A} f(\hat{H}) \right]\]where \(\hat{A}\) is the operator, \(\hat{H}\) is the hamiltonian and f is the fermi function. This expression is expanded in terms of Chebyshev polynomials. The integral over the energies is performed via the resummation of the Fermi-Pade’ expansion of the Fermi function.
- Parameters:
A (Callable) – Linear operator.
dtype (type) – dtype of the linear operator.
T (float) – temperature in Kelvins. Must be greater than 0.
mu (float) – chemical potential.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NPadeFreq (int) – Number of Pade frequencies to evaluate the approximation to the Fermi function.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if temperature is too small.
- Returns:
expectation value of operator A.
- Return type:
Union[float, complex]
- getGF(selector: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | bytes | _NestedSequence[bool | int | float | complex | str | bytes], Order: int, NOmegas: int, NSamplesDis: int = 1, verbose: int = 2, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculate the retarded Green’s Function in the real space basis.
This calculation is performed the same way as for the DOS, the only difference being the states used for evaluating the moments: in this case we directly use the real space basis.
- Parameters:
selector (Union[str, ArrayLike]) – specifies what to compute (‘diag’, ‘full’, or array of row-column pairs)
Order (int) – Order of the Chebyshev expansion.
NOmegas (int) – Number of frequencies to evaluate.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
GF and corresponding frequencies.
- Return type:
tuple[np.ndarray, np.ndarray]
- getH() csr_array
Getter function for Hamiltonian in sparse format.
- Returns:
Hamiltonian matrix in sparse row format.
- Return type:
csr_array
- Raises:
RuntimeError – if the Hamiltonian is not available.
- getLinearResponse(A: Callable, P: Callable, dtype: type, T: float, mu: float, NSamples: int, Order: int, NPadeFreq: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex
Calculates the static linear response of an observable to a perturbation.
This is done by expanding
\[\chi^A_P = \frac{2 \pi}{\Omega} \frac{\partial \langle \hat{A} \rangle}{\partial \varepsilon}\]where \(\hat{A}\) is the observable, \(\hat{P}\) the perturbation and \(\varepsilon\) its strength, i.e. the perturbation enters the Hamiltonian as \(\hat{H}' = \varepsilon \hat{P}\) with \(\varepsilon << 1\).
- Parameters:
A (Callable) – Linear operator associated with the observable.
P (Callable) – Perturbation in linear operator form.
dtype (type) – dtype of the linear operators.
T (float) – temperature in Kelvins. Must be greater than 0.
mu (float) – chemical potential.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NPadeFreq (int) – Number of Pade frequencies to evaluate the approximation to the Fermi function.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if temperature is too small.
- Returns:
expectation value of operator A.
- Return type:
Union[float, complex]
- getMagneticSusceptibility(T: float, mu: float, dos_u: ndarray | None = None, dos_d: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1) float
Calculate the linear static magnetic susceptibility.
This is equal to
\[\chi_m = \frac{2 \pi}{\Omega} \frac{\partial S_z}{\partial B_z}\]where \(\Omega\) is the total volume, \(S_z\) is the spin operator in the z direction and \(B_z\) the magnetic field.
The routine simply computes the numerical derivative of the spin expectation value with respect to the applied B field.
TODO: add possibility to select sublattices, if deemed useful
- Parameters:
T (float) – Temperature.
mu (float) – Chemical potential.
dos_u (Optional[np.ndarray]) – precoumputed DoS of spin up electrons.
dos_d (Optional[np.ndarray]) – precoumputed DoS of spin down electrons.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
- Raises:
ValueError – if the input is not consistent.
- Returns:
static magnetic susceptibility of the system.
- Return type:
float
- getMu(T: float, dos: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1, verbose: int = 2) float
Calculate the chemical potential.
We calculate the chemical potential as the \(\mu\) which satisfies
\[N = \int\limits dE f(E-\mu) \rho(E)\]where \(N\) is the number of particles in the system, f is the fermi function and \(\rho(E)\) is the density of states.
In the case of BCS systems, the DOS depends on the chemical potential. This is therefore calculated for every chemical potential and the corresponding number of particles is obtained. A bisection is used starting from the boundaries of the Hamiltonian and honing in on the chemical potential resulting in a number of particles closest to the desired one. Starting from the two values giving slightly more and slightly less particles than needed, a linear extrapolation is finally performed to approximate the energy that results in the occupation closest to the desired one.
TODO: it is probably better to split this calculation in the “one-shot” version and the self-consistent one, suitable for BCS systems.
- Parameters:
T (float) – Temperature.
dos (Optional[np.ndarray]) – precoumputed DoS. Will be the 1st one to be used in the BCS case.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
verbose (int) – controls the verbosity of the method.
- Raises:
ValueError – if the input is not consistent.
- Returns:
Chemical potential.
- Return type:
float
- getOperator(operator: str) tuple[Callable, type]
Provide basic operators.
- Operators available:
±number operator and its left version
±spin operator and its left version
±position and its left version
- Parameters:
operator (str) – operator to be returned.
- Raises:
NotImplementedError – if the requested operator has not been implemented.
- Returns:
- tuple contining the operator as a callable acting on an input
array and the dtype of the operator.
- Return type:
tuple[Callable, type]
- getSpectral(num_kpoints: float, Order: int, NOmegas: int, NSamplesDis: int = 1, verbose: int = 2, eWindow: list | ndarray | None = None) tuple
Calculate the spectral function.
This calculation is performed the same way as for the GF, the only difference being the states used for evaluating the moments: in this case we directly use the Bloch functions. The band structure is then simply \(-\operatorname{Im}[G_{kk}]/\pi\) for k’s along the correct k path.
- Parameters:
num_kpoints (float) – number of kpoints for the spectral function calculation.
Order (int) – Order of the Chebyshev expansion.
NOmegas (int) – Number of frequencies to evaluate.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
spectral function, frequencies and corresponding k-path information.
- Return type:
tuple
- getTrResolvent(NSamples: int, Order: int, rescale: bool = True, use_KPM: bool = True, verbose: int = 2, selector: ndarray | None = None) Callable
Returns a function evaluating the trace of the resolvent.
This method computes the Chebyshev moments for a given order and given number of stochastic samples to evaluate the trace. Can be used to evaluate the trace of the resolvent,
\[\mathrm{Tr} \left[ \frac{1}{z - \hat{H}} \right]\]for a given ‘frequency’ \(z\) without the need to recompute the Chebyshev expansion. This is useful if it is not a priori clear on how many frequencies the trace of the resolvent needs to be evaluated.
The trace of the resolvent will be evaluated at the given frequencies. For real frequencies the retarded resolvent is chosen.
NOTE: The trace is estimated as the average over all (normalized) stochastic samples. Hence, multiply the result by the linear size of the Hamiltonian to get the “true” estimate for the trace.
NOTE: If the number of samples is larger that the size of the selected subspace, the trace is computed exactly (apart from the normalization, see above).
- Parameters:
NSamples (int) – Number of stochastic samples to approximate the trace.
Order (int) – Order of the Chebyshev expanbsion to approximate the resolvent.
rescale (bool) – Whether generated function transforms input into interval (-1, 1). Defaults to True.
use_KPM (bool) – Flag controlling the use of KPM.
verbose (int) – Controls verbosity of output and warnings. Defaults to 2.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Returns:
Function evaluating the trace of the resolvent for a given frequency.
- Return type:
Callable
- parseDisDict(parse_dict: dict) None
Parse disorder input dictionary.
The disorder dictionary specifies the properties of the disorder:
type: kind of disorder, e.g. onsite (only type implemented for now).
distribution: random distribution of disorder potential.
sigma: standard deviation of the disorder distribution.
avg: mean of distribution.
Note
This will become obsolete with the introduction of a Schema for the disDict.
- Parameters:
parse_dict (dict) – Dictionary containing information about the disorder.
- Raises:
ValueError – if the dictionary cannot be parsed
- scale2real(x: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr
Apply scaling to transform scaled frequencies to real ones.
- Parameters:
x (qt.fl_cmplx_or_ndarr) – array of scaled energies within (-1, 1).
- Returns:
Real energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- scale2transformed(z: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr
Apply scaling to transform real frequencies to scaled ones.
- Parameters:
z (qt.fl_cmplx_or_ndarr) – real energies array.
- Returns:
Scaled energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- scaleH(delta: float = 0.1, LanczOrder: int | None = None, energyBounds: list | ndarray | None = None) None
Rescale Hamiltonian to have spectrum between -1 and 1.
- Parameters:
delta (float) – Controls the extra compression of the band. This will be rescaled to be (-1 + delta/2, 1 - delta/2). Defaults to 0.1.
LanczOrder (Optional[int]) – Order of the Lanczos expansion used to determine the bandwidth. Cannot be set together with energyBounds.
energyBounds (Optional[Union[list, np.ndarray]]) – lower and upper energy boundaries to determine scaling. Cannot be set together with LanczOrder.
- Raises:
ValueError – If delta is not in (0, 2).
ValueError – If both LanczOrder and energyBounds are set.
- scaleH_inv() None
Rescale Hamiltonian to have original spectrum.
- scrambleW() None
Function that scrambles the disorder vector.
- todense() ndarray
Getter function for Hamiltonian in dense format.
- Returns:
Hamiltonian matrix in dense format.
- Return type:
np.ndarray
- lb: LB
- is_spinflip: bool
- disDict: dict
- disLocPot: np.ndarray
- scaling: lsc.chebyshev_scaling
- chebyshev: lsc.chebyshev
- dim: int
- realDim: int
- velocity_operator: tuple[Callable, Callable, Callable] | None
- total_volume: float
- is_complex: bool
- class qolossal.Hamiltonians.HamiltonianOperator(input_dict: dict, disDict: dict | None = None)[source]
Bases:
HamiltonianLB
Hamiltonian in direct operator representation.
This implementation describes the Hamiltonian by simply storing the recipes for all the bonds defining the system. For example, in a 1D chain with a unit cell made of two atoms with an intra-uc hopping of t_1 and an inter-uc hopping of t_2, the information stored in this implementation would be:
\[\begin{split}(0, 0, 0), \begin{pmatrix} 0 & t_1 \\ t_1^* & 0 \end{pmatrix}, \quad (1, 0, 0), \begin{pmatrix} 0 & t_2 \\ t_2^* & 0 \end{pmatrix}\end{split}\]Where the first tuple indicates the translation associated with the bond and the matrix gives us information about the hopping amplitudes within unitcells.
Since the Hamiltonian matrix is never build, the memory impact of this implementation is minimal.
Initialization of the HamiltonianOperator class.
NOTE: This Hamiltonian is only partially tested at the moment, since it does not work for periodic systems and making it fit into the general structure of tests would require more work than necessary. As soon as the class is generalized, this should be added to the list of tested Hamiltonians.
- Parameters:
input_dict (dict) – Input dictionary for the Lattice Builder to construct the Hamiltonian
disDict (Optional[dict]) – dictionary specifying the disorder.
- Raises:
NotImplementedError – in case the input is periodic, spinful or BCS, these cases are still not implemented.
- __init__(input_dict: dict, disDict: dict | None = None) None [source]
Initialization of the HamiltonianOperator class.
NOTE: This Hamiltonian is only partially tested at the moment, since it does not work for periodic systems and making it fit into the general structure of tests would require more work than necessary. As soon as the class is generalized, this should be added to the list of tested Hamiltonians.
- Parameters:
input_dict (dict) – Input dictionary for the Lattice Builder to construct the Hamiltonian
disDict (Optional[dict]) – dictionary specifying the disorder.
- Raises:
NotImplementedError – in case the input is periodic, spinful or BCS, these cases are still not implemented.
- set_Hamiltonian(kpt: ndarray | None = None, mu: float = 0, Bz: float = 0) None [source]
Hamiltonian setter method.
- Raises:
NotImplementedError – if Bz != 0.
- Parameters:
kpt (Optional[np.ndarray]) – Bloch vector determining phase-shift at periodic boundaries.
mu (float) – additional chemical potential.
Bz (float) – additional Bz field.
- dot(v: ndarray, out: ndarray) ndarray [source]
Calculate the scalar product of H.
A simple way of understanding how this dot product is performed is by thinking of a 1D chain with nn hopping -1 and considering H*v. Here the translation of the bond is 1 (to the right or to the left) and, given a certain vector v, we have
\[\begin{split}H \cdot v = \begin{pmatrix} 0 & -1 & 0 & 0 \\ -1 & 0 & -1 & 0 \\ 0 & -1 & 0 & -1 \\ 0 & 0 & -1 & 0 \\ \end{pmatrix} \cdot \begin{pmatrix} v_1 \\ v_2 \\ v_3 \\ v_4 \end{pmatrix} = -1 \begin{pmatrix} v_2 \\ v_3 \\ v_4 \\ 0 \end{pmatrix} -1 \begin{pmatrix} 0 \\ v_1 \\ v_2 \\ v_3 \end{pmatrix}\end{split}\]where we can clearly see that the first vector is the contribution of the hopping to the right and the second, the one of the hopping to the left. To determine the contribution of each bond to the dot product, one has to simply apply the corresponding translation (separately for back and forth hopping) and accumulate the result. This has to be done for each dimension separately, but it is as simple as reshaping the vector v to have the shape (x, y, z, uc) and applying the translations in the corresponding direction. The uc dimension is kept as is and dotted directly into the bond associated matrices.
- Parameters:
v (np.ndarray) – vector to dot the Hamiltonian into.
out (np.ndarray) – preallocated output array.
- Returns:
Dot product of H with v
- Return type:
np.ndarray
- _abc_impl = <_abc._abc_data object>
- _dot_scaling(v: ndarray, out: ndarray) ndarray
Dot product including scaling.
This dot product is needed for evaluating moments of quantities that have not been yet implemented in the lattice solver.
- Parameters:
v (np.ndarray) – Vector to dot.
out (np.ndarray) – preallocated output array.
- Returns:
Dot product of H with v.
- Return type:
np.ndarray
- _get_DOS_moments(NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of the density of states.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the density of states
- Return type:
np.ndarray
- _get_conductivity_moments(tensor_element: str, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of the conductivity.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Moments associated with the conductivity
- Return type:
np.ndarray
- _get_expectation_value_moments(A: Callable, expectation_value_dtype: type, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of an operator’s expectation value.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
A (Callable) – Linear operator.
expectation_value_dtype (type) – dtype of the linear operator.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the expectation value of operator A.
- Return type:
np.ndarray
- _set_cheby(force_complex: bool = False) None
Set the chebyshev object.
- Parameters:
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- _set_scaling_and_cheby(lower_spectral_bound: float = -1, upper_spectral_bound: float = 1, delta: float = 0, force_complex: bool = False) None
Set the scaling and corresponding chebyshev objects.
- Parameters:
lower_spectral_bound (float) – Lower bound of the spectral range. Defaults to -1.
upper_spectral_bound (float) – Upper bound of the spectral range. Defaults to 1.
delta (float) – Spectral buffer for Hamiltonian scaling.
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- property dtype: Type
Dtype convenience function.
- Returns:
complex or float depending on the flag is_complex
- Return type:
Type
- generateSelector(what: str = 'all') ndarray
Generate selector given a certain input configuration.
- Parameters:
what (str) – input configuration.
- Returns:
array composed of 1’s and 0’s selecting the correct sublattice.
- Return type:
np.ndarray
- Raises:
ValueError – if the argument ‘what’ is invalid.
Warning
RuntimeWarning: if the selection is inconsistent with the system and a default choice is made.
- getBoundsLanczos(Order: int, tolerance: float = 1e-11) ndarray
Get spectrum boundaries for the current Hamiltonian with the Lanczos method.
- Parameters:
Order (int) – Order of the Lanczos expansion
tolerance (float) – Tolerance for the expansion. Defaults to 1e-11.
- Returns:
Boundaries of the spectrum.
- Return type:
np.ndarray
- getCarrierDensity(dos: ndarray, w: ndarray, mu: float, T: float) float
Calculate the carrier density.
The calculation is performed by integrating the DoS time the occupation for frequencies larger than the chemical potential and normalizing this by the system’s volume. The formula reads:
\[n = \frac{1}{\Omega} \int\limits_{-\infty}^{\mu} f(E-\mu) \rho(E)\]where \(\Omega\) is the total volume, \(\mu\) is the chemical potential, f is the fermi function and \(\rho(E)\) is the density of states.
- Parameters:
dos (np.ndarray) – Density of states.
w (np.ndarray) – Energies for which the DOS is defined.
mu (float) – Chemical potential.
T (float) – Temperature.
- Raises:
ValueError – If dos and w are not compatible.
- Returns:
Carrier density in \(Å^{-D}\) with D the dimensionality of the system.
- Return type:
float
- getChargeSusceptibility(T: float, mu: float, dos: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1) float
Calculate the linear DC electric charge susceptibility.
This is equal to
\[\chi_e = \frac{2 \pi}{\Omega} \frac{\partial N}{\partial \mu}\]where \(\Omega\) is the total volume, N is the number of particles and \(\mu\) the chemical potential.
The routine simply computes the numerical derivative of the number of particles with respect to the chemical potential as an average of energies close to it.
TODO: add possibility to select sublattices, if deemed useful
- Parameters:
T (float) – Temperature.
mu (float) – Chemical potential.
dos (Optional[np.ndarray]) – precoumputed DoS.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
- Raises:
ValueError – if the input is not consistent.
- Returns:
static charge susceptibility of the system.
- Return type:
float
- getConductivity(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculates the conductivity of the system from the Kubo-Greenwood formula.
This routine follows the method presented in https://doi.org/10.1016/j.physrep.2020.12.001
In short: a Chebyshev expansion of the zero temperature Kubo formula is performed. This translates into the expansion of the function \(\delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H})\) \(\hat{V}_{\beta}\), where \(E\) is the energy, \(\hat{H}\) is the Hamiltonian and \(\hat{V}\) is the velocity operator in the direction \(\alpha\,{\rm and }\,\beta\). The conductivity reads
\[\sigma(E) = \frac{\pi \hbar e^2}{\Omega} {\rm Tr}\left[ \delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H}) \right]\]The temperature dependent result is obtained by simply convolving the zero temperature result by a ‘Fermi window’, i.e. minus the derivative of the Fermi function with respect to the energy.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getConductivityMu(tensor_element: str, NSamples: int, Order: int, mu: float | ndarray, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex | ndarray
Calculates the conductivity of the system defined by H at a single chemical potential.
Given a Hamiltonian, the corresponding conductivity can be calculated as
\[\sigma(\mu) = \frac{\pi \Omega}{\Delta E^2} \braket{\phi^L|\phi^R}\]where \(\Omega\) is the volume of the system, \(\Delta E\) is the scaling applied to the Hamiltonian to ensure the spectrum lies within (-1, 1) and the vectors \(\phi\) are
\[ \begin{align}\begin{aligned}\ket{\phi^L} = \sum_n Im[G^+_n(\mu)] T_n(\tilde{H}) V \ket{r}\\\ket{\phi^R} = \sum_n Im[G^+_n(\mu)] V T_n(\tilde{H}) \ket{r}\end{aligned}\end{align} \]where \(\ket{r}\) is the random vector, \(V\) is the velocity operator, \(G^+_n\) is the n-th GF coefficient and \(T_n(\tilde{H})\) is the m-th Chebyshev polynomial.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
mu (Union[float, np.ndarray]) – Energy(ies) (as in chemical potential) at which to evaluate the conductivity.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the DOS.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity at the specified chemical potential(s).
- Return type:
qt.fl_cmplx_or_ndarr
- getConductivityOptical(tensor_element: str, T: float, mu: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray]
Calculates the complex optical conductivity of the system.
In short: a Chebyshev expansion of the Kubo formula is performed. The procedure is similar to the one presented in https://journals.aps.org/prb/abstract/10.1103/PhysRevB.94.235405
Details on the routine can be found in the internal notes. In particular, eq. 32 of the notes is implemented.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
mu (float) – Chemical potential.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getConductivity_KB(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray]
Calculates the conductivity of the system evaluating the Kubo-Bastin formula.
This routine follows the method presented in https://doi.org/10.1103/PhysRevLett.114.116602
In short: a Chebyshev expansion of the Kubo-Bastin formula is performed. This translates into the expansion of the function:
\[v_\alpha \delta(\varepsilon - \hat{H}) \hat{v}_\beta \frac{dG^+(\varepsilon)} {d\varepsilon} - \hat{v}_\alpha \frac{dG^-(\varepsilon)}{d\varepsilon} \hat{v}_\beta \delta(\varepsilon - \hat{H})\]where \(\varepsilon\) is the energy, \(\hat{H}\) is the Hamiltonian, \(\hat{v}\) is the velocity operator and \(\alpha, \beta\) indicate the direction. The modus operandi is exactly the same as for the other conductivity calculations based on the Chebyshev expansion.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getDOS(NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculates DoS through stochastic averaging of Chebyshev expansion.
This density of states integrates to 1, i.e. it is defined as:
\[\rho(E) = \frac{1}{N} \sum\limits_i \delta(E - E_i) = \frac{1}{N} {\rm Tr} \left[ \delta(E - \hat{H}) \right]\]with \(E_i\) the eigenvalues of the Hamiltonian and N the number of orbitals.
More details on the calculation are readily available in the literature. For example: https://doi.org/10.1016/j.physrep.2020.12.001
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of frequencies to evaluate the DoS at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
DoS and corresponding frequencies.
- Return type:
tuple
- getExpectationValue(A: Callable, dtype: type, T: float, mu: float, NSamples: int, Order: int, NPadeFreq: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex
Calculates the expectation value of an operator through Chebyshev expansion.
This is done by performing the Chebyshev expansion of
\[\langle \hat{A} \rangle = {\rm Tr} \left[ \hat{A} f(\hat{H}) \right]\]where \(\hat{A}\) is the operator, \(\hat{H}\) is the hamiltonian and f is the fermi function. This expression is expanded in terms of Chebyshev polynomials. The integral over the energies is performed via the resummation of the Fermi-Pade’ expansion of the Fermi function.
- Parameters:
A (Callable) – Linear operator.
dtype (type) – dtype of the linear operator.
T (float) – temperature in Kelvins. Must be greater than 0.
mu (float) – chemical potential.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NPadeFreq (int) – Number of Pade frequencies to evaluate the approximation to the Fermi function.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if temperature is too small.
- Returns:
expectation value of operator A.
- Return type:
Union[float, complex]
- getGF(selector: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | bytes | _NestedSequence[bool | int | float | complex | str | bytes], Order: int, NOmegas: int, NSamplesDis: int = 1, verbose: int = 2, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculate the retarded Green’s Function in the real space basis.
This calculation is performed the same way as for the DOS, the only difference being the states used for evaluating the moments: in this case we directly use the real space basis.
- Parameters:
selector (Union[str, ArrayLike]) – specifies what to compute (‘diag’, ‘full’, or array of row-column pairs)
Order (int) – Order of the Chebyshev expansion.
NOmegas (int) – Number of frequencies to evaluate.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
GF and corresponding frequencies.
- Return type:
tuple[np.ndarray, np.ndarray]
- getH() csr_array
Getter function for Hamiltonian in sparse format.
- Returns:
Hamiltonian matrix in sparse row format.
- Return type:
csr_array
- Raises:
RuntimeError – if the Hamiltonian is not available.
- getLinearResponse(A: Callable, P: Callable, dtype: type, T: float, mu: float, NSamples: int, Order: int, NPadeFreq: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex
Calculates the static linear response of an observable to a perturbation.
This is done by expanding
\[\chi^A_P = \frac{2 \pi}{\Omega} \frac{\partial \langle \hat{A} \rangle}{\partial \varepsilon}\]where \(\hat{A}\) is the observable, \(\hat{P}\) the perturbation and \(\varepsilon\) its strength, i.e. the perturbation enters the Hamiltonian as \(\hat{H}' = \varepsilon \hat{P}\) with \(\varepsilon << 1\).
- Parameters:
A (Callable) – Linear operator associated with the observable.
P (Callable) – Perturbation in linear operator form.
dtype (type) – dtype of the linear operators.
T (float) – temperature in Kelvins. Must be greater than 0.
mu (float) – chemical potential.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NPadeFreq (int) – Number of Pade frequencies to evaluate the approximation to the Fermi function.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if temperature is too small.
- Returns:
expectation value of operator A.
- Return type:
Union[float, complex]
- getMagneticSusceptibility(T: float, mu: float, dos_u: ndarray | None = None, dos_d: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1) float
Calculate the linear static magnetic susceptibility.
This is equal to
\[\chi_m = \frac{2 \pi}{\Omega} \frac{\partial S_z}{\partial B_z}\]where \(\Omega\) is the total volume, \(S_z\) is the spin operator in the z direction and \(B_z\) the magnetic field.
The routine simply computes the numerical derivative of the spin expectation value with respect to the applied B field.
TODO: add possibility to select sublattices, if deemed useful
- Parameters:
T (float) – Temperature.
mu (float) – Chemical potential.
dos_u (Optional[np.ndarray]) – precoumputed DoS of spin up electrons.
dos_d (Optional[np.ndarray]) – precoumputed DoS of spin down electrons.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
- Raises:
ValueError – if the input is not consistent.
- Returns:
static magnetic susceptibility of the system.
- Return type:
float
- getMu(T: float, dos: ndarray | None = None, w: ndarray | None = None, NSamples: int | None = None, Order: int | None = None, NOmegas: int | None = None, NSamplesDis: int = 1, verbose: int = 2) float
Calculate the chemical potential.
We calculate the chemical potential as the \(\mu\) which satisfies
\[N = \int\limits dE f(E-\mu) \rho(E)\]where \(N\) is the number of particles in the system, f is the fermi function and \(\rho(E)\) is the density of states.
In the case of BCS systems, the DOS depends on the chemical potential. This is therefore calculated for every chemical potential and the corresponding number of particles is obtained. A bisection is used starting from the boundaries of the Hamiltonian and honing in on the chemical potential resulting in a number of particles closest to the desired one. Starting from the two values giving slightly more and slightly less particles than needed, a linear extrapolation is finally performed to approximate the energy that results in the occupation closest to the desired one.
TODO: it is probably better to split this calculation in the “one-shot” version and the self-consistent one, suitable for BCS systems.
- Parameters:
T (float) – Temperature.
dos (Optional[np.ndarray]) – precoumputed DoS. Will be the 1st one to be used in the BCS case.
w (Optional[np.ndarray]) – frequencies of the precomputed DoS.
NSamples (Optional[int]) – Number of stochastic samples for the DoS calculation.
Order (Optional[int]) – Order of the Chebyshev expansion for the DoS calculation.
NOmegas (Optional[int]) – Number of frequencies for the DoS calculation.
NSamplesDis (int) – Number of disorder configurations for the DoS calculation.
verbose (int) – controls the verbosity of the method.
- Raises:
ValueError – if the input is not consistent.
- Returns:
Chemical potential.
- Return type:
float
- getOperator(operator: str) tuple[Callable, type]
Provide basic operators.
- Operators available:
±number operator and its left version
±spin operator and its left version
±position and its left version
- Parameters:
operator (str) – operator to be returned.
- Raises:
NotImplementedError – if the requested operator has not been implemented.
- Returns:
- tuple contining the operator as a callable acting on an input
array and the dtype of the operator.
- Return type:
tuple[Callable, type]
- getSpectral(num_kpoints: float, Order: int, NOmegas: int, NSamplesDis: int = 1, verbose: int = 2, eWindow: list | ndarray | None = None) tuple
Calculate the spectral function.
This calculation is performed the same way as for the GF, the only difference being the states used for evaluating the moments: in this case we directly use the Bloch functions. The band structure is then simply \(-\operatorname{Im}[G_{kk}]/\pi\) for k’s along the correct k path.
- Parameters:
num_kpoints (float) – number of kpoints for the spectral function calculation.
Order (int) – Order of the Chebyshev expansion.
NOmegas (int) – Number of frequencies to evaluate.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
spectral function, frequencies and corresponding k-path information.
- Return type:
tuple
- getTrResolvent(NSamples: int, Order: int, rescale: bool = True, use_KPM: bool = True, verbose: int = 2, selector: ndarray | None = None) Callable
Returns a function evaluating the trace of the resolvent.
This method computes the Chebyshev moments for a given order and given number of stochastic samples to evaluate the trace. Can be used to evaluate the trace of the resolvent,
\[\mathrm{Tr} \left[ \frac{1}{z - \hat{H}} \right]\]for a given ‘frequency’ \(z\) without the need to recompute the Chebyshev expansion. This is useful if it is not a priori clear on how many frequencies the trace of the resolvent needs to be evaluated.
The trace of the resolvent will be evaluated at the given frequencies. For real frequencies the retarded resolvent is chosen.
NOTE: The trace is estimated as the average over all (normalized) stochastic samples. Hence, multiply the result by the linear size of the Hamiltonian to get the “true” estimate for the trace.
NOTE: If the number of samples is larger that the size of the selected subspace, the trace is computed exactly (apart from the normalization, see above).
- Parameters:
NSamples (int) – Number of stochastic samples to approximate the trace.
Order (int) – Order of the Chebyshev expanbsion to approximate the resolvent.
rescale (bool) – Whether generated function transforms input into interval (-1, 1). Defaults to True.
use_KPM (bool) – Flag controlling the use of KPM.
verbose (int) – Controls verbosity of output and warnings. Defaults to 2.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Returns:
Function evaluating the trace of the resolvent for a given frequency.
- Return type:
Callable
- parseDisDict(parse_dict: dict) None
Parse disorder input dictionary.
The disorder dictionary specifies the properties of the disorder:
type: kind of disorder, e.g. onsite (only type implemented for now).
distribution: random distribution of disorder potential.
sigma: standard deviation of the disorder distribution.
avg: mean of distribution.
Note
This will become obsolete with the introduction of a Schema for the disDict.
- Parameters:
parse_dict (dict) – Dictionary containing information about the disorder.
- Raises:
ValueError – if the dictionary cannot be parsed
- scale2real(x: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr
Apply scaling to transform scaled frequencies to real ones.
- Parameters:
x (qt.fl_cmplx_or_ndarr) – array of scaled energies within (-1, 1).
- Returns:
Real energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- scale2transformed(z: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr
Apply scaling to transform real frequencies to scaled ones.
- Parameters:
z (qt.fl_cmplx_or_ndarr) – real energies array.
- Returns:
Scaled energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- scaleH(delta: float = 0.1, LanczOrder: int | None = None, energyBounds: list | ndarray | None = None) None
Rescale Hamiltonian to have spectrum between -1 and 1.
- Parameters:
delta (float) – Controls the extra compression of the band. This will be rescaled to be (-1 + delta/2, 1 - delta/2). Defaults to 0.1.
LanczOrder (Optional[int]) – Order of the Lanczos expansion used to determine the bandwidth. Cannot be set together with energyBounds.
energyBounds (Optional[Union[list, np.ndarray]]) – lower and upper energy boundaries to determine scaling. Cannot be set together with LanczOrder.
- Raises:
ValueError – If delta is not in (0, 2).
ValueError – If both LanczOrder and energyBounds are set.
- scaleH_inv() None
Rescale Hamiltonian to have original spectrum.
- scrambleW() None
Function that scrambles the disorder vector.
- todense() ndarray
Getter function for Hamiltonian in dense format.
- Returns:
Hamiltonian matrix in dense format.
- Return type:
np.ndarray
- lb: LB
- is_spinflip: bool
- disDict: dict
- disLocPot: np.ndarray
- scaling: lsc.chebyshev_scaling
- chebyshev: lsc.chebyshev
- dim: int
- realDim: int
- velocity_operator: tuple[Callable, Callable, Callable] | None
- total_volume: float
- is_complex: bool
Linear Operator Hamiltonian
Hamiltonian classe implementation for large systems.
Copyright © 2019-2023 HQS Quantum Simulations GmbH. All Rights Reserved.
- class qolossal.Hamiltonian_LO.HamiltonianLinearOperator(linearOp: Callable, dim: int, dtype: Type, total_volume: float, velocity_times_hbar_operator: tuple[Callable, Callable, Callable] | None = None, disDict: dict | None = None)[source]
Bases:
Hamiltonian
Hamiltonian implementation via directly providing the linear operator.
Initialization of the Hamiltonian class based on a linear operator.
IMPORTANT: the linear operator provided should have the following signature: linearOp(x: np.ndarray, res: np.ndarray) -> np.ndarray, where x and res are the input and output arrays. The linear operator sohuld support both shapes (dim, ) or (dim, 1) for the input and output arrays.
- Parameters:
linearOp (Callable) – Linear operator associated with the application of the Hamiltonian.
dim (int) – Total size fo the system.
dtype (Type) – dtype of the system.
total_volume (float) – total volume of the system.
velocity_times_hbar_operator (Optional[tuple[Callable, Callable, Callable]]) – velocity operator times ℏ in the x, y and z direction.
disDict (Optional[dict]) – dictionary specifying the disorder.
- __init__(linearOp: Callable, dim: int, dtype: Type, total_volume: float, velocity_times_hbar_operator: tuple[Callable, Callable, Callable] | None = None, disDict: dict | None = None) None [source]
Initialization of the Hamiltonian class based on a linear operator.
IMPORTANT: the linear operator provided should have the following signature: linearOp(x: np.ndarray, res: np.ndarray) -> np.ndarray, where x and res are the input and output arrays. The linear operator sohuld support both shapes (dim, ) or (dim, 1) for the input and output arrays.
- Parameters:
linearOp (Callable) – Linear operator associated with the application of the Hamiltonian.
dim (int) – Total size fo the system.
dtype (Type) – dtype of the system.
total_volume (float) – total volume of the system.
velocity_times_hbar_operator (Optional[tuple[Callable, Callable, Callable]]) – velocity operator times ℏ in the x, y and z direction.
disDict (Optional[dict]) – dictionary specifying the disorder.
- is_complex: bool
- total_volume: float
- realDim: int
- dim: int
- velocity_operator: tuple[Callable, Callable, Callable] | None
- dot(v: ndarray, out: ndarray) ndarray [source]
Calculate the scalar product of H.
- Parameters:
v (np.ndarray) – vector to dot the Hamiltonian into.
out (np.ndarray) – preallocated output array.
- Returns:
Dot product of H with v
- Return type:
np.ndarray
- generateSelector(what: str = 'all') ndarray [source]
Generate selector given a certain input configuration.
- Parameters:
what (str) – input configuration.
- Returns:
array composed of 1’s and 0’s selecting the correct sublattice.
- Return type:
np.ndarray
- Raises:
ValueError – if the argument ‘what’ is invalid.
- _abc_impl = <_abc._abc_data object>
- _dot_scaling(v: ndarray, out: ndarray) ndarray
Dot product including scaling.
This dot product is needed for evaluating moments of quantities that have not been yet implemented in the lattice solver.
- Parameters:
v (np.ndarray) – Vector to dot.
out (np.ndarray) – preallocated output array.
- Returns:
Dot product of H with v.
- Return type:
np.ndarray
- _get_DOS_moments(NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of the density of states.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the density of states
- Return type:
np.ndarray
- _get_conductivity_moments(tensor_element: str, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of the conductivity.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Moments associated with the conductivity
- Return type:
np.ndarray
- _get_expectation_value_moments(A: Callable, expectation_value_dtype: type, NSamples: int, Order: int, NSamplesDis: int, verbose: int, selector: ndarray) ndarray
Calculates the moments of the Chebyshev expansion of an operator’s expectation value.
Only meant for internal and expert usage. This method does not implement any failsafe mechanism or consistency checks.
- Parameters:
A (Callable) – Linear operator.
expectation_value_dtype (type) – dtype of the linear operator.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (np.ndarray) – selects a sublattice of interest for the calculation.
- Returns:
Moments associated with the expectation value of operator A.
- Return type:
np.ndarray
- _set_cheby(force_complex: bool = False) None
Set the chebyshev object.
- Parameters:
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- _set_scaling_and_cheby(lower_spectral_bound: float = -1, upper_spectral_bound: float = 1, delta: float = 0, force_complex: bool = False) None
Set the scaling and corresponding chebyshev objects.
- Parameters:
lower_spectral_bound (float) – Lower bound of the spectral range. Defaults to -1.
upper_spectral_bound (float) – Upper bound of the spectral range. Defaults to 1.
delta (float) – Spectral buffer for Hamiltonian scaling.
force_complex (bool) – Flag for forcing complex chebyshev objects. Defaults to False.
- property dtype: Type
Dtype convenience function.
- Returns:
complex or float depending on the flag is_complex
- Return type:
Type
- getBoundsLanczos(Order: int, tolerance: float = 1e-11) ndarray
Get spectrum boundaries for the current Hamiltonian with the Lanczos method.
- Parameters:
Order (int) – Order of the Lanczos expansion
tolerance (float) – Tolerance for the expansion. Defaults to 1e-11.
- Returns:
Boundaries of the spectrum.
- Return type:
np.ndarray
- getConductivity(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculates the conductivity of the system from the Kubo-Greenwood formula.
This routine follows the method presented in https://doi.org/10.1016/j.physrep.2020.12.001
In short: a Chebyshev expansion of the zero temperature Kubo formula is performed. This translates into the expansion of the function \(\delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H})\) \(\hat{V}_{\beta}\), where \(E\) is the energy, \(\hat{H}\) is the Hamiltonian and \(\hat{V}\) is the velocity operator in the direction \(\alpha\,{\rm and }\,\beta\). The conductivity reads
\[\sigma(E) = \frac{\pi \hbar e^2}{\Omega} {\rm Tr}\left[ \delta(E - \hat{H}) \hat{V}_{\alpha} \delta(E - \hat{H}) \right]\]The temperature dependent result is obtained by simply convolving the zero temperature result by a ‘Fermi window’, i.e. minus the derivative of the Fermi function with respect to the energy.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getConductivityMu(tensor_element: str, NSamples: int, Order: int, mu: float | ndarray, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex | ndarray
Calculates the conductivity of the system defined by H at a single chemical potential.
Given a Hamiltonian, the corresponding conductivity can be calculated as
\[\sigma(\mu) = \frac{\pi \Omega}{\Delta E^2} \braket{\phi^L|\phi^R}\]where \(\Omega\) is the volume of the system, \(\Delta E\) is the scaling applied to the Hamiltonian to ensure the spectrum lies within (-1, 1) and the vectors \(\phi\) are
\[ \begin{align}\begin{aligned}\ket{\phi^L} = \sum_n Im[G^+_n(\mu)] T_n(\tilde{H}) V \ket{r}\\\ket{\phi^R} = \sum_n Im[G^+_n(\mu)] V T_n(\tilde{H}) \ket{r}\end{aligned}\end{align} \]where \(\ket{r}\) is the random vector, \(V\) is the velocity operator, \(G^+_n\) is the n-th GF coefficient and \(T_n(\tilde{H})\) is the m-th Chebyshev polynomial.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
mu (Union[float, np.ndarray]) – Energy(ies) (as in chemical potential) at which to evaluate the conductivity.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the DOS.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity at the specified chemical potential(s).
- Return type:
qt.fl_cmplx_or_ndarr
- getConductivityOptical(tensor_element: str, T: float, mu: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray]
Calculates the complex optical conductivity of the system.
In short: a Chebyshev expansion of the Kubo formula is performed. The procedure is similar to the one presented in https://journals.aps.org/prb/abstract/10.1103/PhysRevB.94.235405
Details on the routine can be found in the internal notes. In particular, eq. 32 of the notes is implemented.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
mu (float) – Chemical potential.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getConductivity_KB(tensor_element: str, T: float, NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None, NOmegasInt: int | None = None) tuple[ndarray, ndarray]
Calculates the conductivity of the system evaluating the Kubo-Bastin formula.
This routine follows the method presented in https://doi.org/10.1103/PhysRevLett.114.116602
In short: a Chebyshev expansion of the Kubo-Bastin formula is performed. This translates into the expansion of the function:
\[v_\alpha \delta(\varepsilon - \hat{H}) \hat{v}_\beta \frac{dG^+(\varepsilon)} {d\varepsilon} - \hat{v}_\alpha \frac{dG^-(\varepsilon)}{d\varepsilon} \hat{v}_\beta \delta(\varepsilon - \hat{H})\]where \(\varepsilon\) is the energy, \(\hat{H}\) is the Hamiltonian, \(\hat{v}\) is the velocity operator and \(\alpha, \beta\) indicate the direction. The modus operandi is exactly the same as for the other conductivity calculations based on the Chebyshev expansion.
NOTE: the output of this routine is in units of \(e^2/(h Å^{(D-2)})\) with D the dimensionality of the system and does NOT include any spin- degeneracy coefficients for spinless systems.
- Parameters:
tensor_element (str) – specifies which element of the conductivity tensor to calculate, as literal, e.g. ‘xx’.
T (float) – Temperature in Kelvins.
NSamples (int) – Number of stochastic samples for the calculation of the conductivity.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of energies to evaluate the conductivity at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine. Defaults to 1.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
NOmegasInt (Optional[int]) – number of frequencies to use to calculate the E integral.
- Raises:
ValueError – if the velocity operator is not set for the current object.
- Returns:
Conductivity and corresponding frequencies.
- Return type:
tuple
- getDOS(NSamples: int, Order: int, NOmegas: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculates DoS through stochastic averaging of Chebyshev expansion.
This density of states integrates to 1, i.e. it is defined as:
\[\rho(E) = \frac{1}{N} \sum\limits_i \delta(E - E_i) = \frac{1}{N} {\rm Tr} \left[ \delta(E - \hat{H}) \right]\]with \(E_i\) the eigenvalues of the Hamiltonian and N the number of orbitals.
More details on the calculation are readily available in the literature. For example: https://doi.org/10.1016/j.physrep.2020.12.001
- Parameters:
NSamples (int) – Number of stochastic samples for the calculation of the DoS.
Order (int) – Order of the Chebyshev expansion used for the calculation
NOmegas (int) – Number of frequencies to evaluate the DoS at. Defaults to 101.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
DoS and corresponding frequencies.
- Return type:
tuple
- getExpectationValue(A: Callable, dtype: type, T: float, mu: float, NSamples: int, Order: int, NPadeFreq: int = 101, NSamplesDis: int = 1, verbose: int = 2, selector: ndarray | None = None) float | complex
Calculates the expectation value of an operator through Chebyshev expansion.
This is done by performing the Chebyshev expansion of
\[\langle \hat{A} \rangle = {\rm Tr} \left[ \hat{A} f(\hat{H}) \right]\]where \(\hat{A}\) is the operator, \(\hat{H}\) is the hamiltonian and f is the fermi function. This expression is expanded in terms of Chebyshev polynomials. The integral over the energies is performed via the resummation of the Fermi-Pade’ expansion of the Fermi function.
- Parameters:
A (Callable) – Linear operator.
dtype (type) – dtype of the linear operator.
T (float) – temperature in Kelvins. Must be greater than 0.
mu (float) – chemical potential.
NSamples (int) – Number of stochastic samples.
Order (int) – Order of the Chebyshev expansion used for the calculation
NPadeFreq (int) – Number of Pade frequencies to evaluate the approximation to the Fermi function.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – controls verbosity of output and warnings.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Raises:
ValueError – if temperature is too small.
- Returns:
expectation value of operator A.
- Return type:
Union[float, complex]
- getGF(selector: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | bytes | _NestedSequence[bool | int | float | complex | str | bytes], Order: int, NOmegas: int, NSamplesDis: int = 1, verbose: int = 2, eWindow: list | ndarray | None = None) tuple[ndarray, ndarray]
Calculate the retarded Green’s Function in the real space basis.
This calculation is performed the same way as for the DOS, the only difference being the states used for evaluating the moments: in this case we directly use the real space basis.
- Parameters:
selector (Union[str, ArrayLike]) – specifies what to compute (‘diag’, ‘full’, or array of row-column pairs)
Order (int) – Order of the Chebyshev expansion.
NOmegas (int) – Number of frequencies to evaluate.
NSamplesDis (int) – Number of disorder configurations to average over.
verbose (int) – verbosity of routine.
eWindow (Optional[Union[list, np.ndarray]]) – energy window for the result.
- Returns:
GF and corresponding frequencies.
- Return type:
tuple[np.ndarray, np.ndarray]
- getTrResolvent(NSamples: int, Order: int, rescale: bool = True, use_KPM: bool = True, verbose: int = 2, selector: ndarray | None = None) Callable
Returns a function evaluating the trace of the resolvent.
This method computes the Chebyshev moments for a given order and given number of stochastic samples to evaluate the trace. Can be used to evaluate the trace of the resolvent,
\[\mathrm{Tr} \left[ \frac{1}{z - \hat{H}} \right]\]for a given ‘frequency’ \(z\) without the need to recompute the Chebyshev expansion. This is useful if it is not a priori clear on how many frequencies the trace of the resolvent needs to be evaluated.
The trace of the resolvent will be evaluated at the given frequencies. For real frequencies the retarded resolvent is chosen.
NOTE: The trace is estimated as the average over all (normalized) stochastic samples. Hence, multiply the result by the linear size of the Hamiltonian to get the “true” estimate for the trace.
NOTE: If the number of samples is larger that the size of the selected subspace, the trace is computed exactly (apart from the normalization, see above).
- Parameters:
NSamples (int) – Number of stochastic samples to approximate the trace.
Order (int) – Order of the Chebyshev expanbsion to approximate the resolvent.
rescale (bool) – Whether generated function transforms input into interval (-1, 1). Defaults to True.
use_KPM (bool) – Flag controlling the use of KPM.
verbose (int) – Controls verbosity of output and warnings. Defaults to 2.
selector (Optional[np.ndarray]) – selects a sublattice of interest for the calculation.
- Returns:
Function evaluating the trace of the resolvent for a given frequency.
- Return type:
Callable
- parseDisDict(parse_dict: dict) None
Parse disorder input dictionary.
The disorder dictionary specifies the properties of the disorder:
type: kind of disorder, e.g. onsite (only type implemented for now).
distribution: random distribution of disorder potential.
sigma: standard deviation of the disorder distribution.
avg: mean of distribution.
Note
This will become obsolete with the introduction of a Schema for the disDict.
- Parameters:
parse_dict (dict) – Dictionary containing information about the disorder.
- Raises:
ValueError – if the dictionary cannot be parsed
- scale2real(x: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr
Apply scaling to transform scaled frequencies to real ones.
- Parameters:
x (qt.fl_cmplx_or_ndarr) – array of scaled energies within (-1, 1).
- Returns:
Real energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- scale2transformed(z: fl_cmplx_or_ndarr) fl_cmplx_or_ndarr
Apply scaling to transform real frequencies to scaled ones.
- Parameters:
z (qt.fl_cmplx_or_ndarr) – real energies array.
- Returns:
Scaled energies array.
- Return type:
qt.fl_cmplx_or_ndarr
- scaleH(delta: float = 0.1, LanczOrder: int | None = None, energyBounds: list | ndarray | None = None) None
Rescale Hamiltonian to have spectrum between -1 and 1.
- Parameters:
delta (float) – Controls the extra compression of the band. This will be rescaled to be (-1 + delta/2, 1 - delta/2). Defaults to 0.1.
LanczOrder (Optional[int]) – Order of the Lanczos expansion used to determine the bandwidth. Cannot be set together with energyBounds.
energyBounds (Optional[Union[list, np.ndarray]]) – lower and upper energy boundaries to determine scaling. Cannot be set together with LanczOrder.
- Raises:
ValueError – If delta is not in (0, 2).
ValueError – If both LanczOrder and energyBounds are set.
- scaleH_inv() None
Rescale Hamiltonian to have original spectrum.
- scrambleW() None
Function that scrambles the disorder vector.
- disDict: dict
- disLocPot: np.ndarray
- scaling: lsc.chebyshev_scaling
- chebyshev: lsc.chebyshev
Transport Properties
Methods for the calculation of transport properties.
Provided functions:
getMobility: for the calculation of the carrier mobility.
getDiffusion: for the calculation of the diffusion coefficient.
Copyright © 2019-2023 HQS Quantum Simulations GmbH. All Rights Reserved.
- qolossal.transport_properties.getMobility(conductivity: float, carrier_density: float) float [source]
Calculate electron mobility.
The electron (or hole) mobility \(\mu_{e,h}\) is defined from
\[\sigma = e n_{e,h} \mu_{e,h}\]where \(\sigma\) is the conductivity, \(e\) is the electron charge and \(n_{e,h}\) is the carrier density.
The units of the results depend on the input units. For the moment it is assumed the input units are Angstroms for lengths and electronvolts for energies.
NOTE: this routine is sensible to the value of the inputs. Especially for cases where sharp spectral features are present around the chemical potential, the calculation of the conductivity (especially at low temperatures) might be hard to converge.
- Parameters:
conductivity (float) – Conductivity evaluated at the chemical potential.
carrier_density (float) – Carrier density at the given chemical potential.
- Returns:
electron mobility in cm^2/Vs.
- Return type:
float
- qolossal.transport_properties.getDiffusion(dos: float_or_ndarray, conductivity: float_or_ndarray, total_volume: float, system_linear_size: int) float_or_ndarray [source]
Calculate the diffusion coefficient.
The diffusion coefficient D is defined from
\[\sigma(E) = e^2 \rho(E) D(E)\]\(\sigma\) is the conductivity, \(e\) is the electron charge and \(\rho\) is the density of states.
The units of the results depend on the input units. For the moment it is assumed the input units are angstroms for lengths and electronvolts for energies.
NOTE: this routine is sensible to the value of the inputs. Especially for cases where sharp spectral features are present around the chemical potential, the calculation of the conductivity (especially at low temperatures) might be hard to converge.
- Parameters:
dos (float_or_ndarray) – Density of states (integrating to 1) evalauted at a single energy or at multiple energies.
conductivity (float_or_ndarray) – Conductivity evaluated at the same energy(ies) as the dos.
total_volume (float) – total volume of the system.
system_linear_size (int) – total linear size of the system.
- Returns:
- diffusion coefficients at the same energy(ies) of the provided input in
units of Å^D/s.
- Return type:
float_or_ndarray
Optical Properties
Methods for the calculation of optical properties.
Provided functions:
getPermittivity_1D(2D, 3D): for the calculation of the permittivity from the complex conductivity for 1-, 2- and 3D systems.
getReflectivity: for the calculation of the reflectivity from the permittivity via the permittivity, calculated with the first convenience function.
getAbsorptionCoefficient: for the calculation of the absorption coefficient from the permittivity, via the extinction coefficient, i.e. imaginary part of the refractive index.
Copyright © 2019-2023 HQS Quantum Simulations GmbH. All Rights Reserved.
- qolossal.optical_properties.getPermittivity_3D(conductivity: ndarray, w: ndarray, tensor_element: str) ndarray [source]
Compute the permittivity for 3D systems.
The permittivity is calculated directly from the complex optical conductivity. By manipulating the Maxwell’s equations, trying to express the quantities as a function of external fields only, one can find
\[\varepsilon_{\alpha \beta}(\omega) = \delta_{\alpha \beta} + \frac{i \sigma(\omega)}{\varepsilon_0 \omega}\]Reference: https://en.wikipedia.org/wiki/Ewald%E2%80%93Oseen_extinction_theorem
- Parameters:
conductivity (np.ndarray) – Complex conductivity in units of e^2/(h Å).
w (np.ndarray) – Frequencies at which the conductivity has been evaluated.
tensor_element (str) – Tensor element of the provided conductivity.
- Raises:
ValueError – if the passed frequencies contain values too close to zero.
- Returns:
specified tensor element of the permittivity at the provided frequencies.
- Return type:
np.ndarray
- qolossal.optical_properties.getPermittivity_2D(conductivity: ndarray, w: ndarray, tensor_element: str, thickness: float) ndarray [source]
Compute the permittivity for 2D systems.
The permittivity is calculated directly from the complex optical conductivity. By manipulating the Maxwell’s equations, trying to express the quantities as a function of external fields only, one can find
\[\varepsilon_{\alpha \beta}(\omega) = \delta_{\alpha \beta} + \frac{i \sigma(\omega)}{\varepsilon_0 \omega}\]Reference: https://en.wikipedia.org/wiki/Ewald%E2%80%93Oseen_extinction_theorem
- Parameters:
conductivity (np.ndarray) – 2D complex conductivity in units of e^2/h.
w (np.ndarray) – Frequencies at which the conductivity has been evaluated.
tensor_element (str) – Tensor element of the provided conductivity.
thickness (float) – Thickness of the 2D sheet.
- Returns:
specified tensor element of the permittivity at the provided frequencies.
- Return type:
np.ndarray
- qolossal.optical_properties.getPermittivity_1D(conductivity: ndarray, w: ndarray, tensor_element: str, cross_section: float) ndarray [source]
Compute the permittivity for 1D systems.
The permittivity is calculated directly from the complex optical conductivity. By manipulating the Maxwell’s equations, trying to express the quantities as a function of external fields only, one can find
\[\varepsilon_{\alpha \beta}(\omega) = \delta_{\alpha \beta} + \frac{i \sigma(\omega)}{\varepsilon_0 \omega}\]Reference: https://en.wikipedia.org/wiki/Ewald%E2%80%93Oseen_extinction_theorem
- Parameters:
conductivity (np.ndarray) – 1D complex conductivity in units of (e^2/h) Å.
w (np.ndarray) – Frequencies at which the conductivity has been evaluated.
tensor_element (str) – Tensor element of the provided conductivity.
cross_section (float) – Cross section of the 1D wire.
- Returns:
specified tensor element of the permittivity at the provided frequencies.
- Return type:
np.ndarray
- qolossal.optical_properties.getReflectivity(permittivity: ndarray) ndarray [source]
Compute the normal incidence reflectivity.
The reflectivity is computed as
\[\frac{(1 - n)^2 + k^2}{(1 + n)^2 + k^2}\]with \(N(\omega) = n(\omega) + i k(\omega) = \sqrt{\varepsilon(\omega)}\) the complex refractive index.
Reference: https://link.springer.com/article/10.1007/s11664-998-0094-3
- Parameters:
permittivity (np.ndarray) – permittivity of the system.
- Returns:
normal incidence reflectivity.
- Return type:
np.ndarray
- qolossal.optical_properties.getAbsorptionCoefficient(permittivity: ndarray, w: ndarray) ndarray [source]
Compute the absorption coefficient.
Defined as
\[\alpha = \frac{2 \omega k(\omega)}{c}\]with \(k(\omega) = {\rm Im}[\sqrt{\epsilon(\omega)}]\) the extinction coefficient.
Reference: https://en.wikipedia.org/wiki/Ewald%E2%80%93Oseen_extinction_theorem
NOTE: the output is in units of m^-1.
- Parameters:
permittivity (np.ndarray) – permittivity of the system.
w (np.ndarray) – Frequencies at which the permittivity has been evaluated.
- Returns:
absorption coefficient.
- Return type:
np.ndarray
Qolossal Tools
General tools.
Copyright © 2019-2023 HQS Quantum Simulations GmbH. All Rights Reserved.
- qolossal.qolossal_tools._A0_in_AA = 0.529177210903
Vacuum permittivity times the bohr radius This factor is obtained from the definition of eps_0 = e^2/a_0 E_h where a_0 is the Bohr radius and E_h is the Hartree energy. This has this value because we are in rationalized units, i.e. a system in which Coulomb’s law has a prefactor of 1/(4 pi eps_0) and Maxwell’s equations have NO 4 pi.
- qolossal.qolossal_tools.matrix_to_linop(M: csr_array) Callable [source]
Method generating a linear operator given its matrix representation.
- Parameters:
M (csr_array) – Matrix representation of the linear operator.
- Returns:
Linear operator
- Return type:
Callable
- qolossal.qolossal_tools.calcLanczos(dotProd: Callable, x0: ndarray, Order: int, tolerance: float = 1e-11) tuple [source]
Calculate Lanczos expansion of a matrix with dot product dotProd on the vector x0.
- Parameters:
dotProd (Callable) – dot product function.
x0 (np.ndarray) – vector on which to build the Krylov space
Order (int) – order of the expansion
tolerance (float) – Tolerance of non-orthogonality. Defaults to 1e-11.
- Returns:
alphas and betas corresponding to the expansion.
- Return type:
tuple
- qolossal.qolossal_tools.jacksonKernelCoeff(Order: int) ndarray [source]
Get Jackson kernel polynomial coefficients.
- Parameters:
Order (int) – Number of coefficients to return.
- Returns:
Jackson coefficients.
- Return type:
np.ndarray
- qolossal.qolossal_tools.ChebyMoments(dotProd: ~typing.Callable, vL: ~numpy.ndarray, vR: ~numpy.ndarray, Order: int, dtype: ~typing.Type = <class 'float'>) ndarray [source]
Calculate Chebyshev moments corresponding to a matrix with dot product dotProd.
Given a Hamiltonian and two vectors \(v_L\) and \(v_R\), the corresponding Chebyshev moments will be
\[\mu_n = \bra{v_L} T_n(H) \ket{v_R} = \bra{v_L} \ket{v_n}\]with
\[\begin{split}&v_0 = \ket{v_R}\\ &v_1 = H\ket{v_R} \\ &v_{n+1} = 2 H\ket{v_n} - \ket{v_{n-1}}\end{split}\]- Parameters:
dotProd (Callable) – dot product function.
vL (np.ndarray) – vector multiplied on the left to get the moments
vR (np.ndarray) – vector on which to build the Krylov space
Order (int) – order of the expansion
dtype (Type) – specifies the dtype of the problem.
- Returns:
Array containing the Chebyshev moments in ascending order.
- Return type:
np.ndarray
- qolossal.qolossal_tools.ChebyDoubleMoments(dotProd: ~typing.Callable, vL: ~numpy.ndarray, vR: ~numpy.ndarray, P: ~typing.Callable, Order: int, dtype: ~typing.Type = <class 'float'>) ndarray [source]
Calculate Chebyshev moments of a double expansion.
Given a Hamiltonian, an operator and two vectors \(v_L\) and \(v_R\), the corresponding moments of the double Chebyshev expansion will be
\[\mu_{mn} = \bra{v_L} T_m(\hat{H}) \hat{P} T_n(\hat{H}) \ket{v_R}\]vL has to be in the ket form since the Hamiltonian will be applied from the left.
NOTE: dtype has been separated from the dtype of the vectors, since the final dtype will depend on the operator P as well.
- Parameters:
dotProd (Callable) – dot product function.
vL (np.ndarray) – vector (ket) multiplied on the left to get the moments.
vR (np.ndarray) – vector (ket) on which to build the Krylov space.
P (Callable) – linear operator for the expansion.
Order (int) – order of the expansion.
dtype (Type) – specifies the dtype of the problem.
- Raises:
ValueError – if right and left vectors have incompatible shapes.
- Returns:
Array containing the Chebyshev moments in ascending order.
- Return type:
np.ndarray
- qolossal.qolossal_tools.ChebyDoubleMomentsAccumulate(dotProd: ~typing.Callable, gn: ~numpy.ndarray, vL: ~numpy.ndarray, vR: ~numpy.ndarray, P: ~typing.Callable, Order: int, dtype: ~typing.Type = <class 'float'>) ndarray [source]
Calculate Chebyshev moments of a double expansion.
Given a Hamiltonian, an operator and two vectors \(v_L\) and \(v_R\), the corresponding moments of the double Chebyshev expansion will be
\[\mu_{mn} = \bra{v_L} T_m(\hat{H}) \hat{P} T_n(\hat{H}) \ket{v_R}\]- Parameters:
dotProd (Callable) – dot product function.
gn (np.ndarray) – expansion coefficients. Should have shape (Order+1, nFreq)
vL (np.ndarray) – vector multiplied on the left to get the moments
vR (np.ndarray) – vector on which to build the Krylov space
P (Callable) – operator for the expansion
Order (int) – order of the expansion
dtype (Type) – specifies the dtype of the problem.
- Raises:
ValueError – if right and left vectors have incompatible shapes.
- Returns:
frequency dependent contraction.
- Return type:
np.ndarray
- qolossal.qolossal_tools.get_tr_resolvent(moments: ndarray, use_KPM: bool = True) Callable [source]
Returns function evaluating resolvent based on Chebyshev moments.
This function generator returns a function evaluating the trace of the resolvent
\[\mathrm{Tr} \big(z - \hat{H} \big)^{-1}\]for a given ‘frequency’ \(z\) (can be a numpy array).
NOTE: z is expected to be rescaled to the interval (-1, 1) (real part)
NOTE: The trace is estimated as the average over all (normalized) stochastic samples. Hence, multiply the result by the linear size of the Hamiltonian to get the “true” estimate for the trace.
- Parameters:
moments (np.ndarray) – Array containing Chebyshev moments
use_KPM (bool) – Flag to control usage of the Jackson kernel. Defaults to True.
- Returns:
Function evaluating the trace of the resolvent for a given frequency.
- Return type:
Callable
- qolossal.qolossal_tools.get_GF_coeff(w: ndarray | float, Order: int) ndarray [source]
Get the coefficients for the Chebyshev expansion of the Green’s function.
These are defined as
\[g_n(z) = \mp i (2 - \delta_{n0}) \frac{e^{\mp i n \arccos{z}}}{\sqrt{1 - z^2}}\]where the sign corresponds to retarded/advanced components.
- Parameters:
w (Union[np.ndarray, float]) – Frequenc(y)ies at which to compute the Gp.
Order (int) – Order of the expansion.
- Returns:
Coefficients gm at frequenc(y)ies w and order order.
- Return type:
np.ndarray
- qolossal.qolossal_tools.idxListFromSelector(selector: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | bytes | _NestedSequence[bool | int | float | complex | str | bytes], dim: int | None = None) ndarray [source]
Generates list of indices based on the selector.
- Parameters:
selector (Union[str, ArrayLike]) – Selector
dim (Optional[int]) – Dimension of the matrix to generate the selectors of.
- Returns:
Indices corresponding to the selector.
- Return type:
np.ndarray
- Raises:
ValueError – if the selector does not have a valid value or type.
- qolossal.qolossal_tools.generateRandomVector(selector: ~numpy.ndarray, out: ~numpy.ndarray, dtype: ~typing.Type[complex] | ~typing.Type[float] = <class 'float'>) ndarray [source]
Generate random normalized vector given a selector.
- Parameters:
selector (np.ndarray) – array selecting which subspace to consider.
out (np.ndarray) – preallocated output array.
dtype (Union[Type[complex], Type[float]]) – Data type of the output array. Defaults to float.
- Returns:
normalized random vector according to selector.
- Return type:
np.ndarray
- Raises:
ValueError – if dtype is invalid or if the selector is not made of just ones and zeros.
- qolossal.qolossal_tools.blocks2full(blocks: tuple[csr_or_ndarr, csr_or_ndarr, csr_or_ndarr]) csr_or_ndarr [source]
Construct matrix from blocks.
Within the spin representation ((uu, ud), (du, dd)) the blocks passed will be in the following order: [uu, dd, ud].
- Parameters:
blocks (tuple[csr_or_ndarr, csr_or_ndarr, csr_or_ndarr]) – Blocks composing the matrix.
- Returns:
full matrix composed by the input blocks
- Return type:
csr_or_ndarr
- qolossal.qolossal_tools.fermi_distr(energies: ndarray, mu: float | ndarray, T: float) ndarray [source]
Fermi distribution.
Evaluated as
\[f(\epsilon, \mu) = \frac{1}{e^{(\epsilon - \mu) / k_B T} + 1}\]with \(k_B\) the Boltzmann constant.
- Parameters:
energies (np.ndarray) – energies at which to evaluate the Fermi distribution.
mu (Union[float, np.ndarray]) – chemical potential(s).
T (float) – Temperature in Kelvins.
- Returns:
Fermi distribution.
- Return type:
np.ndarray
- qolossal.qolossal_tools.getFermiPadeParams(N: int) tuple[ndarray, ndarray] [source]
Returns Pade-Matsubara poles and residues.
Computes the poles and residues derived from the continued fraction representation of the Fermi function [Ref: Ozaki, PRB 75, 035123 (2007)]
- Parameters:
N (int) – number of poles with positive imaginary part (total number of poles is 2N).
- Returns:
- tuple of two numpy arrays of shape (2 N,).
first element: (complex) Pade-Matsubara poles (sorted with ascending imaginary part). second element: (real) Pade-Matsubara residues corresponding to poles.
- Return type:
tuple[np.ndarray, np.ndarray]
- qolossal.qolossal_tools.dir2idx(tensor_element: str) tuple[int, ...] [source]
Transforms liretal cartesian direction into index.
- Parameters:
tensor_element (str) – Selected tensor element in cartesian coordinates, e.g. ‘xx’.
- Raises:
ValueError – If the selected tensor is not valid.
- Returns:
Indices corresponding to selected the direction.
- Return type:
tuple[int, int]
- qolossal.qolossal_tools.get_energies_from_e_window(scale: float, shift: float, n_omegas: int, e_window: list | ndarray | None = None) ndarray [source]
Helper function returning discretized energies given the energy window.
- Parameters:
scale (float) – Scale used to transform frequencies.
shift (float) – Shift used to transform frequencies.
n_omegas (int) – _description_
e_window (Optional[Union[list, np.ndarray]], optional) – energy window. Defaults to None.
- Returns:
scaled energy window or default one.
- Return type:
np.ndarray
- qolossal.qolossal_tools._scale2real(frequencies: fl_cmplx_or_ndarr, scale: float, shift: float) fl_cmplx_or_ndarr [source]
Apply scaling to transform scaled frequencies to real ones.
- Parameters:
frequencies (fl_cmplx_or_ndarr) – array of scaled energies within (-1, 1).
scale (float) – scale used to transform frequencies.
shift (float) – shift used to transform frequencies.
- Returns:
Real energies array.
- Return type:
fl_cmplx_or_ndarr
- qolossal.qolossal_tools._scale2transformed(frequencies: fl_cmplx_or_ndarr, scale: float, shift: float) fl_cmplx_or_ndarr [source]
Apply scaling to transform real frequencies to scaled ones.
- Parameters:
frequencies (fl_cmplx_or_ndarr) – real energies array.
scale (float) – scale used to transform frequencies.
shift (float) – shift used to transform frequencies.
- Returns:
Scaled energies array.
- Return type:
fl_cmplx_or_ndarr
- qolossal.qolossal_tools.get_DOS_from_moments(moments: ndarray, frequencies: ndarray, scale: float, shift: float, use_jackson_kernel: bool = True, eta: float = 0) ndarray [source]
Evaluate the DOS from the corresponding moments.
- Parameters:
moments (np.ndarray) – moments to expand.
frequencies (np.ndarray) – frequencies at which to evaluate the DOS.
scale (float) – scale used to evaluate the moments.
shift (float) – shift used to evaluate the moments.
use_jackson_kernel (bool) – whether to use the jackson kernel. Defaults to True.
eta (float) – Green’s function coefficients broadening.
- Returns:
density of states at the desired frequencies.
- Return type:
np.ndarray
- qolossal.qolossal_tools.get_KG_conductivity_from_moments(moments: ndarray, chemical_potentials: ndarray, scale: float, shift: float, total_volume: float, system_linear_size: int, use_jackson_kernel: bool = True, eta: float = 0) ndarray [source]
Evaluate the Kubo-Greenwood conductivity from the corresponding moments.
- Parameters:
moments (np.ndarray) – moments to expand.
chemical_potentials (np.ndarray) – chemical potentials at which to evaluate the conductivity.
scale (float) – scale used to evaluate the moments.
shift (float) – shift used to evaluate the moments.
total_volume (float) – total volume of the system. Used for normalization.
system_linear_size (int) – total linear size of the system. Used for normalization.
use_jackson_kernel (bool) – whether to use the jackson kernel. Defaults to True.
eta (float) – Green’s function coefficients broadening.
- Returns:
conductivity at the desired chemical potentials.
- Return type:
np.ndarray
- qolossal.qolossal_tools.get_KB_conductivity_from_moments(moments: ndarray, chemical_potentials: ndarray, scale: float, shift: float, total_volume: float, system_linear_size: int, T: float, NOmegasInt: int, use_jackson_kernel: bool = True) ndarray [source]
Evaluate the Kubo-Bastin conductivity from the corresponding moments.
- Parameters:
moments (np.ndarray) – moments to expand.
chemical_potentials (np.ndarray) – chemical potentials at which to evaluate the conductivity.
scale (float) – scale used to evaluate the moments.
shift (float) – shift used to evaluate the moments.
total_volume (float) – total volume of the system. Used for normalization.
system_linear_size (int) – total linear size of the system. Used for normalization.
T (float) – Temperature (in Kelvin) at which to compute the conductivity.
NOmegasInt (int) – number of energies for performing the numerical integral.
use_jackson_kernel (bool) – whether to use the jackson kernel. Defaults to True.
- Returns:
conductivity at the desired chemical potentials.
- Return type:
np.ndarray
- qolossal.qolossal_tools.get_T_dependent_conductivity(conductivity: ndarray, energies: ndarray, T: float) ndarray [source]
Compute the temperature dependent Kubo-Greenwood conductivity from the zero temperature one.
- Parameters:
conductivity (np.ndarray) – Zero temperature Kubo-Greenwood conductivity.
energies (np.ndarray) – Energies at which the conductivity is computed.
T (float) – Temperature (in Kelvin) at which to compute the conductivity.
- Raises:
ValueError – If the passed temperature is negative.
- Returns:
Temperature dependent Kubo-Greenwood conductivity.
- Return type:
np.ndarray
- qolossal.qolossal_tools.get_expectation_value_from_moments(moments: ndarray, T: float, mu: float, scale: float, shift: float, n_pade_freq: int) float | complex [source]
Evaluate the expectation value of an operator from the corresponding moments.
The implementation follows what outlined in the internal notes on linear response.
- Parameters:
moments (np.ndarray) – moments to expand.
T (float) – Temperature at which to compute the expectation value.
mu (float) – Chemical potential at which to compute the expectation value.
scale (float) – scale used to evaluate the moments.
shift (float) – shift used to evaluate the moments.
n_pade_freq (int) – Number of pade’ frequencies to use for the evaluation of the fermi function.
- Returns:
expectation value.
- Return type:
Union[float, complex]
- qolossal.qolossal_tools.get_optical_conductivity_from_moments(moments: ndarray, frequencies: ndarray, scale: float, shift: float, total_volume: float, system_linear_size: int, T: float, chemical_potential: float, NOmegasInt: int, use_jackson_kernel: bool = True, eta: float = 1e-07, verbose: int = 1) ndarray [source]
Evaluate the complex optical conductivity from the corresponding moments.
This routine implements eq. 32 of the internal notes on the optical conductivity.
- Parameters:
moments (np.ndarray) – conductivity moments to expand.
frequencies (np.ndarray) – frequencies at which to evaluate the conductivity.
scale (float) – scale used to evaluate the moments.
shift (float) – shift used to evaluate the moments.
total_volume (float) – total volume of the system. Used for normalization.
system_linear_size (int) – total linear size of the system. Used for normalization.
T (float) – Temperature in Kelvin.
chemical_potential (float) – Chemical potential.
NOmegasInt (int) – number of frequencies to use to calculate the E integral.
use_jackson_kernel (bool) – whether to use the jackson kernel. Defaults to True.
eta (float) – Green’s function coefficients broadening.
verbose (int) – verbosity level.
- Returns:
conductivity at the desired frequencies.
- Return type:
np.ndarray
- qolossal.qolossal_tools.get_real_optical_conductivity_from_moments(moments: ndarray, frequencies: ndarray, scale: float, shift: float, total_volume: float, system_linear_size: int, T: float, chemical_potential: float, NOmegasInt: int, use_jackson_kernel: bool = True, eta: float = 1e-07) ndarray [source]
Evaluate the real part of the optical conductivity from the corresponding moments.
- Parameters:
moments (np.ndarray) – moments to expand.
frequencies (np.ndarray) – frequencies at which to evaluate the conductivity.
scale (float) – scale used to evaluate the moments.
shift (float) – shift used to evaluate the moments.
total_volume (float) – total volume of the system. Used for normalization.
system_linear_size (int) – total linear size of the system. Used for normalization.
T (float) – Temperature in Kelvin.
chemical_potential (float) – Chemical potential.
NOmegasInt (int) – number of frequencies to use to calculate the E integral.
use_jackson_kernel (bool) – whether to use the jackson kernel. Defaults to True.
eta (float) – Green’s function coefficients broadening.
- Returns:
conductivity at the desired frequencies.
- Return type:
np.ndarray