-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tests for perturbative compton
- Loading branch information
Uwe Hernandez Acosta
committed
Feb 22, 2024
1 parent
5054b76
commit 341bc8e
Showing
5 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
""" | ||
Klein-Nishina: differential cross section | ||
source: Peskin, Schroeder. "Quantum field theory." (1995). eq: 5.91 | ||
note: we compute d sigma/ d Omega, and *not* d sigma/ d cos theta (the difference is a factor 2 pi) | ||
""" | ||
function _groundtruth_pert_compton_diffCS_spinsum_polsum(om, cth, mass) | ||
prefac = ALPHA_SQUARE / 2 | ||
omp = QEDprocesses._pert_omega_prime(om, cth) | ||
sth_sq = 1 - cth^2 | ||
return prefac * (omp / om)^2 * (omp / om + om / omp - sth_sq) | ||
end | ||
|
||
function _groundtruth_pert_compton_diffCS_spinsum_xpol(omega, ctheta, phi, mass) | ||
om_prime = omega_prime(PerturbativeQED(), omega, ctheta; mass=mass) | ||
om_prime_over_om = om_prime / omega | ||
return 0.5 * ALPHA_SQUARE / mass^2 * | ||
om_prime_over_om^2 * | ||
(om_prime_over_om + 1.0 / om_prime_over_om - 2 * (1 - ctheta^2) * cos(phi)^2) | ||
end | ||
|
||
function _groundtruth_pert_compton_diffCS_spinsum_ypol(omega, ctheta, phi, mass) | ||
return _groundtruth_pert_compton_diffCS_spinsum_xpol(omega, ctheta, phi + pi / 2, mass) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
|
||
using QEDbase | ||
using QEDprocesses | ||
using Random | ||
using StaticArrays | ||
using QuadGK | ||
|
||
RNG = MersenneTwister(77697185) | ||
ATOL = eps() | ||
RTOL = sqrt(eps()) | ||
|
||
include("groundtruths.jl") | ||
|
||
MODEL = PerturbativeQED() | ||
PS_DEF = PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame()) | ||
OMEGAS = (1e-6 * rand(RNG), 1e-3 * rand(RNG), rand(RNG), 1e3 * rand(RNG)) | ||
#OMEGAS = (rand(RNG),) | ||
|
||
COS_THETAS = [-1.0, 2 * rand(RNG) - 1, 0.0, 1.0] | ||
PHIS = [0, 2 * pi, rand(RNG) * 2 * pi] | ||
|
||
@testset "perturbative kinematics" begin | ||
PROC = Compton() | ||
@testset "momentum generation" begin | ||
@testset "$om, $cth, $phi" for (om, cth, phi) in | ||
Iterators.product(OMEGAS, COS_THETAS, PHIS) | ||
IN_COORDS = [om] | ||
OUT_COORDS = [cth, phi] | ||
IN_PS, OUT_PS = QEDprocesses._generate_momenta( | ||
PROC, MODEL, PS_DEF, IN_COORDS, PS_DEF, OUT_COORDS | ||
) | ||
in_mom_square = getMass2.(IN_PS) | ||
out_mom_square = getMass2.(OUT_PS) | ||
in_masses = mass.(incoming_particles(PROC)) .^ 2 | ||
out_masses = mass.(outgoing_particles(PROC)) | ||
@test isapprox(in_mom_square, SVector(in_masses)) | ||
@test isapprox(out_mom_square, SVector(out_masses)) | ||
end | ||
end | ||
end | ||
|
||
@testset "perturbative cross section" begin | ||
@testset "$omega" for omega in OMEGAS | ||
@testset "differential cross section" begin | ||
@testset "spin and pol summed" begin | ||
PROC = Compton() | ||
|
||
@testset "$cos_theta $phi" for (cos_theta, phi) in | ||
Iterators.product(COS_THETAS, PHIS) | ||
IN_COORDS = [omega] | ||
OUT_COORDS = [cos_theta, phi] | ||
groundtruth = _groundtruth_pert_compton_diffCS_spinsum_polsum( | ||
omega, cos_theta, 1.0 | ||
) | ||
test_val = unsafe_differential_cross_section( | ||
PROC, MODEL, PS_DEF, IN_COORDS, PS_DEF, OUT_COORDS | ||
) | ||
@test isapprox(test_val, groundtruth, atol=ATOL, rtol=RTOL) | ||
end | ||
end | ||
|
||
@testset "x-pol and spin summed" begin | ||
PROC = Compton(PolX()) | ||
|
||
@testset "$cos_theta $phi" for (cos_theta, phi) in | ||
Iterators.product(COS_THETAS, PHIS) | ||
IN_COORDS = [omega] | ||
OUT_COORDS = [cos_theta, phi] | ||
groundtruth = _groundtruth_pert_compton_diffCS_spinsum_xpol( | ||
omega, cos_theta, phi, 1.0 | ||
) | ||
test_val = unsafe_differential_cross_section( | ||
PROC, MODEL, PS_DEF, IN_COORDS, PS_DEF, OUT_COORDS | ||
) | ||
@test isapprox(test_val, groundtruth, atol=ATOL, rtol=RTOL) | ||
end | ||
end | ||
|
||
@testset "y-pol and spin summed" begin | ||
PROC = Compton(PolY()) | ||
|
||
@testset "$cos_theta $phi" for (cos_theta, phi) in | ||
Iterators.product(COS_THETAS, PHIS) | ||
IN_COORDS = [omega] | ||
OUT_COORDS = [cos_theta, phi] | ||
groundtruth = _groundtruth_pert_compton_diffCS_spinsum_ypol( | ||
omega, cos_theta, phi, 1.0 | ||
) | ||
test_val = unsafe_differential_cross_section( | ||
PROC, MODEL, PS_DEF, IN_COORDS, PS_DEF, OUT_COORDS | ||
) | ||
@test isapprox(test_val, groundtruth, atol=ATOL, rtol=RTOL) | ||
end | ||
end | ||
end | ||
end | ||
# @testset "total cross section" begin | ||
# @testset "spin and pol summed" begin | ||
# PROC = Compton() | ||
# # Klein-Nishina: total cross section | ||
# function klein_nishina_total_cross_section(om, mass) | ||
# function func(x) | ||
# return differential_cross_section_on_coord( | ||
# Compton(), PerturbativeQED(), om, [x, 0.0] | ||
# ) | ||
# end | ||
# res, err = quadgk(func, -1, 1) | ||
# | ||
# # note: mul by 2pi instead of the phi-integration | ||
# return 2 * pi * res | ||
# end | ||
# | ||
# groundtruth = klein_nishina_total_cross_section(OMEGA, MASS) | ||
# test_val = @inferred total_cross_section_on_coord(PROC, MODEL, OMEGA) | ||
# @test isapprox(test_val, groundtruth, atol=ATOL, rtol=RTOL) | ||
# end | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using QEDprocesses | ||
using Random | ||
using QEDbase | ||
using QEDprocesses | ||
|
||
POLS = [PolX(), PolY(), AllPol()] | ||
SPINS = [SpinUp(), SpinDown(), AllSpin()] | ||
POL_AND_SPIN_COMBINATIONS = Iterators.product(SPINS, POLS, SPINS, POLS) | ||
POL_COMBINATIONS = Iterators.product(POLS, POLS) | ||
|
||
@testset "constructor" begin | ||
@testset "default" begin | ||
proc = Compton() | ||
@test QEDprocesses._spin_or_pol(proc, Photon(), Incoming()) == AllPol() | ||
@test QEDprocesses._spin_or_pol(proc, Electron(), Incoming()) == AllSpin() | ||
@test QEDprocesses._spin_or_pol(proc, Photon(), Outgoing()) == AllPol() | ||
@test QEDprocesses._spin_or_pol(proc, Electron(), Outgoing()) == AllSpin() | ||
end | ||
|
||
@testset "in_pol" begin | ||
@testset "$pol" for pol in POLS | ||
proc = Compton(pol) | ||
@test QEDprocesses._spin_or_pol(proc, Electron(), Incoming()) == AllSpin() | ||
@test QEDprocesses._spin_or_pol(proc, Photon(), Incoming()) == pol | ||
@test QEDprocesses._spin_or_pol(proc, Electron(), Outgoing()) == AllSpin() | ||
@test QEDprocesses._spin_or_pol(proc, Photon(), Outgoing()) == AllPol() | ||
end | ||
end | ||
|
||
@testset "in_pol+out_pol" begin | ||
@testset "$in_pol, $out_pol" for (in_pol, out_pol) in POL_COMBINATIONS | ||
proc = Compton(in_pol, out_pol) | ||
@test QEDprocesses._spin_or_pol(proc, Electron(), Incoming()) == AllSpin() | ||
@test QEDprocesses._spin_or_pol(proc, Photon(), Incoming()) == in_pol | ||
@test QEDprocesses._spin_or_pol(proc, Electron(), Outgoing()) == AllSpin() | ||
@test QEDprocesses._spin_or_pol(proc, Photon(), Outgoing()) == out_pol | ||
end | ||
end | ||
@testset "all spins+pols" begin | ||
@testset "$in_spin, $in_pol, $out_spin, $out_pol" for ( | ||
in_spin, in_pol, out_spin, out_pol | ||
) in POL_AND_SPIN_COMBINATIONS | ||
proc = Compton(in_spin, in_pol, out_spin, out_pol) | ||
@test QEDprocesses._spin_or_pol(proc, Electron(), Incoming()) == in_spin | ||
@test QEDprocesses._spin_or_pol(proc, Photon(), Incoming()) == in_pol | ||
@test QEDprocesses._spin_or_pol(proc, Electron(), Outgoing()) == out_spin | ||
@test QEDprocesses._spin_or_pol(proc, Photon(), Outgoing()) == out_pol | ||
end | ||
end | ||
end | ||
@testset "particle content" begin | ||
proc = Compton() | ||
@test incoming_particles(proc) == (Electron(), Photon()) | ||
@test outgoing_particles(proc) == (Electron(), Photon()) | ||
@test number_incoming_particles(proc) == 2 | ||
@test number_outgoing_particles(proc) == 2 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
@time @safetestset "general one photon compton" begin | ||
include("one_photon_compton/process.jl") | ||
end | ||
|
||
@time @safetestset "perturbative one photon compton" begin | ||
include("one_photon_compton/perturbative.jl") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters