Congruent incoming photons implementation #11
@ -1,3 +1,5 @@
|
||||
ENV["UCX_ERROR_SIGNALS"] = "SIGILL,SIGBUS,SIGFPE"
|
||||
|
||||
using MetagraphOptimization
|
||||
using QEDbase
|
||||
using QEDcore
|
||||
@ -102,7 +104,8 @@ function build_psp(processDescription::GenericQEDProcess, momenta)
|
||||
)
|
||||
end
|
||||
|
||||
return 0
|
||||
# hack to fix stacksize for threading
|
||||
with_stacksize(f, n) = fetch(schedule(Task(f, n)))
|
||||
|
||||
# scenario 2
|
||||
N = 1000
|
||||
@ -111,7 +114,7 @@ M = 1000
|
||||
thetas = collect(LinRange(0, 2π, N))
|
||||
phis = collect(LinRange(0, 2π, M))
|
||||
|
||||
for photons in [6]
|
||||
for photons in 1: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)...")
|
||||
@ -121,7 +124,8 @@ for photons in [6]
|
||||
congruent_input_momenta_scenario_2(temp_process, omega, theta, phi) for
|
||||
(theta, phi) in Iterators.product(thetas, phis)
|
||||
]
|
||||
results = [0.0 for _ in 1:length(input_momenta)]
|
||||
results = Array{Float64}(undef, size(input_momenta))
|
||||
fill!(results, 0.0)
|
||||
|
||||
i = 1
|
||||
for (in_pol, in_spin, out_pol, out_spin) in
|
||||
@ -134,15 +138,17 @@ for photons in [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:length(inputs)
|
||||
results[i] += abs2(func(inputs[i]))
|
||||
Threads.@threads for i in 1:N
|
||||
Threads.@threads for j in 1:M
|
||||
return results[i, j] += abs2(func(inputs[i, j]))
|
||||
end
|
||||
end
|
||||
println("Done.")
|
||||
i += 1
|
||||
@ -157,20 +163,23 @@ for photons in [6]
|
||||
end
|
||||
end
|
||||
|
||||
# scenario
|
||||
exit(0)
|
||||
|
||||
# scenario 1 (disabled)
|
||||
n = 1000000
|
||||
|
||||
# n is the number of incoming photons
|
||||
# omega is the number
|
||||
|
||||
for photons in [6]
|
||||
for photons in 1: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 = [0.0 for _ in 1:length(input_momenta)]
|
||||
results = Array{Float64}(undef, size(input_momenta))
|
||||
fill!(results, 0.0)
|
||||
|
||||
i = 1
|
||||
for (in_pol, in_spin, out_pol, out_spin) in
|
||||
|
@ -504,18 +504,15 @@ 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}, i) for i in 1:n],
|
||||
[FeynmanParticle(ParticleStateful{Outgoing, Photon}, i) for i in 1:m],
|
||||
[FeynmanParticle(ParticleStateful{Incoming, Photon, SFourMomentum}, i) for i in 1:n],
|
||||
[FeynmanParticle(ParticleStateful{Outgoing, Photon, SFourMomentum}, i) for i in 1:m],
|
||||
)
|
||||
|
||||
new_diagram = FeynmanDiagram(
|
||||
@ -523,10 +520,10 @@ function gen_compton_diagram_from_order_one_side(
|
||||
missing,
|
||||
[inFerm, outFerm, photons...],
|
||||
Dict{Type, Int64}(
|
||||
ParticleStateful{Incoming, Electron} => 1,
|
||||
ParticleStateful{Outgoing, Electron} => 1,
|
||||
ParticleStateful{Incoming, Photon} => n,
|
||||
ParticleStateful{Outgoing, Photon} => m,
|
||||
ParticleStateful{Incoming, Electron, SFourMomentum} => 1,
|
||||
ParticleStateful{Outgoing, Electron, SFourMomentum} => 1,
|
||||
ParticleStateful{Incoming, Photon, SFourMomentum} => n,
|
||||
ParticleStateful{Outgoing, Photon, SFourMomentum} => m,
|
||||
),
|
||||
)
|
||||
|
||||
@ -538,9 +535,9 @@ function gen_compton_diagram_from_order_one_side(
|
||||
while left_index <= right_index
|
||||
# left side
|
||||
v_left = FeynmanVertex(
|
||||
FeynmanParticle(ParticleStateful{Incoming, Electron}, iterations),
|
||||
FeynmanParticle(ParticleStateful{Incoming, Electron, SFourMomentum}, iterations),
|
||||
photons[order[left_index]],
|
||||
FeynmanParticle(ParticleStateful{Incoming, Electron}, iterations + 1),
|
||||
FeynmanParticle(ParticleStateful{Incoming, Electron, SFourMomentum}, iterations + 1),
|
||||
)
|
||||
left_index += 1
|
||||
add_vertex!(new_diagram, v_left)
|
||||
@ -553,9 +550,9 @@ function gen_compton_diagram_from_order_one_side(
|
||||
if (iterations == 1)
|
||||
# right side
|
||||
v_right = FeynmanVertex(
|
||||
FeynmanParticle(ParticleStateful{Outgoing, Electron}, iterations),
|
||||
FeynmanParticle(ParticleStateful{Outgoing, Electron, SFourMomentum}, iterations),
|
||||
photons[order[right_index]],
|
||||
FeynmanParticle(ParticleStateful{Outgoing, Electron}, iterations + 1),
|
||||
FeynmanParticle(ParticleStateful{Outgoing, Electron, SFourMomentum}, iterations + 1),
|
||||
)
|
||||
right_index -= 1
|
||||
add_vertex!(new_diagram, v_right)
|
||||
@ -569,7 +566,6 @@ function gen_compton_diagram_from_order_one_side(
|
||||
add_tie!(new_diagram, FeynmanTie(ps[1], ps[2]))
|
||||
return new_diagram
|
||||
end
|
||||
=#
|
||||
|
||||
"""
|
||||
gen_compton_diagrams(n::Int, m::Int)
|
||||
|
Loading…
x
Reference in New Issue
Block a user