Hi! I’m trying to reproduce the code from Release notes 0.21.0 (Reduce qubit requirements of simulating Hamiltonians), everything is fine until I change the number of atoms in my molecule. For every molecule with the number of atoms > 2 (for example H-H-H-H) I’m getting an error message at this line:
hf_tapered = qml.hf.transform_hf(generators, paulix_ops, opt_sector, n_elec, n_qubits)
error message:
There is some inconsistency with the length of Pauli strings and “paulix_ops” variable.
whole code:
import pennylane as qml
from pennylane import numpy as np
# molecular geometry
symbols = ["H", "H", "H", 'H']
geometry = np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 1], [0.0, 0.0, 2], [0.0, 0.0, 3]])
mol = qml.hf.Molecule(symbols, geometry, charge=0,mult=1)
# generate the qubit Hamiltonian
H = qml.hf.generate_hamiltonian(mol)(geometry)
# determine Hamiltonian symmetries
generators, paulix_ops = qml.hf.generate_symmetries(H,
len(H.wires))
opt_sector = qml.hf.optimal_sector(H, generators, mol.n_electrons)
# taper the Hamiltonian
H_tapered = qml.hf.transform_hamiltonian(H, generators, paulix_ops,
opt_sector)
n_elec = mol.n_electrons
n_qubits = mol.n_orbitals * 2
hf_tapered = qml.hf.transform_hf(
generators, paulix_ops, opt_sector, n_elec, n_qubits
)