diagonalize
- diagonalize(systems, diagonalizer='eigen', float_type='float64', rtol=1e-06, sort_by_energy=True, energy_range=(None, None), energy_unit=None, m0=None)[source]
Diagonalize a list of systems in parallel using the C++ backend.
A convenience function for diagonalizing a list of systems in parallel using the C++ backend. This is much faster than diagonalizing each system individually on the Python side.
Examples
>>> import pairinteraction.real as pi >>> ket = pi.KetAtom("Rb", n=60, l=0, m=0.5) >>> basis = pi.BasisAtom("Rb", n=(58, 63), l=(0, 3)) >>> systems = [pi.SystemAtom(basis).set_magnetic_field([0, 0, b], unit="gauss") for b in range(1, 4)] >>> print(systems[0]) SystemAtom(BasisAtom(|Rb:58,S_1/2,-1/2⟩ ... |Rb:63,F_5/2,5/2⟩), is_diagonal=False) >>> pi.diagonalize(systems) >>> print(systems[0]) SystemAtom(BasisAtom(|Rb:58,S_1/2,-1/2⟩ ... |Rb:63,F_5/2,5/2⟩), is_diagonal=True)
- Parameters:
systems (
Sequence
[SystemBase
[Any
]]) – A list of SystemAtom or SystemPair objects, which will get diagonalized inplace.diagonalizer (
Literal
['eigen'
,'lapacke_evd'
,'lapacke_evr'
,'feast'
]) – The diagonalizer method to use. Defaults to “eigen”.float_type (
Literal
['float32'
,'float64'
]) – The floating point precision to use for the diagonalization. Defaults to “float64”.rtol (
float
) – The relative tolerance allowed for eigenenergies. The error in eigenenergies is bounded by rtol * ||H||, where ||H|| is the norm of the Hamiltonian matrix. Defaults to 1e-6.sort_by_energy (
bool
) – Whether to sort the resulting basis by energy. Defaults to True.energy_range (
tuple
[Optional
[TypeVar
(Quantity
, bound=Union
[float
, PintFloat])],Optional
[TypeVar
(Quantity
, bound=Union
[float
, PintFloat])]]) – A tuple specifying an energy range, in which eigenvlaues should be calculated. Specifying a range can speed up the diagonalization process (depending on the diagonalizer method). The accuracy of the eigenenergies is not affected by this, but not all eigenenergies will be calculated. Defaults to (None, None), i.e. calculate all eigenenergies.energy_unit (
Optional
[str
]) – The unit in which the energy_range is given. Defaults to None assumes pint objects.m0 (
Optional
[int
]) – The search subspace size for the FEAST diagonalizer. Defaults to None.
- Return type:
None