Skip to content

Commit

Permalink
add twist
Browse files Browse the repository at this point in the history
  • Loading branch information
orso82 committed Sep 4, 2024
1 parent 9c1991a commit 1a3c368
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/MXHEquilibrium.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export PlasmaGeometricParameters, plasma_geometry, flux_surface_geometry
include("shape.jl")
export PlasmaShape, MillerShape, TurnbullMillerShape, MillerExtendedHarmonicShape, LuceShape
export AsymmetricMillerShape, AMShape, MShape, TMShape, MXHShape, LShape, shape
export curvature, triangularity, squareness, tilt, elevation, ovality
export curvature, triangularity, squareness, tilt, elevation, ovality, twist
export scale_aspect, elongation, aspect_ratio, major_radius, minor_radius
export convert_eltype

Expand All @@ -97,6 +97,7 @@ elevation(S::PlasmaShape) = _not_implemented(S)
triangularity(S::PlasmaShape) = _not_implemented(S)
tilt(S::PlasmaShape) = _not_implemented(S)
ovality(S::PlasmaShape) = _not_implemented(S)
twist(S::PlasmaShape) = _not_implemented(S)
squareness(S::PlasmaShape) = _not_implemented(S)

include("fitting.jl")
Expand Down
17 changes: 9 additions & 8 deletions src/shape.jl
Original file line number Diff line number Diff line change
Expand Up @@ -441,17 +441,17 @@ Fields:\\
`ϵ` - Inverse Aspect Ratio a/R0 where a = minor radius\\
`κ` - Elongation\\
`c0` - Tilt\\
`c` - Cosine coefficients i.e. [ovality,...]\\
`s` - Sine coefficients i.e. [asin(triangularity), squareness,...])
`c` - Cosine coefficients i.e. [ovality, twist, ...]\\
`s` - Sine coefficients i.e. [asin(triangularity), -squareness, ...])
"""
struct MillerExtendedHarmonicShape{N,T} <: PlasmaShape{T}
R0::T # Major Radius
Z0::T # Elevation
ϵ::T # inverse aspect ratio a/R0
κ::T # Elongation
c0::T # Tilt
c::SVector{N,T} # Cosine coefficients acos.([ovality,...])
s::SVector{N,T} # Sine coefficients asin.([triangularity,-squareness,...]
c::SVector{N,T} # Cosine coefficients [ovality, twist, ...]\\
s::SVector{N,T} # Sine coefficients [asin(triangularity), -squareness, ...])
end

const MXHShape = MillerExtendedHarmonicShape
Expand Down Expand Up @@ -479,13 +479,13 @@ function MillerExtendedHarmonicShape(R0, Z0, ϵ, κ, c0, c::Vector, s::Vector)
return MillerExtendedHarmonicShape(R0, Z0, ϵ, κ, c0, c, s)
end

function MillerExtendedHarmonicShape(R0, Z0, ϵ, κ, δ; tilt=zero(κ), ovality=zero(R0), squareness=zero(R0))
R0, Z0, ϵ, κ, tilt, ovality, squareness = promote(R0, Z0, ϵ, κ, tilt, ovality, squareness)
function MillerExtendedHarmonicShape(R0, Z0, ϵ, κ, δ; tilt=zero(κ), ovality=zero(R0), twist=zero(κ), squareness=zero(R0))
R0, Z0, ϵ, κ, tilt, twist, ovality, squareness = promote(R0, Z0, ϵ, κ, tilt, twist, ovality, squareness)
Z = zero(R0)
if δ == Z && tilt == Z && ovality == Z && squareness == Z
if δ == Z && tilt == Z && twist == Z && ovality == Z && squareness == Z
return MillerShape(R0, Z0, ϵ, κ, δ)
end
c = SVector(ovality, zero(ovality))
c = SVector(ovality, twist)
s = SVector(asin(δ), -squareness)

return MillerExtendedHarmonicShape(R0, Z0, ϵ, κ, tilt, c, s)
Expand All @@ -506,6 +506,7 @@ minor_radius(S::MXHShape) = S.R0 * S.ϵ
elevation(S::MXHShape) = S.Z0
tilt(S::MXHShape) = S.c0
ovality(S::MXHShape) = S.c[1]
twist(S::MXHShape) = S.c[2]
triangularity(S::MXHShape) = sin(S.s[1])
# MXH squareness differs from TurnbullMiller, using MXH paper's definition
squareness(S::MXHShape) = -S.s[2]
Expand Down

0 comments on commit 1a3c368

Please sign in to comment.