qpe_toolbox.hamiltonian.chemistry¶
Functions¶
|
Build a molecular electronic Hamiltonian mapped to qubits. |
|
Run PySCF electronic-structure calculations. |
|
Construct a qubit Hamiltonian from a PySCF Hartree-Fock object. |
|
Build a fermionic second-quantized Hamiltonian. |
|
Convert an OpenFermion qubit operator into quimb Hamiltonian terms. |
Module Contents¶
- qpe_toolbox.hamiltonian.chemistry.chemistry_hamiltonian(molecule, hf_mode, *, encoding='original', do_fci=False, do_ccsd=False)[source]¶
Build a molecular electronic Hamiltonian mapped to qubits.
This function performs a PySCF Hartree-Fock calculation, optionally followed by FCI and/or CCSD, constructs the second-quantized fermionic Hamiltonian, and maps it to a qubit Hamiltonian using the Jordan-Wigner transformation.
- Parameters:
molecule (pyscf.gto.Mole) – PySCF molecule object defining geometry and basis.
hf_mode ({'rhf', 'uhf'}, optional) – Type of Hartree-Fock calculation. Default is
'rhf'.encoding ({'original', 'sf', 'df'}, optional) – Encoding of two-body integrals: -
'original': full integrals -'sf': single-factorized -'df': double-factorizeddo_fci (bool, optional) – Whether to compute the FCI ground-state energy.
do_ccsd (bool, optional) – Whether to compute the CCSD energy.
- Returns:
Qubit Hamiltonian with additional attributes:
norb,nelec,e_hf, and optionallye_fciande_ccsd.- Return type:
- qpe_toolbox.hamiltonian.chemistry.do_pyscf(molecule, hf_mode, do_fci, do_ccsd)[source]¶
Run PySCF electronic-structure calculations.
Performs a Hartree-Fock calculation, and optionally FCI and CCSD, returning the HF object needed to extract molecular integrals.
- Parameters:
molecule (pyscf.gto.Mole) – Molecular system.
hf_mode ({'rhf', 'uhf'}) – Hartree-Fock flavor.
do_fci (bool) – Whether to compute FCI energy.
do_ccsd (bool) – Whether to compute CCSD energy.
- Returns:
e_fci (float or None) – FCI ground-state energy.
e_ccsd (float or None) – CCSD ground-state energy.
hf (pyscf.scf.hf.SCF) – Hartree-Fock object containing molecular orbitals and integrals.
- qpe_toolbox.hamiltonian.chemistry.make_qubit_hamiltonian(hf, hf_mode, encoding)[source]¶
Construct a qubit Hamiltonian from a PySCF Hartree-Fock object.
- Parameters:
hf (pyscf.scf.hf.SCF) – Converged HF object.
hf_mode ({'rhf', 'uhf'}) – Hartree-Fock type.
encoding ({'original', 'sf', 'df'}) – Integral encoding scheme.
- Returns:
Qubit Hamiltonian with constant energy shift stored in
e_const.- Return type:
- qpe_toolbox.hamiltonian.chemistry.make_fermionic_hamiltonian(ncas, ecore, hpq, hpqrs, hf_mode, encoding, *, verbosity=0)[source]¶
Build a fermionic second-quantized Hamiltonian.
- Parameters:
ncas (int) – Number of active spatial orbitals.
ecore (float) – Core (constant) energy contribution.
hpq (ndarray) – One-body integrals.
hpqrs (ndarray or tuple of ndarray) – Two-body integrals.
hf_mode ({'rhf', 'uhf'}) – Hartree-Fock type.
encoding ({'original', 'sf', 'df'}) – Integral compression scheme.
verbosity (int, optional) – Verbosity level.
- Returns:
Fermionic Hamiltonian operator.
- Return type:
- qpe_toolbox.hamiltonian.chemistry.terms_from_openfermion(qubit_operator)[source]¶
Convert an OpenFermion qubit operator into quimb Hamiltonian terms.
This function separates the constant (identity) contribution from Pauli-string terms and converts them into the format expected by the
Hamiltonianclass.- Parameters:
qubit_operator (openfermion.ops.QubitOperator) – Qubit Hamiltonian expressed as a sum of Pauli strings.
- Returns:
term_list (list of tuple) – List of Hamiltonian terms in quimb format:
(coefficient, pauli_string, qubits).e_const (float) – Constant energy offset corresponding to the identity term.