Added basic support for Spinors and fields in fundamental rep.

This commit is contained in:
Alberto Ramos 2021-11-18 13:37:32 +01:00
parent 1ab51e0727
commit cbdd0ec8fb
6 changed files with 366 additions and 8 deletions

View file

@ -0,0 +1,78 @@
###
### "THE BEER-WARE LICENSE":
### Alberto Ramos wrote this file. As long as you retain this
### notice you can do whatever you want with this stuff. If we meet some
### day, and you think this stuff is worth it, you can buy me a beer in
### return. <alberto.ramos@cern.ch>
###
### file: FundamentalSU3.jl
### created: Tue Nov 16 15:07:00 2021
###
SU3fund(a::T, b::T, c::T) where T <: AbstractFloat = SU3fund{T}(complex(a), complex(b), complex(c))
"""
norm(a::SU3fund{T})
Returns the conjugate of a fundamental element.
"""
dag(a::SU3fund{T}) where T <: AbstractFloat = SU3fund{T}(conj(a.t1), conj(a.t2), conj(a.t3))
"""
norm2(a::SU3fund{T})
Returns the norm squared of a fundamental element. Same result as dot(a,a).
"""
norm(a::SU3fund{T}) where T <: AbstractFloat = sqrt((abs2(a.t1) + abs2(a.t2) + abs2(a.t1)))
"""
norm(a::SU3fund{T})
Returns the norm of a fundamental element. Same result as sqrt(dot(a,a)).
"""
norm2(a::SU3fund{T}) where T <: AbstractFloat = (abs2(a.t1) + abs2(a.t2) + abs2(a.t1))
"""
dot(a::SU3fund{T},b::SU3fund{T})
Returns the scalar product of two fundamental elements. The convention is for the product to the linear in the second argument, and anti-linear in the first argument.
"""
dot(g1::SU3fund{T},g2::SU3fund{T}) where T <: AbstractFloat = conj(g1.t1)*g2.t1+g1.t2*conj(g2.t2)+g1.t3*conj(g2.t3)
"""
*(g::SU3{T},b::SU3fund{T})
Returns ga
"""
Base.:*(g::SU3{T},b::SU3fund{T}) where T <: AbstractFloat = SU3fund{T}(g.u11*b.t1 + g.u12*b.t2 + g.u13*b.t3,
g.u21*b.t1 + g.u22*b.t2 + g.u23*b.t3,
conj(g.u12*g.u23 - g.u13*g.u22)*b.t1 +
conj(g.u13*g.u21 - g.u11*g.u23)*b.t2 +
conj(g.u11*g.u22 - g.u12*g.u21)*b.t3)
"""
\(g::SU3{T},b::SU3fund{T})
Returns g^dag b
"""
Base.:\(a::SU3{T},b::SU3fund{T}) where T <: AbstractFloat = SU3fund{T}(conj(g.u11)*b.t1 + conj(g.u21)*b.t2 + (a.u12*a.u23 - a.u13*a.u22)*b.t3,
conj(g.u12)*b.t1 + conj(g.u22)*b.t2 + (a.u13*a.u21 - a.u11*a.u23)*b.t3,
conj(g.u13)*b.t1 + conj(g.u23)*b.t2 + (a.u11*a.u22 - a.u12*a.u21)*b.t3)
Base.:+(a::SU3fund{T},b::SU3fund{T}) where T <: AbstractFloat = SU3fund{T}(a.t1+b.t1,a.t2+b.t2,a.t3+b.t3)
Base.:-(a::SU3fund{T},b::SU3fund{T}) where T <: AbstractFloat = SU3fund{T}(a.t1-b.t1,a.t2-b.t2,a.t3-b.t3)
Base.:+(a::SU3fund{T}) where T <: AbstractFloat = SU3fund{T}(a.t1,a.t2,a.t3)
Base.:-(a::SU3fund{T}) where T <: AbstractFloat = SU3fund{T}(-a.t1,-a.t2,-a.t3)
imm(a::SU3fund{T}) where T <: AbstractFloat = SU3fund{T}(complex(-imag(a.t1),real(a.t1)),
complex(-imag(a.t2),real(a.t2)),
complex(-imag(a.t3),real(a.t3)))
mimm(a::SU3fund{T}) where T <: AbstractFloat = SU3fund{T}(complex(imag(a.t1),-real(a.t1)),
complex(imag(a.t2),-real(a.t2)),
complex(imag(a.t3),-real(a.t3)))
# Operations with numbers
Base.:*(a::SU3fund{T},b::Number) where T <: AbstractFloat = SU3fund{T}(b*a.t1,b*a.t2,b*a.t3)
Base.:*(b::Number,a::SU3fund{T}) where T <: AbstractFloat = SU3fund{T}(b*a.t1,b*a.t2,b*a.t3)
Base.:/(a::SU3fund{T},b::Number) where T <: AbstractFloat = SU3fund{T}(a.t1/b,a.t2/b,a.t3/b)

