boss_bench

boss_bench.plotting#

Plots of configurations, particle losses, heat flux and trajectories.

boss_bench.plotting.plot_device(record, ax=None)[source]#

Draw the plasma boundary over the full torus, colored by \(|B|\) and viewed from above.

Parameters:
  • record (dict) – the configuration’s fields from data.load_record, including boundary_xyz, modB, phi1d, theta1d and nfp.

  • ax (matplotlib.axes.Axes, optional) – a 3D axis to draw on. By default, a new figure is made.

Returns:

the axis.

Return type:

matplotlib.axes.Axes

boss_bench.plotting.plot_modB_boozer(record, s=0.5, ax=None)[source]#

Plot contours of \(|B|\) on a flux surface in Boozer coordinates, with field lines in black.

Parameters:
  • record (dict) – the configuration’s fields from data.load_record, including modB_boozer, iota, s1d, phi1d, theta1d and nfp.

  • s (float) – the flux surface; the nearest stored surface is used.

  • ax (matplotlib.axes.Axes, optional) – the axis to draw on. By default, a new figure is made.

Returns:

the axis.

Return type:

matplotlib.axes.Axes

boss_bench.plotting.plot_loss_fraction_curves(record, ax=None)[source]#

Plot the fraction of particles lost by time \(t\), for each birth surface.

Parameters:
  • record (dict) – the configuration’s fields from data.load_record on a confinement file, including confinement_time, s_init and t_max.

  • ax (matplotlib.axes.Axes, optional) – the axis to draw on. By default, a new figure is made.

Returns:

the axis.

Return type:

matplotlib.axes.Axes

boss_bench.plotting.plot_strike_points(record, predictions=None, bins=32)[source]#

Plot where the lost particles strike the boundary, as points colored by energy and as a density.

One column per birth surface: the first row shows the true strike points, the second their density. Predictions, if given, add two more rows with the same color scales. The density is a histogram over the Boozer angles of the full torus, normalized to integrate to 1 [1/rad²].

Parameters:
  • record (dict) – the configuration’s fields from data.load_record on a confinement file.

  • predictions (dict, optional) – maps each birth surface s0 to a tuple (zeta, theta, energy, loss_fraction): the Boozer angles [rad] and energies [MeV] of the predicted strike points, arrays of shape (k,), and the predicted loss fraction, a float.

  • bins (int) – the number of density bins per angle.

Returns:

the figure.

Return type:

matplotlib.figure.Figure

boss_bench.plotting.plot_heat_flux(record, predictions=None, resolution=32)[source]#

Plot the heat flux on the boundary over one field period, from heat_flux.binned_heat_flux.

One column per birth surface. Predictions, if given, are drawn in a second row on the same color scale as the truth, scaled so that their total is the predicted loss fraction.

Parameters:
  • record (dict) – the configuration’s fields from data.load_record on a confinement file.

  • predictions (dict, optional) – maps each birth surface s0 to a tuple (zeta, theta, energy, loss_fraction): the Boozer angles [rad] and energies [MeV] of the predicted strike points, arrays of shape (k,), and the predicted loss fraction, a float.

  • resolution (int) – the number of bins per angle.

Returns:

the figure.

Return type:

matplotlib.figure.Figure

boss_bench.plotting.plot_rollouts(z_true, z_pred=None, window_us=350, toroidal_window_us=20)[source]#

Plot embedded trajectories against lead time, one row per trajectory and one column per channel.

The toroidal channels go around about once per sample, so they are drawn over a shorter window, with markers.

Parameters:
  • z_true (np.ndarray) – true embedded states, shape (n, T, 5), with row k at lead time \(k\) µs, as from trajectory.read_trajectories.

  • z_pred (np.ndarray, optional) – predicted states, of the same shape.

  • window_us (float) – the lead times shown for the \(x\), \(y\) and \(\lambda\) channels [µs].

  • toroidal_window_us (float) – the lead times shown for the toroidal channels [µs].

Returns:

the figure.

Return type:

matplotlib.figure.Figure