qxmt.hamiltonians.pennylane.molecular module#
- class qxmt.hamiltonians.pennylane.molecular.InitializationType(value)
Bases:
Enum
- DATASET = 1
- DIRECT_MOLECULE = 2
- INVALID = 3
- class qxmt.hamiltonians.pennylane.molecular.MolecularHamiltonian(molname=None, bondlength=None, symbols=None, coordinates=None, charge=0, multi=1, basis_name='STO-3G', unit='angstrom', method='dhf', active_electrons=None, active_orbitals=None, mapping='jordan_wigner', hf_energy=None, casci_energy=None, casscf_energy=None, fci_energy=None, reference_energy_methods=['fci'], max_cycle_macro=50, conv_tol=1e-07, orbital_optimization=True, logger=<Logger qxmt.hamiltonians.pennylane.molecular (INFO)>)
Bases:
BaseHamiltonian
Molecular Hamiltonian for quantum chemistry calculations.
This class represents a molecular Hamiltonian using PennyLane’s quantum chemistry module. It supports both full and active space calculations for molecular systems, including CASCI (Complete Active Space Configuration Interaction) and CASSCF (Complete Active Space Self-Consistent Field) with frozen core orbitals.
- Parameters:
molname (str | None) – Name of the molecule in PennyLane’s dataset.
bondlength (float | str | None) – Bond length of the molecule in Angstroms.
symbols (list[str] | None) – List of atomic symbols (e.g., [‘H’, ‘H’] for H2).
coordinates (tensor | list[float] | list[list[float]] | None) – Array of atomic coordinates in Angstroms.
charge (int) – Total charge of the molecule. Defaults to 0.
multi (int) – Multiplicity of the molecule. Defaults to 1.
basis_name (Literal['STO-3G', '6-31G', '6-311G', 'CC-PVDZ']) – Basis set name. Only supported [“sto-3g”, “6-31g”, “6-311g”, “cc-pvdz”]. Defaults to “sto-3g”.
unit (Literal['angstrom', 'bohr']) – Unit of the coordinates. Only supported [“angstrom”, “bohr”]. Defaults to “angstrom”.
method (Literal['dhf', 'pyscf', 'openfermion']) – Quantum chemistry method used to solve the mean field electronic structure problem. Only supported [“dhf”, “pyscf”, “openfermion”]. Defaults to “dhf”.
active_electrons (int | None) – Number of active electrons. If None, uses all electrons.
active_orbitals (int | None) – Number of active orbitals. If None, uses all orbitals.
mapping (Literal['jordan_wigner', 'bravyi_kitaev', 'parity']) – Mapping to use for the calculation. Defaults to “jordan_wigner”.
hf_energy (float | None) – Pre-computed HF energy. If None, will be computed.
fci_energy (float | None) – Pre-computed FCI energy. If None, will be computed.
use_casci – Whether to use CASCI instead of FCI for energy calculations. Defaults to False.
cas_type – Type of CAS calculation (“casci” or “casscf”). Defaults to “casci”.
max_cycle_macro (int) – Maximum number of macro iterations for CASSCF. Defaults to 50.
conv_tol (float) – Convergence tolerance for CASSCF. Defaults to 1e-7.
orbital_optimization (bool) – Whether to perform orbital optimization in CASSCF. Defaults to True.
logger (Logger) – Logger instance for logging.
casci_energy (float | None)
casscf_energy (float | None)
reference_energy_methods (list[Literal['casci', 'casscf', 'fci']])
- hamiltonian
PennyLane Hamiltonian operator.
- n_qubits
Number of qubits required for the simulation.
- molecule
PennyLane Molecule object.
- get_active_electrons()
Get the number of active electrons.
If active_electrons is not specified, returns the total number of electrons.
- Returns:
Number of active electrons.
- Return type:
int
- get_active_orbitals()
Get the number of active orbitals.
If active_orbitals is not specified, returns the total number of molecular orbitals.
- Returns:
Number of active orbitals.
- Return type:
int
- get_active_spin_orbitals()
Get the number of active spin orbitals.
If active_orbitals is not specified, returns the total number of spin orbitals.
- Returns:
Number of active spin orbitals (2 * number of active orbitals).
- Return type:
int
- get_casci_energy()
Get the CASCI energy of the molecule.
- Returns:
CASCI energy.
- Return type:
float
- get_casscf_energy()
Get the CASSCF energy of the molecule.
- Returns:
CASSCF energy.
- Return type:
float
- get_electrons()
Get the total number of electrons in the molecule.
- Returns:
Total number of electrons.
- Return type:
int
- get_fci_energy()
Get the FCI energy of the molecule.
- Returns:
FCI energy.
- Return type:
float
- get_hamiltonian()
Get the Hamiltonian operator.
- Returns:
The molecular Hamiltonian operator.
- Return type:
Sum
- get_hf_energy()
Get the Hartree-Fock energy of the molecule.
- Returns:
Hartree-Fock energy.
- Return type:
float
- get_molecular_orbitals()
Get the number of molecular orbitals.
- Returns:
Number of molecular orbitals.
- Return type:
int
- get_molecule()
Get the Molecule object.
- Returns:
The molecule object.
- Return type:
qml.qchem.Molecule
- get_n_qubits()
Get the number of qubits required for the simulation.
- Returns:
Number of qubits.
- Return type:
int
- get_reference_energies()
Get the complete reference energies object.
- Returns:
Object containing all computed reference energies.
- Return type:
ReferenceEnergies
- get_spin_orbitals()
Get the number of spin orbitals.
- Returns:
Number of spin orbitals (2 * number of molecular orbitals).
- Return type:
int