Compare commits

..

No commits in common. "dee44dad66332603d1706f65263a20cfabd2af16" and "813d40cd30b8623e39f13260adbab770f4c49853" have entirely different histories.

2 changed files with 30 additions and 29 deletions

View File

@ -1,5 +1,3 @@
ENV["UCX_ERROR_SIGNALS"] = "SIGILL,SIGBUS,SIGFPE"
using MetagraphOptimization
using QEDbase
using QEDcore
@ -28,12 +26,15 @@ end
function congruent_input_momenta(processDescription::GenericQEDProcess, omega::Number)
# generate an input sample for given e + nk -> e' + k' process, where the nk are equal
massSum = 0
inputMasses = Vector{Float64}()
for particle in incoming_particles(processDescription)
massSum += mass(particle)
push!(inputMasses, mass(particle))
end
outputMasses = Vector{Float64}()
for particle in outgoing_particles(processDescription)
massSum += mass(particle)
push!(outputMasses, mass(particle))
end
@ -48,7 +49,7 @@ function congruent_input_momenta(processDescription::GenericQEDProcess, omega::N
return (tuple(initial_momenta...), tuple(final_momenta...))
end
# theta ∈ [0, 2π] and phi ∈ [0, 2π]
# cos_theta ∈ [-1, 1] and phi ∈ [0, 2π]
function congruent_input_momenta_scenario_2(
processDescription::GenericQEDProcess,
omega::Number,
@ -59,12 +60,15 @@ function congruent_input_momenta_scenario_2(
# same as above
# generate an input sample for given e + nk -> e' + k' process, where the nk are equal
massSum = 0
inputMasses = Vector{Float64}()
for particle in incoming_particles(processDescription)
massSum += mass(particle)
push!(inputMasses, mass(particle))
end
outputMasses = Vector{Float64}()
for particle in outgoing_particles(processDescription)
massSum += mass(particle)
push!(outputMasses, mass(particle))
end
@ -104,8 +108,7 @@ function build_psp(processDescription::GenericQEDProcess, momenta)
)
end
# hack to fix stacksize for threading
with_stacksize(f, n) = fetch(schedule(Task(f, n)))
return 0
# scenario 2
N = 1000
@ -114,7 +117,7 @@ M = 1000
thetas = collect(LinRange(0, 2π, N))
phis = collect(LinRange(0, 2π, M))
for photons in 1:6
for photons in [6]
# temp process to generate momenta
for omega in [2e-3, 2e-6]
println("Generating $(N*M) inputs for $photons photons (Scenario 2 grid walk)...")
@ -124,8 +127,7 @@ for photons in 1:6
congruent_input_momenta_scenario_2(temp_process, omega, theta, phi) for
(theta, phi) in Iterators.product(thetas, phis)
]
results = Array{Float64}(undef, size(input_momenta))
fill!(results, 0.0)
results = [0.0 for _ in 1:length(input_momenta)]
i = 1
for (in_pol, in_spin, out_pol, out_spin) in
@ -138,17 +140,15 @@ for photons in 1:6
inputs = build_psp.(Ref(process), input_momenta)
print("Preparing graph... ")
# prepare function
graph = gen_graph(process)
optimize_to_fixpoint!(ReductionOptimizer(), graph)
print("Preparing function... ")
func = get_compute_function(graph, process, mock_machine())
func(inputs[1])
print("Calculating... ")
Threads.@threads for i in 1:N
Threads.@threads for j in 1:M
return results[i, j] += abs2(func(inputs[i, j]))
end
Threads.@threads for i in 1:length(inputs)
results[i] += abs2(func(inputs[i]))
end
println("Done.")
i += 1
@ -163,23 +163,20 @@ for photons in 1:6
end
end
exit(0)
# scenario 1 (disabled)
n = 1000000
# n is the number of incoming photons
# omega is the number
for photons in 1:6
for photons in [6]
# temp process to generate momenta
for omega in [2e-3, 2e-6]
println("Generating $n inputs for $photons photons...")
temp_process = parse_process("k"^photons * "e->ke", QEDModel(), PolX(), SpinUp(), PolX(), SpinUp())
input_momenta = [congruent_input_momenta(temp_process, omega) for _ in 1:n]
results = Array{Float64}(undef, size(input_momenta))
fill!(results, 0.0)
results = [0.0 for _ in 1:length(input_momenta)]
i = 1
for (in_pol, in_spin, out_pol, out_spin) in

View File

@ -504,15 +504,18 @@ function gen_compton_diagram_from_order(order::Vector{Int}, inFerm, outFerm, n::
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)
function gen_compton_diagram_from_order_one_side(
order::Vector{Int}, inFerm, outFerm, n::Int, m::Int
)
photons = vcat(
[FeynmanParticle(ParticleStateful{Incoming, Photon, SFourMomentum}, i) for i in 1:n],
[FeynmanParticle(ParticleStateful{Outgoing, Photon, SFourMomentum}, i) for i in 1:m],
[FeynmanParticle(ParticleStateful{Incoming, Photon}, i) for i in 1:n],
[FeynmanParticle(ParticleStateful{Outgoing, Photon}, i) for i in 1:m],
)
new_diagram = FeynmanDiagram(
@ -520,10 +523,10 @@ function gen_compton_diagram_from_order_one_side(order::Vector{Int}, inFerm, out
missing,
[inFerm, outFerm, photons...],
Dict{Type, Int64}(
ParticleStateful{Incoming, Electron, SFourMomentum} => 1,
ParticleStateful{Outgoing, Electron, SFourMomentum} => 1,
ParticleStateful{Incoming, Photon, SFourMomentum} => n,
ParticleStateful{Outgoing, Photon, SFourMomentum} => m,
ParticleStateful{Incoming, Electron} => 1,
ParticleStateful{Outgoing, Electron} => 1,
ParticleStateful{Incoming, Photon} => n,
ParticleStateful{Outgoing, Photon} => m,
),
)
@ -535,9 +538,9 @@ function gen_compton_diagram_from_order_one_side(order::Vector{Int}, inFerm, out
while left_index <= right_index
# left side
v_left = FeynmanVertex(
FeynmanParticle(ParticleStateful{Incoming, Electron, SFourMomentum}, iterations),
FeynmanParticle(ParticleStateful{Incoming, Electron}, iterations),
photons[order[left_index]],
FeynmanParticle(ParticleStateful{Incoming, Electron, SFourMomentum}, iterations + 1),
FeynmanParticle(ParticleStateful{Incoming, Electron}, iterations + 1),
)
left_index += 1
add_vertex!(new_diagram, v_left)
@ -550,9 +553,9 @@ function gen_compton_diagram_from_order_one_side(order::Vector{Int}, inFerm, out
if (iterations == 1)
# right side
v_right = FeynmanVertex(
FeynmanParticle(ParticleStateful{Outgoing, Electron, SFourMomentum}, iterations),
FeynmanParticle(ParticleStateful{Outgoing, Electron}, iterations),
photons[order[right_index]],
FeynmanParticle(ParticleStateful{Outgoing, Electron, SFourMomentum}, iterations + 1),
FeynmanParticle(ParticleStateful{Outgoing, Electron}, iterations + 1),
)
right_index -= 1
add_vertex!(new_diagram, v_right)
@ -566,6 +569,7 @@ function gen_compton_diagram_from_order_one_side(order::Vector{Int}, inFerm, out
add_tie!(new_diagram, FeynmanTie(ps[1], ps[2]))
return new_diagram
end
=#
"""
gen_compton_diagrams(n::Int, m::Int)