Skip to content

Commit

Permalink
Revoke namespace changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonReinhard committed Jun 25, 2024
1 parent ed086bd commit 34e0400
Show file tree
Hide file tree
Showing 29 changed files with 458 additions and 708 deletions.
4 changes: 2 additions & 2 deletions src/QEDcore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export SphericalCoordinateSystem
export CenterOfMomentumFrame, ElectronRestFrame
export PhasespaceDefinition
export ParticleStateful, PhaseSpacePoint, InPhaseSpacePoint, OutPhaseSpacePoint
export spin, polarization, particle_direction, particle_species, momentum, momenta, getindex
export spin, polarization, momenta, getindex

using QEDbase: QEDbase
using QEDbase
using DocStringExtensions
using StaticArrays
using SimpleTraits
Expand Down
6 changes: 3 additions & 3 deletions src/algebraic_objects/dirac_tensors/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $(TYPEDEF)
Concrete type to model a Dirac four-spinor with complex-valued components. These are the elements of an actual spinor space.
"""
struct BiSpinor <: QEDbase.AbstractDiracVector{ComplexF64}
struct BiSpinor <: AbstractDiracVector{ComplexF64}
el1::ComplexF64
el2::ComplexF64
el3::ComplexF64
Expand All @@ -20,7 +20,7 @@ $(TYPEDEF)
Concrete type to model an adjoint Dirac four-spinor with complex-valued components. These are the elements of the dual spinor space.
"""
struct AdjointBiSpinor <: QEDbase.AbstractDiracVector{ComplexF64}
struct AdjointBiSpinor <: AbstractDiracVector{ComplexF64}
el1::ComplexF64
el2::ComplexF64
el3::ComplexF64
Expand All @@ -36,7 +36,7 @@ $(TYPEDEF)
Concrete type to model Dirac matrices, i.e. matrix representations of linear mappings between two spinor spaces.
"""
struct DiracMatrix <: QEDbase.AbstractDiracMatrix{ComplexF64}
struct DiracMatrix <: AbstractDiracMatrix{ComplexF64}
el11::ComplexF64
el12::ComplexF64
el13::ComplexF64
Expand Down
30 changes: 20 additions & 10 deletions src/algebraic_objects/four_momentum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@
#
#######

import QEDbase: getT, getX, getY, getZ, setT!, setX!, setY!, setZ!
import QEDbase:
getT,
getX,
getY,
getZ,
setT!,
setX!,
setY!,
setZ!,
IsLorentzVectorLike,
IsMutableLorentzVectorLike
import StaticArrays: similar_type

"""
Expand All @@ -15,7 +25,7 @@ Builds a static LorentzVectorLike with real components used to statically model
# Fields
$(TYPEDFIELDS)
"""
struct SFourMomentum <: QEDbase.AbstractFourMomentum
struct SFourMomentum <: AbstractFourMomentum
"energy component"
E::Float64

Expand Down Expand Up @@ -54,7 +64,7 @@ end

# TODO: this breaks incremental compilation because it's trying to eval permanent changes in a different module
#register_LorentzVectorLike(SFourMomentum)
@traitimpl QEDbase.IsLorentzVectorLike{SFourMomentum}
@traitimpl IsLorentzVectorLike{SFourMomentum}

#######
#
Expand All @@ -69,7 +79,7 @@ Builds a mutable LorentzVector with real components used to statically model the
# Fields
$(TYPEDFIELDS)
"""
mutable struct MFourMomentum <: QEDbase.AbstractFourMomentum
mutable struct MFourMomentum <: AbstractFourMomentum
"energy component"
E::Float64

Expand Down Expand Up @@ -106,23 +116,23 @@ end
@inline getY(p::MFourMomentum) = p.py
@inline getZ(p::MFourMomentum) = p.pz

function QEDbase.setT!(lv::MFourMomentum, value::Float64)
function setT!(lv::MFourMomentum, value::Float64)
return lv.E = value
end

function QEDbase.setX!(lv::MFourMomentum, value::Float64)
function setX!(lv::MFourMomentum, value::Float64)
return lv.px = value
end

function QEDbase.setY!(lv::MFourMomentum, value::Float64)
function setY!(lv::MFourMomentum, value::Float64)
return lv.py = value
end

function QEDbase.setZ!(lv::MFourMomentum, value::Float64)
function setZ!(lv::MFourMomentum, value::Float64)
return lv.pz = value
end

