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

Coordinate-based evaluation of differential cross-sections and probabilities #39

Merged
merged 28 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 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
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
8 changes: 6 additions & 2 deletions src/QEDprocesses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ export AbstractModelDefinition, fundamental_interaction_type

# Abstract process interface
export AbstractProcessDefinition, incoming_particles, outgoing_particles
export in_phasespace_dimension, out_phasespace_dimension
export number_incoming_particles, number_outgoing_particles

# probabilities
export differential_probability, unsafe_differential_probability
export total_probability

# probabilities
export differential_probability, unsafe_differential_probability
export total_probability

# differential cross section
export differential_cross_section, unsafe_differential_cross_section
export total_cross_section
Expand All @@ -31,11 +34,12 @@ export AbstractPhasespaceDefinition, PhasespaceDefinition
using QEDbase

include("utils.jl")
include("phase_spaces.jl")
include("interfaces/model_interface.jl")
include("interfaces/process_interface.jl")
include("interfaces/setup_interface.jl")
include("momentum_generation.jl")
include("propagators.jl")
include("phase_spaces.jl")
include("probabilities.jl")
include("cross_sections.jl")
end
188 changes: 177 additions & 11 deletions src/cross_sections.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
########################
# differential cross sections and probabilities.
# differential and total cross sections.
szabo137 marked this conversation as resolved.
Show resolved Hide resolved
#
# This file contains default implementations for differential and total cross
# sections based on the scattering process interface
########################

############
#
# differential cross sections
#
############

# differential cross sections without energy momentum conservation check
# single in phase space point/ single out phase space point
# based on four-momenta
function _unsafe_differential_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
Expand All @@ -33,6 +32,30 @@ function _unsafe_differential_cross_section(
)
end

# differential cross sections without energy momentum conservation check
# single in phase space point/ single out phase space point
# based on coordinates
function _unsafe_differential_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVector{T},
out_phase_space_def::AbstractPhasespaceDefinition,
out_phase_space::AbstractVector{T},
) where {T<:Real}
in_momenta, out_momenta = _generate_momenta(
proc,
model,
in_phase_space_def,
in_phase_space,
out_phase_space_def,
out_phase_space,
)
return _unsafe_differential_cross_section(
proc, model, in_phase_space_def, in_momenta, out_phase_space_def, out_momenta
)
end

# differential cross sections without energy momentum conservation check
# single in phase space point/ several out phase space points
function _unsafe_differential_cross_section(
Expand All @@ -42,7 +65,7 @@ function _unsafe_differential_cross_section(
in_phase_space::AbstractVector{T},
out_phase_space_def::AbstractPhasespaceDefinition,
out_phase_space::AbstractMatrix{T},
) where {T<:QEDbase.AbstractFourMomentum}
) where {T<:AbstractPhasespaceElement}
res = Vector{eltype(T)}(undef, size(out_phase_space, 2))
for i in 1:size(out_phase_space, 2)
res[i] = _unsafe_differential_cross_section(
Expand All @@ -66,7 +89,7 @@ function _unsafe_differential_cross_section(
in_phase_space::AbstractMatrix{T},
out_phase_space_def::AbstractPhasespaceDefinition,
out_phase_space::AbstractVecOrMat{T},
) where {T<:QEDbase.AbstractFourMomentum}
) where {T<:AbstractPhasespaceElement}
res = Matrix{eltype(T)}(undef, size(in_phase_space, 2), size(out_phase_space, 2))
for i in 1:size(in_phase_space, 2)
res[i, :] .= _unsafe_differential_cross_section(
Expand All @@ -92,7 +115,7 @@ end
out_phase_space::AbstractVecOrMat{T},
) where {T<:QEDbase.AbstractFourMomentum}

