pyrokinetics.local_geometry.miller_turnbull.LocalGeometryMillerTurnbull#
- class pyrokinetics.local_geometry.miller_turnbull.LocalGeometryMillerTurnbull(*args, **kwargs)[source]#
Bases:
LocalGeometryLocal equilibrium representation defined as in:
\[\begin{split}\begin{align} R(r, \theta) &= R_{major}(r) + r \cos(\theta + \arcsin(\delta(r) \sin(\theta)) \\ Z(r, \theta) &= Z_0(r) + r \kappa(r) \sin(\theta + \zeta(r) \sin(2\theta)) \\ r &= (\max(R) - \min(R)) / 2 \end{align}\end{split}\]Data stored in a CleverDict Object
- psi_n#
Normalised Psi
- Type:
Float
- rho#
r/a
- Type:
Float
- r_minor#
Minor radius of flux surface
- Type:
Float
- a_minor#
Minor radius of LCFS [m]
- Type:
Float
- Rmaj#
Normalised Major radius (Rmajor/a_minor)
- Type:
Float
- Z0#
Normalised vertical position of midpoint (Zmid / a_minor)
- Type:
Float
- f_psi#
Torodial field function
- Type:
Float
- B0#
Toroidal field at major radius (Fpsi / Rmajor) [T]
- Type:
Float
- bunit_over_b0#
Ratio of GACODE normalising field = \(q/r \partial \psi/\partial r\) [T] to B0
- Type:
Float
- dpsidr#
\(\frac{\partial \psi}{\partial r}\)
- Type:
Float
- q#
Safety factor
- Type:
Float
- shat#
Magnetic shear \(r/q \partial q/ \partial r\)
- Type:
Float
- beta_prime#
\(\beta = 2 \mu_0 \partial p \partial \rho 1/B0^2\)
- Type:
Float
- kappa#
Elongation
- Type:
Float
- delta#
Triangularity
- Type:
Float
- zeta#
Squareness
- Type:
Float
- s_kappa#
Shear in Elongation \(r/\kappa \partial \kappa/\partial r\)
- Type:
Float
- s_delta#
Shear in Triangularity \(r/\sqrt{1 - \delta^2} \partial \delta/\partial r\)
- Type:
Float
- s_zeta#
Shear in Squareness \(r/ \partial \zeta/\partial r\)
- Type:
Float
- shift#
Shafranov shift
- 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
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, s_zeta)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, s_zeta)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 MillerTurnbull 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:
SimulationNormalisationplot_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
- from_local_geometry(local_geometry, verbose=False, show_fit=False)[source]#
Loads LocalGeometry object of one type from a LocalGeometry Object of a different type
Miller is a special case which is a subset of MillerTurnbull so we can directly set values :type local_geometry: :param local_geometry: LocalGeometry object :type local_geometry:
LocalGeometry:type verbose: :param verbose: Controls verbosity :type verbose:Boolean
- 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 onparams (
Array [Optional]) – If given then will use params = [s_kappa_fit,s_delta_fit,s_zeta_fit, shift_fit,dZ0dr_fit] when calculating derivatives, otherwise will use object attributesnormalised (
Boolean) – Control whether or not to return normalised values
- Return type:
- 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:
- 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 ons_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, s_zeta)[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 ons_kappa (
Float) – Shear in Elongations_zeta (
Float) – Shear in Squareness
- 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 onshift (
Float) – Shafranov shifts_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, s_zeta)[source]#
Calculates the derivatives of \(Z(r, \theta)\) w.r.t \(r\)
- Parameters:
theta (
ArrayLike) – Array of theta points to evaluate dZdr ondZ0dr (
Float) – Shear in midplane elevations_kappa (
Float) – Shear in Elongations_zeta (
Float) – Shear in Squareness
- 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 MillerTurnbull fits
- Parameters:
theta (
Array) – Values of theta to evaluate flux surfacenormalised (
Boolean) – Control whether or not to return normalised flux surface
- Return type:
- 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])