Install, Run and Test Blaze
Get started with Blaze.
Blaze is designed to be accessible. Whether you’re a researcher looking for a quick photonic band structure calculation or a developer who wants to explore the codebase, there’s an installation path for you.
Quick Install via PyPI
The fastest way to get started is through Python’s package manager:
pip install blaze2dThis installs the pre-built binaries and Python bindings. For usage examples and API documentation, visit the PyPI project page .
Running Blaze
Blaze offers two interfaces for running simulations:
| Interface | Best For |
|---|---|
| CLI flags | Quick single runs, scripting |
| TOML files | Reproducible simulations, parameter sweeps |
CLI Flags
For quick, one-off calculations, you can specify all parameters directly on the command line:
blaze2d --lattice square --eps-bg 13.0 --radius 0.3 --polarization TM --resolution 24This is ideal for rapid prototyping or when integrating Blaze into shell scripts.
TOML Configuration Files
Recommended: TOML configuration files are the intended way to use Blaze for serious work. They make your simulations reproducible, shareable, and version-controllable; without sharing actual code.
TOML files separate your simulation parameters from the execution environment. This modern, modular approach means you can:
- Share configurations with collaborators without compatibility issues
- Track changes in version control more easily
- Reproduce results months or years later with identical parameters
- Organize parameter sweeps in a clean, readable format
blaze2d run examples/square_eps13_r0p3_tm_res24.tomlThe repository includes numerous example configurations in the examples/ directory, covering square and hexagonal lattices, various polarizations, and bulk parameter sweeps.
Building from Source
For those who want to modify Blaze, contribute to development, or simply prefer building from source:
git clone https://github.com/RnLe/blaze2d.git
cd blaze2d
cargo build --releaseThe compiled binary will be available at target/release/blaze2d.
Requirements
- Rust 1.91+ (install via rustup )
- Python 3.9+ (for Python bindings, optional)
Running Tests
If you want to inspect the testing infrastructure or verify your build:
cargo testThis runs the full test suite, including unit tests for the core solver algorithms, integration tests for the CLI, and validation tests that compare results against reference solutions.
Reproducing Benchmarks
All performance benchmarks shown in the Blaze introduction can be reproduced from the benchmarks/ directory. The suite is organized with a clean Makefile that automates the entire process.
Quick Start
cd benchmarks
# Run everything (takes 10-20 minutes)
make all
# Or run specific categories
make single # Single-core benchmarks (MPB vs Blaze)
make multi # Multi-core benchmarks (16 threads)
# Generate all plots from existing data
make plotBenchmark Series
The benchmarks are organized into focused series, each targeting a specific aspect of solver performance:
| Series | Target | Command |
|---|---|---|
| Series 1 | Epsilon sweep (dielectric contrast) | make series1 |
| Series 2 | Number of bands scaling | make series2 |
| Series 3 | Grid resolution scaling | make series3 |
| Series 4 | LOBPCG iteration count | make series4 |
| Series 5 | Memory usage comparison | make series5 |
| Series 6 | Accuracy validation (f32 vs f64) | make series6 |
| Series 7 | Multi-threading scaling | make series7 |
Each series has a corresponding make plot-seriesX target to regenerate its plots independently.
Benchmark Requirements
The benchmark suite compares Blaze against MIT Photonic Bands (MPB) , which requires a dedicated conda environment. The Makefile will automatically check for this environment and guide you through setup if needed.
First-time setup:
cd benchmarks
# Option 1: Let the Makefile create the environment (auto-detects mamba/conda)
make setup-env
# Option 2: Create manually
mamba env create -f environment.yml # recommended (faster)
conda env create -f environment.yml # alternativeThe environment.yml file includes MPB, meep, and all required dependencies. Once installed, the environment will be auto-detected whether you use conda or mamba.
Verify your setup:
make check-envIf the environment is missing, you’ll see clear instructions on how to set it up.
Summary of requirements:
- MPB: Auto-installed via
make setup-envorconda env create -f environment.yml - Blaze2D: Rust toolchain (automatically built by the Makefile)
- Plotting: Python with
matplotlibandnumpy(included in the environment)
Run make help for a comprehensive overview of all available targets and their parameters.
