Add graph gen benchmark, eval script, and result image
This commit is contained in:
@ -114,12 +114,8 @@ function gen_graph(process_description::QEDProcessDescription)
|
||||
dataOutNodes[String(particle)] = data_out
|
||||
end
|
||||
|
||||
#dataOutBackup = copy(dataOutNodes)
|
||||
|
||||
# TODO: this should be parallelizable somewhat easily
|
||||
for diagram in diagrams
|
||||
# the intermediate (virtual) particles change across
|
||||
#dataOutNodes = copy(dataOutBackup)
|
||||
|
||||
tie = diagram.tie[]
|
||||
|
||||
# handle the vertices
|
||||
|
@ -447,75 +447,88 @@ Returns true iff the given feynman diagram is an (empty) diagram of a compton pr
|
||||
function is_compton(fd::FeynmanDiagram)
|
||||
return fd.type_ids[FermionStateful{Incoming, SpinUp}] == 1 &&
|
||||
fd.type_ids[FermionStateful{Outgoing, SpinUp}] == 1 &&
|
||||
fd.type_ids[PhotonStateful{Incoming, PolX}] == 1 &&
|
||||
fd.type_ids[AntiFermionStateful{Incoming, SpinUp}] == 0 &&
|
||||
fd.type_ids[AntiFermionStateful{Outgoing, SpinUp}] == 0 &&
|
||||
fd.type_ids[PhotonStateful{Incoming, PolX}] >= 1 &&
|
||||
fd.type_ids[PhotonStateful{Outgoing, PolX}] >= 1
|
||||
end
|
||||
|
||||
"""
|
||||
n_photon_compton_diagrams(n::Int)
|
||||
gen_compton_diagram_from_order(order::Vector{Int}, inFerm, outFerm, n::Int, m::Int)
|
||||
|
||||
Special case diagram generation for n-Photon Compton processes, i.e., processes of the form ke->k^ne
|
||||
Helper function for [`gen_compton_diagrams`](@Ref). Generates a single diagram for the given order and n input and m output photons.
|
||||
"""
|
||||
function n_photon_compton_diagram(n::Int)
|
||||
inEl = FeynmanParticle(FermionStateful{Incoming, SpinUp}, 1)
|
||||
outEl = FeynmanParticle(FermionStateful{Outgoing, SpinUp}, 1)
|
||||
function gen_compton_diagram_from_order(order::Vector{Int}, inFerm, outFerm, n::Int, m::Int)
|
||||
photons = vcat(
|
||||
[FeynmanParticle(PhotonStateful{Incoming, PolX}, i) for i in 1:n],
|
||||
[FeynmanParticle(PhotonStateful{Outgoing, PolX}, i) for i in 1:m],
|
||||
)
|
||||
|
||||
photons = [FeynmanParticle(PhotonStateful{Outgoing, PolX}, i) for i in 1:n]
|
||||
push!(photons, FeynmanParticle(PhotonStateful{Incoming, PolX}, 1))
|
||||
new_diagram = FeynmanDiagram(
|
||||
[],
|
||||
missing,
|
||||
[inFerm, outFerm, photons...],
|
||||
Dict{Type, Int64}(
|
||||
FermionStateful{Incoming, SpinUp} => 1,
|
||||
FermionStateful{Outgoing, SpinUp} => 1,
|
||||
PhotonStateful{Incoming, PolX} => n,
|
||||
PhotonStateful{Outgoing, PolX} => m,
|
||||
),
|
||||
)
|
||||
|
||||
perms = permutations([i for i in 1:length(photons)])
|
||||
left_index = 1
|
||||
right_index = length(order)
|
||||
|
||||
diagrams = Vector{FeynmanDiagram}()
|
||||
for order in perms
|
||||
new_diagram = FeynmanDiagram(
|
||||
[],
|
||||
missing,
|
||||
[inEl, outEl, photons...],
|
||||
Dict{Type, Int64}(
|
||||
FermionStateful{Incoming, SpinUp} => 1,
|
||||
FermionStateful{Outgoing, SpinUp} => 1,
|
||||
PhotonStateful{Incoming, PolX} => 1,
|
||||
PhotonStateful{Outgoing, PolX} => n,
|
||||
),
|
||||
iterations = 1
|
||||
|
||||
while left_index <= right_index
|
||||
# left side
|
||||
v_left = FeynmanVertex(
|
||||
FeynmanParticle(FermionStateful{Incoming, SpinUp}, iterations),
|
||||
photons[order[left_index]],
|
||||
FeynmanParticle(FermionStateful{Incoming, SpinUp}, iterations + 1),
|
||||
)
|
||||
left_index += 1
|
||||
add_vertex!(new_diagram, v_left)
|
||||
|
||||
left_index = 1
|
||||
right_index = length(order)
|
||||
|
||||
iterations = 1
|
||||
|
||||
while left_index <= right_index
|
||||
# left side
|
||||
v_left = FeynmanVertex(
|
||||
FeynmanParticle(FermionStateful{Incoming, SpinUp}, iterations),
|
||||
photons[order[left_index]],
|
||||
FeynmanParticle(FermionStateful{Incoming, SpinUp}, iterations + 1),
|
||||
)
|
||||
left_index += 1
|
||||
add_vertex!(new_diagram, v_left)
|
||||
|
||||
if (left_index > right_index)
|
||||
break
|
||||
end
|
||||
|
||||
# right side
|
||||
v_right = FeynmanVertex(
|
||||
FeynmanParticle(FermionStateful{Outgoing, SpinUp}, iterations),
|
||||
photons[order[right_index]],
|
||||
FeynmanParticle(FermionStateful{Outgoing, SpinUp}, iterations + 1),
|
||||
)
|
||||
right_index -= 1
|
||||
add_vertex!(new_diagram, v_right)
|
||||
|
||||
iterations += 1
|
||||
if (left_index > right_index)
|
||||
break
|
||||
end
|
||||
|
||||
@assert possible_tie(new_diagram) !== missing
|
||||
add_tie!(new_diagram, possible_tie(new_diagram))
|
||||
push!(diagrams, new_diagram)
|
||||
# right side
|
||||
v_right = FeynmanVertex(
|
||||
FeynmanParticle(FermionStateful{Outgoing, SpinUp}, iterations),
|
||||
photons[order[right_index]],
|
||||
FeynmanParticle(FermionStateful{Outgoing, SpinUp}, iterations + 1),
|
||||
)
|
||||
right_index -= 1
|
||||
add_vertex!(new_diagram, v_right)
|
||||
|
||||
iterations += 1
|
||||
end
|
||||
|
||||
return diagrams
|
||||
@assert possible_tie(new_diagram) !== missing
|
||||
add_tie!(new_diagram, possible_tie(new_diagram))
|
||||
return return new_diagram
|
||||
end
|
||||
|
||||
"""
|
||||
gen_compton_diagrams(n::Int, m::Int)
|
||||
|
||||
Special case diagram generation for Compton processes, i.e., processes of the form k^ne->k^me
|
||||
"""
|
||||
function gen_compton_diagrams(n::Int, m::Int)
|
||||
inFerm = FeynmanParticle(FermionStateful{Incoming, SpinUp}, 1)
|
||||
outFerm = FeynmanParticle(FermionStateful{Outgoing, SpinUp}, 1)
|
||||
|
||||
perms = [permutations([i for i in 1:(n + m)])...]
|
||||
|
||||
diagrams = [Vector{FeynmanDiagram}() for i in 1:nthreads()]
|
||||
@threads for order in perms
|
||||
push!(diagrams[threadid()], gen_compton_diagram_from_order(order, inFerm, outFerm, n, m))
|
||||
end
|
||||
|
||||
return vcat(diagrams...)
|
||||
end
|
||||
|
||||
"""
|
||||
@ -525,7 +538,10 @@ From a given feynman diagram in its initial state, e.g. when created through the
|
||||
"""
|
||||
function gen_diagrams(fd::FeynmanDiagram)
|
||||
if is_compton(fd)
|
||||
return n_photon_compton_diagram(fd.type_ids[PhotonStateful{Outgoing, PolX}])
|
||||
return gen_compton_diagrams(
|
||||
fd.type_ids[PhotonStateful{Incoming, PolX}],
|
||||
fd.type_ids[PhotonStateful{Outgoing, PolX}],
|
||||
)
|
||||
end
|
||||
|
||||
working = Set{FeynmanDiagram}()
|
||||
|
Reference in New Issue
Block a user