From 5a97da6b493660d28e3d3266083025576f3f31f1 Mon Sep 17 00:00:00 2001 From: Kipton Barros Date: Mon, 9 Dec 2024 08:31:55 -0700 Subject: [PATCH] Fixes --- Project.toml | 2 +- src/Operators/Rotation.jl | 2 +- src/Symmetry/AllowedAnisotropy.jl | 2 +- src/Symmetry/Printing.jl | 12 +++++++----- test/test_symmetry.jl | 28 ++++++++++++++-------------- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Project.toml b/Project.toml index 80d8b3edf..5b67ccde1 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/Operators/Rotation.jl b/src/Operators/Rotation.jl index 8e45cfa10..f7a259685 100644 --- a/src/Operators/Rotation.jl +++ b/src/Operators/Rotation.jl @@ -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) diff --git a/src/Symmetry/AllowedAnisotropy.jl b/src/Symmetry/AllowedAnisotropy.jl index 1ccf4f5ff..79dc80c0f 100644 --- a/src/Symmetry/AllowedAnisotropy.jl +++ b/src/Symmetry/AllowedAnisotropy.jl @@ -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) diff --git a/src/Symmetry/Printing.jl b/src/Symmetry/Printing.jl index b4e57d43a..e4ecc083d 100644 --- a/src/Symmetry/Printing.jl +++ b/src/Symmetry/Printing.jl @@ -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) @@ -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) diff --git a/test/test_symmetry.jl b/test/test_symmetry.jl index dee420a03..7f6b41591 100644 --- a/test/test_symmetry.jl +++ b/test/test_symmetry.jl @@ -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 @@ -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