Return the differential cross section without checking if the given phase space(s) are physical.
Return the differential cross section evaluated at the four-momenta without checking if the given phase space(s) are physical.
"""
function unsafe_differential_cross_section(
proc::AbstractProcessDefinition,
Expand Down Expand Up @@ -124,6 +147,48 @@ function unsafe_differential_cross_section(
)
end

"""
unsafe_differential_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVecOrMat{T},
out_phase_space_def::AbstractPhasespaceDefinition,
out_phase_space::AbstractVecOrMat{T},
) where {T<:Real}

Return the differential cross section evaluated at the coordinates without checking if the given phase space(s) are physical.
"""
function unsafe_differential_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVecOrMat{T},
out_phase_space_def::AbstractPhasespaceDefinition,
out_phase_space::AbstractVecOrMat{T},
) where {T<:Real}
size(in_phase_space, 1) == in_phase_space_dimension(proc, model) || throw(
DimensionMismatch(
"The dimension of the in-phase-space <$(in_phase_space_dimension(proc,model))> is inconsistent with input size <$(size(in_phase_space,1))>",
),
)

size(out_phase_space, 1) == out_phase_space_dimension(proc, model) || throw(
DimensionMismatch(
"The dimension of the out-phase-space <$(out_phase_space_dimension(proc,model))> is inconsistent with input size <$(size(out_phase_space,1))>",
),
)

return _unsafe_differential_cross_section(
proc,
model,
in_phase_space_def,
in_phase_space,
out_phase_space_def,
out_phase_space,
)
end

# differential cross sections with energy momentum conservation check
# single in phase space point/ single out phase space point
function _differential_cross_section(
Expand Down Expand Up @@ -157,14 +222,35 @@ end

# differential cross sections with energy momentum conservation check
# single in phase space point/ several out phase space points
function _differential_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVector{T},
out_phase_space_def::AbstractPhasespaceDefinition,
out_phase_space::AbstractVector{T},
)::Float64 where {T<:Real}
in_momenta, out_momenta = _generate_momenta(
proc,
model,
in_phase_space_def,
in_phase_space,
out_phase_space_def,
out_phase_space,
)
return _differential_cross_section(
proc, model, in_phase_space_def, in_momenta, out_phase_space_def, out_momenta
)
end

function _differential_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVector{T},
out_phase_space_def::AbstractPhasespaceDefinition,
out_phase_space::AbstractMatrix{T},
) where {T<:QEDbase.AbstractFourMomentum}
) where {T<:AbstractPhasespaceElement}
res = Vector{eltype(T)}(undef, size(out_phase_space, 2))
for i in 1:size(out_phase_space, 2)
res[i] = _differential_cross_section(
Expand All @@ -188,7 +274,7 @@ function _differential_cross_section(
in_phase_space::AbstractMatrix{T},
out_phase_space_def::AbstractPhasespaceDefinition,
out_phase_space::AbstractVecOrMat{T},
) where {T<:QEDbase.AbstractFourMomentum}
) where {T<:AbstractPhasespaceElement}
res = Matrix{eltype(T)}(undef, size(in_phase_space, 2), size(out_phase_space, 2))
for i in 1:size(in_phase_space, 2)
res[i, :] .= _differential_cross_section(
Expand All @@ -213,7 +299,7 @@ end
out_phase_space::AbstractVecOrMat{T},
) where {T<:QEDbase.AbstractFourMomentum}

If the given phase spaces are physical, return differential cross section. Zero otherwise
If the given phase spaces are physical, return differential cross section evaluated at the four-momenta. Zero otherwise.

"""
function differential_cross_section(
Expand Down Expand Up @@ -246,11 +332,54 @@ function differential_cross_section(
)
end

"""
differential_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVecOrMat{T},
out_phase_space_def::AbstractPhasespaceDefinition,
out_phase_space::AbstractVecOrMat{T},
) where {T<:Real}

If the given phase spaces are physical, return differential cross section evaluated at the coordinates. Zero otherwise.
"""
function differential_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVecOrMat{T},
out_phase_space_def::AbstractPhasespaceDefinition,
out_phase_space::AbstractVecOrMat{T},
) where {T<:Real}
size(in_phase_space, 1) == in_phase_space_dimension(proc, model) || throw(
DimensionMismatch(
"The dimension of the in-phase-space <$(in_phase_space_dimension(proc,model))> is inconsistent with input size <$(size(in_phase_space,1))>",
),
)

