Variational Quantum Eigensolver for computing electromagnetic modes of vacuum and cold-plasma-filled rectangular waveguides.
This repository implements a Variational Quantum Algorithm (VQA) to solve eigenvalue problems arising in rectangular waveguide theory:
| Regime | Equation | Eigenvalue |
|---|---|---|
| Vacuum | ||
| Cold Plasma (O-mode) |
The spatial domain is discretised on a
This is the physical representation of our system.
An MLP neural network is trained to predict good initial circuit parameters
├── src/
│ ├── __init__.py
│ ├── coldplasma_vqe_waveguide.py # Core VQE solver
│ └── ml_warmstart_vqe.py # ML warm-start extension
│
├── notebooks/
│ ├── 01_vacuum_waveguide.ipynb # Vacuum TM/TE modes
│ ├── 02_cold_plasma_waveguide.ipynb # Plasma modes (no ML)
│ ├── 03_train_ml_warmstart.ipynb # Train the ML predictor
│ └── 04_cold_plasma_with_ml.ipynb # Plasma modes with ML warm-start
│
├── warmstart_models/ # Trained MLP models (joblib)
├── data/ # Training data for ML warm-start
├── figures/ # Generated plots
├── .github/workflows/ci.yml # Test workflow
├── pyproject.toml
├── requirements.txt
├── LICENSE
└── README.md
Editable install (recommended — this also wires up from src import ...):
pip install -e .To additionally run the notebooks and the test suite:
pip install -e ".[notebooks,dev]"Or, for a plain runtime environment:
pip install -r requirements.txtfrom src import WaveguideModeVQA
solver = WaveguideModeVQA(
nx=2, ny=2, n_layers=2,
mode_type='TM',
Lx=0.015, Ly=0.010,
)
eigenvalue, params, history = solver.optimize_mode(k=0)
solver.print_plot_parameters(0, eigenvalue, params)solver = WaveguideModeVQA(
nx=2, ny=2, n_layers=2,
mode_type='TM',
Lx=0.015, Ly=0.010,
plasma_density=1e17, # Uniform Ne = 10^17 m^-3
)
eigenvalue, params, history = solver.optimize_mode(k=0)
solver.print_plasma_info(eigenvalue)from src import WarmStartPredictor, WarmStartVQA
# Load pre-trained predictor
predictor = WarmStartPredictor(
data_path='data/warmstart_data.json',
model_dir='warmstart_models',
)
# Solve with warm-start
solver = WarmStartVQA(
nx=2, ny=2, n_layers=2,
mode_type='TM',
plasma_density=1e17,
predictor=predictor,
)
eigenvalue, params, history = solver.optimize_mode(k=0)| Notebook | Description |
|---|---|
| 01_vacuum_waveguide.ipynb | Compute TM and TE cutoff modes of a vacuum waveguide. Compares VQE results against classical diagonalisation. |
| 02_cold_plasma_waveguide.ipynb | Solve O-mode eigenvalues with uniform and Gaussian plasma profiles. Includes a density sweep. |
| 03_train_ml_warmstart.ipynb | Full ML training pipeline: data collection → MLP training → diagnostics → benchmarking. |
| 04_cold_plasma_with_ml.ipynb | Side-by-side comparison of ML warm-start vs random initialisation convergence. |
Reference cutoff frequencies for a 15 mm × 10 mm vacuum waveguide on a 16 × 8 grid (classical diagonalisation of the finite-difference operator):
| Mode | TM |
TM |
TE |
TE |
|---|---|---|---|---|
| 0 | 141 158 | 17.93 | 43 724 | 9.98 |
| 1 | 270 651 | 24.82 | 97 434 | 14.89 |
| 2 | 418 627 | 30.87 | 141 158 | 17.93 |
| 3 | 480 934 | 33.09 | 173 216 | 19.86 |
The VQE reproduces these to high accuracy. For a uniform-plasma O-mode example, the VQE eigenvalue agrees with the dense numerical eigenvalue to a relative error of about 0.015%. See the notebooks for full convergence plots.
pip install -e ".[dev]"
pytestThe suite checks operator symmetry, that adding plasma shifts the spectrum upward, and that the VQE ground mode matches classical diagonalisation within tolerance.
- Python ≥ 3.10
- Qiskit ≥ 1.0
- qiskit-algorithms
- NumPy, SciPy, Matplotlib
- scikit-learn, joblib (for ML warm-start)
See requirements.txt for exact versions.
For a rectangular waveguide of dimensions
When the waveguide is filled with a cold magnetised plasma, the O-mode
(ordinary mode) propagation is governed by a modified Helmholtz equation
where the plasma frequency
If you use this code in your research, please cite:
@software{quantum_vqe_waveguide,
title = {Quantum VQE Waveguide Solver with ML Warm-Start},
author = {Juan Manuel},
year = {2026},
url = {https://github.com/JuanManuelsm95/quantum-vqe-waveguide}
}MIT License — see LICENSE for details.

