diff --git a/docs/src/versions.md b/docs/src/versions.md index bbf6d951c..8a6ef6efd 100644 --- a/docs/src/versions.md +++ b/docs/src/versions.md @@ -10,7 +10,7 @@ * Deprecate `spin_operators`, `stevens_operators`, `large_S_spin_operators` and `large_S_stevens_operators`. Use instead [`spin_matrices`](@ref) and [`stevens_matrices`](@ref), which require a specific spin-``S`` label. To - infer this, one can use [`spin_irrep_label`](@ref). + infer this, one can use [`spin_label`](@ref). * To perform a calculation with dipoles in the large-$S$ limit, use the new mode `:dipole_large_S` when constructing a [`System`](@ref). diff --git a/ext/PlottingExt.jl b/ext/PlottingExt.jl index 9a71bdb57..4f2bfbc43 100644 --- a/ext/PlottingExt.jl +++ b/ext/PlottingExt.jl @@ -513,7 +513,7 @@ function plot_coherents(sys::System{N};scale = 1., quantization_axis = nothing, else quantization_axis end - S = spin_matrices(spin_irrep_label(sys,site[4])) + S = spin_matrices(spin_label(sys,site[4])) spin_operator = S[1] .* v[1] .+ S[2] .* v[2] .+ S[3] .* v[3] basis_rotation = eigvecs(spin_operator;sortby = λ -> -real(λ)) dir[i] = Makie.Point3f(v...) diff --git a/src/Sunny.jl b/src/Sunny.jl index b580c3690..b272d0cc4 100644 --- a/src/Sunny.jl +++ b/src/Sunny.jl @@ -66,7 +66,7 @@ include("System/OnsiteCoupling.jl") include("System/Ewald.jl") include("System/Interactions.jl") export SpinInfo, System, Site, eachsite, position_to_site, global_position, magnetic_moment, - set_coherent!, set_dipole!, polarize_spins!, randomize_spins!, energy, energy_per_site, spin_irrep_label, + set_coherent!, set_dipole!, polarize_spins!, randomize_spins!, energy, energy_per_site, spin_label, set_onsite_coupling!, set_pair_coupling!, set_exchange!, dmvec, enable_dipole_dipole!, set_external_field!, to_inhomogeneous, set_external_field_at!, set_vacancy_at!, set_onsite_coupling_at!, set_exchange_at!, set_pair_coupling_at!, symmetry_equivalent_bonds, remove_periodicity! diff --git a/src/System/OnsiteCoupling.jl b/src/System/OnsiteCoupling.jl index bccf9bec9..8957f5068 100644 --- a/src/System/OnsiteCoupling.jl +++ b/src/System/OnsiteCoupling.jl @@ -6,7 +6,7 @@ function onsite_coupling(sys, site, matrep::AbstractMatrix) if sys.mode == :SUN return Hermitian(matrep) elseif sys.mode == :dipole - S = spin_irrep_label(sys, to_atom(site)) + S = spin_label(sys, to_atom(site)) λ = anisotropy_renormalization(S) c = matrix_to_stevens_coefficients(hermitianpart(matrep)) return StevensExpansion(λ .* c) @@ -107,7 +107,7 @@ set_onsite_coupling!(sys, S -> -D*S[3]^3, i) set_onsite_coupling!(sys, S -> 20*(S[1]^4 + S[2]^4 + S[3]^4), i) # An equivalent expression of this quartic anisotropy, up to a constant shift -O = stevens_matrices(spin_irrep_label(sys, i)) +O = stevens_matrices(spin_label(sys, i)) set_onsite_coupling!(sys, O[4,0] + 5*O[4,4], i) ``` """ @@ -157,7 +157,7 @@ function set_onsite_coupling!(sys::System, op, i::Int) end function set_onsite_coupling!(sys::System, fn::Function, i::Int) - S = spin_matrices(spin_irrep_label(sys, i)) + S = spin_matrices(spin_label(sys, i)) set_onsite_coupling!(sys, fn(S), i) end @@ -179,7 +179,7 @@ function set_onsite_coupling_at!(sys::System, op, site::Site) end function set_onsite_coupling_at!(sys::System, fn::Function, site::Site) - S = spin_matrices(spin_irrep_label(sys, to_atom(site))) + S = spin_matrices(spin_label(sys, to_atom(site))) set_onsite_coupling_at!(sys, fn(S), site) end diff --git a/src/System/PairExchange.jl b/src/System/PairExchange.jl index f4e6e705e..0a5fe0f5a 100644 --- a/src/System/PairExchange.jl +++ b/src/System/PairExchange.jl @@ -188,8 +188,8 @@ function set_pair_coupling_aux!(sys::System, scalar::Float64, bilin::Union{Float # Renormalize biquadratic interactions if sys.mode == :dipole - S1 = spin_irrep_label(sys, bond.i) - S2 = spin_irrep_label(sys, bond.j) + S1 = spin_label(sys, bond.i) + S2 = spin_label(sys, bond.j) biquad *= (1 - 1/2S1) * (1 - 1/2S2) end @@ -236,8 +236,8 @@ function set_pair_coupling!(sys::System{N}, op::AbstractMatrix, bond; extract_pa error("Symbolic operators required for mode `:dipole_large_S`.") end - N1 = Int(2spin_irrep_label(sys, bond.i)+1) - N2 = Int(2spin_irrep_label(sys, bond.j)+1) + N1 = Int(2spin_label(sys, bond.i)+1) + N2 = Int(2spin_label(sys, bond.j)+1) scalar, bilin, biquad, tensordec = decompose_general_coupling(op, N1, N2; extract_parts) set_pair_coupling_aux!(sys, scalar, bilin, biquad, tensordec, bond) @@ -249,8 +249,8 @@ function set_pair_coupling!(sys::System{N}, fn::Function, bond; extract_parts=tr error("General couplings not yet supported for mode `:dipole_large_S`.") end - S1 = spin_irrep_label(sys, bond.i) - S2 = spin_irrep_label(sys, bond.j) + S1 = spin_label(sys, bond.i) + S2 = spin_label(sys, bond.j) Si, Sj = to_product_space(spin_matrices.([S1, S2])...) set_pair_coupling!(sys, fn(Si, Sj), bond; extract_parts) return @@ -358,8 +358,8 @@ function set_pair_coupling_at_aux!(sys::System, scalar::Float64, bilin::Union{Fl # Renormalize biquadratic interactions if sys.mode == :dipole - S1 = spin_irrep_label(sys, to_atom(site1)) - S2 = spin_irrep_label(sys, to_atom(site2)) + S1 = spin_label(sys, to_atom(site1)) + S2 = spin_label(sys, to_atom(site2)) biquad *= (1 - 1/2S1) * (1 - 1/2S2) end @@ -422,8 +422,8 @@ function set_pair_coupling_at!(sys::System{N}, op::AbstractMatrix, site1::Site, error("Symbolic operators required for mode `:dipole_large_S`.") end - N1 = Int(2spin_irrep_label(sys, to_atom(site1))+1) - N2 = Int(2spin_irrep_label(sys, to_atom(site2))+1) + N1 = Int(2spin_label(sys, to_atom(site1))+1) + N2 = Int(2spin_label(sys, to_atom(site2))+1) scalar, bilin, biquad, tensordec = decompose_general_coupling(op, N1, N2; extract_parts=true) set_pair_coupling_at_aux!(sys, scalar, bilin, biquad, tensordec, site1, site2, offset) @@ -435,8 +435,8 @@ function set_pair_coupling_at!(sys::System{N}, fn::Function, site1::Site, site2: error("General couplings not yet supported for mode `:dipole_large_S`.") end - S1 = spin_irrep_label(sys, to_atom(site1)) - S2 = spin_irrep_label(sys, to_atom(site2)) + S1 = spin_label(sys, to_atom(site1)) + S2 = spin_label(sys, to_atom(site2)) Si, Sj = to_product_space(spin_matrices.([S1, S2])...) set_pair_coupling_at!(sys, fn(Si, Sj), site1, site2; offset) return diff --git a/src/System/System.jl b/src/System/System.jl index e1a9f21a1..2be6c386e 100644 --- a/src/System/System.jl +++ b/src/System/System.jl @@ -176,12 +176,12 @@ const Site = Union{NTuple{4, Int}, CartesianIndex{4}} @inline eachcell(sys::System) = CartesianIndices(sys.latsize) """ - spin_irrep_label(sys::System, i::Int) + spin_label(sys::System, i::Int) -If atom `i` or site `site` carries a single spin-``S`` moment, then returns -``S``. Otherwise, throws an error. +If atom `i` carries a single spin-``S`` moment, then returns the half-integer +label ``S``. Otherwise, throws an error. """ -function spin_irrep_label(sys::System, i::Int) +function spin_label(sys::System, i::Int) if sys.mode == :dipole_large_S return Inf else diff --git a/src/deprecated.jl b/src/deprecated.jl index ebdec389e..5380ee653 100644 --- a/src/deprecated.jl +++ b/src/deprecated.jl @@ -7,12 +7,12 @@ Base.@deprecate_binding large_S_spin_operators spin_matrices(Inf) Base.@deprecate_binding large_S_stevens_operators stevens_matrices(Inf) Base.@deprecate spin_operators(sys::System, i::Int) let - @warn "`spin_operators` will soon be removed! Use `spin_matrices(spin)` instead where `spin = spin_irrep_label(sys, i)`." - spin_matrices(spin_irrep_label(sys, i)) + @warn "`spin_operators` will soon be removed! Use `spin_matrices(spin)` instead where `spin = spin_label(sys, i)`." + spin_matrices(spin_label(sys, i)) end Base.@deprecate stevens_operators(sys::System, i::Int) let - @warn "`stevens_operators` will soon be removed! Use `stevens_matrices(spin)` instead where `spin = spin_irrep_label(sys, i)`." - stevens_matrices(spin_irrep_label(sys, i)) + @warn "`stevens_operators` will soon be removed! Use `stevens_matrices(spin)` instead where `spin = spin_label(sys, i)`." + stevens_matrices(spin_label(sys, i)) end Base.@deprecate suggest_magnetic_supercell(qs, latsize) suggest_magnetic_supercell(qs) diff --git a/test/shared.jl b/test/shared.jl index 29d7713bb..024de4cc8 100644 --- a/test/shared.jl +++ b/test/shared.jl @@ -36,7 +36,7 @@ function add_quadratic_interactions!(sys, mode) #= # This is a bit slower, but must also work - S = spin_irrep_label(sys, 1) + S = spin_label(sys, 1) O = stevens_matrices(S) Q = [O[2,q] for q in 2:-1:-2] Qi, Qj = to_product_space(Q, Q) @@ -54,11 +54,11 @@ function add_quartic_interactions!(sys, mode) if mode in (:dipole, :dipole_large_S) # Stevens operators O[4,q] are quartic in dipoles i = 3 - O = stevens_matrices(spin_irrep_label(sys, i)) + O = stevens_matrices(spin_label(sys, i)) set_onsite_coupling!(sys, 0.2*((1/20)O[4,0] + (1/4)O[4,4]), i) # Bilinear interactions in quadrupoles also have quartic scaling. - O = stevens_matrices(spin_irrep_label(sys, 1)) + O = stevens_matrices(spin_label(sys, 1)) Q = [O[2,q] for q in 2:-1:-2] Qi, Qj = to_product_space(Q, Q) biquad = [1.2 0 0 0 0 diff --git a/test/test_lswt.jl b/test/test_lswt.jl index a2bb89e2f..9d0895514 100644 --- a/test/test_lswt.jl +++ b/test/test_lswt.jl @@ -12,7 +12,7 @@ A,B,C,D = 2.6, -1.3, 0.2, -5.7 set_exchange!(sys, [A D D; D B C; D C B], Bond(4, 4, [1, 1, 0]))#; biquad = 0.3) - O = stevens_matrices(spin_irrep_label(sys, 3)) + O = stevens_matrices(spin_label(sys, 3)) c1, c2, c3 = 2.6, -1.3, 0.2, -5.7 Λ = c1 * (O[2,-2] - 2O[2,-1] - 2O[2,1]) + c2 * (-7O[4,-3] + 2O[4,-2] + O[4,-1] + O[4,1] + 7O[4,3]) + diff --git a/test/test_rescaling.jl b/test/test_rescaling.jl index d087cd15e..107abb12b 100644 --- a/test/test_rescaling.jl +++ b/test/test_rescaling.jl @@ -103,7 +103,7 @@ end c = randn(2k+1) E1, E2 = map([:dipole, :dipole_large_S]) do mode sys = System(cryst, (1,1,1), [SpinInfo(1; S, g=2)], mode) - O = stevens_matrices(spin_irrep_label(sys, 1)) + O = stevens_matrices(spin_label(sys, 1)) set_onsite_coupling!(sys, sum(c[k-q+1]*O[k, q] for q in -k:k), 1) return energy(sys) end diff --git a/test/test_samplers.jl b/test/test_samplers.jl index 094e5e10a..84f66c226 100644 --- a/test/test_samplers.jl +++ b/test/test_samplers.jl @@ -36,7 +36,7 @@ sys = System(cryst, (L,1,1), [SpinInfo(1, S=2, g=2)], :SUN; seed) randomize_spins!(sys) - S = spin_matrices(spin_irrep_label(sys, 1)) + S = spin_matrices(spin_label(sys, 1)) R = Sunny.random_orthogonal(sys.rng, 3; special=true) Λ = Sunny.rotate_operator(D*(S[3]^2-(1/5)*S[3]^4), R) set_onsite_coupling!(sys, Λ, 1) diff --git a/test/test_symmetry.jl b/test/test_symmetry.jl index a4450aac2..75c5b3928 100644 --- a/test/test_symmetry.jl +++ b/test/test_symmetry.jl @@ -186,7 +186,7 @@ end # Most general allowed anisotropy for this crystal c = randn(9) - O = stevens_matrices(spin_irrep_label(sys, 1)) + O = stevens_matrices(spin_label(sys, 1)) Λ = sum(c .* [O[2,0], O[2,2], O[4,0], O[4,2], O[4,4], O[6,0], O[6,2], O[6,4], O[6,6]]) set_onsite_coupling!(sys, Λ, 1) @@ -329,7 +329,7 @@ end randomize_spins!(sys0) i = 1 - O = stevens_matrices(spin_irrep_label(sys0, i)) + O = stevens_matrices(spin_label(sys0, i)) Λ = randn()*(O[2,0]+3O[2,2]) + randn()*(O[4,0]-5O[4,2]) + randn()*(O[4,0]+5O[4,4]) + randn()*(O[6,0]-21O[6,4]) + randn()*(O[6,0]+(105/16)O[6,2]+(231/16)O[6,6])