Skip to content

Commit 163cdb5

Browse files
committed
Add matrix element calculation
1 parent 1cb6a37 commit 163cdb5

File tree

3 files changed

+119
-43
lines changed

3 files changed

+119
-43
lines changed

src/compton/differential_cross_section.jl

+106-39
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function _differential_cross_section(
2424
in_phase_space::AbstractVector{NumericType},
2525
out_phase_space::AbstractVector{NumericType},
2626
)::Float64 where {NumericType<:QEDbase.AbstractFourMomentum}
27-
if (!isapprox(sum(in_phase_space), sum(out_phase_space); rtol = sqrt(eps())))
27+
if (!isapprox(sum(in_phase_space), sum(out_phase_space); rtol=sqrt(eps())))
2828
return zero(Float64)
2929
end
3030

@@ -33,46 +33,14 @@ function _differential_cross_section(
3333
photon_out = out_phase_space[1]
3434
electron_out = out_phase_space[2]
3535

36-
# get base states of the particles
37-
photon_in_bstate = base_state(
38-
Photon(),
39-
Incoming(),
36+
matrix_elements_sq = _matrix_el_sq(
37+
process,
38+
model,
4039
photon_in,
41-
_spin_or_pol(process, Photon(), Incoming()),
42-
)
43-
electron_in_bstate = base_state(
44-
Electron(),
45-
Incoming(),
4640
electron_in,
47-
_spin_or_pol(process, Electron(), Incoming()),
48-
)
49-
photon_out_bstate = base_state(
50-
Photon(),
51-
Outgoing(),
5241
photon_out,
53-
_spin_or_pol(process, Photon(), Outgoing()),
54-
)
55-
electron_out_bstate = base_state(
56-
Electron(),
57-
Outgoing(),
5842
electron_out,
59-
_spin_or_pol(process, Electron(), Outgoing()),
60-
)
61-
62-
# 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
63-
base_states_comb = Iterators.product(
64-
photon_in_bstate,
65-
electron_in_bstate,
66-
photon_out_bstate,
67-
electron_out_bstate,
6843
)
69-
matrix_elements = Vector{ComplexF64}()
70-
sizehint!(matrix_elements, length(base_states_comb))
71-
for (phin, ein, phout, eout) in base_states_comb
72-
push!(matrix_elements, _perturbative_compton_matrix(phin, ein, phout, eout))
73-
end
74-
75-
matrix_elements_sq = abs2.(matrix_elements)
7644

7745
# average over incoming polarizations/spins, but sum over outgoing pols/spins
7846
normalization = 1.0 / (length(photon_in_bstate) * length(electron_in_bstate))
@@ -85,13 +53,32 @@ function _differential_cross_section(
8553
end
8654

8755
function _perturbative_compton_matrix(
56+
ph_in::NumericType,
57+
el_in::NumericType,
58+
ph_out::NumericType,
59+
el_out::NumericType,
8860
ph_in_bstate::SLorentzVector{ComplexF64},
8961
el_in_bstate::BiSpinor,
9062
ph_out_bstate::SLorentzVector{ComplexF64},
9163
el_out_bstate::AdjointBiSpinor,
92-
)
93-
# TODO
94-
return zero(ComplexF64)
64+
) where {NumericType<:QEDbase.AbstractFourMomentum}
65+
ph_in_slashed = slashed(ph_in_bstate)
66+
ph_out_slashed = slashed(ph_out_bstate)
67+
68+
# TODO: fermion propagator is not yet in QEDbase
69+
diagram_1 = ph_out_slashed * _fermion_propagator(ph_in + el_in, mass(Electron())) * ph_in_slashed
70+
diagram_2 = ph_in_slashed * _fermion_propagator(el_in - ph_out, mass(Electron())) * ph_out_slashed
71+
72+
result = diagram_1 + diagram_2
73+
result = result * el_in_bstate
74+
result = el_out_bstate * result
75+
76+
# TODO: find (preferably unitful) global provider for physical constants
77+
# elementary charge
78+
alpha = 1 / 137.035999084
79+
e = sqrt(4 * pi * alpha)
80+
81+
return -e * e * result
9582
end
9683

9784
function _phase_space_factor(
@@ -114,3 +101,83 @@ function _post_process_dcs(
114101
# generally nothing to be done here
115102
return result
116103
end
104+
105+
function _matrix_el(
106+
process::Compton{InPol,InSpin,OutPol,OutSpin},
107+
model::PerturbativeQED,
108+
photon_in::NumericType,
109+
electron_in::NumericType,
110+
photon_out::NumericType,
111+
electron_out::NumericType,
112+
) where {
113+
InPol<:AbstractPolarization,
114+
InSpin<:AbstractSpin,
115+
OutPol<:AbstractPolarization,
116+
OutSpin<:AbstractSpin,
117+
NumericType<:QEDbase.AbstractFourMomentum
118+
}
119+
# get base states of the particles
120+
photon_in_bstate = Vector{SLorentzVector{ComplexF64}}(base_state(
121+
Photon(),
122+
Incoming(),
123+
photon_in,
124+
_spin_or_pol(process, Photon(), Incoming()),
125+
))
126+
electron_in_bstate = Vector{BiSpinor}(base_state(
127+
Electron(),
128+
Incoming(),
129+
electron_in,
130+
_spin_or_pol(process, Electron(), Incoming()),
131+
))
132+
photon_out_bstate = Vector{SLorentzVector{ComplexF64}}(base_state(
133+
Photon(),
134+
Outgoing(),
135+
photon_out,
136+
_spin_or_pol(process, Photon(), Outgoing()),
137+
))
138+
electron_out_bstate = Vector{AdjointBiSpinor}(base_state(
139+
Electron(),
140+
Outgoing(),
141+
electron_out,
142+
_spin_or_pol(process, Electron(), Outgoing()),
143+
))
144+
145+
# 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
146+
base_states_comb =
147+
Iterators.product(photon_in_bstate, electron_in_bstate, photon_out_bstate, electron_out_bstate)
148+
matrix_elements = Vector{ComplexF64}()
149+
sizehint!(matrix_elements, length(base_states_comb))
150+
for (ph_in, el_in, ph_out, el_out) in base_states_comb
151+
push!(matrix_elements, _perturbative_compton_matrix(photon_in, electron_in, photon_out, electron_out, ph_in, el_in, ph_out, el_out))
152+
end
153+
154+
return matrix_elements
155+
end
156+
157+
function _matrix_el_sq(
158+
process::Compton{InPol,InSpin,OutPol,OutSpin},
159+
model::PerturbativeQED,
160+
photon_in::NumericType,
161+
electron_in::NumericType,
162+
photon_out::NumericType,
163+
electron_out::NumericType,
164+
) where {
165+
NumericType<:QEDbase.AbstractFourMomentum,
166+
InPol<:AbstractPolarization,
167+
InSpin<:AbstractSpin,
168+
OutPol<:AbstractPolarization,
169+
OutSpin<:AbstractSpin,
170+
}
171+
return abs2.(
172+
_matrix_el(process, model, photon_in, electron_in, photon_out, electron_out)
173+
)
174+
end
175+
176+
# TODO: should be implemented in QEDbase instead
177+
function _fermion_propagator(mom::QEDbase.AbstractFourMomentum, mass::Float64)
178+
slashed_mom = slashed(mom)
179+
180+
i = ComplexF64(0.0, 1.0)
181+
# might not be correct, but this is just a mock implementation to have something to test until its available from QEDbase
182+
return (i * (slashed_mom + mass * one(DiracMatrix))) / (mom * mom - mass * mass)
183+
end

src/interfaces/process_interface.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ function total_cross_section(
258258
) where {T<:QEDbase.AbstractFourMomentum}
259259
size(in_phasespace, 1) == number_incoming_particles(proc_def) || throw(
260260
DimensionMismatch(
261-
"The number of momenta in the initial phasespace <{length(in_phasespace)}> does not match the number of incoming particles of the process <{number_incoming_particles(proc_def)}>.",
261+
"The number of momenta in the initial phasespace $(length(in_phasespace)) does not match the number of incoming particles of the process $(number_incoming_particles(proc_def)).",
262262
),
263263
)
264264
return _total_cross_section(proc_def, model_def, in_phasespace)

test/compton.jl

+12-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ end
3232
@test number_outgoing_particles(proc) == 2
3333
end
3434

35-
@testset "invalid inputs" begin
36-
model = PerturbativeQED()
37-
proc = Compton()
35+
model = PerturbativeQED()
36+
proc = Compton((pol1, pol2), (spin1, spin2))
3837

38+
@testset "invalid inputs" begin
3939
momenta_2 = [zero(SFourMomentum) for _ = 1:2]
4040
momenta_3 = [zero(SFourMomentum) for _ = 1:3]
4141

@@ -61,4 +61,13 @@ end
6161
@test_throws "outgoing" differential_cross_section(proc, model, valid, invalid)
6262
end
6363
end
64+
65+
#= See https://github.com/QEDjl-project/QEDbase.jl/issues/36
66+
@testset "valid inputs" begin
67+
momenta_in = [SFourMomentum(1.0, 0.0, 0.0, 0.0), SFourMomentum(1.0, 0.0, 0.0, 0.0)]
68+
momenta_out = [SFourMomentum(1.0, 0.0, 0.0, 0.0), SFourMomentum(1.0, 0.0, 0.0, 0.0)]
69+
70+
differential_cross_section(proc, model, momenta_in, momenta_out)
71+
end
72+
=#
6473
end

0 commit comments

Comments
 (0)