The PennyLane quantum chemistry library.


To access the qml.qchem package, pennylane-qchem must be installed via pip:

pip install pennylane-qchem

The PennyLane quantum chemistry package. Supports OpenFermion, PySCF, and Psi4 for quantum chemistry calculations using PennyLane.


read_structure(filepath[, outpath])

Reads the molecular structure from a file and creates a list containing the symbol and Cartesian coordinates of the atomic species.

meanfield_data(mol_name, geometry, charge, …)

Launches the meanfield (Hartree-Fock) electronic structure calculation.

active_space(mol_name, hf_data[, …])

Builds the active space by partitioning the set of Hartree-Fock molecular orbitals.

decompose_hamiltonian(mol_name, hf_data[, …])

Decomposes the electronic Hamiltonian into a linear combination of Pauli operators using OpenFermion tools.


Converts OpenFermion QubitOperator to a 2-tuple of coefficients and PennyLane Pauli observables.

_terms_to_qubit_operator(coeffs, ops)

Converts a 2-tuple of complex coefficients and PennyLane operations to OpenFermion QubitOperator.


Checks equivalence between OpenFermion QubitOperator and Pennylane VQE Hamiltonian (Tensor product of Pauli matrices).


Converts an OpenFermion QubitOperator operator to a Pennylane VQE observable

generate_hamiltonian(mol_name, mol_geo_file, …)

Generates the qubit Hamiltonian based on geometry and mean field electronic structure.

sd_excitations(n_electrons, n_orbitals[, …])

Generates single and double excitations from a Hartree-Fock (HF) reference state.

hf_state(n_electrons, m_spin_orbitals)

Generates the occupation-number vector representing the Hartree-Fock (HF) state of \(N\) electrons in a basis of \(M\) spin orbitals.

excitations_to_wires(ph_confs, pphh_confs[, …])

Map the indices representing the particle-hole configurations generated by the Coupled-Cluster excitation operator to the wires that the Unitary Coupled-Cluster Singles and Doubles (UCCSD) template will act on.


This module contains functions to construct many-body observables whose expectation values can be used to simulate molecular properties.

observable(me_table[, init_term, mapping])

Builds the many-body observable whose expectation value can be measured in PennyLane.

particle_number(n_orbitals[, mapping])

Computes the particle number operator \(\hat{N}=\sum_\alpha \hat{n}_\alpha\) in the Pauli basis.

spin_z(n_orbitals[, mapping])

Computes the total spin projection operator \(\hat{S}_z\) in the Pauli basis.

spin2(n_electrons, n_orbitals[, mapping])

Computes the total spin operator \(\hat{S}^2\).


Builds the table of matrix elements \(\langle \bm{\alpha}, \bm{\beta} \vert \hat{s}_1 \cdot \hat{s}_2 \vert \bm{\gamma}, \bm{\delta} \rangle\) of the two-particle spin operator \(\hat{s}_1 \cdot \hat{s}_2\).