Skip to content

Commit f686b13

Browse files
szabo137Uwe Hernandez Acosta
and
Uwe Hernandez Acosta
authored
Refactoring QED.jl (#76)
This opts out the `QEDbase` namespace and adds the dependency on `QEDcore`. This is part of the general restructuring of `QED.jl`, see QEDjl-project/QuantumElectrodynamics.jl#35 for details. --------- Co-authored-by: Uwe Hernandez Acosta <[email protected]>
1 parent c768a57 commit f686b13

25 files changed

+308
-207
lines changed

.github/workflows/BuildDeployDoc.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches:
66
- master
77
- dev
8-
tags: '*'
8+
tags: "*"
99
pull_request:
1010

1111
jobs:
@@ -18,9 +18,11 @@ jobs:
1818
- uses: actions/checkout@v4
1919
- uses: julia-actions/setup-julia@v1
2020
with:
21-
version: '1.9'
21+
version: "1.9"
2222
- name: Install dependencies
23-
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
23+
run: |
24+
julia --project=docs/ add_QEDcore_dev.jl
25+
julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
2426
- name: Build and deploy
2527
env:
2628
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token

.gitlab-ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ stages:
99
script:
1010
- apt update && apt install -y git
1111
- git clone --depth 1 -b dev https://github.com/QEDjl-project/QED.jl.git /QEDjl
12+
- julia --project=. add_QEDcore_dev.jl
1213
- >
1314
if [[ $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_REF_NAME == "dev" ]]; then
1415
# set name of the commit message from CI_COMMIT_MESSAGE to NO_MESSAGE, that the script does not read accidentally custom packages from the commit message of a merge commit

Project.toml

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
name = "QEDprocesses"
22
uuid = "46de9c38-1bb3-4547-a1ec-da24d767fdad"
3-
authors = [
4-
"Uwe Hernandez Acosta <[email protected]>",
5-
"Simeon Ehrig",
6-
"Klaus Steiniger",
7-
"Tom Jungnickel",
8-
"Anton Reinhard",
9-
]
3+
authors = ["Uwe Hernandez Acosta <[email protected]>", "Simeon Ehrig", "Klaus Steiniger", "Tom Jungnickel", "Anton Reinhard"]
104
version = "0.1.0"
115

126
[deps]
137
QEDbase = "10e22c08-3ccb-4172-bfcf-7d7aa3d04d93"
8+
QEDcore = "35dc0263-cb5f-4c33-a114-1d7f54ab753e"
149
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
1510
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1611

add_QEDcore_dev.jl

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
@warn "This repository depends on the dev branch of QEDcore.jl\n It is NOT ready for release!"
3+
4+
using Pkg: Pkg
5+
Pkg.add(; url="https://github.com/QEDjl-project/QEDcore.jl", rev="dev")

src/QEDprocesses.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,13 @@ export PerturbativeQED
4444
# specific scattering processes
4545
export Compton, omega_prime
4646

47-
using QEDbase
47+
using QEDbase: QEDbase
48+
using QEDcore
4849
using StaticArrays
4950
using QuadGK
5051

52+
include("restruct_patch.jl")
53+
5154
include("constants.jl")
5255
include("utils.jl")
5356

src/cross_section/diff_probability.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ If the given phase spaces are physical, return differential probability evaluate
3535
"""
3636
function differential_probability(phase_space_point::PhaseSpacePoint)
3737
if !_is_in_phasespace(phase_space_point)
38-
return zero(eltype(momentum(phase_space_point, Incoming(), 1)))
38+
return zero(eltype(momentum(phase_space_point, QEDbase.Incoming(), 1)))
3939
end
4040

4141
return unsafe_differential_probability(phase_space_point)

src/interfaces/process_interface.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,19 @@ end
155155
156156
Convenience function dispatching to [`incoming_particles`](@ref) or [`outgoing_particles`](@ref) depending on the given direction.
157157
"""
158-
@inline particles(proc_def::AbstractProcessDefinition, ::Incoming) =
158+
@inline particles(proc_def::AbstractProcessDefinition, ::QEDbase.Incoming) =
159159
incoming_particles(proc_def)
160-
@inline particles(proc_def::AbstractProcessDefinition, ::Outgoing) =
160+
@inline particles(proc_def::AbstractProcessDefinition, ::QEDbase.Outgoing) =
161161
outgoing_particles(proc_def)
162162

163163
"""
164164
number_particles(proc_def::AbstractProcessDefinition, ::ParticleDirection)
165165
166166
Convenience function dispatching to [`number_incoming_particles`](@ref) or [`number_outgoing_particles`](@ref) depending on the given direction.
167167
"""
168-
@inline number_particles(proc_def::AbstractProcessDefinition, ::Incoming) =
168+
@inline number_particles(proc_def::AbstractProcessDefinition, ::QEDbase.Incoming) =
169169
number_incoming_particles(proc_def)
170-
@inline number_particles(proc_def::AbstractProcessDefinition, ::Outgoing) =
170+
@inline number_particles(proc_def::AbstractProcessDefinition, ::QEDbase.Outgoing) =
171171
number_outgoing_particles(proc_def)
172172

173173
"""

src/patch_QEDbase.jl

+19-19
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
#############
66

77
# fix: https://github.com/QEDjl-project/QEDbase.jl/pull/61
8-
Base.show(io::IO, ::Electron) = print(io, "electron")
9-
Base.show(io::IO, ::Positron) = print(io, "positron")
10-
Base.show(io::IO, ::Photon) = print(io, "photon")
11-
Base.show(io::IO, ::Incoming) = print(io, "incoming")
12-
Base.show(io::IO, ::Outgoing) = print(io, "outgoing")
13-
Base.show(io::IO, ::PolX) = print(io, "x-polarized")
14-
Base.show(io::IO, ::PolY) = print(io, "y-polarized")
15-
Base.show(io::IO, ::AllPol) = print(io, "all polarizations")
16-
Base.show(io::IO, ::SpinUp) = print(io, "spin up")
17-
Base.show(io::IO, ::SpinDown) = print(io, "spin down")
18-
Base.show(io::IO, ::AllSpin) = print(io, "all spins")
8+
Base.show(io::IO, ::QEDbase.Electron) = print(io, "electron")
9+
Base.show(io::IO, ::QEDbase.Positron) = print(io, "positron")
10+
Base.show(io::IO, ::QEDbase.Photon) = print(io, "photon")
11+
Base.show(io::IO, ::QEDbase.Incoming) = print(io, "incoming")
12+
Base.show(io::IO, ::QEDbase.Outgoing) = print(io, "outgoing")
13+
Base.show(io::IO, ::QEDbase.PolX) = print(io, "x-polarized")
14+
Base.show(io::IO, ::QEDbase.PolY) = print(io, "y-polarized")
15+
Base.show(io::IO, ::QEDbase.AllPol) = print(io, "all polarizations")
16+
Base.show(io::IO, ::QEDbase.SpinUp) = print(io, "spin up")
17+
Base.show(io::IO, ::QEDbase.SpinDown) = print(io, "spin down")
18+
Base.show(io::IO, ::QEDbase.AllSpin) = print(io, "all spins")
1919

2020
# fix: https://github.com/QEDjl-project/QEDbase.jl/pull/62
21-
Broadcast.broadcastable(dir::Incoming) = Ref(dir)
22-
Broadcast.broadcastable(dir::Outgoing) = Ref(dir)
23-
Broadcast.broadcastable(part::AbstractParticleType) = Ref(part)
24-
Broadcast.broadcastable(spin_or_pol::AbstractSpinOrPolarization) = Ref(spin_or_pol)
21+
Broadcast.broadcastable(dir::QEDbase.Incoming) = Ref(dir)
22+
Broadcast.broadcastable(dir::QEDbase.Outgoing) = Ref(dir)
23+
Broadcast.broadcastable(part::QEDbase.AbstractParticleType) = Ref(part)
24+
Broadcast.broadcastable(spin_or_pol::QEDbase.AbstractSpinOrPolarization) = Ref(spin_or_pol)
2525

2626
# fix: https://github.com/QEDjl-project/QEDbase.jl/pull/63
27-
number_of_spin_pol(::AbstractDefinitePolarization) = 1
28-
number_of_spin_pol(::AbstractDefiniteSpin) = 1
29-
number_of_spin_pol(::AbstractIndefinitePolarization) = 2
30-
number_of_spin_pol(::AbstractIndefiniteSpin) = 2
27+
number_of_spin_pol(::QEDbase.AbstractDefinitePolarization) = 1
28+
number_of_spin_pol(::QEDbase.AbstractDefiniteSpin) = 1
29+
number_of_spin_pol(::QEDbase.AbstractIndefinitePolarization) = 2
30+
number_of_spin_pol(::QEDbase.AbstractIndefiniteSpin) = 2

src/phase_spaces/access.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ momentum(part::ParticleStateful) = part.mom
2828
2929
Return a `Tuple` of all the particles' momenta for the given `ParticleDirection`.
3030
"""
31-
momenta(psp::PhaseSpacePoint, ::Incoming) = momentum.(psp.in_particles)
32-
momenta(psp::PhaseSpacePoint, ::Outgoing) = momentum.(psp.out_particles)
31+
momenta(psp::PhaseSpacePoint, ::QEDbase.Incoming) = momentum.(psp.in_particles)
32+
momenta(psp::PhaseSpacePoint, ::QEDbase.Outgoing) = momentum.(psp.out_particles)
3333

3434
"""
3535
Base.getindex(psp::PhaseSpacePoint, dir::Incoming, n::Int)
3636
3737
Overload for the array indexing operator `[]`. Returns the nth incoming particle in this phase space point.
3838
"""
39-
function Base.getindex(psp::PhaseSpacePoint, ::Incoming, n::Int)
39+
function Base.getindex(psp::PhaseSpacePoint, ::QEDbase.Incoming, n::Int)
4040
return psp.in_particles[n]
4141
end
4242

@@ -45,7 +45,7 @@ end
4545
4646
Overload for the array indexing operator `[]`. Returns the nth outgoing particle in this phase space point.
4747
"""
48-
function Base.getindex(psp::PhaseSpacePoint, ::Outgoing, n::Int)
48+
function Base.getindex(psp::PhaseSpacePoint, ::QEDbase.Outgoing, n::Int)
4949
return psp.out_particles[n]
5050
end
5151

@@ -54,6 +54,6 @@ end
5454
5555
Returns the momentum of the `n`th particle in the given [`PhaseSpacePoint`](@ref) which has direction `dir`. If `n` is outside the valid range for this phase space point, a `BoundsError` is thrown.
5656
"""
57-
function momentum(psp::PhaseSpacePoint, dir::ParticleDirection, n::Int)
57+
function momentum(psp::PhaseSpacePoint, dir::QEDbase.ParticleDirection, n::Int)
5858
return psp[dir, n].mom
5959
end

src/phase_spaces/create.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ function PhaseSpacePoint(
6262
in_momenta::NTuple{N,ELEMENT},
6363
out_momenta::NTuple{M,ELEMENT},
6464
) where {N,M,ELEMENT<:QEDbase.AbstractFourMomentum}
65-
in_particles = _build_particle_statefuls(proc, in_momenta, Incoming())
66-
out_particles = _build_particle_statefuls(proc, out_momenta, Outgoing())
65+
in_particles = _build_particle_statefuls(proc, in_momenta, QEDbase.Incoming())
66+
out_particles = _build_particle_statefuls(proc, out_momenta, QEDbase.Outgoing())
6767

6868
return PhaseSpacePoint(proc, model, ps_def, in_particles, out_particles)
6969
end
@@ -84,7 +84,7 @@ function InPhaseSpacePoint(
8484
ps_def::AbstractPhasespaceDefinition,
8585
in_momenta::NTuple{N,ELEMENT},
8686
) where {N,ELEMENT<:QEDbase.AbstractFourMomentum}
87-
in_particles = _build_particle_statefuls(proc, in_momenta, Incoming())
87+
in_particles = _build_particle_statefuls(proc, in_momenta, QEDbase.Incoming())
8888

8989
return PhaseSpacePoint(proc, model, ps_def, in_particles, ())
9090
end
@@ -105,7 +105,7 @@ function OutPhaseSpacePoint(
105105
ps_def::AbstractPhasespaceDefinition,
106106
out_momenta::NTuple{N,ELEMENT},
107107
) where {N,ELEMENT<:QEDbase.AbstractFourMomentum}
108-
out_particles = _build_particle_statefuls(proc, out_momenta, Outgoing())
108+
out_particles = _build_particle_statefuls(proc, out_momenta, QEDbase.Outgoing())
109109

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

src/phase_spaces/types.jl

+10-10
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ ParticleStateful: outgoing photon
4949
```
5050
"""
5151
struct ParticleStateful{
52-
DIR<:ParticleDirection,
53-
SPECIES<:AbstractParticleType,
52+
DIR<:QEDbase.ParticleDirection,
53+
SPECIES<:QEDbase.AbstractParticleType,
5454
ELEMENT<:QEDbase.AbstractFourMomentum,
55-
} <: AbstractParticle
55+
} <: QEDbase.AbstractParticle
5656
dir::DIR
5757
species::SPECIES
5858
mom::ELEMENT
5959

6060
function ParticleStateful(
6161
dir::DIR, species::SPECIES, mom::ELEMENT
6262
) where {
63-
DIR<:ParticleDirection,
64-
SPECIES<:AbstractParticleType,
63+
DIR<:QEDbase.ParticleDirection,
64+
SPECIES<:QEDbase.AbstractParticleType,
6565
ELEMENT<:QEDbase.AbstractFourMomentum,
6666
}
6767
return new{DIR,SPECIES,ELEMENT}(dir, species, mom)
@@ -76,19 +76,19 @@ Representation of a point in the phase space of a process. Contains the process
7676
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.
7777
7878
```jldoctest
79-
julia> using QEDprocesses; using QEDbase
79+
julia> using QEDprocesses; import QEDbase; using QEDcore
8080
8181
julia> PhaseSpacePoint(
8282
Compton(),
8383
PerturbativeQED(),
8484
PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame()),
8585
(
86-
ParticleStateful(Incoming(), Electron(), SFourMomentum(1, 0, 0, 0)),
87-
ParticleStateful(Incoming(), Photon(), SFourMomentum(1, 0, 0, 0))
86+
ParticleStateful(QEDbase.Incoming(), QEDbase.Electron(), SFourMomentum(1, 0, 0, 0)),
87+
ParticleStateful(QEDbase.Incoming(), QEDbase.Photon(), SFourMomentum(1, 0, 0, 0))
8888
),
8989
(
90-
ParticleStateful(Outgoing(), Electron(), SFourMomentum(1, 0, 0, 0)),
91-
ParticleStateful(Outgoing(), Photon(), SFourMomentum(1, 0, 0, 0))
90+
ParticleStateful(QEDbase.Outgoing(), QEDbase.Electron(), SFourMomentum(1, 0, 0, 0)),
91+
ParticleStateful(QEDbase.Outgoing(), QEDbase.Photon(), SFourMomentum(1, 0, 0, 0))
9292
)
9393
)
9494
PhaseSpacePoint:

0 commit comments

Comments
 (0)