spectre.converters.compare_vmec_spectre ======================================= .. py:module:: spectre.converters.compare_vmec_spectre .. autoapi-nested-parse:: Comparison plots: VMEC continuous profiles vs SPECTRE discretised values. Module Contents --------------- .. py:function:: plot_pressure_comparison(ax, pressure, tfluxes, pressure_spectre) Overlay VMEC continuous pressure and SPECTRE volume-averaged pressure. Both curves are in SPECTRE's internal (mu0-scaled) pressure units: the continuous VMEC profile as a line, the SPECTRE values as horizontal segments spanning each volume. Args: ax: matplotlib ``Axes`` to draw into. pressure: callable ``pressure(s)`` in SPECTRE units (mu0-scaled). tfluxes: 1-D array of interface toroidal-flux values. pressure_spectre: 1-D array of mu0*

per volume from SPECTRE. .. py:function:: plot_iota_comparison(ax, iota, tfluxes, iota_spectre=None) Overlay VMEC continuous iota and optionally the SPECTRE interface values. Args: ax: matplotlib ``Axes`` to draw into. iota: callable ``iota(s)`` returning the VMEC rotational transform. tfluxes: 1-D array of interface toroidal-flux values. iota_spectre: 1-D array of iota values at interfaces from SPECTRE; omit to show only the VMEC profile (e.g. for current equilibria). .. py:function:: plot_current_comparison(ax, current_density, tfluxes, enclosed_spectre=None) Overlay the VMEC and SPECTRE *enclosed* toroidal current vs flux. Plots the normalised cumulative integral of the VMEC current-density profile (the enclosed current Î(s) ∈ [0, 1]) and, when given, the SPECTRE enclosed current — the combined contribution of the volume (``ivolume``) and sheet (``isurf``) representations, ``ivolume + cumsum(isurf)`` — normalised by its boundary value so the two curves are directly comparable. Args: ax: matplotlib ``Axes`` to draw into. current_density: callable ``j(s) = dI/ds`` for the VMEC current profile. tfluxes: 1-D array of interface toroidal-flux values. enclosed_spectre: 1-D array of SPECTRE enclosed current per interface (``ivolume + cumsum(isurf)``); omit to show only the VMEC profile (e.g. for iota equilibria). .. py:function:: compare_vmec_spectre(vmec, spectre_params) Three-panel comparison of VMEC profiles vs SPECTRE discretised values. Produces a figure with three subplots — pressure, rotational transform, and toroidal current — by calling the three individual plot functions. The VMEC continuous profiles are read directly from the simsopt object; the SPECTRE discretised values are extracted from the pydantic :class:`~spectre.file_io.input_parameters.InputParameters`. The current mode (volume or sheet) is determined automatically from the InputParameters. Args: vmec: simsopt ``Vmec`` object (loaded from either an input file or a wout netCDF file). spectre_params: :class:`~spectre.file_io.input_parameters.InputParameters` returned by :func:`~spectre.converters.simsvmec2spectre`. Returns: Tuple ``(fig, axes)`` — matplotlib figure and array of 3 axes.