Skip to content

Commit

Permalink
Add QEDprocess functionality (#25)
Browse files Browse the repository at this point in the history
This adds the functionality from QEDprocesses again which was
temporarily removed from #6 / #23 to have a working state.

Must be merged after QEDbase is released with the new interfaces from
QEDprocesses.
  • Loading branch information
szabo137 authored Jun 26, 2024
2 parents 002d5fe + ed086bd commit cc4895d
Show file tree
Hide file tree
Showing 24 changed files with 1,821 additions and 10 deletions.
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
QEDbase = "10e22c08-3ccb-4172-bfcf-7d7aa3d04d93"
QEDcore = "35dc0263-cb5f-4c33-a114-1d7f54ab753e"
QEDprocesses = "46de9c38-1bb3-4547-a1ec-da24d767fdad"
11 changes: 10 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
using Pkg

# targeting the correct source code
# this asumes the make.jl script is located in QEDcore.jl/docs
project_path = Base.Filesystem.joinpath(Base.Filesystem.dirname(Base.source_path()), "..")
Pkg.develop(; path=project_path)

Pkg.add(; url="https://github.com/QEDjl-project/QEDbase.jl/", rev="dev")

using QEDcore
using Documenter

DocMeta.setdocmeta!(QEDcore, :DocTestSetup, :(using QEDcore); recursive=true)
# DocMeta.setdocmeta!(QEDcore, :DocTestSetup, :(using QEDcore); recursive=true)

makedocs(;
modules=[QEDcore],
Expand Down
20 changes: 15 additions & 5 deletions src/QEDcore.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
module QEDcore

import Base: *
import StaticArrays: similar_type
import QEDbase: base_state

# lorentz vectors
export SLorentzVector, MLorentzVector

Expand Down Expand Up @@ -32,6 +28,13 @@ export @valid_spinor_input
# particle base states
export base_state

# phase space
export SphericalCoordinateSystem
export CenterOfMomentumFrame, ElectronRestFrame
export PhasespaceDefinition
export ParticleStateful, PhaseSpacePoint, InPhaseSpacePoint, OutPhaseSpacePoint
export spin, polarization, particle_direction, particle_species, momentum, momenta, getindex

using QEDbase: QEDbase
using DocStringExtensions
using StaticArrays
Expand All @@ -40,12 +43,19 @@ using SimpleTraits
include("algebraic_objects/dirac_tensors/types.jl")
include("algebraic_objects/dirac_tensors/multiplication.jl")

include("phase_spaces/types.jl")
include("phase_spaces/access.jl")
include("phase_spaces/create.jl")
include("phase_spaces/print.jl")
include("phase_spaces/utility.jl")

include("algebraic_objects/four_momentum.jl")
include("algebraic_objects/lorentz_vector.jl")
include("algebraic_objects/gamma_matrices.jl")

include("particles/particle_types.jl")
include("particles/spinors.jl")
include("particles/propagators.jl")
include("particles/states.jl")
include("particles/spinors.jl")

end
3 changes: 3 additions & 0 deletions src/algebraic_objects/dirac_tensors/multiplication.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Concrete implementation of multiplication for Dirac Tensors
#
#######

import Base: *

"""
$(TYPEDSIGNATURES)
Expand Down
1 change: 1 addition & 0 deletions src/algebraic_objects/four_momentum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#######

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

"""
$(TYPEDEF)
Expand Down
1 change: 1 addition & 0 deletions src/algebraic_objects/lorentz_vector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#######

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

#######
#
Expand Down
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
29 changes: 29 additions & 0 deletions src/particles/propagators.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import QEDbase: propagator

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

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

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

function _fermion_propagator(P::QEDbase.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))
end

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

function QEDbase.propagator(particle_type::FermionLike, P::QEDbase.AbstractFourMomentum)
return _fermion_propagator(P, QEDbase.mass(particle_type))
end
2 changes: 2 additions & 0 deletions src/particles/states.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import QEDbase: base_state

function _booster_fermion(mom::QEDbase.AbstractFourMomentum, mass::Real)
return (slashed(mom) + mass * one(DiracMatrix)) / (sqrt(abs(QEDbase.getT(mom)) + mass))
end
Expand Down
30 changes: 30 additions & 0 deletions src/phase_spaces/access.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# accessor interface particle stateful
QEDbase.particle_direction(part::ParticleStateful) = part.dir
QEDbase.particle_species(part::ParticleStateful) = part.species
QEDbase.momentum(part::ParticleStateful) = part.mom

# accessor interface phase space point
"""
Base.getindex(psp::PhaseSpacePoint, dir::Incoming, n::Int)
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)
return psp.in_particles[n]
end

"""
Base.getindex(psp::PhaseSpacePoint, dir::Outgoing, n::Int)
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)
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

