def test_srqk_with_uccsdvqe_ref(self): print('\n') # The FCI energy of the equidistant H4/STO-3G chain with r = 1.5 angs. Efci = -1.9961503253000235 geom = [('H', (0.0, 0.0, 0.0)), ('H', (0.0, 0.0, 1.5)), ('H', (0.0, 0.0, 3.0)), ('H', (0.0, 0.0, 4.5))] mol = system_factory(system_type='molecule', build_type='psi4', basis='sto-3g', mol_geometry=geom) alg = UCCNVQE(mol) alg.run(pool_type='SD') ref_circ = alg.build_Uvqc() alg2 = SRQK(mol, reference=ref_circ, state_prep_type='unitary_circ', trotter_number=150) alg2.run(dt=1.0, s=12) Egs = alg2.get_gs_energy() assert Egs == approx(Efci, abs=5.0e-6)
def test_He_uccsd_pqe_exact(self): print('\n') # The FCI energy for He atom in a cc-pvdz basis Efci = -2.887594831090938 mol = system_factory(system_type='molecule', build_type='external', basis='cc-pvdz', filename=data_path) alg = UCCNPQE(mol) alg.run(pool_type='SD', opt_thresh=1.0e-7) Egs_elec = alg.get_gs_energy() assert Egs_elec == approx(Efci, abs=1.0e-11)
def test_He_uccsd_vqe_exact_diis(self): print('\n') # The FCI energy for He atom in a cc-pvdz basis Efci = -2.887594831090938 mol = system_factory(system_type='molecule', build_type='external', basis='cc-pvdz', filename=data_path) alg = UCCNVQE(mol) alg.run(pool_type='SD', use_analytic_grad=True, optimizer="diis_solve") Egs_elec = alg.get_gs_energy() assert Egs_elec == approx(Efci, abs=1.0e-11)
def test_He_uccsd_vqe_exact_psi(self): print('\n') # The FCI energy for He atom in a cc-pvdz basis Efci = -2.887594831090938 mol = system_factory(system_type='molecule', build_type='psi4', basis='cc-pvdz', mol_geometry=[('He', (0, 0, 0))], symmetry="c2v") alg = UCCNVQE(mol) alg.run(pool_type='SD', use_analytic_grad=True) Egs_elec = alg.get_gs_energy() assert Egs_elec == approx(Efci, abs=1.0e-10)
def test_vqe(self): print('\n') Efci = -1.108873060057971 mol = system_factory(system_type='molecule', build_type='psi4', basis='sto-6g', mol_geometry=[('H', (0, 0, 0)), ('H', (0, 0, 1))], symmetry="d2h") pool = SQOpPool() sq_op = SQOperator() sq_op.add_term(1, [0, 1], [2, 3]) sq_op.add_term(-1, [2, 3], [0, 1]) pool.add_term(1, sq_op) alg = UCCNVQE(mol) alg.run(pool_type=pool, use_analytic_grad=True) assert alg.get_gs_energy() == approx(Efci, abs=1.0e-10)
def test_freeze_orb_ucc(self, method, options): mol = system_factory(system_type='molecule', build_type='psi4', basis='sto-3g', mol_geometry=[('Be', (0, 0, -1.2)), ('Be', (0, 0, 1.2))], symmetry='d2h', num_frozen_docc=2, num_frozen_uocc=3) alg = method(mol) alg.run(**options) Egs = alg.get_gs_energy() # WARNING: Due to a bug in Psi4, the energies stored in the fci_energy attrbitute of the Molecule class are not # correct when the number of frozen virtual orbitals is larger than zero. Efci = -28.747184707540754 assert Egs == approx(Efci, abs=1.0e-10)
def test_symmetry_ucc(self, method, options): groups = ['c1', 'c2', 'ci', 'cs', 'd2', 'c2h', 'c2v', 'd2h'] for count, group in enumerate(groups): mol = system_factory(system_type='molecule', build_type='psi4', basis='cc-pVDZ', mol_geometry=[('He', (0, 0, 0))], symmetry=group) alg = method(mol, irrep=0) alg.run(**options) Egs = alg.get_gs_energy() Efci = -2.887594831090935 # FCI t_ops = [24, 12, 12, 16, 6, 8, 10, 6] assert Egs == approx(Efci, abs=1.0e-10) assert len(alg._pool_obj) == t_ops[count]
def test_symmetry_attributes(self): groups = ['c1', 'c2', 'cs', 'ci', 'd2', 'c2h', 'c2v', 'd2h'] irreps = [['A'], ['A', 'B'], ['Ap', 'App'], ['Ag', 'Au'], ['A', 'B1', 'B2', 'B3'], ['Ag', 'Bg', 'Au', 'Bu'], ['A1', 'A2', 'B1', 'B2'], ['Ag', 'B1g', 'B2g', 'B3g', 'Au', 'B1u', 'B2u', 'B3u']] orb_irreps = [['A', 'A', 'A', 'A', 'A', 'A', 'A'], ['A', 'A', 'A', 'B', 'B', 'A', 'A'], ['Ap', 'Ap', 'Ap', 'App', 'Ap', 'Ap', 'Ap'], ['Ag', 'Ag', 'Au', 'Au', 'Au', 'Ag', 'Au'], ['A', 'A', 'B1', 'B2', 'B3', 'A', 'B1'], ['Ag', 'Ag', 'Au', 'Bu', 'Bu', 'Ag', 'Au'], ['A1', 'A1', 'A1', 'B1', 'B2', 'A1', 'A1'], ['Ag', 'Ag', 'B1u', 'B2u', 'B3u', 'Ag', 'B1u']] orb_irreps_to_int = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 1], [0, 0, 1, 2, 3, 0, 1], [0, 0, 2, 3, 3, 0, 2], [0, 0, 0, 2, 3, 0, 0], [0, 0, 5, 6, 7, 0, 5]] c1_char_tbl = ('==========> C1 <==========\n\n' ' A \n\n' 'A A \n') c2_char_tbl = ('==========> C2 <==========\n\n' ' A B \n\n' 'A A B \n' 'B B A \n') cs_char_tbl = ('==========> Cs <==========\n\n' ' Ap App \n\n' 'Ap Ap App \n' 'App App Ap \n') ci_char_tbl = ('==========> Ci <==========\n\n' ' Ag Au \n\n' 'Ag Ag Au \n' 'Au Au Ag \n') d2_char_tbl = ('==========> D2 <==========\n\n' ' A B1 B2 B3 \n\n' 'A A B1 B2 B3 \n' 'B1 B1 A B3 B2 \n' 'B2 B2 B3 A B1 \n' 'B3 B3 B2 B1 A \n') c2h_char_tbl = ('==========> C2h <==========\n\n' ' Ag Bg Au Bu \n\n' 'Ag Ag Bg Au Bu \n' 'Bg Bg Ag Bu Au \n' 'Au Au Bu Ag Bg \n' 'Bu Bu Au Bg Ag \n') c2v_char_tbl = ('==========> C2v <==========\n\n' ' A1 A2 B1 B2 \n\n' 'A1 A1 A2 B1 B2 \n' 'A2 A2 A1 B2 B1 \n' 'B1 B1 B2 A1 A2 \n' 'B2 B2 B1 A2 A1 \n') d2h_char_tbl = ('==========> D2h <==========\n\n' ' Ag B1g B2g B3g Au B1u B2u B3u \n\n' 'Ag Ag B1g B2g B3g Au B1u B2u B3u \n' 'B1g B1g Ag B3g B2g B1u Au B3u B2u \n' 'B2g B2g B3g Ag B1g B2u B3u Au B1u \n' 'B3g B3g B2g B1g Ag B3u B2u B1u Au \n' 'Au Au B1u B2u B3u Ag B1g B2g B3g \n' 'B1u B1u Au B3u B2u B1g Ag B3g B2g \n' 'B2u B2u B3u Au B1u B2g B3g Ag B1g \n' 'B3u B3u B2u B1u Au B3g B2g B1g Ag \n') char_tables = [ c1_char_tbl, c2_char_tbl, cs_char_tbl, ci_char_tbl, d2_char_tbl, c2h_char_tbl, c2v_char_tbl, d2h_char_tbl ] for count, group in enumerate(groups): mol = system_factory(system_type='molecule', build_type='psi4', basis='sto-3g', mol_geometry=[('O', (0., 0., 0)), ('H', (0., 0, -1.5)), ('H', (0., 0, 1.5))], symmetry=group) assert mol.point_group == [group, irreps[count]] assert mol.orb_irreps == orb_irreps[count] assert mol.orb_irreps_to_int == orb_irreps_to_int[count] with patch('sys.stdout', new=StringIO()) as fake_out: char_table([group, irreps[count]]) assert fake_out.getvalue() == char_tables[count]