VQE for H2O Molecule Ground State
Known limitation (October 2026): This demo's 4-qubit Hamiltonian is an illustrative model with round-number coefficients, not computed from water, and its constant term is set to -76.0618 Ha, which is not water's FCI/STO-3G energy (PySCF gives -75.0126 Ha at the experimental geometry, about 1.05 Ha higher). Every energy the code prints is an energy of this model, so the page shows how VQE, Pauli-string measurement and an all-to-all ansatz work, not water's energy. A corrected version is planned.
What You'll Learn:
- How active space reduction shrinks a 10-electron molecule's qubit count (this demo then uses a 4-qubit model Hamiltonian)
- 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 already needed reductions (a frozen core and fewer orbitals) to fit in 4 qubits. Water (H2O) needs more. 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. Two of H2O's ten electrons sit in a deep core orbital (oxygen 1s, orbital energy about -20 Ha) that barely participates in chemical bonding. Freezing it leaves 8 electrons in 6 orbitals (12 qubits). A smaller active space of 4 electrons in 4 orbitals would still need 8 qubits (6 with the parity reduction) and recovers only about 15% of the STO-3G correlation energy. So the 4-qubit Hamiltonian used below is an illustrative model, not the output of this reduction.
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) | Frozen core: 8 electrons, 6 orbitals -> 12 qubits | Active space: 4 electrons, 4 orbitals -> 8 qubits (6 with parity reduction) This demo: 4-qubit model Hamiltonian (illustrative, not derived from the above)
In a real active-space calculation, the frozen core contributes a constant energy offset that is absorbed into the identity coefficient of the Hamiltonian, and the active electrons capture bonding, lone pairs, and correlation effects. In this demo's model, the identity coefficient is simply set so the lowest eigenvalue is -76.0618 Ha.
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 (1,086 under Jordan-Wigner). This demo uses an illustrative 12-term model Hamiltonian with round-number coefficients instead; it is not derived from water's integrals, and its constant term is set so the lowest eigenvalue is -76.0618 Ha. It shows how VQE behaves on a 4-qubit problem:
| Term | Coefficient | Physical meaning |
|---|---|---|
| IIII | -75.3618 | Constant offset (set so the lowest eigenvalue is -76.0618 Ha) |
| 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 (also present in H2; only the simplified LiH model leaves them out). In real molecular Hamiltonians they come from the orbital energies; in this model their values are illustrative.
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 3 and 2 (the X positions, since the leftmost character is the highest qubit), leave qubits 1 and 0 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. In a real calculation, the remaining active space Hamiltonian is the one solved with VQE; this demo solves its 12-term model in its place.
Scaling Comparison
| Property | H2 | LiH | H2O (4-qubit model) | H2O (full) |
|---|---|---|---|---|
| Electrons | 2 | 4 | n/a (model) | 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 |
|---|---|
| Real FCI/STO-3G energy of water (PySCF, experimental geometry) | -75.0126 Ha |
Lowest eigenvalue of the 12-term model (the code's exact_ground_state) | -76.0618 Ha |
| VQE with optimized parameters (model energy) | about -75.7 to -76.06 Ha; most runs -76.00 to -76.06 |
| Initial guess energy (model energy) | ~-74.9 Ha |
| Chemical accuracy threshold | ±1.6 mHa |
These are energies of the 12-term model, not of water. The code's reference value (-76.0618 Ha) is the model's lowest eigenvalue, about 1.05 Ha below water's real FCI/STO-3G energy, so even a perfect VQE run on this model does not give water's energy. A real calculation would use the full Hamiltonian (500+ terms) or a properly reduced active space.
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']}")
chemical_accuracy compares one noisy 2048-shot estimate with the lowest eigenvalue of this model Hamiltonian. It can read True by chance (the estimate can land within 1.6 mHa while the state is several mHa off), and it is not a statement about water's real energy.
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: The 12-term model's lowest eigenvalue is set by hand, so it matches the code's reference by construction. Build the real STO-3G Hamiltonian instead (for example with PySCF and Qiskit Nature), check that its exact ground state at the experimental geometry is -75.0126 Ha, and see how close VQE gets on it.
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