# Other utilities

## Parity

AtomicLevels defines the Parity type, which is used to represent the parity of atomic states etc.

AtomicLevels.ParityType
struct Parity

Represents the parity of a quantum system, taking two possible values: even or odd.

The integer values that correspond to even and odd parity are +1 and -1, respectively. Base.convert can be used to convert integers into Parity values.

julia> convert(Parity, 1)
even

julia> convert(Parity, -1)
odd
source

The parity values also define an algebra and an ordering:

julia> p"odd" < p"even"
true

julia> p"even" * p"odd"
odd

julia> (p"odd")^3
odd

julia> -p"odd"
even

The exported parity function is overloaded for many of the types in AtomicLevels, defining a uniform API to determine the parity of an object.

## JJ to LSJ

AtomicLevels.jj2ℓsjFunction
jj2ℓsj([T=Float64, ]orbs...)

Generates the block-diagonal matrix that transforms jj-coupled configurations to lsj-coupled ones.

The blocks correspond to invariant subspaces, which rotate among themselves to form new linear combinations.

They are sorted according to n,ℓ and within the blocks, the columns are sorted according to mⱼ,j (increasing) and the rows according to s,ℓ,m (increasing).

E.g. the p-block will have the following structure:

⟨p;-1,↓|3/2,-3/2⟩  │       ⋅                  ⋅             │       ⋅                ⋅           │       ⋅
───────────────────┼────────────────────────────────────────┼────────────────────────────────────┼─────────────────
⋅             │  ⟨p;0,↓|1/2,-1/2⟩   ⟨p;0,↓|3/2,-1/2⟩   │       ⋅                ⋅           │       ⋅
⋅             │  ⟨p;-1,↑|1/2,-1/2⟩  ⟨p;-1,↑|3/2,-1/2⟩  │       ⋅                ⋅           │       ⋅
───────────────────┼────────────────────────────────────────┼────────────────────────────────────┼─────────────────
⋅             │       ⋅                  ⋅             │  ⟨p;1,↓|1/2,1/2⟩  ⟨p;1,↓|3/2,1/2⟩  │       ⋅
⋅             │       ⋅                  ⋅             │  ⟨p;0,↑|1/2,1/2⟩  ⟨p;0,↑|3/2,1/2⟩  │       ⋅
───────────────────┼────────────────────────────────────────┼────────────────────────────────────┼─────────────────
⋅             │       ⋅                  ⋅             │       ⋅                ⋅           │  ⟨p;1,↑|3/2,3/2⟩
source

## Angular momentum quantum numbers

AtomicLevels.str2κFunction
str2κ(s) -> Int

A function to convert the canonical string representation of a $\ell_j$ angular label (i.e. ℓ- or ) into the corresponding $\kappa$ quantum number.

julia> str2κ.(["s", "p-", "p"])
3-element Vector{Int64}:
-1
1
-2
source
AtomicLevels.@κ_strMacro
@κ_str -> Int

A string macro to convert the canonical string representation of a $\ell_j$ angular label (i.e. ℓ- or ) into the corresponding $\kappa$ quantum number.

julia> κ"s", κ"p-", κ"p"
(-1, 1, -2)
source
AtomicLevels.κ2ℓFunction
κ2ℓ(κ::Integer) -> Integer

Calculate the quantum number corresponding to the κ quantum number.

Note: κ and values are always integers.

source
AtomicLevels.κ2jFunction
κ2j(κ::Integer) -> HalfInteger

Calculate the j quantum number corresponding to the κ quantum number.

Note: κ is always an integer, but j will be a half-integer value.

source
AtomicLevels.ℓj2κFunction
ℓj2κ(ℓ::Integer, j::Real) -> Integer

Converts a valid (ℓ, j) pair to the corresponding κ value.

Note: there is a one-to-one correspondence between valid (ℓ,j) pairs and κ values such that for j = ℓ ± 1/2, κ = ∓(j + 1/2).

source