From 54907b749ae9fa1d4de24ba821a2a867430c6e54 Mon Sep 17 00:00:00 2001 From: Anton Reinhard Date: Thu, 12 Sep 2024 14:35:47 +0200 Subject: [PATCH 01/21] Rename QED (#58) Temporarily targets the PR of QED to test integration tests in https://github.com/QEDjl-project/QEDbase.jl/pull/119 --- .github/workflows/BuildDeployDoc.yml | 2 +- .gitlab-ci.yml | 4 ++-- README.md | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/BuildDeployDoc.yml b/.github/workflows/BuildDeployDoc.yml index 882a6b7..5c0550a 100644 --- a/.github/workflows/BuildDeployDoc.yml +++ b/.github/workflows/BuildDeployDoc.yml @@ -25,7 +25,7 @@ jobs: - name: set dependencies to dev branch version if: (github.event_name == 'push' && github.ref_name != 'main') || (github.event_name == 'pull_request' && github.base_ref != 'main') run: | - git clone -b dev https://github.com/QEDjl-project/QED.jl.git /tmp/integration_test_tools + git clone -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /tmp/integration_test_tools julia --project=docs/ /tmp/integration_test_tools/.ci/set_dev_dependencies.jl - name: Build and deploy env: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3f8e5d5..b3005f6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -62,7 +62,7 @@ generate_integration_tests: - export CI_DEPENDENCY_NAME=$(cat $CI_PROJECT_DIR/Project.toml | grep name | awk '{ print $3 }' | tr -d '"') - echo "CI_DEPENDENCY_NAME -> $CI_DEPENDENCY_NAME" - apt update && apt install -y git - - git clone --depth 1 -b dev https://github.com/QEDjl-project/QED.jl.git /QEDjl + - git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /QEDjl - cd /QEDjl/.ci/integTestGen/ # use local registry of the QED project - julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/QEDjl-project/registry.git"));' @@ -99,7 +99,7 @@ verify-unit-test-deps_julia1.10: stage: verify-unit-test-deps script: - apt update && apt install -y git - - git clone --depth 1 -b dev https://github.com/QEDjl-project/QED.jl.git /QEDjl + - git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /QEDjl - > if [[ $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_REF_NAME == "dev" ]]; then # does not check for custom package URLs on the main and dev branch diff --git a/README.md b/README.md index 07d24bd..6f8ae43 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,5 @@ [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://QEDjl-project.github.io/QEDcore.jl/dev/) [![Build Status](https://github.com/QEDjl-project/QEDcore.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/QEDjl-project/QEDcore.jl/actions/workflows/CI.yml?query=branch%3Amain) [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) + +This package is part of the `QuantumElectrodynamics.jl` library. For the description of the interoperability with other packages of `QuantumElectrodynamics.jl` see [docs](https://qedjl-project.github.io/QuantumElectrodynamics.jl/dev/). From 32c55ec863d500833568f8c0ae8b959b247a32c3 Mon Sep 17 00:00:00 2001 From: Simeon Ehrig Date: Fri, 13 Sep 2024 18:51:20 +0200 Subject: [PATCH 02/21] remove custom registry in CI (#59) --- .gitlab-ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b3005f6..48e6611 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -64,10 +64,6 @@ generate_integration_tests: - apt update && apt install -y git - git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /QEDjl - cd /QEDjl/.ci/integTestGen/ - # use local registry of the QED project - - julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/QEDjl-project/registry.git"));' - # needs to add General registry again, if local registry was added - - julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/JuliaRegistries/General"));' - julia --project=. -e 'import Pkg; Pkg.instantiate()' # paths of artifacts are relative to CI_PROJECT_DIR - > From a4b4f5d026e6128f5ecd3662c6d7b90c2a8741e2 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Sat, 14 Sep 2024 23:01:47 +0200 Subject: [PATCH 03/21] removed ParticleSpinors --- src/QEDcore.jl | 9 --- src/particles/particle_types.jl | 47 ++++++------- src/particles/spinors.jl | 121 -------------------------------- test/particles/spinors.jl | 88 ----------------------- test/particles/states.jl | 95 +++++++++++++++++++------ test/runtests.jl | 4 -- 6 files changed, 92 insertions(+), 272 deletions(-) delete mode 100644 src/particles/spinors.jl delete mode 100644 test/particles/spinors.jl diff --git a/src/QEDcore.jl b/src/QEDcore.jl index af51154..ef81690 100644 --- a/src/QEDcore.jl +++ b/src/QEDcore.jl @@ -13,18 +13,10 @@ export BiSpinor, AdjointBiSpinor, DiracMatrix export gamma, GAMMA, DiracGammaRepresentation, slashed # particle types -export AbstractParticleSpinor export FermionLike, Fermion, AntiFermion, MajoranaFermion export BosonLike, Boson, AntiBoson, MajoranaBoson export Electron, Positron, Photon -# particle spinors -export BASE_PARTICLE_SPINOR, BASE_ANTIPARTICLE_SPINOR -export IncomingFermionSpinor, - OutgoingFermionSpinor, IncomingAntiFermionSpinor, OutgoingAntiFermionSpinor -export SpinorU, SpinorUbar, SpinorV, SpinorVbar -export @valid_spinor_input - # particle base states export base_state @@ -58,6 +50,5 @@ include("algebraic_objects/gamma_matrices.jl") include("particles/particle_types.jl") include("particles/propagators.jl") include("particles/states.jl") -include("particles/spinors.jl") end diff --git a/src/particles/particle_types.jl b/src/particles/particle_types.jl index 97917df..ecd0a9c 100644 --- a/src/particles/particle_types.jl +++ b/src/particles/particle_types.jl @@ -1,17 +1,10 @@ ############### -# The particle types +# The particle types # # In this file, we define the types of particles, their states and directions, and -# implement the abstact particle interface accordingly. +# implement the abstact particle interface accordingly. ############### -""" - AbstractParticleSpinor - -TBW -""" -abstract type AbstractParticleSpinor end - """ Abstract base types for particle species that act like fermions in the sense of particle statistics. @@ -24,10 +17,10 @@ QEDbase.is_fermion(::FermionLike) = true """ Abstract base type for fermions as distinct from [`AntiFermion`](@ref)s. - + !!! note "particle interface" All subtypes of `Fermion` have - ```julia + ```julia is_fermion(::Fermion) = true is_particle(::Fermion) = true is_anti_particle(::Fermion) = false @@ -44,8 +37,8 @@ QEDbase.is_anti_particle(::Fermion) = false Abstract base type for anti-fermions as distinct from its particle counterpart `Fermion`. !!! note "particle interface" - All subtypes of `AntiFermion` have - ```julia + All subtypes of `AntiFermion` have + ```julia is_fermion(::AntiFermion) = true is_particle(::AntiFermion) = false is_anti_particle(::AntiFermion) = true @@ -61,13 +54,13 @@ QEDbase.is_anti_particle(::AntiFermion) = true Abstract base type for majorana-fermions, i.e. fermions which are their own anti-particles. !!! note "particle interface" - All subtypes of `MajoranaFermion` have - ```julia + All subtypes of `MajoranaFermion` have + ```julia is_fermion(::MajoranaFermion) = true is_particle(::MajoranaFermion) = true is_anti_particle(::MajoranaFermion) = true ``` - + """ abstract type MajoranaFermion <: FermionLike end @@ -76,7 +69,7 @@ QEDbase.is_particle(::MajoranaFermion) = true QEDbase.is_anti_particle(::MajoranaFermion) = true """ -Concrete type for *electrons* as a particle species. Mostly used for dispatch. +Concrete type for *electrons* as a particle species. Mostly used for dispatch. ```jldoctest julia> using QEDcore @@ -99,7 +92,7 @@ QEDbase.charge(::Electron) = -1.0 Base.show(io::IO, ::Electron) = print(io, "electron") """ -Concrete type for *positrons* as a particle species. Mostly used for dispatch. +Concrete type for *positrons* as a particle species. Mostly used for dispatch. ```jldoctest julia> using QEDcore @@ -122,8 +115,8 @@ QEDbase.charge(::Positron) = 1.0 Base.show(io::IO, ::Positron) = print(io, "positron") """ -Abstract base types for particle species that act like bosons in the sense of particle statistics. - +Abstract base types for particle species that act like bosons in the sense of particle statistics. + !!! note "particle interface" Every concrete subtype of `BosonLike` has `is_boson(::BosonLike) = true`. """ @@ -133,10 +126,10 @@ QEDbase.is_boson(::BosonLike) = true """ Abstract base type for bosons as distinct from its anti-particle counterpart [`AntiBoson`](@ref). - + !!! note "particle interface" All subtypes of `Boson` have - ```julia + ```julia is_boson(::Boson) = true is_particle(::Boson) = true is_anti_particle(::Boson) = false @@ -148,10 +141,10 @@ QEDbase.is_anti_particle(::Boson) = false """ Abstract base type for anti-bosons as distinct from its particle counterpart [`Boson`](@ref). - + !!! note "particle interface" All subtypes of `AntiBoson` have - ```julia + ```julia is_boson(::AntiBoson) = true is_particle(::AntiBoson) = false is_anti_particle(::AntiBoson) = true @@ -165,8 +158,8 @@ QEDbase.is_anti_particle(::AntiBoson) = true Abstract base type for majorana-bosons, i.e. bosons which are their own anti-particles. !!! note "particle interface" - All subtypes of `MajoranaBoson` have - ```julia + All subtypes of `MajoranaBoson` have + ```julia is_boson(::MajoranaBoson) = true is_particle(::MajoranaBoson) = true is_anti_particle(::MajoranaBoson) = true @@ -177,7 +170,7 @@ QEDbase.is_particle(::MajoranaBoson) = true QEDbase.is_anti_particle(::MajoranaBoson) = true """ -Concrete type for the *photons* as a particle species. Mostly used for dispatch. +Concrete type for the *photons* as a particle species. Mostly used for dispatch. ```jldoctest julia> using QEDcore diff --git a/src/particles/spinors.jl b/src/particles/spinors.jl deleted file mode 100644 index ab9ddbb..0000000 --- a/src/particles/spinors.jl +++ /dev/null @@ -1,121 +0,0 @@ -const SPINOR_VALIDITY_CHECK = Ref(true) - -macro valid_spinor_input(ex) - return quote - SPINOR_VALIDITY_CHECK.x = false - local val = $(esc(ex)) - SPINOR_VALIDITY_CHECK.x = true - val - end -end - -const BASE_PARTICLE_SPINOR_UP = BiSpinor(1.0, 0.0, 0.0, 0.0) -const BASE_PARTICLE_SPINOR_DOWN = BiSpinor(0.0, 1.0, 0.0, 0.0) -const BASE_PARTICLE_SPINOR = [BASE_PARTICLE_SPINOR_UP, BASE_PARTICLE_SPINOR_DOWN] -const BASE_ANTIPARTICLE_SPINOR_UP = BiSpinor(0.0, 0.0, 1.0, 0.0) -const BASE_ANTIPARTICLE_SPINOR_DOWN = BiSpinor(0.0, 0.0, 0.0, 1.0) -const BASE_ANTIPARTICLE_SPINOR = [ - BASE_ANTIPARTICLE_SPINOR_UP, BASE_ANTIPARTICLE_SPINOR_DOWN -] - -@inline function _check_spinor_input( - mom::T, mass::Float64 -) where {T<:AbstractLorentzVector{TE}} where {TE<:Real} - if SPINOR_VALIDITY_CHECK[] && !isonshell(mom, mass) - throw( - SpinorConstructionError( - "P^2 = $(getMass2(mom)) needs to be equal to mass^2=$(mass^2)" - ), - ) - end -end - -# -# fermion spinors -# - -function _build_particle_booster( - mom::T, mass::Float64 -) where {T<:AbstractLorentzVector{TE}} where {TE<:Real} - _check_spinor_input(mom, mass) - return (slashed(mom) + mass * one(DiracMatrix)) / (sqrt(abs(mom.t) + mass)) -end - -struct IncomingFermionSpinor <: AbstractParticleSpinor - booster::DiracMatrix -end - -function IncomingFermionSpinor( - mom::T, mass::Float64 -) where {T<:AbstractLorentzVector{TE}} where {TE<:Real} - return IncomingFermionSpinor(_build_particle_booster(mom, mass)) -end - -function (SP::IncomingFermionSpinor)(spin::Int64) - return SP.booster * BASE_PARTICLE_SPINOR[spin] -end - -const SpinorU = IncomingFermionSpinor - -struct OutgoingFermionSpinor <: AbstractParticleSpinor - booster::DiracMatrix -end - -function OutgoingFermionSpinor( - mom::T, mass::Float64 -) where {T<:AbstractLorentzVector{TE}} where {TE<:Real} - return OutgoingFermionSpinor(_build_particle_booster(mom, mass)) -end - -function (SP::OutgoingFermionSpinor)(spin::Int64) - return AdjointBiSpinor(SP.booster * BASE_PARTICLE_SPINOR[spin]) * GAMMA[1] -end - -const SpinorUbar = OutgoingFermionSpinor - -# -# Anti fermion spinors -# - -function _build_antiparticle_booster( - mom::T, mass::Float64 -) where {T<:AbstractLorentzVector{TE}} where {TE<:Real} - _check_spinor_input(mom, mass) - return (mass * one(DiracMatrix) - slashed(mom)) / (sqrt(abs(mom.t) + mass)) -end - -struct OutgoingAntiFermionSpinor <: AbstractParticleSpinor - booster::DiracMatrix -end - -function OutgoingAntiFermionSpinor( - mom::T, mass::Float64 -) where {T<:AbstractLorentzVector{TE}} where {TE<:Real} - return OutgoingAntiFermionSpinor(_build_antiparticle_booster(mom, mass)) -end - -function (SP::OutgoingAntiFermionSpinor)(spin::Int64) - return SP.booster * BASE_ANTIPARTICLE_SPINOR[spin] -end - -const SpinorV = OutgoingAntiFermionSpinor - -struct IncomingAntiFermionSpinor <: AbstractParticleSpinor - booster::DiracMatrix -end - -function IncomingAntiFermionSpinor( - mom::T, mass::Float64 -) where {T<:AbstractLorentzVector{TE}} where {TE<:Real} - return IncomingAntiFermionSpinor(_build_antiparticle_booster(mom, mass)) -end - -function (SP::IncomingAntiFermionSpinor)(spin::Int64) - return AdjointBiSpinor(SP.booster * BASE_ANTIPARTICLE_SPINOR[spin]) * GAMMA[1] -end - -const SpinorVbar = IncomingAntiFermionSpinor - -function Base.getindex(SP::T, idx) where {T<:AbstractParticleSpinor} - return idx in (1, 2) ? SP(idx) : throw(BoundsError()) -end diff --git a/test/particles/spinors.jl b/test/particles/spinors.jl deleted file mode 100644 index 7d424c7..0000000 --- a/test/particles/spinors.jl +++ /dev/null @@ -1,88 +0,0 @@ -using QEDcore -using Random - -const ATOL = 1e-15 - -const SPINS = (1, 2) - -@testset "particle spinors" for LorentzVectorType in [SFourMomentum, MFourMomentum] - rng = MersenneTwister(1234) - x, y, z = rand(rng, 3) - mass = rand(rng) - P = LorentzVectorType(sqrt(x^2 + y^2 + z^2 + mass^2), x, y, z) - - U = SpinorU(P, mass) - Ubar = SpinorUbar(P, mass) - V = SpinorV(P, mass) - Vbar = SpinorVbar(P, mass) - - @testset "construction" begin - @test U isa IncomingFermionSpinor - @test Ubar isa OutgoingFermionSpinor - @test V isa OutgoingAntiFermionSpinor - @test Vbar isa IncomingAntiFermionSpinor - - for spin in SPINS - @test isapprox(U[spin], U.booster * BASE_PARTICLE_SPINOR[spin]) - @test isapprox(V[spin], V.booster * BASE_ANTIPARTICLE_SPINOR[spin]) - - @test isapprox(Ubar[spin], AdjointBiSpinor(U[spin]) * GAMMA[1]) - @test isapprox(Vbar[spin], AdjointBiSpinor(V[spin]) * GAMMA[1]) - end - end # construction - - @testset "normatlisation" begin - for s1 in SPINS - for s2 in SPINS - @test isapprox(Ubar[s1] * U[s2], 2 * mass * (s1 == s2)) - @test isapprox(Vbar[s1] * V[s2], -2 * mass * (s1 == s2)) - @test isapprox(Ubar[s1] * V[s2], 0.0) - @test isapprox(Vbar[s1] * U[s2], 0.0) - end - end - end # normatlisation - - @testset "completeness" begin - sumU = zero(DiracMatrix) - sumV = zero(DiracMatrix) - for spin in SPINS - sumU += U(spin) * Ubar(spin) - sumV += V(spin) * Vbar(spin) - end - - @test isapprox(sumU, (slashed(P) + mass * one(DiracMatrix))) - @test isapprox(sumV, (slashed(P) - mass * one(DiracMatrix))) - end # completeness - - @testset "diracs equation" begin - for spin in SPINS - @test isapprox( - (slashed(P) - mass * one(DiracMatrix)) * U[spin], zero(BiSpinor), atol=ATOL - ) - @test isapprox( - (slashed(P) + mass * one(DiracMatrix)) * V[spin], zero(BiSpinor), atol=ATOL - ) - @test isapprox( - Ubar[spin] * (slashed(P) - mass * one(DiracMatrix)), - zero(AdjointBiSpinor), - atol=ATOL, - ) - @test isapprox( - Vbar[spin] * (slashed(P) + mass * one(DiracMatrix)), - zero(AdjointBiSpinor), - atol=ATOL, - ) - end - end #diracs equation - - @testset "sandwich" begin - for s1 in SPINS - for s2 in SPINS - @test isapprox( - LorentzVectorType(Ubar[s1] * (GAMMA * U[s2])) * (s1 == s2), - 2 * P * (s1 == s2), - ) - end - end - end #sandwich -end # particle spinors diff --git a/test/particles/states.jl b/test/particles/states.jl index 36dd488..6c9eb48 100644 --- a/test/particles/states.jl +++ b/test/particles/states.jl @@ -4,15 +4,8 @@ using Random include("../utils.jl") -FERMION_STATES_GROUNDTRUTH_FACTORY = Dict( - (Incoming, Electron) => IncomingFermionSpinor, - (Outgoing, Electron) => OutgoingFermionSpinor, - (Incoming, Positron) => IncomingAntiFermionSpinor, - (Outgoing, Positron) => OutgoingAntiFermionSpinor, -) - RNG = MersenneTwister(708583836976) -ATOL = eps() +ATOL = 1e-15 RTOL = 0.0 PHOTON_ENERGIES = (0.0, rand(RNG), rand(RNG) * 10) COS_THETAS = (-1.0, -rand(RNG), 0.0, rand(RNG), 1.0) @@ -48,21 +41,77 @@ test_broadcast(x::AbstractSpinOrPolarization) = x Iterators.product((Electron, Positron), (Incoming, Outgoing)) mom = SFourMomentum(sqrt(mass(p()) + X^2 + Y^2 + Z^2), X, Y, Z) particle_mass = mass(p()) - groundtruth_states = FERMION_STATES_GROUNDTRUTH_FACTORY[(d, p)](mom, particle_mass) - groundtruth_tuple = SVector(groundtruth_states(1), groundtruth_states(2)) - @test base_state(p(), d(), mom, AllSpin()) == groundtruth_tuple - @test base_state(p(), d(), mom, SpinUp()) == groundtruth_tuple[1] - @test base_state(p(), d(), mom, SpinDown()) == groundtruth_tuple[2] - - @test QEDbase._as_svec(base_state(p(), d(), mom, AllSpin())) isa SVector - @test QEDbase._as_svec(base_state(p(), d(), mom, SpinUp())) isa SVector - @test QEDbase._as_svec(base_state(p(), d(), mom, SpinDown())) isa SVector - - @test QEDbase._as_svec(base_state(p(), d(), mom, AllSpin())) == groundtruth_tuple - @test QEDbase._as_svec(base_state(p(), d(), mom, SpinUp()))[1] == - groundtruth_tuple[1] - @test QEDbase._as_svec(base_state(p(), d(), mom, SpinDown()))[1] == - groundtruth_tuple[2] + + @testset "tooling" begin + @test QEDbase._as_svec(base_state(p(), d(), mom, AllSpin())) isa SVector + @test QEDbase._as_svec(base_state(p(), d(), mom, SpinUp())) isa SVector + @test QEDbase._as_svec(base_state(p(), d(), mom, SpinDown())) isa SVector + end + end + @testset "spinor properties" begin + x, y, z = rand(RNG, 3) + m = mass(Electron()) + P = SFourMomentum(sqrt(x^2 + y^2 + z^2 + m^2), x, y, z) + + U = base_state(Electron(), Incoming(), P, AllSpin()) + Ubar = base_state(Electron(), Outgoing(), P, AllSpin()) + V = base_state(Positron(), Outgoing(), P, AllSpin()) + Vbar = base_state(Positron(), Incoming(), P, AllSpin()) + + @testset "normatlisation" begin + for s1 in (1, 2) + for s2 in (1, 2) + @test isapprox(Ubar[s1] * U[s2], 2 * m * (s1 == s2)) + @test isapprox(Vbar[s1] * V[s2], -2 * m * (s1 == s2)) + @test isapprox(Ubar[s1] * V[s2], 0.0) + @test isapprox(Vbar[s1] * U[s2], 0.0) + end + end + end # normatlisation + + @testset "completeness" begin + sumU = zero(DiracMatrix) + sumV = zero(DiracMatrix) + for spin in (1, 2) + sumU += U[spin] * Ubar[spin] + sumV += V[spin] * Vbar[spin] + end + + @test isapprox(sumU, (slashed(P) + m * one(DiracMatrix))) + @test isapprox(sumV, (slashed(P) - m * one(DiracMatrix))) + end # completeness + + @testset "diracs equation" begin + for spin in (1, 2) + @test isapprox( + (slashed(P) - m * one(DiracMatrix)) * U[spin], zero(BiSpinor), atol=ATOL + ) + @test isapprox( + (slashed(P) + m * one(DiracMatrix)) * V[spin], zero(BiSpinor), atol=ATOL + ) + @test isapprox( + Ubar[spin] * (slashed(P) - m * one(DiracMatrix)), + zero(AdjointBiSpinor), + atol=ATOL, + ) + @test isapprox( + Vbar[spin] * (slashed(P) + m * one(DiracMatrix)), + zero(AdjointBiSpinor), + atol=ATOL, + ) + end + end #diracs equation + + @testset "sandwich" begin + for s1 in (1, 2) + for s2 in (1, 2) + @test isapprox( + SFourMomentum(Ubar[s1] * (GAMMA * U[s2])) * (s1 == s2), + 2 * P * (s1 == s2), + ) + end + end + end #sandwich end end diff --git a/test/runtests.jl b/test/runtests.jl index 48f361a..47d20c0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -33,10 +33,6 @@ begin include("particles/states.jl") end - @time @safetestset "particle spinors" begin - include("particles/spinors.jl") - end - @time @safetestset "particle base states" begin include("particles/states.jl") end From bed246bdaad301bb439688ac2ff38bbe2543cc05 Mon Sep 17 00:00:00 2001 From: Anton Reinhard Date: Mon, 23 Sep 2024 14:23:40 +0200 Subject: [PATCH 04/21] Add CompatHelper (#63) Adds the compat helper workflow. I also set up the deploy key and the private key secret. --- .github/workflows/CompatHelper.yml | 45 ++++++++++++++++++++++++++++++ .github/workflows/TagBot.yml | 31 ++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 .github/workflows/CompatHelper.yml create mode 100644 .github/workflows/TagBot.yml diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml new file mode 100644 index 0000000..ea09c3f --- /dev/null +++ b/.github/workflows/CompatHelper.yml @@ -0,0 +1,45 @@ +name: CompatHelper +on: + schedule: + - cron: 0 0 * * * + workflow_dispatch: +permissions: + contents: write + pull-requests: write +jobs: + CompatHelper: + if: github.repository == 'QEDjl-project/QEDcore.jl' + runs-on: ubuntu-latest + steps: + - name: Check if Julia is already available in the PATH + id: julia_in_path + run: which julia + continue-on-error: true + - name: Install Julia, but only if it is not already available in the PATH + uses: julia-actions/setup-julia@v1 + with: + version: '1' + arch: ${{ runner.arch }} + if: steps.julia_in_path.outcome != 'success' + - name: "Add the General registry via Git" + run: | + import Pkg + ENV["JULIA_PKG_SERVER"] = "" + Pkg.Registry.add("General") + shell: julia --color=yes {0} + - name: "Install CompatHelper" + run: | + import Pkg + name = "CompatHelper" + uuid = "aa819f21-2bde-4658-8897-bab36330d9b7" + version = "3" + Pkg.add(; name, uuid, version) + shell: julia --color=yes {0} + - name: "Run CompatHelper" + run: | + import CompatHelper + CompatHelper.main(; master_branch="dev") + shell: julia --color=yes {0} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }} diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml new file mode 100644 index 0000000..a3d77f7 --- /dev/null +++ b/.github/workflows/TagBot.yml @@ -0,0 +1,31 @@ +name: TagBot +on: + issue_comment: + types: + - created + workflow_dispatch: + inputs: + lookback: + default: "3" +permissions: + actions: read + checks: read + contents: write + deployments: read + issues: read + discussions: read + packages: read + pages: read + pull-requests: read + repository-projects: read + security-events: read + statuses: read +jobs: + TagBot: + if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + ssh: ${{ secrets.TAGBOT_PRIV }} From e24cca8278d44dda532cbc3ad5819d0385052da4 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Mon, 7 Oct 2024 14:58:32 +0200 Subject: [PATCH 05/21] Apply suggestions from code review Co-authored-by: Anton Reinhard --- 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 6c9eb48..df9bfe5 100644 --- a/test/particles/states.jl +++ b/test/particles/states.jl @@ -58,7 +58,7 @@ test_broadcast(x::AbstractSpinOrPolarization) = x V = base_state(Positron(), Outgoing(), P, AllSpin()) Vbar = base_state(Positron(), Incoming(), P, AllSpin()) - @testset "normatlisation" begin + @testset "normalization" begin for s1 in (1, 2) for s2 in (1, 2) @test isapprox(Ubar[s1] * U[s2], 2 * m * (s1 == s2)) From 1a318ddfdd9efc20023be24e2be3bbf10935964f Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Mon, 7 Oct 2024 15:04:43 +0200 Subject: [PATCH 06/21] fixed state test --- test/particles/states.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/particles/states.jl b/test/particles/states.jl index df9bfe5..97ef0a0 100644 --- a/test/particles/states.jl +++ b/test/particles/states.jl @@ -106,8 +106,7 @@ test_broadcast(x::AbstractSpinOrPolarization) = x for s1 in (1, 2) for s2 in (1, 2) @test isapprox( - SFourMomentum(Ubar[s1] * (GAMMA * U[s2])) * (s1 == s2), - 2 * P * (s1 == s2), + SFourMomentum(Ubar[s1] * (GAMMA * U[s2])), 2 * P * (s1 == s2) ) end end From a1741556c9db02316837b10b8bf1feecf3f51cd8 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Wed, 9 Oct 2024 17:36:32 +0200 Subject: [PATCH 07/21] dropped Julia <1.10 in CI, bumped combat to Juila1.10 (#67) Co-authored-by: Uwe Hernandez Acosta --- .gitlab-ci.yml | 2 +- Project.toml | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 48e6611..7f64d6c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,7 @@ unit_tests_releases: extends: .untit_test_template parallel: matrix: - - JULIA_VERSION: ["1.6", "1.7", "1.8", "1.9", "1.10"] + - JULIA_VERSION: ["1.10", "1.11", "rc"] image: julia:$JULIA_VERSION unit_tests_nightly: diff --git a/Project.toml b/Project.toml index 52be8c4..b350c82 100644 --- a/Project.toml +++ b/Project.toml @@ -19,7 +19,7 @@ QEDbase = "0.2.2" Reexport = "^1.2" SimpleTraits = "^0.9" StaticArrays = "^1.9" -julia = "1.6" +julia = "1.10" [extras] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -29,10 +29,4 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = [ - "Random", - "LinearAlgebra", - "SafeTestsets", - "Test", - "SparseArrays", -] +test = ["Random", "LinearAlgebra", "SafeTestsets", "Test", "SparseArrays"] From 56610d7bbb9c0f1d3f2b6a1b9237adf5fa5c7c61 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Mon, 21 Oct 2024 15:13:01 +0200 Subject: [PATCH 08/21] Add Lorentz Boosts (#45) This adds Lorentz boosts in two variants: 1. based on a vector of beta parameters (`BetaVector`), see [here](https://physics.stackexchange.com/questions/30166/what-is-a-lorentz-boost-and-how-to-calculate-it) or [here](https://root.cern.ch/doc/master/classROOT_1_1Math_1_1Boost.html) for details. 2. special case of axis-aligned boosts parameterized using single beta vector components. Solves #18 --------- Co-authored-by: Uwe Hernandez Acosta Co-authored-by: Anton Reinhard --- Project.toml | 5 +- src/QEDcore.jl | 14 + .../boost_parameter/boost_axis/beta.jl | 278 ++++++++++++++++++ .../boost_parameter/boost_axis/convert.jl | 14 + .../boost_parameter/boost_axis/types.jl | 21 ++ .../boost_parameter/boost_vector/beta.jl | 122 ++++++++ .../boost_parameter/boost_vector/types.jl | 24 ++ .../boost_parameter/boost_vector/utils.jl | 13 + src/lorentz_boost/types.jl | 94 ++++++ src/patch_QEDbase.jl | 170 +++++++++++ test/lorentz_transform/lorentz_transform.jl | 149 ++++++++++ test/lorentz_transform/utils.jl | 19 ++ test/particles/states.jl | 2 +- test/runtests.jl | 4 + 14 files changed, 924 insertions(+), 5 deletions(-) create mode 100644 src/lorentz_boost/boost_parameter/boost_axis/beta.jl create mode 100644 src/lorentz_boost/boost_parameter/boost_axis/convert.jl create mode 100644 src/lorentz_boost/boost_parameter/boost_axis/types.jl create mode 100644 src/lorentz_boost/boost_parameter/boost_vector/beta.jl create mode 100644 src/lorentz_boost/boost_parameter/boost_vector/types.jl create mode 100644 src/lorentz_boost/boost_parameter/boost_vector/utils.jl create mode 100644 src/lorentz_boost/types.jl create mode 100644 src/patch_QEDbase.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..4c3c684 100644 --- a/Project.toml +++ b/Project.toml @@ -1,9 +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] diff --git a/src/QEDcore.jl b/src/QEDcore.jl index ef81690..c73e9fd 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 @@ -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") @@ -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") diff --git a/src/lorentz_boost/boost_parameter/boost_axis/beta.jl b/src/lorentz_boost/boost_parameter/boost_axis/beta.jl new file mode 100644 index 0000000..b798000 --- /dev/null +++ b/src/lorentz_boost/boost_parameter/boost_axis/beta.jl @@ -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) || + 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 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..94ffd77 --- /dev/null +++ b/src/lorentz_boost/boost_parameter/boost_axis/convert.jl @@ -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 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..577d0e6 --- /dev/null +++ b/src/lorentz_boost/boost_parameter/boost_axis/types.jl @@ -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 diff --git a/src/lorentz_boost/boost_parameter/boost_vector/beta.jl b/src/lorentz_boost/boost_parameter/boost_vector/beta.jl new file mode 100644 index 0000000..93b5d99 --- /dev/null +++ b/src/lorentz_boost/boost_parameter/boost_vector/beta.jl @@ -0,0 +1,122 @@ + +""" + + BetaVector(x::Real,y::Real,z::Real) + +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} +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) # 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) +* [`ROOT::Math:Boost` from ROOT](https://root.cern.ch/doc/master/classROOT_1_1Math_1_1Boost.html) + +""" +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.", + ), + ) + return new{T}(x, y, z) + end +end +BetaVector(x, y, z) = BetaVector(promote(x, y, 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 commute with four-momentum components +_spatial_mul(beta::BetaVector, p::AbstractFourMomentum) = _spatial_mul(p, beta) + +function _three_vector_square(beta_vec::BetaVector) + bx = beta_vec.x + by = beta_vec.y + bz = beta_vec.z + return bx^2 + by^2 + bz^2 +end + +@inline function _transform(beta_vec::BetaVector, p::M) where {M<:AbstractFourMomentum} + b2 = _three_vector_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 = _spatial_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 + +# 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..184f406 --- /dev/null +++ b/src/lorentz_boost/boost_parameter/boost_vector/types.jl @@ -0,0 +1,24 @@ +""" + AbstractBoostVector <: AbstractBoostParameter + +An abstract base type representing vector-like boost parameters, used to model Lorentz boosts +in any spatial dimension. + +`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 +special relativity. + +## Usage + +Concrete subtypes of `AbstractBoostVector` represent specific boost vectors that describe +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. + +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..fceebfe --- /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.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/types.jl b/src/lorentz_boost/types.jl new file mode 100644 index 0000000..70a83f1 --- /dev/null +++ b/src/lorentz_boost/types.jl @@ -0,0 +1,94 @@ + +""" + + 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`](@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. + +## 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 +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 + +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 invariant mass 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. +""" +struct Boost{T<:AbstractBoostParameter} <: AbstractLorentzBoost + param::T +end +boost_type(::Boost{T}) where {T} = T +Base.eltype(boost::Boost) = eltype(boost.param) + +# defaults +Boost(x::Real) = Boost(BetaX(x)) +Boost(x::Real, y::Real, z::Real) = Boost(BetaVector(x, y, z)) + +function _transform(boost::Boost, p::AbstractFourMomentum) + return _transform(boost.param, p) +end + +function Base.inv(boost::Boost) + return Boost(_inv(boost.param)) +end diff --git a/src/patch_QEDbase.jl b/src/patch_QEDbase.jl new file mode 100644 index 0000000..f88fc7c --- /dev/null +++ b/src/patch_QEDbase.jl @@ -0,0 +1,170 @@ +# This can be removed, if https://github.com/QEDjl-project/QEDbase.jl/pull/129 is merged +# and released. + +####### +# General coordinate transformations +####### + +""" + AbstractCoordinateTransformation + +Abstract base type for coordinate transformations supposed to be acting on four-momenta. +Every subtype of `trafo::AbstractCoordinateTransformation` should implement the following interface functions: + +* `QEDcore._transform(trafo,p)`: transforms `p` +* `Base.inv(trafo)`: returns the inverted transform + +## Example + +Implementing the interface by defining the interface functions: + +```jldoctest trafo_interface +julia> using 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 new file mode 100644 index 0000000..3388295 --- /dev/null +++ b/test/lorentz_transform/lorentz_transform.jl @@ -0,0 +1,149 @@ +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 + 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) + + boost_vec_default = Boost(x, y, z) + @test boost_vec_default.param == BetaVector(x, y, z) + end + + @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 conversions + 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 + 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 + inv_boost_direct = Boost(-test_param) + inv_boost = inv(boost) + + @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_param_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 + 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..e609e98 --- /dev/null +++ b/test/lorentz_transform/utils.jl @@ -0,0 +1,19 @@ +""" +Return a random beta vector. +""" +function _rand_beta(rng::AbstractRNG, ::Type{T}=Float64) where {T<:Real} + 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} = + _rand_beta(rng, 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 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) 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 d61a4be884c34fcc801f9c886b7d7d423d4bb139 Mon Sep 17 00:00:00 2001 From: Rubydragon Date: Tue, 1 Oct 2024 17:55:53 +0200 Subject: [PATCH 09/21] Add the library reference and index manually in a proper structure --- README.md | 34 +++++++++++++- docs/Project.toml | 1 + docs/make.jl | 71 +++++++++++++++++++++++------ docs/src/index.md | 14 ------ docs/src/library/outline.md | 10 ++++ docs/src/library/particles.md | 25 ++++++++++ docs/src/library/phasespacedef.md | 22 +++++++++ docs/src/library/phasespacepoint.md | 14 ++++++ docs/src/library/vectors.md | 38 +++++++++++++++ 9 files changed, 200 insertions(+), 29 deletions(-) delete mode 100644 docs/src/index.md create mode 100644 docs/src/library/outline.md create mode 100644 docs/src/library/particles.md create mode 100644 docs/src/library/phasespacedef.md create mode 100644 docs/src/library/phasespacepoint.md create mode 100644 docs/src/library/vectors.md diff --git a/README.md b/README.md index 6f8ae43..07d7309 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# QEDcore +# QEDcore.jl [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://QEDjl-project.github.io/QEDcore.jl/stable/) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://QEDjl-project.github.io/QEDcore.jl/dev/) @@ -6,3 +6,35 @@ [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) This package is part of the `QuantumElectrodynamics.jl` library. For the description of the interoperability with other packages of `QuantumElectrodynamics.jl` see [docs](https://qedjl-project.github.io/QuantumElectrodynamics.jl/dev/). + +## Contributing + +Contributions are welcome! If you'd like to report a bug, suggest an enhancement, or contribute +code, please feel free to open an issue or submit a pull request. + +To ensure consistency across the `QuantumElectrodynamics.jl` ecosystem, we encourage all contributors +to review the [QuantumElectrodynamics.jl contribution guide](https://qedjl-project.github.io/QuantumElectrodynamics.jl/stable/dev_guide/#Development-Guide). + +## Credits and contributors + +This work was partly funded by the Center for Advanced Systems Understanding (CASUS) that +is financed by Germany’s Federal Ministry of Education and Research (BMBF) and by the Saxon +Ministry for Science, Culture and Tourism (SMWK) with tax funds on the basis of the budget +approved by the Saxon State Parliament. + +The core code of the package `QEDcore.jl` is developed by a small team at the Center for +Advanced Systems Understanding ([CASUS](https://www.casus.science)), namely + +### Core Contributors + +- **Uwe Hernandez Acosta** (CASUS/HZDR, [u.hernandez@hzdr.de](mailto:u.hernandez@hzdr.de)) +- **Anton Reinhard** (CASUS/HZDR) +- **Simeon Ehrig** (CASUS/HZDR) + +### Former Contributors + +We extend our sincere thanks to all contributors who have supported this project. + +## License + +[MIT](LICENSE) © Uwe Hernandez Acosta diff --git a/docs/Project.toml b/docs/Project.toml index 5ba0196..6edf6ee 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,5 +1,6 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656" QEDbase = "10e22c08-3ccb-4172-bfcf-7d7aa3d04d93" QEDcore = "35dc0263-cb5f-4c33-a114-1d7f54ab753e" QEDprocesses = "46de9c38-1bb3-4547-a1ec-da24d767fdad" diff --git a/docs/make.jl b/docs/make.jl index 91cc8b4..8702cc1 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -5,23 +5,66 @@ using Pkg project_path = Base.Filesystem.joinpath(Base.Filesystem.dirname(Base.source_path()), "..") Pkg.develop(; path=project_path) -Pkg.add(; url="https://github.com/QEDjl-project/QEDbase.jl/", rev="dev") - +using QEDbase using QEDcore +using QEDprocesses + using Documenter +using DocumenterInterLinks -# DocMeta.setdocmeta!(QEDcore, :DocTestSetup, :(using QEDcore); recursive=true) - -makedocs(; - modules=[QEDcore], - authors="Uwe Hernandez Acosta ", - sitename="QEDcore.jl", - format=Documenter.HTML(; - canonical="https://QEDjl-project.github.io/QEDcore.jl", - edit_link="main", - assets=String[], - ), - pages=["Home" => "index.md"], +# setup interlinks +links = InterLinks( + "QuantumElectrodynamics" => "https://qedjl-project.github.io/QuantumElectrodynamics.jl/dev/", + "QEDbase" => "https://qedjl-project.github.io/QEDbase.jl/dev/", + "QEDcore" => "https://qedjl-project.github.io/QEDcore.jl/dev/", + "QEDprocesses" => "https://qedjl-project.github.io/QEDprocesses.jl/dev/", ) +# some paths for links +readme_path = joinpath(project_path, "README.md") +index_path = joinpath(project_path, "docs/src/index.md") +license_path = "https://github.com/QEDjl-project/QEDcore.jl/blob/main/LICENSE" + +# Copy README.md from the project base folder and use it as the start page +open(readme_path, "r") do readme_in + readme_string = read(readme_in, String) + + # replace relative links in the README.md + readme_string = replace(readme_string, "[MIT](LICENSE)" => "[MIT]($(license_path))") + + open(index_path, "w") do readme_out + write(readme_out, readme_string) + end +end + +pages = [ + "Home" => "index.md", + "API reference" => [ + "Contents" => "library/outline.md", + "Particles" => "library/particles.md", + "Phase Space Definition" => "library/phasespacedef.md", + "Phase Space Points" => "library/phasespacepoint.md", + "Vector Types" => "library/vectors.md", + ], +] + +try + makedocs(; + modules=[QEDcore], + checkdocs=:exports, + authors="Uwe Hernandez Acosta", + repo=Documenter.Remotes.GitHub("QEDjl-project", "QEDcore.jl"), + sitename="QEDcore.jl", + format=Documenter.HTML(; + prettyurls=get(ENV, "CI", "false") == "true", + canonical="https://qedjl-project.gitlab.io/QEDcore.jl", + assets=String[], + ), + pages=pages, + ) +finally + @info "Garbage collection: remove landing page" + rm(index_path) +end + deploydocs(; repo="github.com/QEDjl-project/QEDcore.jl", push_preview=false) diff --git a/docs/src/index.md b/docs/src/index.md deleted file mode 100644 index da47691..0000000 --- a/docs/src/index.md +++ /dev/null @@ -1,14 +0,0 @@ -```@meta -CurrentModule = QEDcore -``` - -# QEDcore - -Documentation for [QEDcore](https://github.com/QEDjl-project/QEDcore.jl). - -```@index -``` - -```@autodocs -Modules = [QEDcore] -``` diff --git a/docs/src/library/outline.md b/docs/src/library/outline.md new file mode 100644 index 0000000..44e7d82 --- /dev/null +++ b/docs/src/library/outline.md @@ -0,0 +1,10 @@ +```@meta +CurrentModule = QEDcore +``` + +# QEDcore + +API index for [QEDcore](https://github.com/QEDjl-project/QEDcore.jl). + +```@index +``` diff --git a/docs/src/library/particles.md b/docs/src/library/particles.md new file mode 100644 index 0000000..57fc097 --- /dev/null +++ b/docs/src/library/particles.md @@ -0,0 +1,25 @@ +# Particles + +## Particle Types + +The following are subtypes of `QEDbase.AbstractParticleType`(@extref). + +For all these types the corresponding interface is implemented, including `QEDbase.base_state`(@extref) and `QEDbase.propagator`(@extref). + +```@meta +CurrentModule = QEDcore +``` + +```@docs +FermionLike +BosonLike +MajoranaFermion +MajoranaBoson +Fermion +Boson +AntiFermion +AntiBoson +Electron +Positron +Photon +``` diff --git a/docs/src/library/phasespacedef.md b/docs/src/library/phasespacedef.md new file mode 100644 index 0000000..af588b5 --- /dev/null +++ b/docs/src/library/phasespacedef.md @@ -0,0 +1,22 @@ +# Phase Space Definitions + +```@meta +CurrentModule = QEDcore +``` + +## Phase Space Definition Type +```@docs +PhasespaceDefinition +``` + +## Frames of Reference +```@docs +CenterOfMomentumFrame +ElectronRestFrame +``` + +## Coordinate Systems + +```@docs +SphericalCoordinateSystem +``` diff --git a/docs/src/library/phasespacepoint.md b/docs/src/library/phasespacepoint.md new file mode 100644 index 0000000..44565b7 --- /dev/null +++ b/docs/src/library/phasespacepoint.md @@ -0,0 +1,14 @@ +# Phase Space Points + +```@meta +CurrentModule = QEDcore +``` + +```@docs +ParticleStateful +PhaseSpacePoint +InPhaseSpacePoint +OutPhaseSpacePoint +getindex +_momentum_type +``` diff --git a/docs/src/library/vectors.md b/docs/src/library/vectors.md new file mode 100644 index 0000000..6c58fec --- /dev/null +++ b/docs/src/library/vectors.md @@ -0,0 +1,38 @@ +# Vector and Matrix Types + +```@meta +CurrentModule = QEDcore +``` + +## 4-Momenta +```@docs +SFourMomentum +MFourMomentum +``` + +## Spinors +```@docs +BiSpinor +AdjointBiSpinor +``` + +## Lorentz Vectors +```@docs +SLorentzVector +MLorentzVector +``` + +## Dirac Matrix +```@docs +DiracMatrix +``` + +## Multiplications +```@docs +_mul +``` + +## Deprecated +```@docs +AbstractParticleSpinor +``` From 680cc14abc08b3f79666afaff5c6f766c44f6071 Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Wed, 9 Oct 2024 12:39:28 +0200 Subject: [PATCH 10/21] Add small readme section --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 07d7309..48ff7b9 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ This package is part of the `QuantumElectrodynamics.jl` library. For the description of the interoperability with other packages of `QuantumElectrodynamics.jl` see [docs](https://qedjl-project.github.io/QuantumElectrodynamics.jl/dev/). +This package's main purpose is to provide implementations of the basic interfaces defined in [`QEDbase.jl`](https://github.com/QEDjl-project/QEDbase.jl), such as various particle types, `PhasespaceDefinition`, `PhaseSpacePoint`, and various vector and matrix types. These types are used across most of the QEDjl-project repositories. For detailed information on these types, please refer to the respective pages in the [docs](https://qedjl-project.github.io/QEDcore.jl/dev/). + ## Contributing Contributions are welcome! If you'd like to report a bug, suggest an enhancement, or contribute From 3aabb68811d63adf4730de2a7edbecb8016e8c97 Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Wed, 9 Oct 2024 12:41:03 +0200 Subject: [PATCH 11/21] Remove currently non-functional build status badge --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 48ff7b9..fefdef9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://QEDjl-project.github.io/QEDcore.jl/stable/) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://QEDjl-project.github.io/QEDcore.jl/dev/) -[![Build Status](https://github.com/QEDjl-project/QEDcore.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/QEDjl-project/QEDcore.jl/actions/workflows/CI.yml?query=branch%3Amain) [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) This package is part of the `QuantumElectrodynamics.jl` library. For the description of the interoperability with other packages of `QuantumElectrodynamics.jl` see [docs](https://qedjl-project.github.io/QuantumElectrodynamics.jl/dev/). From 03849f7516f0129595af8f3790cdc9cc7e4179dc Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Wed, 9 Oct 2024 19:01:08 +0200 Subject: [PATCH 12/21] Add literals.jl page --- .gitignore | 3 +++ docs/Project.toml | 1 + docs/make.jl | 18 ++++++++++++++++ docs/src/library/index.md | 10 +++++++++ docs/src/library/outline.md | 11 +++------- docs/src/library/phasespacepoint.md | 5 +++++ docs/src/particles_manual.jl | 32 +++++++++++++++++++++++++++++ 7 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 docs/src/library/index.md create mode 100644 docs/src/particles_manual.jl diff --git a/.gitignore b/.gitignore index 493f309..ede1f09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ *Manifest.toml docs/build/ + +docs/src/particles_manual.ipynb +docs/src/particles_manual.md diff --git a/docs/Project.toml b/docs/Project.toml index 6edf6ee..59bb9aa 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,6 +1,7 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656" +Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" QEDbase = "10e22c08-3ccb-4172-bfcf-7d7aa3d04d93" QEDcore = "35dc0263-cb5f-4c33-a114-1d7f54ab753e" QEDprocesses = "46de9c38-1bb3-4547-a1ec-da24d767fdad" diff --git a/docs/make.jl b/docs/make.jl index 8702cc1..b3d244e 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -37,14 +37,31 @@ open(readme_path, "r") do readme_in end end +# setup examples using Literate.jl +using Literate + +literate_paths = [ + ( + Base.Filesystem.joinpath(project_path, "docs/src/particles_manual.jl"), + Base.Filesystem.joinpath(project_path, "docs/src/"), + ), +] + +for (file, output_dir) in literate_paths + Literate.markdown(file, output_dir; documenter=true) + Literate.notebook(file, output_dir) +end + pages = [ "Home" => "index.md", + "Particles and Phase Space Points" => "particles_manual.md", "API reference" => [ "Contents" => "library/outline.md", "Particles" => "library/particles.md", "Phase Space Definition" => "library/phasespacedef.md", "Phase Space Points" => "library/phasespacepoint.md", "Vector Types" => "library/vectors.md", + "Index" => "library/index.md", ], ] @@ -61,6 +78,7 @@ try assets=String[], ), pages=pages, + plugins=[links], ) finally @info "Garbage collection: remove landing page" diff --git a/docs/src/library/index.md b/docs/src/library/index.md new file mode 100644 index 0000000..44e7d82 --- /dev/null +++ b/docs/src/library/index.md @@ -0,0 +1,10 @@ +```@meta +CurrentModule = QEDcore +``` + +# QEDcore + +API index for [QEDcore](https://github.com/QEDjl-project/QEDcore.jl). + +```@index +``` diff --git a/docs/src/library/outline.md b/docs/src/library/outline.md index 44e7d82..bbffee8 100644 --- a/docs/src/library/outline.md +++ b/docs/src/library/outline.md @@ -1,10 +1,5 @@ -```@meta -CurrentModule = QEDcore -``` - -# QEDcore - -API index for [QEDcore](https://github.com/QEDjl-project/QEDcore.jl). +## API Outline -```@index +```@contents +Pages = ["particles.md", "phasespacedef.md", "phasespacepoint.md", "vectors.md"] ``` diff --git a/docs/src/library/phasespacepoint.md b/docs/src/library/phasespacepoint.md index 44565b7..08b35ca 100644 --- a/docs/src/library/phasespacepoint.md +++ b/docs/src/library/phasespacepoint.md @@ -4,11 +4,16 @@ CurrentModule = QEDcore ``` +## Types and Aliases ```@docs ParticleStateful PhaseSpacePoint InPhaseSpacePoint OutPhaseSpacePoint +``` + +## Accessors +```@docs getindex _momentum_type ``` diff --git a/docs/src/particles_manual.jl b/docs/src/particles_manual.jl new file mode 100644 index 0000000..bda35aa --- /dev/null +++ b/docs/src/particles_manual.jl @@ -0,0 +1,32 @@ +# # Particles and Phase Space Points + +# There are three layers of abstraction from particles to phase space points in the QEDjl project: +# - [`AbstractParticleType`](@extref QEDbase.AbstractParticleType): Base type for singleton particle type definitions. We also call these *species*. +# - [`AbstractParticleStateful`](@extref QEDbase.AbstractParticleStateful): Base type for particles with a direction and carrying a momentum. +# - [`AbstractPhaseSpacePoint`](@extref QEDbase.AbstractPhaseSpacePoint): Representation of a point in the phase space for a combination of an [`AbstractProcessDefinition`](@extref QEDbase.AbstractProcessDefinition), [`AbstractModelDefinition`](@extref QEDbase.AbstractModelDefinition), and [`AbstractPhasespaceDefinition`](@extref QEDbase.AbstractPhasespaceDefinition). + +# This manual is intended to showcase the basic usage of these types and their implementations in QEDcore. + +using QEDcore + +# To use concrete process definitions and models, we also need to use [`QEDprocesses.jl`](https://github.com/QEDjl-project/QEDprocesses.jl) + +using QEDprocesses + +# ## Particle Types + +# QEDcore currently defines the three basic particle types of QED [`Electron`](@ref), [`Positron`](@ref), and [`Photon`](@ref), and a type hierarchy for them: + +@assert Photon <: MajoranaBoson +@assert Electron <: Fermion +@assert Positron <: AntiFermion + +# There are also convenience functions in Julia convention: + +@assert is_boson(Photon()) +@assert is_particle(Electron()) +@assert is_anti_particle(Positron()) + +# These functions are part of QEDbase.jl's [particle interface](@extref QEDbase particles). + + From 8a266c0b770bbb4b4de0ddf2cc46e13ac5a4f1ab Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Fri, 11 Oct 2024 13:53:47 +0200 Subject: [PATCH 13/21] Remove ParticleSpinors from docs --- docs/src/library/vectors.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/src/library/vectors.md b/docs/src/library/vectors.md index 6c58fec..6072899 100644 --- a/docs/src/library/vectors.md +++ b/docs/src/library/vectors.md @@ -31,8 +31,3 @@ DiracMatrix ```@docs _mul ``` - -## Deprecated -```@docs -AbstractParticleSpinor -``` From b66332946581d25849b8b534f46308f5e44f90ee Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Fri, 11 Oct 2024 16:49:51 +0200 Subject: [PATCH 14/21] Finish particle documentation --- docs/Project.toml | 1 + docs/make.jl | 31 +++--- docs/src/particles_manual.jl | 32 ------ docs/src/tutorial/particles.jl | 172 +++++++++++++++++++++++++++++++++ 4 files changed, 191 insertions(+), 45 deletions(-) delete mode 100644 docs/src/particles_manual.jl create mode 100644 docs/src/tutorial/particles.jl diff --git a/docs/Project.toml b/docs/Project.toml index 59bb9aa..70df872 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,4 +1,5 @@ [deps] +BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656" Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" diff --git a/docs/make.jl b/docs/make.jl index b3d244e..a8ef9be 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -11,6 +11,7 @@ using QEDprocesses using Documenter using DocumenterInterLinks +using Literate # setup interlinks links = InterLinks( @@ -38,23 +39,18 @@ open(readme_path, "r") do readme_in end # setup examples using Literate.jl -using Literate +literate_paths = [Base.Filesystem.joinpath(project_path, "docs/src/tutorial/particles.jl")] -literate_paths = [ - ( - Base.Filesystem.joinpath(project_path, "docs/src/particles_manual.jl"), - Base.Filesystem.joinpath(project_path, "docs/src/"), - ), -] +tutorial_output_dir = joinpath(project_path, "docs/src/generated/") +!ispath(tutorial_output_dir) && mkdir(tutorial_output_dir) +@info "Literate: create temp dir at $tutorial_output_dir" -for (file, output_dir) in literate_paths - Literate.markdown(file, output_dir; documenter=true) - Literate.notebook(file, output_dir) -end +tutorial_output_dir_name = splitpath(tutorial_output_dir)[end] pages = [ "Home" => "index.md", - "Particles and Phase Space Points" => "particles_manual.md", + "Particles and Phase Space Points" => + joinpath(tutorial_output_dir_name, "particles.md"), "API reference" => [ "Contents" => "library/outline.md", "Particles" => "library/particles.md", @@ -66,6 +62,12 @@ pages = [ ] try + # generate markdown files with Literate.jl + for file in literate_paths + Literate.markdown(file, tutorial_output_dir; documenter=true) + end + # geneate docs with Documenter.jl + makedocs(; modules=[QEDcore], checkdocs=:exports, @@ -81,8 +83,11 @@ try plugins=[links], ) finally - @info "Garbage collection: remove landing page" + # doing some garbage collection + @info "GarbageCollection: remove generated landing page" rm(index_path) + @info "GarbageCollection: remove generated tutorial files" + rm(tutorial_output_dir; recursive=true) end deploydocs(; repo="github.com/QEDjl-project/QEDcore.jl", push_preview=false) diff --git a/docs/src/particles_manual.jl b/docs/src/particles_manual.jl deleted file mode 100644 index bda35aa..0000000 --- a/docs/src/particles_manual.jl +++ /dev/null @@ -1,32 +0,0 @@ -# # Particles and Phase Space Points - -# There are three layers of abstraction from particles to phase space points in the QEDjl project: -# - [`AbstractParticleType`](@extref QEDbase.AbstractParticleType): Base type for singleton particle type definitions. We also call these *species*. -# - [`AbstractParticleStateful`](@extref QEDbase.AbstractParticleStateful): Base type for particles with a direction and carrying a momentum. -# - [`AbstractPhaseSpacePoint`](@extref QEDbase.AbstractPhaseSpacePoint): Representation of a point in the phase space for a combination of an [`AbstractProcessDefinition`](@extref QEDbase.AbstractProcessDefinition), [`AbstractModelDefinition`](@extref QEDbase.AbstractModelDefinition), and [`AbstractPhasespaceDefinition`](@extref QEDbase.AbstractPhasespaceDefinition). - -# This manual is intended to showcase the basic usage of these types and their implementations in QEDcore. - -using QEDcore - -# To use concrete process definitions and models, we also need to use [`QEDprocesses.jl`](https://github.com/QEDjl-project/QEDprocesses.jl) - -using QEDprocesses - -# ## Particle Types - -# QEDcore currently defines the three basic particle types of QED [`Electron`](@ref), [`Positron`](@ref), and [`Photon`](@ref), and a type hierarchy for them: - -@assert Photon <: MajoranaBoson -@assert Electron <: Fermion -@assert Positron <: AntiFermion - -# There are also convenience functions in Julia convention: - -@assert is_boson(Photon()) -@assert is_particle(Electron()) -@assert is_anti_particle(Positron()) - -# These functions are part of QEDbase.jl's [particle interface](@extref QEDbase particles). - - diff --git a/docs/src/tutorial/particles.jl b/docs/src/tutorial/particles.jl new file mode 100644 index 0000000..ee55e96 --- /dev/null +++ b/docs/src/tutorial/particles.jl @@ -0,0 +1,172 @@ +# # Particles and Phase Space Points + +# There are three layers of abstraction from particles to phase space points in the QEDjl project: +# - [`AbstractParticleType`](@extref QEDbase.AbstractParticleType): Base type for singleton particle type definitions. We also call these *species*. +# - [`AbstractParticleStateful`](@extref QEDbase.AbstractParticleStateful): Base type for particles with a direction and carrying a momentum. +# - [`AbstractPhaseSpacePoint`](@extref QEDbase.AbstractPhaseSpacePoint): Representation of a point in the phase space for a combination of an [`AbstractProcessDefinition`](@extref QEDbase.AbstractProcessDefinition), [`AbstractModelDefinition`](@extref QEDbase.AbstractModelDefinition), and [`AbstractPhasespaceDefinition`](@extref QEDbase.AbstractPhasespaceDefinition). + +# This manual is intended to showcase the basic usage of these types and their implementations in QEDcore. + +using QEDcore + +# To use concrete process definitions and models, we also need to use [`QEDprocesses.jl`](https://github.com/QEDjl-project/QEDprocesses.jl) + +using QEDprocesses + +# ## Particle Types + +# QEDcore currently defines the three basic particle types of QED, [`Electron`](@ref), [`Positron`](@ref), and [`Photon`](@ref), and a type hierarchy for them: + +@assert Photon <: MajoranaBoson +@assert Electron <: Fermion +@assert Positron <: AntiFermion + +# All of these are subtypes of [`AbstractParticleType`](@extref QEDbase.AbstractParticleType). +# There are also convenience functions in Julia convention: + +@assert is_boson(Photon()) +@assert is_particle(Electron()) +@assert is_anti_particle(Positron()) + +@assert !is_boson(Electron()) +@assert !is_anti_particle(Electron()) +@assert !is_fermion(Photon()) + +# These functions are part of QEDbase.jl's (TODO: enable link once QEDbase docs are up)`[particle interface](@extref QEDbase particles)`. + +# ## ParticleStateful + +# [`ParticleStateful`](@ref) is the implementation of QEDbase's [`AbstractParticleStateful`](@extref QEDbase.AbstractParticleStateful) interface. It represents a particle with a [`direction`](@extref QEDbase.ParticleDirection) (as used in the context of scattering processes, [`Incoming`](@extref QEDbase.Incoming), [`Outgoing`](@extref QEDbase.Outgoing), or [`UnknownDirection`](@extref QEDbase.UnknownDirection)), a particle species ([`Electron`](@ref), [`Positron`](@ref), [`Photon`](@ref), ...), and a 4-momentum Vector. + +ps = ParticleStateful(Incoming(), Electron(), rand(SFourMomentum)) + +# The relevant accessor functions for the interface are implemented: + +particle_direction(ps) +# +particle_species(ps) +# +momentum(ps) +# + +# ## Phase Space Points + +# A [`PhaseSpacePoint`](@ref) is the combination of incoming and outgoing [`ParticleStateful`](@ref)s. It also contains information about the [scattering process](@extref QEDbase.AbstractProcessDefinition), [model](@extref QEDbase.AbstractModelDefinition), and [phase space](@extref QEDbase.AbstractPhasespaceDefinition) that it is created for. + +# ### Constructors + +psp = PhaseSpacePoint( + Compton(), # scattering process + PerturbativeQED(), # physics model + PhasespaceDefinition( # phase space definition + SphericalCoordinateSystem(),# coordinate system + ElectronRestFrame(), # frame of reference + ), + ( # momenta of the incoming particles + rand(SFourMomentum), + rand(SFourMomentum), + ), + ( # momenta of the outgoing particles + rand(SFourMomentum), + rand(SFourMomentum), + ), +) + +# This version of the constructor automatically creates [`ParticleStateful`](@ref) obejcts from the momenta, matching the particles of the process. In the case of [`Compton`](@extref QEDprocesses.Compton), this is means an incoming electron and photon, and outgoing electron and photon. + +# Automatic checks make sure that the number of 4-momenta given matches the necessary number of 4-momenta for the process (this adds 0 overhead at runtime because it is inferred from type information alone). + +try # hide + PhaseSpacePoint( + Compton(), + PerturbativeQED(), + PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame()), + (rand(SFourMomentum),), # incorrect number of incoming momenta, should be 2 + (rand(SFourMomentum), rand(SFourMomentum)), + ) +catch e # hide + @error e # hide +end # hide + +# Alternatively, a [`PhaseSpacePoint`](@ref) can also be constructed from already existing [`ParticleStateful`](@ref) objects. + +psp = PhaseSpacePoint( + Compton(), # scattering process + PerturbativeQED(), # physics model + PhasespaceDefinition( # phase space definition + SphericalCoordinateSystem(),# coordinate system + ElectronRestFrame(), # frame of reference + ), + ( # incoming particles + ParticleStateful(Incoming(), Electron(), rand(SFourMomentum)), + ParticleStateful(Incoming(), Photon(), rand(SFourMomentum)), + ), + ( # outgoing particles + ParticleStateful(Outgoing(), Electron(), rand(SFourMomentum)), + ParticleStateful(Outgoing(), Photon(), rand(SFourMomentum)), + ), +) + +# Similar to the constructor from momenta, this checks that the given [`ParticleStateful`](@ref)s fit to the given process and throws otherwise. Again, since this can be infered from type information alone, it adds no overhead. + +try # hide + PhaseSpacePoint( + Compton(), + PerturbativeQED(), + PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame()), + ( # incoming particles + ParticleStateful(Incoming(), Positron(), rand(SFourMomentum)), # incorrect particle type + ParticleStateful(Incoming(), Photon(), rand(SFourMomentum)), + ), + ( # outgoing particles + ParticleStateful(Outgoing(), Electron(), rand(SFourMomentum)), + ParticleStateful(Outgoing(), Photon(), rand(SFourMomentum)), + ), + ) +catch e # hide + @error e # hide +end # hide + +# !!! note +# While these constructors check that the given types make sense and work together, they do *not* check whether the given momenta make a physical phase space point or that the incoming or outgoing particles have on-shell 4-momenta. + +# ### Accessors + +# The phase space point provides some convenient accessors to the stateful particles within: + +psp[Incoming(), 1] # the first incoming particle +# +psp[Outgoing(), 2] # the second outgoing particle +# +particles(psp, Incoming()) # all incoming particles as a tuple + +# Momentum accessors: +momentum(psp, Incoming(), Electron(), 1) # the momentum of the first incoming electron + +# When only one particle of the species exists in the particle set, the 1 can be ommitted for convenience. + +@assert ans == momentum(psp, Incoming(), Electron()) + +# !!! note +# This method throws when multiple (or zero) particles of the given direction and species exist in the phase space point. + +# When the index of the required momentum is known at compile time, a `Val(N)` can be used instead of `N`. This performs bounds checks at compile time and removes loops from the runtime execution + +using BenchmarkTools +judge( + median(@benchmark momentum($psp, Incoming(), Photon(), Val(1))), + median(@benchmark momentum($psp, Incoming(), Photon(), 1)), +) + +# !!! note +# This is only faster when `N` is actually known at compile time, for example when it is a literal integer or a function's type parameter. For dynamic values of `N`, prefer the `Int` variant or in case of loops, directly loop over the tuple of [`momenta`](@extref QEDbase.momenta). + +# Some more overloads for the momentum function exist, for a complete list please refer to its documentation: [`momentum`](@extref QEDbase.momentum), [`momenta`](@extref QEDbase.momenta). + +# Finally, [`process`](@ref), [`model`](@ref), and [`phase_space_definition`](@ref) can be used to request the object in question: + +process(psp) +# +model(psp) +# +phase_space_definition(psp) From c0f0d5d566b6c517cda92d8e408b5f94777e07f2 Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Fri, 11 Oct 2024 14:49:31 +0200 Subject: [PATCH 15/21] Add place holders for vector and phasespacedefinition manuals --- docs/make.jl | 8 +++++++- docs/src/tutorial/ps_def.jl | 12 ++++++++++++ docs/src/tutorial/vectors.jl | 23 +++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 docs/src/tutorial/ps_def.jl create mode 100644 docs/src/tutorial/vectors.jl diff --git a/docs/make.jl b/docs/make.jl index a8ef9be..8daba6f 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -39,7 +39,11 @@ open(readme_path, "r") do readme_in end # setup examples using Literate.jl -literate_paths = [Base.Filesystem.joinpath(project_path, "docs/src/tutorial/particles.jl")] +literate_paths = [ + Base.Filesystem.joinpath(project_path, "docs/src/tutorial/ps_def.jl"), + Base.Filesystem.joinpath(project_path, "docs/src/tutorial/particles.jl"), + Base.Filesystem.joinpath(project_path, "docs/src/tutorial/vectors.jl"), +] tutorial_output_dir = joinpath(project_path, "docs/src/generated/") !ispath(tutorial_output_dir) && mkdir(tutorial_output_dir) @@ -49,8 +53,10 @@ tutorial_output_dir_name = splitpath(tutorial_output_dir)[end] pages = [ "Home" => "index.md", + "Phase Space Definitions" => joinpath(tutorial_output_dir_name, "ps_def.md"), "Particles and Phase Space Points" => joinpath(tutorial_output_dir_name, "particles.md"), + "Matrix and Vector Types" => joinpath(tutorial_output_dir_name, "vectors.md"), "API reference" => [ "Contents" => "library/outline.md", "Particles" => "library/particles.md", diff --git a/docs/src/tutorial/ps_def.jl b/docs/src/tutorial/ps_def.jl new file mode 100644 index 0000000..2c7bf33 --- /dev/null +++ b/docs/src/tutorial/ps_def.jl @@ -0,0 +1,12 @@ +# # Phase Space Definition + +# !!! note +# [`PhasespaceDefinition`](@ref)s are to be reworked (see this [issue](https://github.com/QEDjl-project/QEDcore.jl/issues/50)). Therefore, this manual is very rudimentary for the moment. +# + +# A [`PhasespaceDefinition`](@ref) is a representation of a phase space's layout. It is a singleton type definition and has an [`AbstractCoordinateSystem`](@extref QEDbase.AbstractCoordinateSystem) and an [`AbstractFrameOfReference`](@extref QEDbase.AbstractFrameOfReference). + +using QEDcore +ps_def = PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame()) + +# The phase space definition is used in [`PhaseSpacePoint`](@ref)s for dispatching in some of the cross-section interface functions. diff --git a/docs/src/tutorial/vectors.jl b/docs/src/tutorial/vectors.jl new file mode 100644 index 0000000..45ef282 --- /dev/null +++ b/docs/src/tutorial/vectors.jl @@ -0,0 +1,23 @@ +# # Vector and Matrix Types + +# **TBW** + +using QEDcore + +# ## Lorentz Vectors + +lv = rand(SLorentzVector) + +# ## Bispinors and Adjoint Bispinors + +bs = rand(BiSpinor) +# +abs = rand(AdjointBiSpinor) +# +abs * bs + +# ## Dirac and Gamma Matrices + +gm = rand(DiracMatrix) +# +abs * gm * bs From 98855bfafcfa8cb7d82f07948ad74cd06e0abcaf Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Mon, 14 Oct 2024 12:41:52 +0200 Subject: [PATCH 16/21] Add docs for In/Out PhaseSpacePoint & Review comment --- docs/src/tutorial/particles.jl | 70 +++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 6 deletions(-) diff --git a/docs/src/tutorial/particles.jl b/docs/src/tutorial/particles.jl index ee55e96..bf57087 100644 --- a/docs/src/tutorial/particles.jl +++ b/docs/src/tutorial/particles.jl @@ -1,12 +1,13 @@ # # Particles and Phase Space Points # There are three layers of abstraction from particles to phase space points in the QEDjl project: -# - [`AbstractParticleType`](@extref QEDbase.AbstractParticleType): Base type for singleton particle type definitions. We also call these *species*. -# - [`AbstractParticleStateful`](@extref QEDbase.AbstractParticleStateful): Base type for particles with a direction and carrying a momentum. -# - [`AbstractPhaseSpacePoint`](@extref QEDbase.AbstractPhaseSpacePoint): Representation of a point in the phase space for a combination of an [`AbstractProcessDefinition`](@extref QEDbase.AbstractProcessDefinition), [`AbstractModelDefinition`](@extref QEDbase.AbstractModelDefinition), and [`AbstractPhasespaceDefinition`](@extref QEDbase.AbstractPhasespaceDefinition). +# - [`QEDbase.AbstractParticleType`](@extref): Base type for singleton particle type definitions. We also call these *species*. +# - [`QEDbase.AbstractParticleStateful`](@extref): Base type for particles with a direction and carrying a momentum. +# - [`QEDbase.AbstractPhaseSpacePoint`](@extref): Representation of a point in the phase space for a combination of an [`QEDbase.AbstractProcessDefinition`](@extref), [`QEDbase.AbstractModelDefinition`](@extref), and [`QEDbase.AbstractPhasespaceDefinition`](@extref). # This manual is intended to showcase the basic usage of these types and their implementations in QEDcore. +struct UnexpectedSuccess <: Exception end # hide using QEDcore # To use concrete process definitions and models, we also need to use [`QEDprocesses.jl`](https://github.com/QEDjl-project/QEDprocesses.jl) @@ -21,7 +22,7 @@ using QEDprocesses @assert Electron <: Fermion @assert Positron <: AntiFermion -# All of these are subtypes of [`AbstractParticleType`](@extref QEDbase.AbstractParticleType). +# All of these are subtypes of [`QEDbase.AbstractParticleType`](@extref). # There are also convenience functions in Julia convention: @assert is_boson(Photon()) @@ -36,7 +37,7 @@ using QEDprocesses # ## ParticleStateful -# [`ParticleStateful`](@ref) is the implementation of QEDbase's [`AbstractParticleStateful`](@extref QEDbase.AbstractParticleStateful) interface. It represents a particle with a [`direction`](@extref QEDbase.ParticleDirection) (as used in the context of scattering processes, [`Incoming`](@extref QEDbase.Incoming), [`Outgoing`](@extref QEDbase.Outgoing), or [`UnknownDirection`](@extref QEDbase.UnknownDirection)), a particle species ([`Electron`](@ref), [`Positron`](@ref), [`Photon`](@ref), ...), and a 4-momentum Vector. +# [`ParticleStateful`](@ref) is the implementation of QEDbase's [`QEDbase.AbstractParticleStateful`](@extref) interface. It represents a particle with a [`direction`](@extref QEDbase.ParticleDirection) (as used in the context of scattering processes, [`QEDbase.Incoming`](@extref), [`QEDbase.Outgoing`](@extref), or [`QEDbase.UnknownDirection`](@extref)), a particle species ([`Electron`](@ref), [`Positron`](@ref), [`Photon`](@ref), ...), and a 4-momentum vector. ps = ParticleStateful(Incoming(), Electron(), rand(SFourMomentum)) @@ -84,7 +85,11 @@ try # hide (rand(SFourMomentum),), # incorrect number of incoming momenta, should be 2 (rand(SFourMomentum), rand(SFourMomentum)), ) + throw(UnexpectedSuccess()) # hide catch e # hide + if e isa UnexpectedSuccess # hide + rethrow(e) # hide + end # hide @error e # hide end # hide @@ -123,7 +128,11 @@ try # hide ParticleStateful(Outgoing(), Photon(), rand(SFourMomentum)), ), ) + throw(UnexpectedSuccess()) # hide catch e # hide + if e isa UnexpectedSuccess # hide + rethrow(e) # hide + end # hide @error e # hide end # hide @@ -161,7 +170,7 @@ judge( # !!! note # This is only faster when `N` is actually known at compile time, for example when it is a literal integer or a function's type parameter. For dynamic values of `N`, prefer the `Int` variant or in case of loops, directly loop over the tuple of [`momenta`](@extref QEDbase.momenta). -# Some more overloads for the momentum function exist, for a complete list please refer to its documentation: [`momentum`](@extref QEDbase.momentum), [`momenta`](@extref QEDbase.momenta). +# Some more overloads for the momentum function exist, for a complete list please refer to its documentation: [`QEDbase.momentum`](@extref), [`QEDbase.momenta`](@extref). # Finally, [`process`](@ref), [`model`](@ref), and [`phase_space_definition`](@ref) can be used to request the object in question: @@ -170,3 +179,52 @@ process(psp) model(psp) # phase_space_definition(psp) + +# ## In/Out Phase Space Points + +# As a special case, phase space points are allowed to only contain the incoming or outgoing particle momenta. +# These types can be helpful for overloading some functions that don't require the entire phase space point to exist. + +function in_sum(in_psp::AbstractInPhaseSpacePoint) + return sum(momenta(in_psp, Incoming())) +end + +psp = InPhaseSpacePoint( + Compton(), + PerturbativeQED(), + PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame()), + (rand(SFourMomentum), rand(SFourMomentum)), +) + +in_sum(psp) + +# Every full [`PhaseSpacePoint`](@ref) is both an [`InPhaseSpacePoint`](@ref) and an [`OutPhaseSpacePoint`](@ref), too. For example, the `in_sum` function defined above still works with a full [`PhaseSpacePoint`](@ref): + +psp = PhaseSpacePoint( + Compton(), + PerturbativeQED(), + PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame()), + (rand(SFourMomentum), rand(SFourMomentum)), + (rand(SFourMomentum), rand(SFourMomentum)), +) + +in_sum(psp) + +# But an [`InPhaseSpacePoint`](@ref) is not an [`OutPhaseSpacePoint`](@ref) and vice versa. We cannot call `in_sum` on an [`OutPhaseSpacePoint`](@ref): + +psp = OutPhaseSpacePoint( + Compton(), + PerturbativeQED(), + PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame()), + (rand(SFourMomentum), rand(SFourMomentum)), +) + +try # hide + in_sum(psp) + throw(UnexpectedSuccess()) # hide +catch e # hide + if e isa UnexpectedSuccess # hide + rethrow(e) # hide + end # hide + @error e # hide +end # hide From cf5f65d8112674b506a6a5e7d145303df740fd5f Mon Sep 17 00:00:00 2001 From: Anton Reinhard Date: Mon, 21 Oct 2024 16:06:27 +0200 Subject: [PATCH 17/21] Fix QEDbase extrefs and add lorentzboost docstrings to index --- docs/make.jl | 11 +++++++---- docs/src/library/lorentzboosts.md | 16 ++++++++++++++++ docs/src/tutorial/particles.jl | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 docs/src/library/lorentzboosts.md diff --git a/docs/make.jl b/docs/make.jl index 8daba6f..7d140cf 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -53,16 +53,19 @@ tutorial_output_dir_name = splitpath(tutorial_output_dir)[end] pages = [ "Home" => "index.md", - "Phase Space Definitions" => joinpath(tutorial_output_dir_name, "ps_def.md"), - "Particles and Phase Space Points" => - joinpath(tutorial_output_dir_name, "particles.md"), - "Matrix and Vector Types" => joinpath(tutorial_output_dir_name, "vectors.md"), + "Tutorials" => [ + "Phase Space Definitions" => joinpath(tutorial_output_dir_name, "ps_def.md"), + "Particles and Phase Space Points" => + joinpath(tutorial_output_dir_name, "particles.md"), + "Matrix and Vector Types" => joinpath(tutorial_output_dir_name, "vectors.md"), + ], "API reference" => [ "Contents" => "library/outline.md", "Particles" => "library/particles.md", "Phase Space Definition" => "library/phasespacedef.md", "Phase Space Points" => "library/phasespacepoint.md", "Vector Types" => "library/vectors.md", + "Lorentz Boosts" => "library/lorentzboosts.md", "Index" => "library/index.md", ], ] diff --git a/docs/src/library/lorentzboosts.md b/docs/src/library/lorentzboosts.md new file mode 100644 index 0000000..b148fb3 --- /dev/null +++ b/docs/src/library/lorentzboosts.md @@ -0,0 +1,16 @@ +# Lorentz Boosts + +The following is an implementation of the [Lorentz Boost Interface](@extref QEDbase Lorentz-Vector) of QEDbase.jl. + +```@meta +CurrentModule = QEDcore +``` + +```@docs +Boost +BetaVector +BetaX +BetaY +BetaZ +AbstractCoordinateTransformation +``` diff --git a/docs/src/tutorial/particles.jl b/docs/src/tutorial/particles.jl index bf57087..4a51a5e 100644 --- a/docs/src/tutorial/particles.jl +++ b/docs/src/tutorial/particles.jl @@ -33,7 +33,7 @@ using QEDprocesses @assert !is_anti_particle(Electron()) @assert !is_fermion(Photon()) -# These functions are part of QEDbase.jl's (TODO: enable link once QEDbase docs are up)`[particle interface](@extref QEDbase particles)`. +# These functions are part of QEDbase.jl's [particle interface](@extref QEDbase Particle-Interface). # ## ParticleStateful From ea741b3df2f7b0880baf535154421ae45d51a2ab Mon Sep 17 00:00:00 2001 From: Anton Reinhard Date: Wed, 23 Oct 2024 11:00:32 +0200 Subject: [PATCH 18/21] Remove base patch (#71) Merge after #69 This deletes the QEDbase patch which is no longer necessary as the relevant PR in QEDbase was merged. Unfortunately, there seems to be a somewhat strange interaction of doubly defined typenames and `@reexport`, creating an issue in QEDbase's documentation building. This means that I had to remove some `@extref` statements for now that can be readded later, when QEDbase is ready. --- .gitlab-ci.yml | 24 ++- docs/src/library/lorentzboosts.md | 1 - src/QEDcore.jl | 2 - .../boost_parameter/boost_axis/beta.jl | 6 +- .../boost_parameter/boost_axis/types.jl | 2 +- .../boost_parameter/boost_vector/beta.jl | 4 +- .../boost_parameter/boost_vector/types.jl | 6 +- src/lorentz_boost/types.jl | 13 +- src/patch_QEDbase.jl | 170 ------------------ 9 files changed, 32 insertions(+), 196 deletions(-) delete mode 100644 src/patch_QEDbase.jl diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7f64d6c..ad0de8e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,10 +4,18 @@ stages: - run_integration_test - verify-unit-test-deps -.untit_test_template: +.unit_test_template: stage: unit-test script: - apt update && apt install -y git + - git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /QEDjl + - > + if [[ $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_REF_NAME == "dev" ]]; then + # set name of the commit message from CI_COMMIT_MESSAGE to NO_MESSAGE, that the script does not read accidentally custom packages from the commit message of a merge commit + julia --project=. /QEDjl/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml NO_MESSAGE + else + julia --project=. /QEDjl/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml + fi - julia --project=. -e 'import Pkg; Pkg.instantiate()' - julia --project=. -e 'import Pkg; Pkg.test(; coverage = true)' interruptible: true @@ -15,35 +23,35 @@ stages: - cpuonly unit_tests_releases: - extends: .untit_test_template + extends: .unit_test_template parallel: matrix: - JULIA_VERSION: ["1.10", "1.11", "rc"] image: julia:$JULIA_VERSION unit_tests_nightly: - extends: .untit_test_template + extends: .unit_test_template # use the same baseimage like the official julia images image: debian:bookworm-slim variables: # path where julia tar bal should be downloaded - JULIA_DONWLOAD: /julia/download + JULIA_DOWNLOAD: /julia/download # path where julia should be extracted JULIA_EXTRACT: /julia/extract before_script: - apt update && apt install -y wget - - mkdir -p $JULIA_DONWLOAD + - mkdir -p $JULIA_DOWNLOAD - mkdir -p $JULIA_EXTRACT - > if [[ $CI_RUNNER_EXECUTABLE_ARCH == "linux/arm64" ]]; then - wget https://julialangnightlies-s3.julialang.org/bin/linux/aarch64/julia-latest-linux-aarch64.tar.gz -O $JULIA_DONWLOAD/julia-nightly.tar.gz + wget https://julialangnightlies-s3.julialang.org/bin/linux/aarch64/julia-latest-linux-aarch64.tar.gz -O $JULIA_DOWNLOAD/julia-nightly.tar.gz elif [[ $CI_RUNNER_EXECUTABLE_ARCH == "linux/amd64" ]]; then - wget https://julialangnightlies-s3.julialang.org/bin/linux/x86_64/julia-latest-linux-x86_64.tar.gz -O $JULIA_DONWLOAD/julia-nightly.tar.gz + wget https://julialangnightlies-s3.julialang.org/bin/linux/x86_64/julia-latest-linux-x86_64.tar.gz -O $JULIA_DOWNLOAD/julia-nightly.tar.gz else echo "unknown runner architecture -> $CI_RUNNER_EXECUTABLE_ARCH" exit 1 fi - - tar -xf $JULIA_DONWLOAD/julia-nightly.tar.gz -C $JULIA_EXTRACT + - tar -xf $JULIA_DOWNLOAD/julia-nightly.tar.gz -C $JULIA_EXTRACT # we need to search for the julia base folder name, because the second part of the name is the git commit hash # e.g. julia-b0c6781676f - JULIA_EXTRACT_FOLDER=${JULIA_EXTRACT}/$(ls $JULIA_EXTRACT | grep -m1 julia) diff --git a/docs/src/library/lorentzboosts.md b/docs/src/library/lorentzboosts.md index b148fb3..d467e12 100644 --- a/docs/src/library/lorentzboosts.md +++ b/docs/src/library/lorentzboosts.md @@ -12,5 +12,4 @@ BetaVector BetaX BetaY BetaZ -AbstractCoordinateTransformation ``` diff --git a/src/QEDcore.jl b/src/QEDcore.jl index c73e9fd..56a1d3b 100644 --- a/src/QEDcore.jl +++ b/src/QEDcore.jl @@ -38,8 +38,6 @@ using SimpleTraits @reexport using QEDbase -include("patch_QEDbase.jl") - include("algebraic_objects/dirac_tensors/types.jl") include("algebraic_objects/dirac_tensors/multiplication.jl") diff --git a/src/lorentz_boost/boost_parameter/boost_axis/beta.jl b/src/lorentz_boost/boost_parameter/boost_axis/beta.jl index b798000..b9f51e2 100644 --- a/src/lorentz_boost/boost_parameter/boost_axis/beta.jl +++ b/src/lorentz_boost/boost_parameter/boost_axis/beta.jl @@ -105,7 +105,7 @@ end BetaX(beta::T) where {T<:Real} = BetaX{T}(beta) -function _transform(boost_param::BetaX, p::M) where {M<:AbstractFourMomentum} +function QEDbase._transform(boost_param::BetaX, p::M) where {M<:AbstractFourMomentum} en = getE(p) px = getX(p) @@ -187,7 +187,7 @@ end BetaY(beta::T) where {T} = BetaY{T}(beta) -function _transform(boost_param::BetaY, p::M) where {M<:AbstractFourMomentum} +function QEDbase._transform(boost_param::BetaY, p::M) where {M<:AbstractFourMomentum} en = getE(p) py = getY(p) @@ -269,7 +269,7 @@ struct BetaZ{T<:Real} <: AbstractAxisBeta{T} end BetaZ(beta::T) where {T} = BetaZ{T}(beta) -function _transform(boost_param::BetaZ, p::M) where {M<:AbstractFourMomentum} +function QEDbase._transform(boost_param::BetaZ, p::M) where {M<:AbstractFourMomentum} en = getE(p) pz = getZ(p) diff --git a/src/lorentz_boost/boost_parameter/boost_axis/types.jl b/src/lorentz_boost/boost_parameter/boost_axis/types.jl index 577d0e6..2b33417 100644 --- a/src/lorentz_boost/boost_parameter/boost_axis/types.jl +++ b/src/lorentz_boost/boost_parameter/boost_axis/types.jl @@ -12,7 +12,7 @@ Subtypes of `AbstractAxisBoostParameter{T}` are used to define specific boost tr This abstract type is meant to be extended by concrete types to represent boosts along different Cartesian axes. """ -abstract type AbstractAxisBoostParameter{T} <: AbstractBoostParameter end +abstract type AbstractAxisBoostParameter{T} <: QEDbase.AbstractBoostParameter end function (::Type{BP})(boost_val::Real) where {T<:Real,BP<:AbstractAxisBoostParameter{T}} return BP(T(boost_val)) diff --git a/src/lorentz_boost/boost_parameter/boost_vector/beta.jl b/src/lorentz_boost/boost_parameter/boost_vector/beta.jl index 93b5d99..8d966f9 100644 --- a/src/lorentz_boost/boost_parameter/boost_vector/beta.jl +++ b/src/lorentz_boost/boost_parameter/boost_vector/beta.jl @@ -96,7 +96,9 @@ function _three_vector_square(beta_vec::BetaVector) return bx^2 + by^2 + bz^2 end -@inline function _transform(beta_vec::BetaVector, p::M) where {M<:AbstractFourMomentum} +@inline function QEDbase._transform( + beta_vec::BetaVector, p::M +) where {M<:AbstractFourMomentum} b2 = _three_vector_square(beta_vec) if b2 == one(b2) return p diff --git a/src/lorentz_boost/boost_parameter/boost_vector/types.jl b/src/lorentz_boost/boost_parameter/boost_vector/types.jl index 184f406..2546f1a 100644 --- a/src/lorentz_boost/boost_parameter/boost_vector/types.jl +++ b/src/lorentz_boost/boost_parameter/boost_vector/types.jl @@ -1,10 +1,10 @@ """ - AbstractBoostVector <: AbstractBoostParameter + AbstractBoostVector <: QEDbase.AbstractBoostParameter An abstract base type representing vector-like boost parameters, used to model Lorentz boosts in any spatial dimension. -`AbstractBoostVector` extends [`AbstractBoostParameter`](@ref) and provides the framework for +`AbstractBoostVector` extends `QEDbase.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 @@ -21,4 +21,4 @@ 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 +abstract type AbstractBoostVector <: QEDbase.AbstractBoostParameter end diff --git a/src/lorentz_boost/types.jl b/src/lorentz_boost/types.jl index 70a83f1..1b8b505 100644 --- a/src/lorentz_boost/types.jl +++ b/src/lorentz_boost/types.jl @@ -1,11 +1,10 @@ """ - - Boost{V<:AbstractBoostParameter} <: AbstractLorentzBoost + Boost{V<:QEDbase.AbstractBoostParameter} <: QEDbase.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`](@ref) used. The `Boost` type is used to perform +on the subtype of `QEDbase.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. @@ -69,13 +68,13 @@ four-vector will not change the invariant quantity. ## See Also -* [`AbstractBoostParameter`](@ref): Base type for specific kinds of boost parameters. +* `QEDbase.AbstractBoostParameter`: 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. """ -struct Boost{T<:AbstractBoostParameter} <: AbstractLorentzBoost +struct Boost{T<:QEDbase.AbstractBoostParameter} <: QEDbase.AbstractLorentzBoost param::T end boost_type(::Boost{T}) where {T} = T @@ -85,8 +84,8 @@ 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)) -function _transform(boost::Boost, p::AbstractFourMomentum) - return _transform(boost.param, p) +function QEDbase._transform(boost::Boost, p::AbstractFourMomentum) + return QEDbase._transform(boost.param, p) end function Base.inv(boost::Boost) diff --git a/src/patch_QEDbase.jl b/src/patch_QEDbase.jl deleted file mode 100644 index f88fc7c..0000000 --- a/src/patch_QEDbase.jl +++ /dev/null @@ -1,170 +0,0 @@ -# This can be removed, if https://github.com/QEDjl-project/QEDbase.jl/pull/129 is merged -# and released. - -####### -# General coordinate transformations -####### - -""" - AbstractCoordinateTransformation - -Abstract base type for coordinate transformations supposed to be acting on four-momenta. -Every subtype of `trafo::AbstractCoordinateTransformation` should implement the following interface functions: - -* `QEDcore._transform(trafo,p)`: transforms `p` -* `Base.inv(trafo)`: returns the inverted transform - -## Example - -Implementing the interface by defining the interface functions: - -```jldoctest trafo_interface -julia> using 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 From 16b1951a3fe594f10d01921db6fd88ff5646fafb Mon Sep 17 00:00:00 2001 From: Anton Reinhard Date: Thu, 24 Oct 2024 11:09:47 +0200 Subject: [PATCH 19/21] Apply same changes as QEDbase for new CI (#75) Compare https://github.com/QEDjl-project/QEDbase.jl/pull/125 --- .github/workflows/BuildDeployDoc.yml | 19 +++++++++++-------- .gitlab-ci.yml | 18 +++++++++++++----- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/BuildDeployDoc.yml b/.github/workflows/BuildDeployDoc.yml index 5c0550a..f177603 100644 --- a/.github/workflows/BuildDeployDoc.yml +++ b/.github/workflows/BuildDeployDoc.yml @@ -18,16 +18,19 @@ jobs: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v1 with: - version: "1.10" - - name: Install dependencies + version: '1.10' + - name: clone integration test tools run: | - julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' - - name: set dependencies to dev branch version - if: (github.event_name == 'push' && github.ref_name != 'main') || (github.event_name == 'pull_request' && github.base_ref != 'main') + git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /tmp/integration_test_tools/ + - name: set dev dependencies run: | - git clone -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /tmp/integration_test_tools - julia --project=docs/ /tmp/integration_test_tools/.ci/set_dev_dependencies.jl + $(julia --project=. /tmp/integration_test_tools/.ci/integTestGen/src/get_project_name_version_path.jl) + echo "CI_DEV_PKG_NAME -> $CI_DEV_PKG_NAME" + echo "CI_DEV_PKG_VERSION -> $CI_DEV_PKG_VERSION" + echo "CI_DEV_PKG_PATH -> $CI_DEV_PKG_PATH" + julia --project=docs/ /tmp/integration_test_tools/.ci/SetupDevEnv/src/SetupDevEnv.jl + julia --project=docs/ -e 'import Pkg; Pkg.instantiate()' - name: Build and deploy env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: julia --project=docs/ docs/make.jl diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad0de8e..5ef5381 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,13 +8,17 @@ stages: stage: unit-test script: - apt update && apt install -y git - - git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /QEDjl + - git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /tmp/integration_test_tools/ + - $(julia --project=. /tmp/integration_test_tools/.ci/integTestGen/src/get_project_name_version_path.jl) + - echo "CI_DEV_PKG_NAME -> $CI_DEV_PKG_NAME" + - echo "CI_DEV_PKG_VERSION -> $CI_DEV_PKG_VERSION" + - echo "CI_DEV_PKG_PATH -> $CI_DEV_PKG_PATH" - > if [[ $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_REF_NAME == "dev" ]]; then # set name of the commit message from CI_COMMIT_MESSAGE to NO_MESSAGE, that the script does not read accidentally custom packages from the commit message of a merge commit - julia --project=. /QEDjl/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml NO_MESSAGE + julia --project=. /tmp/integration_test_tools/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml NO_MESSAGE else - julia --project=. /QEDjl/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml + julia --project=. /tmp/integration_test_tools/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml fi - julia --project=. -e 'import Pkg; Pkg.instantiate()' - julia --project=. -e 'import Pkg; Pkg.test(; coverage = true)' @@ -62,15 +66,19 @@ unit_tests_nightly: tags: - cpuonly +generate_integration_tests: + image: julia:1.10 generate_integration_tests: image: julia:1.10 stage: generate_integration_test script: # extract package name - - export CI_DEPENDENCY_NAME=$(cat $CI_PROJECT_DIR/Project.toml | grep name | awk '{ print $3 }' | tr -d '"') - - echo "CI_DEPENDENCY_NAME -> $CI_DEPENDENCY_NAME" - apt update && apt install -y git - git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /QEDjl + - $(julia --project /QEDjl/.ci/integTestGen/src/get_project_name_version_path.jl) + - echo "CI_DEV_PKG_NAME -> $CI_DEV_PKG_NAME" + - echo "CI_DEV_PKG_VERSION -> $CI_DEV_PKG_VERSION" + - echo "CI_DEV_PKG_PATH -> $CI_DEV_PKG_PATH" - cd /QEDjl/.ci/integTestGen/ - julia --project=. -e 'import Pkg; Pkg.instantiate()' # paths of artifacts are relative to CI_PROJECT_DIR From 6621d2d6fe2c5441074471ea6a4b68951d437cd4 Mon Sep 17 00:00:00 2001 From: Simeon Ehrig Date: Mon, 28 Oct 2024 19:21:16 +0100 Subject: [PATCH 20/21] Set QEDbase compat version to 0.3.0 (#77) --- .gitlab-ci.yml | 2 -- Project.toml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5ef5381..2aefd42 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,8 +66,6 @@ unit_tests_nightly: tags: - cpuonly -generate_integration_tests: - image: julia:1.10 generate_integration_tests: image: julia:1.10 stage: generate_integration_test diff --git a/Project.toml b/Project.toml index 4c3c684..b3bc515 100644 --- a/Project.toml +++ b/Project.toml @@ -12,7 +12,7 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [compat] DocStringExtensions = "^0.9" -QEDbase = "0.2.2" +QEDbase = "0.3.0" Reexport = "^1.2" SimpleTraits = "^0.9" StaticArrays = "^1.9" From dcc9b2bb2dc67818114b824cf9ff1d6800790136 Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Mon, 28 Oct 2024 19:38:31 +0100 Subject: [PATCH 21/21] Adjust Project.toml --- Project.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index b3bc515..8a1f1d4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "QEDcore" uuid = "35dc0263-cb5f-4c33-a114-1d7f54ab753e" authors = ["Uwe Hernandez Acosta ", "Anton Reinhard"] -version = "0.1.1" +version = "0.2.0" [deps] DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" @@ -11,11 +11,11 @@ SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [compat] -DocStringExtensions = "^0.9" +DocStringExtensions = "0.9" QEDbase = "0.3.0" -Reexport = "^1.2" -SimpleTraits = "^0.9" -StaticArrays = "^1.9" +Reexport = "1.2" +SimpleTraits = "0.9" +StaticArrays = "1.9" julia = "1.10" [extras]