pyrokinetics.local_geometry.mxh.LocalGeometryMXH#
- class pyrokinetics.local_geometry.mxh.LocalGeometryMXH(*args, **kwargs)[source]#
Bases:
LocalGeometryLocal equilibrium representation defined as in: PPCF 63 (2021) 012001 (5pp)
Miller eXtended Harmonic (MXH)
\[\begin{split}\begin{align} R(r, \theta) &= R_{major}(r) + r \cos(\theta_R) \\ Z(r, \theta) &= Z_0(r) + r \kappa(r) \sin(\theta) \\ \theta_R &= \theta + c_0(r) + \sum_{n=1}^N [c_n(r) \cos(n \theta) + s_n(r) \sin(n \theta)] \\ r &= (\max(R) - \min(R)) / 2 \end{align}\end{split}\]Data stored in a ordered dictionary
- psi_n#
Normalised Psi
- Type:
Float
- rho#
r/a
- 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
- s_kappa#
Shear in Elongation \(r/\kappa \partial \kappa/\partial r\)
- Type:
Float
- shift#
Shafranov shift
- Type:
Float
- dZ0dr#
Shear in midplane elevation
- Type:
Float
- thetaR#
thetaR values at theta
- Type:
ArrayLike
- dthetaR_dtheta#
Derivative of thetaR w.r.t theta at theta
- Type:
ArrayLike
- dthetaR_dr#
Derivative of thetaR w.r.t r at theta
- Type:
ArrayLike
- cn#
cosine moments of thetaR
- Type:
ArrayLike
- sn#
sine moments of thetaR
- Type:
ArrayLike
- dcndr#
Shear in cosine moments \(\partial c_n/\partial r\)
- Type:
ArrayLike
- dsndr#
Shear in sine moments \(\partial s_n/\partial r\)
- Type:
ArrayLike
- 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, heta)\) and \(Z(r, heta)\) w.r.t \(r\) and :math:` heta`, used in B_poloidal calc
get_RZ_second_derivatives(theta)Calculates the second derivatives of \(R(r, heta)\) and \(Z(r, heta)\) w.r.t \(r\) and :math:` heta`, 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(thetaR, dthetaR_dr, ...)Calculate the second derivative of \(R(r, heta)\) w.r.t \(r\) and :math:` heta`
get_d2Rdtheta2(thetaR, dthetaR_dtheta, ...)Calculates the second derivative of \(R(r, heta)\) w.r.t :math:` heta`
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 :math:` heta`
get_d2thetaR_drdtheta(theta, dcndr, dsndr)get_d2thetaR_dtheta2(theta)get_dLdtheta(theta)Returns dLdtheta used in loop integrals
get_dRdr(shift, thetaR, dthetaR_dr)Calculates the derivatives of \(R(r, \theta)\) w.r.t \(r\)
get_dRdtheta(thetaR, dthetaR_dtheta)Calculates the derivatives of \(R(r, heta)\) w.r.t :math:` heta`
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_dthetaR_dr(theta, dcndr, dsndr)get_dthetaR_dtheta(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 MXH 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
get_thetaR(theta)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
Attributes
- property delta#
- from_local_geometry(local_geometry, verbose=False, show_fit=False, **kwargs)[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 MXH 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, heta)\) and \(Z(r, heta)\) w.r.t \(r\) and :math:` heta`, 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 = [shift, s_kappa, dZ0dr, cn[nmoments], sn[nmoments] ] when calculating derivatives, otherwise will use object attributes
- Return type:
- Returns:
dRdtheta (
Array) – Derivative of \(R\) w.r.t :math:` heta`dRdr (
Array) – Derivative of \(R\) w.r.t \(r\)dZdtheta (
Array) – Derivative of \(Z\) w.r.t :math:` heta`dZdr (
Array) – Derivative of \(Z\) w.r.t \(r\)
- get_RZ_second_derivatives(theta)[source]#
Calculates the second derivatives of \(R(r, heta)\) and \(Z(r, heta)\) w.r.t \(r\) and :math:` heta`, 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 :math:` heta`d2Rdrdtheta (
Array) – Second derivative of \(R\) w.r.t \(r\) and :math:` heta`d2Zdtheta2 (
Array) – Second derivative of \(Z\) w.r.t :math:` heta`d2Zdrdtheta (
Array) – Second derivative of \(Z\) w.r.t \(r\) and :math:` heta`
- get_d2Rdrdtheta(thetaR, dthetaR_dr, dthetaR_dtheta, d2thetaR_drdtheta)[source]#
Calculate the second derivative of \(R(r, heta)\) w.r.t \(r\) and :math:` heta`
- Parameters:
theta (
ArrayLike) – Array of theta points to evaluate dRdr onthetaR (
ArrayLike) – Array of thetaR points to evaluate dRdtheta ondthetaR_dr (
ArrayLike) – Radial derivative of thetaRdthetaR_dtheta (
ArrayLike) – Theta derivative of thetaRd2thetaR_drdtheta (
ArrayLike) – Second derivative of thetaR w.r.t \(r\) and :math:` heta`
- Returns:
d2Rdrdtheta – Second derivative of R w.r.t \(r\) and :math:` heta`
- Return type:
Array
- get_d2Rdtheta2(thetaR, dthetaR_dtheta, d2thetaR_dtheta2)[source]#
Calculates the second derivative of \(R(r, heta)\) w.r.t :math:` heta`
- Parameters:
thetaR (
ArrayLike) – Array of thetaR points to evaluate dRdtheta ondthetaR_dtheta (
ArrayLike) – Theta derivative of thetaRd2thetaR_dtheta2 (
ArrayLike) – Second theta derivative of thetaR-------
d2Rdtheta2 (
Array) – Second derivative of \(R\) w.r.t :math:` heta`
- 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 dZdr ons_kappa (
Float) – Shear in Elongation \(r/\kappa \partial \kappa/\partial r\)
- 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 :math:` heta`
- Parameters:
theta (
ArrayLike) – Array of theta points to evaluate dZdtheta on- Returns:
d2Zdtheta2 – Second derivative of \(Z\) w.r.t :math:` heta`
- Return type:
Array
- get_d2thetaR_drdtheta(theta, dcndr, dsndr)[source]#
- Parameters:
theta (
Array) – theta anglesdcndr (
Array) – Asymmetric coefficients in thetaRdsndr (
Array) – Symmetric coefficients in thetaR
- get_d2thetaR_dtheta2(theta)[source]#
- Parameters:
theta
- Returns:
d^2thetaR/dtheta^2 – second theta derivative of poloidal angle used in R
- Return type:
Array
- get_dRdr(shift, thetaR, dthetaR_dr)[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 shiftthetaR (
ArrayLike) – Array of thetaR points to evaluate dRdtheta ondthetaR_dr (
ArrayLike) – Radial derivative of thetaR
- Returns:
dRdr – Derivative of \(R\) w.r.t \(r\)
- Return type:
Array
- get_dRdtheta(thetaR, dthetaR_dtheta)[source]#
Calculates the derivatives of \(R(r, heta)\) w.r.t :math:` heta`
- Parameters:
thetaR (
ArrayLike) – Array of thetaR points to evaluate dRdtheta ondthetaR_dtheta (
ArrayLike) – Theta derivative of thetaR-------
dRdtheta (
Array) – Derivative of \(R\) w.r.t :math:` heta`
- 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 ondZ0dr (
Float) – Derivative in midplane elevations_kappa (
Float) – Shear in Elongation \(r/\kappa \partial \kappa/\partial r\)
- 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_dthetaR_dr(theta, dcndr, dsndr)[source]#
- Parameters:
theta (
Array) – theta anglesdcndr (
Array) – Asymmetric coefficients in thetaRdsndr (
Array) – Symmetric coefficients in thetaR
- get_dthetaR_dtheta(theta)[source]#
- Parameters:
theta
- Returns:
dthetaR/dtheta – theta derivative of poloidal angle used in R
- Return type:
Array
- get_thetaR(theta)[source]#
- Parameters:
theta (
Array)- Returns:
thetaR – Poloidal angle used in definition of R
- Return type:
Array
- property n#
- property n_moments#
- property s_delta#
- property s_zeta#
- property zeta#