From 340c75b6670884d45f97e353899da7a2336eb17a Mon Sep 17 00:00:00 2001 From: Kipton Barros Date: Tue, 18 Jun 2024 15:34:33 -0600 Subject: [PATCH] Informative error message regarding zero-spin (#278) --- src/System/SpinInfo.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/System/SpinInfo.jl b/src/System/SpinInfo.jl index c7a84b892..d6663fa39 100644 --- a/src/System/SpinInfo.jl +++ b/src/System/SpinInfo.jl @@ -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