Skip to main content

BLAZE - Band-structure LOBPCG Accelerated Zone Eigensolver for 2D Photonic Crystals

Project description

BLAZE - Band-structure LOBPCG Accelerated Zone Eigensolver

High-performance 2D photonic crystal band structure solver with Python bindings.

Installation

pip install blaze2d

Quick Start

from blaze import BulkDriver

# Load configuration from TOML file
driver = BulkDriver("config.toml")
print(f"Will run {driver.job_count} jobs")

# Stream results as they complete (for live plotting)
for result in driver.run_streaming():
    print(f"Job {result['job_index']}: {result['num_bands']} bands")
    # result['bands'] is a 2D array [k_index][band_index]
    # result['distances'] is the k-path distance for plotting

# Or collect all results at once
results, stats = driver.run_collect()
print(f"Completed {len(results)} jobs in {stats['total_time_secs']:.2f}s")

Configuration

BLAZE uses TOML configuration files. Example for a parameter sweep:

[bulk]
output_dir = "results"
output_mode = "full"

[bulk.ranges]
radius = { min = 0.2, max = 0.4, step = 0.05 }
eps_inside = { values = [9.0, 12.0, 13.0] }
polarization = ["te", "tm"]

[simulation]
resolution = 32
num_bands = 8

[lattice]
type = "square"

[[atoms]]
position = [0.5, 0.5]
radius = 0.3
epsilon = 1.0

API Reference

BulkDriver

driver = BulkDriver(config_path: str, threads: int = 0)
  • config_path: Path to TOML configuration file
  • threads: Thread count (-1 = adaptive, 0 = auto, >0 = fixed)

Properties

  • job_count: Number of jobs to execute
  • config_path: Path to configuration file

Methods

Method Description
run_streaming() Iterator yielding results as they complete
run_streaming_filtered(k_indices, band_indices) Filtered streaming
run_collect(k_indices, band_indices) Collect all results into list
run_batched(buffer_size_mb) Run with buffered disk I/O
run() Synchronous execution
dry_run() Count jobs without executing

Result Dictionary

Each result is a dictionary with:

Key Type Description
job_index int Job identifier
params dict Simulation parameters
k_path list K-points as (kx, ky) tuples
distances list Cumulative k-path distance
bands list 2D array [k_index][band_index]
num_k_points int Number of k-points
num_bands int Number of bands

Plotting Example

import matplotlib.pyplot as plt
from blaze import BulkDriver

driver = BulkDriver("sweep.toml")

# Live plotting with streaming
plt.ion()
fig, ax = plt.subplots()

for result in driver.run_streaming():
    ax.clear()
    for band_idx in range(result['num_bands']):
        band = [result['bands'][k][band_idx] for k in range(result['num_k_points'])]
        ax.plot(result['distances'], band)
    ax.set_xlabel('k-path')
    ax.set_ylabel('ω (normalized)')
    ax.set_title(f"Job {result['job_index']}")
    plt.pause(0.01)

plt.ioff()
plt.show()

Filtered Streaming

For large simulations, filter to only the k-points and bands you need:

# Stream only Gamma (0), X (10), M (15) and first 4 bands
for result in driver.run_streaming_filtered(
    k_indices=[0, 10, 15],
    band_indices=[0, 1, 2, 3]
):
    assert result['num_k_points'] == 3
    assert result['num_bands'] == 4

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blaze2d-0.1.0.tar.gz (214.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blaze2d-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

File details

Details for the file blaze2d-0.1.0.tar.gz.

File metadata

  • Download URL: blaze2d-0.1.0.tar.gz
  • Upload date:
  • Size: 214.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for blaze2d-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c0d0efed23e8b724dda7a355478019fd15d4e0af0f4e84d80438e400d2b40334
MD5 a2f88520647e96c99e1f744385a7e317
BLAKE2b-256 64b6912c5710364aa8754177f35d2137072869610f49f55b49c95d31cc22adea

See more details on using hashes here.

File details

Details for the file blaze2d-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for blaze2d-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 d2da42957e7a1ff47151d089cbf7b2b7e0f20c37d88880556f6060182f5a49fc
MD5 013380276b6f5c886f8a844e31af4c5f
BLAKE2b-256 4bec0cabaab1ca072d368299994aa11ad69c2049162a7264d9a6405c9e31fa1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page