# openqemist.electronic_structure_solvers.vqe_solver package¶

## openqemist.electronic_structure_solvers.vqe_solver.vqe_solver module¶

Perform quantum simulation based on VQE algorithm.

The electronic structure calculation employing the quantum/classical hybrid variational quantum eigensolver (VQE) algorithm is done here. The quantum eigensolver runs inside the classical optimizer.

There are options for which hardware backend can be used.

class openqemist.electronic_structure_solvers.vqe_solver.vqe_solver.VQESolver[source]

Estimates energy wih a variational quantum eigensolver algorithm.

Uses the VQE algorithm to solve the electronic structure problem. By default an optimizer from scipy is used, but users can set any function whose first argument is the simulate function of the hardware backend and the second is the amplitudes to optimize over and returns a energy. See the implementation of _default_optimizer for a concrete example. Users should provide a hardware backend type that conforms to the interface of openqemist.quantum_solver.ParametricQuantumSolver that the VQESolver will construct and use. Users should also provide an ansatze type that is supported by the backend. Users can also provide a function that takes a pyscf.gto.Mole as its first argument and pyscf.scf.RHF as is second and returns the inital amplitudes for the variational optimization. The user is responsible for ensuring that the dimension of the amplitudes vector is correct for the given molecule and andsatz choice.

hardware_backend_type

A type for the backend instance that is automatically constructed.

Type

subclass of ParametricQuantumSolver

ansatz_type

Type of ansatz that is supported by the backend.

Type

subclass of Enum

optimizer

Function that is called to optimize.

Type

function

initial_var_params

Initial values of the variational parameters used in the classical optimization process

Type

list

verbose

Controls the verbosity of the default optimizer.

Type

boolean

backend_parameters

Extra parameters that can be forwarded to the parametric quantum solver.

Type

dict

Note

Initial variational parameters can be specified through the initial_var_params argument. If this is not specified, then the default_initial_var_parameters function provided by the hardware backend is used.

get_rdm()[source]

Returns the RDM from the hardware backend.

Returns the reduced density matrices from the hardware backend. Does not catch and exceptions that the hardware backend raises if it is not in a state to return the RDM.

Returns

One & two-particle RDMs (float64).

Return type

(numpy.array,numpy.array)

Raises

RuntimeError – If no simulation has been run.

simulate(molecule, mean_field=None)[source]

Perform the simulation for the molecule.

If the mean field is not provided it is automatically calculated.

Parameters
• molecule (pyscf.gto.Mole) – The molecule to simulate.

• mean_field (pyscf.scf.RHF) – The mean field of the molecule.