Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Lorentz Boosts #45

Merged
merged 15 commits into from
Oct 21, 2024
5 changes: 1 addition & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name = "QEDcore"
uuid = "35dc0263-cb5f-4c33-a114-1d7f54ab753e"
authors = [
"Uwe Hernandez Acosta <u.hernandez@hzdr.de>",
"Anton Reinhard <a.reinhard@hzdr.de>",
]
authors = ["Uwe Hernandez Acosta <u.hernandez@hzdr.de>", "Anton Reinhard"]
version = "0.1.1"

[deps]
Expand Down
14 changes: 14 additions & 0 deletions src/QEDcore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -34,6 +38,8 @@ using SimpleTraits

@reexport using QEDbase

include("patch_QEDbase.jl")

include("algebraic_objects/dirac_tensors/types.jl")
include("algebraic_objects/dirac_tensors/multiplication.jl")

Expand All @@ -47,6 +53,14 @@ 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_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")
include("particles/states.jl")
Expand Down
278 changes: 278 additions & 0 deletions src/lorentz_boost/boost_parameter/boost_axis/beta.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@

###########
# Axis Beta
###########
"""
AbstractAxisBeta{T} <: AbstractAxisBoostParameter{T}
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

Base.:-(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

"""
BetaX(beta::T) where {T<:Real}
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}
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> 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) # Invariant mass is preserved
```
## 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<:Real} <: AbstractAxisBeta{T}
param::T
function BetaX{T}(beta::T) where {T<:Real}
-one(beta) <= beta < one(beta) ||
AntonReinhard marked this conversation as resolved.
Show resolved Hide resolved
throw(InvalidInputError("beta parameter <$beta> must be between zero and one"))
return new{T}(beta)
end
end

BetaX(beta::T) where {T<:Real} = 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

"""
BetaY(beta::T) where {T<:Real}
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}
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) # Invariant mass is preserved
```
## 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<:Real} <: AbstractAxisBeta{T}
param::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)
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

"""
BetaZ(beta::T) where {T<:Real}
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}
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) # Invariant mass is preserved
```
## 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<:Real} <: AbstractAxisBeta{T}
param::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)
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
14 changes: 14 additions & 0 deletions src/lorentz_boost/boost_parameter/boost_axis/convert.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

function Base.convert(
::Type{B}, param::Real
) where {T<:Real,B<:AbstractAxisBoostParameter{T}}
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{B}, d::B) where {B<:AbstractAxisBoostParameter}
return d
end
21 changes: 21 additions & 0 deletions src/lorentz_boost/boost_parameter/boost_axis/types.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
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`](@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.
"""
abstract type AbstractAxisBoostParameter{T} <: AbstractBoostParameter end

function (::Type{BP})(boost_val::Real) where {T<:Real,BP<:AbstractAxisBoostParameter{T}}
return BP(T(boost_val))
end

Base.eltype(::AbstractAxisBoostParameter{T}) where {T} = T
Loading
Loading