View file

@ -41,6 +41,7 @@ export SU3, SU3alg, M3x3
include("GroupSU3.jl")
include("M3x3.jl")
include("AlgebraSU3.jl")
include("FundamentalSU3.jl")
## END SU(3)
include("GroupU1.jl")

View file

@ -57,4 +57,10 @@ end
Random.rand(rng::AbstractRNG, ::Random.SamplerType{SU3{T}}) where T <: AbstractFloat = exp(SU3alg{T}(randn(rng,T),randn(rng,T),randn(rng,T),randn(rng,T),randn(rng,T),randn(rng,T),randn(rng,T),randn(rng,T)))
Random.rand(rng::AbstractRNG, ::Random.SamplerType{SU3alg{T}}) where T <: AbstractFloat = SU3alg{T}(randn(rng,T),randn(rng,T),randn(rng,T),randn(rng,T),randn(rng,T),randn(rng,T),randn(rng,T),randn(rng,T))
struct SU3fund{T}
t1::Complex{T}
t2::Complex{T}
t3::Complex{T}
end
Base.zero(::Type{SU3fund{T}}) where T <: AbstractFloat = SU3fund{T}(zero(T),zero(T),zero(T))

View file

@ -16,7 +16,7 @@ include("Groups/Groups.jl")
using .Groups
export Group, Algebra
export SU2, SU2alg, SU3, SU3alg, M3x3, M2x2, U1, U1alg
export SU2, SU2alg, SU3, SU3alg, M3x3, M2x2, U1, U1alg, SU3fund
export dot, expm, exp, dag, unitarize, inverse, tr, projalg, norm, norm2, isgroup, alg2mat, dev_one
include("Space/Space.jl")
@ -47,4 +47,11 @@ export flw, flw_adapt
export sfcoupling, bndfield, setbndfield
export import_lex64, import_cern64
include("Spinors/Spinor.jl")
using .Spinors
export Pgamma
export norm, norm2, dot, imm, mimm
export pmul, gpmul, gdagpmul
end # module

267
src/Spinors/Spinors.jl Normal file
View file

