|
|
|
@@ -1,9 +1,51 @@
|
|
|
|
|
import MetagraphOptimization.ABCParticle
|
|
|
|
|
import MetagraphOptimization.interaction_result
|
|
|
|
|
|
|
|
|
|
using QEDbase
|
|
|
|
|
using AccurateArithmetic
|
|
|
|
|
|
|
|
|
|
include("../examples/profiling_utilities.jl")
|
|
|
|
|
|
|
|
|
|
const RTOL = sqrt(eps(Float64))
|
|
|
|
|
|
|
|
|
|
function check_particle_reverse_moment(p1::SFourMomentum, p2::SFourMomentum)
|
|
|
|
|
@test isapprox(abs(p1.E), abs(p2.E))
|
|
|
|
|
@test isapprox(p1.px, -p2.px)
|
|
|
|
|
@test isapprox(p1.py, -p2.py)
|
|
|
|
|
@test isapprox(p1.pz, -p2.pz)
|
|
|
|
|
return nothing
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ground_truth_graph_result(input::ABCProcessInput)
|
|
|
|
|
# formula for one diagram:
|
|
|
|
|
# u_Bp * iλ * u_Ap * S_C * u_B * iλ * u_A
|
|
|
|
|
# for the second diagram:
|
|
|
|
|
# u_B * iλ * u_Ap * S_C * u_Bp * iλ * u_Ap
|
|
|
|
|
# the "u"s are all 1, we ignore the i, λ is 1/137.
|
|
|
|
|
|
|
|
|
|
constant = (1 / 137.0)^2
|
|
|
|
|
|
|
|
|
|
# calculate particle C in diagram 1
|
|
|
|
|
diagram1_C = ParticleC(input.inParticles[1].momentum + input.inParticles[2].momentum)
|
|
|
|
|
diagram2_C = ParticleC(input.inParticles[1].momentum + input.outParticles[2].momentum)
|
|
|
|
|
|
|
|
|
|
diagram1_Cp = ParticleC(input.outParticles[1].momentum + input.outParticles[2].momentum)
|
|
|
|
|
diagram2_Cp = ParticleC(input.outParticles[1].momentum + input.inParticles[2].momentum)
|
|
|
|
|
|
|
|
|
|
check_particle_reverse_moment(diagram1_Cp.momentum, diagram1_C.momentum)
|
|
|
|
|
check_particle_reverse_moment(diagram2_Cp.momentum, diagram2_C.momentum)
|
|
|
|
|
@test isapprox(getMass2(diagram1_C.momentum), getMass2(diagram1_Cp.momentum))
|
|
|
|
|
@test isapprox(getMass2(diagram2_C.momentum), getMass2(diagram2_Cp.momentum))
|
|
|
|
|
|
|
|
|
|
inner1 = MetagraphOptimization.inner_edge(diagram1_C)
|
|
|
|
|
inner2 = MetagraphOptimization.inner_edge(diagram2_C)
|
|
|
|
|
|
|
|
|
|
diagram1_result = inner1 * constant
|
|
|
|
|
diagram2_result = inner2 * constant
|
|
|
|
|
|
|
|
|
|
return sum_kbn([diagram1_result, diagram2_result])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@testset "Unit Tests Execution" begin
|
|
|
|
|
machine = get_machine_info()
|
|
|
|
|
|
|
|
|
@@ -23,29 +65,29 @@ include("../examples/profiling_utilities.jl")
|
|
|
|
|
ParticleB(SFourMomentum(0.823648, 0.835061, 0.474802, -0.277915)),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
expected_result = 0.00013916495566048735
|
|
|
|
|
expected_result = ground_truth_graph_result(particles_2_2)
|
|
|
|
|
|
|
|
|
|
@testset "AB->AB no optimization" begin
|
|
|
|
|
for _ in 1:10 # test in a loop because graph layout should not change the result
|
|
|
|
|
graph = parse_dag(joinpath(@__DIR__, "..", "input", "AB->AB.txt"), ABCModel())
|
|
|
|
|
@test isapprox(execute(graph, process_2_2, machine, particles_2_2), expected_result; rtol = 0.001)
|
|
|
|
|
@test isapprox(execute(graph, process_2_2, machine, particles_2_2), expected_result; rtol = RTOL)
|
|
|
|
|
|
|
|
|
|
# graph should be fully scheduled after being executed
|
|
|
|
|
@test is_scheduled(graph)
|
|
|
|
|
|
|
|
|
|
func = get_compute_function(graph, process_2_2, machine)
|
|
|
|
|
@test isapprox(func(particles_2_2), expected_result; rtol = 0.001)
|
|
|
|
|
@test isapprox(func(particles_2_2), expected_result; rtol = RTOL)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@testset "AB->AB after random walk" begin
|
|
|
|
|
for i in 1:1000
|
|
|
|
|
for i in 1:200
|
|
|
|
|
graph = parse_dag(joinpath(@__DIR__, "..", "input", "AB->AB.txt"), ABCModel())
|
|
|
|
|
random_walk!(graph, 50)
|
|
|
|
|
|
|
|
|
|
@test is_valid(graph)
|
|
|
|
|
|
|
|
|
|
@test isapprox(execute(graph, process_2_2, machine, particles_2_2), expected_result; rtol = 0.001)
|
|
|
|
|
@test isapprox(execute(graph, process_2_2, machine, particles_2_2), expected_result; rtol = RTOL)
|
|
|
|
|
|
|
|
|
|
# graph should be fully scheduled after being executed
|
|
|
|
|
@test is_scheduled(graph)
|
|
|
|
@@ -63,20 +105,20 @@ include("../examples/profiling_utilities.jl")
|
|
|
|
|
@testset "AB->ABBB no optimization" begin
|
|
|
|
|
for _ in 1:5 # test in a loop because graph layout should not change the result
|
|
|
|
|
graph = parse_dag(joinpath(@__DIR__, "..", "input", "AB->ABBB.txt"), ABCModel())
|
|
|
|
|
@test isapprox(execute(graph, process_2_4, machine, particles_2_4), expected_result; rtol = 0.001)
|
|
|
|
|
@test isapprox(execute(graph, process_2_4, machine, particles_2_4), expected_result; rtol = RTOL)
|
|
|
|
|
|
|
|
|
|
func = get_compute_function(graph, process_2_4, machine)
|
|
|
|
|
@test isapprox(func(particles_2_4), expected_result; rtol = 0.001)
|
|
|
|
|
@test isapprox(func(particles_2_4), expected_result; rtol = RTOL)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@testset "AB->ABBB after random walk" begin
|
|
|
|
|
for i in 1:200
|
|
|
|
|
for i in 1:50
|
|
|
|
|
graph = parse_dag(joinpath(@__DIR__, "..", "input", "AB->ABBB.txt"), ABCModel())
|
|
|
|
|
random_walk!(graph, 100)
|
|
|
|
|
@test is_valid(graph)
|
|
|
|
|
|
|
|
|
|
@test isapprox(execute(graph, process_2_4, machine, particles_2_4), expected_result; rtol = 0.001)
|
|
|
|
|
@test isapprox(execute(graph, process_2_4, machine, particles_2_4), expected_result; rtol = RTOL)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@@ -105,8 +147,8 @@ include("../examples/profiling_utilities.jl")
|
|
|
|
|
|
|
|
|
|
# try execute
|
|
|
|
|
@test is_valid(graph)
|
|
|
|
|
expected_result = 0.00013916495566048735
|
|
|
|
|
@test isapprox(execute(graph, process_2_2, machine, particles_2_2), expected_result; rtol = 0.001)
|
|
|
|
|
expected_result = ground_truth_graph_result(particles_2_2)
|
|
|
|
|
@test isapprox(execute(graph, process_2_2, machine, particles_2_2), expected_result; rtol = RTOL)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -135,8 +177,8 @@ include("../examples/profiling_utilities.jl")
|
|
|
|
|
|
|
|
|
|
# try execute
|
|
|
|
|
@test is_valid(graph)
|
|
|
|
|
expected_result = 0.00013916495566048735
|
|
|
|
|
@test isapprox(execute(graph, process_2_2, machine, particles_2_2), expected_result; rtol = 0.001)
|
|
|
|
|
expected_result = ground_truth_graph_result(particles_2_2)
|
|
|
|
|
@test isapprox(execute(graph, process_2_2, machine, particles_2_2), expected_result; rtol = RTOL)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@testset "AB->AB fusion edge case" for _ in 1:20
|
|
|
|
@@ -169,8 +211,8 @@ include("../examples/profiling_utilities.jl")
|
|
|
|
|
|
|
|
|
|
# try execute
|
|
|
|
|
@test is_valid(graph)
|
|
|
|
|
expected_result = 0.00013916495566048735
|
|
|
|
|
@test isapprox(execute(graph, process_2_2, machine, particles_2_2), expected_result; rtol = 0.001)
|
|
|
|
|
expected_result = ground_truth_graph_result(particles_2_2)
|
|
|
|
|
@test isapprox(execute(graph, process_2_2, machine, particles_2_2), expected_result; rtol = RTOL)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|