def build_lih_moleculardata() -> MolecularData:
    """Returns LiH molecular data."""
    geometry = [("Li", (0.0, 0.0, 0.0)), ("H", (0.0, 0.0, 1.45))]
    basis = "sto-3g"
    multiplicity = 1
    filename = os.path.join(
        fud.__file__.replace("__init__.py", ""),
        "H1-Li1_sto-3g_singlet_1.45.hdf5",
    )
    molecule = MolecularData(geometry, basis, multiplicity, filename=filename)
    molecule.load()
    return molecule
    def _generate_molecule(self, p: IParameter) -> MolecularData:
        """Produce molecule that can be used by the hamiltonian.
        Using a singlet state with S = 0 to specify we are looking for the lowest singlet energy state.
        multiplicity = 2S + 1
        """
        geometry = [('H', (0., 0., 0.)), ('H', (0., 0., p['r0']))]
        basis = 'sto-3g'
        multiplicity = 1
        charge = 0
        description = str(p['r0'])

        # Change to whatever directory you want
        cwd = os.getcwd()
        data_directory = cwd+'/mol_data'

        if not os.path.exists(data_directory):
            os.mkdir(data_directory)

        filename = data_directory+'/H2_'+description

        run_scf = 1
        run_mp2 = 1
        run_cisd = 1
        run_ccsd = 1
        run_fci = 1
        delete_input = False
        delete_output = False
        verbose = False

        molecule = MolecularData(
            geometry,
            basis,
            multiplicity,
            description=description,
            filename=filename)

        if os.path.exists('{}.hdf5'.format(filename)):
            molecule.load()

        else:
            molecule = run_psi4(molecule,
                                verbose=verbose,
                                run_scf=run_scf,
                                run_mp2=run_mp2,
                                run_cisd=run_cisd,
                                run_ccsd=run_ccsd,
                                run_fci=run_fci)
        # print(f'Reference (Full Configuration Energy: {molecule.fci_energy})')
        return molecule
def build_h4square_moleculardata() -> MolecularData:
    """Returns H4 molecular data."""
    geometry = [
        ("H", [0.5, 0.5, 0]),
        ("H", [0.5, -0.5, 0]),
        ("H", [-0.5, 0.5, 0]),
        ("H", [-0.5, -0.5, 0]),
    ]
    basis = "sto-3g"
    multiplicity = 1
    filename = os.path.join(fud.__file__.replace("__init__.py", ""),
                            "H4_sto-3g_singlet.hdf5")
    molecule = MolecularData(geometry, basis, multiplicity, filename=filename)
    molecule.load()
    return molecule
Пример #4
0
def get_molecule(element_names, bond_len):
    geometry = [[element_names[0], [0, 0, 0]],
                [element_names[1], [0, 0, bond_len]]]
    basis = 'sto-3g'
    multiplicity = 1
    description = '{:.2}'.format(bond_len)
    data_directory = DATA_DIRECTORY

    molecule = MolecularData(geometry,
                             basis,
                             multiplicity,
                             description=description,
                             data_directory=data_directory)
    molecule.load()

    return molecule
Пример #5
0
def test_d2_to_g2():
    # this should test for correctness
    filename = os.path.join(DATA_DIRECTORY, "H1-Li1_sto-3g_singlet_1.45.hdf5")
    molecule = MolecularData(filename=filename)
    molecule.load()
    opdm = molecule.fci_one_rdm
    tpdm = molecule.fci_two_rdm
    phdm = map_two_pdm_to_particle_hole_dm(tpdm, opdm)

    db = tpdm_to_phdm_mapping(molecule.n_qubits)
    topdm = Tensor(tensor=opdm, name='ck')
    ttpdm = Tensor(tensor=np.einsum('ijlk', tpdm), name='cckk')
    tphdm = Tensor(tensor=np.einsum('ijlk', phdm), name='ckck')
    mt = MultiTensor(tensors=[topdm, ttpdm, tphdm], dual_basis=db)
    A, _, b = mt.synthesize_dual_basis()
    vec_rdms = mt.vectorize_tensors()
    assert np.isclose(np.linalg.norm(A.dot(vec_rdms) - b), 0)