size(out_phase_space, 1) == out_phase_space_dimension(proc, model) || throw(
DimensionMismatch(
"The dimension of the out-phase-space <$(out_phase_space_dimension(proc,model))> is inconsistent with input size <$(size(out_phase_space,1))>",
),
)

return _differential_cross_section(
proc,
model,
in_phase_space_def,
in_phase_space,
out_phase_space_def,
out_phase_space,
)
end

############
# Total cross sections
############

# total cross section on single phase space point
# based on four-momenta
function _total_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
Expand All @@ -262,13 +391,25 @@ function _total_cross_section(
return I * _total_probability(proc, model, in_phase_space_def, in_phase_space)
end

# total cross section on single phase space point
# based on coordinates
function _total_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVector{T},
) where {T<:Real}
in_momenta = _generate_incoming_momenta(proc, model, in_phase_space_def, in_phase_space)
return _total_cross_section(proc, model, in_phase_space_def, in_momenta)
end

# total cross section on several phase space points
function _total_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractMatrix{T},
) where {T<:QEDbase.AbstractFourMomentum}
) where {T<:AbstractPhasespaceElement}
res = Vector{eltype(T)}(undef, size(in_phase_space, 2))
for i in 1:size(in_phase_space, 2)
res[i] = _total_cross_section(
Expand All @@ -286,7 +427,7 @@ end
in_phase_space::AbstractVecOrMat{T},
) where {T<:QEDbase.AbstractFourMomentum}

Return the total cross section for a given combination of scattering process and compute model.
Return the total cross section for a given combination of scattering process and compute model, evaluated at the particle momenta.
"""
function total_cross_section(
proc::AbstractProcessDefinition,
Expand All @@ -302,3 +443,28 @@ function total_cross_section(

return _total_cross_section(proc, model, in_phase_space_def, in_phase_space)
end

"""
total_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVecOrMat{T},
) where {T<:Real}

Return the total cross section for a given combination of scattering process and compute model, evaluated at the coordinates.
"""
function QEDprocesses.total_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVecOrMat{T},
) where {T<:Real}
size(in_phase_space, 1) == in_phase_space_dimension(proc, model) || throw(
DimensionMismatch(
"The dimension of the in-phase-space <$(in_phase_space_dimension(proc,model))> is inconsistent with input size <$(size(in_phase_space,1))>",
),
)
AntonReinhard marked this conversation as resolved.
Show resolved Hide resolved

return _total_cross_section(proc, model, in_phase_space_def, in_phase_space)
end
22 changes: 20 additions & 2 deletions src/interfaces/process_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ function _averaging_norm end
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_ps_def::InPhasespaceDefinition,
in_phase_space::AbstractVector{T}
in_ps::AbstractVector{T}
out_ps_def::OutPhasespaceDefinition,
out_phase_space::AbstractVector{T}
out_ps::AbstractVector{T}
) where {T<:QEDbase.AbstractFourMomentum}

Interface function, which returns `true`, if the combination of the given incoming and outgoing phase space
Expand Down Expand Up @@ -200,6 +200,24 @@ Return the number of outgoing particles of a given process.
return length(outgoing_particles(proc_def))
end

"""
in_phase_space_dimension(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
)
TBW
"""
function in_phase_space_dimension end

"""
out_phase_space_dimension(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
)
TBW
"""
function out_phase_space_dimension end
AntonReinhard marked this conversation as resolved.
Show resolved Hide resolved

"""
_total_probability(
proc::AbstractProcessDefinition,
Expand Down
Loading
Loading