diff --git a/src/QEDcore.jl b/src/QEDcore.jl index 352b5c8..8776223 100644 --- a/src/QEDcore.jl +++ b/src/QEDcore.jl @@ -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 diff --git a/src/algebraic_objects/dirac_tensors/types.jl b/src/algebraic_objects/dirac_tensors/types.jl index a7b5e03..bd21d03 100644 --- a/src/algebraic_objects/dirac_tensors/types.jl +++ b/src/algebraic_objects/dirac_tensors/types.jl @@ -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 @@ -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 @@ -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 diff --git a/src/algebraic_objects/four_momentum.jl b/src/algebraic_objects/four_momentum.jl index f39ddfe..ad86be5 100644 --- a/src/algebraic_objects/four_momentum.jl +++ b/src/algebraic_objects/four_momentum.jl @@ -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 """ @@ -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 @@ -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} ####### # @@ -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 @@ -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} diff --git a/src/algebraic_objects/gamma_matrices.jl b/src/algebraic_objects/gamma_matrices.jl index 8daa2d6..ea91485 100644 --- a/src/algebraic_objects/gamma_matrices.jl +++ b/src/algebraic_objects/gamma_matrices.jl @@ -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 @@ -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 diff --git a/src/algebraic_objects/lorentz_vector.jl b/src/algebraic_objects/lorentz_vector.jl index f83b422..3658cf5 100644 --- a/src/algebraic_objects/lorentz_vector.jl +++ b/src/algebraic_objects/lorentz_vector.jl @@ -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 @@ -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) @@ -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 @@ -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} diff --git a/src/particles/particle_types.jl b/src/particles/particle_types.jl index be51684..8bdeb78 100644 --- a/src/particles/particle_types.jl +++ b/src/particles/particle_types.jl @@ -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 @@ -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 diff --git a/src/particles/propagators.jl b/src/particles/propagators.jl index 1b69de5..8e58a99 100644 --- a/src/particles/propagators.jl +++ b/src/particles/propagators.jl @@ -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 diff --git a/src/particles/spinors.jl b/src/particles/spinors.jl index 93124e7..0764b22 100644 --- a/src/particles/spinors.jl +++ b/src/particles/spinors.jl @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/particles/states.jl b/src/particles/states.jl index 54affde..d656e67 100644 --- a/src/particles/states.jl +++ b/src/particles/states.jl @@ -1,50 +1,36 @@ import QEDbase: base_state -function _booster_fermion(mom::QEDbase.AbstractFourMomentum, mass::Real) - return (slashed(mom) + mass * one(DiracMatrix)) / (sqrt(abs(QEDbase.getT(mom)) + mass)) +function _booster_fermion(mom::AbstractFourMomentum, mass::Real) + return (slashed(mom) + mass * one(DiracMatrix)) / (sqrt(abs(getT(mom)) + mass)) end -function _booster_antifermion(mom::QEDbase.AbstractFourMomentum, mass::Real) - return (mass * one(DiracMatrix) - slashed(mom)) / (sqrt(abs(QEDbase.getT(mom)) + mass)) +function _booster_antifermion(mom::AbstractFourMomentum, mass::Real) + return (mass * one(DiracMatrix) - slashed(mom)) / (sqrt(abs(getT(mom)) + mass)) end function base_state( - particle::Fermion, - ::QEDbase.Incoming, - mom::QEDbase.AbstractFourMomentum, - spin::QEDbase.AbstractDefiniteSpin, + particle::Fermion, ::Incoming, mom::AbstractFourMomentum, spin::AbstractDefiniteSpin ) - booster = _booster_fermion(mom, QEDbase.mass(particle)) + booster = _booster_fermion(mom, mass(particle)) return BiSpinor(booster[:, QEDbase._spin_index(spin)]) end -function base_state( - particle::Fermion, - ::QEDbase.Incoming, - mom::QEDbase.AbstractFourMomentum, - spin::QEDbase.AllSpin, -) - booster = _booster_fermion(mom, QEDbase.mass(particle)) +function base_state(particle::Fermion, ::Incoming, mom::AbstractFourMomentum, spin::AllSpin) + booster = _booster_fermion(mom, mass(particle)) return SVector(BiSpinor(booster[:, 1]), BiSpinor(booster[:, 2])) end function base_state( - particle::AntiFermion, - ::QEDbase.Incoming, - mom::QEDbase.AbstractFourMomentum, - spin::QEDbase.AbstractDefiniteSpin, + particle::AntiFermion, ::Incoming, mom::AbstractFourMomentum, spin::AbstractDefiniteSpin ) - booster = _booster_antifermion(mom, QEDbase.mass(particle)) + booster = _booster_antifermion(mom, mass(particle)) return AdjointBiSpinor(BiSpinor(booster[:, QEDbase._spin_index(spin) + 2])) * GAMMA[1] end function base_state( - particle::AntiFermion, - ::QEDbase.Incoming, - mom::QEDbase.AbstractFourMomentum, - spin::QEDbase.AllSpin, + particle::AntiFermion, ::Incoming, mom::AbstractFourMomentum, spin::AllSpin ) - booster = _booster_antifermion(mom, QEDbase.mass(particle)) + booster = _booster_antifermion(mom, mass(particle)) return SVector( AdjointBiSpinor(BiSpinor(booster[:, 3])) * GAMMA[1], AdjointBiSpinor(BiSpinor(booster[:, 4])) * GAMMA[1], @@ -52,22 +38,14 @@ function base_state( end function base_state( - particle::Fermion, - ::QEDbase.Outgoing, - mom::QEDbase.AbstractFourMomentum, - spin::QEDbase.AbstractDefiniteSpin, + particle::Fermion, ::Outgoing, mom::AbstractFourMomentum, spin::AbstractDefiniteSpin ) - booster = _booster_fermion(mom, QEDbase.mass(particle)) + booster = _booster_fermion(mom, mass(particle)) return AdjointBiSpinor(BiSpinor(booster[:, QEDbase._spin_index(spin)])) * GAMMA[1] end -function base_state( - particle::Fermion, - ::QEDbase.Outgoing, - mom::QEDbase.AbstractFourMomentum, - spin::QEDbase.AllSpin, -) - booster = _booster_fermion(mom, QEDbase.mass(particle)) +function base_state(particle::Fermion, ::Outgoing, mom::AbstractFourMomentum, spin::AllSpin) + booster = _booster_fermion(mom, mass(particle)) return SVector( AdjointBiSpinor(BiSpinor(booster[:, 1])) * GAMMA[1], AdjointBiSpinor(BiSpinor(booster[:, 2])) * GAMMA[1], @@ -75,64 +53,55 @@ function base_state( end function base_state( - particle::AntiFermion, - ::QEDbase.Outgoing, - mom::QEDbase.AbstractFourMomentum, - spin::QEDbase.AbstractDefiniteSpin, + particle::AntiFermion, ::Outgoing, mom::AbstractFourMomentum, spin::AbstractDefiniteSpin ) - booster = _booster_antifermion(mom, QEDbase.mass(particle)) + booster = _booster_antifermion(mom, mass(particle)) return BiSpinor(booster[:, QEDbase._spin_index(spin) + 2]) end function base_state( - particle::AntiFermion, - ::QEDbase.Outgoing, - mom::QEDbase.AbstractFourMomentum, - spin::QEDbase.AllSpin, + particle::AntiFermion, ::Outgoing, mom::AbstractFourMomentum, spin::AllSpin ) - booster = _booster_antifermion(mom, QEDbase.mass(particle)) + booster = _booster_antifermion(mom, mass(particle)) return SVector(BiSpinor(booster[:, 3]), BiSpinor(booster[:, 4])) end -function _photon_state(pol::QEDbase.AllPolarization, mom::QEDbase.AbstractFourMomentum) - cth = QEDbase.getCosTheta(mom) +function _photon_state(pol::AllPolarization, mom::AbstractFourMomentum) + cth = getCosTheta(mom) sth = sqrt(1 - cth^2) - cos_phi = QEDbase.getCosPhi(mom) - sin_phi = QEDbase.getSinPhi(mom) + cos_phi = getCosPhi(mom) + sin_phi = getSinPhi(mom) return SVector( SLorentzVector{Float64}(0.0, cth * cos_phi, cth * sin_phi, -sth), SLorentzVector{Float64}(0.0, -sin_phi, cos_phi, 0.0), ) end -function _photon_state(pol::QEDbase.PolarizationX, mom::QEDbase.AbstractFourMomentum) - cth = QEDbase.getCosTheta(mom) +function _photon_state(pol::PolarizationX, mom::AbstractFourMomentum) + cth = getCosTheta(mom) sth = sqrt(1 - cth^2) - cos_phi = QEDbase.getCosPhi(mom) - sin_phi = QEDbase.getSinPhi(mom) + cos_phi = getCosPhi(mom) + sin_phi = getSinPhi(mom) return SLorentzVector{Float64}(0.0, cth * cos_phi, cth * sin_phi, -sth) end -function _photon_state(pol::QEDbase.PolarizationY, mom::QEDbase.AbstractFourMomentum) - cos_phi = QEDbase.getCosPhi(mom) - sin_phi = QEDbase.getSinPhi(mom) +function _photon_state(pol::PolarizationY, mom::AbstractFourMomentum) + cos_phi = getCosPhi(mom) + sin_phi = getSinPhi(mom) return SLorentzVector{Float64}(0.0, -sin_phi, cos_phi, 0.0) end @inline function base_state( - particle::Photon, - ::QEDbase.ParticleDirection, - mom::QEDbase.AbstractFourMomentum, - pol::QEDbase.AllPolarization, + particle::Photon, ::ParticleDirection, mom::AbstractFourMomentum, pol::AllPolarization ) return _photon_state(pol, mom) end @inline function base_state( particle::Photon, - ::QEDbase.ParticleDirection, - mom::QEDbase.AbstractFourMomentum, - pol::QEDbase.AbstractPolarization, + ::ParticleDirection, + mom::AbstractFourMomentum, + pol::AbstractPolarization, ) return _photon_state(pol, mom) end diff --git a/src/phase_spaces/access.jl b/src/phase_spaces/access.jl index cc51c66..3b7769a 100644 --- a/src/phase_spaces/access.jl +++ b/src/phase_spaces/access.jl @@ -1,7 +1,16 @@ +import QEDbase: + particle_direction, + particle_species, + momentum, + process, + model, + phase_space_definition, + particles + # accessor interface particle stateful -QEDbase.particle_direction(part::ParticleStateful) = part.dir -QEDbase.particle_species(part::ParticleStateful) = part.species -QEDbase.momentum(part::ParticleStateful) = part.mom +particle_direction(part::ParticleStateful) = part.dir +particle_species(part::ParticleStateful) = part.species +momentum(part::ParticleStateful) = part.mom # accessor interface phase space point """ @@ -9,7 +18,7 @@ QEDbase.momentum(part::ParticleStateful) = part.mom Overload for the array indexing operator `[]`. Returns the nth incoming particle in this phase space point. """ -function Base.getindex(psp::PhaseSpacePoint, ::QEDbase.Incoming, n::Int) +function Base.getindex(psp::PhaseSpacePoint, ::Incoming, n::Int) return psp.in_particles[n] end @@ -18,13 +27,13 @@ end Overload for the array indexing operator `[]`. Returns the nth outgoing particle in this phase space point. """ -function Base.getindex(psp::PhaseSpacePoint, ::QEDbase.Outgoing, n::Int) +function Base.getindex(psp::PhaseSpacePoint, ::Outgoing, n::Int) return psp.out_particles[n] end -QEDbase.process(psp::PhaseSpacePoint) = psp.proc -QEDbase.model(psp::PhaseSpacePoint) = psp.model -QEDbase.phase_space_definition(psp::PhaseSpacePoint) = psp.ps_def +process(psp::PhaseSpacePoint) = psp.proc +model(psp::PhaseSpacePoint) = psp.model +phase_space_definition(psp::PhaseSpacePoint) = psp.ps_def -QEDbase.particles(psp::PhaseSpacePoint, ::QEDbase.Incoming) = psp.in_particles -QEDbase.particles(psp::PhaseSpacePoint, ::QEDbase.Outgoing) = psp.out_particles +particles(psp::PhaseSpacePoint, ::Incoming) = psp.in_particles +particles(psp::PhaseSpacePoint, ::Outgoing) = psp.out_particles diff --git a/src/phase_spaces/create.jl b/src/phase_spaces/create.jl index 5f8f701..7b68cc8 100644 --- a/src/phase_spaces/create.jl +++ b/src/phase_spaces/create.jl @@ -2,9 +2,9 @@ """ InPhaseSpacePoint( - proc::QEDbase.AbstractProcessDefinition, - model::QEDbase.AbstractModelDefinition, - ps_def::QEDbase.AbstractPhasespaceDefinition, + proc::AbstractProcessDefinition, + model::AbstractModelDefinition, + ps_def::AbstractPhasespaceDefinition, in_ps::Tuple{ParticleStateful}, ) @@ -13,9 +13,9 @@ function InPhaseSpacePoint( proc::PROC, model::MODEL, ps_def::PSDEF, in_ps::IN_PARTICLES ) where { - PROC<:QEDbase.AbstractProcessDefinition, - MODEL<:QEDbase.AbstractModelDefinition, - PSDEF<:QEDbase.AbstractPhasespaceDefinition, + PROC<:AbstractProcessDefinition, + MODEL<:AbstractModelDefinition, + PSDEF<:AbstractPhasespaceDefinition, IN_PARTICLES<:Tuple{Vararg{ParticleStateful}}, } return PhaseSpacePoint(proc, model, ps_def, in_ps, ()) @@ -23,9 +23,9 @@ end """ OutPhaseSpacePoint( - proc::QEDbase.AbstractProcessDefinition, - model::QEDbase.AbstractModelDefinition, - ps_def::QEDbase.AbstractPhasespaceDefinition, + proc::AbstractProcessDefinition, + model::AbstractModelDefinition, + ps_def::AbstractPhasespaceDefinition, out_ps::Tuple{ParticleStateful}, ) @@ -34,9 +34,9 @@ Construct a [`PhaseSpacePoint`](@ref) with only output particles from [`Particle function OutPhaseSpacePoint( proc::PROC, model::MODEL, ps_def::PSDEF, out_ps::OUT_PARTICLES ) where { - PROC<:QEDbase.AbstractProcessDefinition, - MODEL<:QEDbase.AbstractModelDefinition, - PSDEF<:QEDbase.AbstractPhasespaceDefinition, + PROC<:AbstractProcessDefinition, + MODEL<:AbstractModelDefinition, + PSDEF<:AbstractPhasespaceDefinition, OUT_PARTICLES<:Tuple{Vararg{ParticleStateful}}, } return PhaseSpacePoint(proc, model, ps_def, (), out_ps) @@ -46,66 +46,66 @@ end """ PhaseSpacePoint( - proc::QEDbase.AbstractProcessDefinition, - model::QEDbase.AbstractModelDefinition, - ps_def::QEDbase.AbstractPhasespaceDefinition, - in_momenta::NTuple{N,QEDbase.AbstractFourMomentum}, - out_momenta::NTuple{M,QEDbase.AbstractFourMomentum}, + proc::AbstractProcessDefinition, + model::AbstractModelDefinition, + ps_def::AbstractPhasespaceDefinition, + in_momenta::NTuple{N,AbstractFourMomentum}, + out_momenta::NTuple{M,AbstractFourMomentum}, ) Construct the phase space point from given momenta of incoming and outgoing particles regarding a given process. """ function PhaseSpacePoint( - proc::QEDbase.AbstractProcessDefinition, - model::QEDbase.AbstractModelDefinition, - ps_def::QEDbase.AbstractPhasespaceDefinition, + proc::AbstractProcessDefinition, + model::AbstractModelDefinition, + ps_def::AbstractPhasespaceDefinition, in_momenta::NTuple{N,ELEMENT}, out_momenta::NTuple{M,ELEMENT}, -) where {N,M,ELEMENT<:QEDbase.AbstractFourMomentum} - in_particles = _build_particle_statefuls(proc, in_momenta, QEDbase.Incoming()) - out_particles = _build_particle_statefuls(proc, out_momenta, QEDbase.Outgoing()) +) where {N,M,ELEMENT<:AbstractFourMomentum} + in_particles = _build_particle_statefuls(proc, in_momenta, Incoming()) + out_particles = _build_particle_statefuls(proc, out_momenta, Outgoing()) return PhaseSpacePoint(proc, model, ps_def, in_particles, out_particles) end """ InPhaseSpacePoint( - proc::QEDbase.AbstractProcessDefinition, - model::QEDbase.AbstractModelDefinition, - ps_def::QEDbase.AbstractPhasespaceDefinition, - in_momenta::NTuple{N,QEDbase.AbstractFourMomentum}, + proc::AbstractProcessDefinition, + model::AbstractModelDefinition, + ps_def::AbstractPhasespaceDefinition, + in_momenta::NTuple{N,AbstractFourMomentum}, ) Construct a [`PhaseSpacePoint`](@ref) with only input particles from given momenta. The result will be `<: InPhaseSpacePoint` but **not** `<: OutPhaseSpacePoint`. """ function InPhaseSpacePoint( - proc::QEDbase.AbstractProcessDefinition, - model::QEDbase.AbstractModelDefinition, - ps_def::QEDbase.AbstractPhasespaceDefinition, + proc::AbstractProcessDefinition, + model::AbstractModelDefinition, + ps_def::AbstractPhasespaceDefinition, in_momenta::NTuple{N,ELEMENT}, -) where {N,ELEMENT<:QEDbase.AbstractFourMomentum} - in_particles = _build_particle_statefuls(proc, in_momenta, QEDbase.Incoming()) +) where {N,ELEMENT<:AbstractFourMomentum} + in_particles = _build_particle_statefuls(proc, in_momenta, Incoming()) return PhaseSpacePoint(proc, model, ps_def, in_particles, ()) end """ OutPhaseSpacePoint( - proc::QEDbase.AbstractProcessDefinition, - model::QEDbase.AbstractModelDefinition, - ps_def::QEDbase.AbstractPhasespaceDefinition, - out_momenta::NTuple{N,QEDbase.AbstractFourMomentum}, + proc::AbstractProcessDefinition, + model::AbstractModelDefinition, + ps_def::AbstractPhasespaceDefinition, + out_momenta::NTuple{N,AbstractFourMomentum}, ) Construct a [`PhaseSpacePoint`](@ref) with only output particles from given momenta. The result will be `<: OutPhaseSpacePoint` but **not** `<: InPhaseSpacePoint`. """ function OutPhaseSpacePoint( - proc::QEDbase.AbstractProcessDefinition, - model::QEDbase.AbstractModelDefinition, - ps_def::QEDbase.AbstractPhasespaceDefinition, + proc::AbstractProcessDefinition, + model::AbstractModelDefinition, + ps_def::AbstractPhasespaceDefinition, out_momenta::NTuple{N,ELEMENT}, -) where {N,ELEMENT<:QEDbase.AbstractFourMomentum} - out_particles = _build_particle_statefuls(proc, out_momenta, QEDbase.Outgoing()) +) where {N,ELEMENT<:AbstractFourMomentum} + out_particles = _build_particle_statefuls(proc, out_momenta, Outgoing()) return PhaseSpacePoint(proc, model, ps_def, (), out_particles) end @@ -114,19 +114,19 @@ end """ PhaseSpacePoint( - proc::QEDbase.AbstractProcessDefinition, - model::QEDbase.AbstractModelDefinition, - ps_def::QEDbase.AbstractPhasespaceDefinition, + proc::AbstractProcessDefinition, + model::AbstractModelDefinition, + ps_def::AbstractPhasespaceDefinition, in_coords::NTuple{N,Real}, out_coords::NTuple{M,Real}, ) -Construct a [`PhaseSpacePoint`](@ref) from given coordinates by using the `QEDbase._generate_momenta` interface. +Construct a [`PhaseSpacePoint`](@ref) from given coordinates by using the `_generate_momenta` interface. """ function PhaseSpacePoint( - proc::QEDbase.AbstractProcessDefinition, - model::QEDbase.AbstractModelDefinition, - ps_def::QEDbase.AbstractPhasespaceDefinition, + proc::AbstractProcessDefinition, + model::AbstractModelDefinition, + ps_def::AbstractPhasespaceDefinition, in_coords::NTuple{N,Real}, out_coords::NTuple{M,Real}, ) where {N,M} @@ -136,21 +136,21 @@ end """ InPhaseSpacePoint( - proc::QEDbase.AbstractProcessDefinition, - model::QEDbase.AbstractModelDefinition, - ps_def::QEDbase.AbstractPhasespaceDefinition, + proc::AbstractProcessDefinition, + model::AbstractModelDefinition, + ps_def::AbstractPhasespaceDefinition, in_coords::NTuple{N,Real}, ) -Construct a [`PhaseSpacePoint`](@ref) from given coordinates by using the `QEDbase._generate_momenta` interface. The result will be `<: InPhaseSpacePoint` but **not** `<: OutPhaseSpacePoint`. +Construct a [`PhaseSpacePoint`](@ref) from given coordinates by using the `_generate_momenta` interface. The result will be `<: InPhaseSpacePoint` but **not** `<: OutPhaseSpacePoint`. !!! note A similar function for [`OutPhaseSpacePoint`](@ref) does not exist from coordinates, only a full [`PhaseSpacePoint`](@ref). """ function InPhaseSpacePoint( - proc::QEDbase.AbstractProcessDefinition, - model::QEDbase.AbstractModelDefinition, - ps_def::QEDbase.AbstractPhasespaceDefinition, + proc::AbstractProcessDefinition, + model::AbstractModelDefinition, + ps_def::AbstractPhasespaceDefinition, in_coords::NTuple{N,Real}, ) where {N} in_ps = _generate_incoming_momenta(proc, model, ps_def, in_coords) diff --git a/src/phase_spaces/types.jl b/src/phase_spaces/types.jl index 7f3fcb7..3e74275 100644 --- a/src/phase_spaces/types.jl +++ b/src/phase_spaces/types.jl @@ -3,43 +3,42 @@ TBW """ -struct SphericalCoordinateSystem <: QEDbase.AbstractCoordinateSystem end +struct SphericalCoordinateSystem <: AbstractCoordinateSystem end """ CenterOfMomentumFrame <: AbstractFrameOfReference TBW """ -struct CenterOfMomentumFrame <: QEDbase.AbstractFrameOfReference end +struct CenterOfMomentumFrame <: AbstractFrameOfReference end """ ElectronRestFrame <: AbstractFrameOfReference TBW """ -struct ElectronRestFrame <: QEDbase.AbstractFrameOfReference end +struct ElectronRestFrame <: AbstractFrameOfReference end """ - PhasespaceDefinition(coord_sys::QEDbase.AbstractCoordinateSystem, frame::QEDbase.AbstractFrameOfReference) + PhasespaceDefinition(coord_sys::AbstractCoordinateSystem, frame::AbstractFrameOfReference) -Convenient type to dispatch on coordiante systems and frames of reference. Combines a `QEDbase.AbstractCoordinateSystem` with a `QEDbase.AbstractFrameOfReference`. +Convenient type to dispatch on coordiante systems and frames of reference. Combines a `AbstractCoordinateSystem` with a `AbstractFrameOfReference`. """ -struct PhasespaceDefinition{ - CS<:QEDbase.AbstractCoordinateSystem,F<:QEDbase.AbstractFrameOfReference -} <: QEDbase.AbstractPhasespaceDefinition +struct PhasespaceDefinition{CS<:AbstractCoordinateSystem,F<:AbstractFrameOfReference} <: + AbstractPhasespaceDefinition coord_sys::CS frame::F end """ - ParticleStateful <: QEDbase.AbstractParticle + ParticleStateful <: AbstractParticle 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, `Electron()`, `Positron()` etc. -- `mom::QEDbase.AbstractFourMomentum`: The momentum of the particle. +- `dir::ParticleDirection`: The direction of the particle, `Incoming()` or `Outgoing()`. +- `species::AbstractParticleType`: The species of the particle, `Electron()`, `Positron()` etc. +- `mom::AbstractFourMomentum`: The momentum of the particle. -Overloads for `QEDbase.is_fermion`, `QEDbase.is_boson`, `QEDbase.is_particle`, `QEDbase.is_anti_particle`, `QEDbase.is_incoming`, `QEDbase.is_outgoing`, `QEDbase.mass`, and `QEDbase.charge` are provided, delegating the call to the correct field and thus implementing the `QEDbase.AbstractParticle` interface. +Overloads for `is_fermion`, `is_boson`, `is_particle`, `is_anti_particle`, `is_incoming`, `is_outgoing`, `mass`, and `charge` are provided, delegating the call to the correct field and thus implementing the `AbstractParticle` interface. TODO: Turn this back into a `jldoctest` once refactoring is done. ```Julia @@ -55,10 +54,8 @@ ParticleStateful: outgoing photon ``` """ struct ParticleStateful{ - DIR<:QEDbase.ParticleDirection, - SPECIES<:QEDbase.AbstractParticleType, - ELEMENT<:QEDbase.AbstractFourMomentum, -} <: QEDbase.AbstractParticleStateful{DIR,SPECIES,ELEMENT} + DIR<:ParticleDirection,SPECIES<:AbstractParticleType,ELEMENT<:AbstractFourMomentum +} <: AbstractParticleStateful{DIR,SPECIES,ELEMENT} dir::DIR species::SPECIES mom::ELEMENT @@ -66,9 +63,7 @@ struct ParticleStateful{ function ParticleStateful( dir::DIR, species::SPECIES, mom::ELEMENT ) where { - DIR<:QEDbase.ParticleDirection, - SPECIES<:QEDbase.AbstractParticleType, - ELEMENT<:QEDbase.AbstractFourMomentum, + DIR<:ParticleDirection,SPECIES<:AbstractParticleType,ELEMENT<:AbstractFourMomentum } return new{DIR,SPECIES,ELEMENT}(dir, species, mom) end @@ -77,9 +72,9 @@ end """ PhaseSpacePoint -Representation of a point in the phase space of a process. Contains the process (`QEDbase.AbstractProcessDefinition`), the model (`QEDbase.AbstractModelDefinition`), the phase space definition (`QEDbase.AbstractPhasespaceDefinition`), and stateful incoming and outgoing particles ([`ParticleStateful`](@ref)). +Representation of a point in the phase space of a process. Contains the process (`AbstractProcessDefinition`), the model (`AbstractModelDefinition`), the phase space definition (`AbstractPhasespaceDefinition`), and stateful incoming and outgoing particles ([`ParticleStateful`](@ref)). -The legality of the combination of the given process and the incoming and outgoing particles is checked on construction. If the numbers of particles mismatch, the types of particles mismatch (note that order is important), or incoming particles have an `QEDbase.Outgoing` direction, an error is thrown. +The legality of the combination of the given process and the incoming and outgoing particles is checked on construction. If the numbers of particles mismatch, the types of particles mismatch (note that order is important), or incoming particles have an `Outgoing` direction, an error is thrown. TODO: Turn this back into a `jldoctest` once refactoring is done. ```Julia @@ -116,13 +111,13 @@ PhaseSpacePoint: A completely empty `PhaseSpacePoint` is not allowed. """ struct PhaseSpacePoint{ - PROC<:QEDbase.AbstractProcessDefinition, - MODEL<:QEDbase.AbstractModelDefinition, - PSDEF<:QEDbase.AbstractPhasespaceDefinition, + PROC<:AbstractProcessDefinition, + MODEL<:AbstractModelDefinition, + PSDEF<:AbstractPhasespaceDefinition, IN_PARTICLES<:Tuple{Vararg{ParticleStateful}}, OUT_PARTICLES<:Tuple{Vararg{ParticleStateful}}, - ELEMENT<:QEDbase.AbstractFourMomentum, -} <: QEDbase.AbstractPhaseSpacePoint{PROC,MODEL,PSDEF,IN_PARTICLES,OUT_PARTICLES} + ELEMENT<:AbstractFourMomentum, +} <: AbstractPhaseSpacePoint{PROC,MODEL,PSDEF,IN_PARTICLES,OUT_PARTICLES} proc::PROC model::MODEL ps_def::PSDEF @@ -132,9 +127,9 @@ struct PhaseSpacePoint{ """ PhaseSpacePoint( - proc::QEDbase.AbstractProcessDefinition, - model::QEDbase.AbstractModelDefinition, - ps_def::QEDbase.AbstractPhasespaceDefinition, + proc::AbstractProcessDefinition, + model::AbstractModelDefinition, + ps_def::AbstractPhasespaceDefinition, in_ps::Tuple{ParticleStateful}, out_ps::Tuple{ParticleStateful}, ) @@ -144,15 +139,15 @@ struct PhaseSpacePoint{ function PhaseSpacePoint( proc::PROC, model::MODEL, ps_def::PSDEF, in_p::IN_PARTICLES, out_p::OUT_PARTICLES ) where { - PROC<:QEDbase.AbstractProcessDefinition, - MODEL<:QEDbase.AbstractModelDefinition, - PSDEF<:QEDbase.AbstractPhasespaceDefinition, + PROC<:AbstractProcessDefinition, + MODEL<:AbstractModelDefinition, + PSDEF<:AbstractPhasespaceDefinition, IN_PARTICLES<:Tuple{Vararg{ParticleStateful}}, OUT_PARTICLES<:Tuple{Vararg{ParticleStateful}}, } # this entire check is compiled away every time, so there's no need to disable it for performance ever ELEMENT = _check_psp( - QEDbase.incoming_particles(proc), QEDbase.outgoing_particles(proc), in_p, out_p + incoming_particles(proc), outgoing_particles(proc), in_p, out_p ) return new{PROC,MODEL,PSDEF,IN_PARTICLES,OUT_PARTICLES,ELEMENT}( @@ -164,7 +159,7 @@ end """ InPhaseSpacePoint -A partial type specialization on [`PhaseSpacePoint`](@ref) which can be used for dispatch in functions requiring only the in channel of the phase space to exist, for example implementations of `QEDbase._incident_flux`. No restrictions are imposed on the out-channel, which may or may not exist. +A partial type specialization on [`PhaseSpacePoint`](@ref) which can be used for dispatch in functions requiring only the in channel of the phase space to exist, for example implementations of `_incident_flux`. No restrictions are imposed on the out-channel, which may or may not exist. See also: [`OutPhaseSpacePoint`](@ref) """ diff --git a/src/phase_spaces/utility.jl b/src/phase_spaces/utility.jl index 02fb4d3..5e90fd5 100644 --- a/src/phase_spaces/utility.jl +++ b/src/phase_spaces/utility.jl @@ -1,12 +1,10 @@ # recursion termination: base case -@inline _assemble_tuple_type(::Tuple{}, ::QEDbase.ParticleDirection, ::Type) = () +@inline _assemble_tuple_type(::Tuple{}, ::ParticleDirection, ::Type) = () # function assembling the correct type information for the tuple of ParticleStatefuls in a phasespace point constructed from momenta @inline function _assemble_tuple_type( - particle_types::Tuple{SPECIES_T,Vararg{QEDbase.AbstractParticleType}}, - dir::DIR_T, - ELTYPE::Type, -) where {SPECIES_T<:QEDbase.AbstractParticleType,DIR_T<:QEDbase.ParticleDirection} + particle_types::Tuple{SPECIES_T,Vararg{AbstractParticleType}}, dir::DIR_T, ELTYPE::Type +) where {SPECIES_T<:AbstractParticleType,DIR_T<:ParticleDirection} return ( ParticleStateful{DIR_T,SPECIES_T,ELTYPE}, _assemble_tuple_type(particle_types[2:end], dir, ELTYPE)..., @@ -14,36 +12,32 @@ end # recursion termination: success -@inline _recursive_type_check(::Tuple{}, ::Tuple{}, ::QEDbase.ParticleDirection) = nothing +@inline _recursive_type_check(::Tuple{}, ::Tuple{}, ::ParticleDirection) = nothing # recursion termination: overload for unequal number of particles @inline function _recursive_type_check( ::Tuple{Vararg{ParticleStateful,N}}, - ::Tuple{Vararg{QEDbase.AbstractParticleType,M}}, - dir::QEDbase.ParticleDirection, + ::Tuple{Vararg{AbstractParticleType,M}}, + dir::ParticleDirection, ) where {N,M} - throw( - QEDbase.InvalidInputError( - "expected $(M) $(dir) particles for the process but got $(N)" - ), - ) + throw(InvalidInputError("expected $(M) $(dir) particles for the process but got $(N)")) return nothing end # recursion termination: overload for invalid types @inline function _recursive_type_check( ::Tuple{ParticleStateful{DIR_IN_T,SPECIES_IN_T},Vararg{ParticleStateful,N}}, - ::Tuple{SPECIES_T,Vararg{QEDbase.AbstractParticleType,N}}, + ::Tuple{SPECIES_T,Vararg{AbstractParticleType,N}}, dir::DIR_T, ) where { N, - DIR_IN_T<:QEDbase.ParticleDirection, - DIR_T<:QEDbase.ParticleDirection, - SPECIES_IN_T<:QEDbase.AbstractParticleType, - SPECIES_T<:QEDbase.AbstractParticleType, + DIR_IN_T<:ParticleDirection, + DIR_T<:ParticleDirection, + SPECIES_IN_T<:AbstractParticleType, + SPECIES_T<:AbstractParticleType, } throw( - QEDbase.InvalidInputError( + InvalidInputError( "expected $(dir) $(SPECIES_T()) but got $(DIR_IN_T()) $(SPECIES_IN_T())" ), ) @@ -52,22 +46,22 @@ end @inline function _recursive_type_check( t::Tuple{ParticleStateful{DIR_T,SPECIES_T},Vararg{ParticleStateful,N}}, - p::Tuple{SPECIES_T,Vararg{QEDbase.AbstractParticleType,N}}, + p::Tuple{SPECIES_T,Vararg{AbstractParticleType,N}}, dir::DIR_T, -) where {N,DIR_T<:QEDbase.ParticleDirection,SPECIES_T<:QEDbase.AbstractParticleType} +) where {N,DIR_T<:ParticleDirection,SPECIES_T<:AbstractParticleType} return _recursive_type_check(t[2:end], p[2:end], dir) end @inline function _check_psp( in_proc::P_IN_Ts, out_proc::P_OUT_Ts, in_p::IN_Ts, out_p::OUT_Ts ) where { - P_IN_Ts<:Tuple{Vararg{QEDbase.AbstractParticleType}}, - P_OUT_Ts<:Tuple{Vararg{QEDbase.AbstractParticleType}}, + P_IN_Ts<:Tuple{Vararg{AbstractParticleType}}, + P_OUT_Ts<:Tuple{Vararg{AbstractParticleType}}, IN_Ts<:Tuple{Vararg{ParticleStateful}}, OUT_Ts<:Tuple{}, } # specific overload for InPhaseSpacePoint - _recursive_type_check(in_p, in_proc, QEDbase.Incoming()) + _recursive_type_check(in_p, in_proc, Incoming()) return typeof(in_p[1].mom) end @@ -75,13 +69,13 @@ end @inline function _check_psp( in_proc::P_IN_Ts, out_proc::P_OUT_Ts, in_p::IN_Ts, out_p::OUT_Ts ) where { - P_IN_Ts<:Tuple{Vararg{QEDbase.AbstractParticleType}}, - P_OUT_Ts<:Tuple{Vararg{QEDbase.AbstractParticleType}}, + P_IN_Ts<:Tuple{Vararg{AbstractParticleType}}, + P_OUT_Ts<:Tuple{Vararg{AbstractParticleType}}, IN_Ts<:Tuple{}, OUT_Ts<:Tuple{Vararg{ParticleStateful}}, } # specific overload for OutPhaseSpacePoint - _recursive_type_check(out_p, out_proc, QEDbase.Outgoing()) + _recursive_type_check(out_p, out_proc, Outgoing()) return typeof(out_p[1].mom) end @@ -89,16 +83,16 @@ end @inline function _check_psp( in_proc::P_IN_Ts, out_proc::P_OUT_Ts, in_p::IN_Ts, out_p::OUT_Ts ) where { - P_IN_Ts<:Tuple{Vararg{QEDbase.AbstractParticleType}}, - P_OUT_Ts<:Tuple{Vararg{QEDbase.AbstractParticleType}}, + P_IN_Ts<:Tuple{Vararg{AbstractParticleType}}, + P_OUT_Ts<:Tuple{Vararg{AbstractParticleType}}, IN_Ts<:Tuple{Vararg{ParticleStateful}}, OUT_Ts<:Tuple{Vararg{ParticleStateful}}, } # in_proc/out_proc contain only species types # in_p/out_p contain full ParticleStateful types - _recursive_type_check(in_p, in_proc, QEDbase.Incoming()) - _recursive_type_check(out_p, out_proc, QEDbase.Outgoing()) + _recursive_type_check(in_p, in_proc, Incoming()) + _recursive_type_check(out_p, out_proc, Outgoing()) return typeof(out_p[1].mom) end @@ -132,18 +126,16 @@ end # convenience function building a type stable tuple of ParticleStatefuls from the given process, momenta, and direction function _build_particle_statefuls( - proc::QEDbase.AbstractProcessDefinition, - moms::NTuple{N,ELEMENT}, - dir::QEDbase.ParticleDirection, -) where {N,ELEMENT<:QEDbase.AbstractFourMomentum} - N == QEDbase.number_particles(proc, dir) || throw( - QEDbase.InvalidInputError( - "expected $(QEDbase.number_particles(proc, dir)) $(dir) particles for the process but got $(N)", + proc::AbstractProcessDefinition, moms::NTuple{N,ELEMENT}, dir::ParticleDirection +) where {N,ELEMENT<:AbstractFourMomentum} + N == number_particles(proc, dir) || throw( + InvalidInputError( + "expected $(number_particles(proc, dir)) $(dir) particles for the process but got $(N)", ), ) - res = Tuple{_assemble_tuple_type(QEDbase.particles(proc, dir), dir, ELEMENT)...}( + res = Tuple{_assemble_tuple_type(particles(proc, dir), dir, ELEMENT)...}( ParticleStateful(dir, particle, mom) for - (particle, mom) in zip(QEDbase.particles(proc, dir), moms) + (particle, mom) in zip(particles(proc, dir), moms) ) return res diff --git a/test/algebraic_objects/dirac_tensor.jl b/test/algebraic_objects/dirac_tensor.jl index 22fa07b..cdc4d2e 100644 --- a/test/algebraic_objects/dirac_tensor.jl +++ b/test/algebraic_objects/dirac_tensor.jl @@ -1,5 +1,5 @@ using QEDcore -using QEDbase: QEDbase +using QEDbase using StaticArrays unary_methods = [-, +] diff --git a/test/algebraic_objects/four_momentum.jl b/test/algebraic_objects/four_momentum.jl index 3e20321..47db533 100644 --- a/test/algebraic_objects/four_momentum.jl +++ b/test/algebraic_objects/four_momentum.jl @@ -1,5 +1,5 @@ using QEDcore -using QEDbase: QEDbase +using QEDbase using Random const ATOL = 1e-15 @@ -14,105 +14,101 @@ const ATOL = 1e-15 mom_offshell = MomentumType(0.0, 0.0, 0.0, mass) @testset "magnitude consistence" for mom in [mom_onshell, mom_offshell, mom_zero] - @test QEDbase.getMagnitude2(mom) == QEDbase.getMag2(mom) - @test QEDbase.getMagnitude(mom) == QEDbase.getMag(mom) - @test isapprox(QEDbase.getMagnitude(mom), sqrt(QEDbase.getMagnitude2(mom))) + @test getMagnitude2(mom) == getMag2(mom) + @test getMagnitude(mom) == getMag(mom) + @test isapprox(getMagnitude(mom), sqrt(getMagnitude2(mom))) end @testset "magnitude values" begin - @test isapprox(QEDbase.getMagnitude2(mom_onshell), x^2 + y^2 + z^2) - @test isapprox(QEDbase.getMagnitude(mom_onshell), sqrt(x^2 + y^2 + z^2)) + @test isapprox(getMagnitude2(mom_onshell), x^2 + y^2 + z^2) + @test isapprox(getMagnitude(mom_onshell), sqrt(x^2 + y^2 + z^2)) end @testset "mass consistence" for mom_on in [mom_onshell, mom_zero] - @test QEDbase.getInvariantMass2(mom_on) == QEDbase.getMass2(mom_on) - @test QEDbase.getInvariantMass(mom_on) == QEDbase.getMass(mom_on) - @test isapprox( - QEDbase.getInvariantMass(mom_on), sqrt(QEDbase.getInvariantMass2(mom_on)) - ) + @test getInvariantMass2(mom_on) == getMass2(mom_on) + @test getInvariantMass(mom_on) == getMass(mom_on) + @test isapprox(getInvariantMass(mom_on), sqrt(getInvariantMass2(mom_on))) end @testset "mass value" begin - @test isapprox(QEDbase.getInvariantMass2(mom_onshell), E^2 - (x^2 + y^2 + z^2)) - @test isapprox(QEDbase.getInvariantMass(mom_onshell), sqrt(E^2 - (x^2 + y^2 + z^2))) + @test isapprox(getInvariantMass2(mom_onshell), E^2 - (x^2 + y^2 + z^2)) + @test isapprox(getInvariantMass(mom_onshell), sqrt(E^2 - (x^2 + y^2 + z^2))) - @test isapprox(QEDbase.getInvariantMass(mom_onshell), mass) - @test isapprox(QEDbase.getInvariantMass(mom_offshell), -mass) - @test isapprox(QEDbase.getInvariantMass(mom_zero), 0.0) + @test isapprox(getInvariantMass(mom_onshell), mass) + @test isapprox(getInvariantMass(mom_offshell), -mass) + @test isapprox(getInvariantMass(mom_zero), 0.0) end @testset "momentum components" begin - @test QEDbase.getE(mom_onshell) == E - @test QEDbase.getEnergy(mom_onshell) == QEDbase.getE(mom_onshell) - @test QEDbase.getPx(mom_onshell) == x - @test QEDbase.getPy(mom_onshell) == y - @test QEDbase.getPz(mom_onshell) == z + @test getE(mom_onshell) == E + @test getEnergy(mom_onshell) == getE(mom_onshell) + @test getPx(mom_onshell) == x + @test getPy(mom_onshell) == y + @test getPz(mom_onshell) == z - @test isapprox(QEDbase.getBeta(mom_onshell), sqrt(x^2 + y^2 + z^2) / E) - @test isapprox( - QEDbase.getGamma(mom_onshell), 1 / sqrt(1.0 - QEDbase.getBeta(mom_onshell)^2) - ) + @test isapprox(getBeta(mom_onshell), sqrt(x^2 + y^2 + z^2) / E) + @test isapprox(getGamma(mom_onshell), 1 / sqrt(1.0 - getBeta(mom_onshell)^2)) - @test QEDbase.getE(mom_zero) == 0.0 - @test QEDbase.getEnergy(mom_zero) == 0.0 - @test QEDbase.getPx(mom_zero) == 0.0 - @test QEDbase.getPy(mom_zero) == 0.0 - @test QEDbase.getPz(mom_zero) == 0.0 + @test getE(mom_zero) == 0.0 + @test getEnergy(mom_zero) == 0.0 + @test getPx(mom_zero) == 0.0 + @test getPy(mom_zero) == 0.0 + @test getPz(mom_zero) == 0.0 - @test isapprox(QEDbase.getBeta(mom_zero), 0.0) - @test isapprox(QEDbase.getGamma(mom_zero), 1.0) + @test isapprox(getBeta(mom_zero), 0.0) + @test isapprox(getGamma(mom_zero), 1.0) end @testset "transverse coordinates" for mom_on in [mom_onshell, mom_zero] - @test QEDbase.getTransverseMomentum2(mom_on) == QEDbase.getPt2(mom_on) - @test QEDbase.getTransverseMomentum2(mom_on) == QEDbase.getPerp2(mom_on) - @test QEDbase.getTransverseMomentum(mom_on) == QEDbase.getPt(mom_on) - @test QEDbase.getTransverseMomentum(mom_on) == QEDbase.getPerp(mom_on) + @test getTransverseMomentum2(mom_on) == getPt2(mom_on) + @test getTransverseMomentum2(mom_on) == getPerp2(mom_on) + @test getTransverseMomentum(mom_on) == getPt(mom_on) + @test getTransverseMomentum(mom_on) == getPerp(mom_on) - @test isapprox(QEDbase.getPt(mom_on), sqrt(QEDbase.getPt2(mom_on))) + @test isapprox(getPt(mom_on), sqrt(getPt2(mom_on))) - @test QEDbase.getTransverseMass2(mom_on) == QEDbase.getMt2(mom_on) - @test QEDbase.getTransverseMass(mom_on) == QEDbase.getMt(mom_on) + @test getTransverseMass2(mom_on) == getMt2(mom_on) + @test getTransverseMass(mom_on) == getMt(mom_on) end @testset "transverse coordiantes value" begin - @test isapprox(QEDbase.getTransverseMomentum2(mom_onshell), x^2 + y^2) - @test isapprox(QEDbase.getTransverseMomentum(mom_onshell), sqrt(x^2 + y^2)) - @test isapprox(QEDbase.getTransverseMass2(mom_onshell), E^2 - z^2) - @test isapprox(QEDbase.getTransverseMass(mom_onshell), sqrt(E^2 - z^2)) - @test isapprox(QEDbase.getMt(mom_offshell), -mass) - @test isapprox(QEDbase.getRapidity(mom_onshell), 0.5 * log((E + z) / (E - z))) + @test isapprox(getTransverseMomentum2(mom_onshell), x^2 + y^2) + @test isapprox(getTransverseMomentum(mom_onshell), sqrt(x^2 + y^2)) + @test isapprox(getTransverseMass2(mom_onshell), E^2 - z^2) + @test isapprox(getTransverseMass(mom_onshell), sqrt(E^2 - z^2)) + @test isapprox(getMt(mom_offshell), -mass) + @test isapprox(getRapidity(mom_onshell), 0.5 * log((E + z) / (E - z))) - @test isapprox(QEDbase.getTransverseMomentum2(mom_zero), 0.0) - @test isapprox(QEDbase.getTransverseMomentum(mom_zero), 0.0) - @test isapprox(QEDbase.getTransverseMass2(mom_zero), 0.0) - @test isapprox(QEDbase.getTransverseMass(mom_zero), 0.0) - @test isapprox(QEDbase.getMt(mom_zero), 0.0) + @test isapprox(getTransverseMomentum2(mom_zero), 0.0) + @test isapprox(getTransverseMomentum(mom_zero), 0.0) + @test isapprox(getTransverseMass2(mom_zero), 0.0) + @test isapprox(getTransverseMass(mom_zero), 0.0) + @test isapprox(getMt(mom_zero), 0.0) end @testset "spherical coordiantes consistence" for mom_on in [mom_onshell, mom_zero] - @test QEDbase.getRho2(mom_on) == QEDbase.getMagnitude2(mom_on) - @test QEDbase.getRho(mom_on) == QEDbase.getMagnitude(mom_on) + @test getRho2(mom_on) == getMagnitude2(mom_on) + @test getRho(mom_on) == getMagnitude(mom_on) - @test isapprox(QEDbase.getCosTheta(mom_on), cos(QEDbase.getTheta(mom_on))) - @test isapprox(QEDbase.getCosPhi(mom_on), cos(QEDbase.getPhi(mom_on))) - @test isapprox(QEDbase.getSinPhi(mom_on), sin(QEDbase.getPhi(mom_on))) + @test isapprox(getCosTheta(mom_on), cos(getTheta(mom_on))) + @test isapprox(getCosPhi(mom_on), cos(getPhi(mom_on))) + @test isapprox(getSinPhi(mom_on), sin(getPhi(mom_on))) end @testset "spherical coordiantes values" begin - @test isapprox(QEDbase.getTheta(mom_onshell), atan(QEDbase.getPt(mom_onshell), z)) - @test isapprox(QEDbase.getTheta(mom_zero), 0.0) + @test isapprox(getTheta(mom_onshell), atan(getPt(mom_onshell), z)) + @test isapprox(getTheta(mom_zero), 0.0) - @test isapprox(QEDbase.getPhi(mom_onshell), atan(y, x)) - @test isapprox(QEDbase.getPhi(mom_zero), 0.0) + @test isapprox(getPhi(mom_onshell), atan(y, x)) + @test isapprox(getPhi(mom_zero), 0.0) end @testset "light-cone coordiantes" begin - @test isapprox(QEDbase.getPlus(mom_onshell), 0.5 * (E + z)) - @test isapprox(QEDbase.getMinus(mom_onshell), 0.5 * (E - z)) + @test isapprox(getPlus(mom_onshell), 0.5 * (E + z)) + @test isapprox(getMinus(mom_onshell), 0.5 * (E - z)) - @test isapprox(QEDbase.getPlus(mom_zero), 0.0) - @test isapprox(QEDbase.getMinus(mom_zero), 0.0) + @test isapprox(getPlus(mom_zero), 0.0) + @test isapprox(getMinus(mom_zero), 0.0) end end # FourMomentum getter @@ -129,47 +125,41 @@ end rng = MersenneTwister(123456) @testset "Momentum components" begin - @test test_get_set(rng, QEDbase.setE!, QEDbase.getE) - @test test_get_set(rng, QEDbase.setEnergy!, QEDbase.getE) - @test test_get_set(rng, QEDbase.setPx!, QEDbase.getPx) - @test test_get_set(rng, QEDbase.setPy!, QEDbase.getPy) - @test test_get_set(rng, QEDbase.setPz!, QEDbase.getPz) + @test test_get_set(rng, setE!, getE) + @test test_get_set(rng, setEnergy!, getE) + @test test_get_set(rng, setPx!, getPx) + @test test_get_set(rng, setPy!, getPy) + @test test_get_set(rng, setPz!, getPz) end @testset "spherical coordiantes" begin - @test test_get_set(rng, QEDbase.setTheta!, QEDbase.getTheta) - @test test_get_set(rng, QEDbase.setTheta!, QEDbase.getTheta, value=0.0) - @test test_get_set(rng, QEDbase.setCosTheta!, QEDbase.getCosTheta) - @test test_get_set(rng, QEDbase.setCosTheta!, QEDbase.getCosTheta, value=1.0) - @test test_get_set(rng, QEDbase.setPhi!, QEDbase.getPhi) - @test test_get_set(rng, QEDbase.setPhi!, QEDbase.getPhi, value=0.0) - @test test_get_set(rng, QEDbase.setRho!, QEDbase.getRho) - @test test_get_set(rng, QEDbase.setRho!, QEDbase.getRho, value=0.0) + @test test_get_set(rng, setTheta!, getTheta) + @test test_get_set(rng, setTheta!, getTheta, value=0.0) + @test test_get_set(rng, setCosTheta!, getCosTheta) + @test test_get_set(rng, setCosTheta!, getCosTheta, value=1.0) + @test test_get_set(rng, setPhi!, getPhi) + @test test_get_set(rng, setPhi!, getPhi, value=0.0) + @test test_get_set(rng, setRho!, getRho) + @test test_get_set(rng, setRho!, getRho, value=0.0) end @testset "light-cone coordiantes" begin - @test test_get_set(rng, QEDbase.setPlus!, QEDbase.getPlus) - @test test_get_set(rng, QEDbase.setPlus!, QEDbase.getPlus, value=0.0) - @test test_get_set(rng, QEDbase.setMinus!, QEDbase.getMinus) - @test test_get_set(rng, QEDbase.setMinus!, QEDbase.getMinus, value=0.0) + @test test_get_set(rng, setPlus!, getPlus) + @test test_get_set(rng, setPlus!, getPlus, value=0.0) + @test test_get_set(rng, setMinus!, getMinus) + @test test_get_set(rng, setMinus!, getMinus, value=0.0) end @testset "transverse coordinates" begin - @test test_get_set( - rng, QEDbase.setTransverseMomentum!, QEDbase.getTransverseMomentum - ) - @test test_get_set( - rng, QEDbase.setTransverseMomentum!, QEDbase.getTransverseMomentum, value=0.0 - ) - @test test_get_set(rng, QEDbase.setPerp!, QEDbase.getTransverseMomentum) - @test test_get_set(rng, QEDbase.setPt!, QEDbase.getTransverseMomentum) - @test test_get_set(rng, QEDbase.setTransverseMass!, QEDbase.getTransverseMass) - @test test_get_set( - rng, QEDbase.setTransverseMass!, QEDbase.getTransverseMass, value=0.0 - ) - @test test_get_set(rng, QEDbase.setMt!, QEDbase.getTransverseMass) - @test test_get_set(rng, QEDbase.setRapidity!, QEDbase.getRapidity) - @test test_get_set(rng, QEDbase.setRapidity!, QEDbase.getRapidity, value=0.0) + @test test_get_set(rng, setTransverseMomentum!, getTransverseMomentum) + @test test_get_set(rng, setTransverseMomentum!, getTransverseMomentum, value=0.0) + @test test_get_set(rng, setPerp!, getTransverseMomentum) + @test test_get_set(rng, setPt!, getTransverseMomentum) + @test test_get_set(rng, setTransverseMass!, getTransverseMass) + @test test_get_set(rng, setTransverseMass!, getTransverseMass, value=0.0) + @test test_get_set(rng, setMt!, getTransverseMass) + @test test_get_set(rng, setRapidity!, getRapidity) + @test test_get_set(rng, setRapidity!, getRapidity, value=0.0) end end # FourMomentum setter @@ -192,11 +182,11 @@ const M_RELERR = 0.0001 E_massive = sqrt(x^2 + y^2 + z^2 + M_MASSIVE^2) mom_massless = SFourMomentum(E_massless, x, y, z) mom_massive = SFourMomentum(E_massive, x, y, z) - @test QEDbase.isonshell(mom_massless, M_MASSLESS) - @test QEDbase.isonshell(mom_massive, M_MASSIVE) + @test isonshell(mom_massless, M_MASSLESS) + @test isonshell(mom_massive, M_MASSIVE) - @test QEDbase.assert_onshell(mom_massless, M_MASSLESS) == nothing - @test QEDbase.assert_onshell(mom_massive, M_MASSIVE) == nothing + @test assert_onshell(mom_massless, M_MASSLESS) == nothing + @test assert_onshell(mom_massive, M_MASSIVE) == nothing end end @@ -212,13 +202,11 @@ const M_RELERR = 0.0001 mom_massless = SFourMomentum(E_massless, x, y, z) mom_massive = SFourMomentum(E_massive, x, y, z) - @test !QEDbase.isonshell(mom_massless, M_MASSLESS) - @test !QEDbase.isonshell(mom_massive, M_MASSIVE) + @test !isonshell(mom_massless, M_MASSLESS) + @test !isonshell(mom_massive, M_MASSIVE) - @test_throws QEDbase.OnshellError QEDbase.assert_onshell( - mom_massless, M_MASSLESS - ) - @test_throws QEDbase.OnshellError QEDbase.assert_onshell(mom_massive, M_MASSIVE) + @test_throws OnshellError assert_onshell(mom_massless, M_MASSLESS) + @test_throws OnshellError assert_onshell(mom_massive, M_MASSIVE) end end end diff --git a/test/algebraic_objects/gamma_matrices.jl b/test/algebraic_objects/gamma_matrices.jl index 02e4e04..1c837c7 100644 --- a/test/algebraic_objects/gamma_matrices.jl +++ b/test/algebraic_objects/gamma_matrices.jl @@ -1,5 +1,5 @@ using QEDcore -using QEDbase: QEDbase +using QEDbase using LinearAlgebra using Random using SparseArrays diff --git a/test/algebraic_objects/lorentz_vector.jl b/test/algebraic_objects/lorentz_vector.jl index fa07c0f..135f21b 100644 --- a/test/algebraic_objects/lorentz_vector.jl +++ b/test/algebraic_objects/lorentz_vector.jl @@ -1,5 +1,5 @@ using QEDcore -using QEDbase: QEDbase +using QEDbase using StaticArrays unary_methods = [-, +] @@ -27,10 +27,10 @@ unary_methods = [-, +] "No precise constructor for $(LorentzVectorType) found. Length of input was 2." ) LorentzVectorType(1, 2) - @test LV.t == LV[1] == QEDbase.getT(LV) - @test LV.x == LV[2] == QEDbase.getX(LV) - @test LV.y == LV[3] == QEDbase.getY(LV) - @test LV.z == LV[4] == QEDbase.getZ(LV) + @test LV.t == LV[1] == getT(LV) + @test LV.x == LV[2] == getX(LV) + @test LV.y == LV[3] == getY(LV) + @test LV.z == LV[4] == getZ(LV) end # General Properties @testset "Arithmetics" begin @@ -82,7 +82,7 @@ unary_methods = [-, +] @testset "utility functions" begin LV = LorentzVectorType(4, 3, 2, 1) - @test isapprox(@inferred(QEDbase.getMagnitude(LV)), sqrt(14)) + @test isapprox(@inferred(getMagnitude(LV)), sqrt(14)) end # utility functions end # LorentzVectorType diff --git a/test/interfaces/process.jl b/test/interfaces/process.jl index fae7118..e4e067f 100644 --- a/test/interfaces/process.jl +++ b/test/interfaces/process.jl @@ -1,5 +1,5 @@ using Random -using QEDbase: QEDbase +using QEDbase using QEDcore RNG = MersenneTwister(137137) @@ -32,8 +32,8 @@ include("../test_implementation/TestImplementation.jl") TESTPSDEF_FAIL = TestImplementation.TestPhasespaceDef_FAIL() @testset "failed process interface" begin - @test_throws MethodError QEDbase.incoming_particles(TESTPROC_FAIL_ALL) - @test_throws MethodError QEDbase.outgoing_particles(TESTPROC_FAIL_ALL) + @test_throws MethodError incoming_particles(TESTPROC_FAIL_ALL) + @test_throws MethodError outgoing_particles(TESTPROC_FAIL_ALL) end @testset "$PROC $MODEL" for (PROC, MODEL) in Iterators.product( @@ -56,18 +56,18 @@ include("../test_implementation/TestImplementation.jl") end @testset "broadcast" begin - test_func(proc::QEDbase.AbstractProcessDefinition) = proc + test_func(proc::AbstractProcessDefinition) = proc @test test_func.(TESTPROC) == TESTPROC - test_func(model::QEDbase.AbstractModelDefinition) = model + test_func(model::AbstractModelDefinition) = model @test test_func.(TESTMODEL) == TESTMODEL end @testset "incoming/outgoing particles" begin - @test QEDbase.incoming_particles(TESTPROC) == INCOMING_PARTICLES - @test QEDbase.outgoing_particles(TESTPROC) == OUTGOING_PARTICLES - @test QEDbase.number_incoming_particles(TESTPROC) == N_INCOMING - @test QEDbase.number_outgoing_particles(TESTPROC) == N_OUTGOING + @test incoming_particles(TESTPROC) == INCOMING_PARTICLES + @test outgoing_particles(TESTPROC) == OUTGOING_PARTICLES + @test number_incoming_particles(TESTPROC) == N_INCOMING + @test number_outgoing_particles(TESTPROC) == N_OUTGOING end @testset "incident flux" begin diff --git a/test/interfaces/setup.jl b/test/interfaces/setup.jl deleted file mode 100644 index 067a8ed..0000000 --- a/test/interfaces/setup.jl +++ /dev/null @@ -1,194 +0,0 @@ -using Random -using Suppressor -using QEDbase: QEDbase -using QEDcore - -RNG = MersenneTwister(137137) -ATOL = 0.0 -RTOL = sqrt(eps()) - -_groundtruth_compute(x) = x -_groundtruth_input_validation(x) = (x > 0) -struct TestException <: QEDbase.AbstractInvalidInputException end -function _groundtruth_valid_input_assert(x) - _groundtruth_input_validation(x) || throw(TestException()) - return nothing -end -_transform_to_invalid(x) = -abs(x) -_groundtruth_post_processing(x, y) = x + y - -# setups for which the interface is implemented -abstract type AbstractTestSetup <: QEDbase.AbstractComputationSetup end -QEDbase._compute(stp::AbstractTestSetup, x) = _groundtruth_compute(x) - -# setup with default implementations -struct TestSetupDefault <: AbstractTestSetup end - -# setup with custom _assert_valid_input -struct TestSetupCustomAssertValidInput <: AbstractTestSetup end -function QEDbase._assert_valid_input(stp::TestSetupCustomAssertValidInput, x) - return _groundtruth_valid_input_assert(x) -end - -# setup with custom post processing -struct TestSetupCustomPostProcessing <: AbstractTestSetup end -function QEDbase._post_processing(::TestSetupCustomPostProcessing, x, y) - return _groundtruth_post_processing(x, y) -end - -# setup with custom input validation and post processing -struct TestSetupCustom <: AbstractTestSetup end -function QEDbase._assert_valid_input(stp::TestSetupCustom, x) - return _groundtruth_valid_input_assert(x) -end -QEDbase._post_processing(::TestSetupCustom, x, y) = _groundtruth_post_processing(x, y) - -# setup which fail on computation with default implementations -struct TestSetupFAIL <: QEDbase.AbstractComputationSetup end - -# setup which fail on computation with custom input validation, where the -# invalid input will be caught before the computation. -struct TestSetupCustomValidationFAIL <: QEDbase.AbstractComputationSetup end -function QEDbase._assert_valid_input(stp::TestSetupCustomValidationFAIL, x) - return _groundtruth_valid_input_assert(x) -end - -# setup which fail on computation with custom post processing -struct TestSetupCustomPostProcessingFAIL <: QEDbase.AbstractComputationSetup end -function QEDbase._post_processing(::TestSetupCustomPostProcessingFAIL, x, y) - return _groundtruth_post_processing(x, y) -end -@testset "general computation setup interface" begin - @testset "interface fail" begin - rnd_input = rand(RNG) - - @test_throws MethodError QEDbase._compute(TestSetupFAIL(), rnd_input) - @test_throws MethodError QEDbase.compute(TestSetupFAIL(), rnd_input) - - @test_throws MethodError QEDbase._compute( - TestSetupCustomValidationFAIL(), rnd_input - ) - @test_throws MethodError QEDbase.compute(TestSetupCustomValidationFAIL(), rnd_input) - # invalid input should be caught without throwing a MethodError - @test_throws TestException QEDbase.compute( - TestSetupCustomValidationFAIL(), _transform_to_invalid(rnd_input) - ) - - @test_throws MethodError QEDbase._compute( - TestSetupCustomPostProcessingFAIL(), rnd_input - ) - @test_throws MethodError QEDbase.compute( - TestSetupCustomPostProcessingFAIL(), rnd_input - ) - end - - @testset "default interface" begin - stp = TestSetupDefault() - - rnd_input = rand(RNG) - rnd_output = rand(RNG) - @test QEDbase._post_processing(stp, rnd_input, rnd_output) == rnd_output - @test isapprox( - QEDbase._compute(stp, rnd_input), - _groundtruth_compute(rnd_input), - atol=ATOL, - rtol=RTOL, - ) - @test isapprox( - QEDbase.compute(stp, rnd_input), - _groundtruth_compute(rnd_input), - atol=ATOL, - rtol=RTOL, - ) - end - - @testset "custom input validation" begin - stp = TestSetupCustomAssertValidInput() - rnd_input = rand(RNG) - @test QEDbase._assert_valid_input(stp, rnd_input) == nothing - @test_throws TestException QEDbase._assert_valid_input( - stp, _transform_to_invalid(rnd_input) - ) - @test_throws TestException QEDbase.compute(stp, _transform_to_invalid(rnd_input)) - end - - @testset "custom post processing" begin - stp = TestSetupCustomPostProcessing() - rnd_input = rand(RNG) - rnd_output = rand(RNG) - @test isapprox( - QEDbase._post_processing(stp, rnd_input, rnd_output), - _groundtruth_post_processing(rnd_input, rnd_output), - ) - @test isapprox( - QEDbase.compute(stp, rnd_input), - _groundtruth_post_processing(rnd_input, _groundtruth_compute(rnd_input)), - ) - end - - @testset "custom input validation and post processing" begin - stp = TestSetupCustom() - rnd_input = rand(RNG) - rnd_output = rand(RNG) - - @test_throws TestException() QEDbase.compute(stp, _transform_to_invalid(rnd_input)) - @test isapprox( - QEDbase._post_processing(stp, rnd_input, rnd_output), - _groundtruth_post_processing(rnd_input, rnd_output), - ) - @test isapprox( - QEDbase.compute(stp, rnd_input), - _groundtruth_post_processing(rnd_input, _groundtruth_compute(rnd_input)), - ) - end -end -# process setup - -struct TestParticle1 <: QEDbase.AbstractParticle end -struct TestParticle2 <: QEDbase.AbstractParticle end -struct TestParticle3 <: QEDbase.AbstractParticle end -struct TestParticle4 <: QEDbase.AbstractParticle end - -PARTICLE_SET = [TestParticle1(), TestParticle2(), TestParticle3(), TestParticle4()] - -struct TestProcess <: QEDbase.AbstractProcessDefinition end -struct TestModel <: QEDbase.AbstractModelDefinition end - -struct TestProcessSetup <: QEDbase.AbstractProcessSetup end -QEDbase.scattering_process(::TestProcessSetup) = TestProcess() -QEDbase.physical_model(::TestProcessSetup) = TestModel() - -struct TestProcessSetupFAIL <: QEDbase.AbstractProcessSetup end - -@testset "process setup interface" begin - @testset "interface fail" begin - rnd_input = rand(RNG) - @test_throws MethodError QEDbase.scattering_process(TestProcessSetupFAIL()) - @test_throws MethodError QEDbase.physical_model(TestProcessSetupFAIL()) - @test_throws MethodError QEDbase._compute(TestProcessSetupFAIL(), rnd_input) - end - - @testset "hard interface" begin - stp = TestProcessSetup() - - @test QEDbase._is_computation_setup(stp) - @test QEDbase.scattering_process(stp) == TestProcess() - @test QEDbase.physical_model(stp) == TestModel() - end - - @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 = rand(RNG, PARTICLE_SET, N_INCOMING) - OUTGOING_PARTICLES = rand(RNG, PARTICLE_SET, N_OUTGOING) - - @suppress QEDbase.incoming_particles(::TestProcess) = INCOMING_PARTICLES - @suppress QEDbase.outgoing_particles(::TestProcess) = OUTGOING_PARTICLES - - @testset "delegated functions" begin - stp = TestProcessSetup() - @test QEDbase.number_incoming_particles(stp) == N_INCOMING - @test QEDbase.number_outgoing_particles(stp) == N_OUTGOING - end - end -end diff --git a/test/particles/propagators.jl b/test/particles/propagators.jl index 6f29f0e..771502e 100644 --- a/test/particles/propagators.jl +++ b/test/particles/propagators.jl @@ -1,5 +1,5 @@ using Random -using QEDbase: QEDbase +using QEDbase using QEDcore RNG = MersenneTwister(137137) @@ -12,15 +12,15 @@ end groundtruth_propagator(::Photon, mom) = one(eltype(mom)) / (mom * mom) function groundtruth_propagator(particle::FermionLike, mom) - return (slashed(mom) + QEDbase.mass(particle) * one(DiracMatrix)) / - (mom * mom - QEDbase.mass(particle)^2) + return (slashed(mom) + mass(particle) * one(DiracMatrix)) / + (mom * mom - mass(particle)^2) end @testset "propagators" begin @testset "$P" for P in (Electron(), Positron(), Photon()) mom = _rand_momentum(RNG) groundtruth = groundtruth_propagator(P, mom) - test_prop = QEDbase.propagator(P, mom) + test_prop = propagator(P, mom) @test isapprox(test_prop, groundtruth, atol=ATOL, rtol=RTOL) end end diff --git a/test/particles/spinors.jl b/test/particles/spinors.jl index e42f69f..abe097a 100644 --- a/test/particles/spinors.jl +++ b/test/particles/spinors.jl @@ -1,4 +1,4 @@ -using QEDbase: QEDbase +using QEDbase using QEDcore using Random diff --git a/test/particles/states.jl b/test/particles/states.jl index bf14ce1..bb7ad31 100644 --- a/test/particles/states.jl +++ b/test/particles/states.jl @@ -1,4 +1,4 @@ -using QEDbase: QEDbase +using QEDbase using QEDcore using StaticArrays using Random @@ -6,10 +6,10 @@ using Random include("../utils.jl") FERMION_STATES_GROUNDTRUTH_FACTORY = Dict( - (QEDbase.Incoming, Electron) => IncomingFermionSpinor, - (QEDbase.Outgoing, Electron) => OutgoingFermionSpinor, - (QEDbase.Incoming, Positron) => IncomingAntiFermionSpinor, - (QEDbase.Outgoing, Positron) => OutgoingAntiFermionSpinor, + (Incoming, Electron) => IncomingFermionSpinor, + (Outgoing, Electron) => OutgoingFermionSpinor, + (Incoming, Positron) => IncomingAntiFermionSpinor, + (Outgoing, Positron) => OutgoingAntiFermionSpinor, ) RNG = MersenneTwister(708583836976) @@ -34,57 +34,55 @@ PHIS = ( X, Y, Z = rand(RNG, 3) # test function to test scalar broadcasting -test_broadcast(x::QEDbase.AbstractParticle) = x -test_broadcast(x::QEDbase.ParticleDirection) = x -test_broadcast(x::QEDbase.AbstractSpinOrPolarization) = x +test_broadcast(x::AbstractParticle) = x +test_broadcast(x::ParticleDirection) = x +test_broadcast(x::AbstractSpinOrPolarization) = x @testset "fermion" begin struct TestFermion <: Fermion end - @test QEDbase.is_fermion(TestFermion()) - @test QEDbase.is_particle(TestFermion()) - @test !QEDbase.is_anti_particle(TestFermion()) + @test is_fermion(TestFermion()) + @test is_particle(TestFermion()) + @test !is_anti_particle(TestFermion()) @test test_broadcast.(TestFermion()) == TestFermion() - @testset "$p $d" for (p, d) in Iterators.product( - (Electron, Positron), (QEDbase.Incoming, QEDbase.Outgoing) - ) - mom = SFourMomentum(sqrt(QEDbase.mass(p()) + X^2 + Y^2 + Z^2), X, Y, Z) - particle_mass = QEDbase.mass(p()) + @testset "$p $d" for (p, d) in + 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, QEDbase.AllSpin()) == groundtruth_tuple - @test base_state(p(), d(), mom, QEDbase.SpinUp()) == groundtruth_tuple[1] - @test base_state(p(), d(), mom, QEDbase.SpinDown()) == groundtruth_tuple[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, QEDbase.AllSpin())) isa SVector - @test QEDbase._as_svec(base_state(p(), d(), mom, QEDbase.SpinUp())) isa SVector - @test QEDbase._as_svec(base_state(p(), d(), mom, QEDbase.SpinDown())) isa SVector + @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, QEDbase.AllSpin())) == - groundtruth_tuple - @test QEDbase._as_svec(base_state(p(), d(), mom, QEDbase.SpinUp()))[1] == + @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, QEDbase.SpinDown()))[1] == + @test QEDbase._as_svec(base_state(p(), d(), mom, SpinDown()))[1] == groundtruth_tuple[2] end end @testset "photon" begin - @test !QEDbase.is_fermion(Photon()) - @test QEDbase.is_boson(Photon()) - @test QEDbase.is_particle(Photon()) - @test QEDbase.is_anti_particle(Photon()) - @test QEDbase.charge(Photon()) == 0.0 - @test QEDbase.mass(Photon()) == 0.0 + @test !is_fermion(Photon()) + @test is_boson(Photon()) + @test is_particle(Photon()) + @test is_anti_particle(Photon()) + @test charge(Photon()) == 0.0 + @test mass(Photon()) == 0.0 @test test_broadcast.(Photon()) == Photon() - @testset "$D" for D in [QEDbase.Incoming, QEDbase.Outgoing] + @testset "$D" for D in [Incoming, Outgoing] @testset "$om $cth $phi" for (om, cth, phi) in Iterators.product(PHOTON_ENERGIES, COS_THETAS, PHIS) #@testset "$x $y $z" for (x,y,z) in Iterators.product(X_arr,Y_arr,Z_arr) mom = SFourMomentum(_cartesian_coordinates(om, om, cth, phi)) - both_photon_states = base_state(Photon(), D(), mom, QEDbase.AllPolarization()) + both_photon_states = base_state(Photon(), D(), mom, AllPolarization()) # property test the photon states @test isapprox((both_photon_states[1] * mom), 0.0, atol=ATOL, rtol=RTOL) @@ -100,27 +98,22 @@ end ) # test the single polarization states - @test base_state(Photon(), D(), mom, QEDbase.PolarizationX()) == - both_photon_states[1] - @test base_state(Photon(), D(), mom, QEDbase.PolarizationY()) == - both_photon_states[2] - @test base_state(Photon(), D(), mom, QEDbase.PolX()) == both_photon_states[1] - @test base_state(Photon(), D(), mom, QEDbase.PolY()) == both_photon_states[2] + @test base_state(Photon(), D(), mom, PolarizationX()) == both_photon_states[1] + @test base_state(Photon(), D(), mom, PolarizationY()) == both_photon_states[2] + @test base_state(Photon(), D(), mom, PolX()) == both_photon_states[1] + @test base_state(Photon(), D(), mom, PolY()) == both_photon_states[2] - @test QEDbase._as_svec(base_state(Photon(), D(), mom, QEDbase.PolX())) isa - SVector - @test QEDbase._as_svec(base_state(Photon(), D(), mom, QEDbase.PolY())) isa - SVector - @test QEDbase._as_svec(base_state(Photon(), D(), mom, QEDbase.AllPol())) isa - SVector + @test QEDbase._as_svec(base_state(Photon(), D(), mom, PolX())) isa SVector + @test QEDbase._as_svec(base_state(Photon(), D(), mom, PolY())) isa SVector + @test QEDbase._as_svec(base_state(Photon(), D(), mom, AllPol())) isa SVector - @test QEDbase._as_svec(base_state(Photon(), D(), mom, QEDbase.PolX()))[1] == + @test QEDbase._as_svec(base_state(Photon(), D(), mom, PolX()))[1] == both_photon_states[1] - @test QEDbase._as_svec(base_state(Photon(), D(), mom, QEDbase.PolY()))[1] == + @test QEDbase._as_svec(base_state(Photon(), D(), mom, PolY()))[1] == both_photon_states[2] - @test QEDbase._as_svec(base_state(Photon(), D(), mom, QEDbase.AllPol()))[1] == + @test QEDbase._as_svec(base_state(Photon(), D(), mom, AllPol()))[1] == both_photon_states[1] - @test QEDbase._as_svec(base_state(Photon(), D(), mom, QEDbase.AllPol()))[2] == + @test QEDbase._as_svec(base_state(Photon(), D(), mom, AllPol()))[2] == both_photon_states[2] end end diff --git a/test/phase_spaces.jl b/test/phase_spaces.jl index 7116a4b..6ef7a06 100644 --- a/test/phase_spaces.jl +++ b/test/phase_spaces.jl @@ -1,11 +1,8 @@ using Random using StaticArrays -using QEDbase: QEDbase +using QEDbase using QEDcore -# can be removed when QEDbase exports them -import QEDbase.is_incoming, QEDbase.is_outgoing - include("test_implementation/TestImplementation.jl") TESTMODEL = TestImplementation.TestModel() TESTPSDEF = TestImplementation.TestPhasespaceDef() @@ -19,7 +16,7 @@ BUF = IOBuffer() end @testset "Stateful Particle" begin - DIRECTIONS = [QEDbase.Incoming(), QEDbase.Outgoing()] + DIRECTIONS = [Incoming(), Outgoing()] SPECIES = [Electron(), Positron()] #=, Muon(), AntiMuon(), Tauon(), AntiTauon()=# for (species, dir) in Iterators.product(SPECIES, DIRECTIONS) @@ -28,23 +25,22 @@ end particle_stateful = ParticleStateful(dir, species, mom) # particle interface - @test QEDbase.is_fermion(particle_stateful) == QEDbase.is_fermion(species) - @test QEDbase.is_boson(particle_stateful) == QEDbase.is_boson(species) - @test QEDbase.is_particle(particle_stateful) == QEDbase.is_particle(species) - @test QEDbase.is_anti_particle(particle_stateful) == - QEDbase.is_anti_particle(species) - @test QEDbase.is_incoming(particle_stateful) == QEDbase.is_incoming(dir) - @test QEDbase.is_outgoing(particle_stateful) == QEDbase.is_outgoing(dir) - @test QEDbase.mass(particle_stateful) == QEDbase.mass(species) - @test QEDbase.charge(particle_stateful) == QEDbase.charge(species) + @test is_fermion(particle_stateful) == is_fermion(species) + @test is_boson(particle_stateful) == is_boson(species) + @test is_particle(particle_stateful) == is_particle(species) + @test is_anti_particle(particle_stateful) == is_anti_particle(species) + @test is_incoming(particle_stateful) == is_incoming(dir) + @test is_outgoing(particle_stateful) == is_outgoing(dir) + @test mass(particle_stateful) == mass(species) + @test charge(particle_stateful) == charge(species) # accessors @test particle_stateful.dir == dir - @test QEDbase.particle_direction(particle_stateful) == particle_stateful.dir + @test particle_direction(particle_stateful) == particle_stateful.dir @test particle_stateful.species == species - @test QEDbase.particle_species(particle_stateful) == particle_stateful.species + @test particle_species(particle_stateful) == particle_stateful.species @test particle_stateful.mom == mom - @test QEDbase.momentum(particle_stateful) == mom + @test momentum(particle_stateful) == mom # printing print(BUF, particle_stateful) @@ -62,10 +58,10 @@ end out_el_mom = rand(RNG, SFourMomentum) out_ph_mom = rand(RNG, SFourMomentum) - 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_el = ParticleStateful(Incoming(), Electron(), in_el_mom) + in_ph = ParticleStateful(Incoming(), Photon(), in_ph_mom) + out_el = ParticleStateful(Outgoing(), Electron(), out_el_mom) + out_ph = ParticleStateful(Outgoing(), Photon(), out_ph_mom) in_particles_valid = (in_el, in_ph) in_particles_invalid = (in_el, out_ph) @@ -92,15 +88,15 @@ end ) isa RegexMatch @testset "Accessor" begin - @test QEDbase.momentum(psp, QEDbase.Incoming(), 1) == in_el.mom - @test QEDbase.momentum(psp, QEDbase.Incoming(), 2) == in_ph.mom - @test QEDbase.momentum(psp, QEDbase.Outgoing(), 1) == out_el.mom - @test QEDbase.momentum(psp, QEDbase.Outgoing(), 2) == out_ph.mom - - @test psp[QEDbase.Incoming(), 1] == in_el - @test psp[QEDbase.Incoming(), 2] == in_ph - @test psp[QEDbase.Outgoing(), 1] == out_el - @test psp[QEDbase.Outgoing(), 2] == out_ph + @test momentum(psp, Incoming(), 1) == in_el.mom + @test momentum(psp, Incoming(), 2) == in_ph.mom + @test momentum(psp, Outgoing(), 1) == out_el.mom + @test momentum(psp, Outgoing(), 2) == out_ph.mom + + @test psp[Incoming(), 1] == in_el + @test psp[Incoming(), 2] == in_ph + @test psp[Outgoing(), 1] == out_el + @test psp[Outgoing(), 2] == out_ph end @testset "Error handling" begin @@ -139,29 +135,29 @@ end ) end - @test_throws BoundsError QEDbase.momentum(psp, QEDbase.Incoming(), -1) - @test_throws BoundsError QEDbase.momentum(psp, QEDbase.Outgoing(), -1) - @test_throws BoundsError QEDbase.momentum(psp, QEDbase.Incoming(), 4) - @test_throws BoundsError QEDbase.momentum(psp, QEDbase.Outgoing(), 4) + @test_throws BoundsError momentum(psp, Incoming(), -1) + @test_throws BoundsError momentum(psp, Outgoing(), -1) + @test_throws BoundsError momentum(psp, Incoming(), 4) + @test_throws BoundsError momentum(psp, Outgoing(), 4) - @test_throws BoundsError psp[QEDbase.Incoming(), -1] - @test_throws BoundsError psp[QEDbase.Outgoing(), -1] - @test_throws BoundsError psp[QEDbase.Incoming(), 4] - @test_throws BoundsError psp[QEDbase.Outgoing(), 4] + @test_throws BoundsError psp[Incoming(), -1] + @test_throws BoundsError psp[Outgoing(), -1] + @test_throws BoundsError psp[Incoming(), 4] + @test_throws BoundsError psp[Outgoing(), 4] - @test_throws QEDbase.InvalidInputError PhaseSpacePoint( + @test_throws InvalidInputError PhaseSpacePoint( process, model, phasespace_def, in_particles_invalid, out_particles_valid ) - @test_throws QEDbase.InvalidInputError PhaseSpacePoint( + @test_throws InvalidInputError PhaseSpacePoint( process, model, phasespace_def, in_particles_valid, out_particles_invalid ) - @test_throws QEDbase.InvalidInputError PhaseSpacePoint( + @test_throws InvalidInputError PhaseSpacePoint( process, model, phasespace_def, (in_ph, in_el), out_particles_valid ) - @test_throws QEDbase.InvalidInputError PhaseSpacePoint( + @test_throws InvalidInputError PhaseSpacePoint( process, model, phasespace_def, in_particles_valid, (out_ph, out_el) ) end @@ -175,15 +171,15 @@ end @test test_psp.model == model @test test_psp.ps_def == phasespace_def - @test test_psp[QEDbase.Incoming(), 1] == in_el - @test test_psp[QEDbase.Incoming(), 2] == in_ph - @test test_psp[QEDbase.Outgoing(), 1] == out_el - @test test_psp[QEDbase.Outgoing(), 2] == out_ph + @test test_psp[Incoming(), 1] == in_el + @test test_psp[Incoming(), 2] == in_ph + @test test_psp[Outgoing(), 1] == out_el + @test test_psp[Outgoing(), 2] == out_ph end @testset "Error handling from momenta" for (i, o) in Iterators.product([1, 3, 4, 5], [1, 3, 4, 5]) - @test_throws QEDbase.InvalidInputError PhaseSpacePoint( + @test_throws InvalidInputError PhaseSpacePoint( process, model, phasespace_def, @@ -216,18 +212,18 @@ end @test out_psp_from_moms isa OutPhaseSpacePoint @test !(out_psp_from_moms isa InPhaseSpacePoint) - @test_throws QEDbase.InvalidInputError InPhaseSpacePoint( + @test_throws InvalidInputError InPhaseSpacePoint( process, model, phasespace_def, in_particles_invalid ) - @test_throws QEDbase.InvalidInputError OutPhaseSpacePoint( + @test_throws InvalidInputError OutPhaseSpacePoint( process, model, phasespace_def, out_particles_invalid ) @testset "Error handling from momenta" for i in [1, 3, 4, 5] - @test_throws QEDbase.InvalidInputError InPhaseSpacePoint( + @test_throws InvalidInputError InPhaseSpacePoint( process, model, phasespace_def, TestImplementation._rand_momenta(RNG, i) ) - @test_throws QEDbase.InvalidInputError OutPhaseSpacePoint( + @test_throws InvalidInputError OutPhaseSpacePoint( process, model, phasespace_def, TestImplementation._rand_momenta(RNG, i) ) end diff --git a/test/runtests.jl b/test/runtests.jl index 02a159f..48f361a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -49,8 +49,4 @@ begin @time @safetestset "process interface" begin include("interfaces/process.jl") end - - @time @safetestset "computation setup interface" begin - include("interfaces/setup.jl") - end end diff --git a/test/test_implementation/TestImplementation.jl b/test/test_implementation/TestImplementation.jl index 830e1ce..5197738 100644 --- a/test/test_implementation/TestImplementation.jl +++ b/test/test_implementation/TestImplementation.jl @@ -26,7 +26,7 @@ export TestProcess, TestProcess_FAIL export TestPhasespaceDef, TestPhasespaceDef_FAIL using Random -using QEDbase: QEDbase +using QEDbase using QEDcore using StaticArrays diff --git a/test/test_implementation/groundtruths.jl b/test/test_implementation/groundtruths.jl index e6dc7e2..fce9891 100644 --- a/test/test_implementation/groundtruths.jl +++ b/test/test_implementation/groundtruths.jl @@ -1,5 +1,3 @@ -import QEDbase.AbstractFourMomentum - """ _groundtruth_incident_flux(in_ps) @@ -35,9 +33,7 @@ end Test implementation of the averaging norm. Returns the inverse of the sum of all external particles of the passed process. """ function _groundtruth_averaging_norm(proc) - return 1.0 / ( - QEDbase.number_incoming_particles(proc) + QEDbase.number_outgoing_particles(proc) - ) + return 1.0 / (number_incoming_particles(proc) + number_outgoing_particles(proc)) end """ @@ -61,8 +57,8 @@ end Test implementation of the phase space factor. Return the inverse of the product of the energies of all external particles. """ function _groundtruth_phase_space_factor(in_ps, out_ps) - en_in = QEDbase.getE.(in_ps) - en_out = QEDbase.getE.(out_ps) + en_in = getE.(in_ps) + en_out = getE.(out_ps) return 1 / (prod(en_in) * prod(en_out)) end @@ -242,26 +238,26 @@ Test implementation of the total cross section. Return the Minkowski square of t """ function _groundtruth_total_probability( in_ps::NTuple{N,T} -) where {N,T<:QEDbase.AbstractFourMomentum} +) where {N,T<:AbstractFourMomentum} Ptot = sum(in_ps) return Ptot * Ptot end function _groundtruth_total_probability( in_pss::Vector{NTuple{N,T}} -) where {N,T<:QEDbase.AbstractFourMomentum} +) where {N,T<:AbstractFourMomentum} return _groundtruth_total_probability.(in_pss) end function _groundtruth_total_cross_section( in_ps::NTuple{N,T} -) where {N,T<:QEDbase.AbstractFourMomentum} +) where {N,T<:AbstractFourMomentum} init_flux = _groundtruth_incident_flux(in_ps) return _groundtruth_total_probability(in_ps) / (4 * init_flux) end function _groundtruth_total_cross_section( in_pss::Vector{NTuple{N,T}} -) where {N,T<:QEDbase.AbstractFourMomentum} +) where {N,T<:AbstractFourMomentum} return _groundtruth_total_cross_section.(in_psps) end diff --git a/test/test_implementation/test_model.jl b/test/test_implementation/test_model.jl index 6e5aaf2..87f4f04 100644 --- a/test/test_implementation/test_model.jl +++ b/test/test_implementation/test_model.jl @@ -1,4 +1,4 @@ -struct TestModel <: QEDbase.AbstractModelDefinition end +struct TestModel <: AbstractModelDefinition end QEDbase.fundamental_interaction_type(::TestModel) = :test_interaction -struct TestModel_FAIL <: QEDbase.AbstractModelDefinition end +struct TestModel_FAIL <: AbstractModelDefinition end diff --git a/test/test_implementation/test_process.jl b/test/test_implementation/test_process.jl index 67c844a..5a81146 100644 --- a/test/test_implementation/test_process.jl +++ b/test/test_implementation/test_process.jl @@ -8,7 +8,7 @@ const PARTICLE_SET = [TestParticleFermion(), TestParticleBoson()] TestProcess(rng,incoming_particles,outgoing_particles) """ -struct TestProcess{IP<:Tuple,OP<:Tuple} <: QEDbase.AbstractProcessDefinition +struct TestProcess{IP<:Tuple,OP<:Tuple} <: AbstractProcessDefinition incoming_particles::IP outgoing_particles::OP end @@ -22,7 +22,7 @@ end QEDbase.incoming_particles(proc::TestProcess) = proc.incoming_particles QEDbase.outgoing_particles(proc::TestProcess) = proc.outgoing_particles -struct TestProcess_FAIL{IP<:Tuple,OP<:Tuple} <: QEDbase.AbstractProcessDefinition +struct TestProcess_FAIL{IP<:Tuple,OP<:Tuple} <: AbstractProcessDefinition incoming_particles::IP outgoing_particles::OP end @@ -34,16 +34,16 @@ function TestProcess_FAIL(rng::AbstractRNG, N_in::Int, N_out::Int) end function QEDbase.in_phase_space_dimension(proc::TestProcess, ::TestModel) - return QEDbase.number_incoming_particles(proc) * 4 + return number_incoming_particles(proc) * 4 end function QEDbase.out_phase_space_dimension(proc::TestProcess, ::TestModel) - return QEDbase.number_outgoing_particles(proc) * 4 + return number_outgoing_particles(proc) * 4 end """ Test process with no implemented interface. Should fail every usage except construction. """ -struct TestProcess_FAIL_ALL{IP<:Tuple,OP<:Tuple} <: QEDbase.AbstractProcessDefinition +struct TestProcess_FAIL_ALL{IP<:Tuple,OP<:Tuple} <: AbstractProcessDefinition incoming_particles::IP outgoing_particles::OP end @@ -58,7 +58,7 @@ end Test process with no implemented interface except the incoming and outgoing particles. Should fail every usage except construction of itself and the respective phase space point for given four-momenta. """ -struct TestProcess_FAIL_DIFFCS{IP<:Tuple,OP<:Tuple} <: QEDbase.AbstractProcessDefinition +struct TestProcess_FAIL_DIFFCS{IP<:Tuple,OP<:Tuple} <: AbstractProcessDefinition incoming_particles::IP outgoing_particles::OP end @@ -73,13 +73,13 @@ QEDbase.incoming_particles(proc::TestProcess_FAIL_DIFFCS) = proc.incoming_partic QEDbase.outgoing_particles(proc::TestProcess_FAIL_DIFFCS) = proc.outgoing_particles # dummy phase space definition + failing phase space definition -struct TestPhasespaceDef <: QEDbase.AbstractPhasespaceDefinition end -struct TestPhasespaceDef_FAIL <: QEDbase.AbstractPhasespaceDefinition end +struct TestPhasespaceDef <: AbstractPhasespaceDefinition end +struct TestPhasespaceDef_FAIL <: AbstractPhasespaceDefinition end # dummy implementation of the process interface function QEDbase._incident_flux(in_psp::InPhaseSpacePoint{<:TestProcess,<:TestModel}) - return _groundtruth_incident_flux(QEDbase.momenta(in_psp, QEDbase.Incoming())) + return _groundtruth_incident_flux(momenta(in_psp, Incoming())) end function QEDbase._averaging_norm(proc::TestProcess) @@ -87,22 +87,22 @@ function QEDbase._averaging_norm(proc::TestProcess) end function QEDbase._matrix_element(psp::PhaseSpacePoint{<:TestProcess,TestModel}) - in_ps = QEDbase.momenta(psp, QEDbase.Incoming()) - out_ps = QEDbase.momenta(psp, QEDbase.Outgoing()) + in_ps = momenta(psp, Incoming()) + out_ps = momenta(psp, Outgoing()) return _groundtruth_matrix_element(in_ps, out_ps) end function QEDbase._is_in_phasespace(psp::PhaseSpacePoint{<:TestProcess,TestModel}) - in_ps = QEDbase.momenta(psp, QEDbase.Incoming()) - out_ps = QEDbase.momenta(psp, QEDbase.Outgoing()) + in_ps = momenta(psp, Incoming()) + out_ps = momenta(psp, Outgoing()) return _groundtruth_is_in_phasespace(in_ps, out_ps) end function QEDbase._phase_space_factor( psp::PhaseSpacePoint{<:TestProcess,TestModel,TestPhasespaceDef} ) - in_ps = QEDbase.momenta(psp, QEDbase.Incoming()) - out_ps = QEDbase.momenta(psp, QEDbase.Outgoing()) + in_ps = momenta(psp, Incoming()) + out_ps = momenta(psp, Outgoing()) return _groundtruth_phase_space_factor(in_ps, out_ps) end @@ -127,5 +127,5 @@ end function QEDbase._total_probability( in_psp::InPhaseSpacePoint{<:TestProcess,<:TestModel,<:TestPhasespaceDef} ) - return _groundtruth_total_probability(QEDbase.momenta(in_psp, QEDbase.Incoming())) + return _groundtruth_total_probability(momenta(in_psp, Incoming())) end diff --git a/test/test_implementation/utils.jl b/test/test_implementation/utils.jl index 3a141d9..8804b29 100644 --- a/test/test_implementation/utils.jl +++ b/test/test_implementation/utils.jl @@ -5,11 +5,11 @@ _any_fail(::TestProcess, ::TestModel) = false _any_fail(::TestProcess, ::TestModel, ::TestPhasespaceDef) = false # unrolls all elements of a list of four-momenta into vector of coordinates -function _unroll_moms(ps_moms::AbstractVector{T}) where {T<:QEDbase.AbstractFourMomentum} +function _unroll_moms(ps_moms::AbstractVector{T}) where {T<:AbstractFourMomentum} return collect(Iterators.flatten(ps_moms)) end -function _unroll_moms(ps_moms::AbstractMatrix{T}) where {T<:QEDbase.AbstractFourMomentum} +function _unroll_moms(ps_moms::AbstractMatrix{T}) where {T<:AbstractFourMomentum} res = Matrix{eltype(T)}(undef, size(ps_moms, 1) * 4, size(ps_moms, 2)) for i in 1:size(ps_moms, 2) res[:, i] .= _unroll_moms(view(ps_moms, :, i))