SunnySuite / Sunny.jl

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

Allow `set_onsite_coupling!` with zero #111

Closed kbarros closed 1 year ago

kbarros commented 1 year ago

This fixes https://github.com/SunnySuite/Sunny.jl/issues/110 and performs some additional reorganization.

kbarros commented 1 year ago

The proposed new behavior is:

sys = System(...)
S = spin_operators(sys, 1)
set_onsite_coupling!(sys, zero(S[3]), 1) # does nothing
set_onsite_coupling!(sys, S[3]^2, 1)     # sets a coupling
set_onsite_coupling!(sys, zero(S[3]), 1) # emits a warning and removes coupling
set_onsite_coupling!(sys, S[3]^2, 1)     # sets a coupling *without warning* (does not detect existing coupling)