Skip to content

NcBfield

dexter.NcBfield(path: str, interp_type: Interp2DType, *, padding: int = 15)

Numerical magnetic field profile reconstructed from a netCDF file.

Related quantities are computed by interpolating over the data arrays.

\(\theta\) padding

At the grid edges, the interpolator’s higher derivatives are not well defined. By left-right padding the \(B\) array with extra \(\theta=const\) columns, we force the interpolator to take \(\theta\)’s periodicity into account and therefore calculate the correct derivative values.

Note that in contrast to the one-dimensional cubic spline, in a bicubic interpolation 3 columns are not enough to ensure periodicity, since the spline coefficients depend on the values of the whole array.

According to this stack overflow thread, the effect of the \(i\)-th column at the \(j\)-th column of the spline goes as \(r^{|i-j|}\), where \(r=\sqrt{3}-2 \approx -0.26\). Therefore, with a padding of 10, the effect at the \(\theta=0\) boundary would be of the order of \(1^{-6}\).

Parameters:

  • path (str) –

    The path to the NetCDF file.

  • interp_type (Interp2DType) –

    The type of 2D Interpolation.

  • padding (int, default: 15 ) –

    The left-right \(\theta\) (per-side) padding width. Defaults to 15.

Example
NcBfield creation
>>> bfield = dex.NcBfield(path, "Bicubic")

Methods:

  • b_of_psi

    The \(B(\psi, \theta)\) value in Normalized Units.

  • b_of_psip

    The \(B(\psi_p, \theta)\) value in Normalized Units.

  • db_dpsi

    The \(dB(\psi, \theta)/d\psi\) value in Normalized Units.

  • db_dpsip

    The \(dB(\psi_p, \theta)/d\psi_p\) value in Normalized Units.

  • db_of_psi_dtheta

    The \(dB(\psi, \theta)/d\theta\) value in Normalized Units.

  • db_of_psip_dtheta

    The \(dB(\psi_p, \theta)/d\theta\) value in Normalized Units.

Attributes:

dexter.NcBfield.psi_state: FluxState property

The state of the toroidal flux coordinate.

dexter.NcBfield.psip_state: FluxState property

The state of the poloidal flux coordinate.

dexter.NcBfield.path: str property

The path of the netCDF file.

dexter.NcBfield.netcdf_version: NetCDFVersion property

The netCDF convention version (SemVer).

dexter.NcBfield.equilibrium_type: EquilibriumType property

The object's equilibrium's type.

dexter.NcBfield.interp_type: str property

The Interpolation type.

dexter.NcBfield.baxis: float property

The magnetic field strength on the magnetic axis \(B_0\) in \([T]\).

dexter.NcBfield.padding: int property

The left-right \(\theta\) (per side) padding width.

dexter.NcBfield.shape: ArrayShape property

The shape of the 2 dimensional data arrays, as in \((len(\psi/\psi_p), len(\theta))\).

If both coordinates are “good”, they are guaranteed to be of the same length.

dexter.NcBfield.shape_padded: ArrayShape property

The shape of the 2 dimensional padded data arrays, as in \((len(\psi/\psi_p), len(\theta))\).

If both coordinates are “good”, they are guaranteed to be of the same length.

dexter.NcBfield.psi_last: float property

The value of the last closed toroidal flux surface \(\psi_{LCFS}\) in Normalized Units.

dexter.NcBfield.psip_last: float property

The value of the last closed poloidal flux surface \(\psi_{p,LCFS}\) in Normalized Units.

dexter.NcBfield.psi_array: Array1 property

The NetCDF \(\psi\) data.

dexter.NcBfield.psip_array: Array1 property

The NetCDF \(\psi_p\) data.

dexter.NcBfield.theta_array: Array1 property

The NetCDF \(\theta\) data.

dexter.NcBfield.b_array: Array2 property

The NetCDF \(g\) data.

dexter.NcBfield.theta_array_padded: Array1 property

The padded \(\theta\) data.

dexter.NcBfield.b_array_padded: Array2 property

The padded \(B\) data.

dexter.NcBfield.b_of_psi(psi: ArrayLike, theta: ArrayLike) -> NDArray

The \(B(\psi, \theta)\) value in Normalized Units.

Parameters:

  • psi (ArrayLike) –

    The toroidal flux \(\psi\) in Normalized Units.

  • theta (ArrayLike) –

    The \(\theta\) angle in \([rads]\).

dexter.NcBfield.b_of_psip(psip: ArrayLike, theta: ArrayLike) -> NDArray

The \(B(\psi_p, \theta)\) value in Normalized Units.

Parameters:

  • psip (ArrayLike) –

    The poloidal flux \(\psi_p\) in Normalized Units.

  • theta (ArrayLike) –

    The \(\theta\) angle in \([rads]\).

dexter.NcBfield.db_dpsi(psi: ArrayLike, theta: ArrayLike) -> NDArray

The \(dB(\psi, \theta)/d\psi\) value in Normalized Units.

Parameters:

  • psi (ArrayLike) –

    The toroidal flux \(\psi\) in Normalized Units.

  • theta (ArrayLike) –

    The \(\theta\) angle in \([rads]\).

dexter.NcBfield.db_dpsip(psip: ArrayLike, theta: ArrayLike) -> NDArray

The \(dB(\psi_p, \theta)/d\psi_p\) value in Normalized Units.

Parameters:

  • psip (ArrayLike) –

    The poloidal flux \(\psi_p\) in Normalized Units.

  • theta (ArrayLike) –

    The \(\theta\) angle in \([rads]\).

dexter.NcBfield.db_of_psi_dtheta(psi: ArrayLike, theta: ArrayLike) -> NDArray

The \(dB(\psi, \theta)/d\theta\) value in Normalized Units.

Parameters:

  • psi (ArrayLike) –

    The toroidal flux \(\psi\) in Normalized Units.

  • theta (ArrayLike) –

    The \(\theta\) angle in \([rads]\).

dexter.NcBfield.db_of_psip_dtheta(psip: ArrayLike, theta: ArrayLike) -> NDArray

The \(dB(\psi_p, \theta)/d\theta\) value in Normalized Units.

Parameters:

  • psip (ArrayLike) –

    The poloidal flux \(\psi_p\) in Normalized Units.

  • theta (ArrayLike) –

    The \(\theta\) angle in \([rads]\).