SphericalHarmonicModes.jl

SphericalHarmonicModes.L1L2TriangleType
L1L2Triangle(l1_min::Int, l1_max::Int, Δl_max::Int, l2_min::Int = max(0, l1_min - Δl_max), l2_max = l1_max + Δl_max)
L1L2Triangle(l1_range::AbstractUnitRange{Int}, Δl_max::Int, l2_range::AbstractUnitRange{Int})

Return an iterator that loops over pairs of (l1,l2) where l1 lies in l1_range, l2 lies in l2_range, and l2 and l1 obey the triangle condition max(0, l1 - Δl_max) ⩽ l2 ⩽ l1 + Δl_max. If l2_range is not specified, it defaults to the maximal range permissible.

Warning

The ranges l1_range and l2_range will be curtailed to the minimal permissible subsets.

Examples

julia> L1L2Triangle(1:2, 2) |> collect
9-element Vector{Tuple{Int64, Int64}}:
 (1, 0)
 (1, 1)
 (1, 2)
 (1, 3)
 (2, 0)
 (2, 1)
 (2, 2)
 (2, 3)
 (2, 4)

julia> L1L2Triangle(2:3, 1) |> collect
6-element Vector{Tuple{Int64, Int64}}:
 (2, 1)
 (2, 2)
 (2, 3)
 (3, 2)
 (3, 3)
 (3, 4)

julia> L1L2Triangle(2:3, 1, 2:3) |> collect
4-element Vector{Tuple{Int64, Int64}}:
 (2, 2)
 (2, 3)
 (3, 2)
 (3, 3)
source
SphericalHarmonicModes.L2L1TriangleType
L2L1Triangle(l1_min::Int, l1_max::Int, Δl_max::Int, l2_min::Int = max(0, l1_min - Δl_max), l2_max = l1_max + Δl_max)
L2L1Triangle(l1_range::AbstractUnitRange{Int}, Δl_max::Int, l2_range::AbstractUnitRange{Int})

Return an iterator that loops over pairs of (l2,l1) where l1 lies in l1_range, l2 lies in l2_range, and l2 and l1 obey the triangle condition max(0, l1 - Δl_max) ⩽ l2 ⩽ l1 + Δl_max. If l2_range is not specified, it defaults to the maximal range permissible.

Warning

The ranges l1_range and l2_range will be curtailed to the minimal permissible subsets.

Examples

julia> L2L1Triangle(1:2, 2) |> collect
9-element Vector{Tuple{Int64, Int64}}:
 (0, 1)
 (1, 1)
 (2, 1)
 (3, 1)
 (0, 2)
 (1, 2)
 (2, 2)
 (3, 2)
 (4, 2)

julia> L2L1Triangle(2:3, 1) |> collect
6-element Vector{Tuple{Int64, Int64}}:
 (1, 2)
 (2, 2)
 (3, 2)
 (2, 3)
 (3, 3)
 (4, 3)

julia> L2L1Triangle(2:3, 1, 2:3) |> collect
4-element Vector{Tuple{Int64, Int64}}:
 (2, 2)
 (3, 2)
 (2, 3)
 (3, 3)
source
SphericalHarmonicModes.LMType
LM(l_range::Union{Integer, AbstractUnitRange{<:Integer}}, m_range::Union{Integer, AbstractUnitRange{<:Integer}})
LM(l_range::Union{Integer, AbstractUnitRange{<:Integer}}, [T = FullRange]) where T<:Union{FullRange, ZeroTo, ToZero}

Return an iterator that loops over pairs of spherical harmonic modes (l,m), with l increasing faster than m. The loop runs over all the valid modes that may be obtained from the ranges provided. If m_range is not specified, the loop runs over all valid values of m for each l. Neither l_range nor m_range may be empty.

Optionally m_range may be provided implicitly using the range specifiers FullRange, ZeroTo and ToZero, or as a SingleValuedRange type. Additionally, l_range may be of type ZeroTo or SingleValuedRange. Iterators constructed using these special types would often permit optimizations.

Warning

An overlarge l_range will be curtailed to match the valid range compatible with m_range. A smaller l_range than that compatible with m_range will raise an error.

Examples

julia> LM(0:1) |> collect
4-element Vector{Tuple{Int64, Int64}}:
 (1, -1)
 (0, 0)
 (1, 0)
 (1, 1)

julia> LM(0:1, 1:1) |> collect
1-element Vector{Tuple{Int64, Int64}}:
 (1, 1)

julia> r = LM(ZeroTo(1), FullRange);

julia> r |> collect
4-element Vector{Tuple{Int64, Int64}}:
 (1, -1)
 (0, 0)
 (1, 0)
 (1, 1)

See also: ML

source
SphericalHarmonicModes.MLType
ML(l_range::Union{Integer, AbstractUnitRange{<:Integer}}, m_range::Union{Integer, AbstractUnitRange{<:Integer}})
ML(l_range::Union{Integer, AbstractUnitRange{<:Integer}}, [T = FullRange]) where T<:Union{FullRange, ZeroTo, ToZero}

