tangelo.algorithms.variational package

Subpackages

Submodules

tangelo.algorithms.variational.adapt_vqe_solver module

Module that defines the ADAPT-VQE algorithm framework. ADAPT-VQE is a variational approach that builds an ansatz iteratively, until a convergence criteria or a maximum number of cycles is reached. Each iteration (“cycle”) of ADAPT consists in drawing an operator from a pre-defined operator pool, selecting the one that impacts the energy the most, growing the ansatz circuit accordingly, and optimizing the variational parameters using VQE.

Ref:

Grimsley, H.R., Economou, S.E., Barnes, E. et al. An adaptive variational algorithm for exact molecular simulations on a quantum computer. Nat Commun 10, 3007 (2019). https://doi.org/10.1038/s41467-019-10988-2.

class tangelo.algorithms.variational.adapt_vqe_solver.ADAPTSolver(opt_dict)

Bases: object

ADAPT VQE class. This is an iterative algorithm that uses VQE. Methods are defined to rank operators with respect to their influence on the total energy.

molecule

The molecular system.

Type:

SecondQuantizedMolecule

tol

Maximum gradient allowed for a particular operator before convergence.

Type:

float

max_cycles

Maximum number of iterations for ADAPT.

Type:

int

pool

Function that returns a list of FermionOperator or QubitOperator. Each element represents excitation/operator that has an effect of the total energy.

Type:

func

pool_args

The arguments for the pool function. Will be unpacked in function call as pool(**pool_args)

Type:

dict

qubit_mapping

One of the supported qubit mapping identifiers.

Type:

str

qubit_hamiltonian

Self-explanatory.

Type:

QubitOperator-like

up_then_down

Spin orbitals ordering.

Type:

bool

n_spinorbitals

Self-explanatory.

Type:

int

n_electrons

Self-explanatory.

Type:

int

spin

