Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perturbative Compton #40

Merged
merged 70 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
81e9404
updated differential cross section and tests
Nov 21, 2023
044c8c6
formatting
Nov 21, 2023
3c231fc
rearranged probabilities in separate file; added unit tests for proba…
Nov 21, 2023
8fbc037
formatting
Nov 21, 2023
d5e9f1a
started adding unittests for safe evaluation
Nov 23, 2023
3c97861
cleanup
Nov 23, 2023
a2ebca3
rearranged and finalized tests for cross sections and probabilities
Nov 23, 2023
3896bbf
cleanup Project.toml
Nov 23, 2023
83e2964
formatting
Nov 23, 2023
e0ce33b
end of day
Nov 30, 2023
6491775
added missing doc-strings and renames probability -> differentia_prob…
Jan 28, 2024
055f20e
added interface total cross section and probability, adjusted tests a…
Feb 1, 2024
5a152c5
formatting
Feb 1, 2024
c95d736
added coordiante-based implementation for probabilities and different…
Nov 29, 2023
7b1f730
formatting
Nov 29, 2023
5e640ad
added generic fallback for coordinate-based phasespace check
Nov 30, 2023
df59e98
added utils for flattening of momenta to tests
Nov 30, 2023
0ac64d1
added more sophisticated tests for probability and cross section, fix…
Feb 6, 2024
72126ef
added reminder for doc strings, applied formatting
Feb 6, 2024
696fa8a
updated comment
Feb 20, 2024
d08c741
rebased on current dev, debugging
Mar 8, 2024
793e9c2
removed utils from tests
Mar 8, 2024
e41f52e
removed doublings in tests
Mar 8, 2024
8d09791
removed doublings in tests
Mar 8, 2024
0795f74
added docstrings
Mar 12, 2024
2bb21d5
Apply suggestions from code review
szabo137 Mar 24, 2024
cba6238
bugfix in test implementation
Mar 25, 2024
51b583b
factored out phase space validity check
Apr 2, 2024
436bd4c
started refactoring of differential cross sections
Nov 14, 2023
d571da0
updated differential cross section and tests
Nov 21, 2023
edfa6d3
formatting
Nov 21, 2023
3a5ae50
rearranged probabilities in separate file; added unit tests for proba…
Nov 21, 2023
92c9a0d
formatting
Nov 21, 2023
c3de08e
started adding unittests for safe evaluation
Nov 23, 2023
6e534b6
rearranged and finalized tests for cross sections and probabilities
Nov 23, 2023
6c21933
cleanup Project.toml
Nov 23, 2023
b3bd151
formatting
Nov 23, 2023
026c2b8
end of day
Nov 30, 2023
c9fc4eb
added missing doc-strings and renames probability -> differentia_prob…
Jan 28, 2024
a1acf6b
added interface total cross section and probability, adjusted tests a…
Feb 1, 2024
47403bb
formatting
Feb 1, 2024
a19b0fd
added coordiante-based implementation for probabilities and different…
Nov 29, 2023
fd8fabf
formatting
Nov 29, 2023
e762624
added generic fallback for coordinate-based phasespace check
Nov 30, 2023
fc38d70
added more sophisticated tests for probability and cross section, fix…
Feb 6, 2024
e702c88
added reminder for doc strings, applied formatting
Feb 6, 2024
e155000
add physical constants
Feb 22, 2024
9ef7b8d
patch QEDbase: add polarization functionality
Feb 22, 2024
b85768a
bugfix: process interface + updated some doc-strings
Feb 22, 2024
e7dc916
added perturbative QED as compute model
Feb 22, 2024
b531467
add implementation of the cross section interface
Feb 22, 2024
b654c4d
added StaticArrays to deps
Feb 22, 2024
49fc844
added tests for perturbative compton
Feb 22, 2024
6cb2ef2
bugfix after rebase
Mar 26, 2024
fb7245f
formatting
Mar 26, 2024
70ede25
bugfix after rebase
Apr 2, 2024
2351a96
cleanup
May 14, 2024
a58e241
Merge branch 'dev' into dev-perturbative-compton
May 14, 2024
007d8bd
fixed merge conflicts and adopted current dev
May 14, 2024
600687f
formatting
May 14, 2024
35b9fff
cleanup
May 14, 2024
cb66173
removed unnecessary omega_prime function
May 14, 2024
446f002
removed .vscode
May 14, 2024
2b781f5
formatting
May 14, 2024
f2a1104
Apply suggestions from code review
szabo137 May 15, 2024
bb7f08c
minor changes suggested from review
May 15, 2024
1725694
added total cross section
May 16, 2024
201cc63
formatting
May 16, 2024
49db1d9
bugfix in incident flux
May 16, 2024
87ee685
cleanup
May 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = "0.1.0"

