def test_h2_321g(self): """ Test the converged energy of VQE with initial variational parameters provided by the user """ mol = gto.Mole() mol.atom = H2 mol.basis = "3-21g" mol.charge = 0 mol.spin = 0 mol.build() solver = VQESolver() solver.hardware_backend_type = QiskitParametricSolver solver.ansatz_type = QiskitParametricSolver.Ansatze.UCCSD solver.initial_var_params = [ -0.01039529, -0.04685435, -0.01858744, -0.01118045, -0.04674074, -0.01848484, -0.12702138, -0.0222594, 0.04799664, -0.02237422, -0.04972733, 0.01266251, 0.04764409, 0.01265669, -0.06169727 ] energy = solver.simulate(mol) self.assertAlmostEqual(energy, -1.1478300615818977, delta=1e-3)
def test_h4ring_vqe_uccsd_rigetti_size2(self): """ DMET on H4 ring with fragment size two, using VQE-UCCSD backend """ mol = gto.Mole() mol.atom = H4_RING mol.basis = "minao" mol.charge = 0 mol.spin = 0 mol.build() # Initialize VQE object with Qiskit backend vqe = VQESolver() vqe.hardware_backend_type = RigettiParametricSolver vqe.ansatz_type = RigettiParametricSolver.Ansatze.UCCSD # Run DMET dmet = DMETProblemDecomposition() dmet.electron_localization_method = meta_lowdin_localization dmet.electronic_structure_solver = vqe energy_vqe = dmet.simulate(mol, [2, 2]) self.assertAlmostEqual(energy_vqe, -1.9916120594, delta=1e-3)
def test_h2_321g(self): """ Test the converged energye of VQE """ from openqemist.quantum_solvers import MicrosoftQSharpParametricSolver mol = gto.Mole() mol.atom = H2 mol.basis = "3-21g" mol.charge = 0 mol.spin = 0 mol.build() solver = VQESolver() solver.hardware_backend_type = MicrosoftQSharpParametricSolver solver.ansatz_type = MicrosoftQSharpParametricSolver.Ansatze.UCCSD solver.initial_var_params = [ -0.003013364325590502, 0.005694780930328863, 0.00035386539723315964, 0.04244748156400211, 0.02380828037656643, 0.018789486618923344, 0.0007322518664444671, 0.04376425859874745, 8.503425743572844e-05 ] energy = solver.simulate(mol) self.assertAlmostEqual(energy, -1.1478300615818977, delta=1e-3)