Add some todos, add issame and caninteract to module instead of test

This commit is contained in:
Anton Reinhard 2023-11-24 19:37:16 +01:00
parent 62d572adbf
commit afec3f6e70
3 changed files with 51 additions and 30 deletions

View File

@ -32,7 +32,9 @@ function compute(
data2::QEDParticleValue{P2},
)::QEDParticleValue where {P1 <: QEDParticle, P2 <: QEDParticle}
p3 = QED_preserve_momentum(data1.p, data2.p)
dataOut = QEDParticleValue{typeof(p3)}(p3, data1.v * ABC_vertex() * data2.v)
P3 = interaction_result(P1, P2)
# TODO: which of data1 and data2 is left and right might depend on their types?
dataOut = QEDParticleValue{P3}(P3(p3), data1.v * ABC_vertex() * data2.v)
return dataOut
end
@ -47,9 +49,11 @@ For valid inputs, both input particles should have the same momenta at this poin
"""
function compute(
::ComputeTaskQED_S2,
data1::ParticleValue{P},
data2::ParticleValue{P},
)::ComplexF64 where {P <: QEDParticle}
data1::ParticleValue{P1},
data2::ParticleValue{P2},
)::ComplexF64 where {P1 <: QEDParticle, P2 <: QEDParticle}
@assert issame(P1, propagation_result(P2))
# TODO: assert that data1 and data2
inner = QED_inner_edge(data1.p)
return data1.v * inner * data2.v
end

View File

@ -177,6 +177,44 @@ end
@inline direction(::FermionStateful{Dir}) where {Dir <: ParticleDirection} = Dir()
@inline direction(::AntiFermionStateful{Dir}) where {Dir <: ParticleDirection} = Dir()
"""
caninteract(T1::Type{<:QEDParticle}, T2::Type{<:QEDParticle})
For two given [`QEDParticle`](@ref) types, return whether they can interact at a vertex. This is equivalent to `!issame(T1, T2)`.
See also: [`issame`](@ref) and [`interaction_result`](@ref)
"""
function caninteract(T1::Type{<:QEDParticle}, T2::Type{<:QEDParticle})
if (T1 == T2)
return false
end
if (T1 <: PhotonStateful && T2 <: PhotonStateful)
return false
end
for (P1, P2) in [(T1, T2), (T2, T1)]
if (P1 == FermionStateful{Incoming} && P2 == AntiFermionStateful{Outgoing})
return false
end
if (P1 == FermionStateful{Outgoing} && P2 == AntiFermionStateful{Incoming})
return false
end
end
return true
end
"""
issame(T1::Type{<:QEDParticle}, T2::Type{<:QEDParticle})
For two given [`QEDParticle`](@ref) types, return whether they are equivalent for the purpose of a Feynman Diagram. That means e.g. an `Incoming` `AntiFermion` is the same as an `Outgoing` `Fermion`. This is equivalent to `!caninteract(T1, T2)`.
See also: [`caninteract`](@ref) and [`interaction_result`](@ref)
"""
function issame(T1::Type{<:QEDParticle}, T2::Type{<:QEDParticle})
return !caninteract(T1, T2)
end
"""
QED_vertex()
@ -192,7 +230,8 @@ end
Calculate and return a new particle from two given interacting ones at a vertex.
"""
function QED_preserve_momentum(p1::QEDParticle, p2::QEDParticle)
t3 = interaction_result(typeof(p1), typeof(p2))
p3 = t3(p1.momentum + p2.momentum)
T3 = interaction_result(typeof(p1), typeof(p2))
# TODO: probably also need to do something about the spin/pol
p3 = T3(p1.momentum + p2.momentum)
return p3
end

View File

@ -1,6 +1,8 @@
using MetagraphOptimization
using QEDbase
import MetagraphOptimization.caninteract
import MetagraphOptimization.issame
import MetagraphOptimization.interaction_result
import MetagraphOptimization.propagation_result
import MetagraphOptimization.direction
@ -25,30 +27,6 @@ testparticleTypesPropagated = [
AntiFermionStateful{Incoming},
]
function caninteract(t1::Type{<:QEDParticle}, t2::Type{<:QEDParticle})
if (t1 == t2)
return false
end
if (t1 <: PhotonStateful && t2 <: PhotonStateful)
return false
end
for (p1, p2) in [(t1, t2), (t2, t1)]
if (p1 == FermionStateful{Incoming} && p2 == AntiFermionStateful{Outgoing})
return false
end
if (p1 == FermionStateful{Outgoing} && p2 == AntiFermionStateful{Incoming})
return false
end
end
return true
end
function issame(t1::Type{<:QEDParticle}, t2::Type{<:QEDParticle})
return !caninteract(t1, t2)
end
@testset "Interaction Result" begin
for p1 in testparticleTypes, p2 in testparticleTypes
if !caninteract(p1, p2)