PlasmaEquilibriumToolkit

PlasmaEquilibriumToolkit.BasisVectorsType
BasisVectors{T} <: SArray{Tuple{3,3},T,2,9}

Convenience type for defining the Cartesian coordinate representation of 3D curvilinear vector fields. For a vector defined by inverse map $R(x,y,z) = (U(x,y,z),V(x,y,z),W(x,y,z))$, the components are represented by the 3×3 SArray:

R = [Ux Vx Wx;Uy Vy Wy;Uz Vz Wz]

where Ux is the x-component of U.

Examples

julia> using StaticArrays
julia> typeof(@SArray(ones(3,3))) <: BasisVectors{Float64}
true
PlasmaEquilibriumToolkit.BoozerCoordinatesType
BoozerCoordinates{T,A}(ψ::T,χ::A,ϕ::A) <: MagneticCoordinates

Coordinates on a magnetic flux surface, where ψ is the flux label and χ and ϕ are angle-like variables

PlasmaEquilibriumToolkit.ClebschCoordinatesType
ClebschCoordinates(α,β,η)

Coordintes (α,β,η) representing a divergence-free magnetic field $B = ∇α×∇β$ with a Jacobian defined by $√g = 1/(∇η ⋅ ∇α × ∇β)$.

PlasmaEquilibriumToolkit.FluxCoordinatesType
FluxCoordinates{T,A}(ψ::T,θ::A,ζ::A) <: MagneticCoordinates

Coordinates on a magnetic flux surface, where ψ is the physical toroidal flux divided by 2π and θ and ζ are angle-like variables

PlasmaEquilibriumToolkit.FourierCoordinatesType
FourierCoordinates{T,A}(s::T, θ::A, ζ::A)

Coordinates on a surface. These are identical to the coordinates on a magnetic These are identical to magnetic flux-surface coordinates. s represents a surface label and is some degree arbitrary unless the surface is part of a magnetic equilibrium. θ and ζ are poloidal and toroidal angle-like coordinates respectively

PlasmaEquilibriumToolkit.MagneticGeometryType

MagneticGeometry

Subtype of AbstractMagneticGeometry. Possibly should be a struct with some general features of magnetic geometry (like field information) Right now it is empty

PlasmaEquilibriumToolkit.PestCoordinatesType
PestCoordinates{T,A}(ψ::T,α::A,ζ::A) <: MagneticCoordinates

Coordinates on a magnetic flux surface, where ψ is the toroidal flux divided by 2π in the clockwise direction, α is the field line label, and ζ is the geometric toroidal angle advancing the clockwise direction.

PlasmaEquilibriumToolkit.SurfaceFourierDataType
SurfaceFourierData{T} where T <: AbstractFloat

Composite type representation for a single set of cos and sin coefficients and deriatives w.r.t s for a given poloidal and toroidal mode number

Fields

  • m::T : Poloidal mode number
  • n::T : Toroidal mode number multiplied by number of field periods
  • cos::T : The cosine coefficient
  • sin::T : The sine coefficient
  • dcosds::T : Derivative of the cosine coefficient w.r.t. s
  • dsinds::T : Derivative of the sine coefficient w.r.t. s
Base.absMethod
abs(e::BasisVectors{T},component=0)

Compute the L2 norm of the basis vector e. If component > 0 and <= 3, the L2 norm of the component is returned.

Examples

julia> using StaticArrays

julia> e = @SArray([1 4 7;2 5 8;3 6 9]);

julia> abs(e)
16.881943016134134

