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

Introduce InPhaseSpacePoint #68

Merged
merged 43 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
70ce920
updated tests for process interface
May 16, 2024
6baf36c
updated docstrings describing the process interface
May 16, 2024
ae0f18e
formatting
May 16, 2024
f9705ae
opt out the evaluation of cross sections and probabilities on sets of…
May 16, 2024
24e49b2
formatting
May 16, 2024
69593f2
updated diffCS and diffProb to PSPs, removed old interface, updated t…
May 16, 2024
dff0d20
updated perturbative Compton to PSPs
May 16, 2024
62c430d
formatting
May 16, 2024
63c3ec6
cleanup tests for cross sections and probabilities; formatting
May 16, 2024
7e78c2b
Apply suggestions from code review
szabo137 May 21, 2024
94a560c
Improve type info for PS
AntonReinhard May 18, 2024
f2b646c
Move generate_phasespacepoint into constructor
AntonReinhard May 18, 2024
a00d35b
Improve performance with type magic
AntonReinhard May 19, 2024
7a1fa95
EOD
May 19, 2024
1010dae
Improve type checking with even more type magic and fix (some) tests
AntonReinhard May 20, 2024
2cf05e6
Fix last type instability in psp construction from momenta
AntonReinhard May 20, 2024
11250f3
Rebase fix
AntonReinhard May 21, 2024
6deedcc
Add (possibly temporary) fix for tests
AntonReinhard May 21, 2024
3b479ab
Fix doctests
AntonReinhard May 21, 2024
a3ed261
Remove unused functions
AntonReinhard May 21, 2024
aaab777
Make pretty print tests prettier
AntonReinhard May 21, 2024
c7692ee
Tentative merge remote-tracking branch 'Uwe/update-diffCS-interface' …
May 21, 2024
6da8127
Merge remote-tracking branch 'QED/dev' into 58-ps-improve
May 21, 2024
179fb0b
Review changes
AntonReinhard May 21, 2024
d267ced
Move phase_spaces.jl into directory and split into files
AntonReinhard May 21, 2024
3bf45dc
Add directional PhaseSpacePoint aliases and tests
AntonReinhard May 21, 2024
da6adf9
Use Tuples everywhere instead of Tuples and introduce IncomingPhaseSp…
AntonReinhard May 22, 2024
35a5be4
Format
AntonReinhard May 22, 2024
a3eb8de
Merge branch 'dev' into 65_psp_alias
AntonReinhard May 22, 2024
98ea1d9
Format
AntonReinhard May 22, 2024
9ea5a2b
Fix doctest
AntonReinhard May 22, 2024
0c85689
Add docs for Incoming/OutgoingPhaseSpacePoints
AntonReinhard May 22, 2024
182200a
Fix docs for the process interface
AntonReinhard May 22, 2024
cd783e3
Rename Incoming and Outgoing to In and Out for PhaseSpacePoints
AntonReinhard May 22, 2024
baf2d72
Outsource some of the work from PSP constructors
AntonReinhard May 22, 2024
b47c7fd
Add create.jl for PhaseSpacePoints and move constructors there
AntonReinhard May 22, 2024
9375d99
Formatting
AntonReinhard May 22, 2024
810eb30
Fix 1.6 and 1.7 unreachable reached
AntonReinhard May 23, 2024
9697a7d
Small changes
AntonReinhard May 23, 2024
8923365
Add more tests
AntonReinhard May 23, 2024
a99c302
Review fixes
AntonReinhard May 24, 2024
8718957
Add explanation to In/OutPhaseSpacePoint docstrings
AntonReinhard May 25, 2024
6ecd648
Add negative tests for InPhaseSpacePoint interface functions
AntonReinhard May 27, 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
11 changes: 8 additions & 3 deletions src/QEDprocesses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export AbstractModelDefinition, fundamental_interaction_type
# Abstract process interface
export AbstractProcessDefinition, incoming_particles, outgoing_particles
export number_incoming_particles, number_outgoing_particles
export particles, number_particles

# probabilities
export differential_probability, unsafe_differential_probability
Expand All @@ -34,7 +35,7 @@ export propagator
export AbstractCoordinateSystem, SphericalCoordinateSystem
export AbstractFrameOfReference, CenterOfMomentumFrame, ElectronRestFrame
export AbstractPhasespaceDefinition, PhasespaceDefinition
export ParticleStateful, PhaseSpacePoint
export ParticleStateful, PhaseSpacePoint, InPhaseSpacePoint, OutPhaseSpacePoint
export spin, polarization, particle_direction, particle_species, momentum, momenta, getindex

# specific compute models
Expand All @@ -54,15 +55,19 @@ include("interfaces/model_interface.jl")
include("interfaces/process_interface.jl")
include("interfaces/setup_interface.jl")

