mirror of
https://igit.ific.uv.es/alramos/latticegpu.jl.git
synced 2025-05-14 19:23:42 +02:00
Addition of conversion group,algebra to generit matrices for SU(3)
This commit is contained in:
parent
a5e7cfd8b0
commit
afd837e80d
9 changed files with 19 additions and 305 deletions
|
@ -59,6 +59,8 @@ Base.:*(a::SU3alg{T},b::Number) where T <: AbstractFloat = SU3alg{T}(b*a.t1,b
|
|||
Base.:*(b::Number,a::SU3alg{T}) where T <: AbstractFloat = SU3alg{T}(b*a.t1,b*a.t2,b*a.t3,b*a.t4,b*a.t5,b*a.t6,b*a.t7,b*a.t8)
|
||||
Base.:/(a::SU3alg{T},b::Number) where T <: AbstractFloat = SU3alg{T}(a.t1/b,a.t2/b,a.t3/b,a.t4/b,a.t5/b,a.t6/b,a.t7/b,a.t8/b)
|
||||
|
||||
Base.:*(a::SU3alg{T},b::SU3alg{T}) where T = convert(M3x3{T}, a)*convert(M3x3{T}, a)
|
||||
|
||||
|
||||
function alg2mat(a::SU3alg{T}) where T <: AbstractFloat
|
||||
|
||||
|
|
|
@ -71,6 +71,9 @@ function Base.:/(a::M3x3{T},b::SU3{T}) where T <: AbstractFloat
|
|||
a.u31*conj(b.u21) + a.u32*conj(b.u22) + a.u33*conj(b.u23),
|
||||
a.u31*(bu31) + a.u32*(bu32) + a.u33*(bu33))
|
||||
end
|
||||
Base.:/(a::M3x3{T}, b::Number) where T <: AbstractFloat = M3x3{T}(a.u11/b, a.u12/b, a.u13/b,
|
||||
a.u21/b, a.u22/b, a.u23/b,
|
||||
a.u31/b, a.u32/b, a.u33/b)
|
||||
|
||||
function Base.:\(a::SU3{T},b::M3x3{T}) where T <: AbstractFloat
|
||||
|
||||
|
@ -131,3 +134,4 @@ end
|
|||
dag(a::M3x3{T}) where T = M3x3{T}(conj(a.u11), conj(a.u21), conj(a.u31),
|
||||
conj(a.u12), conj(a.u22), conj(a.u32),
|
||||
conj(a.u13), conj(a.u23), conj(a.u33))
|
||||
tr(a::M3x3{T}) where T = a.u11+a.u22+a.u33
|
||||
|
|
|
@ -32,5 +32,8 @@ Base.zero(::Type{M2x2{T}}) where T <: AbstractFloat = M2x2{T}(zero(T),zero(T),
|
|||
Base.one(::Type{SU2{T}}) where T <: AbstractFloat = SU2{T}(one(T),zero(T))
|
||||
Base.one(::Type{M2x2{T}}) where T <: AbstractFloat = M2x2{T}(one(T),zero(T),zero(T),one(T))
|
||||
|
||||
Base.convert(::Type{M2x2{T}}, a::SU3alg{T}) where T = alg2mat(a)
|
||||
Base.convert(::Type{M2x2{T}}, a::SU3{T}) where T = M2x2{T}(a.t1,a.t2,-conj(a.t2), conj(a.t1))
|
||||
|
||||
Random.rand(rng::AbstractRNG, ::Random.SamplerType{SU2alg{T}}) where T <: AbstractFloat = SU2alg{T}(randn(rng,T),randn(rng,T),randn(rng,T))
|
||||
Random.rand(rng::AbstractRNG, ::Random.SamplerType{SU2{T}}) where T <: AbstractFloat = exp(SU2alg{T}(randn(rng,T),randn(rng,T),randn(rng,T)))
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
# a.u33 = conj(a.u11*a.u22 - a.u12*a.u21)
|
||||
#
|
||||
|
||||
import Base.convert
|
||||
|
||||
struct SU3{T} <: Group
|
||||
u11::Complex{T}
|
||||
u12::Complex{T}
|
||||
|
@ -57,6 +59,12 @@ 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))
|
||||
|
||||
Base.convert(::Type{M3x3{T}}, a::SU3alg{T}) where T = alg2mat(a)
|
||||
Base.convert(::Type{M3x3{T}}, a::SU3{T}) where T = M3x3{T}(a.u11,a.u12,a.u13,
|
||||
a.u21,a.u22,a.u23,
|
||||
conj(a.u12*a.u23 - a.u13*a.u22),
|
||||
conj(a.u13*a.u21 - a.u11*a.u23),
|
||||
conj(a.u11*a.u22 - a.u12*a.u21))
|
||||
struct SU3fund{T}
|
||||
t1::Complex{T}
|
||||
t2::Complex{T}
|
||||
|
@ -67,3 +75,4 @@ Random.rand(rng::AbstractRNG, ::Random.SamplerType{SU3fund{T}}) where T <: Abstr
|
|||
complex(randn(rng,T),randn(rng,T)),
|
||||
complex(randn(rng,T),randn(rng,T)))
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
module Spinors
|
||||
|
||||
using ..Groups
|
||||
import ..Groups.imm, ..Groups.mimm, ..Groups.norm, ..Groups.norm2
|
||||
import ..Groups.imm, ..Groups.mimm, ..Groups.norm, ..Groups.norm2, ..Groups.dot
|
||||
|
||||
struct Spinor{NS,G}
|
||||
s::NTuple{NS,G}
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
using LinearAlgebra, Random
|
||||
|
||||
import Pkg
|
||||
#Pkg.activate("/lhome/ific/a/alramos/s.images/julia/workspace/LatticeGPU")
|
||||
Pkg.activate("/home/alberto/code/julia/LatticeGPU")
|
||||
using LatticeGPU
|
||||
|
||||
|
||||
T = Float32
|
||||
|
||||
b = rand(U1{T})
|
||||
println(b)
|
||||
|
||||
ba = rand(U1alg{T})
|
||||
println("Ba: ", ba)
|
||||
b = exp(ba)
|
||||
println("B: ", b)
|
||||
c = exp(ba, convert(T,-1))
|
||||
println(typeof(norm2(ba)))
|
||||
d = b*c
|
||||
println("Test: ", d)
|
||||
|
||||
c = inverse(b)
|
||||
println("Inverse B: ", c)
|
||||
|
||||
d = b*c
|
||||
println("Test: ", d)
|
||||
|
||||
println("B: ", b)
|
||||
println("Ba: ", ba)
|
||||
b = expm(b, ba, convert(T,-1))
|
||||
println("Test: ", b)
|
||||
|
||||
|
||||
Ma = Array{U1{T}}(undef, 2)
|
||||
rand!(Ma)
|
||||
println(Ma)
|
||||
|
||||
fill!(Ma, one(eltype(Ma)))
|
||||
println(Ma)
|
|
@ -1,52 +0,0 @@
|
|||
using LinearAlgebra, Random
|
||||
|
||||
import Pkg
|
||||
#Pkg.activate("/lhome/ific/a/alramos/s.images/julia/workspace/LatticeGPU")
|
||||
Pkg.activate("/home/alberto/code/julia/LatticeGPU")
|
||||
using LatticeGPU
|
||||
|
||||
|
||||
T = Float64
|
||||
|
||||
b = rand(SU2{T})
|
||||
println(b)
|
||||
|
||||
ba = rand(SU2alg{T})
|
||||
println("Ba: ", ba)
|
||||
b = exp(ba)
|
||||
println("B: ", b)
|
||||
println(typeof(norm2(ba)))
|
||||
|
||||
c = inverse(b)
|
||||
println("Inverse B: ", c)
|
||||
|
||||
d = b*c
|
||||
println("Test: ", d)
|
||||
|
||||
c = exp(ba, -1.0)
|
||||
println("Inverse B: ", c)
|
||||
|
||||
d = b*c
|
||||
println("Test: ", d)
|
||||
|
||||
Ma = Array{SU2{T}}(undef, 2)
|
||||
rand!(Ma)
|
||||
println(Ma)
|
||||
|
||||
fill!(Ma, one(eltype(Ma)))
|
||||
println(Ma)
|
||||
|
||||
println("## Aqui test M2x2")
|
||||
ba = rand(SU2alg{T})
|
||||
ga = exp(ba)
|
||||
println("Matrix: ", alg2mat(ba))
|
||||
println("Exp: ", ga)
|
||||
|
||||
|
||||
mo = one(M2x2{T})
|
||||
println(mo)
|
||||
mp = mo*ga
|
||||
println(mp)
|
||||
println(projalg(mp))
|
||||
println(projalg(ga))
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
import Pkg
|
||||
#Pkg.activate("/lhome/ific/a/alramos/s.images/julia/workspace/LatticeGPU")
|
||||
Pkg.activate("/home/alberto/code/julia/LatticeGPU")
|
||||
using LatticeGPU, BenchmarkTools
|
||||
|
||||
|
||||
lp = SpaceParm{4}((8,12,6,6), (8,2,2,3))
|
||||
|
||||
function test_point(pt::NTuple{2,Int64}, lp::SpaceParm)
|
||||
ok = true
|
||||
println("Global point: ", global_point(pt, lp))
|
||||
for id in 1:lp.ndim
|
||||
ua, ub = up(pt, id, lp)
|
||||
println(" - UP in id $id: ", global_point((ua,ub), lp))
|
||||
|
||||
da, db = dw(pt, id, lp)
|
||||
println(" - DW in id $id: ", global_point((da,db), lp), "\n")
|
||||
|
||||
ua2, ub2, da2, db2 = updw(pt, id, lp)
|
||||
ok = ok && (ua == ua2)
|
||||
ok = ok && (ub == ub2)
|
||||
ok = ok && (da == da2)
|
||||
ok = ok && (db == db2)
|
||||
end
|
||||
return ok
|
||||
end
|
||||
|
||||
global ok = true
|
||||
for i in 1:lp.bsz, j in 1:lp.rsz
|
||||
global ok = ok && test_point((i,j), lp)
|
||||
end
|
||||
|
||||
if ok
|
||||
println("ALL tests passed")
|
||||
else
|
||||
println("ERROR in test")
|
||||
end
|
||||
|
||||
println(lp)
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
using CUDA, LinearAlgebra
|
||||
|
||||
import Pkg
|
||||
#Pkg.activate("/lhome/ific/a/alramos/s.images/julia/workspace/LatticeGPU")
|
||||
Pkg.activate("/home/alberto/code/julia/LatticeGPU")
|
||||
using LatticeGPU
|
||||
|
||||
function g2mat(g::SU3)
|
||||
|
||||
M = Array{ComplexF64, 2}(undef, 3,3)
|
||||
|
||||
M[1,1] = g.u11
|
||||
M[1,2] = g.u12
|
||||
M[1,3] = g.u13
|
||||
|
||||
M[2,1] = g.u21
|
||||
M[2,2] = g.u22
|
||||
M[2,3] = g.u23
|
||||
|
||||
M[3,1] = conj(g.u12*g.u23 - g.u13*g.u22)
|
||||
M[3,2] = conj(g.u13*g.u21 - g.u11*g.u23)
|
||||
M[3,3] = conj(g.u11*g.u22 - g.u12*g.u21)
|
||||
|
||||
return M
|
||||
end
|
||||
|
||||
|
||||
|
||||
# 0.40284714488721746 + 0.2704272209422031im -0.029482825024553627 - 0.8247329455356851im 0.28771631112777535 + 0.027366985901323956im; -0.08478364480998268 + 0.8226014762207954im -0.4790638417896126 + 0.24301903735299646im -0.022591091614522323 + 0.16452285690920823im; 0.28083864951126214 + 0.04302898862961919im 0.0066864552013863165 - 0.17418727240313508im -0.939634663641523 + 0.07732362776719631im
|
||||
|
||||
T = Float64
|
||||
a = rand(SU3alg{T})
|
||||
println("Random algebra: ", a)
|
||||
g1 = exp(a, 0.2)
|
||||
g2 = exp(a, -0.2)
|
||||
|
||||
g = g1*g2
|
||||
println("One?: ", g)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
M = [0.40284714488721746 + 0.2704272209422031im -0.029482825024553627 - 0.8247329455356851im 0.28771631112777535 + 0.027366985901323956im; -0.08478364480998268 + 0.8226014762207954im -0.4790638417896126 + 0.24301903735299646im -0.022591091614522323 + 0.16452285690920823im; 0.28083864951126214 + 0.04302898862961919im 0.0066864552013863165 - 0.17418727240313508im -0.939634663641523 + 0.07732362776719631im]
|
||||
|
||||
println(det(M))
|
||||
|
||||
|
||||
g1 = SU3(M[1,1],M[1,2],M[1,3], M[2,1],M[2,2],M[2,3])
|
||||
println("dir: ", g1)
|
||||
g2 = exp(a)
|
||||
println("exp: ", g2)
|
||||
println("dif: ", g2mat(g1)-g2mat(g2))
|
||||
|
||||
g3 = g1/g2
|
||||
println(g3)
|
||||
|
||||
println("END")
|
||||
|
||||
ftest(g::Group) = LatticeGPU.tr(g)
|
||||
|
||||
#println(" ## SU(2)")
|
||||
#asu2 = SU2alg(0.23, 1.23, -0.34)
|
||||
#gsu2 = exp(asu2)
|
||||
#
|
||||
#eps = 0.001
|
||||
#h = SU2alg(eps,0.0,0.0)
|
||||
#fp = ftest(exp(h)*gsu2)
|
||||
#fm = ftest(exp(h,-1.0)*gsu2)
|
||||
#println("Numerical derivative: ", (fp-fm)/(2.0*eps))
|
||||
#h = SU2alg(0.0,eps,0.0)
|
||||
#fp = ftest(exp(h)*gsu2)
|
||||
#fm = ftest(exp(h,-1.0)*gsu2)
|
||||
#println("Numerical derivative: ", (fp-fm)/(2.0*eps))
|
||||
#h = SU2alg(0.0,0.0,eps)
|
||||
#fp = ftest(exp(h)*gsu2)
|
||||
#fm = ftest(exp(h,-1.0)*gsu2)
|
||||
#println("Numerical derivative: ", (fp-fm)/(2.0*eps))
|
||||
#println("Exact derivative: ", -projalg(gsu2))
|
||||
|
||||
|
||||
|
||||
println("\n\n ## SU(3)")
|
||||
asu3 = SU3alg{T}(0.23, 1.23, -0.34, 2.34, -0.23, 0.23, -1.34, 1.34)
|
||||
gsu3 = exp(asu3)
|
||||
|
||||
eps = 0.001
|
||||
h = SU3alg{T}(eps,0.0,0.0,0.0,0.0,0.0,0.0,0.0)
|
||||
fp = ftest(exp(h)*gsu3)
|
||||
fm = ftest(exp(h,-1.0)*gsu3)
|
||||
println("Numerical derivative: ", (fp-fm)/(2.0*eps))
|
||||
h = SU3alg{T}(0.0,eps,0.0,0.0,0.0,0.0,0.0,0.0)
|
||||
fp = ftest(exp(h)*gsu3)
|
||||
fm = ftest(exp(h,-1.0)*gsu3)
|
||||
println("Numerical derivative: ", (fp-fm)/(2.0*eps))
|
||||
h = SU3alg{T}(0.0,0.0,eps,0.0,0.0,0.0,0.0,0.0)
|
||||
fp = ftest(exp(h)*gsu3)
|
||||
fm = ftest(exp(h,-1.0)*gsu3)
|
||||
println("Numerical derivative: ", (fp-fm)/(2.0*eps))
|
||||
h = SU3alg{T}(0.0,0.0,0.0,eps,0.0,0.0,0.0,0.0)
|
||||
fp = ftest(exp(h)*gsu3)
|
||||
fm = ftest(exp(h,-1.0)*gsu3)
|
||||
println("Numerical derivative: ", (fp-fm)/(2.0*eps))
|
||||
h = SU3alg{T}(0.0,0.0,0.0,0.0,eps,0.0,0.0,0.0)
|
||||
fp = ftest(exp(h)*gsu3)
|
||||
fm = ftest(exp(h,-1.0)*gsu3)
|
||||
println("Numerical derivative: ", (fp-fm)/(2.0*eps))
|
||||
h = SU3alg{T}(0.0,0.0,0.0,0.0,0.0,eps,0.0,0.0)
|
||||
fp = ftest(exp(h)*gsu3)
|
||||
fm = ftest(exp(h,-1.0)*gsu3)
|
||||
println("Numerical derivative: ", (fp-fm)/(2.0*eps))
|
||||
h = SU3alg{T}(0.0,0.0,0.0,0.0,0.0,0.0,eps,0.0)
|
||||
fp = ftest(exp(h)*gsu3)
|
||||
fm = ftest(exp(h,-1.0)*gsu3)
|
||||
println("Numerical derivative: ", (fp-fm)/(2.0*eps))
|
||||
h = SU3alg{T}(0.0,0.0,0.0,0.0,0.0,0.0,0.0,eps)
|
||||
fp = ftest(exp(h)*gsu3)
|
||||
fm = ftest(exp(h,-1.0)*gsu3)
|
||||
println("Numerical derivative: ", (fp-fm)/(2.0*eps))
|
||||
println("Exact derivative: ", -projalg(gsu3))
|
||||
|
||||
println("\n # Mutiplications")
|
||||
|
||||
g1 = exp(SU3alg{T}(0.23, 1.23, -0.34, 2.34, -0.23, 0.23, -1.34, 1.34))
|
||||
g2 = exp(SU3alg{T}(1.23, -0.23, -0.14, 0.4, -1.23, -0.8, -0.34, 0.34))
|
||||
|
||||
a = g1/(g2*g1)
|
||||
b = g2*a
|
||||
println("b is one: ", b)
|
||||
|
||||
|
||||
println("## Aqui test M3x3")
|
||||
ba = rand(SU3alg{T})
|
||||
ga = exp(ba)
|
||||
println("Matrix: ", alg2mat(ba))
|
||||
println("Exp: ", ga)
|
||||
|
||||
|
||||
println("## Final tests: ")
|
||||
g1 = exp(SU3alg{T}(6.23, 1.23, -0.34, 2.34, -0.23, 0.23, -8.34, 8.34))
|
||||
println(g1)
|
||||
println(isgroup(g1))
|
||||
g1 = unitarize(g1)
|
||||
println(g1)
|
||||
println(isgroup(g1))
|
||||
|
||||
println("## Fundamental")
|
||||
psi = rand(SU3fund{Float64})
|
||||
println(psi)
|
||||
|
||||
s = Spinor{4,SU3fund{Float64}}((rand(SU3fund{Float64}),rand(SU3fund{Float64}),rand(SU3fund{Float64}),rand(SU3fund{Float64})))
|
||||
println(s)
|
||||
for n in 1:4
|
||||
t1 = pmul(Pgamma{n,1}, s)
|
||||
t2 = g1\gpmul(Pgamma{n,1}, g1, s)
|
||||
println("Direction (+)$n: ", LatticeGPU.norm(t1-t2))
|
||||
|
||||
t1 = pmul(Pgamma{n,-1}, s)
|
||||
t2 = g1\gpmul(Pgamma{n,-1}, g1, s)
|
||||
println("Direction (-)$n: ", LatticeGPU.norm(t1-t2))
|
||||
end
|
||||
|
||||
for n in 1:4
|
||||
t1 = pmul(Pgamma{n,1}, s)
|
||||
t2 = g1*gdagpmul(Pgamma{n,1}, g1, s)
|
||||
println("Direction (+)$n: ", LatticeGPU.norm(t1-t2))
|
||||
|
||||
t1 = pmul(Pgamma{n,-1}, s)
|
||||
t2 = g1*gdagpmul(Pgamma{n,-1}, g1, s)
|
||||
println("Direction (-)$n: ", LatticeGPU.norm(t1-t2))
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue