Skip to content

Commit

Permalink
rearrangement
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwe Hernandez Acosta committed Sep 9, 2024
1 parent d7a0749 commit 95042f4
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 97 deletions.
5 changes: 3 additions & 2 deletions src/QEDcore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down
File renamed without changes.
95 changes: 95 additions & 0 deletions src/lorentz_boost/general_trafo.jl
Original file line number Diff line number Diff line change
@@ -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
95 changes: 0 additions & 95 deletions src/lorentz_boost/types.jl
Original file line number Diff line number Diff line change
@@ -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
#######
Expand Down

0 comments on commit 95042f4

Please sign in to comment.