Skip to Content
Back

Set the number of workers

Performance

Blaze parallelises across sweep JOBS, not across the linear algebra within a single job. With threads=N and a sweep of MM jobs, up to NN jobs run concurrently on the desktop. The browser build is single-threaded by design (one WASM core), so jobs run sequentially here, but the same Python code scales straight to your laptop or a workstation without changes.

Explorer
set-number-of-workers/
workers.py
1import blaze
2
3# On the desktop, threads=N distributes sweep jobs across N workers.
4# In the browser WASM build there is a single core, so the thread
5# setting is ignored for live compute, but the API is identical.
6results = blaze.solve(
7    lattice_type="square",
8    epsilon_background=1.0,
9    epsilon_atoms=8.9,
10    radius_atom=[0.2, 0.35, 0.05],
11    polarization="TM",
12    n_bands=8,
13    threads=4,
14)
15
16print(f"{len(results)} jobs done")
⚠ The browser runs a single-threaded WASM build. Thread settings are accepted by the API but ignored for in-browser compute (jobs run sequentially on one core).

Band diagram

Run the example to see the band diagram.

Result · list[BandResult] (0)

Result
results:list[BandResult] (0)