Hello PennyLane team,
I’ve encountered issues with inaccurate energy outputs and basis set mismatches when using qchem.molecular_hamiltonian
for VQE calculations, especially on heavy atoms like Sn (in triorganotin compounds) using LANL2DZ basis. I suspect PennyLane may silently fall back to STO-3G, despite explicit LANL2DZ selection.
I tested this in both large and small systems. For instance:
Use Case: Fentin Chloride (Sn Compound)
- Traditional DFT energy (LANL2DZ): ~ -713 Ha
- PennyLane VQE energy: ~ -1311 Ha
- Suggests fallback to minimal basis set?
hamiltonian, qubits = qchem.molecular_hamiltonian(
symbols, coordinates, charge=0, mult=1, basis=basis,
method=method, active_electrons=ae, active_orbitals=ao
)
hf = qchem.hf_state(electrons=ae, orbitals=qubits)
num_wires = qubits
dev_sim = qml.device("lightning.gpu", wires=num_wires)
@qml.qnode(dev_sim)
def exp_energy_sim(state):
qml.BasisState(np.array(state), wires=range(num_wires))
return qml.expval(hamiltonian)
expectation_energy = float(exp_energy_sim(hf))
log_to_file(file_name_log, f"HF Expectation Energy: {expectation_energy:.8f} Ha")
single_excitations, double_excitations = qchem.excitations(ae, num_wires)
s_wires, d_wires = qml.qchem.excitations_to_wires(single_excitations, double_excitations)
def cost_function(params, wires, s_wires, d_wires, init_state):
qml.UCCSD(params, wires=range(num_wires), s_wires=s_wires, d_wires=d_wires, init_state=init_state)
return qml.expval(hamiltonian)
num_params = len(single_excitations) + len(double_excitations)
theta_sim = np.zeros(num_params, requires_grad=True)
opt = qml.GradientDescentOptimizer(stepsize=learning_rate)
print("Starting VQE optimization...")
for n in range(max_iteration):
theta_sim, cost_sim = opt.step_and_cost(cost_function, theta_sim, wires=range(qubits), s_wires=s_wires, d_wires=d_wires, init_state=hf)
if abs(prev_energy - cost_sim) < tolerance:
log_to_file(file_name_log, f"Converged at iteration {n} with energy {cost_sim:.8f} Ha")
break
prev_energy = cost_sim
If you want help with diagnosing an error, please put the full error message below:
# Put full error message here
And, finally, make sure to include the versions of your packages. Specifically, show us the output of qml.about()
.