pyrokinetics.equilibrium.flux_surface.FluxSurface#

class pyrokinetics.equilibrium.flux_surface.FluxSurface(R, Z, B_poloidal, R_major, r_minor, Z_mid, F, FF_prime, p, q, magnetic_shear, shafranov_shift, midplane_shift, pressure_gradient, psi_gradient, a_minor)[source]#

Bases: DatasetWrapper

Information about a single flux surface of a tokamak plasma equilibrium. Users are not expected to initialise FluxSurface objects directly, but instead should generate them from Equilibrium objects. FluxSurface is used as an intermediate object when generating LocalGeometry objects from global plasma equilibria. For more information, see the ‘Notes’ section for Equilibrium.

Parameters:
  • R (ArrayLike, units [meter]) – 1D grid of major radius coordinates describing the path of the flux surface. The endpoints should be repead.

  • Z (ArrayLike, units [meter]) – 1D grid of tokamak Z-coordinates describing the path of the flux surface. This is usually the height above the plasma midplane, but Z=0 may be set at any reference point. Should have same length as R, and the endpoints should be repeated.

  • B_poloidal (ArrayLike, units [tesla]) – 1D grid of the magnitude of the poloidal magnetic field following the path described by R and Z. Should have the same length as R.

  • R_major (float, units [meter]) – The major radius position of the center of each flux surface. This should be given by the mean of the maximum and minimum major radii of the flux surface.

  • r_minor (float, units [meter]) – The minor radius of the flux surface. This should be half of the difference between the maximum and minimum major radii of the flux surface.

  • Z_mid (float, units [meter]) – The z-midpoint of the flux surface. This should be the mean of the maximum and minimum z-positions of the flux surface.

  • F (float, units [meter * tesla]) – The poloidal current function.

  • FF_prime (float, units [meter**2 * tesla**2 / weber]) – 1D grid defining the poloidal current function f multiplied by its derivative with respect to psi. Should have the same length as psi.

  • p (float, units [pascal]) – Plasma pressure.

  • q (float, units [dimensionless]) – The safety factor.

  • magnetic_shear (float, units [dimensionless]) – Defined as \(\frac{r}{q}\frac{dq}{dr}\), where \(r\) is the minor radius and \(q\) is the safety factor.

  • shafranov_shift (float, units [dimensionless]) – The derivative of R_major with respect to r_minor

  • midplane_shift (float, units [dimensionless]) – The derivative of Z_mid with respect to r_minor

  • pressure_gradient (float, units [pascal / meter]) – The derivative of pressure with respect to r_minor.

  • psi_gradient (float, units [weber / meter]) – The derivative of the poloidal magnetic flux function \(\psi\) with respect to r_minor.

  • a_minor (float, units [meter]) – The minor radius of the last closed flux surface (LCFS). Though not necessarily applicable to this flux surface, a_minor is often used as a reference length in gyrokinetic simulations.

data#

The internal representation of the FluxSurface object. The function __getitem__ redirects indexing lookups here, but the Dataset itself may be accessed directly by the user if they wish to perform more complex actions.

Type:

xarray.Dataset

rho#
Type:

float, units [dimensionless]

R_major#
Type:

float, units [meter]

r_minor#
Type:

float, units [meter]

Z_mid#
Type:

float, units [meter]

F#
Type:

float, units [meter * tesla]

FF_prime#
Type:

float, units [meter**2 * tesla**2 / weber]

p#
Type:

float, units [pascal]

q#
Type:

float, units [dimensionless]

magnetic_shear#
Type:

float, units [dimensionless]

shafranov_shift#
Type:

float, units [dimensionless]

midplane_shift#
Type:

float, units [dimensionless]

pressure_gradient#
Type:

float, units [pascal / meter]

psi_gradient#
Type:

float, units [weber / meter]

a_minor#
Type:

float, units [meter]

See also

Equilibrium

Object representing a global equilibrium.

__init__(R, Z, B_poloidal, R_major, r_minor, Z_mid, F, FF_prime, p, q, magnetic_shear, shafranov_shift, midplane_shift, pressure_gradient, psi_gradient, a_minor)[source]#
Parameters:

Methods

__init__(R, Z, B_poloidal, R_major, r_minor, ...)

from_netcdf(path, *args[, ...])

Initialise self.data from a netCDF file.

plot(quantity[, ax, show, x_label, y_label])

Plot a quantity defined on the \(\theta\) grid.

plot_path([ax, aspect, show, x_label, y_label])

Plot the path of the flux surface in \((R, Z)\) coordinates.

to_netcdf(*args, **kwargs)

Writes self.data to disk.

Attributes

attrs

Redirects to underlying Xarray Dataset attrs.

coords

Redirects to underlying Xarray Dataset coords.

data

Property for managing the underlying Xarray Dataset.

data_vars

Redirects to underlying Xarray Dataset data_vars.

dims

Redirects to underlying Xarray Dataset dims.

sizes

Redirects to underlying Xarray Dataset sizes.

plot(quantity, ax=None, show=False, x_label=None, y_label=None, **kwargs)[source]#

Plot a quantity defined on the \(\theta\) grid. These include R, Z, and B_poloidal.

Parameters:
  • quantity (str) – Name of the quantity to plot. Must be defined over the grid theta.

  • ax (Optional[plt.Axes]) – Axes object on which to plot. If not provided, a new figure is created.

  • show (bool, default False) – Immediately show Figure after creation.

  • x_label (Optional[str], default None) – Overwrite the default x label. Set to an empty string "" to disable.

  • y_label (Optional[str], default None) – Overwrite the default y label. Set to an empty string "" to disable.

  • **kwargs – Additional arguments to pass to Matplotlib’s plot call.

Returns:

The Axes object created after plotting.

Return type:

plt.Axes

Raises:

ValueError – If quantity is not a quantity defined over the \(\theta\) grid, or is not the name of a FluxSurface quantity.

plot_path(ax=None, aspect=False, show=False, x_label=None, y_label=None, **kwargs)[source]#

Plot the path of the flux surface in \((R, Z)\) coordinates.

Parameters:
  • ax (Optional[plt.Axes]) – Axes object on which to plot. If not provided, a new figure is created.

  • aspect (bool, default False) – If True, ensures the axes have the correct aspect ratio. If the user supplies their own ax, has no effect.

  • show (bool, default False) – Immediately show Figure after creation.

  • x_label (Optional[str], default None) – Overwrite the default x label. Set to an empty string "" to disable.

  • y_label (Optional[str], default None) – Overwrite the default y label. Set to an empty string "" to disable.

  • **kwargs – Additional arguments to pass to Matplotlib’s plot call.

Returns:

The Axes object created after plotting.

Return type:

plt.Axes