Skip to content

Commit

Permalink
added docstring for boost vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwe Hernandez Acosta committed Sep 9, 2024
1 parent ca05028 commit d7a0749
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 22 deletions.
19 changes: 7 additions & 12 deletions src/lorentz_boost/axis_boost.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TODO:
# TODO:
# - test conversions
# - add convenient constructors: Boost(:x,::Real)
# - add convenient constructors: Boost(:rest_frame,::AbstractFourMomentum)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
```
Expand Down
67 changes: 64 additions & 3 deletions src/lorentz_boost/boost_vector.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/lorentz_boost/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
"""
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`
* `Base.inv(trafo)`: returns the inverted transform
## 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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit d7a0749

Please sign in to comment.