Skip to content

Commit

Permalink
Warn if set_onsite_coupling! is called for spin s=1/2 (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbarros authored Sep 20, 2024
1 parent 6c5d991 commit 69131fe
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/System/OnsiteCoupling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ function onsite_coupling(sys, site, matrep::AbstractMatrix)
size(matrep) == (N, N) || error("Invalid matrix size.")
matrep matrep' || error("Operator is not Hermitian")

if N == 2 && isapprox(matrep, matrep[1, 1] * I; atol=1e-8)
suggest = sys.mode == :dipole ? " (use :dipole_large_s to reproduce legacy calculations)" : ""
@warn "Onsite coupling is always trivial for quantum spin s=1/2" * suggest
end

if sys.mode == :SUN
return Hermitian(matrep)
elseif sys.mode == :dipole
Expand Down

0 comments on commit 69131fe

Please sign in to comment.