include("phase_spaces.jl")
include("phase_spaces/types.jl")
include("phase_spaces/access.jl")
include("phase_spaces/create.jl")
include("phase_spaces/print.jl")
include("phase_spaces/utility.jl")

include("momentum_generation.jl")
include("propagators.jl")

include("cross_section/diff_probability.jl")
include("cross_section/diff_cross_section.jl")
include("cross_section/total_probability.jl")
include("cross_section/total_cross_section.jl")
include("cross_section/internal.jl")

include("models/models.jl")
include("processes/one_photon_compton/one_photon_compton.jl")
Expand Down
6 changes: 1 addition & 5 deletions src/cross_section/diff_cross_section.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
# cross sections based on the scattering process interface
########################

function _incident_flux(psp::PhaseSpacePoint)
return _incident_flux(psp.proc, psp.model, momenta(psp, Incoming()))
end

"""
unsafe_differential_cross_section(phase_space_point::PhaseSpacePoint)

Expand All @@ -27,7 +23,7 @@ If the given phase spaces are physical, return differential cross section evalua
"""
function differential_cross_section(phase_space_point::PhaseSpacePoint)
if !_is_in_phasespace(phase_space_point)
return zero(eltype(momentum(phase_space_point, Incoming(), 1)))
return zero(eltype(_momentum_type(phase_space_point)))
end

return unsafe_differential_cross_section(phase_space_point)
Expand Down
131 changes: 0 additions & 131 deletions src/cross_section/internal.jl

This file was deleted.

83 changes: 5 additions & 78 deletions src/cross_section/total_cross_section.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,12 @@
# Total cross sections
############

# total cross section on single phase space point
# based on four-momenta
function _total_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVector{T},
) where {T<:QEDbase.AbstractFourMomentum}
I = 1 / (4 * _incident_flux(proc, model, in_phase_space))

return I * _total_probability(proc, model, 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,
phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVector{T},
) where {T<:Real}
in_momenta = _generate_incoming_momenta(proc, model, phase_space_def, in_phase_space)
return _total_cross_section(proc, model, 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<: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(
proc, model, in_phase_space_def, view(in_phase_space, :, i)
)
end
return res
end

"""
total_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVecOrMat{T},
) where {T<:QEDbase.AbstractFourMomentum}
total_cross_section(in_psp::InPhaseSpacePoint)

Return the total cross section for a given combination of scattering process and compute model, evaluated at the particle momenta.
Return the total cross section for a given [`InPhaseSpacePoint`](@ref).
"""
function total_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVecOrMat{T},
) where {T<:QEDbase.AbstractFourMomentum}
_check_in_phase_space_dimension(proc, model, in_phase_space)

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 total_cross_section(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVecOrMat{T},
) where {T<:Real}
_check_in_phase_space_dimension(proc, model, in_phase_space)

return _total_cross_section(proc, model, in_phase_space_def, in_phase_space)
function total_cross_section(in_psp::InPhaseSpacePoint)
I = 1 / (4 * _incident_flux(in_psp))
return I * _total_probability(in_psp)
end
70 changes: 4 additions & 66 deletions src/cross_section/total_probability.jl
Original file line number Diff line number Diff line change
@@ -1,74 +1,12 @@

###########
# Total probability
###########

# total probability on a phase space point
# based on coordinates
function _total_probability(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVector{T},
) where {T<:Real}
in_momenta = _generate_incoming_momenta(proc, model, phase_space_def, in_phase_space)
return _total_probability(proc, model, phase_space_def, in_momenta)
end

# total probability on several phase space points
function _total_probability(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractMatrix{T},
) 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_probability(
proc, model, phase_space_def, view(in_phase_space, :, i)
)
end
return res
end

"""
total_probability(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractMatrix{T},
) where {T<:QEDbase.AbstractFourMomentum}

Return the total probability of a given model and process combination, evaluated at the particle momenta.
"""
function total_probability(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVecOrMat{T},
) where {T<:QEDbase.AbstractFourMomentum}
_check_in_phase_space_dimension(proc, model, in_phase_space)

return _total_probability(proc, model, phase_space_def, in_phase_space)
end

"""
total_probability(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractMatrix{T},
) where {T<:Real}
total_probability(in_psp::InPhaseSpacePoint)

Return the total probability of a given model and process combination, evaluated at the coordinates.
Return the total probability of a given [`InPhaseSpacePoint`](@ref).
"""
function total_probability(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
phase_space_def::AbstractPhasespaceDefinition,
in_phase_space::AbstractVecOrMat{T},
) where {T<:Real}
_check_in_phase_space_dimension(proc, model, in_phase_space)

return _total_probability(proc, model, phase_space_def, in_phase_space)
function total_probability(in_psp::InPhaseSpacePoint)
return _total_probability(in_psp)
end
Loading
Loading