From 0984daa8ee9f00e1fa0acf19135ac2b5a509d135 Mon Sep 17 00:00:00 2001 From: Kipton Barros Date: Mon, 24 Jul 2023 19:11:28 -0600 Subject: [PATCH] Fixes --- src/System/System.jl | 3 ++- test/test_optimization.jl | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/System/System.jl b/src/System/System.jl index ff5cd35c8..6d36b889d 100644 --- a/src/System/System.jl +++ b/src/System/System.jl @@ -405,7 +405,8 @@ end Polarize the spin at a [`Site`](@ref) along the direction `dir`. """ function polarize_spin!(sys::System{N}, dir, site) where N - setspin!(sys, dipolar_state(sys, site, dir), to_cartesian(site)) + site = to_cartesian(site) + setspin!(sys, dipolar_state(sys, site, dir), site) end """ diff --git a/test/test_optimization.jl b/test/test_optimization.jl index 253423e59..8fea1b421 100644 --- a/test/test_optimization.jl +++ b/test/test_optimization.jl @@ -16,7 +16,7 @@ end @testitem "Optimization" begin # H = -∑Sᵢ⋅Sⱼ - ∑(Sᵢᶻ)² on 2D square lattice (z-polarized ground state) - function simple_sys(; mode=:dipole, dims=(4,4,1), seed=nothing, S) + function simple_sys(; dims=(4,4,1), mode, seed, S) cryst = Crystal(lattice_vectors(1,1,2,90,90,90), [[0,0,0]]) sys = System(cryst, dims, [SpinInfo(1; S)], mode; seed) set_exchange!(sys, -1, Bond(1,1,[1,0,0])) @@ -27,8 +27,9 @@ end S = 3/2 is_z_polarized(sys) = all(s -> abs(s[3]) ≈ S, sys.dipoles) - sys_dip = simple_sys(; mode=:dipole, seed=101, S) - sys_sun = simple_sys(; mode=:SUN, seed=102, S) + seed = 101 + sys_dip = simple_sys(; mode=:dipole, seed, S) + sys_sun = simple_sys(; mode=:SUN, seed, S) # Thermalize near ground state Δt = 0.05