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 structure of the polyatomic system from a file and returns a list with the symbols of the atoms in the molecule and a 1D array with their positions \([x_1, y_1, z_1, x_2, y_2, z_2, \dots]\) in atomic units (Bohr radius = 1).

meanfield(symbols, coordinates[, name, …])

Generates a file from which the mean field electronic structure of the molecule can be retrieved.

active_space(electrons, orbitals[, mult, …])

Builds the active space for a given number of active electrons and active orbitals.

decompose(hf_file[, mapping, core, active])

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

convert_observable(qubit_observable[, wires])

Converts an OpenFermion QubitOperator operator to a Pennylane VQE observable

molecular_hamiltonian(symbols, coordinates)

Generates the qubit Hamiltonian of a molecule.

hf_state(electrons, orbitals)

Generates the occupation-number vector representing the Hartree-Fock state.

excitations(electrons, orbitals[, delta_sz])

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

excitations_to_wires(singles, doubles[, wires])

Map the indices representing the single and double excitations generated with the function excitations() to the wires that the Unitary Coupled-Cluster (UCCSD) template will act on.

_qubit_operator_to_terms(qubit_operator[, wires])

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

_terms_to_qubit_operator(coeffs, ops[, wires])

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

_qubit_operators_equivalent(…[, wires])

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


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

observable(fermion_ops[, init_term, …])

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

particle_number(orbitals[, mapping, wires])

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

spin_z(orbitals[, mapping, wires])

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

spin2(electrons, orbitals[, mapping, wires])

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

one_particle(matrix_elements[, core, …])

Generates the FermionOperator representing a given one-particle operator required to build many-body qubit observables.

two_particle(matrix_elements[, core, …])

Generates the FermionOperator representing a given two-particle operator required to build many-body qubit observables.


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\).