Skip to content

Commit

Permalink
Sort spin-orbitals by spatial orbitals, then by projections
Browse files Browse the repository at this point in the history
  • Loading branch information
jagot committed Dec 19, 2023
1 parent b3ef25a commit f8b4de1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/spin_orbitals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f8b4de1

Please sign in to comment.