Some updates

This commit is contained in:
Alberto Ramos 2022-01-05 19:55:51 +01:00
parent 6f6773d2ed
commit 65a619e554
7 changed files with 191 additions and 64 deletions

View file

@ -19,6 +19,23 @@ using ..Fields
using ..YM
using ..Spinors
struct DiracWorkspace{T}
sr
sp
sAp
st
function DiracWorkspace(::Type{G}, ::Type{T}, lp::SpaceParm{4,6,B,D}) where {G,T <: AbstractFloat, B,D}
sr = scalar_field(Spinor{4,G}, lp)
sp = scalar_field(Spinor{4,G}, lp)
sAp = scalar_field(Spinor{4,G}, lp)
st = scalar_field(Spinor{4,G}, lp)
return new{T}(sr,sp,sAp,st)
end
end
export DiracWorkspace
function Dw!(so, U, si, m0, lp::SpaceParm)
@timeit "Dw" begin
@ -30,7 +47,7 @@ function Dw!(so, U, si, m0, lp::SpaceParm)
return nothing
end
function DwdagDw!(so, U, si, m0, lp::SpaceParm)
function DwdagDw!(so, U, si, m0, st, lp::SpaceParm)
@timeit "DwdagDw" begin
CUDA.@sync begin
@ -49,16 +66,18 @@ function krnl_Dw!(so, U, si, m0, th, lp::SpaceParm{4,6,B,D}) where {B,D}
b, r = CUDA.threadIdx().x, CUDA.blockIdx().x
< # For SF:
# For SF:
# - cttilde affects mass term at x0 = a, T-a
# - Spinor can be periodic as long as 0 at x_0=0
so[b,r] = (4+m0)*si[b,r]
for id in 1:4
bu, ru = up((b,r), id, lp)
bd, rd = dw((b,r), id, lp)
so[b,r] -= ( th[id]*gpmul(Pgamma{id,-1},U[b,id,r],si[bu,ru]) +
conj(th[id])*gdagpmul(Pgamma{id,+1},U[bd,id,rd],si[bd,rd]) )/2
@inbounds begin
so[b,r] = (4+m0)*si[b,r]
for id in 1:4
bu, ru = up((b,r), id, lp)
bd, rd = dw((b,r), id, lp)
so[b,r] -= ( th[id]*gpmul(Pgamma{id,-1},U[b,id,r],si[bu,ru]) +
conj(th[id])*gdagpmul(Pgamma{id,+1},U[bd,id,rd],si[bd,rd]) )/2
end
end
return nothing
@ -67,21 +86,22 @@ end
function krnl_g5Dw!(so, U, si, m0, th, lp::SpaceParm{4,6,B,D}) where {B,D}
b, r = CUDA.threadIdx().x, CUDA.blockIdx().x
so[b,r] = (4+m0)*si[b,r]
for id in 1:4
bu, ru = up((b,r), id, lp)
bd, rd = dw((b,r), id, lp)
so[b,r] -= ( th[id]*gpmul(Pgamma{id,-1},U[b,id,r],si[bu,ru]) +
conj(th[id])*gdagpmul(Pgamma{id,+1},U[bd,id,rd],si[bd,rd]) )/2
@inbounds begin
so[b,r] = (4+m0)*si[b,r]
for id in 1:4
bu, ru = up((b,r), id, lp)
bd, rd = dw((b,r), id, lp)
so[b,r] -= ( th[id]*gpmul(Pgamma{id,-1},U[b,id,r],si[bu,ru]) +
conj(th[id])*gdagpmul(Pgamma{id,+1},U[bd,id,rd],si[bd,rd]) )/2
end
so[b,r] = dmul(Gamma{5}, so[b,r])
end
so[b,r].s[3] = -so[b,r].s[3]
so[b,r].s[4] = -so[b,r].s[4]
return nothing
end
export Dw
export Dw!, DwdagDw!
end

View file

@ -45,7 +45,7 @@ export Eoft_clover, Eoft_plaq, Qtop
export FlowIntr, wfl_euler, zfl_euler, wfl_rk2, zfl_rk2, wfl_rk3, zfl_rk3
export flw, flw_adapt
export sfcoupling, bndfield, setbndfield
export import_lex64, import_cern64
export import_lex64, import_cern64, import_bsfqcd
include("Spinors/Spinors.jl")
@ -54,4 +54,14 @@ export Spinor, Pgamma
export imm, mimm
export pmul, gpmul, gdagpmul, dmul
include("Dirac/Dirac.jl")
using .Dirac
export DiracWorkspace
export Dw!, DwdagDw!
include("Solvers/Solvers.jl")
using .Solvers
export CG!
end # module

