From 15b7bcfa5e7970865db29fdb98e84e995a8ee7f8 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Sun, 25 Aug 2024 22:33:18 +0200 Subject: [PATCH 01/15] finished tests and fixed bugs --- Project.toml | 1 + src/QEDcore.jl | 9 ++ src/lorentz_boost/axis_boost.jl | 120 ++++++++++++++++++++ src/lorentz_boost/boost_vector.jl | 79 +++++++++++++ src/lorentz_boost/types.jl | 77 +++++++++++++ test/lorentz_transform/lorentz_transform.jl | 75 ++++++++++++ test/lorentz_transform/utils.jl | 14 +++ test/runtests.jl | 4 + 8 files changed, 379 insertions(+) create mode 100644 src/lorentz_boost/axis_boost.jl create mode 100644 src/lorentz_boost/boost_vector.jl create mode 100644 src/lorentz_boost/types.jl create mode 100644 test/lorentz_transform/lorentz_transform.jl create mode 100644 test/lorentz_transform/utils.jl diff --git a/Project.toml b/Project.toml index b350c82..f644bfd 100644 --- a/Project.toml +++ b/Project.toml @@ -8,6 +8,7 @@ version = "0.1.1" [deps] DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" +LorentzVectors = "3f54b04b-17fc-5cd4-9758-90c048d965e3" QEDbase = "10e22c08-3ccb-4172-bfcf-7d7aa3d04d93" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" diff --git a/src/QEDcore.jl b/src/QEDcore.jl index ef81690..441a683 100644 --- a/src/QEDcore.jl +++ b/src/QEDcore.jl @@ -6,6 +6,10 @@ export SLorentzVector, MLorentzVector # four momenta export SFourMomentum, MFourMomentum +# four momenta +export Boost +export BetaX, BetaY, BetaZ, BetaVector + # spinors export BiSpinor, AdjointBiSpinor, DiracMatrix @@ -27,6 +31,7 @@ export PhasespaceDefinition export ParticleStateful, PhaseSpacePoint, InPhaseSpacePoint, OutPhaseSpacePoint export spin, polarization, momenta, getindex +import Base: - using Reexport using DocStringExtensions using StaticArrays @@ -47,6 +52,10 @@ include("algebraic_objects/four_momentum.jl") include("algebraic_objects/lorentz_vector.jl") include("algebraic_objects/gamma_matrices.jl") +include("lorentz_boost/types.jl") +include("lorentz_boost/boost_vector.jl") +include("lorentz_boost/axis_boost.jl") + include("particles/particle_types.jl") include("particles/propagators.jl") include("particles/states.jl") diff --git a/src/lorentz_boost/axis_boost.jl b/src/lorentz_boost/axis_boost.jl new file mode 100644 index 0000000..18c10bd --- /dev/null +++ b/src/lorentz_boost/axis_boost.jl @@ -0,0 +1,120 @@ +abstract type AbstractAxisBoostParameter{T} <: AbstractBoostParameter end +convert(::Type{B}, param::S) where {T <: Real,B<:AbstractAxisBoostParameter{T},S <: Real} = B(T(param)) +function Base.convert(::Type{B1}, d::B2) where {B1<:AbstractAxisBoostParameter,B2<:AbstractAxisBoostParameter} + return B1(d.param) +end +Base.convert(::Type{B1}, d::B2) where {T<:Real,B1<:AbstractAxisBoostParameter{T},B2<:AbstractAxisBoostParameter{T}} = d + +########### +# Axis Beta +########### +abstract type AbstractAxisBeta{T}<:AbstractAxisBoostParameter{T} end + +-(beta::B) where {B<:AbstractAxisBeta} = B(-beta.param) + +_inv(beta::B) where {B<:AbstractAxisBeta} = B(-beta.param) + +@inline function _generic_axis_boost(en,comp,beta) + b2 = beta^2 + gamma = inv(sqrt(one(b2) - b2)) + + en_prime = gamma*(en - beta*comp) + comp_prime = gamma*(comp - beta*en) + + return (en_prime, comp_prime) +end + +""" +TBW +""" +struct BetaX{T} <: AbstractAxisBeta{T} + param::T + function BetaX{T}(beta::T) where {T} + -one(beta)<=beta must be between zero and one" + ) + ) + return new{T}(beta) + end +end + +BetaX(beta::T) where T = BetaX{T}(beta) + +function _transform(boost_param::BetaX,p::M) where {M<:AbstractFourMomentum} + en = getE(p) + px = getX(p) + + en_prime, px_prime = _generic_axis_boost(en,px,boost_param.param) + return M( + en_prime, + px_prime, + getY(p), + getZ(p), + ) +end + +""" +TBW +""" +struct BetaY{T} <: AbstractAxisBeta{T} + param::T + function BetaY{T}(beta::T) where {T} + -one(beta)<=beta must be between zero and one" + ) + ) + return new{T}(beta) + end +end + +BetaY(beta::T) where T = BetaY{T}(beta) + +function _transform(boost_param::BetaY,p::M) where {M<:AbstractFourMomentum} + en = getE(p) + py = getY(p) + + en_prime, py_prime = _generic_axis_boost(en,py,boost_param.param) + return M( + en_prime, + getX(p), + py_prime, + getZ(p), + ) +end + +""" +TBW +""" +struct BetaZ{T} <: AbstractAxisBeta{T} + param::T + function BetaZ{T}(beta::T) where {T} + -one(beta)<=beta must be between zero and one" + ) + ) + return new{T}(beta) + end +end + +BetaZ(beta::T) where T = BetaZ{T}(beta) +function _transform(boost_param::BetaZ,p::M) where {M<:AbstractFourMomentum} + en = getE(p) + pz = getZ(p) + + en_prime, pz_prime = _generic_axis_boost(en,pz,boost_param.param) + return M( + en_prime, + getX(p), + getY(p), + pz_prime, + ) +end + + +# TODO: +# - add convenient constructors: Boost(:x,::Real) +# - add convenient constructors: Boost(:rest_frame,::AbstractFourMomentum) +# - add convenient constructors: Boost(::RestFrame,::AbstractFourMomentum) diff --git a/src/lorentz_boost/boost_vector.jl b/src/lorentz_boost/boost_vector.jl new file mode 100644 index 0000000..0526782 --- /dev/null +++ b/src/lorentz_boost/boost_vector.jl @@ -0,0 +1,79 @@ + +# TODO: +# - add interaction with axis boosts +# - add convenient constructors BetaVector(p) for the rest system? +abstract type AbstractBoostVector <: AbstractBoostParameter end + +""" +TBW +""" +struct BetaVector{T<:Real} <: AbstractBoostVector + x::T + y::T + z::T + + function BetaVector(x::T,y::T,z::T) where {T} + b2 = x^2 + y^2 + z^2 + b2<=1 || throw( + InvalidInputError( + "wrong length of the beta vector ($x, $y, $z). Its length needs to be less or equal to one, but x^2 + y^2 + z^2 = $b2 is given." + ) + ) + new{T}(x,y,z) + end +end +BetaVector(x,y,z) = BetaVector(promote(x,y,z)...) + +import Base:- + +-(b::BetaVector) = BetaVector(-b.x,-b.y,-b.z) + +function Base.isapprox(b1::BetaVector,b2::BetaVector; + atol::Real=0, rtol::Real=Base.rtoldefault(b1.x,b1.y,atol), + nans::Bool=false, norm::Function=abs) + isapprox(b1.x,b2.x;atol=atol,rtol=rtol,nans=nans,norm=norm) && + isapprox(b1.y,b2.y;atol=atol,rtol=rtol,nans=nans,norm=norm) && + isapprox(b1.z,b2.z;atol=atol,rtol=rtol,nans=nans,norm=norm) +end + +@inline function _mul(p::AbstractFourMomentum,beta::BetaVector) + p[2]*beta.x + p[3]*beta.y + p[4]*beta.z +end +_mul(beta::BetaVector,p::AbstractFourMomentum) = _mul(p,beta) + +function _square(beta_vec::BetaVector) + bx = beta_vec.x + by = beta_vec.y + bz = beta_vec.z + bx^2 + by^2 + bz^2 +end + + +@inline function _transform(beta_vec::BetaVector,p::M) where {M<:AbstractFourMomentum} + b2 = _square(beta_vec) + if b2 == one(b2) + return p + end + gamma = inv(sqrt(one(b2) - b2)) + + en = getE(p) + px = getX(p) + py = getY(p) + pz = getZ(p) + bp = _mul(p,beta_vec) + gamma2 = (gamma - one(b2))/b2 + fac = gamma2*bp - gamma*en + px_prime = px + fac*beta_vec.x + py_prime = py + fac*beta_vec.y + pz_prime = pz + fac*beta_vec.z + en_prime = gamma*(en - bp) + + return M( + en_prime, + px_prime, + py_prime, + pz_prime, + ) +end + +_inv(beta_vec::BetaVector) = BetaVector(-beta_vec.x,-beta_vec.y,-beta_vec.z) diff --git a/src/lorentz_boost/types.jl b/src/lorentz_boost/types.jl new file mode 100644 index 0000000..9897252 --- /dev/null +++ b/src/lorentz_boost/types.jl @@ -0,0 +1,77 @@ +####### +# 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)`](@ref}: transfroms `p` +* `Base.inv(trafo)`: returns the inverted transform + +""" +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) + _transform(trafo,p) +end + +@inline function (trafo::AbstractCoordinateTransformation)(psf::PSF) where {PSF<:ParticleStateful} + p_prime = _transform(trafo,momentum(psf)) + return PSF(p_prime) +end + +# FIXME: incoming and outgoing particles +@inline function (trafo::AbstractCoordinateTransformation)(psp::PSP) where {PSP<:PhasespacePoint} + moms = momenta(psp) + moms_prime = _transform.(trafo,moms) + PSP(moms_prime) +end +# TODO: +# - add convenient function `trafo(::ParticleStateful)` +# - add convenient function `trafo(::PhasespacePoint)` + +####### +# Lorentz Boosts +####### +abstract type AbstractLorentzTransformation <: AbstractCoordinateTransformation end +abstract type AbstractLorentzBoost <: AbstractLorentzTransformation end + +""" +TBW +""" +abstract type AbstractBoostParameter end + +""" +TBW +""" +struct Boost{V<:AbstractBoostParameter} <: AbstractLorentzBoost + param::V +end +boost_type(::Boost{V}) where V = V +Boost(x::Real) = Boost(BetaX(x)) +Boost(x::Real,y::Real,z::Real) = Boost(BetaVector(x,y,z)) + +# TODO: +# - add more convenient functions (type of the boost_param, ... ) +# - interaction between several boosts? -> product trafo (for later) + +function _transform(boost::Boost,p::AbstractFourMomentum) + _transform(boost.param,p) +end + +function Base.inv(boost::Boost) + return Boost(_inv(boost.param)) +end diff --git a/test/lorentz_transform/lorentz_transform.jl b/test/lorentz_transform/lorentz_transform.jl new file mode 100644 index 0000000..ca155d6 --- /dev/null +++ b/test/lorentz_transform/lorentz_transform.jl @@ -0,0 +1,75 @@ +using QEDcore +using Random + +include("utils.jl") + +const RNG = MersenneTwister(12345) +const ATOL = 1e-15 + +const test_mom = rand(RNG,SFourMomentum) +const test_mass_square = test_mom*test_mom + +@testset "beta boost" begin + @testset "defaults" begin + x,y,z = rand(RNG,3) + boost_x_default = Boost(x) + @test boost_x_default.param==BetaX(x) + + boost_vec_default = Boost(x,y,z) + @test boost_vec_default.param == BetaVector(x,y,z) + end + + @testset "$boost_type" for boost_type in (BetaVector,BetaX,BetaY,BetaZ) + test_param = _rand(RNG,boost_type) + boost = Boost(test_param) + + @testset "invariance" begin + test_mom_prime = boost(test_mom) + @test isapprox(test_mom_prime*test_mom_prime,test_mass_square) + end + + @testset "inversion" begin + inv_boost_direct = Boost(-test_param) + inv_boost = inv(boost) + + @test isapprox(test_mom |> boost |> inv_boost_direct ,test_mom) + @test isapprox(test_mom |> boost |> inv_boost,test_mom) + end + end + + @testset "recover axis boost" begin + test_beta_vec = _rand_beta(RNG,Float64) + boost = Boost(test_beta_vec) + + @testset "x boost" begin + rnd_beta = rand(RNG) + beta_x = BetaX(rnd_beta) + beta_vec_x = BetaVector(rnd_beta,0.0,0.0) + + boost_axis = Boost(beta_x) + boost_vec = Boost(beta_vec_x) + + @test isapprox(boost_axis(test_mom),boost_vec(test_mom)) + end + @testset "y boost" begin + rnd_beta = rand(RNG) + beta_y = BetaY(rnd_beta) + beta_vec_y = BetaVector(0.0,rnd_beta,0.0) + + boost_axis = Boost(beta_y) + boost_vec = Boost(beta_vec_y) + + @test isapprox(boost_axis(test_mom),boost_vec(test_mom)) + end + @testset "z boost" begin + rnd_beta = rand(RNG) + beta_z = BetaZ(rnd_beta) + beta_vec_z = BetaVector(0.0,0.0,rnd_beta) + + boost_axis = Boost(beta_z) + boost_vec = Boost(beta_vec_z) + + @test isapprox(boost_axis(test_mom),boost_vec(test_mom)) + end + end +end diff --git a/test/lorentz_transform/utils.jl b/test/lorentz_transform/utils.jl new file mode 100644 index 0000000..51dcc37 --- /dev/null +++ b/test/lorentz_transform/utils.jl @@ -0,0 +1,14 @@ +""" +Return a random beta vector. +""" +function _rand_beta(rng::AbstractRNG,::Type{T}=Float64) where {T<:Real} + bx,by,bz = rand(rng,T,3) + r = sqrt(bx^2 + by^2 + bz^2) + bxn,byn,bzn = bx/r,by/r,bz/r + scale = 2*rand(rng,T)-one(T) + BetaVector(bx*scale,by*scale,bz*scale) +end + +@inline _rand(rng::AbstractRNG,::Type{BetaVector},::Type{T}=Float64) where {T<:Real}= _rand_beta(rng,T) + +_rand(rng::AbstractRNG,::Type{B},::Type{T}=Float64) where {B<:QEDcore.AbstractAxisBeta,T<:Real} = B(2*rand(rng,T)-one(T)) diff --git a/test/runtests.jl b/test/runtests.jl index 47d20c0..afef197 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,6 +3,10 @@ using Test using SafeTestsets begin + @time @safetestset "Lorentz transform" begin + include("lorentz_transform/lorentz_transform.jl") + end + @time @safetestset "phase spaces" begin include("phase_spaces.jl") end From 941b3ebb323d8f1354fb34d96782a32febf534b1 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Sun, 25 Aug 2024 22:55:39 +0200 Subject: [PATCH 02/15] formatting --- src/lorentz_boost/axis_boost.jl | 85 +++++++++------------ src/lorentz_boost/boost_vector.jl | 67 ++++++++-------- src/lorentz_boost/types.jl | 26 ++++--- test/lorentz_transform/lorentz_transform.jl | 42 +++++----- test/lorentz_transform/utils.jl | 19 +++-- 5 files changed, 116 insertions(+), 123 deletions(-) diff --git a/src/lorentz_boost/axis_boost.jl b/src/lorentz_boost/axis_boost.jl index 18c10bd..079179c 100644 --- a/src/lorentz_boost/axis_boost.jl +++ b/src/lorentz_boost/axis_boost.jl @@ -1,25 +1,35 @@ abstract type AbstractAxisBoostParameter{T} <: AbstractBoostParameter end -convert(::Type{B}, param::S) where {T <: Real,B<:AbstractAxisBoostParameter{T},S <: Real} = B(T(param)) -function Base.convert(::Type{B1}, d::B2) where {B1<:AbstractAxisBoostParameter,B2<:AbstractAxisBoostParameter} +function convert( + ::Type{B}, param::S +) where {T<:Real,B<:AbstractAxisBoostParameter{T},S<:Real} + return B(T(param)) +end +function Base.convert( + ::Type{B1}, d::B2 +) where {B1<:AbstractAxisBoostParameter,B2<:AbstractAxisBoostParameter} return B1(d.param) end -Base.convert(::Type{B1}, d::B2) where {T<:Real,B1<:AbstractAxisBoostParameter{T},B2<:AbstractAxisBoostParameter{T}} = d +function Base.convert( + ::Type{B1}, d::B2 +) where {T<:Real,B1<:AbstractAxisBoostParameter{T},B2<:AbstractAxisBoostParameter{T}} + return d +end ########### # Axis Beta ########### -abstract type AbstractAxisBeta{T}<:AbstractAxisBoostParameter{T} end +abstract type AbstractAxisBeta{T} <: AbstractAxisBoostParameter{T} end -(beta::B) where {B<:AbstractAxisBeta} = B(-beta.param) _inv(beta::B) where {B<:AbstractAxisBeta} = B(-beta.param) -@inline function _generic_axis_boost(en,comp,beta) +@inline function _generic_axis_boost(en, comp, beta) b2 = beta^2 gamma = inv(sqrt(one(b2) - b2)) - en_prime = gamma*(en - beta*comp) - comp_prime = gamma*(comp - beta*en) + en_prime = gamma * (en - beta * comp) + comp_prime = gamma * (comp - beta * en) return (en_prime, comp_prime) end @@ -30,28 +40,20 @@ TBW struct BetaX{T} <: AbstractAxisBeta{T} param::T function BetaX{T}(beta::T) where {T} - -one(beta)<=beta must be between zero and one" - ) - ) + -one(beta) <= beta < one(beta) || + throw(InvalidInputError("beta parameter <$beta> must be between zero and one")) return new{T}(beta) end end -BetaX(beta::T) where T = BetaX{T}(beta) +BetaX(beta::T) where {T} = BetaX{T}(beta) -function _transform(boost_param::BetaX,p::M) where {M<:AbstractFourMomentum} +function _transform(boost_param::BetaX, p::M) where {M<:AbstractFourMomentum} en = getE(p) px = getX(p) - en_prime, px_prime = _generic_axis_boost(en,px,boost_param.param) - return M( - en_prime, - px_prime, - getY(p), - getZ(p), - ) + en_prime, px_prime = _generic_axis_boost(en, px, boost_param.param) + return M(en_prime, px_prime, getY(p), getZ(p)) end """ @@ -60,28 +62,20 @@ TBW struct BetaY{T} <: AbstractAxisBeta{T} param::T function BetaY{T}(beta::T) where {T} - -one(beta)<=beta must be between zero and one" - ) - ) + -one(beta) <= beta < one(beta) || + throw(InvalidInputError("beta parameter <$beta> must be between zero and one")) return new{T}(beta) end end -BetaY(beta::T) where T = BetaY{T}(beta) +BetaY(beta::T) where {T} = BetaY{T}(beta) -function _transform(boost_param::BetaY,p::M) where {M<:AbstractFourMomentum} +function _transform(boost_param::BetaY, p::M) where {M<:AbstractFourMomentum} en = getE(p) py = getY(p) - en_prime, py_prime = _generic_axis_boost(en,py,boost_param.param) - return M( - en_prime, - getX(p), - py_prime, - getZ(p), - ) + en_prime, py_prime = _generic_axis_boost(en, py, boost_param.param) + return M(en_prime, getX(p), py_prime, getZ(p)) end """ @@ -90,30 +84,21 @@ TBW struct BetaZ{T} <: AbstractAxisBeta{T} param::T function BetaZ{T}(beta::T) where {T} - -one(beta)<=beta must be between zero and one" - ) - ) + -one(beta) <= beta < one(beta) || + throw(InvalidInputError("beta parameter <$beta> must be between zero and one")) return new{T}(beta) end end -BetaZ(beta::T) where T = BetaZ{T}(beta) -function _transform(boost_param::BetaZ,p::M) where {M<:AbstractFourMomentum} +BetaZ(beta::T) where {T} = BetaZ{T}(beta) +function _transform(boost_param::BetaZ, p::M) where {M<:AbstractFourMomentum} en = getE(p) pz = getZ(p) - en_prime, pz_prime = _generic_axis_boost(en,pz,boost_param.param) - return M( - en_prime, - getX(p), - getY(p), - pz_prime, - ) + en_prime, pz_prime = _generic_axis_boost(en, pz, boost_param.param) + return M(en_prime, getX(p), getY(p), pz_prime) end - # TODO: # - add convenient constructors: Boost(:x,::Real) # - add convenient constructors: Boost(:rest_frame,::AbstractFourMomentum) diff --git a/src/lorentz_boost/boost_vector.jl b/src/lorentz_boost/boost_vector.jl index 0526782..3cd2762 100644 --- a/src/lorentz_boost/boost_vector.jl +++ b/src/lorentz_boost/boost_vector.jl @@ -12,44 +12,48 @@ struct BetaVector{T<:Real} <: AbstractBoostVector y::T z::T - function BetaVector(x::T,y::T,z::T) where {T} + function BetaVector(x::T, y::T, z::T) where {T} b2 = x^2 + y^2 + z^2 - b2<=1 || throw( + b2 <= 1 || throw( InvalidInputError( - "wrong length of the beta vector ($x, $y, $z). Its length needs to be less or equal to one, but x^2 + y^2 + z^2 = $b2 is given." - ) + "wrong length of the beta vector ($x, $y, $z). Its length needs to be less or equal to one, but x^2 + y^2 + z^2 = $b2 is given.", + ), ) - new{T}(x,y,z) + return new{T}(x, y, z) end end -BetaVector(x,y,z) = BetaVector(promote(x,y,z)...) +BetaVector(x, y, z) = BetaVector(promote(x, y, z)...) -import Base:- +import Base: - --(b::BetaVector) = BetaVector(-b.x,-b.y,-b.z) +-(b::BetaVector) = BetaVector(-b.x, -b.y, -b.z) -function Base.isapprox(b1::BetaVector,b2::BetaVector; - atol::Real=0, rtol::Real=Base.rtoldefault(b1.x,b1.y,atol), - nans::Bool=false, norm::Function=abs) - isapprox(b1.x,b2.x;atol=atol,rtol=rtol,nans=nans,norm=norm) && - isapprox(b1.y,b2.y;atol=atol,rtol=rtol,nans=nans,norm=norm) && - isapprox(b1.z,b2.z;atol=atol,rtol=rtol,nans=nans,norm=norm) +function Base.isapprox( + b1::BetaVector, + b2::BetaVector; + atol::Real=0, + rtol::Real=Base.rtoldefault(b1.x, b1.y, atol), + nans::Bool=false, + norm::Function=abs, +) + return isapprox(b1.x, b2.x; atol=atol, rtol=rtol, nans=nans, norm=norm) && + isapprox(b1.y, b2.y; atol=atol, rtol=rtol, nans=nans, norm=norm) && + isapprox(b1.z, b2.z; atol=atol, rtol=rtol, nans=nans, norm=norm) end -@inline function _mul(p::AbstractFourMomentum,beta::BetaVector) - p[2]*beta.x + p[3]*beta.y + p[4]*beta.z +@inline function _mul(p::AbstractFourMomentum, beta::BetaVector) + return p[2] * beta.x + p[3] * beta.y + p[4] * beta.z end -_mul(beta::BetaVector,p::AbstractFourMomentum) = _mul(p,beta) +_mul(beta::BetaVector, p::AbstractFourMomentum) = _mul(p, beta) function _square(beta_vec::BetaVector) bx = beta_vec.x by = beta_vec.y bz = beta_vec.z - bx^2 + by^2 + bz^2 + return bx^2 + by^2 + bz^2 end - -@inline function _transform(beta_vec::BetaVector,p::M) where {M<:AbstractFourMomentum} +@inline function _transform(beta_vec::BetaVector, p::M) where {M<:AbstractFourMomentum} b2 = _square(beta_vec) if b2 == one(b2) return p @@ -60,20 +64,15 @@ end px = getX(p) py = getY(p) pz = getZ(p) - bp = _mul(p,beta_vec) - gamma2 = (gamma - one(b2))/b2 - fac = gamma2*bp - gamma*en - px_prime = px + fac*beta_vec.x - py_prime = py + fac*beta_vec.y - pz_prime = pz + fac*beta_vec.z - en_prime = gamma*(en - bp) + bp = _mul(p, beta_vec) + gamma2 = (gamma - one(b2)) / b2 + fac = gamma2 * bp - gamma * en + px_prime = px + fac * beta_vec.x + py_prime = py + fac * beta_vec.y + pz_prime = pz + fac * beta_vec.z + en_prime = gamma * (en - bp) - return M( - en_prime, - px_prime, - py_prime, - pz_prime, - ) + return M(en_prime, px_prime, py_prime, pz_prime) end -_inv(beta_vec::BetaVector) = BetaVector(-beta_vec.x,-beta_vec.y,-beta_vec.z) +_inv(beta_vec::BetaVector) = BetaVector(-beta_vec.x, -beta_vec.y, -beta_vec.z) diff --git a/src/lorentz_boost/types.jl b/src/lorentz_boost/types.jl index 9897252..2ebb78b 100644 --- a/src/lorentz_boost/types.jl +++ b/src/lorentz_boost/types.jl @@ -25,19 +25,23 @@ function _transform end # make the transform callable @inline function (trafo::AbstractCoordinateTransformation)(p::AbstractFourMomentum) - _transform(trafo,p) + return _transform(trafo, p) end -@inline function (trafo::AbstractCoordinateTransformation)(psf::PSF) where {PSF<:ParticleStateful} - p_prime = _transform(trafo,momentum(psf)) +@inline function (trafo::AbstractCoordinateTransformation)( + psf::PSF +) where {PSF<:ParticleStateful} + p_prime = _transform(trafo, momentum(psf)) return PSF(p_prime) end # FIXME: incoming and outgoing particles -@inline function (trafo::AbstractCoordinateTransformation)(psp::PSP) where {PSP<:PhasespacePoint} +@inline function (trafo::AbstractCoordinateTransformation)( + psp::PSP +) where {PSP<:PhasespacePoint} moms = momenta(psp) - moms_prime = _transform.(trafo,moms) - PSP(moms_prime) + moms_prime = _transform.(trafo, moms) + return PSP(moms_prime) end # TODO: # - add convenient function `trafo(::ParticleStateful)` @@ -57,19 +61,19 @@ abstract type AbstractBoostParameter end """ TBW """ -struct Boost{V<:AbstractBoostParameter} <: AbstractLorentzBoost +struct Boost{V<:AbstractBoostParameter} <: AbstractLorentzBoost param::V end -boost_type(::Boost{V}) where V = V +boost_type(::Boost{V}) where {V} = V Boost(x::Real) = Boost(BetaX(x)) -Boost(x::Real,y::Real,z::Real) = Boost(BetaVector(x,y,z)) +Boost(x::Real, y::Real, z::Real) = Boost(BetaVector(x, y, z)) # TODO: # - add more convenient functions (type of the boost_param, ... ) # - interaction between several boosts? -> product trafo (for later) -function _transform(boost::Boost,p::AbstractFourMomentum) - _transform(boost.param,p) +function _transform(boost::Boost, p::AbstractFourMomentum) + return _transform(boost.param, p) end function Base.inv(boost::Boost) diff --git a/test/lorentz_transform/lorentz_transform.jl b/test/lorentz_transform/lorentz_transform.jl index ca155d6..674da75 100644 --- a/test/lorentz_transform/lorentz_transform.jl +++ b/test/lorentz_transform/lorentz_transform.jl @@ -6,70 +6,70 @@ include("utils.jl") const RNG = MersenneTwister(12345) const ATOL = 1e-15 -const test_mom = rand(RNG,SFourMomentum) -const test_mass_square = test_mom*test_mom +const test_mom = rand(RNG, SFourMomentum) +const test_mass_square = test_mom * test_mom @testset "beta boost" begin @testset "defaults" begin - x,y,z = rand(RNG,3) + x, y, z = rand(RNG, 3) boost_x_default = Boost(x) - @test boost_x_default.param==BetaX(x) + @test boost_x_default.param == BetaX(x) - boost_vec_default = Boost(x,y,z) - @test boost_vec_default.param == BetaVector(x,y,z) + boost_vec_default = Boost(x, y, z) + @test boost_vec_default.param == BetaVector(x, y, z) end - @testset "$boost_type" for boost_type in (BetaVector,BetaX,BetaY,BetaZ) - test_param = _rand(RNG,boost_type) + @testset "$boost_type" for boost_type in (BetaVector, BetaX, BetaY, BetaZ) + test_param = _rand(RNG, boost_type) boost = Boost(test_param) @testset "invariance" begin test_mom_prime = boost(test_mom) - @test isapprox(test_mom_prime*test_mom_prime,test_mass_square) + @test isapprox(test_mom_prime * test_mom_prime, test_mass_square) end @testset "inversion" begin inv_boost_direct = Boost(-test_param) inv_boost = inv(boost) - @test isapprox(test_mom |> boost |> inv_boost_direct ,test_mom) - @test isapprox(test_mom |> boost |> inv_boost,test_mom) + @test isapprox(inv_boost_direct(boost(test_mom)), test_mom) + @test isapprox(inv_boost(boost(test_mom)), test_mom) end end @testset "recover axis boost" begin - test_beta_vec = _rand_beta(RNG,Float64) + test_beta_vec = _rand_beta(RNG, Float64) boost = Boost(test_beta_vec) @testset "x boost" begin rnd_beta = rand(RNG) beta_x = BetaX(rnd_beta) - beta_vec_x = BetaVector(rnd_beta,0.0,0.0) + beta_vec_x = BetaVector(rnd_beta, 0.0, 0.0) boost_axis = Boost(beta_x) - boost_vec = Boost(beta_vec_x) + boost_vec = Boost(beta_vec_x) - @test isapprox(boost_axis(test_mom),boost_vec(test_mom)) + @test isapprox(boost_axis(test_mom), boost_vec(test_mom)) end @testset "y boost" begin rnd_beta = rand(RNG) beta_y = BetaY(rnd_beta) - beta_vec_y = BetaVector(0.0,rnd_beta,0.0) + beta_vec_y = BetaVector(0.0, rnd_beta, 0.0) boost_axis = Boost(beta_y) - boost_vec = Boost(beta_vec_y) + boost_vec = Boost(beta_vec_y) - @test isapprox(boost_axis(test_mom),boost_vec(test_mom)) + @test isapprox(boost_axis(test_mom), boost_vec(test_mom)) end @testset "z boost" begin rnd_beta = rand(RNG) beta_z = BetaZ(rnd_beta) - beta_vec_z = BetaVector(0.0,0.0,rnd_beta) + beta_vec_z = BetaVector(0.0, 0.0, rnd_beta) boost_axis = Boost(beta_z) - boost_vec = Boost(beta_vec_z) + boost_vec = Boost(beta_vec_z) - @test isapprox(boost_axis(test_mom),boost_vec(test_mom)) + @test isapprox(boost_axis(test_mom), boost_vec(test_mom)) end end end diff --git a/test/lorentz_transform/utils.jl b/test/lorentz_transform/utils.jl index 51dcc37..2eb1cae 100644 --- a/test/lorentz_transform/utils.jl +++ b/test/lorentz_transform/utils.jl @@ -1,14 +1,19 @@ """ Return a random beta vector. """ -function _rand_beta(rng::AbstractRNG,::Type{T}=Float64) where {T<:Real} - bx,by,bz = rand(rng,T,3) +function _rand_beta(rng::AbstractRNG, ::Type{T}=Float64) where {T<:Real} + bx, by, bz = rand(rng, T, 3) r = sqrt(bx^2 + by^2 + bz^2) - bxn,byn,bzn = bx/r,by/r,bz/r - scale = 2*rand(rng,T)-one(T) - BetaVector(bx*scale,by*scale,bz*scale) + bxn, byn, bzn = bx / r, by / r, bz / r + scale = 2 * rand(rng, T) - one(T) + return BetaVector(bx * scale, by * scale, bz * scale) end -@inline _rand(rng::AbstractRNG,::Type{BetaVector},::Type{T}=Float64) where {T<:Real}= _rand_beta(rng,T) +@inline _rand(rng::AbstractRNG, ::Type{BetaVector}, ::Type{T}=Float64) where {T<:Real} = + _rand_beta(rng, T) -_rand(rng::AbstractRNG,::Type{B},::Type{T}=Float64) where {B<:QEDcore.AbstractAxisBeta,T<:Real} = B(2*rand(rng,T)-one(T)) +function _rand( + rng::AbstractRNG, ::Type{B}, ::Type{T}=Float64 +) where {B<:QEDcore.AbstractAxisBeta,T<:Real} + return B(2 * rand(rng, T) - one(T)) +end From 1bac27f4a0543baaf293e1121f7db3704e2cb579 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Sun, 25 Aug 2024 23:02:38 +0200 Subject: [PATCH 03/15] formatting --- src/lorentz_boost/boost_vector.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lorentz_boost/boost_vector.jl b/src/lorentz_boost/boost_vector.jl index 3cd2762..9d1d00f 100644 --- a/src/lorentz_boost/boost_vector.jl +++ b/src/lorentz_boost/boost_vector.jl @@ -37,8 +37,8 @@ function Base.isapprox( norm::Function=abs, ) return isapprox(b1.x, b2.x; atol=atol, rtol=rtol, nans=nans, norm=norm) && - isapprox(b1.y, b2.y; atol=atol, rtol=rtol, nans=nans, norm=norm) && - isapprox(b1.z, b2.z; atol=atol, rtol=rtol, nans=nans, norm=norm) + isapprox(b1.y, b2.y; atol=atol, rtol=rtol, nans=nans, norm=norm) && + isapprox(b1.z, b2.z; atol=atol, rtol=rtol, nans=nans, norm=norm) end @inline function _mul(p::AbstractFourMomentum, beta::BetaVector) From 42c4f27eff11aa93f88d4f836fae9d7d11772e08 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Mon, 2 Sep 2024 00:24:18 +0200 Subject: [PATCH 04/15] fixed boost of phase space points --- src/lorentz_boost/axis_boost.jl | 18 ++++++++--- src/lorentz_boost/boost_vector.jl | 6 ++++ src/lorentz_boost/types.jl | 29 ++++++++++++------ test/lorentz_transform/lorentz_transform.jl | 34 +++++++++++++++++++++ 4 files changed, 73 insertions(+), 14 deletions(-) diff --git a/src/lorentz_boost/axis_boost.jl b/src/lorentz_boost/axis_boost.jl index 079179c..73a6105 100644 --- a/src/lorentz_boost/axis_boost.jl +++ b/src/lorentz_boost/axis_boost.jl @@ -1,3 +1,13 @@ +# TODO: +# - test conversions +# - add convenient constructors: Boost(:x,::Real) +# - add convenient constructors: Boost(:rest_frame,::AbstractFourMomentum) +# - add convenient constructors: Boost(::RestFrame,::AbstractFourMomentum) + + +""" +TBW +""" abstract type AbstractAxisBoostParameter{T} <: AbstractBoostParameter end function convert( ::Type{B}, param::S @@ -18,6 +28,9 @@ end ########### # Axis Beta ########### +""" +TBW +""" abstract type AbstractAxisBeta{T} <: AbstractAxisBoostParameter{T} end -(beta::B) where {B<:AbstractAxisBeta} = B(-beta.param) @@ -98,8 +111,3 @@ function _transform(boost_param::BetaZ, p::M) where {M<:AbstractFourMomentum} en_prime, pz_prime = _generic_axis_boost(en, pz, boost_param.param) return M(en_prime, getX(p), getY(p), pz_prime) end - -# TODO: -# - add convenient constructors: Boost(:x,::Real) -# - add convenient constructors: Boost(:rest_frame,::AbstractFourMomentum) -# - add convenient constructors: Boost(::RestFrame,::AbstractFourMomentum) diff --git a/src/lorentz_boost/boost_vector.jl b/src/lorentz_boost/boost_vector.jl index 9d1d00f..1fb3441 100644 --- a/src/lorentz_boost/boost_vector.jl +++ b/src/lorentz_boost/boost_vector.jl @@ -2,6 +2,10 @@ # TODO: # - add interaction with axis boosts # - add convenient constructors BetaVector(p) for the rest system? +# - test constructor error +""" +TBW +""" abstract type AbstractBoostVector <: AbstractBoostParameter end """ @@ -44,6 +48,8 @@ end @inline function _mul(p::AbstractFourMomentum, beta::BetaVector) return p[2] * beta.x + p[3] * beta.y + p[4] * beta.z end + +# FIXME: not every component has commutative product _mul(beta::BetaVector, p::AbstractFourMomentum) = _mul(p, beta) function _square(beta_vec::BetaVector) diff --git a/src/lorentz_boost/types.jl b/src/lorentz_boost/types.jl index 2ebb78b..137eaaf 100644 --- a/src/lorentz_boost/types.jl +++ b/src/lorentz_boost/types.jl @@ -30,27 +30,36 @@ end @inline function (trafo::AbstractCoordinateTransformation)( psf::PSF -) where {PSF<:ParticleStateful} +) where {PSF<:AbstractParticleStateful} p_prime = _transform(trafo, momentum(psf)) return PSF(p_prime) end -# FIXME: incoming and outgoing particles @inline function (trafo::AbstractCoordinateTransformation)( psp::PSP -) where {PSP<:PhasespacePoint} - moms = momenta(psp) - moms_prime = _transform.(trafo, moms) - return PSP(moms_prime) +) 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 -# TODO: -# - add convenient function `trafo(::ParticleStateful)` -# - add convenient function `trafo(::PhasespacePoint)` ####### # Lorentz Boosts ####### +""" +TBW +""" abstract type AbstractLorentzTransformation <: AbstractCoordinateTransformation end + +""" +TBW +""" abstract type AbstractLorentzBoost <: AbstractLorentzTransformation end """ @@ -65,6 +74,8 @@ struct Boost{V<:AbstractBoostParameter} <: AbstractLorentzBoost param::V end boost_type(::Boost{V}) where {V} = V + +# defaults Boost(x::Real) = Boost(BetaX(x)) Boost(x::Real, y::Real, z::Real) = Boost(BetaVector(x, y, z)) diff --git a/test/lorentz_transform/lorentz_transform.jl b/test/lorentz_transform/lorentz_transform.jl index 674da75..146e18b 100644 --- a/test/lorentz_transform/lorentz_transform.jl +++ b/test/lorentz_transform/lorentz_transform.jl @@ -2,13 +2,18 @@ using QEDcore using Random include("utils.jl") +include("../test_implementation/TestImplementation.jl") const RNG = MersenneTwister(12345) const ATOL = 1e-15 const test_mom = rand(RNG, SFourMomentum) +const test_psf = ParticleStateful(Incoming(),rand(RNG,TestImplementation.PARTICLE_SET),test_mom) const test_mass_square = test_mom * test_mom +const TESTMODEL = TestImplementation.TestModel() +const TESTPSDEF = TestImplementation.TestPhasespaceDef() + @testset "beta boost" begin @testset "defaults" begin x, y, z = rand(RNG, 3) @@ -25,7 +30,9 @@ const test_mass_square = test_mom * test_mom @testset "invariance" begin test_mom_prime = boost(test_mom) + test_psf_prime = boost(test_psf) @test isapprox(test_mom_prime * test_mom_prime, test_mass_square) + @test isapprox(momentum(test_psf_prime)* momentum(test_psf_prime), test_mass_square) end @testset "inversion" begin @@ -35,6 +42,33 @@ const test_mass_square = test_mom * test_mom @test isapprox(inv_boost_direct(boost(test_mom)), test_mom) @test isapprox(inv_boost(boost(test_mom)), test_mom) end + + @testset "phase space point" begin + + test_param = _rand(RNG, boost_type) + boost = Boost(test_param) + @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) + IN_PS = TestImplementation._rand_momenta(RNG, N_INCOMING) + OUT_PS = TestImplementation._rand_momenta(RNG, N_OUTGOING) + PSP = PhaseSpacePoint(TESTPROC, TESTMODEL, TESTPSDEF, IN_PS, OUT_PS) + + PSP_prime = boost(PSP) + @test isapprox( + [getMass2.(momenta(PSP,Incoming()))...], + [getMass2.(momenta(PSP_prime,Incoming()))...] + ) + @test isapprox( + [getMass2.(momenta(PSP,Outgoing()))...], + [getMass2.(momenta(PSP_prime,Outgoing()))...] + ) + end + end end @testset "recover axis boost" begin From c90262a8a2603c2fc88f4b2602f45bc109afa1b9 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Mon, 2 Sep 2024 00:24:41 +0200 Subject: [PATCH 05/15] formatting --- src/lorentz_boost/axis_boost.jl | 1 - src/lorentz_boost/types.jl | 6 ++-- test/lorentz_transform/lorentz_transform.jl | 36 +++++++++++++-------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/lorentz_boost/axis_boost.jl b/src/lorentz_boost/axis_boost.jl index 73a6105..4299c4c 100644 --- a/src/lorentz_boost/axis_boost.jl +++ b/src/lorentz_boost/axis_boost.jl @@ -4,7 +4,6 @@ # - add convenient constructors: Boost(:rest_frame,::AbstractFourMomentum) # - add convenient constructors: Boost(::RestFrame,::AbstractFourMomentum) - """ TBW """ diff --git a/src/lorentz_boost/types.jl b/src/lorentz_boost/types.jl index 137eaaf..b427f2b 100644 --- a/src/lorentz_boost/types.jl +++ b/src/lorentz_boost/types.jl @@ -38,15 +38,15 @@ end @inline function (trafo::AbstractCoordinateTransformation)( psp::PSP ) where {PSP<:AbstractPhaseSpacePoint} - in_moms = momenta(psp,Incoming()) - out_moms = momenta(psp,Outgoing()) + 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) + return PhaseSpacePoint(proc, mod, ps_def, in_moms_prime, out_moms_prime) end ####### diff --git a/test/lorentz_transform/lorentz_transform.jl b/test/lorentz_transform/lorentz_transform.jl index 146e18b..ccdaf01 100644 --- a/test/lorentz_transform/lorentz_transform.jl +++ b/test/lorentz_transform/lorentz_transform.jl @@ -8,7 +8,9 @@ const RNG = MersenneTwister(12345) const ATOL = 1e-15 const test_mom = rand(RNG, SFourMomentum) -const test_psf = ParticleStateful(Incoming(),rand(RNG,TestImplementation.PARTICLE_SET),test_mom) +const test_psf = ParticleStateful( + Incoming(), rand(RNG, TestImplementation.PARTICLE_SET), test_mom +) const test_mass_square = test_mom * test_mom const TESTMODEL = TestImplementation.TestModel() @@ -32,7 +34,9 @@ const TESTPSDEF = TestImplementation.TestPhasespaceDef() test_mom_prime = boost(test_mom) test_psf_prime = boost(test_psf) @test isapprox(test_mom_prime * test_mom_prime, test_mass_square) - @test isapprox(momentum(test_psf_prime)* momentum(test_psf_prime), test_mass_square) + @test isapprox( + momentum(test_psf_prime) * momentum(test_psf_prime), test_mass_square + ) end @testset "inversion" begin @@ -44,28 +48,34 @@ const TESTPSDEF = TestImplementation.TestPhasespaceDef() end @testset "phase space point" begin - - test_param = _rand(RNG, boost_type) - boost = Boost(test_param) - @testset "($N_INCOMING,$N_OUTGOING)" for (N_INCOMING, N_OUTGOING) in Iterators.product( + test_param = _rand(RNG, boost_type) + boost = Boost(test_param) + @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)) + 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) + TESTPROC = TestImplementation.TestProcess( + INCOMING_PARTICLES, OUTGOING_PARTICLES + ) IN_PS = TestImplementation._rand_momenta(RNG, N_INCOMING) OUT_PS = TestImplementation._rand_momenta(RNG, N_OUTGOING) PSP = PhaseSpacePoint(TESTPROC, TESTMODEL, TESTPSDEF, IN_PS, OUT_PS) PSP_prime = boost(PSP) @test isapprox( - [getMass2.(momenta(PSP,Incoming()))...], - [getMass2.(momenta(PSP_prime,Incoming()))...] + [getMass2.(momenta(PSP, Incoming()))...], + [getMass2.(momenta(PSP_prime, Incoming()))...], ) @test isapprox( - [getMass2.(momenta(PSP,Outgoing()))...], - [getMass2.(momenta(PSP_prime,Outgoing()))...] + [getMass2.(momenta(PSP, Outgoing()))...], + [getMass2.(momenta(PSP_prime, Outgoing()))...], ) end end From 57f44f16d8b7472ad1756608b6c819a28452ad3d Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Sat, 7 Sep 2024 00:33:00 +0200 Subject: [PATCH 06/15] added docstrings and doc tests to axis boosts --- src/lorentz_boost/axis_boost.jl | 200 ++++++++++++++++++++++++++++++-- src/lorentz_boost/types.jl | 46 +++++++- 2 files changed, 237 insertions(+), 9 deletions(-) diff --git a/src/lorentz_boost/axis_boost.jl b/src/lorentz_boost/axis_boost.jl index 4299c4c..c60057b 100644 --- a/src/lorentz_boost/axis_boost.jl +++ b/src/lorentz_boost/axis_boost.jl @@ -5,7 +5,10 @@ # - add convenient constructors: Boost(::RestFrame,::AbstractFourMomentum) """ -TBW + + AbstractAxisBoostParameter{T} + +Abstract base type for boost parameter of type `T` associated to a certain axis in space. """ abstract type AbstractAxisBoostParameter{T} <: AbstractBoostParameter end function convert( @@ -28,7 +31,10 @@ end # Axis Beta ########### """ -TBW + + AbstractAxisBeta{T} <: AbstractAxisBoostParameter{T} + +Abstact base type for boost beta parameter of type `T` associated to an axis in space. """ abstract type AbstractAxisBeta{T} <: AbstractAxisBoostParameter{T} end @@ -47,18 +53,77 @@ _inv(beta::B) where {B<:AbstractAxisBeta} = B(-beta.param) end """ -TBW + + BetaX(beta::T) where {T<:Real} + +Beta parameter associated to the x-axis, commonly referred to as ``\\beta_x``. +The corresponding Lorentz boost reads + +```math +\\begin{pmatrix} +p_0\\\\ +p_1\\\\ +p_2\\\\ +p_3 +\\end{pmatrix} \\mapsto +\\begin{pmatrix} +\\gamma (p_0 - \\beta_x p_1)\\\\ +\\gamma (p_1 - \\beta_x p_0)\\\\ +p_2\\\\ +p_3 +\\end{pmatrix} +``` +where the kinematic factor is given as ``\\gamma = 1/\\sqrt{1-\\beta_x^2}``) + +## Example + +```jldoctest +julia> using QEDcore + +julia> using Random + +julia> RNG = MersenneTwister(1234) +MersenneTwister(1234) + +julia> beta_x = BetaX(0.5) +BetaX{Float64}(0.5) + +julia> boost = Boost(beta_x) +Boost{BetaX{Float64}}(BetaX{Float64}(0.5)) + +julia> p = SFourMomentum(4,3,2,1) +4-element SFourMomentum with indices SOneTo(4): + 4.0 + 3.0 + 2.0 + 1.0 + +julia> p_prime = boost(p) +4-element SFourMomentum with indices SOneTo(4): + 2.886751345948129 + 1.1547005383792517 + 2.0 + 1.0 + +julia> @assert isapprox(p*p,p_prime*p_prime) +``` + +## External link + +* [Lorentz Boost on Wikipedia](https://en.wikipedia.org/wiki/Lorentz_transformation) +* [Kinematics in PDG review](https://pdg.lbl.gov/2024/reviews/rpp2024-rev-kinematics.pdf) + """ -struct BetaX{T} <: AbstractAxisBeta{T} +struct BetaX{T<:Real} <: AbstractAxisBeta{T} param::T - function BetaX{T}(beta::T) where {T} + function BetaX{T}(beta::T) where {T<:Real} -one(beta) <= beta < one(beta) || throw(InvalidInputError("beta parameter <$beta> must be between zero and one")) return new{T}(beta) end end -BetaX(beta::T) where {T} = BetaX{T}(beta) +BetaX(beta::T) where {T<:Real} = BetaX{T}(beta) function _transform(boost_param::BetaX, p::M) where {M<:AbstractFourMomentum} en = getE(p) @@ -69,7 +134,66 @@ function _transform(boost_param::BetaX, p::M) where {M<:AbstractFourMomentum} end """ -TBW + + BetaY(beta::T) where {T<:Real} + +Beta parameter associated to the y-axis, commonly referred to as ``\\beta_y``. +The corresponding Lorentz boost reads + +```math +\\begin{pmatrix} +p_0\\\\ +p_1\\\\ +p_2\\\\ +p_3 +\\end{pmatrix} \\mapsto +\\begin{pmatrix} +\\gamma (p_0 - \\beta_y p_2)\\\\ +p_1\\\\ +\\gamma (p_2 - \\beta_y p_0)\\\\ +p_3 +\\end{pmatrix} +``` +where the kinematic factor is given as ``\\gamma = 1/\\sqrt{1-\\beta_y^2}``) + +## Example + +```jldoctest +julia> using QEDcore + +julia> using Random + +julia> RNG = MersenneTwister(1234) +MersenneTwister(1234) + +julia> beta_y = BetaY(0.5) +BetaY{Float64}(0.5) + +julia> boost = Boost(beta_y) +Boost{BetaY{Float64}}(BetaY{Float64}(0.5)) + +julia> p = SFourMomentum(4,3,2,1) +4-element SFourMomentum with indices SOneTo(4): + 4.0 + 3.0 + 2.0 + 1.0 + +julia> p_prime = boost(p) +4-element SFourMomentum with indices SOneTo(4): + 3.4641016151377553 + 3.0 + 0.0 + 1.0 + +julia> @assert isapprox(p*p,p_prime*p_prime) +``` + +## External link + +* [Lorentz Boost on Wikipedia](https://en.wikipedia.org/wiki/Lorentz_transformation) +* [Kinematics in PDG review](https://pdg.lbl.gov/2024/reviews/rpp2024-rev-kinematics.pdf) + """ struct BetaY{T} <: AbstractAxisBeta{T} param::T @@ -91,7 +215,67 @@ function _transform(boost_param::BetaY, p::M) where {M<:AbstractFourMomentum} end """ -TBW + + BetaZ(beta::T) where {T<:Real} + +Beta parameter associated to the z-axis, commonly referred to as ``\\beta_z``. +The corresponding Lorentz boost reads + +```math +\\begin{pmatrix} +p_0\\\\ +p_1\\\\ +p_2\\\\ +p_3 +\\end{pmatrix} \\mapsto +\\begin{pmatrix} +\\gamma (p_0 - \\beta_z p_3)\\\\ +p_1\\\\ +p_2\\\\ +\\gamma (p_3 - \\beta_z p_0)\\\\ +\\end{pmatrix} +``` +where the kinematic factor is given as ``\\gamma = 1/\\sqrt{1-\\beta_z^2}``) + +## Example + +```jldoctest +julia> using QEDcore + +julia> using Random + +julia> RNG = MersenneTwister(1234) +MersenneTwister(1234) + +julia> beta_z = BetaZ(0.5) +BetaZ{Float64}(0.5) + +julia> boost = Boost(beta_z) +Boost{BetaZ{Float64}}(BetaZ{Float64}(0.5)) + +julia> p = SFourMomentum(4,3,2,1) +4-element SFourMomentum with indices SOneTo(4): + 4.0 + 3.0 + 2.0 + 1.0 + +julia> p_prime = boost(p) +4-element SFourMomentum with indices SOneTo(4): + 4.041451884327381 + 3.0 + 2.0 + -1.1547005383792517 + +julia> @assert isapprox(p*p,p_prime*p_prime) + +``` + +## External link + +* [Lorentz Boost on Wikipedia](https://en.wikipedia.org/wiki/Lorentz_transformation) +* [Kinematics in PDG review](https://pdg.lbl.gov/2024/reviews/rpp2024-rev-kinematics.pdf) + """ struct BetaZ{T} <: AbstractAxisBeta{T} param::T diff --git a/src/lorentz_boost/types.jl b/src/lorentz_boost/types.jl index b427f2b..5107d12 100644 --- a/src/lorentz_boost/types.jl +++ b/src/lorentz_boost/types.jl @@ -8,9 +8,53 @@ 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)`](@ref}: transfroms `p` +* `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) +4-element SFourMomentum with indices SOneTo(4): + 8.0 + 6.0 + 4.0 + 2.0 + +julia> inv(trafo)(p) +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) From b6131c5ce79abc845abe6b1f2a3d42123e189f1a Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Mon, 9 Sep 2024 23:39:19 +0200 Subject: [PATCH 07/15] added docstring for boost vectors --- src/lorentz_boost/axis_boost.jl | 19 ++++----- src/lorentz_boost/boost_vector.jl | 67 +++++++++++++++++++++++++++++-- src/lorentz_boost/types.jl | 14 +++---- 3 files changed, 78 insertions(+), 22 deletions(-) diff --git a/src/lorentz_boost/axis_boost.jl b/src/lorentz_boost/axis_boost.jl index c60057b..00343f6 100644 --- a/src/lorentz_boost/axis_boost.jl +++ b/src/lorentz_boost/axis_boost.jl @@ -1,4 +1,4 @@ -# TODO: +# TODO: # - test conversions # - add convenient constructors: Boost(:x,::Real) # - add convenient constructors: Boost(:rest_frame,::AbstractFourMomentum) @@ -56,7 +56,7 @@ end BetaX(beta::T) where {T<:Real} -Beta parameter associated to the x-axis, commonly referred to as ``\\beta_x``. +Beta parameter associated to the x-axis, commonly referred to as ``\\beta_x``. The corresponding Lorentz boost reads ```math @@ -80,11 +80,6 @@ where the kinematic factor is given as ``\\gamma = 1/\\sqrt{1-\\beta_x^2}``) ```jldoctest julia> using QEDcore -julia> using Random - -julia> RNG = MersenneTwister(1234) -MersenneTwister(1234) - julia> beta_x = BetaX(0.5) BetaX{Float64}(0.5) @@ -105,7 +100,7 @@ julia> p_prime = boost(p) 2.0 1.0 -julia> @assert isapprox(p*p,p_prime*p_prime) +julia> @assert isapprox(p*p,p_prime*p_prime) ``` ## External link @@ -137,7 +132,7 @@ end BetaY(beta::T) where {T<:Real} -Beta parameter associated to the y-axis, commonly referred to as ``\\beta_y``. +Beta parameter associated to the y-axis, commonly referred to as ``\\beta_y``. The corresponding Lorentz boost reads ```math @@ -186,7 +181,7 @@ julia> p_prime = boost(p) 0.0 1.0 -julia> @assert isapprox(p*p,p_prime*p_prime) +julia> @assert isapprox(p*p,p_prime*p_prime) ``` ## External link @@ -218,7 +213,7 @@ end BetaZ(beta::T) where {T<:Real} -Beta parameter associated to the z-axis, commonly referred to as ``\\beta_z``. +Beta parameter associated to the z-axis, commonly referred to as ``\\beta_z``. The corresponding Lorentz boost reads ```math @@ -267,7 +262,7 @@ julia> p_prime = boost(p) 2.0 -1.1547005383792517 -julia> @assert isapprox(p*p,p_prime*p_prime) +julia> @assert isapprox(p*p,p_prime*p_prime) ``` diff --git a/src/lorentz_boost/boost_vector.jl b/src/lorentz_boost/boost_vector.jl index 1fb3441..7d58596 100644 --- a/src/lorentz_boost/boost_vector.jl +++ b/src/lorentz_boost/boost_vector.jl @@ -1,15 +1,76 @@ -# TODO: +# TODO: # - add interaction with axis boosts # - add convenient constructors BetaVector(p) for the rest system? # - test constructor error """ -TBW + + AbstractBoostVector<:AbstractBoostParameter + +Abstract base type for vector-like boost parameters, modelling boosts in any spatial dimension. """ abstract type AbstractBoostVector <: AbstractBoostParameter end """ -TBW + + BetaVector(x::Real,y::Real,z::Real) + +Spatial vector of beta parameters associated with the three chartesian directions: ``\\vec\\beta = (\\beta_x,\\beta_y,\\beta_z)``. +The corresponding Lorentz boost transformation reads + +```math +\\begin{pmatrix} +p_0\\\\ +p_1\\\\ +p_2\\\\ +p_3 +\\end{pmatrix} \\mapsto +\\begin{pmatrix} + \\gamma (p_0 - \\vec\\beta \\vec p)\\\\ +p_1 + (\\frac{\\gamma - 1}{\\beta^2} \\vec\\beta\\vec p - \\gamma p_0) + \\beta_x\\\\ +p_2 + (\\frac{\\gamma - 1}{\\beta^2} \\vec\\beta\\vec p - \\gamma p_0) + \\beta_y\\\\ + p_3 + (\\frac{\\gamma - 1}{\\beta^2} \\vec\\beta\\vec p - \\gamma p_0) + \\beta_z\\\\ +\\end{pmatrix} +``` +where the kinematic factor is given as ``\\gamma = 1/\\sqrt{1-\\beta_x^2}``) + +## Example + +```jldoctest +julia> using QEDcore + +julia> beta_vec = BetaVector(0.2,0.3,0.1) +BetaVector{Float64}(0.2, 0.3, 0.1) + +julia> boost = Boost(beta_vec) +Boost{BetaVector{Float64}}(BetaVector{Float64}(0.2, 0.3, 0.1)) + +julia> p = SFourMomentum(4.0,3.0,2.0,1.0) +4-element SFourMomentum with indices SOneTo(4): + 4.0 + 3.0 + 2.0 + 1.0 + +julia> p_prime = boost(p) +4-element SFourMomentum with indices SOneTo(4): + 2.911484876492837 + 2.282803602436349 + 0.9242054036545237 + 0.6414018012181746 + +julia> @assert isapprox(p*p,p_prime*p_prime) +``` + +## External link + +* [Lorentz Boost on Wikipedia](https://en.wikipedia.org/wiki/Lorentz_transformation) +* [Kinematics in PDG review](https://pdg.lbl.gov/2024/reviews/rpp2024-rev-kinematics.pdf) +* [`ROOT::Math:Boost` from ROOT](https://root.cern.ch/doc/master/classROOT_1_1Math_1_1Boost.html) + """ struct BetaVector{T<:Real} <: AbstractBoostVector x::T diff --git a/src/lorentz_boost/types.jl b/src/lorentz_boost/types.jl index 5107d12..2b37c70 100644 --- a/src/lorentz_boost/types.jl +++ b/src/lorentz_boost/types.jl @@ -5,7 +5,7 @@ """ AbstractCoordinateTransformation -Abstract base type for coordinate transformations supposed to be acting on four-momenta. +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` @@ -13,12 +13,12 @@ Every subtype of `trafo::AbstractCoordianteTransformation` should implement the ## Example -Implementing the interface by defining the interface functions: +Implementing the interface by defining the interface functions: ```jldoctest trafo_interface julia> using QEDcore -julia> struct TestTrafo{T} <: QEDcore.AbstractCoordinateTransformation +julia> struct TestTrafo{T} <: QEDcore.AbstractCoordinateTransformation a::T end @@ -41,14 +41,14 @@ julia> p = SFourMomentum(4,3,2,1) 2.0 1.0 -julia> trafo(p) +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) +julia> inv(trafo)(p) # divide every component by 2.0 4-element SFourMomentum with indices SOneTo(4): 2.0 1.5 @@ -62,7 +62,7 @@ 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 +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 @@ -123,7 +123,7 @@ boost_type(::Boost{V}) where {V} = V Boost(x::Real) = Boost(BetaX(x)) Boost(x::Real, y::Real, z::Real) = Boost(BetaVector(x, y, z)) -# TODO: +# TODO: # - add more convenient functions (type of the boost_param, ... ) # - interaction between several boosts? -> product trafo (for later) From e49d65047e46a1c1e6086828c2b5a41688e1708b Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Tue, 10 Sep 2024 00:09:15 +0200 Subject: [PATCH 08/15] rearrangement --- src/QEDcore.jl | 5 +- .../boost_axis}/axis_boost.jl | 1 + .../boost_vector}/boost_vector.jl | 0 src/lorentz_boost/general_trafo.jl | 95 +++++++++++++++++++ src/lorentz_boost/types.jl | 95 ------------------- 5 files changed, 99 insertions(+), 97 deletions(-) rename src/lorentz_boost/{ => boost_parameter/boost_axis}/axis_boost.jl (99%) rename src/lorentz_boost/{ => boost_parameter/boost_vector}/boost_vector.jl (100%) create mode 100644 src/lorentz_boost/general_trafo.jl diff --git a/src/QEDcore.jl b/src/QEDcore.jl index 441a683..64a671b 100644 --- a/src/QEDcore.jl +++ b/src/QEDcore.jl @@ -52,9 +52,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 ####### From 7067e0d86395c029a554f427e2bc1e084b9fcb28 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Fri, 13 Sep 2024 22:53:22 +0200 Subject: [PATCH 09/15] rearrangement + more enhanced tests --- src/QEDcore.jl | 11 +- .../boost_axis/{axis_boost.jl => beta.jl} | 72 +++----- .../boost_parameter/boost_axis/convert.jl | 16 ++ .../boost_parameter/boost_axis/types.jl | 28 +++ .../boost_vector/{boost_vector.jl => beta.jl} | 50 ++---- .../boost_parameter/boost_vector/types.jl | 29 +++ .../boost_parameter/boost_vector/utils.jl | 13 ++ src/lorentz_boost/general_trafo.jl | 95 ---------- src/lorentz_boost/types.jl | 95 ++++++++-- src/patch_QEDbase.jl | 168 ++++++++++++++++++ test/lorentz_transform/lorentz_transform.jl | 38 +++- test/lorentz_transform/utils.jl | 10 +- 12 files changed, 420 insertions(+), 205 deletions(-) rename src/lorentz_boost/boost_parameter/boost_axis/{axis_boost.jl => beta.jl} (73%) create mode 100644 src/lorentz_boost/boost_parameter/boost_axis/convert.jl create mode 100644 src/lorentz_boost/boost_parameter/boost_axis/types.jl rename src/lorentz_boost/boost_parameter/boost_vector/{boost_vector.jl => beta.jl} (66%) create mode 100644 src/lorentz_boost/boost_parameter/boost_vector/types.jl create mode 100644 src/lorentz_boost/boost_parameter/boost_vector/utils.jl delete mode 100644 src/lorentz_boost/general_trafo.jl create mode 100644 src/patch_QEDbase.jl diff --git a/src/QEDcore.jl b/src/QEDcore.jl index 64a671b..6b23f92 100644 --- a/src/QEDcore.jl +++ b/src/QEDcore.jl @@ -39,6 +39,8 @@ using SimpleTraits @reexport using QEDbase +include("patch_QEDbase.jl") + include("algebraic_objects/dirac_tensors/types.jl") include("algebraic_objects/dirac_tensors/multiplication.jl") @@ -52,10 +54,13 @@ 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_parameter/boost_axis/axis_boost.jl") -include("lorentz_boost/boost_parameter/boost_vector/boost_vector.jl") +include("lorentz_boost/boost_parameter/boost_axis/types.jl") +include("lorentz_boost/boost_parameter/boost_axis/convert.jl") +include("lorentz_boost/boost_parameter/boost_axis/beta.jl") +include("lorentz_boost/boost_parameter/boost_vector/types.jl") +include("lorentz_boost/boost_parameter/boost_vector/beta.jl") +include("lorentz_boost/boost_parameter/boost_vector/utils.jl") include("particles/particle_types.jl") include("particles/propagators.jl") diff --git a/src/lorentz_boost/boost_parameter/boost_axis/axis_boost.jl b/src/lorentz_boost/boost_parameter/boost_axis/beta.jl similarity index 73% rename from src/lorentz_boost/boost_parameter/boost_axis/axis_boost.jl rename to src/lorentz_boost/boost_parameter/boost_axis/beta.jl index f7bf575..89c1566 100644 --- a/src/lorentz_boost/boost_parameter/boost_axis/axis_boost.jl +++ b/src/lorentz_boost/boost_parameter/boost_axis/beta.jl @@ -1,32 +1,3 @@ -# TODO: -# - test conversions -# - add convenient constructors: Boost(:x,::Real) -# - add convenient constructors: Boost(:rest_frame,::AbstractFourMomentum) -# - add convenient constructors: Boost(::RestFrame,::AbstractFourMomentum) -# - decompose into separate files - -""" - - AbstractAxisBoostParameter{T} - -Abstract base type for boost parameter of type `T` associated to a certain axis in space. -""" -abstract type AbstractAxisBoostParameter{T} <: AbstractBoostParameter end -function convert( - ::Type{B}, param::S -) where {T<:Real,B<:AbstractAxisBoostParameter{T},S<:Real} - return B(T(param)) -end -function Base.convert( - ::Type{B1}, d::B2 -) where {B1<:AbstractAxisBoostParameter,B2<:AbstractAxisBoostParameter} - return B1(d.param) -end -function Base.convert( - ::Type{B1}, d::B2 -) where {T<:Real,B1<:AbstractAxisBoostParameter{T},B2<:AbstractAxisBoostParameter{T}} - return d -end ########### # Axis Beta @@ -35,7 +6,19 @@ end AbstractAxisBeta{T} <: AbstractAxisBoostParameter{T} -Abstact base type for boost beta parameter of type `T` associated to an axis in space. +An abstract base type for the beta (velocity) parameter of type `T`, representing a Lorentz boost along a specific spatial axis. + +`AbstractAxisBeta{T}` extends `AbstractAxisBoostParameter{T}` and provides a general framework for defining beta parameters associated with individual Cartesian axes (x, y, z) in special relativity. The parameter `T` typically represents the numeric type (e.g., `Float64`, `Float32`) used for the beta value. + +### Usage + +Concrete subtypes of `AbstractAxisBeta{T}` define the beta parameters for Lorentz boosts along the x, y, and z axes: +- [`BetaX{T}`](@ref): Boost parameter for the x-axis. +- [`BetaY{T}`](@ref): Boost parameter for the y-axis. +- [`BetaZ{T}`](@ref): Boost parameter for the z-axis. + +These beta parameters are essential for performing axis-specific Lorentz boosts, which transform physical quantities such as four-momentum between different inertial frames. + """ abstract type AbstractAxisBeta{T} <: AbstractAxisBoostParameter{T} end @@ -57,8 +40,9 @@ end BetaX(beta::T) where {T<:Real} -Beta parameter associated to the x-axis, commonly referred to as ``\\beta_x``. -The corresponding Lorentz boost reads +Represents the beta parameter associated with a Lorentz boost along the x-axis, commonly denoted as ``\\beta_x``. + +The transformation for a boost along the x-axis is: ```math \\begin{pmatrix} @@ -101,7 +85,7 @@ julia> p_prime = boost(p) 2.0 1.0 -julia> @assert isapprox(p*p,p_prime*p_prime) +julia> @assert isapprox(p*p,p_prime*p_prime) # Invariant mass is preserved ``` ## External link @@ -133,8 +117,9 @@ end BetaY(beta::T) where {T<:Real} -Beta parameter associated to the y-axis, commonly referred to as ``\\beta_y``. -The corresponding Lorentz boost reads +Represents the beta parameter associated with a Lorentz boost along the y-axis, commonly denoted as ``\\beta_y``. + +The transformation for a boost along the y-axis is: ```math \\begin{pmatrix} @@ -182,7 +167,7 @@ julia> p_prime = boost(p) 0.0 1.0 -julia> @assert isapprox(p*p,p_prime*p_prime) +julia> @assert isapprox(p*p,p_prime*p_prime) # Invariant mass is preserved ``` ## External link @@ -191,9 +176,9 @@ julia> @assert isapprox(p*p,p_prime*p_prime) * [Kinematics in PDG review](https://pdg.lbl.gov/2024/reviews/rpp2024-rev-kinematics.pdf) """ -struct BetaY{T} <: AbstractAxisBeta{T} +struct BetaY{T<:Real} <: AbstractAxisBeta{T} param::T - function BetaY{T}(beta::T) where {T} + function BetaY{T}(beta::T) where {T<:Real} -one(beta) <= beta < one(beta) || throw(InvalidInputError("beta parameter <$beta> must be between zero and one")) return new{T}(beta) @@ -214,8 +199,9 @@ end BetaZ(beta::T) where {T<:Real} -Beta parameter associated to the z-axis, commonly referred to as ``\\beta_z``. -The corresponding Lorentz boost reads +Represents the beta parameter associated with a Lorentz boost along the z-axis, commonly denoted as ``\\beta_z``. + +The transformation for a boost along the z-axis is: ```math \\begin{pmatrix} @@ -263,7 +249,7 @@ julia> p_prime = boost(p) 2.0 -1.1547005383792517 -julia> @assert isapprox(p*p,p_prime*p_prime) +julia> @assert isapprox(p*p,p_prime*p_prime) # Invariant mass is preserved ``` @@ -273,9 +259,9 @@ julia> @assert isapprox(p*p,p_prime*p_prime) * [Kinematics in PDG review](https://pdg.lbl.gov/2024/reviews/rpp2024-rev-kinematics.pdf) """ -struct BetaZ{T} <: AbstractAxisBeta{T} +struct BetaZ{T<:Real} <: AbstractAxisBeta{T} param::T - function BetaZ{T}(beta::T) where {T} + function BetaZ{T}(beta::T) where {T<:Real} -one(beta) <= beta < one(beta) || throw(InvalidInputError("beta parameter <$beta> must be between zero and one")) return new{T}(beta) diff --git a/src/lorentz_boost/boost_parameter/boost_axis/convert.jl b/src/lorentz_boost/boost_parameter/boost_axis/convert.jl new file mode 100644 index 0000000..6da6bba --- /dev/null +++ b/src/lorentz_boost/boost_parameter/boost_axis/convert.jl @@ -0,0 +1,16 @@ + +function Base.convert( + ::Type{B}, param::S +) where {T<:Real,B<:AbstractAxisBoostParameter{T},S<:Real} + return B(T(param)) +end +function Base.convert( + ::Type{B1}, d::B2 +) where {T<:Real,B1<:AbstractAxisBoostParameter{T},B2<:AbstractAxisBoostParameter} + return B1(T(d.param)) +end +function Base.convert( + ::Type{B1}, d::B2 +) where {T<:Real,B1<:AbstractAxisBoostParameter{T},B2<:AbstractAxisBoostParameter{T}} + return d +end diff --git a/src/lorentz_boost/boost_parameter/boost_axis/types.jl b/src/lorentz_boost/boost_parameter/boost_axis/types.jl new file mode 100644 index 0000000..7147667 --- /dev/null +++ b/src/lorentz_boost/boost_parameter/boost_axis/types.jl @@ -0,0 +1,28 @@ + +# TODO: +# - test conversions +# - decompose into separate files + +""" + AbstractAxisBoostParameter{T} + +An abstract base type representing a boost parameter of type `T`, associated with a specific axis in space (e.g., ``x``, ``y``, or ``z``). + +This type serves as a foundation for concrete boost parameter types that define Lorentz boosts along individual spatial directions, The parameter `T` typically represents the data type for the boost value (e.g., `Float64`, `Float32`). + +### Usage + +Subtypes of `AbstractAxisBoostParameter{T}` are used to define specific boost transformations along a given axis (such as `BetaX` for the x-axis). These types are essential in performing Lorentz boosts, which transform four-momentum vectors between different inertial reference frames. + +This abstract type is meant to be extended by concrete types to represent boosts along different Cartesian axes. + +""" +abstract type AbstractAxisBoostParameter{T} <: AbstractBoostParameter end + +function (::Type{BP})( + boost_val::S +) where {T<:Real,BP<:AbstractAxisBoostParameter{T},S<:Real} + return BP(T(boost_val)) +end + +Base.eltype(::AbstractAxisBoostParameter{T}) where {T} = T diff --git a/src/lorentz_boost/boost_parameter/boost_vector/boost_vector.jl b/src/lorentz_boost/boost_parameter/boost_vector/beta.jl similarity index 66% rename from src/lorentz_boost/boost_parameter/boost_vector/boost_vector.jl rename to src/lorentz_boost/boost_parameter/boost_vector/beta.jl index 7d58596..5aaffa7 100644 --- a/src/lorentz_boost/boost_parameter/boost_vector/boost_vector.jl +++ b/src/lorentz_boost/boost_parameter/boost_vector/beta.jl @@ -1,22 +1,13 @@ -# TODO: -# - add interaction with axis boosts -# - add convenient constructors BetaVector(p) for the rest system? -# - test constructor error -""" - - AbstractBoostVector<:AbstractBoostParameter - -Abstract base type for vector-like boost parameters, modelling boosts in any spatial dimension. -""" -abstract type AbstractBoostVector <: AbstractBoostParameter end - """ BetaVector(x::Real,y::Real,z::Real) -Spatial vector of beta parameters associated with the three chartesian directions: ``\\vec\\beta = (\\beta_x,\\beta_y,\\beta_z)``. -The corresponding Lorentz boost transformation reads +Represents the spatial vector of velocity parameters (denoted as the "beta" vector) associated with motion in the three Cartesian directions, i.e., +``\\vec\\beta = (\\beta_x, \\beta_y, \\beta_z)``. These components correspond to the velocity of an object (in units of the speed of light) in each of the +``x``, ``y``, and ``z`` directions. + +The Lorentz boost along the direction of the beta vector ``\\vec\\beta`` transforms the four-momentum as follows: ```math \\begin{pmatrix} @@ -35,7 +26,7 @@ p_2 + (\\frac{\\gamma - 1}{\\beta^2} \\vec\\beta\\vec p - \\gamma p_0) \\beta_z\\\\ \\end{pmatrix} ``` -where the kinematic factor is given as ``\\gamma = 1/\\sqrt{1-\\beta_x^2}``) +where the kinematic factor is given as ``\\gamma = 1/\\sqrt{1-\\beta_x^2}``. ## Example @@ -62,7 +53,7 @@ julia> p_prime = boost(p) 0.9242054036545237 0.6414018012181746 -julia> @assert isapprox(p*p,p_prime*p_prime) +julia> @assert isapprox(p*p,p_prime*p_prime) # Invariant mass is preserved ``` ## External link @@ -90,30 +81,16 @@ end BetaVector(x, y, z) = BetaVector(promote(x, y, z)...) import Base: - - -(b::BetaVector) = BetaVector(-b.x, -b.y, -b.z) -function Base.isapprox( - b1::BetaVector, - b2::BetaVector; - atol::Real=0, - rtol::Real=Base.rtoldefault(b1.x, b1.y, atol), - nans::Bool=false, - norm::Function=abs, -) - return isapprox(b1.x, b2.x; atol=atol, rtol=rtol, nans=nans, norm=norm) && - isapprox(b1.y, b2.y; atol=atol, rtol=rtol, nans=nans, norm=norm) && - isapprox(b1.z, b2.z; atol=atol, rtol=rtol, nans=nans, norm=norm) -end - -@inline function _mul(p::AbstractFourMomentum, beta::BetaVector) +@inline function _spatial_mul(p::AbstractFourMomentum, beta::BetaVector) return p[2] * beta.x + p[3] * beta.y + p[4] * beta.z end -# FIXME: not every component has commutative product -_mul(beta::BetaVector, p::AbstractFourMomentum) = _mul(p, beta) +# assumption: beta vector components are communte with four momentum components +_spatial_mul(beta::BetaVector, p::AbstractFourMomentum) = _spatial_mul(p, beta) -function _square(beta_vec::BetaVector) +function _three_vector_square(beta_vec::BetaVector) bx = beta_vec.x by = beta_vec.y bz = beta_vec.z @@ -121,7 +98,7 @@ function _square(beta_vec::BetaVector) end @inline function _transform(beta_vec::BetaVector, p::M) where {M<:AbstractFourMomentum} - b2 = _square(beta_vec) + b2 = _three_vector_square(beta_vec) if b2 == one(b2) return p end @@ -131,7 +108,7 @@ end px = getX(p) py = getY(p) pz = getZ(p) - bp = _mul(p, beta_vec) + bp = _spatial_mul(p, beta_vec) gamma2 = (gamma - one(b2)) / b2 fac = gamma2 * bp - gamma * en px_prime = px + fac * beta_vec.x @@ -142,4 +119,5 @@ end return M(en_prime, px_prime, py_prime, pz_prime) end +# inverse is just a boost with -beta _inv(beta_vec::BetaVector) = BetaVector(-beta_vec.x, -beta_vec.y, -beta_vec.z) diff --git a/src/lorentz_boost/boost_parameter/boost_vector/types.jl b/src/lorentz_boost/boost_parameter/boost_vector/types.jl new file mode 100644 index 0000000..e65bd00 --- /dev/null +++ b/src/lorentz_boost/boost_parameter/boost_vector/types.jl @@ -0,0 +1,29 @@ +# TODO: +# - add interaction with axis boosts +# - add convenient constructors BetaVector(p) for the rest system? +# - test constructor error + +""" + AbstractBoostVector <: AbstractBoostParameter + +An abstract base type representing vector-like boost parameters, used to model Lorentz boosts +in any spatial dimension. + +`AbstractBoostVector` extends `AbstractBoostParameter` and provides the framework for +describing boosts that act in multiple spatial dimensions simultaneously, typically in +three-dimensional space. This type is designed to support vector representations of +velocities (in units of the speed of light) associated with Lorentz transformations in +special relativity. + +## Usage + +Concrete subtypes of `AbstractBoostVector` represent specific boost vectors that describe +the velocity components in each spatial dimension, such as `BetaVector`. These boost +vectors are commonly used in transformations of four-vectors (e.g., four-momentum, +four-position) between different reference frames. + +For example: +- [`BetaVector{T}`](@ref): A concrete subtype representing a boost vector with velocity components ``\\beta_x``, ``\\beta_y``, and ``\\beta_z`` (in units of the speed of light). + +""" +abstract type AbstractBoostVector <: AbstractBoostParameter end diff --git a/src/lorentz_boost/boost_parameter/boost_vector/utils.jl b/src/lorentz_boost/boost_parameter/boost_vector/utils.jl new file mode 100644 index 0000000..231b918 --- /dev/null +++ b/src/lorentz_boost/boost_parameter/boost_vector/utils.jl @@ -0,0 +1,13 @@ + +function Base.isapprox( + b1::BetaVector, + b2::BetaVector; + atol::Real=0, + rtol::Real=Base.rtoldefault(b1.x, b1.y, atol), + nans::Bool=false, + norm::Function=abs, +) + return isapprox(b1.x, b2.x; atol=atol, rtol=rtol, nans=nans, norm=norm) && + isapprox(b1.y, b2.y; atol=atol, rtol=rtol, nans=nans, norm=norm) && + isapprox(b1.z, b2.z; atol=atol, rtol=rtol, nans=nans, norm=norm) +end diff --git a/src/lorentz_boost/general_trafo.jl b/src/lorentz_boost/general_trafo.jl deleted file mode 100644 index b2bd208..0000000 --- a/src/lorentz_boost/general_trafo.jl +++ /dev/null @@ -1,95 +0,0 @@ - -####### -# 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 68bec01..a357a76 100644 --- a/src/lorentz_boost/types.jl +++ b/src/lorentz_boost/types.jl @@ -1,28 +1,85 @@ -####### -# Lorentz Boosts -####### -""" -TBW -""" -abstract type AbstractLorentzTransformation <: AbstractCoordinateTransformation end """ -TBW -""" -abstract type AbstractLorentzBoost <: AbstractLorentzTransformation end -""" -TBW -""" -abstract type AbstractBoostParameter end + Boost{V<:AbstractBoostParameter} <: AbstractLorentzBoost +A concrete type representing a Lorentz boost transformation, parameterized by a boost +parameter `V`. The boost parameter can be either axis-specific or vector-like, depending +on the subtype of `AbstractBoostParameter` used. The `Boost` type is used to perform +Lorentz boosts on four-vectors (such as four-momentum or four-position) between different +inertial frames in special relativity. + +## Fields +- `param::V`: A boost parameter of type `V`, which is a subtype of `AbstractBoostParameter`. + This parameter defines the velocity (as a fraction of the speed of light, ``\\beta``) + and the direction of the boost (e.g., along a single axis or in multiple directions). + +## Overview + +A Lorentz boost is a transformation that adjusts the time and spatial components of a +four-vector based on the relative velocity between two reference frames. The `Boost` +struct provides a general and flexible implementation of such a boost, where the type of +the boost parameter determines the direction and magnitude of the boost. + +Depending on the boost parameter `V`, the boost can be: +- **Axis-specific**: When `V` is an axis-specific boost parameter (e.g., `BetaX`), the + boost will be along that axis. +- **Vector-like**: When `V` is a vector of boost parameters (e.g., `BetaVector`), the + boost will have components in multiple spatial directions. + +## Example +To create a Lorentz boost along the x-axis using the `BetaX` boost parameter: + +```jldoctest example_boost_x +using QEDcore +julia> beta_x = BetaX(0.5) +BetaX{Float64}(0.5) + +julia> boost_x = Boost(beta_x) +Boost{BetaX{Float64}}(BetaX{Float64}(0.5)) +``` + +To perform a Lorentz boost using the `boost_x` object, you can apply it to a four-vector, +such as four-momentum: + +```jldoctest example_boost_x +julia> p = SFourMomentum(4, 3, 2, 1) +4-element SFourMomentum with indices SOneTo(4): + 4.0 + 3.0 + 2.0 + 1.0 + +julia> p_prime = boost_x(p) # Perform the boost +4-element SFourMomentum with indices SOneTo(4): + 2.886751345948129 + 1.1547005383792517 + 2.0 + 1.0 + +julia> @assert isapprox(p*p, p_prime*p_prime) # The spacetime interval is preserved +``` + +## Notes + +The `Boost` type provides a unified and flexible interface for applying Lorentz boosts, +with the boost parameter `V` determining the specific form of the transformation. +Lorentz boosts preserve the spacetime interval, meaning that applying the boost to a +four-vector will not change the invariant quantity + +## See Also + +* [`AbstractBoostParameter`](@ref): Base type for specific kinds of boost parameters. +* [`BetaX`](@ref): Boost parameter for the x-axis. +* [`BetaY`](@ref): Boost parameter for the y-axis. +* [`BetaZ`](@ref): Boost parameter for the z-axis. +* [`BetaVector`](@ref): Vector of boost parameters for boosts in multiple spatial directions. """ -TBW -""" -struct Boost{V<:AbstractBoostParameter} <: AbstractLorentzBoost - param::V +struct Boost{T<:AbstractBoostParameter} <: AbstractLorentzBoost + param::T end -boost_type(::Boost{V}) where {V} = V +boost_type(::Boost{T}) where {T} = T +Base.eltype(boost::Boost) = eltype(boost.param) # defaults Boost(x::Real) = Boost(BetaX(x)) diff --git a/src/patch_QEDbase.jl b/src/patch_QEDbase.jl new file mode 100644 index 0000000..28700ab --- /dev/null +++ b/src/patch_QEDbase.jl @@ -0,0 +1,168 @@ + +####### +# 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 + +######### +# 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. + +### Usage + +Subtypes of `AbstractLorentzTransformation` implement specific kinds of Lorentz transformations. +For example: +- [`Boost{T}`](@ref): A concrete implementation of Lorentz boosts with boost parameter `T` (see also [`AbstractBoostParameter`]@ref). + +These subtypes perform transformations on four-vectors (such as [`SFourMomentum`](@ref)) between different inertial reference 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 (such as [`SFourMomentum`](@ref)) change when transitioning between two reference frames moving at constant velocities (in units of the speed of light) relative to each other. + +For example: +- [`Boost{T}`](@ref): A concrete implementation of Lorentz boosts with boost parameter `T` (see also [`AbstractBoostParameter`]@ref). + +""" +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 (such as [`SFourMomentum`](@ref)). + +## 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. + +The `AbstractBoostParameter` type is the parent type for all specific kinds of boost parameters, including: +- **Axis-specific Boost Parameters**: Such as [`BetaX`](@ref), which describes a boost along the x-axis. +- **Vector-like Boost Parameters**: Such as [`BetaVector`](@ref), which describes boosts with components in multiple spatial directions. + +""" +abstract type AbstractBoostParameter end diff --git a/test/lorentz_transform/lorentz_transform.jl b/test/lorentz_transform/lorentz_transform.jl index ccdaf01..45be991 100644 --- a/test/lorentz_transform/lorentz_transform.jl +++ b/test/lorentz_transform/lorentz_transform.jl @@ -18,7 +18,9 @@ const TESTPSDEF = TestImplementation.TestPhasespaceDef() @testset "beta boost" begin @testset "defaults" begin - x, y, z = rand(RNG, 3) + xyz = rand(RNG, 3) + xyz = @. (2 * xyz - 1) / sqrt(3) + x, y, z = xyz boost_x_default = Boost(x) @test boost_x_default.param == BetaX(x) @@ -26,8 +28,36 @@ const TESTPSDEF = TestImplementation.TestPhasespaceDef() @test boost_vec_default.param == BetaVector(x, y, z) end - @testset "$boost_type" for boost_type in (BetaVector, BetaX, BetaY, BetaZ) - test_param = _rand(RNG, boost_type) + @testset "$val_type" for val_type in (Float64, Float32) + @testset "axis beta" begin + @testset "$beta_param_type" for beta_param_type in (BetaX, BetaY, BetaZ) + test_beta_val = 2 * rand(RNG, val_type) - 1 + test_beta = beta_param_type(test_beta_val) + + @testset "element type" begin + @test eltype(test_beta) == val_type + end + + # test converts + for comp_val_type in (Float64, Float32) + comp_beta = beta_param_type(comp_val_type(test_beta_val)) + + @testset "convert element" begin + test_beta_after = beta_param_type{comp_val_type}(test_beta_val) + @test test_beta_after == comp_beta + end + + @testset "convert type" begin + test_beta_after = convert(beta_param_type{comp_val_type}, test_beta) + @test test_beta_after == comp_beta + end + end + end + end + end + + @testset "$boost_param_type" for boost_param_type in (BetaVector, BetaX, BetaY, BetaZ) + test_param = _rand(RNG, boost_param_type) boost = Boost(test_param) @testset "invariance" begin @@ -48,7 +78,7 @@ const TESTPSDEF = TestImplementation.TestPhasespaceDef() end @testset "phase space point" begin - test_param = _rand(RNG, boost_type) + test_param = _rand(RNG, boost_param_type) boost = Boost(test_param) @testset "($N_INCOMING,$N_OUTGOING)" for (N_INCOMING, N_OUTGOING) in Iterators.product( diff --git a/test/lorentz_transform/utils.jl b/test/lorentz_transform/utils.jl index 2eb1cae..e609e98 100644 --- a/test/lorentz_transform/utils.jl +++ b/test/lorentz_transform/utils.jl @@ -2,11 +2,11 @@ Return a random beta vector. """ function _rand_beta(rng::AbstractRNG, ::Type{T}=Float64) where {T<:Real} - bx, by, bz = rand(rng, T, 3) - r = sqrt(bx^2 + by^2 + bz^2) - bxn, byn, bzn = bx / r, by / r, bz / r - scale = 2 * rand(rng, T) - one(T) - return BetaVector(bx * scale, by * scale, bz * scale) + beta_xyz = rand(rng, T, 3) + beta_xyz .*= 2 + beta_xyz .-= 1 + beta_xyz ./= sqrt(3) + return BetaVector(beta_xyz...) end @inline _rand(rng::AbstractRNG, ::Type{BetaVector}, ::Type{T}=Float64) where {T<:Real} = From 79d4e24ca1569150463ea649fcb533231146c03f Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Fri, 13 Sep 2024 23:05:53 +0200 Subject: [PATCH 10/15] fix doctests --- src/lorentz_boost/types.jl | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/lorentz_boost/types.jl b/src/lorentz_boost/types.jl index a357a76..2f33425 100644 --- a/src/lorentz_boost/types.jl +++ b/src/lorentz_boost/types.jl @@ -31,33 +31,35 @@ Depending on the boost parameter `V`, the boost can be: To create a Lorentz boost along the x-axis using the `BetaX` boost parameter: ```jldoctest example_boost_x -using QEDcore +julia> using QEDcore + julia> beta_x = BetaX(0.5) BetaX{Float64}(0.5) julia> boost_x = Boost(beta_x) Boost{BetaX{Float64}}(BetaX{Float64}(0.5)) ``` - To perform a Lorentz boost using the `boost_x` object, you can apply it to a four-vector, such as four-momentum: ```jldoctest example_boost_x julia> p = SFourMomentum(4, 3, 2, 1) 4-element SFourMomentum with indices SOneTo(4): - 4.0 - 3.0 - 2.0 - 1.0 + 4.0 + 3.0 + 2.0 + 1.0 julia> p_prime = boost_x(p) # Perform the boost 4-element SFourMomentum with indices SOneTo(4): - 2.886751345948129 - 1.1547005383792517 - 2.0 - 1.0 + 2.886751345948129 + 1.1547005383792517 + 2.0 + 1.0 + +julia> @assert isapprox(p*p, p_prime*p_prime) # The invariant mass is preserved + -julia> @assert isapprox(p*p, p_prime*p_prime) # The spacetime interval is preserved ``` ## Notes From 7bc14da28bf4098513bf57d34aba2b1cea5dd6b1 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Mon, 7 Oct 2024 15:11:40 +0200 Subject: [PATCH 11/15] Apply suggestions from code review Co-authored-by: Anton Reinhard --- src/QEDcore.jl | 1 - src/lorentz_boost/boost_parameter/boost_axis/beta.jl | 2 +- src/lorentz_boost/boost_parameter/boost_axis/convert.jl | 4 ++-- src/lorentz_boost/boost_parameter/boost_axis/types.jl | 8 ++++---- src/lorentz_boost/boost_parameter/boost_vector/beta.jl | 5 ++--- src/lorentz_boost/boost_parameter/boost_vector/types.jl | 4 ++-- src/lorentz_boost/boost_parameter/boost_vector/utils.jl | 2 +- src/lorentz_boost/types.jl | 6 ++---- src/patch_QEDbase.jl | 8 ++++---- test/lorentz_transform/lorentz_transform.jl | 2 +- 10 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/QEDcore.jl b/src/QEDcore.jl index 6b23f92..c73e9fd 100644 --- a/src/QEDcore.jl +++ b/src/QEDcore.jl @@ -31,7 +31,6 @@ export PhasespaceDefinition export ParticleStateful, PhaseSpacePoint, InPhaseSpacePoint, OutPhaseSpacePoint export spin, polarization, momenta, getindex -import Base: - using Reexport using DocStringExtensions using StaticArrays diff --git a/src/lorentz_boost/boost_parameter/boost_axis/beta.jl b/src/lorentz_boost/boost_parameter/boost_axis/beta.jl index 89c1566..b798000 100644 --- a/src/lorentz_boost/boost_parameter/boost_axis/beta.jl +++ b/src/lorentz_boost/boost_parameter/boost_axis/beta.jl @@ -22,7 +22,7 @@ These beta parameters are essential for performing axis-specific Lorentz boosts, """ abstract type AbstractAxisBeta{T} <: AbstractAxisBoostParameter{T} end --(beta::B) where {B<:AbstractAxisBeta} = B(-beta.param) +Base.:-(beta::B) where {B<:AbstractAxisBeta} = B(-beta.param) _inv(beta::B) where {B<:AbstractAxisBeta} = B(-beta.param) diff --git a/src/lorentz_boost/boost_parameter/boost_axis/convert.jl b/src/lorentz_boost/boost_parameter/boost_axis/convert.jl index 6da6bba..88c435a 100644 --- a/src/lorentz_boost/boost_parameter/boost_axis/convert.jl +++ b/src/lorentz_boost/boost_parameter/boost_axis/convert.jl @@ -1,7 +1,7 @@ function Base.convert( - ::Type{B}, param::S -) where {T<:Real,B<:AbstractAxisBoostParameter{T},S<:Real} + ::Type{B}, param::Real +) where {T<:Real,B<:AbstractAxisBoostParameter{T}} return B(T(param)) end function Base.convert( diff --git a/src/lorentz_boost/boost_parameter/boost_axis/types.jl b/src/lorentz_boost/boost_parameter/boost_axis/types.jl index 7147667..3ca7916 100644 --- a/src/lorentz_boost/boost_parameter/boost_axis/types.jl +++ b/src/lorentz_boost/boost_parameter/boost_axis/types.jl @@ -8,11 +8,11 @@ An abstract base type representing a boost parameter of type `T`, associated with a specific axis in space (e.g., ``x``, ``y``, or ``z``). -This type serves as a foundation for concrete boost parameter types that define Lorentz boosts along individual spatial directions, The parameter `T` typically represents the data type for the boost value (e.g., `Float64`, `Float32`). +This type serves as a foundation for concrete boost parameter types that define Lorentz boosts along individual spatial directions. The parameter `T` typically represents the data type for the boost value (e.g., `Float64`, `Float32`). ### Usage -Subtypes of `AbstractAxisBoostParameter{T}` are used to define specific boost transformations along a given axis (such as `BetaX` for the x-axis). These types are essential in performing Lorentz boosts, which transform four-momentum vectors between different inertial reference frames. +Subtypes of `AbstractAxisBoostParameter{T}` are used to define specific boost transformations along a given axis (such as [`BetaX`](@ref) for the x-axis). These types are essential in performing Lorentz boosts, which transform four-momentum vectors between different inertial reference frames. This abstract type is meant to be extended by concrete types to represent boosts along different Cartesian axes. @@ -20,8 +20,8 @@ This abstract type is meant to be extended by concrete types to represent boosts abstract type AbstractAxisBoostParameter{T} <: AbstractBoostParameter end function (::Type{BP})( - boost_val::S -) where {T<:Real,BP<:AbstractAxisBoostParameter{T},S<:Real} + boost_val::Real +) where {T<:Real,BP<:AbstractAxisBoostParameter{T}} return BP(T(boost_val)) end diff --git a/src/lorentz_boost/boost_parameter/boost_vector/beta.jl b/src/lorentz_boost/boost_parameter/boost_vector/beta.jl index 5aaffa7..93b5d99 100644 --- a/src/lorentz_boost/boost_parameter/boost_vector/beta.jl +++ b/src/lorentz_boost/boost_parameter/boost_vector/beta.jl @@ -80,14 +80,13 @@ struct BetaVector{T<:Real} <: AbstractBoostVector end BetaVector(x, y, z) = BetaVector(promote(x, y, z)...) -import Base: - --(b::BetaVector) = BetaVector(-b.x, -b.y, -b.z) +Base.:-(b::BetaVector) = BetaVector(-b.x, -b.y, -b.z) @inline function _spatial_mul(p::AbstractFourMomentum, beta::BetaVector) return p[2] * beta.x + p[3] * beta.y + p[4] * beta.z end -# assumption: beta vector components are communte with four momentum components +# assumption: beta vector components commute with four-momentum components _spatial_mul(beta::BetaVector, p::AbstractFourMomentum) = _spatial_mul(p, beta) function _three_vector_square(beta_vec::BetaVector) diff --git a/src/lorentz_boost/boost_parameter/boost_vector/types.jl b/src/lorentz_boost/boost_parameter/boost_vector/types.jl index e65bd00..43443bd 100644 --- a/src/lorentz_boost/boost_parameter/boost_vector/types.jl +++ b/src/lorentz_boost/boost_parameter/boost_vector/types.jl @@ -9,7 +9,7 @@ An abstract base type representing vector-like boost parameters, used to model Lorentz boosts in any spatial dimension. -`AbstractBoostVector` extends `AbstractBoostParameter` and provides the framework for +`AbstractBoostVector` extends [`AbstractBoostParameter`](@ref) and provides the framework for describing boosts that act in multiple spatial dimensions simultaneously, typically in three-dimensional space. This type is designed to support vector representations of velocities (in units of the speed of light) associated with Lorentz transformations in @@ -18,7 +18,7 @@ special relativity. ## Usage Concrete subtypes of `AbstractBoostVector` represent specific boost vectors that describe -the velocity components in each spatial dimension, such as `BetaVector`. These boost +the velocity components in each spatial dimension, such as [`BetaVector`](@ref). These boost vectors are commonly used in transformations of four-vectors (e.g., four-momentum, four-position) between different reference frames. diff --git a/src/lorentz_boost/boost_parameter/boost_vector/utils.jl b/src/lorentz_boost/boost_parameter/boost_vector/utils.jl index 231b918..fceebfe 100644 --- a/src/lorentz_boost/boost_parameter/boost_vector/utils.jl +++ b/src/lorentz_boost/boost_parameter/boost_vector/utils.jl @@ -2,7 +2,7 @@ function Base.isapprox( b1::BetaVector, b2::BetaVector; - atol::Real=0, + atol::Real=0.0, rtol::Real=Base.rtoldefault(b1.x, b1.y, atol), nans::Bool=false, norm::Function=abs, diff --git a/src/lorentz_boost/types.jl b/src/lorentz_boost/types.jl index 2f33425..1988a28 100644 --- a/src/lorentz_boost/types.jl +++ b/src/lorentz_boost/types.jl @@ -5,7 +5,7 @@ A concrete type representing a Lorentz boost transformation, parameterized by a boost parameter `V`. The boost parameter can be either axis-specific or vector-like, depending -on the subtype of `AbstractBoostParameter` used. The `Boost` type is used to perform +on the subtype of [`AbstractBoostParameter`](@ref) used. The `Boost` type is used to perform Lorentz boosts on four-vectors (such as four-momentum or four-position) between different inertial frames in special relativity. @@ -58,8 +58,6 @@ julia> p_prime = boost_x(p) # Perform the boost 1.0 julia> @assert isapprox(p*p, p_prime*p_prime) # The invariant mass is preserved - - ``` ## Notes @@ -67,7 +65,7 @@ julia> @assert isapprox(p*p, p_prime*p_prime) # The invariant mass is preserved The `Boost` type provides a unified and flexible interface for applying Lorentz boosts, with the boost parameter `V` determining the specific form of the transformation. Lorentz boosts preserve the spacetime interval, meaning that applying the boost to a -four-vector will not change the invariant quantity +four-vector will not change the invariant quantity. ## See Also diff --git a/src/patch_QEDbase.jl b/src/patch_QEDbase.jl index 28700ab..e19e8e8 100644 --- a/src/patch_QEDbase.jl +++ b/src/patch_QEDbase.jl @@ -7,9 +7,9 @@ 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: +Every subtype of `trafo::AbstractCoordinateTransformation` should implement the following interface functions: -* `QEDcore._transform(trafo,p)`: transfroms `p` +* `QEDcore._transform(trafo,p)`: transforms `p` * `Base.inv(trafo)`: returns the inverted transform ## Example @@ -115,7 +115,7 @@ inertial frames. Subtypes of `AbstractLorentzTransformation` implement specific kinds of Lorentz transformations. For example: -- [`Boost{T}`](@ref): A concrete implementation of Lorentz boosts with boost parameter `T` (see also [`AbstractBoostParameter`]@ref). +- [`Boost{T}`](@ref): A concrete implementation of Lorentz boosts with boost parameter `T` (see also [`AbstractBoostParameter`](@ref)). These subtypes perform transformations on four-vectors (such as [`SFourMomentum`](@ref)) between different inertial reference frames. """ @@ -133,7 +133,7 @@ for all types of boost transformations in special relativity. Lorentz boosts des four-vectors (such as [`SFourMomentum`](@ref)) change when transitioning between two reference frames moving at constant velocities (in units of the speed of light) relative to each other. For example: -- [`Boost{T}`](@ref): A concrete implementation of Lorentz boosts with boost parameter `T` (see also [`AbstractBoostParameter`]@ref). +- [`Boost{T}`](@ref): A concrete implementation of Lorentz boosts with boost parameter `T` (see also [`AbstractBoostParameter`](@ref)). """ abstract type AbstractLorentzBoost <: AbstractLorentzTransformation end diff --git a/test/lorentz_transform/lorentz_transform.jl b/test/lorentz_transform/lorentz_transform.jl index 45be991..3388295 100644 --- a/test/lorentz_transform/lorentz_transform.jl +++ b/test/lorentz_transform/lorentz_transform.jl @@ -38,7 +38,7 @@ const TESTPSDEF = TestImplementation.TestPhasespaceDef() @test eltype(test_beta) == val_type end - # test converts + # test conversions for comp_val_type in (Float64, Float32) comp_beta = beta_param_type(comp_val_type(test_beta_val)) From b8e95f0c94510ad323ef78b1a41943992b20b8ac Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Mon, 7 Oct 2024 14:59:14 +0200 Subject: [PATCH 12/15] add fix in states --- test/particles/states.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/particles/states.jl b/test/particles/states.jl index 97ef0a0..5de2404 100644 --- a/test/particles/states.jl +++ b/test/particles/states.jl @@ -5,7 +5,7 @@ using Random include("../utils.jl") RNG = MersenneTwister(708583836976) -ATOL = 1e-15 +ATOL = 1e-14 RTOL = 0.0 PHOTON_ENERGIES = (0.0, rand(RNG), rand(RNG) * 10) COS_THETAS = (-1.0, -rand(RNG), 0.0, rand(RNG), 1.0) From 3413670b63f8ac1df1bcd7cce9cae70e6a839b56 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Mon, 7 Oct 2024 15:20:31 +0200 Subject: [PATCH 13/15] simplified noop in convert --- Project.toml | 6 +----- src/lorentz_boost/boost_parameter/boost_axis/convert.jl | 4 +--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index f644bfd..456fa71 100644 --- a/Project.toml +++ b/Project.toml @@ -1,14 +1,10 @@ name = "QEDcore" uuid = "35dc0263-cb5f-4c33-a114-1d7f54ab753e" -authors = [ - "Uwe Hernandez Acosta ", - "Anton Reinhard ", -] +authors = ["Uwe Hernandez Acosta ", "Anton Reinhard "] version = "0.1.1" [deps] DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" -LorentzVectors = "3f54b04b-17fc-5cd4-9758-90c048d965e3" QEDbase = "10e22c08-3ccb-4172-bfcf-7d7aa3d04d93" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" diff --git a/src/lorentz_boost/boost_parameter/boost_axis/convert.jl b/src/lorentz_boost/boost_parameter/boost_axis/convert.jl index 88c435a..94ffd77 100644 --- a/src/lorentz_boost/boost_parameter/boost_axis/convert.jl +++ b/src/lorentz_boost/boost_parameter/boost_axis/convert.jl @@ -9,8 +9,6 @@ function Base.convert( ) where {T<:Real,B1<:AbstractAxisBoostParameter{T},B2<:AbstractAxisBoostParameter} return B1(T(d.param)) end -function Base.convert( - ::Type{B1}, d::B2 -) where {T<:Real,B1<:AbstractAxisBoostParameter{T},B2<:AbstractAxisBoostParameter{T}} +function Base.convert(::Type{B}, d::B) where {B<:AbstractAxisBoostParameter} return d end From deac722289f4c5a0a4779791493e8c0b4661cec9 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Mon, 7 Oct 2024 23:57:08 +0200 Subject: [PATCH 14/15] removed TODOs in source files --- src/lorentz_boost/boost_parameter/boost_axis/types.jl | 9 +-------- src/lorentz_boost/boost_parameter/boost_vector/types.jl | 5 ----- src/lorentz_boost/types.jl | 4 ---- src/patch_QEDbase.jl | 2 ++ 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/lorentz_boost/boost_parameter/boost_axis/types.jl b/src/lorentz_boost/boost_parameter/boost_axis/types.jl index 3ca7916..577d0e6 100644 --- a/src/lorentz_boost/boost_parameter/boost_axis/types.jl +++ b/src/lorentz_boost/boost_parameter/boost_axis/types.jl @@ -1,8 +1,3 @@ - -# TODO: -# - test conversions -# - decompose into separate files - """ AbstractAxisBoostParameter{T} @@ -19,9 +14,7 @@ This abstract type is meant to be extended by concrete types to represent boosts """ abstract type AbstractAxisBoostParameter{T} <: AbstractBoostParameter end -function (::Type{BP})( - boost_val::Real -) where {T<:Real,BP<:AbstractAxisBoostParameter{T}} +function (::Type{BP})(boost_val::Real) where {T<:Real,BP<:AbstractAxisBoostParameter{T}} return BP(T(boost_val)) end diff --git a/src/lorentz_boost/boost_parameter/boost_vector/types.jl b/src/lorentz_boost/boost_parameter/boost_vector/types.jl index 43443bd..184f406 100644 --- a/src/lorentz_boost/boost_parameter/boost_vector/types.jl +++ b/src/lorentz_boost/boost_parameter/boost_vector/types.jl @@ -1,8 +1,3 @@ -# TODO: -# - add interaction with axis boosts -# - add convenient constructors BetaVector(p) for the rest system? -# - test constructor error - """ AbstractBoostVector <: AbstractBoostParameter diff --git a/src/lorentz_boost/types.jl b/src/lorentz_boost/types.jl index 1988a28..70a83f1 100644 --- a/src/lorentz_boost/types.jl +++ b/src/lorentz_boost/types.jl @@ -85,10 +85,6 @@ Base.eltype(boost::Boost) = eltype(boost.param) Boost(x::Real) = Boost(BetaX(x)) Boost(x::Real, y::Real, z::Real) = Boost(BetaVector(x, y, z)) -# TODO: -# - add more convenient functions (type of the boost_param, ... ) -# - interaction between several boosts? -> product trafo (for later) - function _transform(boost::Boost, p::AbstractFourMomentum) return _transform(boost.param, p) end diff --git a/src/patch_QEDbase.jl b/src/patch_QEDbase.jl index e19e8e8..f88fc7c 100644 --- a/src/patch_QEDbase.jl +++ b/src/patch_QEDbase.jl @@ -1,3 +1,5 @@ +# This can be removed, if https://github.com/QEDjl-project/QEDbase.jl/pull/129 is merged +# and released. ####### # General coordinate transformations From 085e2933b528afdc001d5ecec1ed7c58a32cf49a Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Mon, 21 Oct 2024 11:29:15 +0200 Subject: [PATCH 15/15] cleanup Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 456fa71..4c3c684 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "QEDcore" uuid = "35dc0263-cb5f-4c33-a114-1d7f54ab753e" -authors = ["Uwe Hernandez Acosta ", "Anton Reinhard "] +authors = ["Uwe Hernandez Acosta ", "Anton Reinhard"] version = "0.1.1" [deps]