pyrokinetics.local_geometry.local_geometry.LocalGeometry#

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

Bases: object

General geometry Object representing local LocalGeometry fit parameters

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#

\(\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

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

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

Methods

__init__(*args, **kwargs)

convert_physical_units(norms)

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

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(**kwargs)

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_dLdtheta(theta)

Returns dLdtheta used in loop integrals

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_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

convert_physical_units(norms)[source]#

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

classmethod from_gk_data(params)[source]#

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

Parameters:

params (Dict[str, Any])

from_global_eq(eq, psi_n, norms, show_fit=False, surface_interps=False, **kwargs)[source]#

Loads LocalGeometry object from an Equilibrium Object

Parameters:
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

Gradients in shaping parameters are fitted from poloidal field

Parameters:
  • local_geometry (LocalGeometry) – LocalGeometry object

  • verbose (Boolean) – Controls verbosity

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

Returns Miller prediction for get_b_poloidal given flux surface parameters

Parameters:
  • params (List) – List with LocalGeometry type specific values

  • theta (numpy.typing.ArrayLike)

Returns:

local_geometry_b_poloidal – Array of get_b_poloidal from Miller fit

Return type:

Array

get_bunit_over_b0()[source]#

Get Bunit/B0 using q and loop integral of Bp

\(\frac{B_{unit}}{B_0} = \frac{R_0}{2\pi r_{minor}} \oint \frac{a}{R} \frac{dl_N}{\nabla r}\)

where \(dl_N = \frac{dl}{a_{minor}}\) coming from the normalising a_minor

See eqn 97 in Candy Plasma Phys. Control. Fusion 51 (2009) 105009

Returns:

bunit_over_b0\(\frac{B_{unit}}{B_0}\)

Return type:

Float

get_dLdtheta(theta)[source]#

Returns dLdtheta used in loop integrals

See eqn 93 in Candy Plasma Phys. Control. Fusion 51 (2009) 105009

Parameters:

theta (ArrayLike) – Poloidal angle to evaluate at

Returns:

dLdtheta

Return type:

Poloidal derivative of Arclength

get_f_prime(ntheta=1024)[source]#

Calculate F’ from and other geometry terms

See eqn 45/46 in Dudding Geometry Paper

Returns:

Fprime – Prediction for \(F'\) given a LocalGeometry’

Return type:

Float

get_f_psi()[source]#

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

See eqn 97 in Candy Plasma Phys. Control. Fusion 51 (2009) 105009

Returns:

f – Prediction for \(f_\psi\) from B_poloidal

Return type:

Float

get_flux_surface_area_volume()[source]#

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

\(A_{toroidal} = 2\pi \int_0^{2\pi} R\frac{\partial L}{\partial \theta} d\theta\)

\(A_{poloidal} = \int_0^{2\pi} R\frac{\partial Z}{\partial \theta} d\theta\)

\(V_{toroidal} = \pi \ int_0^{2\pi} R^2\frac{\partial Z}{\partial \theta} d\theta\)

Returns:

  • poloidal_area (float, units [lref**2]) – Calculation of the poloidal surface area \(A_{poloidal}\)

  • toroidal_area (float, units [lref**2]) – Calculation of the toroidal surface area \(A_{toroidal}\)

  • toroidal_volume (float, units [lref**3]) – Calculation of the poloidal volume \(V_{toroidal}\)

get_flux_surface_area_volume_derivatives()[source]#

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

\(\frac{\partial A_{toroidal}}{\partial r} = 2\pi \int_0^{2\pi} R\frac{\partial L}{\partial \theta} d\theta\)

\(\frac{\partial A_{poloidal}}{\partial r} = \int_0^{2\pi} \frac{J}{R} d\theta\)

\(V_{toroidal} = 2\pi \ int_0^{2\pi} J d\theta\)

Returns:

  • poloidal_area (float, units [lref**2]) – Calculation of the poloidal surface area \(A_{poloidal}\)

  • toroidal_area (float, units [lref**2]) – Calculation of the toroidal surface area \(A_{toroidal}\)

  • toroidal_volume (float, units [lref**3]) – Calculation of the poloidal volume \(V_{toroidal}\)

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

MXH definition of grad r from MXH, R. L., et al. “Noncircular, finite aspect ratio, local equilibrium model.” Physics of Plasmas 5.4 (1998): 973-978.

Also see eqn 39 in Candy Plasma Phys. Control. Fusion 51 (2009) 105009

Parameters:
  • kappa (Scalar) – elongation

  • shift (Scalar) – Shafranov shift

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

Returns:

grad_r – grad_r(theta)

Return type:

Array

get_s_hat(Fprime=None, ntheta=1024)[source]#

Calculate magnetic shear from F’ and other geometry terms

See eqn 45/46 in Dudding Geometry Paper

Returns:

shat – Prediction for \(\hat{s}\) given a F’

Return type:

Float

keys()[source]#
minimise_b_poloidal(params, even_space_theta=False)[source]#

Function for least squares minimisation of poloidal field

Parameters:

params (List) – List with LocalGeometry type specific values

Return type:

Difference between local geometry and equilibrium get_b_poloidal

normalise(norms, context=None)[source]#

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(axes=None, show_fit=False)[source]#
Parameters:

axes (Tuple[Axes, Axes] | None)

test_safety_factor()[source]#

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

Returns:

q – Prediction for \(q\) from fourier B_poloidal

Return type:

Float

to(norms, context=None)[source]#

Thin wrapper for normalise