SunnySuite / Sunny.jl

Spin dynamics and generalization to SU(N) coherent states
Other
86 stars 19 forks source link

Catch errors during show(System) #234

Closed Lazersmoke closed 8 months ago

Lazersmoke commented 8 months ago

Now that energy(sys) sometimes errors (e.g. if dipoles are not normalized), typing in sys at the REPL can clobber the terminal with a huge error message. This PR makes it so the error message is relatively tame

kbarros commented 8 months ago

I modified the PR slightly so that it has the following behavior:

sys = System(cryst, dims, [SpinInfo(1; S, g=1)], :dipole)
display(sys)
#=
System [Dipole mode]
Lattice (1×1×1)×1
Energy per site 0
=#

sys.dipoles[1,1,1,1] *= 2
display(sys)
#=
System [Dipole mode]
Lattice (1×1×1)×1
[Incorrectly normalized spin state!]
=#