|
| 1 | + |
| 2 | +using QEDbase |
| 3 | +using QEDprocesses |
| 4 | +using Random |
| 5 | +using StaticArrays |
| 6 | +using QuadGK |
| 7 | + |
| 8 | +RNG = MersenneTwister(77697185) |
| 9 | +ATOL = eps() |
| 10 | +RTOL = sqrt(eps()) |
| 11 | + |
| 12 | +include("groundtruths.jl") |
| 13 | + |
| 14 | +MODEL = PerturbativeQED() |
| 15 | +PS_DEF = PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame()) |
| 16 | +OMEGAS = (1e-6 * rand(RNG), 1e-3 * rand(RNG), rand(RNG), 1e3 * rand(RNG)) |
| 17 | +#OMEGAS = (rand(RNG),) |
| 18 | + |
| 19 | +COS_THETAS = [-1.0, 2 * rand(RNG) - 1, 0.0, 1.0] |
| 20 | +PHIS = [0, 2 * pi, rand(RNG) * 2 * pi] |
| 21 | + |
| 22 | +@testset "perturbative kinematics" begin |
| 23 | + PROC = Compton() |
| 24 | + @testset "momentum generation" begin |
| 25 | + @testset "$om, $cth, $phi" for (om, cth, phi) in |
| 26 | + Iterators.product(OMEGAS, COS_THETAS, PHIS) |
| 27 | + IN_COORDS = [om] |
| 28 | + OUT_COORDS = [cth, phi] |
| 29 | + IN_PS, OUT_PS = QEDprocesses._generate_momenta( |
| 30 | + PROC, MODEL, PS_DEF, IN_COORDS, PS_DEF, OUT_COORDS |
| 31 | + ) |
| 32 | + in_mom_square = getMass2.(IN_PS) |
| 33 | + out_mom_square = getMass2.(OUT_PS) |
| 34 | + in_masses = mass.(incoming_particles(PROC)) .^ 2 |
| 35 | + out_masses = mass.(outgoing_particles(PROC)) |
| 36 | + @test isapprox(in_mom_square, SVector(in_masses)) |
| 37 | + @test isapprox(out_mom_square, SVector(out_masses)) |
| 38 | + end |
| 39 | + end |
| 40 | +end |
| 41 | + |
| 42 | +@testset "perturbative cross section" begin |
| 43 | + @testset "$omega" for omega in OMEGAS |
| 44 | + @testset "differential cross section" begin |
| 45 | + @testset "spin and pol summed" begin |
| 46 | + PROC = Compton() |
| 47 | + |
| 48 | + @testset "$cos_theta $phi" for (cos_theta, phi) in |
| 49 | + Iterators.product(COS_THETAS, PHIS) |
| 50 | + IN_COORDS = [omega] |
| 51 | + OUT_COORDS = [cos_theta, phi] |
| 52 | + groundtruth = _groundtruth_pert_compton_diffCS_spinsum_polsum( |
| 53 | + omega, cos_theta, 1.0 |
| 54 | + ) |
| 55 | + test_val = unsafe_differential_cross_section( |
| 56 | + PROC, MODEL, PS_DEF, IN_COORDS, PS_DEF, OUT_COORDS |
| 57 | + ) |
| 58 | + @test isapprox(test_val, groundtruth, atol=ATOL, rtol=RTOL) |
| 59 | + end |
| 60 | + end |
| 61 | + |
| 62 | + @testset "x-pol and spin summed" begin |
| 63 | + PROC = Compton(PolX()) |
| 64 | + |
| 65 | + @testset "$cos_theta $phi" for (cos_theta, phi) in |
| 66 | + Iterators.product(COS_THETAS, PHIS) |
| 67 | + IN_COORDS = [omega] |
| 68 | + OUT_COORDS = [cos_theta, phi] |
| 69 | + groundtruth = _groundtruth_pert_compton_diffCS_spinsum_xpol( |
| 70 | + omega, cos_theta, phi, 1.0 |
| 71 | + ) |
| 72 | + test_val = unsafe_differential_cross_section( |
| 73 | + PROC, MODEL, PS_DEF, IN_COORDS, PS_DEF, OUT_COORDS |
| 74 | + ) |
| 75 | + @test isapprox(test_val, groundtruth, atol=ATOL, rtol=RTOL) |
| 76 | + end |
| 77 | + end |
| 78 | + |
| 79 | + @testset "y-pol and spin summed" begin |
| 80 | + PROC = Compton(PolY()) |
| 81 | + |
| 82 | + @testset "$cos_theta $phi" for (cos_theta, phi) in |
| 83 | + Iterators.product(COS_THETAS, PHIS) |
| 84 | + IN_COORDS = [omega] |
| 85 | + OUT_COORDS = [cos_theta, phi] |
| 86 | + groundtruth = _groundtruth_pert_compton_diffCS_spinsum_ypol( |
| 87 | + omega, cos_theta, phi, 1.0 |
| 88 | + ) |
| 89 | + test_val = unsafe_differential_cross_section( |
| 90 | + PROC, MODEL, PS_DEF, IN_COORDS, PS_DEF, OUT_COORDS |
| 91 | + ) |
| 92 | + @test isapprox(test_val, groundtruth, atol=ATOL, rtol=RTOL) |
| 93 | + end |
| 94 | + end |
| 95 | + end |
| 96 | + end |
| 97 | + # @testset "total cross section" begin |
| 98 | + # @testset "spin and pol summed" begin |
| 99 | + # PROC = Compton() |
| 100 | + # # Klein-Nishina: total cross section |
| 101 | + # function klein_nishina_total_cross_section(om, mass) |
| 102 | + # function func(x) |
| 103 | + # return differential_cross_section_on_coord( |
| 104 | + # Compton(), PerturbativeQED(), om, [x, 0.0] |
| 105 | + # ) |
| 106 | + # end |
| 107 | + # res, err = quadgk(func, -1, 1) |
| 108 | + # |
| 109 | + # # note: mul by 2pi instead of the phi-integration |
| 110 | + # return 2 * pi * res |
| 111 | + # end |
| 112 | + # |
| 113 | + # groundtruth = klein_nishina_total_cross_section(OMEGA, MASS) |
| 114 | + # test_val = @inferred total_cross_section_on_coord(PROC, MODEL, OMEGA) |
| 115 | + # @test isapprox(test_val, groundtruth, atol=ATOL, rtol=RTOL) |
| 116 | + # end |
| 117 | + # end |
| 118 | +end |
0 commit comments