qrunch.chemistry.orbital_optimizers.reduced_density_matrices
Module for reduced density matrix (RDM) calculators.
Functions
|
Project a noisy real 1-RDM to the space of valid 1-RDMs using spectral projection. |
|
Project a vector onto the capped simplex. |
|
Project a real symmetric matrix to the space of traceless symmetric matrices using a spectral shift. |
Classes
Class for calculating restricted bosonic 1- and 2-particle reduced density matrices (RDMs). |
|
Class for calculating restricted 1- and 2-particle reduced density matrices (RDMs). |
|
Class for calculating unrestricted 1- and 2-particle reduced density matrices (RDMs). |
- class BosonReducedDensityMatrixCalculator
Bases:
ReducedDensityMatrixCalculatorClass for calculating restricted bosonic 1- and 2-particle reduced density matrices (RDMs).
The boson RMD is restricted to half the number of qubits compared to the the fermionic RDMs. The restricted single excitation RMD consist of only alpha-alpha component. The restricted double excitation RDM consist of only alpha-alpha-alpha-alpha component
- __init__(estimator: Estimator, mapper: Mapper | None = None, *, purify: bool = False) None
Initialize a reduced density matrix calculator.
- calculate(circuit: Circuit, shots: int | None = None) RestrictedReducedDensityMatrices
Calculate the 1- and 2-particle RDMs.
- 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:
- class RestrictedReducedDensityMatrixCalculator
Bases:
ReducedDensityMatrixCalculatorClass for calculating restricted 1- and 2-particle reduced density matrices (RDMs).
The restricted single excitation RMD consist of only alpha-alpha component. The restricted double excitation RDM consist of only alpha-alpha-alpha-alpha component.
- __init__(estimator: Estimator, mapper: Mapper | None = None) None
Initialize a reduced density matrix calculator.
- calculate(circuit: Circuit, shots: int | None = None) RestrictedReducedDensityMatrices
Calculate the 1- and 2-particle RDMs.
- 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:
- class UnrestrictedReducedDensityMatrixCalculator
Bases:
ReducedDensityMatrixCalculatorClass for calculating unrestricted 1- and 2-particle reduced density matrices (RDMs).
The unrestricted 1-RMD consist of both alpha-alpha and beta-beta component. The unrestricted 2-RDM consist of alpha-alpha-alpha-alpha, beta-beta-beta-beta, and beta-alpha-beta-alpha (physics ordering).
- __init__(estimator: Estimator, mapper: Mapper | None = None) None
Initialize a reduced density matrix calculator.
- calculate(circuit: Circuit, shots: int | None = None) UnrestrictedReducedDensityMatrices
Calculate the 1- and 2-particle RDMs.
- 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:
- project_reduced_density_matrix(gamma_noisy: ndarray[Any, dtype[float64]], electron_count: float) ndarray[Any, dtype[float64]]
Project a noisy real 1-RDM to the space of valid 1-RDMs using spectral projection.
It is assumed that the real 1-RDM fulfills the following conditions: (1) Positive semidefiniteness (eigenvalues >= 0) (2) Eigenvalues must be below or equal to 1 (3) The trace must equal the electron count (4) The matrix is symmetric
This method uses spectral projection for speed: - Diagonalizes the matrix - Clips eigenvalues to [0, 1] - Rescales eigenvalues to match target trace - Reconstructs the matrix from adjusted spectrum
- Parameters:
gamma_noisy (ndarray[Any, dtype[float64]]) – Symmetric real matrix with trace approximately equal to electron_count.
electron_count (float) – The desired trace of the projected density matrix.
- Raises:
ValueError – If the matrix is not square or not symmetric.
- Return type:
ndarray[Any, dtype[float64]]
- project_to_capped_simplex(eigenvalues: ndarray[Any, dtype[float64]], target_sum: float, lower: float = 0.0, upper: float = 1.0) ndarray[Any, dtype[float64]]
Project a vector onto the capped simplex.
Adjusts the entries of the input vector so that the sum equals the target value and each element is confined between the specified lower and upper bounds.
- Parameters:
eigenvalues (ndarray[Any, dtype[float64]]) – A numpy array of values to project.
target_sum (float) – Desired sum of the output vector.
lower (float) – The minimum allowed value for each element.
upper (float) – The maximum allowed value for each element.
- Return type:
ndarray[Any, dtype[float64]]
- project_traceless_symmetric_matrix(matrix_noisy: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]]
Project a real symmetric matrix to the space of traceless symmetric matrices using a spectral shift.
It is assumed that the input matrix is: (1) Symmetric (2) Real-valued (3) Trace may be non-zero (4) Eigenvalues may be positive or negative
The projection subtracts a scaled identity matrix to enforce tracelessness.
- Parameters:
matrix_noisy (ndarray[Any, dtype[float64]]) – Real symmetric matrix to project.
- Raises:
ValueError – If the input is not square or symmetric.
- Return type:
ndarray[Any, dtype[float64]]