API Reference
MillerExtendedHarmonic
MillerExtendedHarmonic.MXH
— TypeMXH(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(θ)
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(θ)
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
MXH(flat::AbstractVector{<:Real})
Return MXH for Miller-extended-harmonic representation from flattened coefficients
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 points
splinekeyword indicates to use spline integration for modes
rmin,
rmax,
zmin,
zmax` force certain maximum and minimum values for the fit
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 points
spline` 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
(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
.
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
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
MillerExtendedHarmonic.copy_MXH!
— Functioncopy_MXH!(mxh1::MXH, mxh2::MXH)
copy all attributes from mxh2 to mxh1
MillerExtendedHarmonic.flat_coeffs
— Functionflat_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
MillerExtendedHarmonic.flat_coeffs!
— Functionflat_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