-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Following the suggestion made here: QEDjl-project/QEDcore.jl#45 (comment) --------- Co-authored-by: Uwe Hernandez Acosta <u.hernandez@hzdr.de> Co-authored-by: Anton Reinhard <anton.reinhard@proton.me>
- Loading branch information
1 parent
c4eeaa7
commit 566e001
Showing
9 changed files
with
249 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
####### | ||
# General coordinate transformations | ||
####### | ||
|
||
""" | ||
AbstractCoordinateTransformation | ||
Abstract base type for coordinate transformations supposed to be acting on four-momenta. | ||
Every subtype of `trafo::AbstractCoordinateTransformation` should implement the following interface functions: | ||
* `QEDbase._transform(trafo,p)`: transforms `p` | ||
* `Base.inv(trafo)`: returns the inverted transform | ||
## Example | ||
Implementing the interface by defining the interface functions: | ||
```jldoctest trafo_interface | ||
julia> using QEDbase | ||
julia> using QEDcore | ||
julia> struct TestTrafo{T} <: AbstractCoordinateTransformation | ||
a::T | ||
end | ||
julia> QEDbase._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 constructorof(PSP)(proc, mod, ps_def, in_moms_prime, out_moms_prime) | ||
end | ||
|
||
######### | ||
# Abstract Lorentz Boosts | ||
######### | ||
|
||
""" | ||
AbstractLorentzTransformation <: AbstractCoordinateTransformation | ||
An abstract base type representing Lorentz transformations, which are coordinate | ||
transformations between inertial and reference frames in special relativity. | ||
`AbstractLorentzTransformation` extends `AbstractCoordinateTransformation` and provides | ||
the foundational framework for all types of Lorentz transformations, including boosts. | ||
These transformations preserve the Minkowski product of two four-vectors and are fundamental to | ||
the description of relativistic physics, ensuring the laws of physics are the same in all | ||
inertial frames. | ||
""" | ||
abstract type AbstractLorentzTransformation <: AbstractCoordinateTransformation end | ||
|
||
""" | ||
AbstractLorentzBoost <: AbstractLorentzTransformation | ||
An abstract base type representing Lorentz boosts, a specific type of Lorentz transformation | ||
associated with relative motion between inertial frames along one or more spatial directions. | ||
`AbstractLorentzBoost` extends `AbstractLorentzTransformation` and serves as the foundation | ||
for all types of boost transformations in special relativity. Lorentz boosts describe how | ||
four-vectors change when transitioning between two reference frames moving at constant velocities (in units of the speed of light) relative to each other. | ||
""" | ||
abstract type AbstractLorentzBoost <: AbstractLorentzTransformation end | ||
|
||
""" | ||
AbstractBoostParameter | ||
An abstract base type representing boost parameters used in Lorentz transformations, which | ||
describe the relative motion between two inertial frames in special relativity. | ||
`AbstractBoostParameter` serves as the foundation for defining specific boost parameters | ||
that control Lorentz boosts in different spatial directions. Boost parameters typically | ||
represent the velocity of one reference frame relative to another, expressed as a fraction | ||
of the speed of light (`\\beta`), and are essential for performing Lorentz transformations | ||
on four-vectors. | ||
## Overview | ||
In the context of special relativity, a Lorentz boost is a transformation that changes the | ||
time and spatial components of a four-vector based on the relative motion between two | ||
inertial reference frames. For example, the boost parameter ``\\beta`` is dimensionless and represents | ||
this velocity as a fraction of the speed of light. Depending on the frame's relative velocity, | ||
different forms of boost parameters exist, such as those associated with a single axis or | ||
a vector describing boosts in multiple spatial dimensions. | ||
""" | ||
abstract type AbstractBoostParameter end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Random | ||
using QEDbase | ||
using QEDcore | ||
|
||
RNG = MersenneTwister(137137) | ||
ATOL = 0.0 | ||
RTOL = sqrt(eps()) | ||
|
||
include("../test_implementation/TestImplementation.jl") | ||
TESTMODEL = TestImplementation.TestModel() | ||
TESTPSDEF = TestImplementation.TestPhasespaceDef() | ||
|
||
TESTTRAFO = TestImplementation.TestCoordTrafo() | ||
|
||
@testset "broadcast" begin | ||
test_func(trafo) = trafo | ||
@test test_func.(TESTTRAFO) == TESTTRAFO | ||
end | ||
|
||
@testset "single momenta" begin | ||
test_mom = rand(RNG, SFourMomentum) | ||
|
||
test_mom_prime = @inferred TESTTRAFO(test_mom) | ||
|
||
@test isapprox(test_mom_prime, TestImplementation._groundtruth_coord_trafo(test_mom)) | ||
end | ||
@testset "set of momenta" begin | ||
test_moms = rand(RNG, SFourMomentum, 3) | ||
test_moms_prime = TESTTRAFO.(test_moms) | ||
|
||
@test isapprox(test_moms_prime, TestImplementation._groundtruth_coord_trafo.(test_moms)) | ||
end | ||
|
||
@testset "phase space points" begin | ||
@testset "($N_INCOMING,$N_OUTGOING)" for (N_INCOMING, N_OUTGOING) in Iterators.product( | ||
(1, rand(RNG, 2:8)), (1, rand(RNG, 2:8)) | ||
) | ||
INCOMING_PARTICLES = Tuple(rand(RNG, TestImplementation.PARTICLE_SET, N_INCOMING)) | ||
OUTGOING_PARTICLES = Tuple(rand(RNG, TestImplementation.PARTICLE_SET, N_OUTGOING)) | ||
|
||
TESTPROC = TestImplementation.TestProcess(INCOMING_PARTICLES, OUTGOING_PARTICLES) | ||
|
||
p_in_phys = TestImplementation._rand_momenta(RNG, N_INCOMING) | ||
p_out_phys = TestImplementation._rand_momenta(RNG, N_OUTGOING) | ||
|
||
PS_POINT = PhaseSpacePoint(TESTPROC, TESTMODEL, TESTPSDEF, p_in_phys, p_out_phys) | ||
|
||
test_psp_prime = @inferred TESTTRAFO(PS_POINT) | ||
|
||
@test test_psp_prime == TestImplementation._groundtruth_coord_trafo(PS_POINT) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
struct TestCoordTrafo <: AbstractCoordinateTransformation end | ||
QEDbase._transform(::TestCoordTrafo, p) = _groundtruth_coord_trafo(p) |