StateAtom

Class Methods

__init__(coefficients[, kets, basis])

Initialize a state object from a coefficient vector and the corresponding kets.

get_amplitude(other)

Calculate the amplitude of the state with respect to another state or ket.

get_coefficients()

Return the coefficients of the state as a 1d-array.

get_corresponding_ket()

Return the ket with the maximal overlap with self.

get_corresponding_ket_index()

Return the ket index with the maximal overlap with self.

get_ket(index)

Return the ket at the given index.

get_label([stop_after_num_kets, ...])

Label representing the state.

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

Calculate the matrix element of the operator with respect to the state and another state or ket.

get_overlap(other)

Calculate the overlap of the state with respect to another state or ket.

is_normalized([tol])

Check if the state is normalized within a given tolerance.

normalize()

Normalize the coefficients of the state.

Class Attributes and Properties

database

The database used for this object.

is_canonical

kets

Return a list containing the kets of the basis.

norm

Return the norm of the state.

number_of_kets

Return the number of kets in the basis.

species

The atomic species.

class StateAtom[source]

State of a single atom.

A coefficient vector and a list of kets are used to represent an arbitrary single-atom state.

Examples

>>> import pairinteraction as pi
>>> ket = pi.KetAtom("Rb", n=60, l=0, m=0.5)
>>> state = ket.to_state()
>>> print(state)
1.00 |Rb:60,S_1/2,1/2⟩
>>> ket2 = pi.KetAtom("Rb", n=60, l=1, j=0.5, m=0.5)
>>> state2 = pi.StateAtom([1], [ket2])
>>> print(state2)
1.00 |Rb:60,P_1/2,1/2⟩
>>> print((2 * state2 - state).normalize())
0.89 |Rb:60,P_1/2,1/2⟩ - 0.45 |Rb:60,S_1/2,1/2⟩
>>> print(pi.StateAtom([2, 1], [ket, ket2]).normalize())
0.89 |Rb:60,S_1/2,1/2⟩ + 0.45 |Rb:60,P_1/2,1/2⟩
__init__(coefficients, kets=None, *, basis=None)[source]

Initialize a state object from a coefficient vector and the corresponding kets.

Overloads:
  • self, coefficients (Sequence[complex]), kets (Sequence[KetAtom]), basis (BasisAtom | None) → None

  • self, ket (KetAtom), basis (BasisAtom) → None

Parameters:
  • coefficients (collections.abc.Sequence[complex] | KetAtom) – The coefficient of each of the given kets.

  • kets (collections.abc.Sequence[KetAtom] | BasisAtom | None) – The kets the state is composed of.

  • basis (BasisAtom | None) – The basis in which the state should be expressed. If None (default), a minimal basis consisting only of the given kets is constructed. Providing a basis is only relevant if you want the state to already live in a larger Hilbert space; when adding states, their bases are merged automatically. All given kets must be part of this basis. Since the coefficients are always defined with respect to the kets, only the kets of the given basis are used and the coefficients of the basis are ignored, i.e. the basis is canonicalized first.

Return type:

None

normalize()[source]

Normalize the coefficients of the state.

Return type:

Self

is_normalized(tol=1e-10)[source]

Check if the state is normalized within a given tolerance.

Parameters:

tol (float) – The tolerance for the normalization check. Default is 1e-10.

Return type:

bool

Returns:

True if the state is normalized within the given tolerance, False otherwise.

property database: Database

The database used for this object.

property species: str

The atomic species.

property is_canonical: bool
get_amplitude(other)[source]

Calculate the amplitude of the state with respect to another state or ket.

This means the inner product <self|other>.

Parameters:

other (Self | KetAtom) – Either a state or a ket for which the amplitude should be calculated.

Return type:

float | complex

Returns:

The amplitude between self and other.

get_overlap(other)[source]

Calculate the overlap of the state with respect to another state or ket.

This means calculate \(|\langle \mathrm{self} | \mathrm{other} \rangle|^2\).

Parameters:

other (Self | KetAtom) – Either a state or a ket for which the overlap should be calculated.

Return type:

float

Returns:

The overlap between self and other.

get_coefficients()

Return the coefficients of the state as a 1d-array.

The coefficients are stored in a numpy.array with shape (number_of_kets,).

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

Return type:

pairinteraction.units.NDArray

get_corresponding_ket()

Return the ket with the maximal overlap with self.

Return type:

TypeVar(KetType, bound= KetBase)

get_corresponding_ket_index()

Return the ket index with the maximal overlap with self.

Return type:

int

get_ket(index)

Return the ket at the given index.

Return type:

TypeVar(KetType, bound= KetBase)

Parameters:

index (int)

get_label(stop_after_num_kets=3, stop_after_accumulated_overlap=0.95)

Label representing the state.

Parameters:
  • stop_after_num_kets (int) – Maximum number of kets to include in the label.

  • stop_after_accumulated_overlap (float) – Stop including kets in the label, if the accumulated overlap of the included kets exceeds this value.

Return type:

str

Returns:

The label of the ket in the given format.

property kets: list[KetType]

Return a list containing the kets of the basis.

property norm: floating

Return the norm of the state.

property number_of_kets: int

Return the number of kets in the basis.

get_matrix_element(other, operator, q, unit=None)[source]

Calculate the matrix element of the operator with respect to the state and another state or ket.

Overloads:
  • self, other (KetAtom | Self), operator (OperatorType), q (int), unit (None) → PintFloat | PintComplex

  • self, other (KetAtom | Self), operator (OperatorType), q (int), unit (str) → float | complex

Parameters:
  • other (KetAtom | Self)

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

  • q (int)

  • unit (str | None)

Return type:

TypeAliasForwardRef(‘pairinteraction.units.PintFloat’) | TypeAliasForwardRef(‘pairinteraction.units.PintComplex’) | float | complex

This means the inner product <self|operator|other>.

Parameters:
  • other (KetAtom | Self) – Either a state or a ket for which the matrix element should be calculated.

  • operator (Literal['zero', 'energy', 'electric_monopole', 'electric_dipole', 'electric_quadrupole', 'electric_quadrupole_zero', 'electric_octupole', 'magnetic_dipole', 'identity', 'arbitrary']) – The operator for which the matrix element should be calculated.

  • q (int) – The projection quantum number of the operator.

  • unit (str | None) – The unit in which the result should be returned. Default None will return a pint.Quantity.

Returns:

The matrix element between self and other.

Return type:

TypeAliasForwardRef(‘pairinteraction.units.PintFloat’) | TypeAliasForwardRef(‘pairinteraction.units.PintComplex’) | float | complex