# TODO: this breaks incremental compilation because it's trying to eval permanent changes in a different module
# register_LorentzVectorLike(MFourMomentum)
@traitimpl QEDbase.IsLorentzVectorLike{MFourMomentum}
@traitimpl QEDbase.IsMutableLorentzVectorLike{MFourMomentum}
@traitimpl IsLorentzVectorLike{MFourMomentum}
@traitimpl IsMutableLorentzVectorLike{MFourMomentum}
8 changes: 4 additions & 4 deletions src/algebraic_objects/gamma_matrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
# the definition below looks *transposed*.
####

function gamma(::Type{T})::SLorentzVector where {T<:QEDbase.AbstractGammaRepresentation}
function gamma(::Type{T})::SLorentzVector where {T<:AbstractGammaRepresentation}
return SLorentzVector(_gamma0(T), _gamma1(T), _gamma2(T), _gamma3(T))
end

struct DiracGammaRepresentation <: QEDbase.AbstractGammaRepresentation end
struct DiracGammaRepresentation <: AbstractGammaRepresentation end

#! format: off
function _gamma0(::Type{DiracGammaRepresentation})::DiracMatrix
Expand Down Expand Up @@ -52,10 +52,10 @@ const GAMMA = gamma()

function slashed(
::Type{TG}, LV::TV
) where {TG<:QEDbase.AbstractGammaRepresentation,TV<:QEDbase.AbstractLorentzVector}
) where {TG<:AbstractGammaRepresentation,TV<:AbstractLorentzVector}
return gamma(TG) * LV
end

function slashed(LV::T) where {T<:QEDbase.AbstractLorentzVector}
function slashed(LV::T) where {T<:AbstractLorentzVector}
return GAMMA * LV
end
10 changes: 5 additions & 5 deletions src/algebraic_objects/lorentz_vector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Concrete implementation of a generic static Lorentz vector. Each manipulation of
# Fields
$(TYPEDFIELDS)
"""
struct SLorentzVector{T} <: QEDbase.AbstractLorentzVector{T}
struct SLorentzVector{T} <: AbstractLorentzVector{T}
"`t` component"
t::T

Expand All @@ -46,7 +46,7 @@ end

# TODO: this breaks incremental compilation because it's trying to eval permanent changes in a different module
#register_LorentzVectorLike(SLorentzVector)
@traitimpl QEDbase.IsLorentzVectorLike{SLorentzVector}
@traitimpl IsLorentzVectorLike{SLorentzVector}

"""
$(TYPEDEF)
Expand All @@ -56,7 +56,7 @@ Concrete implementation of a generic mutable Lorentz vector. Each manipulation o
# Fields
$(TYPEDFIELDS)
"""
mutable struct MLorentzVector{T} <: QEDbase.AbstractLorentzVector{T}
mutable struct MLorentzVector{T} <: AbstractLorentzVector{T}
"`t` component"
t::T

Expand Down Expand Up @@ -98,5 +98,5 @@ end

# TODO: this breaks incremental compilation because it's trying to eval permanent changes in a different module
#register_LorentzVectorLike(MLorentzVector)
@traitimpl QEDbase.IsLorentzVectorLike{MLorentzVector}
@traitimpl QEDbase.IsMutableLorentzVectorLike{MLorentzVector}
@traitimpl IsLorentzVectorLike{MLorentzVector}
@traitimpl IsMutableLorentzVectorLike{MLorentzVector}
4 changes: 2 additions & 2 deletions src/particles/particle_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Abstract base types for particle species that act like fermions in the sense of
!!! note "particle interface"
Every concrete subtype of [`FermionLike`](@ref) has `is_fermion(::FermionLike) = true`.
"""
abstract type FermionLike <: QEDbase.AbstractParticleType end
abstract type FermionLike <: AbstractParticleType end

is_fermion(::FermionLike) = true

