From 0bafe76da20b6c3d763c71c62a3fcf5d730e385a Mon Sep 17 00:00:00 2001 From: Kipton Barros Date: Fri, 20 Sep 2024 10:43:23 -0600 Subject: [PATCH 1/2] Warn on s=1/2 anisotropy --- src/System/OnsiteCoupling.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/System/OnsiteCoupling.jl b/src/System/OnsiteCoupling.jl index 9c617cd99..c2bb891aa 100644 --- a/src/System/OnsiteCoupling.jl +++ b/src/System/OnsiteCoupling.jl @@ -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 && norm(matrep) > 1e-12 && matrep ≈ matrep[1, 1] * I + 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 From 0bfdd48878d29e74690d9485dfeb41ff8ae46c06 Mon Sep 17 00:00:00 2001 From: Kipton Barros Date: Fri, 20 Sep 2024 10:43:23 -0600 Subject: [PATCH 2/2] Simplify check --- src/System/OnsiteCoupling.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System/OnsiteCoupling.jl b/src/System/OnsiteCoupling.jl index c2bb891aa..3f7c9d132 100644 --- a/src/System/OnsiteCoupling.jl +++ b/src/System/OnsiteCoupling.jl @@ -3,7 +3,7 @@ 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 && norm(matrep) > 1e-12 && matrep ≈ matrep[1, 1] * I + 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