Skip to content
/ blaze2d Public

A Rust-based 2D PWE Maxwell solver architected specifically for massive parameter sweeps. It significantly outperforms MIT's MPB while achieving a similar accuracy.

License

Notifications You must be signed in to change notification settings

RnLe/blaze2d

Repository files navigation

Blaze2D

A Rust-based 2D Maxwell solver designed for large-scale band diagram sweeps. Outperforms MIT's MPB in TM polarizations and high-throughput workloads.

PyPI License

Try it in your browser — no installation required (WebAssembly).


Quick Start

# Clone and test
git clone https://github.com/RnLe/blaze2d.git
cd blaze2d
cargo test

# Run a simulation
cargo run --release -- --lattice square --eps-bg 13.0 --radius 0.3 --polarization TM --resolution 24

# Reproduce benchmarks (requires conda/mamba for MPB)
cd benchmarks
make setup-env   # one-time: creates mpb-reference environment
make quick       # ~2 min validation run

Full Installation Guide


Usage

Blaze2D offers two interfaces:

Interface Best For Documentation
CLI flags Quick single runs, scripting CLI Reference
TOML files Reproducible simulations, parameter sweeps TOML Reference

Quick Example

# Using CLI flags
blaze2d --lattice square --eps-bg 13.0 --radius 0.3 --polarization TM --resolution 24

# Using a TOML file
blaze2d run examples/square_eps13_r0p3_tm_res24.toml

Web Demo

The solver compiles to WebAssembly, enabling browser-based simulations without installation:

https://rnle.github.io/blaze2d/blaze/

Features:

  • Interactive band diagram visualization
  • Real-time parameter adjustment
  • Export results as CSV/JSON

Benchmarks

Comparative benchmarks against MPB under matched conditions (same tolerance, resolution, band count).

Technical Report with Full Results


Installation

From PyPI (Recommended)

pip install blaze2d

From Source

git clone https://github.com/RnLe/blaze2d.git
cd blaze2d
cargo build --release

The binary will be at target/release/blaze2d.

Requirements

  • Rust 1.91+ (for building from source)
  • Python 3.9+ (for Python bindings)

Optimization Potential

Blaze2D is currently CPU-bound with a straightforward LOBPCG implementation. Significant performance gains are achievable through:

Optimization Expected Impact
Optimized preconditioners up to 2–3× fewer iterations
Dynamic subspace deflation Reduced dense matrix ops; faster convergence
Advanced BLAS/LAPACK integration Faster dense operations; speedup potential 1–3x
GPU acceleration (CUDA/Metal) 10–100× for large grids; linear scaling (!)

GPU support is expected to provide substantial speedups even at modest resolutions (64×64), where memory transfer overhead is amortized across many eigenvalue iterations.


License

Licensed under the MIT License. See LICENSE for details.

Citation

If you use Blaze2D in academic work, please cite this repository.

About

A Rust-based 2D PWE Maxwell solver architected specifically for massive parameter sweeps. It significantly outperforms MIT's MPB while achieving a similar accuracy.

Topics

Resources

License

Stars

Watchers

Forks