Linear Response

class slowquant.qiskit_interface.linear_response.allprojected.quantumLR(wf: WaveFunctionCircuit)

Initialize linear response by calculating the needed matrices.

Parameters:

wf – Wavefunction object.

_get_qbitmap(cliques: bool = False) tuple[list[list[str]], list[list[str]], list[list[str]]]

Get qubit map of operators.

Parameters:

cliques – If using cliques.

Returns:

Qubit map of operators.

_run_no_saving(do_gradients: bool = True) None

Run simulation of all projected LR matrix elements without re-using recouring matrix elements.

Parameters:

do_gradients – Calculate gradients w.r.t. orbital rotations and active space excitations.

get_transition_dipole(dipole_integrals: Sequence[ndarray]) ndarray

Calculate transition dipole moment.

Parameters:

dipole_integrals – Dipole integrals ordered as (x,y,z).

Returns:

Transition dipole moment.

run(do_gradients: bool = True) None

Run simulation of all projected LR matrix elements.

Parameters:

do_gradients – Calculate gradients w.r.t. orbital rotations and active space excitations.

run_std(no_coeffs: bool = False, verbose: bool = True, cv: bool = True, save: bool = False) tuple[ndarray, ndarray, ndarray]

Get standard deviation in matrix elements of LR equation.

Parameters:
  • no_coeffs – Boolean to no include coefficients

  • verbose – Boolean to print more info

  • cv – Boolean to calculate coefficient of variance

  • save – Boolean to save operator-specific standard deviations

Returns:

Array of standard deviations for A, B and Sigma

slowquant.qiskit_interface.linear_response.lr_baseclass.get_num_CBS_elements(matrix: list[list[str]]) tuple[int, int]

Count how many individual elements in matrix require only measurement in computational basis and how many do not.

Parameters:

matrix – Operator matrix.

Returns:

Number of elements only requiring computational basis measurements and how many do not.

slowquant.qiskit_interface.linear_response.lr_baseclass.get_num_nonCBS(matrix: list[list[str]]) int

Count number of non computational basis measurements in operator matrix.

Parameters:

matrix – Operator matrix.

Returns:

Number of non computational basis measurements.

class slowquant.qiskit_interface.linear_response.lr_baseclass.quantumLRBaseClass(wf: WaveFunctionCircuit)

Initialize linear response by calculating the needed matrices.

Parameters:

wf – Wavefunction object.

_analyze_std(A: ndarray, B: ndarray, Sigma: ndarray, max_values: int = 4, verbose: bool = True, cv: bool = True, save: bool = False) None

Analyze standard deviation in matrix elements of LR equation.

_get_CV_trend(re_calc: bool = False) tuple[list[list[float]], list[list[float]], list[list[float]]]

Analyze CV trend across excited states.

Parameters:

re_calc – Force recalculation of standard deviations.

Returns:

Weighted coefficient of variance for A, B and Sigma.

_get_excited_state_norm() ndarray

Calculate the norm of excited states.

Returns:

Norm of excited states.

_get_qbitmap() tuple[list[list[str]], list[list[str]], list[list[str]]]

Get qbitmapping of operators.

_get_std_trend(re_calc: bool = False) tuple[list[list[float]], list[list[float]], list[list[float]]]

Analyze standard deviation trend across excited states.

Parameters:

re_calc – Force recalculation of standard deviations.

Returns:

Weighted standard deviation for A, B and Sigma.

get_excitation_energies() ndarray

Solve LR eigenvalue problem.

get_excited_state_contributions(num_contr: int | None = None, cutoff: float = 0.01) None

Create table of contributions to each excitation vector.

Returns:

Nicely formatted table.

get_formatted_oscillator_strength() str

Create table of excitation energies and oscillator strengths.

Returns:

Nicely formatted table.

get_normed_excitation_vectors() None

Get normed excitation vectors via excitated state norm.

get_operator_info() None

Information about operators.

get_oscillator_strength(dipole_integrals: Sequence[ndarray]) ndarray

Calculate oscillator strength.

\[f_n = \frac{2}{3}e_n\left|\left<0\left|\hat{\mu}\right|n\right>\right|^2\]
Parameters:

