SunnySuite / Sunny.jl

Spin dynamics and generalization to SU(N) coherent states
Other
84 stars 19 forks source link

Possible inconsistency in printed allowed symmetries #241

Closed kbarros closed 7 months ago

kbarros commented 7 months ago

From Bhushan on Slack:


using Sunny, GLMakie

a = b = 4.05012 
c = 6.75214     
latvecs = lattice_vectors(a, b, c, 90, 90, 120) 
positions = [[0, 0, 0], [1/3, 2/3, 1/4], [2/3, 1/3, 3/4]]  

types = ["Fe", "I", "I"]
FeI2 = Crystal(latvecs, positions; types)
cryst = subcrystal(FeI2, "Fe")
#GLMakie.activate!()
#view_crystal(cryst)
print_symmetry_table(cryst,8)

Sunny.all_symmetry_related_bonds_for_atom(cryst,1,Bond(1, 1, [1, 0, 0]))

print_bond(cryst, Bond(1, 1, [0, 1, 0]))
basis=Sunny.basis_for_symmetry_allowed_couplings(cryst,Bond(1, 1, [0, 1, 0]))

###The basis for A is wrong. For example: in the first row first column element,
###there should be 1/4 but its normalized to one and  first row, 2nd column element should be non zero. 
###The other three basis are correct, there is only an issue with the first one.
kbarros commented 7 months ago

I think it is working as expected. Maybe Bhushan intended to call basis_for_exchange_on_bond, which includes logic for performing transformations relative to a reference bond. See usage example below. The choice b_ref=nothing refers to the reference bond that appears in print_symmetry_table. To have discovered basis_for_exchange_on_bond, one could inspect the code for print_bond.

Beware: Any function that must be accessed as Sunny.* (including these ones) is an internal function. Any code that uses these functions will easily break with new Sunny releases.

b = Bond(1, 1, [0, 1, 0])
basis = Sunny.basis_for_exchange_on_bond(cryst, b; b_ref=nothing) # Alternatively, b_ref=b
for (basis_matrix, letter) in zip(basis, 'A':'Z')
    basis_strs = Sunny.coupling_basis_strings([(letter, basis_matrix)]; digits=3, atol=1e-8)
    println(Sunny.formatted_matrix(basis_strs; prefix="Basis matrix: "))
end

#=
Basis matrix: [  (1/4)A -(√3/4)A 0
               -(√3/4)A   (3/4)A 0
                      0        0 0]
Basis matrix: [ (3/4)B (√3/4)B 0
               (√3/4)B  (1/4)B 0
                     0       0 0]
Basis matrix: [0 0 0
               0 0 0
               0 0 C]
Basis matrix: [       0       0 -(√3/2)D
                      0       0  -(1/2)D
               -(√3/2)D -(1/2)D        0]
=#