Expand Down Expand Up @@ -129,7 +129,7 @@ Abstract base types for particle species that act like bosons in the sense of pa
!!! note "particle interface"
Every concrete subtype of `BosonLike` has `is_boson(::BosonLike) = true`.
"""
abstract type BosonLike <: QEDbase.AbstractParticleType end
abstract type BosonLike <: AbstractParticleType end

is_boson(::BosonLike) = true

Expand Down
18 changes: 9 additions & 9 deletions src/particles/propagators.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import QEDbase: propagator

function _scalar_propagator(K::QEDbase.AbstractFourMomentum, mass::Real)
function _scalar_propagator(K::AbstractFourMomentum, mass::Real)
return one(mass) / (K * K - mass^2)
end

function _scalar_propagator(K::QEDbase.AbstractFourMomentum)
function _scalar_propagator(K::AbstractFourMomentum)
return one(getT(K)) / (K * K)
end

function _fermion_propagator(P::QEDbase.AbstractFourMomentum, mass::Real)
function _fermion_propagator(P::AbstractFourMomentum, mass::Real)
return (slashed(P) + mass * one(DiracMatrix)) * _scalar_propagator(P, mass)
end

function _fermion_propagator(P::QEDbase.AbstractFourMomentum)
function _fermion_propagator(P::AbstractFourMomentum)
return (slashed(P)) * _scalar_propagator(P)
end

function QEDbase.propagator(particle_type::BosonLike, K::QEDbase.AbstractFourMomentum)
return _scalar_propagator(K, QEDbase.mass(particle_type))
function propagator(particle_type::BosonLike, K::AbstractFourMomentum)
return _scalar_propagator(K, mass(particle_type))
end

function QEDbase.propagator(particle_type::Photon, K::QEDbase.AbstractFourMomentum)
function propagator(particle_type::Photon, K::AbstractFourMomentum)
return _scalar_propagator(K)
end

function QEDbase.propagator(particle_type::FermionLike, P::QEDbase.AbstractFourMomentum)
return _fermion_propagator(P, QEDbase.mass(particle_type))
function propagator(particle_type::FermionLike, P::AbstractFourMomentum)
return _fermion_propagator(P, mass(particle_type))
end
18 changes: 9 additions & 9 deletions src/particles/spinors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ const BASE_ANTIPARTICLE_SPINOR = [

@inline function _check_spinor_input(
mom::T, mass::Float64
) where {T<:QEDbase.AbstractLorentzVector{TE}} where {TE<:Real}
if SPINOR_VALIDITY_CHECK[] && !QEDbase.isonshell(mom, mass)
) where {T<:AbstractLorentzVector{TE}} where {TE<:Real}
if SPINOR_VALIDITY_CHECK[] && !isonshell(mom, mass)
throw(
SpinorConstructionError(
"P^2 = $(QEDbase.getMass2(mom)) needs to be equal to mass^2=$(mass^2)"
"P^2 = $(getMass2(mom)) needs to be equal to mass^2=$(mass^2)"
),
)
end
Expand All @@ -38,7 +38,7 @@ end

function _build_particle_booster(
mom::T, mass::Float64
) where {T<:QEDbase.AbstractLorentzVector{TE}} where {TE<:Real}
) where {T<:AbstractLorentzVector{TE}} where {TE<:Real}
_check_spinor_input(mom, mass)
return (slashed(mom) + mass * one(DiracMatrix)) / (sqrt(abs(mom.t) + mass))
end
Expand All @@ -49,7 +49,7 @@ end

function IncomingFermionSpinor(
mom::T, mass::Float64
) where {T<:QEDbase.AbstractLorentzVector{TE}} where {TE<:Real}
) where {T<:AbstractLorentzVector{TE}} where {TE<:Real}
return IncomingFermionSpinor(_build_particle_booster(mom, mass))
end

Expand All @@ -65,7 +65,7 @@ end

function OutgoingFermionSpinor(
mom::T, mass::Float64
) where {T<:QEDbase.AbstractLorentzVector{TE}} where {TE<:Real}
) where {T<:AbstractLorentzVector{TE}} where {TE<:Real}
return OutgoingFermionSpinor(_build_particle_booster(mom, mass))
end

Expand All @@ -81,7 +81,7 @@ const SpinorUbar = OutgoingFermionSpinor

function _build_antiparticle_booster(
mom::T, mass::Float64
) where {T<:QEDbase.AbstractLorentzVector{TE}} where {TE<:Real}
) where {T<:AbstractLorentzVector{TE}} where {TE<:Real}
_check_spinor_input(mom, mass)
return (mass * one(DiracMatrix) - slashed(mom)) / (sqrt(abs(mom.t) + mass))
end
Expand All @@ -92,7 +92,7 @@ end

function OutgoingAntiFermionSpinor(
mom::T, mass::Float64
) where {T<:QEDbase.AbstractLorentzVector{TE}} where {TE<:Real}
) where {T<:AbstractLorentzVector{TE}} where {TE<:Real}
return OutgoingAntiFermionSpinor(_build_antiparticle_booster(mom, mass))
end

Expand All @@ -108,7 +108,7 @@ end

function IncomingAntiFermionSpinor(
mom::T, mass::Float64
) where {T<:QEDbase.AbstractLorentzVector{TE}} where {TE<:Real}
) where {T<:AbstractLorentzVector{TE}} where {TE<:Real}
return IncomingAntiFermionSpinor(_build_antiparticle_booster(mom, mass))
end

Expand Down
Loading

0 comments on commit 34e0400

Please sign in to comment.