Skip to content

Commit db41346

Browse files
author
AntonReinhard
committed
Format
1 parent 5a9631d commit db41346

File tree

3 files changed

+94
-20
lines changed

3 files changed

+94
-20
lines changed

src/compton/differential_cross_section.jl

+47-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function _differential_cross_section(
1616
in_phase_space::AbstractVector{NumericType},
1717
out_phase_space::AbstractVector{NumericType},
1818
)::Float64 where {NumericType<:QEDbase.AbstractFourMomentum}
19-
if (!isapprox(sum(in_phase_space), sum(out_phase_space); rtol=sqrt(eps())))
19+
if (!isapprox(sum(in_phase_space), sum(out_phase_space); rtol = sqrt(eps())))
2020
return zero(Float64)
2121
end
2222

@@ -26,13 +26,38 @@ function _differential_cross_section(
2626
electron_out = out_phase_space[2]
2727

2828
# get base states of the particles
29-
photon_in_bstate = base_state(Photon(), Incoming(), photon_in, _spin_or_pol(process, Photon(), Incoming()))
30-
electron_in_bstate = base_state(Electron(), Incoming(), electron_in, _spin_or_pol(process, Electron(), Incoming()))
31-
photon_out_bstate = base_state(Photon(), Outgoing(), photon_out, _spin_or_pol(process, Photon(), Outgoing()))
32-
electron_out_bstate = base_state(Electron(), Outgoing(), electron_out, _spin_or_pol(process, Electron(), Outgoing()))
29+
photon_in_bstate = base_state(
30+
Photon(),
31+
Incoming(),
32+
photon_in,
33+
_spin_or_pol(process, Photon(), Incoming()),
34+
)
35+
electron_in_bstate = base_state(
36+
Electron(),
37+
Incoming(),
38+
electron_in,
39+
_spin_or_pol(process, Electron(), Incoming()),
40+
)
41+
photon_out_bstate = base_state(
42+
Photon(),
43+
Outgoing(),
44+
photon_out,
45+
_spin_or_pol(process, Photon(), Outgoing()),
46+
)
47+
electron_out_bstate = base_state(
48+
Electron(),
49+
Outgoing(),
50+
electron_out,
51+
_spin_or_pol(process, Electron(), Outgoing()),
52+
)
3353

3454
# if the particles had AllSpin or AllPol, the base states can be vectors and we need to consider every combination of the base states with each other
35-
base_states_comb = Iterators.product(photon_in_bstate, electron_in_bstate, photon_out_bstate, electron_out_bstate)
55+
base_states_comb = Iterators.product(
56+
photon_in_bstate,
57+
electron_in_bstate,
58+
photon_out_bstate,
59+
electron_out_bstate,
60+
)
3661
matrix_elements = Vector{ComplexF64}()
3762
sizehint!(matrix_elements, length(base_states_comb))
3863
for (phin, ein, phout, eout) in base_states_comb
@@ -45,15 +70,28 @@ function _differential_cross_section(
4570
normalization = 1.0 / (length(photon_in_bstate) * length(electron_in_bstate))
4671
I = photon_in * electron_in
4772

48-
return I * normalization * sum(matrix_elements_sq) * _phase_space_factor(photon_in, electron_in, photon_out, electron_out)
73+
return I *
74+
normalization *
75+
sum(matrix_elements_sq) *
76+
_phase_space_factor(photon_in, electron_in, photon_out, electron_out)
4977
end
5078

51-
function _perturbative_compton_matrix(ph_in_bstate::SLorentzVector{ComplexF64}, el_in_bstate::BiSpinor, ph_out_bstate::SLorentzVector{ComplexF64}, el_out_bstate::AdjointBiSpinor)
79+
function _perturbative_compton_matrix(
80+
ph_in_bstate::SLorentzVector{ComplexF64},
81+
el_in_bstate::BiSpinor,
82+
ph_out_bstate::SLorentzVector{ComplexF64},
83+
el_out_bstate::AdjointBiSpinor,
84+
)
5285
# TODO
5386
return zero(ComplexF64)
5487
end
5588

56-
function _phase_space_factor(ph_in::NumericType, el_in::NumericType, ph_out::NumericType, el_out::NumericType) where {NumericType<:QEDbase.AbstractFourMomentum}
89+
function _phase_space_factor(
90+
ph_in::NumericType,
91+
el_in::NumericType,
92+
ph_out::NumericType,
93+
el_out::NumericType,
94+
) where {NumericType<:QEDbase.AbstractFourMomentum}
5795
# TODO
5896
return zero(ComplexF64)
5997
end

src/compton/scattering_process.jl

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
Type for a Compton scattering process. The Compton process is parametrized with the types of [`AbstractPolarization`](@ref) and [`AbstractSpin`](@ref) used for the incoming and outgoing particles.
1111
This type implements the [`AbstractScatteringProcess`](@ref) interface. It can be used with [`DifferentialCrossSection`](@ref) to calculate differential cross sections of Compton scattering events.
1212
"""
13-
struct Compton{InPhotonPol,InElectronSpin,OutPhotonPol,OutElectronSpin} <: AbstractScatteringProcess where {
13+
struct Compton{InPhotonPol,InElectronSpin,OutPhotonPol,OutElectronSpin} <:
14+
AbstractScatteringProcess where {
1415
InPhotonPol<:AbstractPolarization,
1516
InElectronSpin<:AbstractSpin,
1617
OutPhotonPol<:AbstractPolarization,
@@ -29,7 +30,13 @@ const ComptonDCS = DifferentialCrossSection{
2930
Compton{P1,S1,P2,S2},
3031
PerturbativeQED,
3132
PhaseSpace,
32-
} where {P1<:AbstractPolarization,S1<:AbstractSpin,P2<:AbstractPolarization,S2<:AbstractSpin,PhaseSpace<:AbstractArray{SFourMomentum}}
33+
} where {
34+
P1<:AbstractPolarization,
35+
S1<:AbstractSpin,
36+
P2<:AbstractPolarization,
37+
S2<:AbstractSpin,
38+
PhaseSpace<:AbstractArray{SFourMomentum},
39+
}
3340

3441
"""
3542
$(TYPEDSIGNATURES)

test/compton.jl

+38-9
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,51 @@ end
3434
model = PerturbativeQED()
3535
proc = Compton()
3636

37-
momenta_2 = [zero(SFourMomentum) for _ in 1:2]
38-
momenta_3 = [zero(SFourMomentum) for _ in 1:3]
37+
momenta_2 = [zero(SFourMomentum) for _ = 1:2]
38+
momenta_3 = [zero(SFourMomentum) for _ = 1:3]
3939

4040
momenta_2_2 = Matrix{SFourMomentum}(undef, 2, 2)
4141
momenta_3_2 = Matrix{SFourMomentum}(undef, 3, 2)
4242

4343
# try compute single input with incorrect dimensions
44-
@test_throws DimensionMismatch differential_cross_section(proc, model, momenta_3, momenta_2)
44+
@test_throws DimensionMismatch differential_cross_section(
45+
proc,
46+
model,
47+
momenta_3,
48+
momenta_2,
49+
)
4550
@test_throws "incoming" differential_cross_section(proc, model, momenta_3, momenta_2)
46-
@test_throws DimensionMismatch differential_cross_section(proc, model, momenta_2, momenta_3)
51+
@test_throws DimensionMismatch differential_cross_section(
52+
proc,
53+
model,
54+
momenta_2,
55+
momenta_3,
56+
)
4757
@test_throws "outgoing" differential_cross_section(proc, model, momenta_2, momenta_3)
4858

4959
# try compute multiple inputs with incorrect dimensions
50-
@test_throws DimensionMismatch differential_cross_section(proc, model, momenta_3_2, momenta_2_2)
51-
@test_throws "incoming" differential_cross_section(proc, model, momenta_3_2, momenta_2_2)
52-
@test_throws DimensionMismatch differential_cross_section(proc, model, momenta_2_2, momenta_3_2)
53-
@test_throws "outgoing" differential_cross_section(proc, model, momenta_2_2, momenta_3_2)
60+
@test_throws DimensionMismatch differential_cross_section(
61+
proc,
62+
model,
63+
momenta_3_2,
64+
momenta_2_2,
65+
)
66+
@test_throws "incoming" differential_cross_section(
67+
proc,
68+
model,
69+
momenta_3_2,
70+
momenta_2_2,
71+
)
72+
@test_throws DimensionMismatch differential_cross_section(
73+
proc,
74+
model,
75+
momenta_2_2,
76+
momenta_3_2,
77+
)
78+
@test_throws "outgoing" differential_cross_section(
79+
proc,
80+
model,
81+
momenta_2_2,
82+
momenta_3_2,
83+
)
5484
end
55-

0 commit comments

Comments
 (0)