API Reference

MillerExtendedHarmonic

MillerExtendedHarmonic.MXHType
MXH(R0::T, Z0::T, ϵ::T, κ::T, c0::T, c::U, s::U) where {T<:Real,U<:AbstractVector{<:Real}}

Return MXH for Miller-extended-harmonic representation:

R(θ) = R0 + R0*ϵ*cos(θᵣ(θ)) where θᵣ(θ) = θ + c0 + sum[c[m]*cos(m*θ) + s[m]*sin(m*θ)]
Z(θ) = Z0 - κ*R0*ϵ*sin(θ)
source
MXH(R0::Real, Z0::Real, ϵ::Real, κ::Real, c0::Real, c::AbstractVector{<:Real}, s::AbstractVector{<:Real})

Return MXH for Miller-extended-harmonic representation:

R(θ) = R0 + R0*ϵ*cos(θᵣ(θ)) where θᵣ(θ) = θ + c0 + sum[c[m]*cos(m*θ) + s[m]*sin(m*θ)]
Z(θ) = Z0 - κ*R0*ϵ*sin(θ)
source
MXH(R0::Real, n_coeffs::Integer)

Return MXH for example Miller-extended-harmonic representation:

R(θ) = R0 + 0.3*R0*cos(θ)
Z(θ) = -0.3*R0*sin(θ)

with n_coeffs` sin/cos coefficients all set to zero

source
MXH(flat::AbstractVector{<:Real})

Return MXH for Miller-extended-harmonic representation from flattened coefficients

source
MXH(
pr::AbstractVector{<:Real},
pz::AbstractVector{<:Real},
MXH_modes::Integer=5;
optimize_fit=false,
spline=false,
rmin=0.0,
rmax=0.0,
zmin=0.0,
zmax=0.0)

Compute Fourier coefficients for Miller-extended-harmonic representation:

R(θ) = R0 + R0*ϵ*cos(θᵣ(θ)) where θᵣ(θ) = θ + c0 + sum[c[m]*cos(m*θ) + s[m]*sin(m*θ)]
Z(θ) = Z0 - κ*R0*ϵ*sin(θ)

Where pr,pz are the flux surface coordinates and MXHmodes is the number of modes. `optimizefitkeyword indicates to optimize the fit parameters to best go through the pointssplinekeyword indicates to use spline integration for modesrmin,rmax,zmin,zmax` force certain maximum and minimum values for the fit

source
    MXH(pr::AbstractVector{<:Real}, pz::AbstractVector{<:Real}, R0::Real, Z0::Real, a::Real, b::Real, MXH_modes::Integer;
         optimize_fit=false, spline=false)

Compute Fourier coefficients for Miller-extended-harmonic representation:

R(θ) = R0 + R0*ϵ*cos(θᵣ(θ)) where θᵣ(θ) = θ + c0 + sum[c[m]*cos(m*θ) + s[m]*sin(m*θ)]
Z(θ) = Z0 - κ*R0*ϵ*sin(θ)

Where pr,pz are the flux surface coordinates and MXHmodes is the number of modes. `optimizefitkeyword indicates to optimize the fit parameters to best go through the pointsspline` keyword indicates to use spline integration for modes

N.B.: If optimize_fit is false, some MXH values are fixed, namely R0=R0, Z0=Z0, ϵ=a/R0, and κ=b/a Otherwise, these are just the starting values for the optimzation

source
(mxh::MXH)(n_points::Int=100; adaptive::Bool=true)

Returns (r,z) vectors of given MXH

If adaptive, n_points is specified for the perimeter of a unit circle; and the number will never be less than n_points.

source
MillerExtendedHarmonic.MXH!Function
    MXH!(
    mxh::MXH,
    pr::AbstractVector{<:Real},
    pz::AbstractVector{<:Real};
    θ=similar(pr),
    Δθᵣ=similar(pr),
    dθ=similar(pr),
    Fm=similar(pr),
    optimize_fit=false,
    spline=false,
    rmin=0.0,
    rmax=0.0,
    zmin=0.0,
    zmax=0.0)

Like MXH() but operates in place. θ, Δθᵣ, dθ, Fm are work arrays vectors that can be preallocated if desired

source
    MXH!(mxh::MXH, pr::AbstractVector{<:Real}, pz::AbstractVector{<:Real}, R0::Real, Z0::Real, a::Real, b::Real;
θ::AbstractVector{<:Real}, Δθᵣ::AbstractVector{<:Real}, dθ::AbstractVector{<:Real}, Fm::AbstractVector{<:Real},
optimize_fit=false, spline=false)

Like MXH() but operates in place. θ, Δθᵣ, dθ, Fm are work arrays vectors that can be preallocated if desired

N.B.: This function potentially reorders pr and pz in-place

source
MillerExtendedHarmonic.flat_coeffsFunction
flat_coeffs(mxh::MXH)

return all mxh coefficients as an array of floats of length 5 + 2L where L is the number of sin/cos coefficients

NOTE: autodiff compatible

source
MillerExtendedHarmonic.flat_coeffs!Function
flat_coeffs!(flat::AbstractVector{<:Real}, mxh::MXH)

return all mxh coefficients as an array of floats of length 5 + 2L where L is the number of sin/cos coefficients

NOTE: operates in place on flat input vector and is not autodiff compatible

source