openqemist.electronic_structure_solvers.vqe_solver package

Submodules

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]

Bases: openqemist.electronic_structure_solvers.electronic_structure_solver.ElectronicStructureSolver

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_amplitude_function

Function that returns the initial amplitudes used for the optimization.

Type

function

initial_amplitudes

The initial amplitudes for the optimzation.

Type

list

verbose

Controls the verbosity of the default optimizer.

Type

boolean

Note

Initial amplitudes can be specified both through the functional parameter initial_amplitude_function and through the initial_amplitudes. If both are specified the initial_amplitudes are 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.

Module contents