openqemist.tests.electronic_structure_solvers.vqe_solver package

Submodules

openqemist.tests.electronic_structure_solvers.vqe_solver.test_vqe_solver module

class openqemist.tests.electronic_structure_solvers.vqe_solver.test_vqe_solver.MockQuantumSolver(ansatz, molecule, mean_field=None, backend_parameters={})[source]

Bases: openqemist.quantum_solvers.parametric_quantum_solver.ParametricQuantumSolver

Class that mocks out the abstract ParametricQuantumSolver for testing.

For the purpose of this test, all we need is that we return the same thing, causing the optimizer to converge. We assume that the optimizer is working correctly.

class Ansatze[source]

Bases: enum.Enum

An enumeration.

UCCSD = 0
default_initial_var_parameters()[source]

Returns reasonably good initial parameters for a VQE simulation.

The construction of the object should set the state so that this function can produce its output.

get_rdm()[source]

Returns the RDM from the simulation.

This is intended to be called after the simulation loop of the calling code has converged to be passed on to problem decompositions. In a concrete implementation, the simulate function would set the necessary internal state for the class so that this function can return the reduced density matrix.

Returns

The one- and two-element RDMs (float64).

Return type

(numpy.array, numpy.array)

Raises

RuntimeError – If no simulation has been run.

simulate(amplitudes)[source]

Performs an energy simulation for the given amplitudes.

Parameters

amplitudes (list) – The amplitudes to use in the simulation.

Returns

The energy from the simulation.

Return type

float

Raises

ValueError – If len(amplitudes) doesn’t equal amplitude_dimension.

class openqemist.tests.electronic_structure_solvers.vqe_solver.test_vqe_solver.VQESolverTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_get_rdm_no_sim()[source]

Tests that exception is raised when calling get_rdm before simulate

test_mock()[source]

Test that the solver returns with the default optimizer from scipy.

Since simlate is always returning the same number, this should force the optimizer to converge.

Module contents