A project that benchmarks and compares two approaches to handling the energy levels of the hydrogen atom:
- A pure C++ Eigen based linear decomposition of the Hamiltonian
- Using qiskit in Python to perform a VQE on the Hamiltonian
The analytic hamiltonian for the radial component of the wavefunction
in SI units and
in atomic units. A brief note that the C++ eigensolver uses SI units, and the python VQE uses atomic units (for consistency in Qiskit implementations). The ground state energy is
While exact diagonalization (C++ approach) scales as O(
- Classical Solver (
$N=1000$ )- Error:
$~0.02%$ - Runtime:
$~0.3$ seconds - Deterministic result
- Error:
- VQE (4 qubits,
$N=16$ )- Mean error:
$4.13\pm0.95%$ - Best error:
$3.40%$ - Runtime:
$13.83\pm7.29$ seconds - Best runtime:
$5.11$ seconds
- Mean error:
Variability in the VQE approach arises from sensitivity to initial parameter choice, as well as the non-convex optimization landscape. In a more expressive ansatz, the barren plateau effect may become more significant due to the expressibility and depth of the ansatz.
The classical approach uses a significantly larger basis (
The key distinction between these approaches is as
Future extensions could incorporate shot-based estimation and noise models to study the robustness of VQE under realistic NISQ hardware constraints.
After installing all dependencies, you can simply run make from the main directory of the repository. If you wish to run only the classical approach, run make classic. For just the quantum portion: make quantum. For just the studying of the phase space of the VQE: make evaluation.
├── quantum/
├── classical/
├── data/
├── Plots/
├── Plotting/
├── Makefile
├── README.md
quantum/: Directory that performs a VQE in Python and qiskit to solve for the ground state energy of the Hydrogen atom. Contains two files:vqe.py: file that handles the VQE solving, as well as creating the Hamiltonian for the VQEerror_estimation.py: file that benchmarks and evaluates top achievable VQE model performance for varying number of qubits, N and max radius
classical/: Directory that houses C++ code to perform classical eigendecomposition of Hamiltonian to solve for energy levels of Hydrogen atom. This file also outputs the data for the reconstructed wavefunctions of the Hydrogen atom and stores them indata/wavefunctions.datsrc/Houses the source code to run the eigensolverinclude/Houses the header file to define the eigenSolver class, various constants and other methods
data/: Directory that contains data for output wavefunctions from classical approachMakefile: Top-level Makefile that, upon running "make", will run all the code and produce the output comparisonsPlots/: Directory that contains output oferror_estimation.py, including various quantitative evaluations of the VQE project on Hydrogen. As well, output wave functions from the classical approach (done in thePlotting/directory)Plotting/: usage of gnuplot-latex-utils as a submodule to create publication-quality plots on the fly through gnuplot and LaTeX. Please see original documentation for more information.wave_functions/: Directory that plots the extracted wave functions from the classical approach vs the analytic curves.pdfs/: Where the output pdf is stored/
- Classical:
- C++ >= C++17
- CMake
- Eigen3
- Quantum:
- numpy
- matplotlib
- scipy (scipy.optimize)
- qiskit
- Dependencies outlined in gnuplot-latex-utils including
- Gnuplot
- LaTeX
- Heatmap of minimum achievable VQE error as a function of qubit count and maximum radial cutoff r_max. The optimal configuration (9 qubits, r_max = 9.0) is highlighted.

- Comparison of numerically computed eigenfunctions (C++ diagonalization) with analytic hydrogen wavefunctions for the ground and first excited states.
