Skip to content

Commit be7636c

Browse files
author
Anton Reinhard
committed
Uncomment and fix Compton tests
1 parent 9bbf370 commit be7636c

File tree

2 files changed

+28
-40
lines changed

2 files changed

+28
-40
lines changed

src/compton/differential_cross_section.jl

+23-37
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,19 @@ function _differential_cross_section(
3838
)
3939

4040
# TODO: replace this with some less computationally intensive way to figure out how many states there are
41-
photon_in_bstate = Vector{SLorentzVector{ComplexF64}}(
42-
base_state(
43-
Photon(), Incoming(), photon_in, _spin_or_pol(process, Photon(), Incoming())
44-
),
41+
photon_in_bstate = base_state(
42+
Photon(), Incoming(), photon_in, _spin_or_pol(process, Photon(), Incoming())
4543
)
46-
electron_in_bstate = Vector{BiSpinor}(
47-
base_state(
48-
Electron(),
49-
Incoming(),
50-
electron_in,
51-
_spin_or_pol(process, Electron(), Incoming()),
52-
),
44+
electron_in_bstate = base_state(
45+
Electron(), Incoming(), electron_in, _spin_or_pol(process, Electron(), Incoming())
5346
)
5447

5548
# average over incoming polarizations/spins, but sum over outgoing pols/spins
56-
normalization = 1.0 / (length(photon_in_bstate) * length(electron_in_bstate))
49+
normalization =
50+
1.0 / (
51+
length(QEDbase._as_svec(photon_in_bstate)) *
52+
length(QEDbase._as_svec(electron_in_bstate))
53+
)
5754
I = photon_in * electron_in
5855

5956
return I *
@@ -67,9 +64,9 @@ function _perturbative_compton_matrix(
6764
el_in::NumericType,
6865
ph_out::NumericType,
6966
el_out::NumericType,
70-
ph_in_bstate::SLorentzVector{ComplexF64},
67+
ph_in_bstate::SLorentzVector,
7168
el_in_bstate::BiSpinor,
72-
ph_out_bstate::SLorentzVector{ComplexF64},
69+
ph_out_bstate::SLorentzVector,
7370
el_out_bstate::AdjointBiSpinor,
7471
) where {NumericType<:QEDbase.AbstractFourMomentum}
7572
ph_in_slashed = slashed(ph_in_bstate)
@@ -130,36 +127,25 @@ function _matrix_el(
130127
NumericType<:QEDbase.AbstractFourMomentum,
131128
}
132129
# get base states of the particles
133-
photon_in_bstate = Vector{SLorentzVector{ComplexF64}}(
134-
base_state(
135-
Photon(), Incoming(), photon_in, _spin_or_pol(process, Photon(), Incoming())
136-
),
130+
photon_in_bstate = base_state(
131+
Photon(), Incoming(), photon_in, _spin_or_pol(process, Photon(), Incoming())
137132
)
138-
electron_in_bstate = Vector{BiSpinor}(
139-
base_state(
140-
Electron(),
141-
Incoming(),
142-
electron_in,
143-
_spin_or_pol(process, Electron(), Incoming()),
144-
),
133+
electron_in_bstate = base_state(
134+
Electron(), Incoming(), electron_in, _spin_or_pol(process, Electron(), Incoming())
145135
)
146-
photon_out_bstate = Vector{SLorentzVector{ComplexF64}}(
147-
base_state(
148-
Photon(), Outgoing(), photon_out, _spin_or_pol(process, Photon(), Outgoing())
149-
),
136+
photon_out_bstate = base_state(
137+
Photon(), Outgoing(), photon_out, _spin_or_pol(process, Photon(), Outgoing())
150138
)
151-
electron_out_bstate = Vector{AdjointBiSpinor}(
152-
base_state(
153-
Electron(),
154-
Outgoing(),
155-
electron_out,
156-
_spin_or_pol(process, Electron(), Outgoing()),
157-
),
139+
electron_out_bstate = base_state(
140+
Electron(), Outgoing(), electron_out, _spin_or_pol(process, Electron(), Outgoing())
158141
)
159142

160143
# 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
161144
base_states_comb = Iterators.product(
162-
photon_in_bstate, electron_in_bstate, photon_out_bstate, electron_out_bstate
145+
QEDbase._as_svec(photon_in_bstate),
146+
QEDbase._as_svec(electron_in_bstate),
147+
QEDbase._as_svec(photon_out_bstate),
148+
QEDbase._as_svec(electron_out_bstate),
163149
)
164150
matrix_elements = Vector{ComplexF64}()
165151
sizehint!(matrix_elements, length(base_states_comb))

test/compton.jl

+5-3
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ end
6363
end
6464
end
6565

66-
#= See https://github.com/QEDjl-project/QEDbase.jl/issues/36
6766
@testset "valid inputs" begin
6867
momenta_in = [SFourMomentum(1.0, 0.0, 0.0, 0.0), SFourMomentum(1.0, 0.0, 0.0, 0.0)]
6968
momenta_out = [SFourMomentum(1.0, 0.0, 0.0, 0.0), SFourMomentum(1.0, 0.0, 0.0, 0.0)]
7069

71-
differential_cross_section(proc, model, momenta_in, momenta_out)
70+
@test isapprox(
71+
differential_cross_section(proc, model, momenta_in, momenta_out),
72+
0.0;
73+
atol=eps(Float64),
74+
)
7275
end
73-
=#
7476
end

0 commit comments

Comments
 (0)