diff --git a/Project.toml b/Project.toml index ad4d552..5c4cb0c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AtomicLevels" uuid = "10933b4c-d60f-11e8-1fc6-bd9035a249a1" authors = ["Stefanos Carlström "] -version = "0.1.11" +version = "0.1.12" [deps] BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" @@ -15,7 +15,7 @@ UnicodeFun = "1cfade01-22cf-5700-b092-accc4b62d6e1" WignerSymbols = "9f57e263-0b3d-5e2e-b1be-24f2bb48858b" [compat] -BlockArrays = "1" +BlockArrays = "0.16,1" BlockBandedMatrices = "0.8, 0.9, 0.10, 0.11, 0.12, 0.13" Combinatorics = "1" FillArrays = "1" diff --git a/src/orbitals.jl b/src/orbitals.jl index ef26fe6..7688eeb 100644 --- a/src/orbitals.jl +++ b/src/orbitals.jl @@ -253,7 +253,7 @@ function parse_orbital_ℓ(m::RegexMatch,i=2) end function Base.parse(::Type{<:Orbital}, orb_str) - m = match(r"^([0-9]+|.)([a-z]|\[[0-9]+\])$", orb_str) + m = match(r"^([0-9]+|.|\[.+\])([a-z]|\[[0-9]+\])$", orb_str) isnothing(m) && throw(ArgumentError("Invalid orbital string: $(orb_str)")) n = parse_orbital_n(m) ℓ = parse_orbital_ℓ(m) diff --git a/src/relativistic_orbitals.jl b/src/relativistic_orbitals.jl index e28ec6e..cba498e 100644 --- a/src/relativistic_orbitals.jl +++ b/src/relativistic_orbitals.jl @@ -211,7 +211,7 @@ end # * Orbital construction from strings function Base.parse(::Type{<:RelativisticOrbital}, orb_str) - m = match(r"^([0-9]+|.)([a-z]|\[[0-9]+\])([-]{0,1})$", orb_str) + m = match(r"^([0-9]+|.|\[.+\])([a-z]|\[[0-9]+\])([-]{0,1})$", orb_str) isnothing(m) && throw(ArgumentError("Invalid orbital string: $(orb_str)")) n = parse_orbital_n(m) ℓ = parse_orbital_ℓ(m) diff --git a/src/spin_orbitals.jl b/src/spin_orbitals.jl index 56723c7..7f22ba8 100644 --- a/src/spin_orbitals.jl +++ b/src/spin_orbitals.jl @@ -71,9 +71,6 @@ end degeneracy(::SpinOrbital) = 1 -# We cannot order spin-orbitals of differing orbital types -Base.isless(a::SpinOrbital{O,M}, b::SpinOrbital{O,N}) where {O<:AbstractOrbital,M,N} = false - function Base.isless(a::SpinOrbital{<:O,M}, b::SpinOrbital{<:O,M}) where {O,M} a.orb < b.orb && return true a.orb > b.orb && return false @@ -86,6 +83,18 @@ function Base.isless(a::SpinOrbital{<:O,M}, b::SpinOrbital{<:O,M}) where {O,M} return false end +function Base.isless(a::SpinOrbital{O,M}, b::SpinOrbital{O,M}) where {O,M} + a.orb < b.orb && return true + a.orb > b.orb && return false + + for (ma,mb) in zip(a.m,b.m) + ma < mb && return true + ma > mb && return false + end + # All projections were equal + return false +end + function Base.isless(a::SpinOrbital{<:Orbital}, b::SpinOrbital{<:Orbital}) a.orb < b.orb && return true a.orb > b.orb && return false diff --git a/test/orbitals.jl b/test/orbitals.jl index 396eb3b..3282a67 100644 --- a/test/orbitals.jl +++ b/test/orbitals.jl @@ -66,6 +66,8 @@ using Random @test parse(Orbital, "1s") == Orbital(1, 0) @test parse(Orbital{Int}, "1s") == Orbital(1, 0) @test parse(Orbital{Symbol}, "ks") == Orbital(:k, 0) + @test parse(Orbital, "[abc]s") == Orbital(Symbol("[abc]"), 0) + @test parse(RelativisticOrbital, "[abc]p") == RelativisticOrbital(Symbol("[abc]"), 1, 3/2) @test ro"1s" == RelativisticOrbital(1, -1) # κ=-1 => s orbital @test ro"2p-" == RelativisticOrbital(2, 1, half(1))