qrunch.chemistry.reduced_density_matrices.reduced_density_matrix_calculator

Module for reduced density matrix (RDM) calculators.

Functions

get_permutation_sign_to_collect_number_operator(...)

Calculate the fermionic sign from rearranging an operator string to group repeated indices.

iter_double_spin_indices()

Iterate over spin components.

iter_quadruple_spin_indices()

Iterate over spin components.

iter_triple_spin_indices()

Iterate over spin components.

Classes

ReducedDensityMatrixCalculator

Class for calculating reduced density matrices (RDMs).

class ReducedDensityMatrixCalculator

Bases: object

Class for calculating reduced density matrices (RDMs).

__init__(estimator: Estimator) None

Initialize the reduced density matrix calculator.

Parameters:

estimator (Estimator) – The estimator to be used for the matrix elements. Can be created using the estimator_creator() builder.

Return type:

None

calculate_1_rdm(circuit: Circuit, shots: int | None = None) ndarray[Any, dtype[float64]]

Calculate the 1-particle RDMs.

Eq. 47 of https://arxiv.org/pdf/2404.16586

\[\Gamma^{[1]}_{pq} = \sum_{\tau} \langle \Psi | a^{\dagger}_{p \tau} a_{q \tau} | \Psi \rangle\]
Parameters:
  • circuit (Circuit) – Circuit to use as the ansatz for estimating the RDMs.

  • shots (int | None) – The number of shots to use in the estimation. Defaults to None.

Return type:

ndarray[Any, dtype[float64]]

calculate_2_rdm(circuit: Circuit, shots: int | None = None) ndarray[Any, dtype[float64]]

Calculate the 2-particle RDMs.

Eq. 48 of https://arxiv.org/pdf/2404.16586

\[\Gamma^{[2]}_{pqrs} = \sum_{\tau \sigma} \langle \Psi | a^{\dagger}_{p \tau} a^{\dagger}_{r \sigma} a_{s \sigma} a_{q \tau} | \Psi \rangle\]
Parameters:
  • circuit (Circuit) – Circuit to use as the ansatz for estimating the RDMs.

  • shots (int | None) – The number of shots to use in the estimation. Defaults to None.

Return type:

ndarray[Any, dtype[float64]]

calculate_3_rdm(circuit: Circuit, shots: int | None = None) ndarray[Any, dtype[float64]]

Calculate the 3-particle RDMs.

Eq. 49 of https://arxiv.org/pdf/2404.16586

\[\begin{split}\Gamma^{[3]}_{pqrstu} = \sum_{\tau \sigma \delta} \langle \Psi | a^{\dagger}_{p \tau} a^{\dagger}_{r \sigma} a^{\dagger}_{t \delta} \\ a_{u \delta} a_{s \sigma} a_{q \tau} | \Psi \rangle\end{split}\]
Parameters:
  • circuit (Circuit) – Circuit to use as the ansatz for estimating the RDMs.

  • shots (int | None) – The number of shots to use in the estimation. Defaults to None.

Return type:

ndarray[Any, dtype[float64]]

calculate_4_rdm(circuit: Circuit, shots: int | None = None) ndarray[Any, dtype[float64]]

Calculate the 4-particle RDMs.

\[\begin{split}\Gamma^{[4]}_{pqrstumn} = \sum_{\tau \sigma \delta \gamma} \langle \Psi | a^{\dagger}_{p \tau} a^{\dagger}_{r \sigma} \\ a^{\dagger}_{t \delta} a^{\dagger}_{m \gamma} \\ a_{n \gamma} a_{u \delta} a_{s \sigma} a_{q \tau} | \Psi \rangle\end{split}\]
Parameters:
  • circuit (Circuit) – Circuit to use as the ansatz for estimating the RDMs.

  • shots (int | None) – The number of shots to use in the estimation. Defaults to None.

Return type:

ndarray[Any, dtype[float64]]

get_permutation_sign_to_collect_number_operator(indices: tuple[int, ...], repeated_indices: tuple[int, ...]) float

Calculate the fermionic sign from rearranging an operator string to group repeated indices.

This function simulates moving all operators whose indices are in repeated_indices to the left of the string, counting the number of swaps, as each swap result in a minus sign.

The total sign become (-1)^swaps.

Parameters:
  • indices (tuple[int, ...]) – A tuple of spin-orbital indices representing the operator string.

  • repeated_indices (tuple[int, ...]) – A tuple of indices that should be grouped at the front.

Return type:

float

iter_double_spin_indices() Iterator[tuple[int, int]]

Iterate over spin components.

Return type:

Iterator[tuple[int, int]]

iter_quadruple_spin_indices() Iterator[tuple[int, int, int, int]]

Iterate over spin components.

Return type:

Iterator[tuple[int, int, int, int]]

iter_triple_spin_indices() Iterator[tuple[int, int, int]]

Iterate over spin components.

Return type:

Iterator[tuple[int, int, int]]