VQE for H2O Molecule Ground State
What You'll Learn:
- How active space reduction brings a 10-electron molecule down to 4 qubits
- How all-to-all CX connectivity captures longer-range orbital correlations
- How frozen-core approximation preserves accuracy while reducing qubit count
- Why molecular size does not always equal qubit count
Level: Intermediate | Time: 30 minutes | Qubits: 4 | Framework: Qiskit
Prerequisites
- H2 Ground State — VQE fundamentals on 2 qubits
- LiH Ground State — Scaling VQE to 4 qubits with linear connectivity
The Idea
LiH was a direct scale-up: 4 electrons mapped to 4 qubits with no tricks needed. Water (H2O) is different. It has 10 electrons — 8 from oxygen and 1 from each hydrogen — which would naively require ~14 qubits in a minimal basis (STO-3G). That is beyond what a simple VQE tutorial can handle efficiently.
The solution is active space reduction. Most of H2O's electrons sit in deep core orbitals (the 1s orbital on oxygen) that barely participate in chemical bonding. By freezing these core electrons and selecting only the 4 most chemically relevant orbitals (4 active electrons in 4 active orbitals), we get a 4-qubit problem that captures the essential correlation energy.
This is the same technique used in production quantum chemistry: identify which orbitals matter, freeze the rest, and focus quantum resources on the hard part.
How It Works
Active Space Selection
CODEFull H2O (STO-3G): 10 electrons, 7 orbitals -> ~14 qubits | Freeze core (1s on O) | Active space: 4 electrons, 4 orbitals -> 4 qubits
The frozen core contributes a constant energy offset absorbed into the identity coefficient of the Hamiltonian. The active electrons capture bonding, lone pairs, and correlation effects.
The Ansatz: 2-Layer All-to-All Entangling
Unlike LiH's linear CX chain, H2O uses all-to-all CX-RZ-CX entangling blocks. Water's bent geometry creates orbital interactions between non-adjacent qubits that a linear chain cannot efficiently capture.
CODELayer 1 Layer 2 q0: ─RY(θ₀)─■──────■──────■───────────── ─RY(θ₁₀)─■───────■───────■────────── │ │ │ │ │ │ q1: ─RY(θ₁)─X─RZ─X─│──────│──■────────── ─RY(θ₁₁)──X─RZ─X──│───────│──■────── │ │ │ │ │ │ q2: ─RY(θ₂)─────────X─RZ─X─│──X─RZ─X─■── ─RY(θ₁₂)──────────X─RZ─X──│──X─RZ─X─■── │ │ │ │ q3: ─RY(θ₃)─────────────────X─RZ─X────X─RZ─X ─RY(θ₁₃)──────────────────X─RZ─X─────X─RZ─X
- RY: Controls amplitude mixing (polar angle on Bloch sphere)
- CX-RZ-CX: Parameterized ZZ-type interaction between qubit pairs
- All-to-all: 6 pairs per layer (0-1, 0-2, 0-3, 1-2, 1-3, 2-3)
- 20 parameters: (4 RY + 6 CX-RZ-CX) x 2 layers
The Hamiltonian: 12 Pauli Terms (Active Space)
The full H2O Hamiltonian in STO-3G has 500+ Pauli terms. After active space reduction, the dominant contributions are captured in 12 terms:
| Term | Coefficient | Physical meaning |
|---|---|---|
| IIII | -75.3618 | Constant offset (calibrated to FCI, includes frozen core) |
| ZIII | +0.25 | Single-qubit Z on qubit 3 |
| IZII | +0.25 | Single-qubit Z on qubit 2 |
| IIZI | -0.15 | Single-qubit Z on qubit 1 |
| IIIZ | -0.15 | Single-qubit Z on qubit 0 |
| ZZII | +0.12 | ZZ correlation, qubits 2-3 |
| IIZZ | +0.08 | ZZ correlation, qubits 0-1 |
| ZIZI | +0.10 | Alternating Z correlation |
| XXII | +0.05 | XX exchange, qubits 2-3 |
| YYII | +0.05 | YY exchange, qubits 2-3 |
| IIXX | +0.04 | XX exchange, qubits 0-1 |
| IIYY | +0.04 | YY exchange, qubits 0-1 |
Note the single-qubit Z terms (absent in H2 and LiH's simplified Hamiltonians) — these arise from the asymmetric orbital energies in the active space due to oxygen's larger nuclear charge.
Measuring Multi-Qubit Pauli Strings
Each 4-character Pauli string requires its own measurement circuit. Before measuring, rotate each qubit into the appropriate basis:
- I or Z: No rotation (computational basis)
- X: Apply H (Hadamard)
- Y: Apply S†H
For example, to measure XXII, apply H on qubits 0 and 1 (the X positions), leave qubits 2 and 3 unchanged, then measure all in the computational basis.
PYTHONfrom circuit import run_circuit, optimize_vqe # Quick evaluation with initial parameters result = run_circuit() print(f"Energy: {result['energy']:.4f} Ha") # Full optimization (takes longer — 20 parameters) opt = optimize_vqe(max_iterations=200, shots=2048, seed=42) print(f"Optimized: {opt['optimal_energy']:.4f} Ha")
The Math
Active Space Approximation
The full electronic Hamiltonian operates on all electrons. Active space methods partition the orbitals:
E_total = E_frozen_core + E_active_space + E_core-active_interaction
The frozen core energy is absorbed into the identity term. The core-active interaction is approximated as a mean-field contribution. The remaining active space Hamiltonian is the one we solve with VQE.
Scaling Comparison
| Property | H2 | LiH | H2O (active) | H2O (full) |
|---|---|---|---|---|
| Electrons | 2 | 4 | 4 (of 10) | 10 |
| Qubits | 2 | 4 | 4 | ~14 |
| Parameters | 4 | 16 | 20 | ~100+ |
| Hamiltonian terms | 5 | 9 | 12 | 500+ |
| Matrix size | 4x4 | 16x16 | 16x16 | 16384x16384 |
| Measurement circuits | 2 | 8 | 11 | 100+ |
| Connectivity | linear | linear | all-to-all | all-to-all |
Active space reduction is what makes VQE practical for real molecules. Without it, even water would require circuits far beyond current NISQ capabilities.
Frozen Core Justification
The 1s orbital on oxygen has an ionization energy of ~543 eV, while valence orbitals are ~12-15 eV. The energy scale separation is >30x, meaning core electrons are essentially inert during chemical bonding. Freezing them introduces errors of <1 mHa for most properties.
Expected Output
| Metric | Value |
|---|---|
| Exact ground state (FCI/STO-3G) | -76.0618 Ha |
| VQE with optimized parameters | -76.0 to -76.1 Ha |
| Initial guess energy | ~-75.5 Ha |
| Chemical accuracy threshold | ±1.6 mHa |
With a simplified 12-term Hamiltonian, VQE may not reach chemical accuracy. The full 500+ term Hamiltonian is needed for production-quality results.
Running the Circuit
PYTHONfrom circuit import run_circuit, optimize_vqe, verify_vqe # Quick evaluation result = run_circuit() print(f"Energy: {result['energy']:.4f} Ha (error: {result['error']:.4f})") print(f"Active space: {result['active_space']}") # Full optimization opt = optimize_vqe(max_iterations=200, shots=2048, seed=42) print(f"Optimized: {opt['optimal_energy']:.4f} Ha") print(f"Chemical accuracy: {opt['chemical_accuracy']}") # Verification v = verify_vqe() for check in v["checks"]: status = "PASS" if check["passed"] else "FAIL" print(f"[{status}] {check['name']}: {check['detail']}")
Try It Yourself
-
Compare connectivity: Replace all-to-all CX with a linear chain (like LiH). How much accuracy is lost? This shows why H2O needs richer entanglement.
-
Expand the active space: Add a 5th qubit (5 active orbitals). Does the extra orbital improve the energy enough to justify the deeper circuit?
-
Try different optimizers: Compare COBYLA, Nelder-Mead, and Powell on the 20-parameter landscape. Which converges fastest?
-
Vary the geometry: Adjust the O-H bond angle from 90 to 180 degrees (modify Hamiltonian coefficients). Can VQE reproduce the equilibrium angle of 104.5 degrees?
-
Benchmark active space quality: Compare the exact diagonalization of the 12-term Hamiltonian with the FCI reference. How much error comes from the Hamiltonian truncation vs. the VQE optimization?
What's Next
- BeH2 Ground State — 6 qubits, the largest in the VQE progression
- QAOA MaxCut — Variational algorithms for optimization (not chemistry)
Applications
| Domain | Use case |
|---|---|
| Active space methods | Demonstrating orbital selection and frozen-core techniques |
| Benchmark | Standard test for VQE with non-trivial active space reduction |
| Water chemistry | Foundation for studying solvation, hydrogen bonding, and reactivity |
| Algorithm R&D | Testing all-to-all vs. linear connectivity, ansatz expressibility |
References
- Kandala, A. et al. (2017). "Hardware-efficient variational quantum eigensolver for small molecules and quantum magnets." Nature 549, 242-246. DOI: 10.1038/nature23879
- Peruzzo, A. et al. (2014). "A variational eigenvalue solver on a photonic quantum processor." Nature Communications 5, 4213. DOI: 10.1038/ncomms5213
- Helgaker, T., Jorgensen, P., Olsen, J. (2000). "Molecular Electronic-Structure Theory." Wiley. ISBN: 978-0-471-96755-2
- McArdle, S. et al. (2020). "Quantum computational chemistry." Reviews of Modern Physics 92, 015003. DOI: 10.1103/RevModPhys.92.015003