Skip to content

Commit

Permalink
used PSL interface from QEDbase namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwe Hernandez Acosta committed Nov 21, 2024
1 parent 82bb595 commit 398b139
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 20 deletions.
21 changes: 13 additions & 8 deletions src/coordinate_map/cached.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ out_coord_map(out_coords)
"""
struct CoordinateMapCached{
P<:AbstractProcessDefinition,M<:AbstractModelDefinition,PSL<:AbstractPhaseSpaceLayout,TM
P<:AbstractProcessDefinition,
M<:AbstractModelDefinition,
PSL<:QEDbase.AbstractPhaseSpaceLayout,
TM,
} <: AbstractCoordinateMap
proc::P
model::M
Expand All @@ -77,36 +80,38 @@ end
function CoordinateMapCached(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
psl::AbstractInPhaseSpaceLayout,
psl::QEDbase.AbstractInPhaseSpaceLayout,
in_coords::NTuple{N,T},
) where {N,T<:Real}
in_moms = build_momenta(proc, model, psl, in_coords)
in_moms = QEDbase.build_momenta(proc, model, psl, in_coords)
return CoordinateMapCached(proc, model, psl, in_moms)
end

function CoordinateMapCached(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
psl::AbstractOutPhaseSpaceLayout,
psl::QEDbase.AbstractOutPhaseSpaceLayout,
in_coords::NTuple{N,T},
) where {N,T<:Real}
in_moms = build_momenta(proc, model, in_phase_space_layout(psl), in_coords)
in_moms = QEDbase.build_momenta(
proc, model, QEDbase.in_phase_space_layout(psl), in_coords
)
return CoordinateMapCached(proc, model, psl, in_moms)
end

# make the transform callable: for in_psl maps return the cached
@inline function (
coord_map::CoordinateMapCached{P,M,PSL}
)() where {P,M,PSL<:AbstractInPhaseSpaceLayout}
)() where {P,M,PSL<:QEDbase.AbstractInPhaseSpaceLayout}
return getfield(coord_map, :in_moms)
end

# make the transform callable: for out_psl maps
@inline function (coord_map::CoordinateMapCached{P,M,PSL})(
out_coords::Tuple
) where {P,M,PSL<:AbstractOutPhaseSpaceLayout}
) where {P,M,PSL<:QEDbase.AbstractOutPhaseSpaceLayout}
in_moms = coord_map.in_moms
return build_momenta(
return QEDbase.build_momenta(
coord_map.proc, coord_map.model, in_moms, coord_map.psl, out_coords
)
end
19 changes: 12 additions & 7 deletions src/coordinate_map/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ coord_map(in_coords, out_coords)
and momentum conservation for the process.
"""
struct CoordinateMap{P,M,PSL<:AbstractPhaseSpaceLayout} <: AbstractCoordinateMap
struct CoordinateMap{P,M,PSL<:QEDbase.AbstractPhaseSpaceLayout} <: AbstractCoordinateMap
proc::P
model::M
psl::PSL
Expand All @@ -75,17 +75,22 @@ end
# make the transform callable
@inline function (coord_map::CoordinateMap{P,M,PSL})(
in_coords::Tuple
) where {P,M,PSL<:AbstractInPhaseSpaceLayout}
return build_momenta(coord_map.proc, coord_map.model, coord_map.psl, in_coords)
) where {P,M,PSL<:QEDbase.AbstractInPhaseSpaceLayout}
return QEDbase.build_momenta(coord_map.proc, coord_map.model, coord_map.psl, in_coords)
end

# make the transform callable
@inline function (coord_map::CoordinateMap{P,M,PSL})(
in_coords::Tuple, out_coords::Tuple
) where {P,M,PSL<:AbstractOutPhaseSpaceLayout}
in_moms = build_momenta(
coord_map.proc, coord_map.model, in_phase_space_layout(coord_map.psl), in_coords
) where {P,M,PSL<:QEDbase.AbstractOutPhaseSpaceLayout}
in_moms = QEDbase.build_momenta(
coord_map.proc,
coord_map.model,
QEDbase.in_phase_space_layout(coord_map.psl),
in_coords,
)
return in_moms,
build_momenta(coord_map.proc, coord_map.model, in_moms, coord_map.psl, out_coords)
QEDbase.build_momenta(
coord_map.proc, coord_map.model, in_moms, coord_map.psl, out_coords
)
end
2 changes: 1 addition & 1 deletion src/coordinates/multivariate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function CoordinateSet{N}(coords::AbstractUnivariateCoordinate...) where {N}
end
CoordinateSet(coords::AbstractUnivariateCoordinate...) = CoordinateSet(coords)

phase_space_dimension(::CoordinateSet{N}) where {N} = N
QEDbase.phase_space_dimension(::CoordinateSet{N}) where {N} = N

BivariateCoordiantes(coords::Tuple) = CoordinateSet{2}(coords)
TrivariateCoordiantes(coords::Tuple) = CoordinateSet{3}(coords)
Expand Down
2 changes: 1 addition & 1 deletion src/phase_space_layouts/in_channel/two_body/general.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ processes can be modeled flexibly and accurately within phase space calculations
- [`AbstractTwoBodyRestSystem`](@ref): A subtype representing two-body systems where one
particle is at rest.
"""
abstract type AbstractTwoBodyInPhaseSpaceLayout <: AbstractInPhaseSpaceLayout end
abstract type AbstractTwoBodyInPhaseSpaceLayout <: QEDbase.AbstractInPhaseSpaceLayout end
2 changes: 1 addition & 1 deletion test/coordinates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ end

@testset "utility" begin
@test coordinate_names(test_coord_set) == COORD_NAMES
@test phase_space_dimension(test_coord_set) == DIM
@test QEDbase.phase_space_dimension(test_coord_set) == DIM
end

@testset "error handling" begin
Expand Down
4 changes: 2 additions & 2 deletions test/test_implementation/test_phase_space_layout.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Trivial phase-space layouts

# maps all components onto four momenta
struct TrivialInPSL <: AbstractInPhaseSpaceLayout end
struct TrivialInPSL <: QEDbase.AbstractInPhaseSpaceLayout end

@inline QEDbase.phase_space_dimension(
proc::AbstractProcessDefinition, ::AbstractModelDefinition, ::TrivialInPSL
Expand All @@ -14,7 +14,7 @@ struct TrivialInPSL <: AbstractInPhaseSpaceLayout end
end

# maps componets of N-1 particles onto four-momenta and uses energy-momentum conservation
struct TrivialOutPSL <: AbstractOutPhaseSpaceLayout{TrivialInPSL}
struct TrivialOutPSL <: QEDbase.AbstractOutPhaseSpaceLayout{TrivialInPSL}
in_psl::TrivialInPSL
end

Expand Down

0 comments on commit 398b139

Please sign in to comment.