View file

@ -22,7 +22,7 @@ Base.zero(::Type{Spinor{NS,G}}) where {NS,G} = Spinor{NS,G}(ntuple(i->zero(G), N
"""
norm2(a::Spinor)
Returns the norm of a fundamental element. Same result as sqrt(dot(a,a)).
Returns the norm squared of a fundamental element. Same result as `dot(a,a)`.
"""
@generated function norm2(a::Spinor{NS,G}) where {NS,G}
@ -100,52 +100,52 @@ end
Returns ``(1+s\\gamma_N)a``.
"""
function pmul(::Type{Pgamma{4,1}}, a::Spinor{4,G}) where {NS,G}
@inline 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}
@inline 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}
@inline 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}
@inline 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,imm(r2),imm(r1)))
end
function pmul(::Type{Pgamma{2,1}}, a::Spinor{4,G}) where {NS,G}
@inline 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}
@inline 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}
@inline 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}
@inline 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])
@ -158,52 +158,52 @@ end
Returns ``g(1+s\\gamma_N)a``
"""
function gpmul(::Type{Pgamma{4,1}}, g, a::Spinor{4,G}) where {NS,G}
@inline 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}
@inline 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}
@inline 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}
@inline 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,imm(r2),imm(r1)))
end
function gpmul(::Type{Pgamma{2,1}}, g, a::Spinor{4,G}) where {NS,G}
@inline 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}
@inline 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}
@inline 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}
@inline 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]))
@ -215,52 +215,52 @@ end
Returns ``g^+ (1+s\\gamma_N)a``
"""
function gdagpmul(::Type{Pgamma{4,1}}, g, a::Spinor{4,G}) where {NS,G}
@inline 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}
@inline 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}
@inline 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}
@inline 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,imm(r2),imm(r1)))
end
function gdagpmul(::Type{Pgamma{2,1}}, g, a::Spinor{4,G}) where {NS,G}
@inline 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}
@inline 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}
@inline 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}
@inline 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]))
@ -298,22 +298,22 @@ indexing for Dirac basis ``\\Gamma_n``:
16 identity
"""
dmul(::Type{Gamma{1}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(mimm(a.s[4]), mimm(a.s[3]), imm(a.s[2]), imm(a.s[1]))
dmul(::Type{Gamma{2}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(-a.s[4], a.s[3], a.s[2], -a.s[1])
dmul(::Type{Gamma{3}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(mimm(a.s[3]), imm(a.s[4]), imm(a.s[1]), mimm(a.s[2]))
dmul(::Type{Gamma{4}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(-a.s[3], -a.s[4], -a.s[1], -a.s[2])
dmul(::Type{Gamma{5}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( a.s[1], a.s[2], -a.s[3], -a.s[4])
dmul(::Type{Gamma{6}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( imm(a.s[4]), imm(a.s[3]), imm(a.s[2]), imm(a.s[1]))
dmul(::Type{Gamma{7}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( a.s[4], -a.s[3], a.s[2], -a.s[1])
dmul(::Type{Gamma{8}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( imm(a.s[3]), mimm(a.s[4]), imm(a.s[1]), mimm(a.s[2]))
dmul(::Type{Gamma{9}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( a.s[3], a.s[4], -a.s[1], -a.s[2])
dmul(::Type{Gamma{10}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( a.s[2], a.s[1], -a.s[4], -a.s[3])
dmul(::Type{Gamma{11}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(mimm(a.s[2]), imm(a.s[1]), imm(a.s[4]), mimm(a.s[3]))
dmul(::Type{Gamma{12}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( a.s[1], -a.s[2], -a.s[3], a.s[4])
dmul(::Type{Gamma{13}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(-a.s[1], a.s[2], -a.s[3], a.s[4])
dmul(::Type{Gamma{14}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(-a.s[2], -a.s[1], -a.s[4], -a.s[3])
dmul(::Type{Gamma{15}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( imm(a.s[2]), mimm(a.s[1]), imm(a.s[4]), mimm(a.s[3]))
dmul(::Type{Gamma{16}}, a::Spinor{4,G}) where {G} = a
@inline dmul(::Type{Gamma{1}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(mimm(a.s[4]), mimm(a.s[3]), imm(a.s[2]), imm(a.s[1]))
@inline dmul(::Type{Gamma{2}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(-a.s[4], a.s[3], a.s[2], -a.s[1])
@inline dmul(::Type{Gamma{3}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(mimm(a.s[3]), imm(a.s[4]), imm(a.s[1]), mimm(a.s[2]))
@inline dmul(::Type{Gamma{4}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(-a.s[3], -a.s[4], -a.s[1], -a.s[2])
@inline dmul(::Type{Gamma{5}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( a.s[1], a.s[2], -a.s[3], -a.s[4])
@inline dmul(::Type{Gamma{6}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( imm(a.s[4]), imm(a.s[3]), imm(a.s[2]), imm(a.s[1]))
@inline dmul(::Type{Gamma{7}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( a.s[4], -a.s[3], a.s[2], -a.s[1])
@inline dmul(::Type{Gamma{8}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( imm(a.s[3]), mimm(a.s[4]), imm(a.s[1]), mimm(a.s[2]))
@inline dmul(::Type{Gamma{9}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( a.s[3], a.s[4], -a.s[1], -a.s[2])
@inline dmul(::Type{Gamma{10}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( a.s[2], a.s[1], -a.s[4], -a.s[3])
@inline dmul(::Type{Gamma{11}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(mimm(a.s[2]), imm(a.s[1]), imm(a.s[4]), mimm(a.s[3]))
@inline dmul(::Type{Gamma{12}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( a.s[1], -a.s[2], -a.s[3], a.s[4])
@inline dmul(::Type{Gamma{13}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(-a.s[1], a.s[2], -a.s[3], a.s[4])
@inline dmul(::Type{Gamma{14}}, a::Spinor{4,G}) where {G} = Spinor{4,G}(-a.s[2], -a.s[1], -a.s[4], -a.s[3])
@inline dmul(::Type{Gamma{15}}, a::Spinor{4,G}) where {G} = Spinor{4,G}( imm(a.s[2]), mimm(a.s[1]), imm(a.s[4]), mimm(a.s[3]))
@inline dmul(::Type{Gamma{16}}, a::Spinor{4,G}) where {G} = a
export Spinor, Pgamma
export norm, norm2, dot, imm, mimm

View file

@ -12,7 +12,7 @@
module YM
using CUDA, Random, TimerOutputs
using CUDA, Random, TimerOutputs, BDIO
using ..Space
using ..Groups
using ..Fields
@ -147,6 +147,6 @@ include("YMsf.jl")
export sfcoupling, bndfield, setbndfield
include("YMio.jl")
export import_lex64, import_cern64
export import_lex64, import_cern64, import_bsfqcd
end

View file

@ -9,6 +9,49 @@
### created: Wed Nov 10 12:58:27 2021
###
"""
function import_lex64(fname::String, lp::SpaceParm)
import a double precision configuration in lexicographic format. SF boundary conditions are assummed.
"""
function import_bsfqcd(fname, lp::SpaceParm)
fp = BDIO_open(fname, "r")
while BDIO_seek!(fp)
if (BDIO_get_uinfo(fb) == 2)
break
end
end
dtr = [2,3,4,1]
assign(id, V, i3) = SU3{Float64}(V[1,dtr[id],i3],V[2,dtr[id],i3],V[3,dtr[id],i3],
V[4,dtr[id],i3],V[5,dtr[id],i3],V[6,dtr[id],i3])
Ucpu = Array{SU3{Float64}, 3}(undef, lp.bsz, lp.ndim, lp.rsz)
V = Array{ComplexF64, 3}(undef, 9, lp.ndim, lp.iL[3])
for i4 in 1:lp.iL[4]
for i1 in 1:lp.iL[1]
for i2 in 1:lp.iL[2]
BDIO_read(fp, V)
for i3 in 1:lp.iL[3]
b, r = point_index(CartesianIndex(i1,i2,i3,i4), lp)
for id in 1:lp.ndim
Ucpu[b,id,r] = assign(id, V, i3)
end
end
end
end
end
BDIO_read(fp, V)
Ubnd = ntuple(i->assign(i, V, 1), 3)
close(fp)
return CuArray(Ucpu), Ubnd
end
"""
function import_lex64(fname::String, lp::SpaceParm)