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.
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.
A type for the backend instance that is automatically constructed.
subclass of ParametricQuantumSolver
Type of ansatz that is supported by the backend.
subclass of Enum
Function that is called to optimize.
Function that returns the initial amplitudes used for the optimization.
The initial amplitudes for the optimzation.
Controls the verbosity of the default optimizer.
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.
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.
One & two-particle RDMs (float64).
- Return type
RuntimeError – If no simulation has been run.
Perform the simulation for the molecule.
If the mean field is not provided it is automatically calculated.
molecule (pyscf.gto.Mole) – The molecule to simulate.
mean_field (pyscf.scf.RHF) – The mean field of the molecule.