You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# The generalized Clebsch Gordan Coefficients; variables of this function are fully inherited from the first ACE paper
50
+
# The generalized Clebsch Gordan Coefficients; variables of this function are
51
+
# fully inherited from the first ACE paper.
16
52
function GCG(l::SVector{N,Int64},m::SVector{N,Int64},L::SVector{N,Int64},M_N::Int64;flag=:cSH) where N
17
53
# @assert -L[N] ≤ M_N ≤ L[N]
18
54
if m_filter(m, M_N;flag=flag) ==false|| L[1] < abs(m[1])
@@ -40,7 +76,7 @@ function GCG(l::SVector{N,Int64},m::SVector{N,Int64},L::SVector{N,Int64},M_N::In
40
76
mm = SA[mm...]
41
77
@assert sum(mm) == M
42
78
C_loc = GCG(l,mm,L,M;flag=:cSH)
43
-
coeff = Ctran(M_N,M;convention=flag)'* prod( RepLieGroups.O3.Ctran(m[i],mm[i];convention=flag) for i in1:N )
79
+
coeff = Ctran(M_N,M;convention=flag)'* prod( Ctran(m[i],mm[i];convention=flag) for i in1:N )
44
80
C_loc *= coeff
45
81
C += C_loc
46
82
end
@@ -165,25 +201,113 @@ end
165
201
# Function that generates the set of ordered m's given `n` and `l` with the abosolute sum of m's being smaller than L.
166
202
m_generate(n,l,L;flag=:cSH) = union([m_generate(n,l,L,k;flag)[1] for k in-L:L]...), sum(length.(union([m_generate(n,l,L,k;flag)[1] for k in-L:L]...))) # orginal version: sum(m_generate(n,l,L,k;flag)[2] for k in -L:L), but this cannot be true anymore b.c. the m_classes can intersect
167
203
204
+
function gram(X::Matrix{SVector{N,T}}) where {N,T}
205
+
G = zeros(T, size(X,1), size(X,1))
206
+
for i =1:size(X,1)
207
+
for j = i:size(X,1)
208
+
G[i,j] = sum(dot(X[i,t], X[j,t]) for t =1:size(X,2))
209
+
i == j ?nothing: (G[j,i]=G[i,j]')
210
+
end
211
+
end
212
+
return G
213
+
end
214
+
215
+
gram(X::Matrix{<:Number}) = X * X'
216
+
217
+
function lexi_ord(nn::SVector{N, Int64}, ll::SVector{N, Int64}) where N
Compute coupling coefficients for the spherical harmonics basis, where
228
+
- `L` must be an `Integer`;
229
+
- `ll, nn` must be vectors or tuples of `Integer` of the same length.
230
+
- `PI`: whether or not the coupled basis is permutation-invariant (or the
231
+
corresponding tensor symmetric); default is `true` when `nn` is provided
232
+
and `false` when `nn` is not provided.
233
+
- `basis`: which basis is being coupled, default is `complex`, alternative
234
+
choice is `real`, which is compatible with the `SpheriCart.jl` convention.
235
+
"""
236
+
function coupling_coeffs(L::Integer, ll, nn = nothing;
237
+
PI = !(isnothing(nn)),
238
+
basis = complex)
239
+
240
+
# convert L into the format required internally
241
+
_L = Int(L)
242
+
243
+
# convert ll into an SVector{N, Int}, as required internally
244
+
N = length(ll)
245
+
_ll = try
246
+
_ll = SVector{N, Int}(ll...)
247
+
catch
248
+
error("""coupling_coeffs(L::Integer, ll, ...) requires ll to be
249
+
a vector or tuple of integers""")
250
+
end
168
251
169
-
# Function that generates the coupling coefficient of the RE basis given `n` and `l`., the FMatrix for generating the RPE basis is also generated here.
170
-
function re_rpe(n::SVector{N,Int64},l::SVector{N,Int64},L::Int64;flag=:cSH) where N
171
-
Lset = SetLl(l,L)
252
+
# convert nn into an SVector{N, Int}, as required internally
253
+
if isnothing(nn)
254
+
if PI
255
+
_nn = SVector{N, Int}(ntuple(i -> 0, N)...)
256
+
else
257
+
_nn = SVector{N, Int}((1:N)...)
258
+
end
259
+
elseif length(nn) != N
260
+
error("""coupling_coeffs(L::Integer, ll, nn) requires ll and nn to be
261
+
of the same length""")
262
+
else
263
+
_nn = try
264
+
_nn = SVector{N, Int}(nn...)
265
+
catch
266
+
error("""coupling_coeffs(L::Integer, ll, nn) requires nn to be
267
+
a vector or tuple of integers""")
268
+
end
269
+
end
270
+
271
+
if basis == complex
272
+
flag = :cSH
273
+
elseif basis == real
274
+
flag = :SpheriCart
275
+
elseif basis isa Symbol
276
+
flag = basis
277
+
else
278
+
error("unknown basis type: $basis")
279
+
end
280
+
281
+
return _coupling_coeffs(_L, _ll, _nn; PI = PI, flag = flag)
282
+
end
283
+
284
+
285
+
# Function that generates the coupling coefficient of the RE basis (PI = false)
286
+
# or RPE basis (PI = true) given `nn` and `ll`.
287
+
function _coupling_coeffs(L::Int64, ll::SVector{N, Int64}, nn::SVector{N, Int64};
0 commit comments