Skip to content

Commit

Permalink
Fix namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonReinhard committed Jun 20, 2024
1 parent 32b9733 commit 8cb6ecd
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 40 deletions.
6 changes: 3 additions & 3 deletions src/particles/particle_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ is_anti_particle(::MajoranaFermion) = true
Concrete type for *electrons* as a particle species. Mostly used for dispatch.
```jldoctest
julia> using QEDbase
julia> using QEDcore
julia> Electron()
electron
Expand All @@ -104,7 +104,7 @@ Base.show(io::IO, ::Electron) = print(io, "electron")
Concrete type for *positrons* as a particle species. Mostly used for dispatch.
```jldoctest
julia> using QEDbase
julia> using QEDcore
julia> Positron()
positron
Expand Down Expand Up @@ -182,7 +182,7 @@ is_anti_particle(::MajoranaBoson) = true
Concrete type for the *photons* as a particle species. Mostly used for dispatch.
```jldoctest
julia> using QEDbase
julia> using QEDcore
julia> Photon()
photon
Expand Down
10 changes: 3 additions & 7 deletions src/particles/propagators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@ function _fermion_propagator(P::QEDbase.AbstractFourMomentum)
return (slashed(P)) * _scalar_propagator(P)
end

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

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

function QEDbase.propagator(
particle_type::QEDbase.FermionLike, P::QEDbase.AbstractFourMomentum
)
function QEDbase.propagator(particle_type::FermionLike, P::QEDbase.AbstractFourMomentum)
return _fermion_propagator(P, QEDbase.mass(particle_type))
end
14 changes: 7 additions & 7 deletions src/phase_spaces/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ end
Representation of a particle with a state. It has four fields:
- `dir::QEDbase.ParticleDirection`: The direction of the particle, `QEDbase.Incoming()` or `QEDbase.Outgoing()`.
- `species::QEDbase.AbstractParticleType`: The species of the particle, `QEDbase.Electron()`, `QEDbase.Positron()` etc.
- `species::QEDbase.AbstractParticleType`: The species of the particle, `Electron()`, `Positron()` etc.
- `mom::QEDbase.AbstractFourMomentum`: The momentum of the particle.
Overloads for [`is_fermion`](@ref), [`is_boson`](@ref), [`is_particle`](@ref), [`is_anti_particle`](@ref), [`is_incoming`](@ref), [`is_outgoing`](@ref), [`mass`](@ref), and [`charge`](@ref) are provided, delegating the call to the correct field and thus implementing the [`QEDbase.AbstractParticle`](@ref) interface.
```jldoctest
julia> import QEDbase; using QEDprocesses
julia> ParticleStateful(QEDbase.Incoming(), QEDbase.Electron(), SFourMomentum(1, 0, 0, 0))
julia> ParticleStateful(QEDbase.Incoming(), Electron(), SFourMomentum(1, 0, 0, 0))
ParticleStateful: incoming electron
momentum: [1.0, 0.0, 0.0, 0.0]
julia> ParticleStateful(QEDbase.Outgoing(), QEDbase.Photon(), SFourMomentum(1, 0, 0, 0))
julia> ParticleStateful(QEDbase.Outgoing(), Photon(), SFourMomentum(1, 0, 0, 0))
ParticleStateful: outgoing photon
momentum: [1.0, 0.0, 0.0, 0.0]
```
Expand Down Expand Up @@ -72,12 +72,12 @@ julia> PhaseSpacePoint(
PerturbativeQED(),
PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame()),
(
ParticleStateful(QEDbase.Incoming(), QEDbase.Electron(), SFourMomentum(1, 0, 0, 0)),
ParticleStateful(QEDbase.Incoming(), QEDbase.Photon(), SFourMomentum(1, 0, 0, 0))
ParticleStateful(QEDbase.Incoming(), Electron(), SFourMomentum(1, 0, 0, 0)),
ParticleStateful(QEDbase.Incoming(), Photon(), SFourMomentum(1, 0, 0, 0))
),
(
ParticleStateful(QEDbase.Outgoing(), QEDbase.Electron(), SFourMomentum(1, 0, 0, 0)),
ParticleStateful(QEDbase.Outgoing(), QEDbase.Photon(), SFourMomentum(1, 0, 0, 0))
ParticleStateful(QEDbase.Outgoing(), Electron(), SFourMomentum(1, 0, 0, 0)),
ParticleStateful(QEDbase.Outgoing(), Photon(), SFourMomentum(1, 0, 0, 0))
)
)
PhaseSpacePoint:
Expand Down
10 changes: 7 additions & 3 deletions src/phase_spaces/utility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ end
::Tuple{Vararg{QEDbase.AbstractParticleType,M}},
dir::QEDbase.ParticleDirection,
) where {N,M}
throw(InvalidInputError("expected $(M) $(dir) particles for the process but got $(N)"))
throw(
QEDbase.InvalidInputError(
"expected $(M) $(dir) particles for the process but got $(N)"
),
)
return nothing
end

Expand All @@ -39,7 +43,7 @@ end
SPECIES_T<:QEDbase.AbstractParticleType,
}
throw(
InvalidInputError(
QEDbase.InvalidInputError(
"expected $(dir) $(SPECIES_T()) but got $(DIR_IN_T()) $(SPECIES_IN_T())"
),
)
Expand Down Expand Up @@ -132,7 +136,7 @@ function _build_particle_statefuls(
dir::QEDbase.ParticleDirection,
) where {N,ELEMENT<:QEDbase.AbstractFourMomentum}
N == QEDbase.number_particles(proc, dir) || throw(
InvalidInputError(
QEDbase.InvalidInputError(
"expected $(QEDbase.number_particles(proc, dir)) $(dir) particles for the process but got $(N)",
),
)
Expand Down
32 changes: 15 additions & 17 deletions test/phase_spaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end

@testset "Stateful Particle" begin
DIRECTIONS = [QEDbase.Incoming(), QEDbase.Outgoing()]
SPECIES = [QEDbase.Electron(), QEDbase.Positron()] #=, Muon(), AntiMuon(), Tauon(), AntiTauon()=#
SPECIES = [Electron(), Positron()] #=, Muon(), AntiMuon(), Tauon(), AntiTauon()=#

for (species, dir) in Iterators.product(SPECIES, DIRECTIONS)
mom = rand(RNG, SFourMomentum)
Expand Down Expand Up @@ -62,10 +62,10 @@ end
out_el_mom = rand(RNG, SFourMomentum)
out_ph_mom = rand(RNG, SFourMomentum)

in_el = ParticleStateful(QEDbase.Incoming(), QEDbase.Electron(), in_el_mom)
in_ph = ParticleStateful(QEDbase.Incoming(), QEDbase.Photon(), in_ph_mom)
out_el = ParticleStateful(QEDbase.Outgoing(), QEDbase.Electron(), out_el_mom)
out_ph = ParticleStateful(QEDbase.Outgoing(), QEDbase.Photon(), out_ph_mom)
in_el = ParticleStateful(QEDbase.Incoming(), Electron(), in_el_mom)
in_ph = ParticleStateful(QEDbase.Incoming(), Photon(), in_ph_mom)
out_el = ParticleStateful(QEDbase.Outgoing(), Electron(), out_el_mom)
out_ph = ParticleStateful(QEDbase.Outgoing(), Photon(), out_ph_mom)

in_particles_valid = (in_el, in_ph)
in_particles_invalid = (in_el, out_ph)
Expand All @@ -74,9 +74,7 @@ end
out_particles_invalid = (out_el, in_ph)

model = TESTMODEL
process = TestImplementation.TestProcess(
(QEDbase.Electron(), QEDbase.Photon()), (QEDbase.Electron(), QEDbase.Photon())
)
process = TestImplementation.TestProcess((Electron(), Photon()), (Electron(), Photon()))
phasespace_def = TESTPSDEF

psp = PhaseSpacePoint(
Expand Down Expand Up @@ -151,19 +149,19 @@ end
@test_throws BoundsError psp[QEDbase.Incoming(), 4]
@test_throws BoundsError psp[QEDbase.Outgoing(), 4]

@test_throws InvalidInputError PhaseSpacePoint(
@test_throws QEDbase.InvalidInputError PhaseSpacePoint(
process, model, phasespace_def, in_particles_invalid, out_particles_valid
)

@test_throws InvalidInputError PhaseSpacePoint(
@test_throws QEDbase.InvalidInputError PhaseSpacePoint(
process, model, phasespace_def, in_particles_valid, out_particles_invalid
)

@test_throws InvalidInputError PhaseSpacePoint(
@test_throws QEDbase.InvalidInputError PhaseSpacePoint(
process, model, phasespace_def, (in_ph, in_el), out_particles_valid
)

@test_throws InvalidInputError PhaseSpacePoint(
@test_throws QEDbase.InvalidInputError PhaseSpacePoint(
process, model, phasespace_def, in_particles_valid, (out_ph, out_el)
)
end
Expand All @@ -185,7 +183,7 @@ end

@testset "Error handling from momenta" for (i, o) in
Iterators.product([1, 3, 4, 5], [1, 3, 4, 5])
@test_throws InvalidInputError PhaseSpacePoint(
@test_throws QEDbase.InvalidInputError PhaseSpacePoint(
process,
model,
phasespace_def,
Expand Down Expand Up @@ -218,18 +216,18 @@ end
@test out_psp_from_moms isa OutPhaseSpacePoint
@test !(out_psp_from_moms isa InPhaseSpacePoint)

@test_throws InvalidInputError InPhaseSpacePoint(
@test_throws QEDbase.InvalidInputError InPhaseSpacePoint(
process, model, phasespace_def, in_particles_invalid
)
@test_throws InvalidInputError OutPhaseSpacePoint(
@test_throws QEDbase.InvalidInputError OutPhaseSpacePoint(
process, model, phasespace_def, out_particles_invalid
)

@testset "Error handling from momenta" for i in [1, 3, 4, 5]
@test_throws InvalidInputError InPhaseSpacePoint(
@test_throws QEDbase.InvalidInputError InPhaseSpacePoint(
process, model, phasespace_def, TestImplementation._rand_momenta(RNG, i)
)
@test_throws InvalidInputError OutPhaseSpacePoint(
@test_throws QEDbase.InvalidInputError OutPhaseSpacePoint(
process, model, phasespace_def, TestImplementation._rand_momenta(RNG, i)
)
end
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ begin
end

@time @safetestset "particle base states" begin
include("particles/base_states.jl")
include("particles/states.jl")
end

@time @safetestset "particle propagators" begin
Expand Down
4 changes: 2 additions & 2 deletions test/test_implementation/test_process.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dummy particles
struct TestParticleFermion <: QEDbase.FermionLike end
struct TestParticleBoson <: QEDbase.BosonLike end
struct TestParticleFermion <: FermionLike end
struct TestParticleBoson <: BosonLike end

const PARTICLE_SET = [TestParticleFermion(), TestParticleBoson()]

Expand Down

0 comments on commit 8cb6ecd

Please sign in to comment.