Skip to content

Commit deb0a04

Browse files
committed
Add matrix element calculation
1 parent 1cb6a37 commit deb0a04

File tree

3 files changed

+147
-47
lines changed

3 files changed

+147
-47
lines changed

src/compton/differential_cross_section.jl

+134-43
Original file line numberDiff line numberDiff line change
@@ -33,46 +33,8 @@ 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(),
40-
photon_in,
41-
_spin_or_pol(process, Photon(), Incoming()),
42-
)
43-
electron_in_bstate = base_state(
44-
Electron(),
45-
Incoming(),
46-
electron_in,
47-
_spin_or_pol(process, Electron(), Incoming()),
48-
)
49-
photon_out_bstate = base_state(
50-
Photon(),
51-
Outgoing(),
52-
photon_out,
53-
_spin_or_pol(process, Photon(), Outgoing()),
54-
)
55-
electron_out_bstate = base_state(
56-
Electron(),
57-
Outgoing(),
58-
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,
68-
)
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)
36+
matrix_elements_sq =
37+
_matrix_el_sq(process, model, photon_in, electron_in, photon_out, electron_out)
7638

7739
# average over incoming polarizations/spins, but sum over outgoing pols/spins
7840
normalization = 1.0 / (length(photon_in_bstate) * length(electron_in_bstate))
@@ -85,13 +47,38 @@ function _differential_cross_section(
8547
end
8648

8749
function _perturbative_compton_matrix(
50+
ph_in::NumericType,
51+
el_in::NumericType,
52+
ph_out::NumericType,
53+
el_out::NumericType,
8854
ph_in_bstate::SLorentzVector{ComplexF64},
8955
el_in_bstate::BiSpinor,
9056
ph_out_bstate::SLorentzVector{ComplexF64},
9157
el_out_bstate::AdjointBiSpinor,
92-
)
93-
# TODO
94-
return zero(ComplexF64)
58+
) where {NumericType<:QEDbase.AbstractFourMomentum}
59+
ph_in_slashed = slashed(ph_in_bstate)
60+
ph_out_slashed = slashed(ph_out_bstate)
61+
62+
# TODO: fermion propagator is not yet in QEDbase
63+
diagram_1 =
64+
ph_out_slashed *
65+
_fermion_propagator(ph_in + el_in, mass(Electron())) *
66+
ph_in_slashed
67+
diagram_2 =
68+
ph_in_slashed *
69+
_fermion_propagator(el_in - ph_out, mass(Electron())) *
70+
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,107 @@ 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}}(
121+
base_state(
122+
Photon(),
123+
Incoming(),
124+
photon_in,
125+
_spin_or_pol(process, Photon(), Incoming()),
126+
),
127+
)
128+
electron_in_bstate = Vector{BiSpinor}(
129+
base_state(
130+
Electron(),
131+
Incoming(),
132+
electron_in,
133+
_spin_or_pol(process, Electron(), Incoming()),
134+
),
135+
)
136+
photon_out_bstate = Vector{SLorentzVector{ComplexF64}}(
137+
base_state(
138+
Photon(),
139+
Outgoing(),
140+
photon_out,
141+
_spin_or_pol(process, Photon(), Outgoing()),
142+
),
143+
)
144+
electron_out_bstate = Vector{AdjointBiSpinor}(
145+
base_state(
146+
Electron(),
147+
Outgoing(),
148+
electron_out,
149+
_spin_or_pol(process, Electron(), Outgoing()),
150+
),
151+
)
152+
153+
# 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
154+
base_states_comb = Iterators.product(
155+
photon_in_bstate,
156+
electron_in_bstate,
157+
photon_out_bstate,
158+
electron_out_bstate,
159+
)
160+
matrix_elements = Vector{ComplexF64}()
161+
sizehint!(matrix_elements, length(base_states_comb))
162+
for (ph_in, el_in, ph_out, el_out) in base_states_comb
163+
push!(
164+
matrix_elements,
165+
_perturbative_compton_matrix(
166+
photon_in,
167+
electron_in,
168+
photon_out,
169+
electron_out,
170+
ph_in,
171+
el_in,
172+
ph_out,
173+
el_out,
174+
),
175+
)
176+
end
177+
178+
return matrix_elements
179+
end
180+
181+
function _matrix_el_sq(
182+
process::Compton{InPol,InSpin,OutPol,OutSpin},
183+
model::PerturbativeQED,
184+
photon_in::NumericType,
185+
electron_in::NumericType,
186+
photon_out::NumericType,
187+
electron_out::NumericType,
188+
) where {
189+
NumericType<:QEDbase.AbstractFourMomentum,
190+
InPol<:AbstractPolarization,
191+
InSpin<:AbstractSpin,
192+
OutPol<:AbstractPolarization,
193+
OutSpin<:AbstractSpin,
194+
}
195+
return abs2.(
196+
_matrix_el(process, model, photon_in, electron_in, photon_out, electron_out)
197+
)
198+
end
199+
200+
# TODO: should be implemented in QEDbase instead
201+
function _fermion_propagator(mom::QEDbase.AbstractFourMomentum, mass::Float64)
202+
slashed_mom = slashed(mom)
203+
204+
i = ComplexF64(0.0, 1.0)
205+
# might not be correct, but this is just a mock implementation to have something to test until its available from QEDbase
206+
return (i * (slashed_mom + mass * one(DiracMatrix))) / (mom * mom - mass * mass)
207+
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)