julia> abs(e,1)
3.7416573867739413
PlasmaEquilibriumToolkit.MagneticCoordinateGridMethod
MagneticCoordinateGrid(C::AbstractMagneticCoordinates,α::Union{AbstractArray,Real},β::Union{AbstractArray,Real},η::Union{AbstractArray,Real}

Generate a grid of magnetic coordiantes of type C, returning a StructArray{C} containing the coordinates

PlasmaEquilibriumToolkit.basis_vectorsMethod
basis_vectors(b::BasisType,t::Transformation,x::AbstractArray{T},eq::AbstractGeometry) where T <: AbstractMagneticCoordinates

Generate basis vectors of type b for the magnetic coordinates defined by the transformation t at the points given by x using data from the magnetic equilibrium eq. The routine providing the point transformation designated by t is defined in the respective equilibrium module.

Examples

Generate covariant basis vectors for points along a field line defined by PestCoordinates using a VMEC equilibrium

julia> using PlasmaEquilibriumToolkit, VMEC, NetCDF
julia> wout = NetCDF.open("wout.nc"); vmec, vmec_data = readVmecWout(wout);
julia> s = 0.5; vmec_s = VmecSurface(s,vmec);
julia> x = PestCoordinates(s*vmec.phi(1.0)/2π*vmec.signgs,0.0,-π:2π/10:π);
julia> v = VmecFromPest()(x,vmec_s);
julia> e_v = basis_vectors(Covariant(),CartesianFromVmec(),v,vmec_s)
10-element Array{StaticArrays.SArray{Tuple{3,3},Float64,2,9},1}:
 ⋮
PlasmaEquilibriumToolkit.geodesic_curvatureMethod
geodesic_curvature(b::CoordinateVector,gradB::CoordinateVector,gradX::CoordinateVector)

Computes the geodesic curvature component defined in straight fieldline coordinates (X,Y,Z) with basis vectors defined by (∇X,∇Y,∇Z) with the relation κ_g = -(B × ∇B) ⋅ ∇X/(B²|∇X|)

PlasmaEquilibriumToolkit.grad_B_projectionMethod
grad_B_projection(e::BasisVectors,∇B::CoordinateVector)

Computes the projection of B × ∇B/B² onto the perpendicular coordinate vectors given by ∇X = e[:,1] and ∇Y = e[:,2].

PlasmaEquilibriumToolkit.in_surfaceMethod

insurface(cc, surf; res=100) insurface(xyz, surf; res=100)

Calculate where a value is inside a surface given a surface and cylindrical or cartesian coordinates. Uses the PolygonOps package

PlasmaEquilibriumToolkit.inverseTransformMethod
inverseTransform(x::AbstractMagneticCoordinates,data::SurfaceFourierData{T};deriv::Symbol=:none)

Compute the inverse Fourier transform of VMEC spectral data with coefficients defined in data at the points defined by the AbstractMagneticCoordinates x. The inverse transform of the derivative of data can be specified as :none,:ds, :dθ, or .

Examples

PlasmaEquilibriumToolkit.jacobianMethod
jacobian(t::BasisType,e::BasisVectors{T})

Compute the Jacobian of the covariant/contravariatn basis vectors e given by $J = e₁ ⋅ e₂ × e₃$ (covariant) or $J = 1/(e¹ ⋅ e² × e³)$ (contravariant).

PlasmaEquilibriumToolkit.metricMethod
metric2(e::BasisVectors)

Computes the metric tensor components gᵘᵛ or gᵤᵥ for a set of basis vectors e in a 6 element SVector: [g11 = e[:,1]*e[:,1], g12 = e[:,1]*e[:,2],…]

PlasmaEquilibriumToolkit.normal_curvatureMethod
normal_curvature(B::CoordinateVector,∇B::CoordinateVector,∇X::CoordinateVector,∇Y::CoordinateVector)

Computes the normal curvature component defined in straight fieldline coordinates (X,Y,Z) with basis vectors defined by (∇X,∇Y,∇Z) with the relation κₙ = (B × ∇B) ⋅ ((∇X⋅∇X)∇Y - (∇X⋅∇Y)∇X)/(B³|∇X|)

PlasmaEquilibriumToolkit.transform_basisMethod
transform_basis(t::Transformation,x::AbstracyArray{AbstractMagneticCoordinates},e::AbstractArray{BasisVectors{T}},eq::AbstractGeometry)

Perform a change of basis for magnetic coordinates denoted by the transformation t, using the provided coordinate charts and basis vectors.

PlasmaEquilibriumToolkit.transform_basisMethod
transform_basis(t::BasisTransformation, e::BasisVectors)
transform_basis(t::BasisTransformation, e::BasisVectors, jacobian)
transform_basis(t::BasisTransformation, e::AbstractArray{BasisVectors})
transform_basis(t::BasisTransformation, e::AbstractArray{BasisVectors}, jacobian::AbstractArray)

Transform the covariant/contravariant basis given by e to a contravariant/covariant basis by computing the transformation Jacobian from the basis vectors; for ContravariantFromCovariant() the Jacobian is given by $J = e₁ ⋅ e₂ × e₃$ and for CovariantFromContravariant() the Jacobian is given by $J = 1.0/(e¹ ⋅ e² × e³)$.