pyrokinetics.local_geometry.miller.LocalGeometryMiller#

class pyrokinetics.local_geometry.miller.LocalGeometryMiller(*args, **kwargs)[source]#

Bases: LocalGeometry

Local equilibrium representation defined as in: Phys Plasmas, Vol 5, No 4, April 1998 Miller et al

\[\begin{split}\begin{align} R_s(r, \theta) &= R_0(r) + r \cos[\theta + (\sin^{-1}\delta) \sin(\theta)] \\ Z_s(r, \theta) &= Z_0(r) + r \kappa \sin(\theta) \\ r &= (\max(R) - \min(R)) / 2 \end{align}\end{split}\]

Data stored in a CleverDict Object

psi_n#

Normalised poloidal flux \(\psi_n=\psi_{surface}/\psi_{LCFS}\)

Type:

Float

rho#

Minor radius \(\rho=r/a\)

Type:

Float

a_minor#

Minor radius [m] \(a\) (if 2D equilibrium exists)

Type:

Float

Rmaj#

Normalised major radius \(R_{maj}/a\)

Type:

Float

Z0#

Normalised vertical position of midpoint (Zmid / a_minor)

Type:

Float

f_psi#

Torodial field function

Type:

Float

B0#

Normalising magnetic field \(B_0 = f / R_{maj}\) [T]

Type:

Float

bunit_over_b0#

Ratio of GACODE normalising field to B0 \(B_{unit} = \frac{q}{r}\frac{\partial\psi}{\partial r}\) [T]

Type:

Float

dpsidr#

\(\frac{\partial \psi}{\partial r}\)

Type:

Float

q#

Safety factor \(q\)

Type:

Float

shat#

Magnetic shear \(\hat{s} = \frac{\rho}{q}\frac{\partial q}{\partial\rho}\)

Type:

Float

beta_prime#

