Skip to content

Commit

Permalink
Revoke namespace change (#29)
Browse files Browse the repository at this point in the history
This PR revokes the namespace changes done before QEDbase.jl 0.2 was
released.

Currently based on #25,
I will rebase once that is merged.
  • Loading branch information
szabo137 authored Jun 27, 2024
2 parents cc4895d + cbe1f62 commit 56f2444
Show file tree
Hide file tree
Showing 31 changed files with 499 additions and 777 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
1 change: 1 addition & 0 deletions src/algebraic_objects/dirac_tensors/multiplication.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
#######

# Base.*(...) = ... is not possible directly so we have to import here
import Base: *

"""
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
39 changes: 22 additions & 17 deletions src/algebraic_objects/four_momentum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#
#######

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

"""
$(TYPEDEF)
Expand All @@ -15,7 +12,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 All @@ -40,17 +37,21 @@ function SFourMomentum(t::T, x::T, y::T, z::T) where {T<:Union{Integer,Rational,
return SFourMomentum(float(t), x, y, z)
end

function similar_type(::Type{A}, ::Type{T}, ::Size{S}) where {A<:SFourMomentum,T<:Real,S}
function StaticArrays.similar_type(
::Type{A}, ::Type{T}, ::Size{S}
) where {A<:SFourMomentum,T<:Real,S}
return SFourMomentum
end
function similar_type(::Type{A}, ::Type{T}, ::Size{S}) where {A<:SFourMomentum,T,S}
function StaticArrays.similar_type(
::Type{A}, ::Type{T}, ::Size{S}
) where {A<:SFourMomentum,T,S}
return SLorentzVector{T}
end

@inline getT(p::SFourMomentum) = p.E
@inline getX(p::SFourMomentum) = p.px
@inline getY(p::SFourMomentum) = p.py
@inline getZ(p::SFourMomentum) = p.pz
@inline QEDbase.getT(p::SFourMomentum) = p.E
@inline QEDbase.getX(p::SFourMomentum) = p.px
@inline QEDbase.getY(p::SFourMomentum) = p.py
@inline QEDbase.getZ(p::SFourMomentum) = p.pz

# TODO: this breaks incremental compilation because it's trying to eval permanent changes in a different module
#register_LorentzVectorLike(SFourMomentum)
Expand All @@ -69,7 +70,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 All @@ -94,17 +95,21 @@ function MFourMomentum(t::T, x::T, y::T, z::T) where {T<:Union{Integer,Rational,
return MFourMomentum(float(t), x, y, z)
end

function similar_type(::Type{A}, ::Type{T}, ::Size{S}) where {A<:MFourMomentum,T<:Real,S}
function StaticArrays.similar_type(
::Type{A}, ::Type{T}, ::Size{S}
) where {A<:MFourMomentum,T<:Real,S}
return MFourMomentum
end
function similar_type(::Type{A}, ::Type{T}, ::Size{S}) where {A<:MFourMomentum,T,S}
function StaticArrays.similar_type(
::Type{A}, ::Type{T}, ::Size{S}
) where {A<:MFourMomentum,T,S}
return MLorentzVector{T}
end

@inline getT(p::MFourMomentum) = p.E
@inline getX(p::MFourMomentum) = p.px
@inline getY(p::MFourMomentum) = p.py
@inline getZ(p::MFourMomentum) = p.pz
@inline QEDbase.getT(p::MFourMomentum) = p.E
@inline QEDbase.getX(p::MFourMomentum) = p.px
@inline QEDbase.getY(p::MFourMomentum) = p.py
@inline QEDbase.getZ(p::MFourMomentum) = p.pz

function QEDbase.setT!(lv::MFourMomentum, value::Float64)
return lv.E = value
Expand Down
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
39 changes: 20 additions & 19 deletions src/algebraic_objects/lorentz_vector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#
#######

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

#######
#
# Concrete LorentzVector types
Expand All @@ -20,7 +17,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 @@ -35,14 +32,16 @@ struct SLorentzVector{T} <: QEDbase.AbstractLorentzVector{T}
end
SLorentzVector(t, x, y, z) = SLorentzVector(promote(t, x, y, z)...)

function similar_type(::Type{A}, ::Type{T}, ::Size{S}) where {A<:SLorentzVector,T,S}
function StaticArrays.similar_type(
::Type{A}, ::Type{T}, ::Size{S}
) where {A<:SLorentzVector,T,S}
return SLorentzVector{T}
end

@inline getT(lv::SLorentzVector) = lv.t
@inline getX(lv::SLorentzVector) = lv.x
@inline getY(lv::SLorentzVector) = lv.y
@inline getZ(lv::SLorentzVector) = lv.z
@inline QEDbase.getT(lv::SLorentzVector) = lv.t
@inline QEDbase.getX(lv::SLorentzVector) = lv.x
@inline QEDbase.getY(lv::SLorentzVector) = lv.y
@inline QEDbase.getZ(lv::SLorentzVector) = lv.z

# TODO: this breaks incremental compilation because it's trying to eval permanent changes in a different module
#register_LorentzVectorLike(SLorentzVector)
Expand All @@ -56,7 +55,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 All @@ -71,28 +70,30 @@ mutable struct MLorentzVector{T} <: QEDbase.AbstractLorentzVector{T}
end
MLorentzVector(t, x, y, z) = MLorentzVector(promote(t, x, y, z)...)

function similar_type(::Type{A}, ::Type{T}, ::Size{S}) where {A<:MLorentzVector,T,S}
function StaticArrays.similar_type(
::Type{A}, ::Type{T}, ::Size{S}
) where {A<:MLorentzVector,T,S}
return MLorentzVector{T}
end

@inline getT(lv::MLorentzVector) = lv.t
@inline getX(lv::MLorentzVector) = lv.x
@inline getY(lv::MLorentzVector) = lv.y
@inline getZ(lv::MLorentzVector) = lv.z
@inline QEDbase.getT(lv::MLorentzVector) = lv.t
@inline QEDbase.getX(lv::MLorentzVector) = lv.x
@inline QEDbase.getY(lv::MLorentzVector) = lv.y
@inline QEDbase.getZ(lv::MLorentzVector) = lv.z

function setT!(lv::MLorentzVector, value::T) where {T}
function QEDbase.setT!(lv::MLorentzVector, value::T) where {T}
return lv.t = value
end

function setX!(lv::MLorentzVector, value::T) where {T}
function QEDbase.setX!(lv::MLorentzVector, value::T) where {T}
return lv.x = value
end

function setY!(lv::MLorentzVector, value::T) where {T}
function QEDbase.setY!(lv::MLorentzVector, value::T) where {T}
return lv.y = value
end

function setZ!(lv::MLorentzVector, value::T) where {T}
function QEDbase.setZ!(lv::MLorentzVector, value::T) where {T}
return lv.z = value
end

Expand Down
46 changes: 22 additions & 24 deletions src/particles/particle_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# implement the abstact particle interface accordingly.
###############

import QEDbase: is_particle, is_anti_particle, is_boson, is_fermion, mass, charge

"""
AbstractParticleSpinor
Expand All @@ -20,9 +18,9 @@ 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
QEDbase.is_fermion(::FermionLike) = true

"""
Abstract base type for fermions as distinct from [`AntiFermion`](@ref)s.
Expand All @@ -38,9 +36,9 @@ Abstract base type for fermions as distinct from [`AntiFermion`](@ref)s.
"""
abstract type Fermion <: FermionLike end

is_particle(::Fermion) = true
QEDbase.is_particle(::Fermion) = true

is_anti_particle(::Fermion) = false
QEDbase.is_anti_particle(::Fermion) = false

"""
Abstract base type for anti-fermions as distinct from its particle counterpart `Fermion`.
Expand All @@ -55,9 +53,9 @@ Abstract base type for anti-fermions as distinct from its particle counterpart `
"""
abstract type AntiFermion <: FermionLike end

is_particle(::AntiFermion) = false
QEDbase.is_particle(::AntiFermion) = false

is_anti_particle(::AntiFermion) = true
QEDbase.is_anti_particle(::AntiFermion) = true

"""
Abstract base type for majorana-fermions, i.e. fermions which are their own anti-particles.
Expand All @@ -73,9 +71,9 @@ Abstract base type for majorana-fermions, i.e. fermions which are their own anti
"""
abstract type MajoranaFermion <: FermionLike end

is_particle(::MajoranaFermion) = true
QEDbase.is_particle(::MajoranaFermion) = true

is_anti_particle(::MajoranaFermion) = true
QEDbase.is_anti_particle(::MajoranaFermion) = true

"""
Concrete type for *electrons* as a particle species. Mostly used for dispatch.
Expand All @@ -96,8 +94,8 @@ electron
```
"""
struct Electron <: Fermion end
mass(::Electron) = 1.0
charge(::Electron) = -1.0
QEDbase.mass(::Electron) = 1.0
QEDbase.charge(::Electron) = -1.0
Base.show(io::IO, ::Electron) = print(io, "electron")

"""
Expand All @@ -119,8 +117,8 @@ positron
```
"""
struct Positron <: AntiFermion end
mass(::Positron) = 1.0
charge(::Positron) = 1.0
QEDbase.mass(::Positron) = 1.0
QEDbase.charge(::Positron) = 1.0
Base.show(io::IO, ::Positron) = print(io, "positron")

"""
Expand All @@ -129,9 +127,9 @@ 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
QEDbase.is_boson(::BosonLike) = true

"""
Abstract base type for bosons as distinct from its anti-particle counterpart [`AntiBoson`](@ref).
Expand All @@ -145,8 +143,8 @@ Abstract base type for bosons as distinct from its anti-particle counterpart [`A
```
"""
abstract type Boson <: BosonLike end
is_particle(::Boson) = true
is_anti_particle(::Boson) = false
QEDbase.is_particle(::Boson) = true
QEDbase.is_anti_particle(::Boson) = false

"""
Abstract base type for anti-bosons as distinct from its particle counterpart [`Boson`](@ref).
Expand All @@ -160,8 +158,8 @@ Abstract base type for anti-bosons as distinct from its particle counterpart [`B
```
"""
abstract type AntiBoson <: BosonLike end
is_particle(::AntiBoson) = false
is_anti_particle(::AntiBoson) = true
QEDbase.is_particle(::AntiBoson) = false
QEDbase.is_anti_particle(::AntiBoson) = true

"""
Abstract base type for majorana-bosons, i.e. bosons which are their own anti-particles.
Expand All @@ -175,8 +173,8 @@ Abstract base type for majorana-bosons, i.e. bosons which are their own anti-par
```
"""
abstract type MajoranaBoson <: BosonLike end
is_particle(::MajoranaBoson) = true
is_anti_particle(::MajoranaBoson) = true
QEDbase.is_particle(::MajoranaBoson) = true
QEDbase.is_anti_particle(::MajoranaBoson) = true

"""
Concrete type for the *photons* as a particle species. Mostly used for dispatch.
Expand All @@ -197,6 +195,6 @@ photon
```
"""
struct Photon <: MajoranaBoson end
mass(::Photon) = 0.0
charge(::Photon) = 0.0
QEDbase.mass(::Photon) = 0.0
QEDbase.charge(::Photon) = 0.0
Base.show(io::IO, ::Photon) = print(io, "photon")
Loading

0 comments on commit 56f2444

Please sign in to comment.