The spin of the system (# alpha - # beta electrons)

Type:

int

optimizer

Optimization function for VQE minimization.

Type:

func

backend_options

Backend options for the underlying VQE object.

Type:

dict

simulate_options

Options for fine-control of the simulator backend, including desired measurement results, etc.

Type:

dict

verbose

Flag for verbosity of VQE.

Type:

bool

deflation_circuits

Deflation circuits to add an orthogonalization penalty with.

Type:

list[Circuit]

deflation_coeff

The coefficient of the deflation.

Type:

float

projective_circuit

A terminal circuit that projects into the correct space, always added to the end of the ansatz circuit.

Type:

Circuit

ref_state

The reference configuration to use. Replaces HF state

Type:

array or Circuit

LBFGSB_optimizer(func, var_params)

Default optimizer for ADAPT-VQE.

build()

Builds the underlying objects required to run the ADAPT-VQE algorithm.

choose_operator(gradients, tolerance=0.001)

Choose next operator to add according to the ADAPT-VQE algorithm.

Parameters:
  • gradients (list of float) – Operator gradients corresponding to self.pool_operators.

  • tolerance (float) – Minimum value for gradient to be considered.

Returns:

list of int – Index (list of length=1) of the operator with the highest gradient. If it is not bigger than tolerance, returns an empty list.

compute_gradients(circuit, backend)

Compute gradients for the operator pool with a specific circuit.

Args:

circuit (tangelo.linq.Circuit): Circuit for measuring each commutator. backend (tangelo.linq.Backend): Backend to compute expectation values.

Returns:

list of float – Operator gradients.

property ferm_operators
get_resources()

Returns resources currently used in underlying VQE.

property operators
simulate()

Performs the ADAPT cycles. Each iteration, a VQE minimization is done.

tangelo.algorithms.variational.iqcc_ilc_solver module

This module implements the iQCC-ILC VQE procedure of Refs. 1-2. It is an iterative and variational approach that combines an ansatz defined as an exponentiated involutory linear combination (ILC) of mutually anticommuting Pauli word generators with the QCC ansatz. A small number of iterations are performed with the ILC ansatz prior to a single energy evaluation with the QCC ansatz. The advantage of this method over the iQCC VQE procedure is that Hamiltonian dressing after each iteration with the set of ILC generators results in quadratic growth of the number of terms, which is an improvement over the exponential growth that occurs when QCC generators are used. Refs:

      1. Lang, I. G. Ryabinkin, and A. F. Izmaylov.

    arXiv:2002.05701v1, 2020, 1–10.

      1. Lang, I. G. Ryabinkin, and A. F. Izmaylov.

    1. Chem. Theory Comput. 2021, 17, 1, 66–78.

class tangelo.algorithms.variational.iqcc_ilc_solver.iQCC_ILC_solver(opt_dict)

Bases: object

The iQCC-ILC-VQE solver class combines the both the ILC and ILC ansatze Classes with the VQESolver class to perform an iterative and variational procedure to compute the total iQCC-ILC energy for a given Hamiltonian. The algorithm is outlined below: (1) For a user-specified number of iterations, compute the ILC energy:

  1. prepare/purify the QMF wave function, obtain the ACS of ILC generators, and initialize the ILC parameter set;

  2. simulate the ILC energy through VQE minimization

  3. dress the qubit Hamiltonian with the set of ILC generators and optimal parameters; optional: compress the dressed Hamiltonian via a technique using the Frobenius norm

  1. With the ILC dressed Hamiltonian, obtain the DIS of QCC generators, and initialize QCC parameters

  2. Perform a single VQE minimization of the QCC energy functional to obtain the final iQCC-ILC energy.

molecule

The molecular system.

Type:

SecondQuantizedMolecule

qubit_mapping

One of the supported qubit mapping identifiers. Default, “jw”.

Type:

str

up_then_down

Change basis ordering putting all spin up orbitals first, followed by all spin down. Default, False.

Type:

bool

initial_var_params

Initial values of the variational parameters for the classical optimizer.

Type:

str or array-like

backend_options

parameters to build the underlying compute backend (simulator, etc).

Type:

dict

penalty_terms

Parameters for penalty terms to append to target qubit Hamiltonian (see penaly_terms for more details).

Type:

dict

ilc_ansatz_options

Parameters for ILC ansatz (see ILC ansatz file for details).

Type:

dict

qcc_ansatz_options

Parameters for QCC ansatz (see QCC ansatz file for details).

Type:

dict

qubit_hamiltonian

Self-explanatory.

Type:

QubitOperator-like

max_ilc_iter

maximum number of ILC iterations allowed before termination. Default, 3.

Type:

int

compress_qubit_ham

controls whether the qubit Hamiltonian is compressed after dressing with the current set of generators at the end of each ILC iteration. Default, False.

Type:

bool

compress_eps

parameter required for compressing intermediate ILC Hamiltonians using the Froebenius norm. Discarding terms in this manner will not alter the eigenspectrum of intermediate Hamiltonians by more than compress_eps. Default, 1.59e-3 Hartree.

Type:

float

verbose

Flag for verbosity. Default, False.

Type:

bool

build()

Builds the underlying objects required to run the ILC-VQE algorithm.

get_resources()

Returns the quantum resource estimates for the final ILC-QCC-VQE iteration.

simulate()

Executes the ILC-VQE algorithm. During each iteration, a ILC-VQE minimization is performed with the current set of generators, amplitudes, and qubit Hamiltonian.

tangelo.algorithms.variational.iqcc_solver module

This module implements the iterative qubit coupled cluster (iQCC)-VQE procedure of Ref. 1. It is a variational approach that utilizes the the QCC ansatz to produce shallow circuits. The iterative procedure allows a small number (1—10) of generators to be used for the QCC This results in even shallower circuits and fewer quantum resources for the iQCC approach relative to the native QCC method. A caveat is that after each iteration, the qubit Hamiltonian is dressed with the generators and optimal parameters, the result of which is an exponential growth of the number of terms.

Refs:
      1. Ryabinkin, R. A. Lang, S. N. Genin, and A. F. Izmaylov.

    1. Chem. Theory Comput. 2020, 16, 2, 1055–1063.

class tangelo.algorithms.variational.iqcc_solver.iQCC_solver(opt_dict)

Bases: object

The iQCC-VQE solver class combines the QCC ansatz and VQESolver classes to perform an iterative and variational procedure to compute the total QCC energy for a given Hamiltonian. The algorithm is outlined below:

  1. Prepare a qubit Hamiltonian, initialize QMF parameters, construct the DIS, select QCC generators, and initialize QCC amplitudes.

  2. Simulate the QCC energy through VQE minimization.

  3. Check if the energy is lowered relative to the previous iteration.

  4. If the energy is lowered, proceed to (4); else, keep the QCC generators, re-initialize the amplitudes, and re-compute the energy. If after several attempts the energy is not lowered, set all QCC amplitudes to zero and use the QMF parameters from the previous iteration to compute the energy. This is guaranteed to yield a lower energy.

  5. Check termination criteria: terminate if the change in energy is below a threshold, the DIS is empty, or the maximum number of iterations is reached.

  6. If not terminated, dress the qubit Hamiltonian with the current QCC generators and optimal amplitudes.

  7. Purify the QMF parameters, rebuild the DIS, and select generators for the next iteration; return to (1) and repeat until termination.

molecule

The molecular system.

Type:

SecondQuantizedMolecule

qubit_mapping

One of the supported qubit mapping identifiers. Default, “jw”.

Type:

str

up_then_down

Change basis ordering putting all spin up orbitals first, followed by all spin down. Default, False.

Type:

bool

initial_var_params

Initial values of the variational parameters for the classical optimizer.

Type:

str or array-like

backend_options

parameters to build the underlying compute backend (simulator, etc).

Type:

dict

penalty_terms

Parameters for penalty terms to append to target qubit Hamiltonian (see penaly_terms for more details).

Type:

dict

ansatz_options

Parameters for the chosen ansatz (see given ansatz file for details).

Type:

dict

qubit_hamiltonian

Self-explanatory.

Type:

QubitOperator-like

deqcc_thresh

threshold for the difference in iQCC energies between consecutive iterations required for convergence of the algorithm. Default, 1e-5 Hartree.

Type:

float

max_iqcc_iter

maximum number of iQCC iterations allowed before termination. Default, 100.

Type:

int

max_iqcc_retries

if the iQCC energy for a given iteration is not lower than the value from the previous iteration, the iQCC parameters are reinitialized and the VQE procedure will be attempted up to max_iqcc_retries times. If unsuccessful after max_iqcc_retries attempts, the iQCC parameters are all set to 0 and the QMF Bloch angles from the previous iteration are used. Default, 10.

Type:

int

compress_qubit_ham

controls whether the qubit Hamiltonian is compressed after dressing with the current set of generators at the end of each iQCC iteration. Default, False.

Type:

bool

compress_eps

parameter required for compressing intermediate iQCC Hamiltonians using the Froebenius norm. Discarding terms in this manner will not alter the eigenspeectrum of intermediate Hamiltonians by more than compress_eps. Default, 1.59e-3 Hartree.

Type:

float

verbose

Flag for verbosity. Default, False.

Type:

bool

build()

Builds the underlying objects required to run the iQCC-VQE algorithm.

get_resources()

Returns the quantum resource estimates for the final iQCC-VQE iteration.

simulate()

Executes the iQCC-VQE algorithm. During each iteration, QCC-VQE minimization is performed.

tangelo.algorithms.variational.sa_oo_vqe_solver module

Module that defines the SA-OO-VQE algorithm

Ref: [1] Saad Yalouz, Bruno Senjean, Jakob Gunther, Francesco Buda, Thomas E. O’Brien, Lucas Visscher, “A state-averaged orbital-optimized hybrid quantum-classical algorithm for a democratic description of ground and excited states”, 2021, Quantum Sci. Technol. 6 024004

class tangelo.algorithms.variational.sa_oo_vqe_solver.SA_OO_Solver(opt_dict: dict)

Bases: SA_VQESolver

State Averaged Orbital Optimized Solver class. This is an iterative algorithm that uses SA-VQE alternatively with an orbital optimization step.

Users must first set the desired options of the SA_OO_Solver object through the __init__ method, and call the “build” method to build the underlying objects (mean-field, hardware backend, ansatz…). They are then able to call any of the energy_estimation, simulate, get_rdm, or iterate methods. In particular, iterate runs the SA-OO algorithm, alternating calls to the SA_VQESolver and orbital optimization.

tol

Maximum energy difference before convergence

Type:

float

max_cycles

Maximum number of iterations for sa-oo-vqe

Type:

int

n_oo_per_iter

Number of orbital optimization Newton-Raphson steps per SA-OO-VQE iteration

Type:

int

molecule

the molecular system.

Type:

SecondQuantizedMolecule

qubit_mapping

one of the supported qubit mapping identifiers.

Type:

str

ansatz

one of the supported ansatze.

Type:

Ansatze

optimizer

a function defining the classical optimizer and its behavior.

Type:

function handle

initial_var_params

initial value for the classical optimizer.

Type:

str or array-like

backend_options

parameters to build the underlying compute backend (simulator, etc).

Type:

dict

simulate_options

Options for fine-control of the simulator backend, including desired measurement results, etc.

Type:

dict

penalty_terms

parameters for penalty terms to append to target qubit Hamiltonian (see penalty_terms for more details).

Type:

dict

ansatz_options

parameters for the given ansatz (see given ansatz file for details).

Type:

dict

up_then_down

change basis ordering putting all spin up orbitals first, followed by all spin down. Default, False has alternating spin up/down ordering.

Type:

bool

qubit_hamiltonian

Self-explanatory.

Type:

QubitOperator-like

verbose

Flag for VQE verbosity.

Type:

bool

projective_circuit

A terminal circuit that projects into the correct space, always added to the end of the ansatz circuit.

Type:

Circuit

ref_states

The vector occupations of the reference configurations

Type:

list

weights

The weights of the occupations

Type:

array

energy_from_rdms()

Calculate energy from rdms generated from SA_VQESolver

generate_oo_unitary()

Generate the orbital optimization unitary that rotates the orbitals. It uses n_oo_per_iter Newton-Raphson steps with the Hessian calculated analytically.

The unitary is generated using the method outlined in [1] Per E. M. Siegbahn, Jan Almlof, Anders Heiberg, and Bjorn O. Roos, “The complete active space SCF (CASSCF) method in a Newton-Raphson formulation with application to the HNO molecule”, J. Chem. Phys. 74, 2384-2396 (1981)

Returns:

array – The unitary matrix that when applied to the mean-field coefficients reduces the state averaged energy

iterate()

Performs the SA-OO-VQE iterations.

Each iteration, a SA-VQE minimization is performed followed by an orbital optimization. This process repeats until max_cycles are reached or the change in energy is less than tol.

tangelo.algorithms.variational.sa_vqe_solver module

Implements the state-averaged variational quantum eigensolver. Also known as the subspace-search variational quantum eigensolver.

Ref: [1] Saad Yalouz, Bruno Senjean, Jakob Gunther, Francesco Buda, Thomas E. O’Brien, Lucas Visscher, “A state-averaged orbital-optimized hybrid quantum-classical algorithm for a democratic description of ground and excited states”, 2021, Quantum Sci. Technol. 6 024004 [2] Ken M Nakanishi, Kosuke Mitarai, Keisuke Fujii, “Subspace-search variational quantum eigensolver for excited states”, Phys. Rev. Research 1, 033062 (2019)

class tangelo.algorithms.variational.sa_vqe_solver.SA_VQESolver(opt_dict)

Bases: VQESolver

Solve the electronic structure problem for a molecular system by using the state-averaged variational quantum eigensolver (SA-VQE) algorithm.

This algorithm evaluates the energy of a molecular system by performing classical optimization over a parametrized ansatz circuit for multiple reference states.

Users must first set the desired options of the SA_VQESolver object through the __init__ method, and call the “build” method to build the underlying objects (mean-field, hardware backend, ansatz…). They are then able to call any of the energy_estimation, simulate, or get_rdm methods. In particular, simulate runs the VQE algorithm, returning the optimal energy found by the classical optimizer.

molecule

the molecular system.

Type:

SecondQuantizedMolecule

qubit_mapping

one of the supported qubit mapping identifiers.

Type:

str

ansatz

one of the supported ansatze.

Type:

Ansatze

optimizer

a function defining the classical optimizer and its behavior.

Type:

function handle

initial_var_params

initial value for the classical optimizer.

Type:

str or array-like

backend_options

parameters to build the underlying compute backend (simulator, etc).

Type:

dict

simulate_options

Options for fine-control of the simulator backend, including desired measurement results, etc.

Type:

dict

penalty_terms

parameters for penalty terms to append to target qubit Hamiltonian (see penalty_terms for more details).

Type:

dict

deflation_circuits

Deflation circuits to add an orthogonalization penalty with.

Type:

list[Circuit]

deflation_coeff

The coefficient of the deflation.

Type:

float

ansatz_options

parameters for the given ansatz (see given ansatz file for details).

Type:

dict

up_then_down

change basis ordering putting all spin up orbitals first, followed by all spin down. Default, False has alternating spin up/down ordering.

Type:

bool

qubit_hamiltonian

Self-explanatory.

Type:

QubitOperator-like

verbose

Flag for VQE verbosity.

Type:

bool

projective_circuit

A terminal circuit that projects into the correct space, always added to the end of the ansatz circuit.

Type:

Circuit

ref_states

The vector occupations of the reference configurations or the reference circuits.

Type:

list

weights

The weights of the occupations

Type:

array

build()

Build the underlying objects required to run the SA-VQE algorithm afterwards.

energy_estimation(var_params)

Estimate state-averaged energy using the given ansatz, qubit hamiltonian and compute backend. Keeps track of optimal energy and variational parameters along the way.

Parameters:

var_params (numpy.array or str) – variational parameters to use for VQE energy evaluation.

Returns:

float – energy computed by VQE using the ansatz and input variational parameters.

get_resources()

Estimate the resources required by SA-VQE, with the current ansatz. This assumes “build” has been run, as it requires the ansatz circuit and the qubit Hamiltonian. Return information that pertains to the user, for the purpose of running an experiment on a classical simulator or a quantum device.

simulate()

Run the SA-VQE algorithm, using the ansatz, classical optimizer, initial parameters and hardware backend built in the build method.

tangelo.algorithms.variational.tetris_adapt_vqe_solver module

Module that defines the TETRIS-ADAPT-VQE algorithm framework. Differences vs ADAPT-VQE: more than one operators acting on different qubits can be added to the adaptive ansatz during the same ADAPT cycle. This algorithm creates denser circuits.

Ref:

Panagiotis G. Anastasiou, Yanzhu Chen, Nicholas J. Mayhall, Edwin Barnes, and Sophia E. Economou. TETRIS-ADAPT-VQE: An adaptive algorithm that yields shallower, denser circuit ansätze arXiv:2209.10562 (2022)

class tangelo.algorithms.variational.tetris_adapt_vqe_solver.TETRISADAPTSolver(opt_dict)

Bases: ADAPTSolver

TETRIS-ADAPT-VQE class. This is an iterative algorithm that uses VQE. A single method is redefined from ADAPTSolver to allow the addition of many operators per ADAPT cycle.

choose_operator(gradients, tolerance=0.001)

Choose the next operator(s) to add according to the TETRIS-ADAPT-VQE algorithm.

Parameters:
  • gradients (list of float) – Operator gradients (absolute values) corresponding to self.pool_operators.

  • tolerance (float) – Minimum value for gradient to be considered.

Returns:

list of int – Indice(s) of the operator(s) to be considered for this ADAPT cycle.

tangelo.algorithms.variational.vqe_solver module

Implements the variational quantum eigensolver (VQE) algorithm to solve electronic structure calculations.

class tangelo.algorithms.variational.vqe_solver.BuiltInAnsatze(value)

Bases: Enum

Enumeration of the ansatz circuits supported by VQE.

HEA = <class 'tangelo.toolboxes.ansatz_generator.hea.HEA'>
ILC = <class 'tangelo.toolboxes.ansatz_generator.ilc.ILC'>
QCC = <class 'tangelo.toolboxes.ansatz_generator.qcc.QCC'>
QMF = <class 'tangelo.toolboxes.ansatz_generator.qmf.QMF'>
UCC1 = <tangelo.toolboxes.ansatz_generator.rucc.RUCC object>
UCC3 = <tangelo.toolboxes.ansatz_generator.rucc.RUCC object>
UCCGD = <class 'tangelo.toolboxes.ansatz_generator.uccgd.UCCGD'>
UCCSD = <class 'tangelo.toolboxes.ansatz_generator.uccsd.UCCSD'>
UpCCGSD = <class 'tangelo.toolboxes.ansatz_generator.upccgsd.UpCCGSD'>
VSQS = <class 'tangelo.toolboxes.ansatz_generator.vsqs.VSQS'>
pUCCD = <class 'tangelo.toolboxes.ansatz_generator.puccd.pUCCD'>
class tangelo.algorithms.variational.vqe_solver.VQESolver(opt_dict)

Bases: object

Solve the electronic structure problem for a molecular system by using the variational quantum eigensolver (VQE) algorithm.

This algorithm evaluates the energy of a molecular system by performing classical optimization over a parametrized ansatz circuit.

Users must first set the desired options of the VQESolver object through the __init__ method, and call the “build” method to build the underlying objects (mean-field, hardware backend, ansatz…). They are then able to call any of the energy_estimation, simulate, or get_rdm methods. In particular, simulate runs the VQE algorithm, returning the optimal energy found by the classical optimizer.

molecule

the molecular system.

Type:

SecondQuantizedMolecule

qubit_mapping

one of the supported qubit mapping identifiers.

Type:

str

ansatz

one of the supported ansatze.

Type:

Ansatze

optimizer

a function defining the classical optimizer and its behavior.

Type:

function handle

initial_var_params

initial value for the classical optimizer.

Type:

str or array-like

backend_options

parameters to build the underlying compute backend (simulator, etc).

Type:

dict

simulate_options

Options for fine-control of the simulator backend, including desired measurement results, etc.

Type:

dict

penalty_terms

parameters for penalty terms to append to target qubit Hamiltonian (see penalty_terms for more details).

Type:

dict

deflation_circuits

Deflation circuits to add an orthogonalization penalty with.

Type:

list[Circuit]

deflation_coeff

The coefficient of the deflation.

Type:

float

ansatz_options

parameters for the given ansatz (see given ansatz file for details).

Type:

dict

up_then_down

change basis ordering putting all spin up orbitals first, followed by all spin down. Default, False has alternating

spin up/down ordering.

Type:

bool

qubit_hamiltonian

Self-explanatory.

Type:

QubitOperator-like

verbose

Flag for VQE verbosity.

Type:

bool

projective_circuit

A terminal circuit that projects into the correct space, always added to the end of the ansatz circuit.

Type:

Circuit

ref_state

The reference configuration to use. Replaces HF state QMF, QCC, ILC require ref_state to be an array. UCC1, UCC3, VSQS can not use a different ref_state than HF by construction.

Type:

array or Circuit

save_energies

Flag for saving energy estimation values.

Type:

bool

build()

Build the underlying objects required to run the VQE algorithm afterwards.

energy_estimation(var_params)

Estimate energy using the given ansatz, qubit hamiltonian and compute backend. Keeps track of optimal energy and variational parameters along the way.

Parameters:

var_params (numpy.array or str) – variational parameters to use for VQE energy evaluation.

Returns:

float – energy computed by VQE using the ansatz and input variational parameters.

get_rdm(var_params, resample=False, sum_spin=True, ref_state=<tangelo.linq.circuit.Circuit object>)

Compute the 1- and 2- RDM matrices using the VQE energy evaluation. This method allows to combine the DMET problem decomposition technique with the VQE as an electronic structure solver. The RDMs are computed by using each fermionic Hamiltonian term, transforming them and computing the elements one-by-one. Note that the Hamiltonian coefficients will not be multiplied as in the energy evaluation. The first element of the Hamiltonian is the nuclear repulsion energy term, not the Hamiltonian term.

Parameters:
  • var_params (numpy.array or list) – variational parameters to use for rdm calculation

  • resample (bool) – Whether to resample saved frequencies. get_rdm with savefrequencies=True must be called or a dictionary for each qubit terms’ frequencies must be set to self.rdm_freq_dict

  • sum_spin (bool) – If True, the spin-summed 1-RDM and 2-RDM will be returned. If False, the full 1-RDM and 2-RDM will be returned.

  • ref_state (Circuit) – A reference state preparation circuit.

Returns:

(numpy.array, numpy.array) – One & two-particle spin summed RDMs if sumspin=True or the full One & two-Particle RDMs if sumspin=False.

get_rdm_uhf(var_params, resample=False, ref_state=<tangelo.linq.circuit.Circuit object>)

Compute the 1- and 2- RDM matrices using the VQE energy evaluation. This method allows to combine the DMET problem decomposition technique with the VQE as an electronic structure solver. The RDMs are computed by using each fermionic Hamiltonian term, transforming them and computing the elements one-by-one. Note that the Hamiltonian coefficients will not be multiplied as in the energy evaluation. The first element of the Hamiltonian is the nuclear repulsion energy term, not the Hamiltonian term.

Parameters:
  • var_params (numpy.array or list) – variational parameters to use for rdm calculation

  • resample (bool) – Whether to resample saved frequencies. get_rdm with savefrequencies=True must be called or a dictionary for each qubit terms’ frequencies must be set to self.rdm_freq_dict

  • ref_state (Circuit) – A reference state preparation circuit.

Returns: TODO
(numpy.array, numpy.array): One & two-particle spin summed RDMs if

sumspin=True or the full One & two-Particle RDMs if sumspin=False.

get_resources()

Estimate the resources required by VQE, with the current ansatz. This assumes “build” has been run, as it requires the ansatz circuit and the qubit Hamiltonian. Return information that pertains to the user, for the purpose of running an experiment on a classical simulator or a quantum device.

operator_expectation(operator, var_params=None, n_active_mos=None, n_active_electrons=None, n_active_sos=None, spin=None, ref_state=<tangelo.linq.circuit.Circuit object>)

Obtains the operator expectation value of a given operator.

Parameters:
  • operator (str or QubitOperator) – The operator to find the expectation value of str availability: - N : Particle number - Sz: Spin in z-direction - S^2: Spin quantum number s(s+1)

  • var_params (str or numpy.array) – variational parameters to use for VQE expectation value evaluation.

  • n_active_mos (int) – The number of active_mos (int). Only required when using a str input and VQESolver is initiated with a QubitHamiltonian.

  • n_active_electrons (int) – The number of active electrons. Only required when operator is of type FermionOperator and mapping used is scbk and vqe_solver was initiated using a QubitHamiltonian.

  • n_active_sos (int) – Number of active spin orbitals. Only required when operator is of type FermionOperator and mapping used is scbk and vqe_solver was initiated using a QubitHamiltonian.

  • spin (int) – Spin (n_alpha - n_beta)

  • ref_state (Circuit) – A reference state preparation circuit

Returns:

float – operator expectation value computed by VQE using the ansatz and input variational parameters.

simulate()

Run the VQE algorithm, using the ansatz, classical optimizer, initial parameters and hardware backend built in the build method.

Module contents