Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kbarros committed Dec 9, 2024
1 parent 968f7a0 commit 5a97da6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Sunny"
uuid = "2b4a2ac8-8f8b-43e8-abf4-3cb0c45e8736"
authors = ["The Sunny team"]
version = "0.7.4"
version = "0.7.5"

[deps]
Brillouin = "23470ee3-d0df-4052-8b1a-8cbd6363e7f0"
Expand Down
2 changes: 1 addition & 1 deletion src/Operators/Rotation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Rotates the local quantum operator `A` according to the ``3×3`` rotation matrix
function rotate_operator(A::AbstractMatrix{ComplexF64}, R)
isempty(A) && return A
A A' || error("Non-Hermitian operator")
A = Hermitian(hermitianpart(A))
A = hermitianpart(A)
R = convert(Mat3, R)
N = size(A, 1)
U = unitary_irrep_for_rotation(R; N)
Expand Down
2 changes: 1 addition & 1 deletion src/Symmetry/AllowedAnisotropy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function basis_for_symmetry_allowed_anisotropies(cryst::Crystal, i::Int; k::Int,
transform_spherical_to_stevens_coefficients(k, c)
end

# Apply a global rotation R to the Cartesian coordinate system. Stevens
# Apply a global rotation to the Cartesian coordinate system. Stevens
# operators rotate as 𝒪′ = V 𝒪. Coefficients satisfying b′ᵀ 𝒪′ = bᵀ 𝒪
# must therefore transform as b′ = V⁻ᵀ b.
V = operator_for_stevens_rotation(k, R_global)
Expand Down
12 changes: 7 additions & 5 deletions src/Symmetry/Printing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ function print_site(cryst, i; i_ref=i, R=Mat3(I), ks=[2,4,6], io=stdout)
syms = symmetries_between_atoms(cryst, i, i_ref)
isempty(syms) && error("Atoms $i and $i_ref are not symmetry equivalent.")
R_site = cryst.latvecs * first(syms).R * inv(cryst.latvecs)
R_site *= det(R_site) # Remove possible inversion (appropriate for spin pseudo-vector)
end

basis = basis_for_symmetry_allowed_couplings(cryst, Bond(i_ref, i_ref, [0, 0, 0]); R_global)
Expand Down Expand Up @@ -268,16 +269,17 @@ function print_allowed_anisotropy(cryst::Crystal, i_ref::Int; R_global::Mat3, R_
for k in ks
B = basis_for_symmetry_allowed_anisotropies(cryst, i_ref; k, R_global, atol)

# Rotation R_site transforms from i_ref to atom i of interest. V is the
# corresponding linear operator that acts on Stevens coefficients
# B is an allowed basis for i_ref, but we want to print the allowed
# basis for i. These sites are symmetry equivalent under the rotation
# R_site. V is the corresponding linear operator that acts on Stevens
# operators, 𝒪′ = V 𝒪. Coefficients satisfying b′ᵀ 𝒪′ = bᵀ 𝒪 then
# transform as b′ = V⁻ᵀ b.
V = operator_for_stevens_rotation(k, R_site)
B = [transpose(V) \ b for b in B]

if size(B, 2) > 0
terms = String[]
for b in reverse(B)
# map expansion for i_ref to expansion for relevant site i
b = V * b

# reverse b elements to print q-components in ascending order, q=-k...k
ops = String[]
for (b_q, q) in zip(reverse(b), -k:k)
Expand Down
28 changes: 14 additions & 14 deletions test/test_symmetry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -390,20 +390,23 @@ end
"""

capt = IOCapture.capture() do
print_site(cryst, 2; i_ref=1)
print_site(cryst, 5; i_ref=2)
end
@test capt.output == """
Atom 2
Position [1/4, 1/4, 0], multiplicity 16
Allowed g-tensor: [ A B -B
B A -B
-B -B A]
Atom 5
Position [1/4, 0, 1/4], multiplicity 16
Allowed g-tensor: [ A -B B
-B A -B
B -B A]
Allowed anisotropy in Stevens operators:
c₁*(4𝒪[2,-2]-2𝒪[2,-1]-(1/2)𝒪[2,1]) +
c₂*(-6𝒪[4,-4]-(11/2)𝒪[4,-3]+25𝒪[4,-2]+(23/2)𝒪[4,-1]+(1/2)𝒪[4,1]+(1/2)𝒪[4,3]) + c₃*((89/4)𝒪[4,0]-(17/4)𝒪[4,2]+(3/4)𝒪[4,4]) +
c₄*(11𝒪[6,-6]+(3/2)𝒪[6,-5]-6𝒪[6,-4]-(7/2)𝒪[6,-3]-7𝒪[6,-2]-(25/2)𝒪[6,-1]-(179/16)𝒪[6,1]+(65/16)𝒪[6,3]-(3/16)𝒪[6,5]) + c₅*(-(659/8)𝒪[6,0]-(31/8)𝒪[6,2]+(137/8)𝒪[6,4]-(31/8)𝒪[6,6]) + c₆*(15𝒪[6,-6]-(17/2)𝒪[6,-5]-62𝒪[6,-4]+(93/2)𝒪[6,-3]+101𝒪[6,-2]-(109/2)𝒪[6,-1]-(161/16)𝒪[6,1]+(27/16)𝒪[6,3]-(17/16)𝒪[6,5])
c₁*(𝒪[2,-2]+2𝒪[2,-1]-2𝒪[2,1]) +
c₂*(7𝒪[4,-3]+2𝒪[4,-2]-𝒪[4,-1]+𝒪[4,1]+7𝒪[4,3]) + c₃*(𝒪[4,0]+5𝒪[4,4]) +
c₄*(-11𝒪[6,-6]-8𝒪[6,-3]+𝒪[6,-2]-8𝒪[6,-1]+8𝒪[6,1]-8𝒪[6,3]) + c₅*(-𝒪[6,0]+21𝒪[6,4]) + c₆*(9𝒪[6,-6]+24𝒪[6,-5]+5𝒪[6,-2]+8𝒪[6,-1]-8𝒪[6,1]-24𝒪[6,5])
"""

𝒪 = stevens_matrices(4)
@test Sunny.is_anisotropy_valid(cryst, 5, 7𝒪[4,-3]+2𝒪[4,-2]-𝒪[4,-1]+𝒪[4,1]+7𝒪[4,3])

capt = IOCapture.capture() do
print_suggested_frame(cryst, 2)
end
Expand Down Expand Up @@ -481,11 +484,8 @@ end
"""

# These operators should be symmetry allowed
s = 4
sys = System(cryst, [1 => Moment(; s, g=2), 2 => Moment(; s, g=2)], :dipole)
O = stevens_matrices(s)
set_onsite_coupling!(sys, O[6,-1]+0.997385420O[6,1], 2)
set_onsite_coupling!(sys, rotate_operator(O[6,2], R), 2)
@test Sunny.is_anisotropy_valid(cryst, 2, 𝒪[6,-1]+0.997385420𝒪[6,1])
@test Sunny.is_anisotropy_valid(cryst, 2, rotate_operator(𝒪[6,2], R))
end


Expand Down

0 comments on commit 5a97da6

Please sign in to comment.