forge.plotting

Plotting utilities.

This module provides standalone, data-driven plotting functions that can be used by both the original matplotlib-based workflow and the Panel/Bokeh GUI. Functions accept plain data (numpy arrays, dicts) and some accept optional matplotlib axes for embedding into existing figures.

forge.plotting.plot_profiles(psin_data, pprime_data, ffprime_data, pprime_func, ffprime_func, MU0=1.2566370614359173e-06)[source]

Plot pprime and ffprime profiles.

Parameters:
  • psin_data (array-like) – Normalised poloidal flux values.

  • pprime_data (array-like) – pprime profile data.

  • ffprime_data (array-like) – ffprime profile data.

  • pprime_func (callable) – Interpolator for pprime.

  • ffprime_func (callable) – Interpolator for ffprime.

  • MU0 (float) – Vacuum permeability.

forge.plotting.plot_equilibrium(R_2D, Z_2D, psi_2D, psi_lcfs, wall_R, wall_Z, axis=None)[source]

Plot the equilibrium contours.

Parameters:
  • R_2D (2D arrays) – Meshgrid arrays.

  • Z_2D (2D arrays) – Meshgrid arrays.

  • psi_2D (2D array) – Poloidal magnetic flux.

  • psi_lcfs (float) – Flux value at the last closed flux surface.

  • wall_R (array-like) – Wall coordinates.

  • wall_Z (array-like) – Wall coordinates.

  • axis (matplotlib Axes or None) – Axes to plot onto. Created if None.

Returns:

axis (matplotlib Axes)

forge.plotting.plot_fluxes(R_2D, Z_2D, psi_2D, psi_plas_2D, psi_mach_2D, psi_lcfs, wall_R, wall_Z, R_lcfs, Z_lcfs)[source]

Plot the total, plasma and machine flux surfaces.

Parameters:
  • R_2D (2D arrays) – Meshgrid arrays.

  • Z_2D (2D arrays) – Meshgrid arrays.

  • psi_2D (2D array) – Total poloidal magnetic flux.

  • psi_plas_2D (2D array) – Plasma contribution to flux.

  • psi_mach_2D (2D array) – Machine contribution to flux.

  • psi_lcfs (float) – Flux at the LCFS.

  • wall_R (array-like) – Wall coordinates.

  • wall_Z (array-like) – Wall coordinates.

  • R_lcfs (array-like) – LCFS coordinates.

  • Z_lcfs (array-like) – LCFS coordinates.

forge.plotting.plot_fields(R_2D, Z_2D, wall_R, wall_Z, R_lcfs, Z_lcfs, total_Br, plasma_Br, machine_Br, total_Bz, plasma_Bz, machine_Bz)[source]

Plot the total, plasma and machine Br and Bz field components.

Parameters:
  • R_2D (2D arrays) – Meshgrid arrays.

  • Z_2D (2D arrays) – Meshgrid arrays.

  • wall_R (array-like) – Wall coordinates.

  • wall_Z (array-like) – Wall coordinates.

  • R_lcfs (array-like) – LCFS coordinates.

  • Z_lcfs (array-like) – LCFS coordinates.

  • total_Br (2D arrays) – Radial field components.

  • plasma_Br (2D arrays) – Radial field components.

  • machine_Br (2D arrays) – Radial field components.

  • total_Bz (2D arrays) – Vertical field components.

  • plasma_Bz (2D arrays) – Vertical field components.

  • machine_Bz (2D arrays) – Vertical field components.

forge.plotting.plot_optimiser_state(R_2D, Z_2D, flux_map, psi_lcfs, wall_R, wall_Z, constraint_points_R, constraint_points_Z, divertor_regions=None, divertor_data=None, state_data=None, plot_field_lines=False, ax=None, show=False)[source]

Plot a single equilibrium state snapshot.

Parameters:
  • R_2D (2D arrays) – Meshgrid arrays.

  • Z_2D (2D arrays) – Meshgrid arrays.

  • flux_map (2D array) – The poloidal magnetic flux to contour.

  • psi_lcfs (float) – LCFS flux level.

  • wall_R (array-like) – Wall boundary.

  • wall_Z (array-like) – Wall boundary.

  • constraint_points_R (array-like) – Constraint point locations.

  • constraint_points_Z (array-like) – Constraint point locations.

  • divertor_regions (list of str, optional) – Names of divertor regions.

  • divertor_data (dict, optional) – Per-region data including field lines.

  • state_data (dict, optional) – Current state data containing "divertors".

  • plot_field_lines (bool) – Whether to overlay traced field lines.

  • ax (matplotlib Axes or None) – If None, a new figure is created.

  • show (bool) – If True, call plt.show(); otherwise return ax.

Returns:

ax (matplotlib Axes (only if *show is False)*)

forge.plotting.plot_currents_comparison_bar_chart(x_labels, initial_data, optimised_data, scale_kA=True)[source]

Bar chart comparing initial and optimised coil currents.

Parameters:
  • x_labels (list) – Coil names.

  • initial_data (list) – Initial per-turn coil currents (A).

  • optimised_data (list) – Optimised per-turn coil currents (A).

  • scale_kA (bool) – Display in kA if True, MA otherwise.

forge.plotting.plot_optimisation_summary(opt, show=True)[source]

Produce a multi-panel summary of a completed optimisation.

Generates four matplotlib figures:

  1. Equilibrium comparison — initial and optimised equilibria side by side with wall, separatrix, contours, coils, and traced field lines.

  2. Cost history — total cost and per-component breakdown vs iteration, plus connection length, temperature, and acceptance rate.

  3. Coil current comparison — grouped bar chart of initial vs optimised coil currents (kA).

  4. Flux decomposition — total, plasma, and machine flux for the optimised equilibrium.

Parameters:
  • opt (forge.optimise.Optimiser) – A completed Optimiser instance (after opt.optimise()).

  • show (bool) – If True (default) call plt.show() after creating all figures. Set to False to allow further customisation before displaying.