5959"""
6060Symmetrize the Hubbard occupation matrix according to the l quantum number of the manifold.
6161"""
62- function symmetrize_nhub (nhubbard:: Array{Matrix{Complex{T}}} , lattice, symmetry , positions) where {T}
62+ function symmetrize_nhub (nhubbard:: Array{Matrix{Complex{T}}} , lattice, symmetries , positions) where {T}
6363 # For now we apply symmetries only on nII terms, not on cross-atom terms (nIJ)
6464 # WARNING: To implement +V this will need to be changed!
6565
6666 nspins = size (nhubbard, 1 )
6767 natoms = size (nhubbard, 2 )
68- nsym = length (symmetry )
68+ nsym = length (symmetries )
6969 l = Int64 ((size (nhubbard[1 , 1 , 1 ], 1 )- 1 )/ 2 )
70- WigD = Wigner_sym (l, lattice, symmetry)
7170
7271 # Initialize the nhubbard matrix
7372 ns = Array {Matrix{Complex{T}}} (undef, nspins, natoms, natoms)
@@ -77,52 +76,22 @@ function symmetrize_nhub(nhubbard::Array{Matrix{Complex{T}}}, lattice, symmetry,
7776 size (nhubbard[σ, iatom, jatom], 2 ))
7877 end
7978
80- for σ in 1 : nspins, iatom in 1 : natoms, isym in 1 : nsym
81- for m1 in 1 : size (ns[σ, iatom, iatom], 1 ), m2 in 1 : size (ns[σ, iatom, iatom], 2 )
82- sym_atom = find_symmetry_preimage (positions, positions[iatom], symmetry[isym])
83- # TODO : Here QE flips spin for time-reversal in collinear systems, should we?
84- for m0 in 1 : size (nhubbard[σ, iatom, iatom], 1 ), m00 in 1 : size (nhubbard[σ, iatom, iatom], 2 )
85- ns[σ, iatom, iatom][m1, m2] += WigD[m0, m1, isym] *
86- nhubbard[σ, sym_atom, sym_atom][m0, m00] *
87- WigD[m00, m2, isym]
88- end
89- end
90- end
91- ns .= ns / nsym
92- end
93-
94- """
95- This function returns the Wigner matrix for a given l and symmetry operation
96- solving a randomized linear system.
97- The lattice L is needed to convert reduced symmetries to Cartesian space.
98- """
99- function Wigner_sym (l:: Int64 , L, symmetries:: Vector{SymOp{T}} ) where {T}
100- nsym = length (symmetries)
101- D = Array {Float64} (undef, 2 * l+ 1 , 2 * l+ 1 , nsym)
102- if l == 0
103- return D .= 1
104- end
105- Random. seed! (1234 )
106- for (isym, symmetry) in enumerate (symmetries)
107- W = symmetry. W
108- for m1 in - l: l
109- b = Vector {Float64} (undef, 2 * l+ 1 )
110- A = Matrix {Float64} (undef, 2 * l+ 1 , 2 * l+ 1 )
111- for n in 1 : 2 * l+ 1
112- r = rand (Float64, 3 )
113- r = r / norm (r)
114- r0 = L * W * inv (L) * r
115- b[n] = DFTK. ylm_real (l, m1, r0)
116- for m2 in - l: l
117- A[n,m2+ l+ 1 ] = DFTK. ylm_real (l, m2, r)
79+ for symmetry in symmetries
80+ Wcart = lattice * symmetry. W * inv (lattice)
81+ WigD = wigner_d_matrix (l, Wcart)
82+ for σ in 1 : nspins, iatom in 1 : natoms
83+ sym_atom = find_symmetry_preimage (positions, positions[iatom], symmetry)
84+ for m1 in 1 : size (ns[σ, iatom, iatom], 1 ), m2 in 1 : size (ns[σ, iatom, iatom], 2 )
85+ # TODO : Here QE flips spin for time-reversal in collinear systems, should we?
86+ for m0 in 1 : size (nhubbard[σ, iatom, iatom], 1 ), m00 in 1 : size (nhubbard[σ, iatom, iatom], 2 )
87+ ns[σ, iatom, iatom][m1, m2] += WigD[m0, m1] *
88+ nhubbard[σ, sym_atom, sym_atom][m0, m00] *
89+ WigD[m00, m2]
11890 end
11991 end
120- @assert cond (A) > 1 / 2 " The Wigner matrix computaton is badly conditioned."
121- D[m1+ l+ 1 ,:,isym] = A\ b
12292 end
12393 end
124-
125- return D
94+ ns .= ns / nsym
12695end
12796
12897"""
@@ -243,7 +212,7 @@ struct Hubbard
243212 U
244213end
245214function (hubbard:: Hubbard )(basis:: AbstractBasis )
246- isempty (hubbard. U) && return TermNoop ()
215+ iszero (hubbard. U) && return TermNoop ()
247216 projs, labs = atomic_orbital_projectors (basis)
248217 labels, projectors = extract_manifold (basis, projs, labs, hubbard. manifold)
249218 U = austrip (hubbard. U)
0 commit comments