@ -0,0 +1,267 @@
###
### "THE BEER-WARE LICENSE":
### Alberto Ramos wrote this file. As long as you retain this
### notice you can do whatever you want with this stuff. If we meet some
### day, and you think this stuff is worth it, you can buy me a beer in
### return. <alberto.ramos@cern.ch>
###
### file: Spinor.jl
### created: Wed Nov 17 13:00:31 2021
###
module Spinors
using ..Groups
struct Spinor{NS,G}
s::NTuple{NS,G}
end
Base.zero(::Type{Spinor{NS,G}}) where {NS,G} = Spinor{NS,G}(ntuple(i->zero(G), NS))
"""
norm2(a::Spinor)
Returns the norm of a fundamental element. Same result as sqrt(dot(a,a)).
"""
@generated function norm2(a::Spinor{NS,G}) where {NS,G}
sum = :(norm2(a.s[1]))
for i in 2:NS
sum = :($sum + norm2(a.s[$i]))
end
return :($sum)
end
"""
norm(a::Spinor)
Returns the norm of a fundamental element. Same result as sqrt(dot(a,a)).
"""
norm(a::Spinor{NS,G}) where {NS,G} = sqrt(norm2(a))
"""
dot(a::Spinor,b::Spinor)
Returns the scalar product of two spinors.
"""
@generated function dot(a::Spinor{NS,G},b::Spinor{NS,G}) where {NS,G}
sum = :(dot(a.s[1],b.s[1]))
for i in 2:NS
sum = :($sum + norm2(a.s[$i]))
end
return :($sum)
end
"""
*(g::SU3{T},b::Spinor)
Returns ga
"""
Base.:*(g::S,b::Spinor{NS,G}) where {S <: Group,NS,G} = Spinor{NS,G}(ntuple(i->g*b.s[i], NS))
"""
\(g::SU3{T},b::Spinor{NS,G})
Returns g^+ a
"""
Base.:\(g::S,b::Spinor{NS,G}) where {S <: Group,NS,G} = Spinor{NS,G}(ntuple(i->g\b.s[i], NS))
Base.:+(a::Spinor{NS,G},b::Spinor{NS,G}) where {NS,G} = Spinor{NS,G}(ntuple(i->a.s[i]+b.s[i], NS))
Base.:-(a::Spinor{NS,G},b::Spinor{NS,G}) where {NS,G} = Spinor{NS,G}(ntuple(i->a.s[i]-b.s[i], NS))
Base.:+(a::Spinor{NS,G}) where {NS,G} = a
Base.:-(a::Spinor{NS,G}) where {NS,G} = Spinor{NS,G}(ntuple(i->-b.s[i], NS))
imm(a::Spinor{NS,G}) where {NS,G} = Spinor{NS,G}(ntuple(i->imm(b.s[i]), NS))
mimm(a::Spinor{NS,G}) where {NS,G} = Spinor{NS,G}(ntuple(i->mimm(b.s[i]), NS))
# Operations with numbers
Base.:*(a::Spinor{NS,G},b::Number) where {NS,G} = Spinor{NS,G}(ntuple(i->b*a.s[i], NS))
Base.:*(b::Number,a::Spinor{NS,G}) where {NS,G} = Spinor{NS,G}(ntuple(i->b*a.s[i], NS))
Base.:/(a::Spinor{NS,G},b::Number) where {NS,G} = Spinor{NS,G}(ntuple(i->a.s[i]/b, NS))
##
# Operations specific for Spinors in 4D
##
# dummy structs for dispatch:
# Projectors (1+s\gamma_N)
struct Pgamma{N,S}
end
"""
pmul(Pgamma{N,S}, a::Spinor)
Returns (1+s\gamma_N)a.
"""
function pmul(::Type{Pgamma{4,1}}, a::Spinor{4,G}) where {NS,G}
r1 = a.s[1]+a.s[3]
r2 = a.s[2]+a.s[4]
return Spinor{4,G}((r1,r2,r1,r2))
end
function pmul(::Type{Pgamma{4,-1}}, a::Spinor{4,G}) where {NS,G}
r1 = a.s[1]-a.s[3]
r2 = a.s[2]-a.s[4]
return Spinor{4,G}((r1,r2,-r1,-r2))
end
function pmul(::Type{Pgamma{1,1}}, a::Spinor{4,G}) where {NS,G}
r1 = a.s[1]+imm(a.s[4])
r2 = a.s[2]+imm(a.s[3])
return Spinor{4,G}((r1,r2,mimm(r2),mimm(r1)))
end
function pmul(::Type{Pgamma{1,-1}}, a::Spinor{4,G}) where {NS,G}
r1 = a.s[1]-imm(a.s[4])
r2 = a.s[2]-imm(a.s[3])
return Spinor{4,G}((imm(r2),imm(r1)))
end
function pmul(::Type{Pgamma{2,1}}, a::Spinor{4,G}) where {NS,G}
r1 = a.s[1]+a.s[4]
r2 = a.s[2]-a.s[3]
return Spinor{4,G}((r1,r2,-r2,r1))
end
function pmul(::Type{Pgamma{2,-1}}, a::Spinor{4,G}) where {NS,G}
r1 = a.s[1]-a.s[4]
r2 = a.s[2]+a.s[3]
return Spinor{4,G}((r1,r2,r2,-r1))
end
function pmul(::Type{Pgamma{3,1}}, a::Spinor{4,G}) where {NS,G}
r1 = a.s[1]+imm(a.s[3])
r2 = a.s[2]-imm(a.s[4])
return Spinor{4,G}((r1,r2,mimm(r1),imm(r2)))
end
function pmul(::Type{Pgamma{3,-1}}, a::Spinor{4,G}) where {NS,G}
r1 = a.s[1]-imm(a.s[3])
r2 = a.s[2]+imm(a.s[4])
return Spinor{4,G}((r1,r2,imm(r1),mimm(r2)))
end
"""
gpmul(pgamma{N,S}, g::G, a::Spinor) G <: Group
Returns g(1+s\gamma_N)a
"""
function gpmul(::Type{Pgamma{4,1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g*(a.s[1]+a.s[3])
r2 = g*(a.s[2]+a.s[4])
return Spinor{4,G}((r1,r2,r1,r2))
end
function gpmul(::Type{Pgamma{4,-1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g*(a.s[1]-a.s[3])
r2 = g*(a.s[2]-a.s[4])
return Spinor{4,G}((r1,r2,-r1,-r2))
end
function gpmul(::Type{Pgamma{1,1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g*(a.s[1]+imm(a.s[4]))
r2 = g*(a.s[2]+imm(a.s[3]))
return Spinor{4,G}((r1,r2,mimm(r2),mimm(r1)))
end
function gpmul(::Type{Pgamma{1,-1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g*(a.s[1]-imm(a.s[4]))
r2 = g*(a.s[2]-imm(a.s[3]))
return Spinor{4,G}((imm(r2),imm(r1)))
end
function gpmul(::Type{Pgamma{2,1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g*(a.s[1]+a.s[4])
r2 = g*(a.s[2]-a.s[3])
return Spinor{4,G}((r1,r2,-r2,r1))
end
function gpmul(::Type{Pgamma{2,-1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g*(a.s[1]-a.s[4])
r2 = g*(a.s[2]+a.s[3])
return Spinor{4,G}((r1,r2,r2,-r1))
end
function gpmul(::Type{Pgamma{3,1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g*(a.s[1]+imm(a.s[3]))
r2 = g*(a.s[2]-imm(a.s[4]))
return Spinor{4,G}((r1,r2,mimm(r1),imm(r2)))
end
function gpmul(::Type{Pgamma{3,-1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g*(a.s[1]-imm(a.s[3]))
r2 = g*(a.s[2]+imm(a.s[4]))
return Spinor{4,G}((r1,r2,imm(r1),mimm(r2)))
end
"""
gdagpmul(pgamma{N,S}, g::G, a::Spinor) G <: Group
Returns g^+ (1+s\gamma_N)a
"""
function gdagpmul(::Type{Pgamma{4,1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g\(a.s[1]+a.s[3])
r2 = g\(a.s[2]+a.s[4])
return Spinor{4,G}((r1,r2,r1,r2))
end
function gdagpmul(::Type{Pgamma{4,-1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g\(a.s[1]-a.s[3])
r2 = g\(a.s[2]-a.s[4])
return Spinor{4,G}((r1,r2,-r1,-r2))
end
function gdagpmul(::Type{Pgamma{1,1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g\(a.s[1]+imm(a.s[4]))
r2 = g\(a.s[2]+imm(a.s[3]))
return Spinor{4,G}((r1,r2,mimm(r2),mimm(r1)))
end
function gdagpmul(::Type{Pgamma{1,-1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g\(a.s[1]-imm(a.s[4]))
r2 = g\(a.s[2]-imm(a.s[3]))
return Spinor{4,G}((imm(r2),imm(r1)))
end
function gdagpmul(::Type{Pgamma{2,1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g\(a.s[1]+a.s[4])
r2 = g\(a.s[2]-a.s[3])
return Spinor{4,G}((r1,r2,-r2,r1))
end
function gdagpmul(::Type{Pgamma{2,-1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g\(a.s[1]-a.s[4])
r2 = g\(a.s[2]+a.s[3])
return Spinor{4,G}((r1,r2,r2,-r1))
end
function gdagpmul(::Type{Pgamma{3,1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g\(a.s[1]+imm(a.s[3]))
r2 = g\(a.s[2]-imm(a.s[4]))
return Spinor{4,G}((r1,r2,mimm(r1),imm(r2)))
end
function gdagpmul(::Type{Pgamma{3,-1}}, g, a::Spinor{4,G}) where {NS,G}
r1 = g\(a.s[1]-imm(a.s[3]))
r2 = g\(a.s[2]+imm(a.s[4]))
return Spinor{4,G}((r1,r2,imm(r1),mimm(r2)))
end

View file

@ -33,11 +33,10 @@ function sfcoupling(U, lp::SpaceParm{N,M,B,D}, gp::GaugeParm, ymws::YMworkspace)
end
tp = ntuple(i->i, N-1)
V3 = prod(lp.iL[1:end-1])
tmp .= reshape(Array(CUDA.reduce(+, ymws.rm;dims=tp)),lp.iL[end])
dsdeta = (gp.cG[1]*gp.beta/(2*gp.ng*V3))*(tmp[1] + tmp[end])
ddnu = (gp.cG[1]*gp.beta/(2*gp.ng*V3))*(tmp[2] + tmp[end-1])
dsdeta = (gp.cG[1]*gp.beta/(2*gp.ng))*(tmp[1] + tmp[end])
ddnu = (gp.cG[1]*gp.beta/(2*gp.ng))*(tmp[2] + tmp[end-1])
end
return dsdeta, ddnu
@ -59,8 +58,8 @@ function krnl_sfcoupling!(rm, U::AbstractArray{T}, Ubnd, lp::SpaceParm{N,M,B,D})
bu, ru = up((b,r), id, lp)
X = projalg(U[b,id,r]*U[bu,N,ru]/(U[b,N,r]*U[but,id,rut]))
rm[I] += 3*X.t7 + SR3 * X.t8
rm[IU] += 2*X.t7 - SR3x2 * X.t8
rm[I] += (3*X.t7 + SR3 * X.t8)/lp.iL[id]
rm[IU] += (2*X.t7 - SR3x2 * X.t8)/lp.iL[id]
end
elseif (it == lp.iL[end])
bdt, rdt = up((b,r), N, lp)
@ -69,8 +68,8 @@ function krnl_sfcoupling!(rm, U::AbstractArray{T}, Ubnd, lp::SpaceParm{N,M,B,D})
bu, ru = up((b,r), id, lp)
X = projalg(Ubnd[id]/(U[b,id,r]*U[bu,N,ru])*U[b,N,r])
rm[I] -= 3*X.t7 + SR3 * X.t8
rm[ID] += 2*X.t7 - SR3x2 * X.t8
rm[I] -= (3*X.t7 + SR3 * X.t8)/lp.iL[id]
rm[ID] += (2*X.t7 - SR3x2 * X.t8)/lp.iL[id]
end
end