Return an iterator that loops over pairs of spherical harmonic modes (l,m), with m increasing faster than l. The loop runs over all the valid modes that may be obtained from the ranges provided. If m_range is not specified, the loop runs over all valid values of m for each l. Neither l_range nor m_range may be empty.

Optionally m_range may be provided implicitly using the range specifiers FullRange, ZeroTo and ToZero, or as a SingleValuedRange type. Additionally l_range may be of type ZeroTo or SingleValuedRange. Iterators constructed using these special types would often permit optimizations.

Warning

An overlarge l_range will be curtailed to match the valid range compatible with m_range. A smaller l_range than that compatible with m_range will raise an error.

Examples

julia> ML(0:1) |> collect
4-element Vector{Tuple{Int64, Int64}}:
 (0, 0)
 (1, -1)
 (1, 0)
 (1, 1)

julia> ML(0:1, 1:1) |> collect
1-element Vector{Tuple{Int64, Int64}}:
 (1, 1)

julia> r = ML(ZeroTo(1), FullRange);

julia> r |> collect
4-element Vector{Tuple{Int64, Int64}}:
 (0, 0)
 (1, -1)
 (1, 0)
 (1, 1)

See also: LM

source
SphericalHarmonicModes.SHModeRangeType
SphericalHarmonicModes.SHModeRange <: SphericalHarmonicModes.ModeRange

Abstract supertype of iterators that loop over (l,m) pairs. The types LM and ML are subtypes of this.

source
SphericalHarmonicModes.flipMethod
SphericalHarmonicModes.flip(mr::SphericalHarmonicModes.SHModeRange)

Return an iterator that flips the order in which the modes (l,m) are iterated over. flip(::LM) will return an ML iterator and vice versa.

Examples

julia> LM(0:1) |> collect
4-element Vector{Tuple{Int64, Int64}}:
 (1, -1)
 (0, 0)
 (1, 0)
 (1, 1)

julia> SphericalHarmonicModes.flip(LM(0:1)) |> collect
4-element Vector{Tuple{Int64, Int64}}:
 (0, 0)
 (1, -1)
 (1, 0)
 (1, 1)

julia> SphericalHarmonicModes.flip(LM(0:1)) == ML(0:1)
true
source
SphericalHarmonicModes.l2_rangeMethod
l2_range(mr::L2L1Triangle, l1::Integer)

Return a subsection of the range of l2 spanned by the iterator for which (l1,l2) satisfy l1 - mr.Δl_max ⩽ l2 ⩽ l1 + mr.Δl_max.

Examples

julia> r = L2L1Triangle(1:2, 1);

julia> collect(r)
6-element Vector{Tuple{Int64, Int64}}:
 (0, 1)
 (1, 1)
 (2, 1)
 (1, 2)
 (2, 2)
 (3, 2)

julia> l2_range(r, 1)
0:2

julia> l2_range(r, 2)
1:3
source
SphericalHarmonicModes.l_rangeMethod
l_range(mr::SphericalHarmonicModes.SHModeRange, m::Integer)

Return the subsection of the range of l spanned by the iterator for which (l,m) is a valid spherical harmonic mode.

Examples

julia> r = LM(1:2, 1:2);

julia> collect(r)
3-element Vector{Tuple{Int64, Int64}}:
 (1, 1)
 (2, 1)
 (2, 2)

julia> l_range(r, 1)
1:2

julia> l_range(r, 2)
2:2
source
SphericalHarmonicModes.m_rangeMethod
m_range(mr::SphericalHarmonicModes.SHModeRange, l::Integer)

Return the subsection of the range of m spanned by the iterator for which (l,m) is a valid spherical harmonic mode.

Examples

julia> r = LM(1:2, 1:2);

julia> collect(r)
3-element Vector{Tuple{Int64, Int64}}:
 (1, 1)
 (2, 1)
 (2, 2)

julia> m_range(r, 1)
1:1

julia> m_range(r, 2)
1:2
source
SphericalHarmonicModes.modeindexMethod
modeindex(mr::SphericalHarmonicModes.ModeRange, mode::Tuple)

Return the index of mode in the iterator mr. Raise an error if mode is not present in mr.

Examples

julia> r = LM(1:2, 1:2);

julia> collect(r)
3-element Vector{Tuple{Int64, Int64}}:
 (1, 1)
 (2, 1)
 (2, 2)

julia> modeindex(r, (2,1))
2

julia> modeindex(r, (3,2))
ERROR: Mode with (l=3,m=2) is not included in the range given by LM(1:2, 1:2)
source
SphericalHarmonicModes.oforderingMethod
SphericalHarmonicModes.ofordering(S, m)

Convert m to the ordering of S.

Examples

julia> SphericalHarmonicModes.ofordering(LM(0:1), ML(0:1)) |> collect
4-element Vector{Tuple{Int64, Int64}}:
 (1, -1)
 (0, 0)
 (1, 0)
 (1, 1)

julia> SphericalHarmonicModes.ofordering(ML(0:1), ML(0:1)) |> collect
4-element Vector{Tuple{Int64, Int64}}:
 (0, 0)
 (1, -1)
 (1, 0)
 (1, 1)
source