Пример #1
0
 def test_qmolecule_log_with_atoms(self):
     """Test QMolecule log function."""
     qmolecule = FCIDumpDriver(
         self.get_resource_path('test_driver_fcidump_h2.fcidump'),
         atoms=['H', 'H']).run()
     with self.assertLogs('qiskit.chemistry', level='DEBUG') as _:
         qmolecule.log()
Пример #2
0
    def setUp(self):
        super().setUp()
        self.core_energy = 0.7199
        self.num_orbitals = 2
        self.num_electrons = 2
        self.spin_number = 0
        self.wf_symmetry = 1
        self.orb_symmetries = [1, 1]
        self.mo_onee = [[1.2563, 0.0], [0.0, 0.4719]]
        self.mo_eri = [0.6757, 0.0, 0.1809, 0.6646, 0.0, 0.6986]
        try:
            driver = PySCFDriver(atom='H .0 .0 .0; H .0 .0 0.735',
                                 unit=UnitsType.ANGSTROM,
                                 charge=0,
                                 spin=0,
                                 basis='sto3g')
            qmolecule = driver.run()

            dump = tempfile.NamedTemporaryFile()
            FCIDumpDriver.dump(qmolecule, dump.name)

            # pylint: disable=import-outside-toplevel
            from pyscf.tools import fcidump as pyscf_fcidump
            self.dumped = pyscf_fcidump.read(dump.name)

            dump.close()
        except QiskitChemistryError:
            self.skipTest('PYSCF driver does not appear to be installed.')
        except ImportError:
            self.skipTest('PYSCF driver does not appear to be installed.')
Пример #3
0
 def setUp(self):
     super().setUp()
     self.nuclear_repulsion_energy = 11.3412
     self.num_orbitals = 6
     self.num_alpha = 5
     self.num_beta = 4
     loaded = np.load(self.get_resource_path('test_driver_fcidump_oh.npz'))
     self.mo_onee = loaded['mo_onee']
     self.mo_onee_b = loaded['mo_onee_b']
     self.mo_eri = loaded['mo_eri']
     self.mo_eri_ba = loaded['mo_eri_ba']
     self.mo_eri_bb = loaded['mo_eri_bb']
     driver = FCIDumpDriver(self.get_resource_path('test_driver_fcidump_oh.fcidump'))
     self.qmolecule = driver.run()
Пример #4
0
 def setUp(self):
     super().setUp()
     self.nuclear_repulsion_energy = 0.7199
     self.num_orbitals = 2
     self.num_alpha = 1
     self.num_beta = 1
     self.mo_onee = np.array([[1.2563, 0.0], [0.0, 0.4719]])
     self.mo_onee_b = None
     self.mo_eri = np.array([[[[0.6757, 0.0], [0.0, 0.6646]],
                              [[0.0, 0.1809], [0.1809, 0.0]]],
                             [[[0.0, 0.1809], [0.1809, 0.0]],
                              [[0.6646, 0.0], [0.0, 0.6986]]]])
     self.mo_eri_ba = None
     self.mo_eri_bb = None
     driver = FCIDumpDriver(self.get_resource_path('test_driver_fcidump_h2.fcidump'))
     self.qmolecule = driver.run()
Пример #5
0
 def test_oh_with_atoms(self):
     """ OH with num_atoms test """
     driver = FCIDumpDriver(
         self.get_resource_path('test_driver_fcidump_oh.fcidump'),
         atoms=['O', 'H'])
     result = self._run_driver(driver, freeze_core=True)
     self._assert_energy(result, 'oh')
Пример #6
0
 def test_oh_freeze_core(self):
     """ OH freeze core test """
     with self.assertLogs('qiskit.chemistry', level='WARNING') as log:
         driver = FCIDumpDriver(
             self.get_resource_path('test_driver_fcidump_oh.fcidump'))
         result = self._run_driver(driver, freeze_core=True)
         self._assert_energy(result, 'oh')
     warning = 'WARNING:qiskit.chemistry.qmolecule:' + \
               'Missing molecule information! Returning empty core orbital list.'
     self.assertIn(warning, log.output)
Пример #7
0
 def test_oh(self):
     """ OH test """
     driver = FCIDumpDriver(
         self.get_resource_path('test_driver_fcidump_oh.fcidump'))
     result = self._run_driver(driver, freeze_core=False)
     self._assert_energy(result, 'oh')