diff --git a/src/QEDcore.jl b/src/QEDcore.jl index 966e679..550396e 100644 --- a/src/QEDcore.jl +++ b/src/QEDcore.jl @@ -60,9 +60,10 @@ include("algebraic_objects/four_momentum.jl") include("algebraic_objects/lorentz_vector.jl") include("algebraic_objects/gamma_matrices.jl") +include("lorentz_boost/general_trafo.jl") include("lorentz_boost/types.jl") -include("lorentz_boost/boost_vector.jl") -include("lorentz_boost/axis_boost.jl") +include("lorentz_boost/boost_parameter/boost_axis/axis_boost.jl") +include("lorentz_boost/boost_parameter/boost_vector/boost_vector.jl") include("particles/particle_types.jl") include("particles/propagators.jl") diff --git a/src/lorentz_boost/axis_boost.jl b/src/lorentz_boost/boost_parameter/boost_axis/axis_boost.jl similarity index 99% rename from src/lorentz_boost/axis_boost.jl rename to src/lorentz_boost/boost_parameter/boost_axis/axis_boost.jl index 00343f6..f7bf575 100644 --- a/src/lorentz_boost/axis_boost.jl +++ b/src/lorentz_boost/boost_parameter/boost_axis/axis_boost.jl @@ -3,6 +3,7 @@ # - add convenient constructors: Boost(:x,::Real) # - add convenient constructors: Boost(:rest_frame,::AbstractFourMomentum) # - add convenient constructors: Boost(::RestFrame,::AbstractFourMomentum) +# - decompose into separate files """ diff --git a/src/lorentz_boost/boost_vector.jl b/src/lorentz_boost/boost_parameter/boost_vector/boost_vector.jl similarity index 100% rename from src/lorentz_boost/boost_vector.jl rename to src/lorentz_boost/boost_parameter/boost_vector/boost_vector.jl diff --git a/src/lorentz_boost/general_trafo.jl b/src/lorentz_boost/general_trafo.jl new file mode 100644 index 0000000..b2bd208 --- /dev/null +++ b/src/lorentz_boost/general_trafo.jl @@ -0,0 +1,95 @@ + +####### +# General coordinate transformations +####### + +""" + AbstractCoordinateTransformation + +Abstract base type for coordinate transformations supposed to be acting on four-momenta. +Every subtype of `trafo::AbstractCoordianteTransformation` should implement the following interface functions: + +* `QEDcore._transform(trafo,p)`: transfroms `p` +* `Base.inv(trafo)`: returns the inverted transform + +## Example + +Implementing the interface by defining the interface functions: + +```jldoctest trafo_interface +julia> using QEDcore + +julia> struct TestTrafo{T} <: QEDcore.AbstractCoordinateTransformation + a::T + end + +julia> QEDcore._transform(trafo::TestTrafo,p) = trafo.a*p + +julia> Base.inv(trafo::TestTrafo) = TestTrafo(inv(trafo.a)) + +``` + +The `TestTrafo` can then be used to transform four-momenta: + +```jldoctest trafo_interface +julia> trafo = TestTrafo(2.0) +TestTrafo{Float64}(2.0) + +julia> p = SFourMomentum(4,3,2,1) +4-element SFourMomentum with indices SOneTo(4): + 4.0 + 3.0 + 2.0 + 1.0 + +julia> trafo(p) # multiply every component with 2.0 +4-element SFourMomentum with indices SOneTo(4): + 8.0 + 6.0 + 4.0 + 2.0 + +julia> inv(trafo)(p) # divide every component by 2.0 +4-element SFourMomentum with indices SOneTo(4): + 2.0 + 1.5 + 1.0 + 0.5 +``` +""" +abstract type AbstractCoordinateTransformation end +Base.broadcastable(trafo::AbstractCoordinateTransformation) = Ref(trafo) + +""" + _transform(trafo::AbstractCoordinateTransformation,p::AbstractFourMomentum) + +Interface function for the application of the transformation to the four-momentum `p`. Must return a four-momentum +of the same type as `p`. +""" +function _transform end + +# make the transform callable +@inline function (trafo::AbstractCoordinateTransformation)(p::AbstractFourMomentum) + return _transform(trafo, p) +end + +@inline function (trafo::AbstractCoordinateTransformation)( + psf::PSF +) where {PSF<:AbstractParticleStateful} + p_prime = _transform(trafo, momentum(psf)) + return PSF(p_prime) +end + +@inline function (trafo::AbstractCoordinateTransformation)( + psp::PSP +) where {PSP<:AbstractPhaseSpacePoint} + in_moms = momenta(psp, Incoming()) + out_moms = momenta(psp, Outgoing()) + in_moms_prime = _transform.(trafo, in_moms) + out_moms_prime = _transform.(trafo, out_moms) + + proc = process(psp) + mod = model(psp) + ps_def = phase_space_definition(psp) + return PhaseSpacePoint(proc, mod, ps_def, in_moms_prime, out_moms_prime) +end diff --git a/src/lorentz_boost/types.jl b/src/lorentz_boost/types.jl index 2b37c70..68bec01 100644 --- a/src/lorentz_boost/types.jl +++ b/src/lorentz_boost/types.jl @@ -1,98 +1,3 @@ -####### -# General coordinate transformations -####### - -""" - AbstractCoordinateTransformation - -Abstract base type for coordinate transformations supposed to be acting on four-momenta. -Every subtype of `trafo::AbstractCoordianteTransformation` should implement the following interface functions: - -* `QEDcore._transform(trafo,p)`: transfroms `p` -* `Base.inv(trafo)`: returns the inverted transform - -## Example - -Implementing the interface by defining the interface functions: - -```jldoctest trafo_interface -julia> using QEDcore - -julia> struct TestTrafo{T} <: QEDcore.AbstractCoordinateTransformation - a::T - end - -julia> QEDcore._transform(trafo::TestTrafo,p) = trafo.a*p - -julia> Base.inv(trafo::TestTrafo) = TestTrafo(inv(trafo.a)) - -``` - -The `TestTrafo` can then be used to transform four-momenta: - -```jldoctest trafo_interface -julia> trafo = TestTrafo(2.0) -TestTrafo{Float64}(2.0) - -julia> p = SFourMomentum(4,3,2,1) -4-element SFourMomentum with indices SOneTo(4): - 4.0 - 3.0 - 2.0 - 1.0 - -julia> trafo(p) # multiply every component with 2.0 -4-element SFourMomentum with indices SOneTo(4): - 8.0 - 6.0 - 4.0 - 2.0 - -julia> inv(trafo)(p) # divide every component by 2.0 -4-element SFourMomentum with indices SOneTo(4): - 2.0 - 1.5 - 1.0 - 0.5 -``` -""" -abstract type AbstractCoordinateTransformation end -Base.broadcastable(trafo::AbstractCoordinateTransformation) = Ref(trafo) - -""" - _transform(trafo::AbstractCoordinateTransformation,p::AbstractFourMomentum) - -Interface function for the application of the transformation to the four-momentum `p`. Must return a four-momentum -of the same type as `p`. -""" -function _transform end - -# make the transform callable -@inline function (trafo::AbstractCoordinateTransformation)(p::AbstractFourMomentum) - return _transform(trafo, p) -end - -@inline function (trafo::AbstractCoordinateTransformation)( - psf::PSF -) where {PSF<:AbstractParticleStateful} - p_prime = _transform(trafo, momentum(psf)) - return PSF(p_prime) -end - -@inline function (trafo::AbstractCoordinateTransformation)( - psp::PSP -) where {PSP<:AbstractPhaseSpacePoint} - in_moms = momenta(psp, Incoming()) - out_moms = momenta(psp, Outgoing()) - in_moms_prime = _transform.(trafo, in_moms) - out_moms_prime = _transform.(trafo, out_moms) - - proc = process(psp) - mod = model(psp) - ps_def = phase_space_definition(psp) - return PhaseSpacePoint(proc, mod, ps_def, in_moms_prime, out_moms_prime) -end - ####### # Lorentz Boosts #######