diff --git a/src/models/qed/diagrams.jl b/src/models/qed/diagrams.jl index 23daf00..6cf7ed1 100644 --- a/src/models/qed/diagrams.jl +++ b/src/models/qed/diagrams.jl @@ -509,9 +509,74 @@ function gen_compton_diagram_from_order(order::Vector{Int}, inFerm, outFerm, n:: @assert possible_tie(new_diagram) !== missing add_tie!(new_diagram, possible_tie(new_diagram)) - return return new_diagram + return new_diagram end + +""" + gen_compton_diagram_from_order_one_side(order::Vector{Int}, inFerm, outFerm, n::Int, m::Int) + +Helper function for [`gen_compton_diagrams`](@Ref). Generates a single diagram for the given order and n input and m output photons. +""" +function gen_compton_diagram_from_order_one_side(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], + ) + + 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, + ), + ) + + 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 + + # only once on the right side + if (iterations == 1) + # 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) + end + + iterations += 1 + end + + ps = get_particles(new_diagram) + @assert length(ps) == 2 + add_tie!(new_diagram, FeynmanTie(ps[1], ps[2])) + return new_diagram +end + + """ gen_compton_diagrams(n::Int, m::Int) @@ -531,6 +596,26 @@ function gen_compton_diagrams(n::Int, m::Int) return vcat(diagrams...) end + +""" + gen_compton_diagrams_one_side(n::Int, m::Int) + +Special case diagram generation for Compton processes, i.e., processes of the form k^ne->k^me, but generating from one end, yielding larger diagrams +""" +function gen_compton_diagrams_one_side(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_one_side(order, inFerm, outFerm, n, m)) + end + + return vcat(diagrams...) +end + """ gen_diagrams(fd::FeynmanDiagram)