dipole_integrals – Dipole integrals (x,y,z) in AO basis.

Rerturns:

Oscillator Strength.

get_transition_dipole(dipole_integrals: Sequence[ndarray]) ndarray

Calculate transtition dipole moment.

Parameters:

dipole_integrals – Dipole integrals (x,y,z) in AO basis.

Returns:

Transition dipole moments.

run() None

Run linear response.

run_std(no_coeffs: bool = False, verbose: bool = True, cv: bool = True, save: bool = False) tuple[list[list[float]], list[list[float]], list[list[float]]]

Get standard deviation in matrix elements of LR equation.

Parameters:
  • no_coeffs – Boolean to no include coefficients

  • verbose – Boolean to print more info

  • cv – Boolean to calculate coefficient of variance

  • save – Boolean to save operator-specific standard deviations

Returns:

Array of standard deviations for A, B and Sigma

class slowquant.qiskit_interface.linear_response.naive.quantumLR(wf: WaveFunctionCircuit)

Initialize linear response by calculating the needed matrices.

Parameters:

wf – Wavefunction object.

_get_qbitmap(cliques: bool = False, do_rdm: bool = False) tuple[list[list[str]], list[list[str]], list[list[str]]]

Get qubit map of operators.

Parameters:
  • cliques – If using cliques.

  • do_rdm – Use RDMs for QQ part.

Returns:

Qubit map of operators.

get_transition_dipole(dipole_integrals: Sequence[ndarray]) ndarray

Calculate transition dipole moment.

Parameters:

dipole_integrals – Dipole integrals ordered as (x,y,z).

Returns:

Transition dipole moment.

run(do_rdm: bool = True, do_gradients: bool = True) None

Run simulation of naive LR matrix elements.

Parameters:
  • do_rdm – Use RDMs for QQ part.

  • do_gradients – Calculate gradients w.r.t. orbital rotations and active space excitations.

run_std(no_coeffs: bool = False, verbose: bool = True, cv: bool = True, save: bool = False) tuple[ndarray, ndarray, ndarray]

Get standard deviation in matrix elements of LR equation.

Parameters:
  • no_coeffs – Boolean to no include coefficients

  • verbose – Boolean to print more info

  • cv – Boolean to calculate coefficient of variance

  • save – Boolean to save operator-specific standard deviations

Returns:

Array of standard deviations for A, B and Sigma

class slowquant.qiskit_interface.linear_response.projected.quantumLR(wf: WaveFunctionCircuit)

Initialize linear response by calculating the needed matrices.

Parameters:

wf – Wavefunction object.

_get_qbitmap(cliques: bool = False, do_rdm: bool = False) tuple[list[list[str]], list[list[str]], list[list[str]]]

Get qubit map of operators.

Parameters:
  • cliques – If using cliques.

  • do_rdm – Use RDMs for QQ part.

Returns:

Qubit map of operators.

_run_no_saving(do_rdm: bool = True, do_gradients: bool = True) None

Run simulation of projected LR matrix elements without re-using recourring matrix elements.

Parameters:
  • do_rdm – Use RDMs for QQ part.

  • do_gradients – Calculate gradients w.r.t. orbital rotations and active space excitations.

get_transition_dipole(dipole_integrals: Sequence[ndarray]) ndarray

Calculate transition dipole moment.

Parameters:

dipole_integrals – Dipole integrals ordered as (x,y,z).

Returns:

Transition dipole moment.

run(do_rdm: bool = True, do_gradients: bool = True) None

Run simulation of projected LR matrix elements.

Parameters:
  • do_rdm – Use RDMs for QQ part.

  • do_gradients – Calculate gradients w.r.t. orbital rotations and active space excitations.

run_std(no_coeffs: bool = False, verbose: bool = True, cv: bool = True, save: bool = False) tuple[ndarray, ndarray, ndarray]

Get standard deviation in matrix elements of LR equation.

Parameters:
  • no_coeffs – Boolean to no include coefficients

  • verbose – Boolean to print more info

  • cv – Boolean to calculate coefficient of variance

  • save – Boolean to save operator-specific standard deviations

Returns:

Array of standard deviations for A, B and Sigma