[deps]
QEDbase = "10e22c08-3ccb-4172-bfcf-7d7aa3d04d93"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[compat]
Expand Down
1 change: 1 addition & 0 deletions src/QEDprocesses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export Compton, omega_prime

using QEDbase
using StaticArrays
using QuadGK

include("constants.jl")
include("utils.jl")
Expand Down
1 change: 1 addition & 0 deletions src/processes/one_photon_compton/one_photon_compton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
include("process.jl")
include("perturbative/kinematics.jl")
include("perturbative/cross_section.jl")
include("perturbative/total_probability.jl")
15 changes: 14 additions & 1 deletion src/processes/one_photon_compton/perturbative/kinematics.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

@inline function _pert_omega_prime(omega, cth; mass=1.0)
return omega / (1 + omega / mass * (1 - cth))
end
Expand All @@ -13,6 +12,20 @@ function generate_momenta(
return _generate_momenta(proc, model, in_ps_def, in_ps, out_ps)
end

function _generate_incoming_momenta(
proc::Compton,
model::PerturbativeQED,
in_ps_def::PhasespaceDefinition{SphericalCoordinateSystem,ElectronRestFrame},
in_ps::AbstractVector{T},
) where {T<:Real}
om = in_ps[1]

P = SFourMomentum(one(om), zero(om), zero(om), zero(om))
K = SFourMomentum(om, zero(om), zero(om), om)

return [P, K]
end

function _generate_momenta(
proc::Compton,
model::PerturbativeQED,
Expand Down
20 changes: 20 additions & 0 deletions src/processes/one_photon_compton/perturbative/total_probability.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

function _total_probability(
proc::Compton,
model::PerturbativeQED,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVector{T},
) where {T<:QEDbase.AbstractFourMomentum}
omega = getE(in_phase_space[2])

function func(x)
return unsafe_differential_probability(
proc, model, in_phase_space_def, [omega], [x, 0.0]
)
end

tot_prob, _ = quadgk(func, -1, 1; rtol=sqrt(eps(omega)))

tot_prob *= 2 * pi # phi integration is trivial
return tot_prob
end
61 changes: 31 additions & 30 deletions test/processes/one_photon_compton/perturbative.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ using Random
using StaticArrays
using QuadGK

RNG = MersenneTwister(77697185)
ATOL = eps()
RTOL = sqrt(eps())
const RNG = MersenneTwister(77697185)
const ATOL = eps()
const 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))
const MODEL = PerturbativeQED()
const PS_DEF = PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame())
const OMEGAS = (1e-6 * rand(RNG), 1e-3 * rand(RNG), rand(RNG), 1e3 * rand(RNG))
#OMEGAS = (rand(RNG),)
AntonReinhard marked this conversation as resolved.
Show resolved Hide resolved

COS_THETAS = [-1.0, 2 * rand(RNG) - 1, 0.0, 1.0]
PHIS = [0, 2 * pi, rand(RNG) * 2 * pi]
const COS_THETAS = [-1.0, 2 * rand(RNG) - 1, 0.0, 1.0]
const PHIS = [0, 2 * pi, rand(RNG) * 2 * pi]

@testset "perturbative kinematics" begin
PROC = Compton()
Expand All @@ -39,7 +39,7 @@ PHIS = [0, 2 * pi, rand(RNG) * 2 * pi]
end
end

@testset "perturbative cross section" begin
@testset "perturbative" begin
@testset "$omega" for omega in OMEGAS
@testset "differential cross section" begin
@testset "spin and pol summed" begin
Expand Down Expand Up @@ -93,26 +93,27 @@ 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(in_ps)
function func(x)
return unsafe_differential_cross_section(
Compton(), PerturbativeQED(), PS_DEF, in_ps, [x, 0.0]
)
end
res, err = quadgk(func, -1, 1)

# note: mul by 2pi instead of the phi-integration
return 2 * pi * res
end

IN_COORDS = [omega]
groundtruth = klein_nishina_total_cross_section(IN_COORDS)
test_val = @inferred total_cross_section(PROC, MODEL, PS_DEF, IN_COORDS)
@test isapprox(test_val, groundtruth, atol=ATOL, rtol=RTOL)
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
Loading