VQE for H2 Molecule Ground State
Overview
The Variational Quantum Eigensolver (VQE) is a hybrid quantum-classical algorithm for finding the ground state energy of molecules. This circuit implements VQE for the hydrogen molecule (H₂), the simplest molecular system.
The Algorithm
VQE uses a parameterized quantum circuit (ansatz) to prepare trial states, measures the energy, and uses classical optimization to minimize it.
CODE┌─────────────────────────────────────────────────┐ │ VQE Loop │ │ │ │ 1. Prepare |ψ(θ)⟩ with quantum circuit │ │ 2. Measure ⟨ψ(θ)|H|ψ(θ)⟩ │ │ 3. Classical optimizer updates θ │ │ 4. Repeat until converged │ │ │ └─────────────────────────────────────────────────┘
The Ansatz
Hardware-efficient ansatz for 2 qubits:
CODE┌──────────┐ ┌──────────┐ q_0: ┤ RY(θ₀) ├──■──┤ RY(θ₂) ├ ├──────────┤┌─┴─┐├──────────┤ q_1: ┤ RY(θ₁) ├┤ X ├┤ RY(θ₃) ├ └──────────┘└───┘└──────────┘
The H2 Hamiltonian
In the STO-3G basis, the H₂ Hamiltonian can be written as:
CODEH = c₀I + c₁Z₀ + c₂Z₁ + c₃Z₀Z₁ + c₄(X₀X₁ + Y₀Y₁)
At equilibrium bond length (~0.735 Å), the exact ground state energy is approximately -1.137 Hartree.
Running the Circuit
PYTHONfrom circuit import run_circuit, optimize_vqe # Single evaluation with default parameters result = run_circuit() print(f"Energy: {result['energy']:.4f} Ha") # Run full VQE optimization opt_result = optimize_vqe(max_iterations=50) print(f"Optimized energy: {opt_result['optimal_energy']:.4f} Ha")
Expected Output
| Metric | Value |
|---|---|
| Exact ground state | -1.137 Ha |
| VQE estimate (optimized) | -1.13 to -1.14 Ha |
| Chemical accuracy | ±1.6 mHa (0.001 Ha) |
Key Concepts
Variational Principle
The variational principle guarantees that any trial wavefunction gives an energy ≥ the true ground state energy:
⟨ψ|H|ψ⟩ ≥ E₀
Measurement
To compute ⟨H⟩, we measure each Pauli term separately:
- ZZ basis: Standard measurement
- XX basis: Apply H gates before measurement
- YY basis: Apply S†H gates before measurement
Applications
- Quantum Chemistry: Molecular ground state energies
- Drug Discovery: Protein folding, molecular interactions
- Materials Science: Electronic structure calculations
Limitations
- Barren Plateaus: Gradients vanish for deep circuits
- Noise: Real hardware introduces errors
- Local Minima: Classical optimizer may get stuck