예제 #1
0
    def test_H4_adapt_vqe_exact(self):
        print('\n')

        # The FCI energy for H4 at 0.75 Angstrom in a sto-6g basis
        Efci = -2.1628978832666865
        # The Nuclear repulsion energy
        Enuc =  3.057468328315556

        mol = system_factory(stytem_type = 'molecule',
                                     build_type = 'external',
                                     basis='sto-6g',
                                     filename=data_path)

        alg = ADAPTVQE(mol, print_summary_file=False)

        alg.run(adapt_maxiter=20,
                avqe_thresh=1.0e-4,
                opt_thresh=1.0e-5,
                use_analytic_grad=True,
                pool_type='SDTQ')

        Egs_elec = alg.get_gs_energy()
        # Egs = Egs_elec + Enuc
        Egs = Egs_elec
        self.assertLess(abs(Egs-Efci), 5.0e-11)
예제 #2
0
    def test_H4_spqe_exact(self):
        print('\n')

        # The FCI energy for H4 at 0.75 Angstrom in a sto-6g basis
        Efci = -2.1628978832666865
        # The Nuclear repulsion energy
        Enuc =  3.057468328315556

        mol = system_factory(stytem_type = 'molecule',
                                     build_type = 'external',
                                     basis='sto-6g',
                                     filename=data_path)

        Hnonzero = qforte.QuantumOperator()
        for term in mol._hamiltonian.terms():
            if abs(term[0]) > 1.0e-14:
                Hnonzero.add_term(term[0], term[1])
        mol._hamiltonian = Hnonzero
        qforte.smart_print(Hnonzero)

        alg = SPQE(mol, print_summary_file=False)
        alg.run(spqe_maxiter=20,
                spqe_thresh=1.0e-4,
                res_vec_thresh=1.0e-5,
                dt = 0.0001)

        Egs_elec = alg.get_gs_energy()
        # Egs = Egs_elec + Enuc
        Egs = Egs_elec
        self.assertLess(abs(Egs-Efci), 5.0e-11)
예제 #3
0
    def test_He_uccsd_pqe_exact(self):
        print('\n')
        # The FCI energy for He atom in a cc-pvdz basis
        Efci = -2.887594831090938
        # The Nuclear repulsion energy
        Enuc = 0.0

        mol = system_factory(system_type='molecule',
                             build_type='external',
                             basis='cc-pvdz',
                             filename=data_path)

        alg = UCCNPQE(mol)
        alg.run(pool_type='SD', res_vec_thresh=1.0e-7)

        Egs_elec = alg.get_gs_energy()
        Egs = Egs_elec + Enuc
        self.assertLess(abs(Egs - Efci), 1.0e-11)
예제 #4
0
    def test_He_uccsd_vqe_frozen_virtual(self):
        print('\n')
        # The FCI energy for He atom in a cc-pvdz basis, according to Psi, one frozen virtual
        Efci = -2.8819250903
        # The Nuclear repulsion energy
        Enuc = 0.0

        mol = system_factory(system_type='molecule',
                             build_type='openfermion',
                             basis='cc-pvdz',
                             mol_geometry=[('He', (0, 0, 0))],
                             virtual_indices=[8, 9])

        alg = UCCNVQE(mol)
        alg.run(pool_type='SD', use_analytic_grad=True)

        Egs_elec = alg.get_gs_energy()
        Egs = Egs_elec + Enuc
        self.assertLess(abs(Egs - Efci), 1.0e-10)
예제 #5
0
    def test_He_uccsd_vqe_exact_psi(self):
        print('\n')
        # The FCI energy for He atom in a cc-pvdz basis
        Efci = -2.887594831090938
        # The Nuclear repulsion energy
        Enuc = 0.0

        mol = system_factory(system_type='molecule',
                             build_type='psi4',
                             basis='cc-pvdz',
                             mol_geometry=[('He', (0, 0, 0))],
                             filename=data_path,
                             symmetry="c2v")

        alg = UCCNVQE(mol)
        alg.run(pool_type='SD', use_analytic_grad=True)

        Egs_elec = alg.get_gs_energy()
        Egs = Egs_elec + Enuc
        self.assertLess(abs(Egs - Efci), 1.0e-11)