Skip to content

Commit

Permalink
Informative error message regarding zero-spin (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbarros authored Jun 18, 2024
1 parent 9af8c4c commit 340c75b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/System/SpinInfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ struct SpinInfo
g :: Mat3 # Spin g-tensor

function SpinInfo(atom::Int; S, g)
if !isinteger(2S)
error("Spin $S for atom $atom is not a multiple of 1/2")
end
S > 0 || error("Spin S must be positive. Use `subcrystal` to discard non-magnetic ions.")
isinteger(2S) || error("Spin S must be an exact multiple of 1/2")
g = typeof(g) <: Number ? Mat3(I*g) : Mat3(g)
new(atom, S, g)
end
Expand Down

0 comments on commit 340c75b

Please sign in to comment.