def test_h4ring_vqe_uccsd_microsoft_qsharp_size1(self): """ DMET on H4 ring with fragment size one, using VQE-UCCSD backend from Microsoft. """ mol = gto.Mole() mol.atom = H4_RING mol.basis = "minao" mol.charge = 0 mol.spin = 0 mol.build() # Initialize VQE object with MicrosoftQSharp backend from openqemist.quantum_solvers import MicrosoftQSharpParametricSolver from openqemist.electronic_structure_solvers import VQESolver vqe = VQESolver() vqe.hardware_backend_type = MicrosoftQSharpParametricSolver vqe.ansatz_type = MicrosoftQSharpParametricSolver.Ansatze.UCCSD # Run DMET dmet = DMETProblemDecomposition() dmet.electron_localization_method = meta_lowdin_localization dmet.electronic_structure_solver = vqe energy_vqe = dmet.simulate(mol, [1, 1, 1, 1]) self.assertAlmostEqual(energy_vqe, -1.9916120594, delta=1e-3)
def test_h4ring_vqe_uccsd_qiskit_size2(self): """ DMET on H4 ring with fragment size two, using VQE-UCCSD backend from Qiskit. """ 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 = QiskitParametricSolver vqe.ansatz_type = QiskitParametricSolver.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_tetra_ml_fci_no_mf(self): mol = gto.Mole() mol.atom = TETRA mol.basis = "3-21g" mol.charge = 0 mol.spin = 0 mol.build() solver = DMETProblemDecomposition() solver.electron_localization_method = meta_lowdin_localization solver.electronic_structure_solver = CCSDSolver() energy = solver.simulate(mol, [1,1,1,1,1,1,1,1]) self.assertAlmostEqual(energy, -153.1879732845, places=6)
def test_hring_ml_fci_no_mf(self): mol = gto.Mole() mol.atom = H10_RING mol.basis = "3-21g" mol.charge = 0 mol.spin = 0 mol.build() solver = DMETProblemDecomposition() solver.electron_localization_method = meta_lowdin_localization solver.electronic_structure_solver = FCISolver() energy = solver.simulate(mol, [1,1,1,1,1,1,1,1,1,1]) self.assertAlmostEqual(energy, -4.4989730244, places=6)
def test_incorrect_number_atoms(self): """Tests if the program raises the error when the number of fragment sites is not equal to the number of atoms in the molecule.""" mol = gto.Mole() mol.atom = H10_RING mol.basis = "3-21g" mol.charge = 0 mol.spin = 0 mol.build() solver = DMETProblemDecomposition() solver.electron_localization_method = meta_lowdin_localization solver.electronic_structure_solver = FCISolver() # The molecule has more atoms than this. self.assertRaises(RuntimeError, solver.simulate, mol, [1, 1, 1, 1])
def test_h4ring_ml_fci_no_mf_minao(self): """ Tests the result from DMET against a value from a reference implementation with meta-lowdin localization and FCI solution to fragments.""" mol = gto.Mole() mol.atom = H4_RING mol.basis = "minao" mol.charge = 0 mol.spin = 0 mol.build() solver = DMETProblemDecomposition() solver.electron_localization_method = meta_lowdin_localization solver.electronic_structure_solver = FCISolver() energy = solver.simulate(mol, [1,1,1,1]) self.assertAlmostEqual(energy, -1.9916120594, places=4)
def test_h4ring_iao_ccsd_no_mf_321g(self): """ Tests the result from DMET against a value from a reference implementation with IAO localization, 3-21g basis, and CCSD solution to fragments.""" mol = gto.Mole() mol.atom = H4_RING mol.basis = "3-21g" mol.charge = 0 mol.spin = 0 mol.build() solver = DMETProblemDecomposition() solver.electron_localization_method = iao_localization solver.electronic_structure_solver = CCSDSolver() energy = solver.simulate(mol, [2,2]) self.assertAlmostEqual(energy, -2.0290205366, places=6)