Skip to content

Commit

Permalink
Introduce InPhaseSpacePoint (#68)
Browse files Browse the repository at this point in the history
This PR adds a type `InPhaseSpacePoint`, which is a partially
specialized version of a `PhaseSpacePoint`. It can be used to dispatch
in places where only the incoming part of a phase space is required.
Construction of PhaseSpacePoints now allows empty tuples for either
incoming or outgoing phase spaces.

---------

Co-authored-by: Uwe Hernandez Acosta <[email protected]>
Co-authored-by: Uwe Hernandez Acosta <[email protected]>
Co-authored-by: AntonReinhard <[email protected]>
  • Loading branch information
4 people authored May 27, 2024
1 parent 67b966c commit c768a57
Show file tree
Hide file tree
Showing 24 changed files with 909 additions and 943 deletions.
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

0 comments on commit c768a57

Please sign in to comment.