Pressure gradient \(\beta'=\frac{8\pi 10^{-7}}{B_0^2} \frac{\partial p}{\partial\rho}\)

Type:

Float

kappa#

Elongation \(\kappa\)

Type:

Float

delta#

Triangularity \(\delta\)

Type:

Float

s_kappa#

Shear in Elongation \(\frac{\rho}{\kappa} \frac{\partial\kappa}{\partial\rho}\)

Type:

Float

s_delta#

Shear in Triangularity \(\frac{\rho}{\sqrt{1-\delta^2}} \frac{\partial\delta}{\partial\rho}\)

Type:

Float

shift#

Shafranov shift \(\Delta = \frac{\partial R_{maj}}{\partial r}\)

Type:

Float

dZ0dr#

Shear in midplane elevation

Type:

Float

R_eq#

Equilibrium R data used for fitting

Type:

Array

Z_eq#

Equilibrium Z data used for fitting

Type:

Array

b_poloidal_eq#

Equilibrium B_poloidal data used for fitting

Type:

Array

theta_eq#

theta values for equilibrium data

Type:

Float

R#

Fitted R data

Type:

Array

Z#

Fitted Z data

Type:

Array

b_poloidal#

Fitted B_poloidal data

Type:

Array

theta#

Fitted theta data

Type:

Float

dRdtheta#

Derivative of fitted \(R\) w.r.t \(\theta\)

Type:

Array

dRdr#

Derivative of fitted \(R\) w.r.t \(r\)

Type:

Array

dZdtheta#

Derivative of fitted \(Z\) w.r.t \(\theta\)

Type:

Array

dZdr#

Derivative of fitted \(Z\) w.r.t \(r\)

Type:

Array

d2Rdtheta2#

Second derivative of fitted \(R\) w.r.t \(\theta\)

Type:

Array

d2Rdrdtheta#

Derivative of fitted \(R\) w.r.t \(r\) and \(\theta\)

Type:

Array

d2Zdtheta2#

Second derivative of fitted \(Z\) w.r.t \(\theta\)

Type:

Array

d2Zdrdtheta#

Derivative of fitted \(Z\) w.r.t \(r\) and \(\theta\)

Type:

Array

__init__(*args, **kwargs)[source]#

Methods

__init__(*args, **kwargs)

convert_physical_units(norms)

Convert physical-unit attributes to generic simulation units of norms.

default()

Default parameters for geometry Same as GA-STD case

from_gk_data(params)

Initialise from data gathered from GKCode object, and additionally set bunit_over_b0

from_global_eq(eq, psi_n, norms[, show_fit, ...])

Loads LocalGeometry object from an Equilibrium Object

from_local_geometry(local_geometry[, ...])

Loads LocalGeometry object of one type from a LocalGeometry Object of a different type

get_RZ_derivatives(theta[, params])

Calculates the derivatives of \(R(r, \theta)\) and \(Z(r, \theta)\) w.r.t \(r\) and \(\theta\), used in B_poloidal calc

get_RZ_second_derivatives(theta)

Calculates the second derivatives of \(R(r, \theta)\) and \(Z(r, \theta)\) w.r.t \(r\) and \(\theta\), used in geometry terms

get_b_poloidal(theta[, params])

Returns Miller prediction for get_b_poloidal given flux surface parameters

get_bunit_over_b0()

Get Bunit/B0 using q and loop integral of Bp

get_d2Rdrdtheta(theta, s_delta)

Calculate the second derivative of \(R(r, \theta)\) w.r.t \(r\) and \(\theta\)

get_d2Rdtheta2(theta)

Calculate the second derivative of \(R(r, \theta)\) w.r.t \(\theta\)

get_d2Zdrdtheta(theta, s_kappa)

Calculates the second derivative of \(Z(r, \theta)\) w.r.t \(r\) and \(\theta\)

get_d2Zdtheta2(theta)

Calculates the second derivative of \(Z(r, theta)\) w.r.t \(\theta\)

get_dLdtheta(theta)

Returns dLdtheta used in loop integrals

get_dRdr(theta, shift, s_delta)

Calculates the derivatives of \(R(r, \theta)\) w.r.t \(r\)

get_dRdtheta(theta)

Calculates the derivatives of \(R(r, \theta)\) w.r.t \(\theta\)

get_dZdr(theta, dZ0dr, s_kappa)

Calculates the derivatives of \(Z(r, \theta)\) w.r.t \(r\)

get_dZdtheta(theta)

Calculates the derivatives of \(Z(r, theta)\) w.r.t \(\theta\)

get_f_prime([ntheta])

Calculate F' from and other geometry terms

get_f_psi()

Calculate safety factor from b poloidal field, R, Z and q \(f = \frac{2\pi q}{\oint \frac{dl}{R^2 B_{\theta}}}\)

get_flux_surface(theta)

Generates \((R,Z)\) of a flux surface given a set of Miller fits

get_flux_surface_area_volume()

Calculate the poloidal and toroidal area of the flux surface and the toroidal volume in units of lref

get_flux_surface_area_volume_derivatives()

Calculate the derivative of the poloidal and toroidal area of the flux surface and the toroidal volume with respect to r

get_grad_r(theta[, params])

MXH definition of grad r from MXH, R.

get_s_hat([Fprime, ntheta])

Calculate magnetic shear from F' and other geometry terms

keys()

minimise_b_poloidal(params[, even_space_theta])

Function for least squares minimisation of poloidal field

normalise(norms[, context])

Convert LocalGeometry Parameters to current NormalisationConvention Note this creates the attribute unit_mapping which is used to apply units to the LocalGeometry object :type norms: :param norms: Normalisation convention to convert to :type norms: SimulationNormalisation

plot_equilibrium_to_local_geometry_fit([...])

test_safety_factor()

Calculate safety factor from LocalGeometry object b poloidal field \(q = \frac{1}{2\pi} \oint \frac{f dl}{R^2 B_{\theta}}\)

to(norms[, context])

Thin wrapper for normalise

default()[source]#

Default parameters for geometry Same as GA-STD case

get_RZ_derivatives(theta, params=None)[source]#

Calculates the derivatives of \(R(r, \theta)\) and \(Z(r, \theta)\) w.r.t \(r\) and \(\theta\), used in B_poloidal calc

Parameters:
  • theta (ArrayLike) – Array of theta points to evaluate grad_r on

  • params (Array [Optional]) – If given then will use params = [s_kappa_fit, s_delta_fit, shift_fit, dZ0dr_fit] when calculating derivatives, otherwise will use object attributes

Return type:

ndarray

Returns:

  • dRdtheta (Array) – Derivative of \(R\) w.r.t \(\theta\)

  • dRdr (Array) – Derivative of \(R\) w.r.t \(r\)

  • dZdtheta (Array) – Derivative of \(Z\) w.r.t \(\theta\)

  • dZdr (Array) – Derivative of \(Z\) w.r.t \(r\)

get_RZ_second_derivatives(theta)[source]#

Calculates the second derivatives of \(R(r, \theta)\) and \(Z(r, \theta)\) w.r.t \(r\) and \(\theta\), used in geometry terms

Parameters:

theta (ArrayLike) – Array of theta points to evaluate grad_r on

Return type:

ndarray

Returns:

  • d2Rdtheta2 (Array) – Second derivative of \(R\) w.r.t \(\theta\)

  • d2Rdrdtheta (Array) – Second derivative of \(R\) w.r.t \(r\) and \(\theta\)

  • d2Zdtheta2 (Array) – Second derivative of \(Z\) w.r.t \(\theta\)

  • d2Zdrdtheta (Array) – Second derivative of \(Z\) w.r.t \(r\) and \(\theta\)

get_d2Rdrdtheta(theta, s_delta)[source]#

Calculate the second derivative of \(R(r, \theta)\) w.r.t \(r\) and \(\theta\)

Parameters:
  • theta (ArrayLike) – Array of theta points to evaluate d2Rdrdtheta on

  • s_delta (Float) – Shear in Triangularity

Returns:

d2Rdrdtheta – Second derivative of \(R\) w.r.t \(r\) and \(\theta\)

Return type:

Array

get_d2Rdtheta2(theta)[source]#

Calculate the second derivative of \(R(r, \theta)\) w.r.t \(\theta\)

Parameters:

theta (ArrayLike) – Array of theta points to evaluate d2Rdtheta2 on

Returns:

d2Rdtheta2 – Second derivative of \(R\) w.r.t \(\theta\)

Return type:

Array

get_d2Zdrdtheta(theta, s_kappa)[source]#

Calculates the second derivative of \(Z(r, \theta)\) w.r.t \(r\) and \(\theta\)

Parameters:
  • theta (ArrayLike) – Array of theta points to evaluate d2Zdrdtheta on

  • s_kappa (Float) – Shear in Elongation

Returns:

d2Zdrdtheta – Second derivative of \(Z\) w.r.t \(r\) and \(\theta\)

Return type:

Array

get_d2Zdtheta2(theta)[source]#

Calculates the second derivative of \(Z(r, theta)\) w.r.t \(\theta\)

Parameters:

theta (ArrayLike) – Array of theta points to evaluate d2Zdtheta2 on

Returns:

d2Zdtheta2 – Second derivative of \(Z\) w.r.t \(\theta\)

Return type:

Array

get_dRdr(theta, shift, s_delta)[source]#

Calculates the derivatives of \(R(r, \theta)\) w.r.t \(r\)

Parameters:
  • theta (ArrayLike) – Array of theta points to evaluate dRdr on

  • shift (Float) – Shafranov shift

  • s_delta (Float) – Shear in Triangularity

Returns:

dRdr – Derivative of \(R\) w.r.t \(r\)

Return type:

Array

get_dRdtheta(theta)[source]#

Calculates the derivatives of \(R(r, \theta)\) w.r.t \(\theta\)

Parameters:

theta (ArrayLike) – Array of theta points to evaluate dRdtheta on

Returns:

dRdtheta – Derivative of \(R\) w.r.t \(\theta\)

Return type:

Array

get_dZdr(theta, dZ0dr, s_kappa)[source]#

Calculates the derivatives of \(Z(r, \theta)\) w.r.t \(r\)

Parameters:
  • theta (ArrayLike) – Array of theta points to evaluate dZdr on

  • dZ0dr (Float) – Shear in midplane elevation

  • s_kappa (Float) – Shear in Elongation

Returns:

dZdr – Derivative of \(Z\) w.r.t \(r\)

Return type:

Array

get_dZdtheta(theta)[source]#

Calculates the derivatives of \(Z(r, theta)\) w.r.t \(\theta\)

Parameters:

theta (ArrayLike) – Array of theta points to evaluate dZdtheta on

Returns:

dZdtheta – Derivative of \(Z\) w.r.t \(\theta\)

Return type:

Array

get_flux_surface(theta)[source]#

Generates \((R,Z)\) of a flux surface given a set of Miller fits

Parameters:

theta (Array) – Values of theta to evaluate flux surface

Return type:

Tuple[ndarray, ndarray]

Returns:

  • :math:`R` (Array) – \(R(\theta)\) values for this flux surface (if not normalised then in [m])

  • :math:`Z` (Array) – \(Z(\theta)\) Values for this flux surface (if not normalised then in [m])