QEDbase.particles(psp::PhaseSpacePoint, ::QEDbase.Incoming) = psp.in_particles
QEDbase.particles(psp::PhaseSpacePoint, ::QEDbase.Outgoing) = psp.out_particles
158 changes: 158 additions & 0 deletions src/phase_spaces/create.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# PSP constructors from particle statefuls

"""
InPhaseSpacePoint(
proc::QEDbase.AbstractProcessDefinition,
model::QEDbase.AbstractModelDefinition,
ps_def::QEDbase.AbstractPhasespaceDefinition,
in_ps::Tuple{ParticleStateful},
)
Construct a [`PhaseSpacePoint`](@ref) with only input particles from [`ParticleStateful`](@ref)s. The result will be `<: InPhaseSpacePoint` but **not** `<: OutPhaseSpacePoint`.
"""
function InPhaseSpacePoint(
proc::PROC, model::MODEL, ps_def::PSDEF, in_ps::IN_PARTICLES
) where {
PROC<:QEDbase.AbstractProcessDefinition,
MODEL<:QEDbase.AbstractModelDefinition,
PSDEF<:QEDbase.AbstractPhasespaceDefinition,
IN_PARTICLES<:Tuple{Vararg{ParticleStateful}},
}
return PhaseSpacePoint(proc, model, ps_def, in_ps, ())
end

"""
OutPhaseSpacePoint(
proc::QEDbase.AbstractProcessDefinition,
model::QEDbase.AbstractModelDefinition,
ps_def::QEDbase.AbstractPhasespaceDefinition,
out_ps::Tuple{ParticleStateful},
)
Construct a [`PhaseSpacePoint`](@ref) with only output particles from [`ParticleStateful`](@ref)s. The result will be `<: OutPhaseSpacePoint` but **not** `<: InPhaseSpacePoint`.
"""
function OutPhaseSpacePoint(
proc::PROC, model::MODEL, ps_def::PSDEF, out_ps::OUT_PARTICLES
) where {
PROC<:QEDbase.AbstractProcessDefinition,
MODEL<:QEDbase.AbstractModelDefinition,
PSDEF<:QEDbase.AbstractPhasespaceDefinition,
OUT_PARTICLES<:Tuple{Vararg{ParticleStateful}},
}
return PhaseSpacePoint(proc, model, ps_def, (), out_ps)
end

# PSP constructors from momenta

"""
PhaseSpacePoint(
proc::QEDbase.AbstractProcessDefinition,
model::QEDbase.AbstractModelDefinition,
ps_def::QEDbase.AbstractPhasespaceDefinition,
in_momenta::NTuple{N,QEDbase.AbstractFourMomentum},
out_momenta::NTuple{M,QEDbase.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,
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())

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},
)
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,
in_momenta::NTuple{N,ELEMENT},
) where {N,ELEMENT<:QEDbase.AbstractFourMomentum}
in_particles = _build_particle_statefuls(proc, in_momenta, QEDbase.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},
)
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,
out_momenta::NTuple{N,ELEMENT},
) where {N,ELEMENT<:QEDbase.AbstractFourMomentum}
out_particles = _build_particle_statefuls(proc, out_momenta, QEDbase.Outgoing())

return PhaseSpacePoint(proc, model, ps_def, (), out_particles)
end

# PSP constructors from coordinates

"""
PhaseSpacePoint(
proc::QEDbase.AbstractProcessDefinition,
model::QEDbase.AbstractModelDefinition,
ps_def::QEDbase.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.
"""
function PhaseSpacePoint(
proc::QEDbase.AbstractProcessDefinition,
model::QEDbase.AbstractModelDefinition,
ps_def::QEDbase.AbstractPhasespaceDefinition,
in_coords::NTuple{N,Real},
out_coords::NTuple{M,Real},
) where {N,M}
in_ps, out_ps = _generate_momenta(proc, model, ps_def, in_coords, out_coords)
return PhaseSpacePoint(proc, model, ps_def, in_ps, out_ps)
end

"""
InPhaseSpacePoint(
proc::QEDbase.AbstractProcessDefinition,
model::QEDbase.AbstractModelDefinition,
ps_def::QEDbase.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`.
!!! 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,
in_coords::NTuple{N,Real},
) where {N}
in_ps = _generate_incoming_momenta(proc, model, ps_def, in_coords)
return InPhaseSpacePoint(proc, model, ps_def, in_ps)
end
Loading

0 comments on commit cc4895d

Please sign in to comment.