Overview#
boss-bench is the Python package of the BoSS. It loads the data and computes the
benchmark metrics exactly as they are defined in the paper. It depends only on NumPy,
SciPy, h5py and Matplotlib, and needs Python 3.9 or newer. Install it with
pip install boss-bench
or from source:
git clone https://github.com/mishapadidar/boss_bench.git
cd boss_bench
pip install .
Then import it as
import boss_bench as bb
The package works on local files, so download the data first.
What’s in the package#
Each module has its own page, with every function and the formula of every metric.
boss_bench.dataFinds the downloaded files and reads them: one configuration at a time with
load_record(), or chosen fields of many configurations at once.boss_bench.confinementComputes the loss metrics of the particles born on one surface: the loss fraction, the energy loss and its normalized form, and the mean confinement time, e.g.
loss_fraction().boss_bench.heat_fluxFinds where lost particles strike the plasma boundary and turns their energy into a heat flux on the boundary. It also scores predictions for the heat-flux benchmark, with
heat_flux_metrics().boss_bench.trajectoryProvides convenience functions to load trajectory data for one particle or one device, and to convert orbits to Cartesian coordinates. It also computes the prediction-error metrics of the trajectory benchmark, with
trajectory_metrics().boss_bench.designScores generated designs for the inverse-design benchmark, with
design_metrics().boss_bench.plottingPlots a configuration, its particle losses and heat flux, and its orbits, alone or next to a model’s predictions.
Benchmarks#
Each benchmark scores a model’s predictions on the test split with the metrics of the paper:
Surrogate models: predict a quantity of each configuration, such as its
loss_fraction()ornormalized_energy_loss()at \(s_0 = 0.1\).Heat flux: predict the loss fraction and the strike points of the lost particles, for each configuration and birth surface; scored by
heat_flux_metrics().Trajectories: predict each orbit from its first sample; scored by
trajectory_metrics().Inverse design: generate designs and evaluate them with VMEC and particle tracing; scored by
design_metrics().
Tutorials#
To see the package in use, work through the tutorials:
Exploring a stellarator: load a configuration, plot it, and compute its losses and heat flux.
Loading trajectory data: read and plot orbits, and draw rollouts.
Fitting a surrogate model: predict loss fractions with scikit-learn.