BasisAtom

Class Methods

__init__(species[, n, nu, nui, l, s, j, ...])

Create a basis for a single atom.

from_kets(kets[, delta_n, delta_nu, ...])

Create a BasisAtom from one or more kets and quantum number deltas.

get_amplitudes(other)

get_coefficients()

Return the coefficients of the basis as a sparse matrix.

get_corresponding_ket(state)

get_corresponding_ket_index(state)

get_corresponding_state(ket)

get_corresponding_state_index(ket)

get_matrix_elements(other, operator, q[, unit])

get_overlaps(other)

get_state(index)

Return the state at the given index.

Class Attributes and Properties

database

The database used for this object.

kets

Return a list containing the kets of the basis.

number_of_kets

Return the number of kets in the basis.

number_of_states

Return the number of states in the basis.

species

The atomic species.

states

Return a list containing the states of the basis.

class BasisAtom[source]

Basis for a single atom.

Add all KetAtom objects that match the given quantum numbers to the basis. The initial coefficients matrix is a unit matrix, i.e. the first basis state is the first ket, etc. The BasisAtom coefficients matrix will always be square, i.e. the number of kets is equal to the number of states.

Examples

>>> import pairinteraction as pi
>>> ket = pi.KetAtom("Rb", n=60, l=0, m=0.5)
>>> energy_min, energy_max = ket.get_energy(unit="GHz") - 100, ket.get_energy(unit="GHz") + 100
>>> basis = pi.BasisAtom("Rb", n=(57, 63), l=(0, 3), energy=(energy_min, energy_max), energy_unit="GHz")
>>> print(basis)
BasisAtom(n=(57, 63), l=(0, 3), energy=(1008911.9216, 1009111.9216), energy_unit=GHz)
__init__(species, n=None, nu=None, nui=None, l=None, s=None, j=None, l_ryd=None, j_ryd=None, f=None, m=None, energy=None, energy_unit=None, parity=None, database=None, additional_kets=None)[source]

Create a basis for a single atom.

Parameters:
  • species (str) – The species of the atom.

  • n (tuple[int, int] | None) – tuple of (min, max) values for this quantum number. Default None, i.e. add all available states.

  • nu (tuple[float, float] | None) – tuple of (min, max) values for this quantum number. Default None, i.e. add all available states.

  • nui (tuple[float, float] | None) – tuple of (min, max) values for this quantum number. Default None, i.e. add all available states.

  • l (tuple[float, float] | None) – tuple of (min, max) values for this quantum number. Default None, i.e. add all available states.

  • s (tuple[float, float] | None) – tuple of (min, max) values for this quantum number. Default None, i.e. add all available states.

  • j (tuple[float, float] | None) – tuple of (min, max) values for this quantum number. Default None, i.e. add all available states.

  • l_ryd (tuple[float, float] | None) – tuple of (min, max) values for this quantum number. Default None, i.e. add all available states.

  • j_ryd (tuple[float, float] | None) – tuple of (min, max) values for this quantum number. Default None, i.e. add all available states.

  • f (tuple[float, float] | None) – tuple of (min, max) values for this quantum number. Default None, i.e. add all available states.

  • m (tuple[float, float] | None) – tuple of (min, max) values for this quantum number. Default None, i.e. add all available states.

  • energy (tuple[float, float] | tuple[pairinteraction.units.PintFloat, pairinteraction.units.PintFloat] | None) – tuple of (min, max) value for the energy. Default None, i.e. add all available states.

  • energy_unit (str | None) – In which unit the energy values are given, e.g. “GHz”. Default None, i.e. energy is provided as pint object.

  • parity (Literal['even', 'odd', 'unknown'] | None) – The parity of the states to consider. Default None, i.e. add all available states.

  • database (Database | None) – Which database to use. Default None, i.e. use the global database instance.

  • additional_kets (Sequence[pairinteraction.ket.ket_atom.KetAtom] | None) – List of additional kets to add to the basis. Default None.

Return type:

None

classmethod from_kets(kets, delta_n=None, delta_nu=None, delta_nui=None, delta_l=None, delta_s=None, delta_j=None, delta_l_ryd=None, delta_j_ryd=None, delta_f=None, delta_m=None, delta_energy=None, delta_energy_unit=None, parity=None, database=None, additional_kets=None)[source]

Create a BasisAtom from one or more kets and quantum number deltas.

Currently a single big basis including all kets for the quantum numbers from min_value - delta to max_value + delta is returned. In the future this might change to return a basis including all states around the given kets +/- delta, but not necessarily all states between the given kets.

For each quantum number, pass the corresponding delta_* argument to include all states within [min_value - delta, max_value + delta], where min_value / max_value are the extremes across all provided kets. If no delta_* is given for a quantum number, that quantum number is left unrestricted.

