def test_inconsistent_active_spaces(mol_name, act_electrons, act_orbitals,
                                    message_match):
    r"""Test that an error is raised if an inconsistent active space is generated"""

    molecule = MolecularData(filename=os.path.join(ref_dir, mol_name))

    with pytest.raises(ValueError, match=message_match):
        qchem.active_space(
            molecule.n_electrons,
            molecule.n_orbitals,
            mult=molecule.multiplicity,
            active_electrons=act_electrons,
            active_orbitals=act_orbitals,
        )
Example #2
0
def test_active_spaces(mol_name, n_act_electrons, n_act_orbitals,
                       docc_indices_ref, act_indices_ref):
    r"""Test the correctness of the generated active spaces"""

    docc_indices, active_indices = qchem.active_space(mol_name, ref_dir,
                                                      n_act_electrons,
                                                      n_act_orbitals)

    assert docc_indices == docc_indices_ref
    assert active_indices == act_indices_ref
def test_active_spaces(mol_name, act_electrons, act_orbitals, core_ref,
                       active_ref):
    r"""Test the correctness of the generated active spaces"""

    molecule = MolecularData(filename=os.path.join(ref_dir, mol_name))

    core, active = qchem.active_space(
        molecule.n_electrons,
        molecule.n_orbitals,
        mult=molecule.multiplicity,
        active_electrons=act_electrons,
        active_orbitals=act_orbitals,
    )

    assert core == core_ref
    assert active == active_ref
Example #4
0
#     :width: 50%
#     :align: center
#
# .. note::
#     The number of *active spin-orbitals* determines the *number of qubits* required
#     to perform quantum simulations of the electronic structure of the molecule.
#
# For the case of the water molecule described using a minimal basis set, we have a total of ten
# electrons occupying the first five out of seven molecular orbitals in the HF reference state.
# Let's partition the HF orbitals to define an active space of four electrons in four active
# orbitals:

electrons = 10
orbitals = 7
core, active = qchem.active_space(electrons,
                                  orbitals,
                                  active_electrons=4,
                                  active_orbitals=4)

##############################################################################
# Viewing the results:

print("List of core orbitals: {:}".format(core))
print("List of active orbitals: {:}".format(active))
print("Number of qubits required for quantum simulation: {:}".format(
    2 * len(active)))

##############################################################################
# Notice that calling the :func:`~.pennylane_qchem.qchem.active_space` function without
# specifying an active space results in no core orbitals---*all* molecular orbitals are
# considered to be active.
Example #5
0
def test_inconsistent_active_spaces(mol_name, n_act_electrons, n_act_orbitals,
                                    message_match):
    r"""Test that an error is raised if an inconsistent active space is generated"""

    with pytest.raises(ValueError, match=message_match):
        qchem.active_space(mol_name, ref_dir, n_act_electrons, n_act_orbitals)