desc.plotting.plot_field_lines_sfl

desc.plotting.plot_field_lines_sfl(eq, rho, seed_thetas=0, phi_start=0, phi_end=6.283185307179586, dphi=0.01, ax=None, return_data=False, **kwargs)Source

Plots field lines on specified flux surface.

Traces field lines at specified initial vartheta (\(\\vartheta\)) seed locations, then plots them. Field lines traced by first finding the corresponding straight field line (SFL) coordinates \((\\rho,\\vartheta,\\phi)\) for each field line, then converting those to the computational \((\\rho,\\theta,\\phi)\) coordinates, then finally computing from those the toroidal \((R,\\phi,Z)\) coordinates of each field line.

The SFL angle coordinates are found with the SFL relation:

\(\\vartheta = \\iota \\phi + \\vartheta_0\)

Parameters:
  • eq (Equilibrium) – Object from which to plot.

  • rho (float) – Flux surface to trace field lines at.

  • seed_thetas (float or array-like of floats) – Poloidal positions at which to seed magnetic field lines. If array-like, will plot multiple field lines.

  • phi_start (float) – Toroidal angle to integrate field line from, in radians. Default is 0.

  • phi_end (float) – Toroidal angle to integrate field line until, in radians. Default is 2*pi.

  • dphi (float) – spacing in phi to sample field lines along, in radians. Default is 1e-2.

  • ax (matplotlib AxesSubplot, optional) – Axis to plot on. if True, return the data plotted as well as fig,ax

  • return_data (bool) – if True, return the data plotted as well as fig,ax

  • **kwargs (dict, optional) –

    Specify properties of the figure, axis, and plot appearance e.g.:

    plot_X(figsize=(4,6))
    

    Valid keyword arguments are:

    • figsize: tuple of length 2, the size of the figure (to be passed to matplotlib)

Returns:

  • fig (matplotlib.figure.Figure) – Figure being plotted to.

  • ax (matplotlib.axes.Axes or ndarray of Axes) – Axes being plotted to.

  • plot_data (dict) – dictionary of the data plotted, only returned if return_data=True

Examples

../../_images/DSHAPE_field_lines_plot.png
from desc.plotting import plot_field_lines_sfl
import desc.examples
import numpy as np
eq = desc.examples.get("DSHAPE")
seed_thetas=np.linspace(0, 2 * np.pi, 3,endpoint=False)
fig, ax, _ = plot_field_lines_sfl(
    eq, rho=1,seed_thetas=seed_thetas , phi_end=2 * np.pi
)