Parameters:
  • kets (pairinteraction.ket.ket_atom.KetAtom | Sequence[pairinteraction.ket.ket_atom.KetAtom]) – The ket(s) around which the basis should be centered.

  • delta_n (int | None) – Half-width of the n window (integer steps). Default None means no restriction on n.

  • delta_nu (float | None) – Half-width of the nu window. Default None means no restriction on nu.

  • delta_nui (float | None) – Half-width of the nui window. Default None means no restriction on nui.

  • delta_l (float | None) – Half-width of the l window. Default None means no restriction on l.

  • delta_s (float | None) – Half-width of the s window. Default None means no restriction on s.

  • delta_j (float | None) – Half-width of the j window. Default None means no restriction on j.

  • delta_l_ryd (float | None) – Half-width of the l_ryd window. Default None means no restriction on l_ryd.

  • delta_j_ryd (float | None) – Half-width of the j_ryd window. Default None means no restriction on j_ryd.

  • delta_f (int | None) – Half-width of the f window (integer steps). Default None means no restriction on f.

  • delta_m (int | None) – Half-width of the m window (integer steps). Default None means no restriction on m.

  • delta_energy (float | pairinteraction.units.PintFloat | None) – Half-width of the energy window around the energies of the provided kets. Default None means no energy restriction.

  • delta_energy_unit (str | None) – Unit for delta_energy (e.g. "GHz"). Default None means pint quantities are used.

  • parity (Literal['even', 'odd', 'unknown'] | None) – Restrict to states with this parity. Default None means no parity restriction.

  • database (Database | None) – Database instance to use. Default None uses the global database.

  • additional_kets (Sequence[pairinteraction.ket.ket_atom.KetAtom] | None) – Extra kets to force-include in the basis. Default None.

Return type:

Self

Returns:

A new BasisAtom centered around the provided kets.

Examples

>>> import pairinteraction as pi
>>> ket1 = pi.KetAtom("Rb", n=60, l=0, m=0.5)
>>> ket2 = pi.KetAtom("Rb", n=59, l=0, m=0.5)
>>> basis = pi.BasisAtom.from_kets([ket1, ket2], delta_n=2, delta_l=1)
>>> basis.species
'Rb'
>>> all(57 <= k.n <= 62 for k in basis.kets)
True
property database: Database

The database used for this object.

property species: str

The atomic species.

get_amplitudes(other)[source]
Overloads:
  • self, other (KetAtom | StateAtom) → NDArray

  • self, other (Self) → csr_matrix

Parameters:

other (TypeAliasForwardRef('pairinteraction.ket.ket_atom.KetAtom') | StateAtom | Self)

Return type:

TypeAliasForwardRef(‘pairinteraction.units.NDArray’) | csr_matrix

get_overlaps(other)[source]
Overloads:
  • self, other (KetAtom | StateAtom) → NDArray

  • self, other (Self) → csr_matrix

Parameters:

other (TypeAliasForwardRef('pairinteraction.ket.ket_atom.KetAtom') | StateAtom | Self)

Return type:

TypeAliasForwardRef(‘pairinteraction.units.NDArray’) | csr_matrix

get_coefficients()

Return the coefficients of the basis as a sparse matrix.

The coefficients are stored in a sparse matrix with shape (number_of_kets, number_of_states), where the first index correspond to the kets and the second index correspond to the states. For example basis.get_coefficients()[i, j] is the i-th coefficient (i.e. the coefficient corresponding to the i-th ket) of the j-th state.

The coefficients are normalized, i.e. the sum of the absolute values of the coefficients in each row is equal to 1.

Return type:

csr_matrix

get_corresponding_ket(state)
Return type:

TypeVar(KetType, bound= KetBase)

Parameters:
  • self (Self)

  • state (StateType)

get_corresponding_ket_index(state)
Return type:

int

Parameters:

state (StateType)

get_corresponding_state(ket)
Return type:

TypeVar(StateType, bound= StateBase[Any])

Parameters:

ket (KetBase)

get_corresponding_state_index(ket)
Return type:

int

Parameters:

ket (KetBase)

get_state(index)

Return the state at the given index.

Return type:

TypeVar(StateType, bound= StateBase[Any])

Parameters:

index (int)

property kets: list[KetType]

Return a list containing the kets of the basis.

property number_of_kets: int

Return the number of kets in the basis.

property number_of_states: int

Return the number of states in the basis.

property states: list[StateType]

Return a list containing the states of the basis.

get_matrix_elements(other, operator, q, unit=None)[source]
Overloads:
  • self, other (KetAtom | StateAtom), operator (OperatorType), q (int), unit (None) → PintArray

  • self, other (KetAtom | StateAtom), operator (OperatorType), q (int), unit (str) → NDArray

  • self, other (Self), operator (OperatorType), q (int), unit (None) → PintSparse

  • self, other (Self), operator (OperatorType), q (int), unit (str) → csr_matrix

Parameters:
  • other (TypeAliasForwardRef('pairinteraction.ket.ket_atom.KetAtom') | StateAtom | Self)

  • operator (Literal['zero', 'energy', 'electric_dipole', 'electric_quadrupole', 'electric_quadrupole_zero', 'electric_octupole', 'magnetic_dipole', 'identity', 'arbitrary'])

  • q (int)

  • unit (str | None)

Return type:

TypeAliasForwardRef(‘pairinteraction.units.NDArray’) | TypeAliasForwardRef(‘pairinteraction.units.PintArray’) | csr_matrix | TypeAliasForwardRef(‘pairinteraction.units.PintSparse’)