Skip to content

Commit

Permalink
Iterate through all pols and spins for all Compton tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Reinhard authored and AntonReinhard committed Oct 13, 2023
1 parent bbb322b commit 86b319a
Showing 1 changed file with 50 additions and 52 deletions.
102 changes: 50 additions & 52 deletions test/compton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,63 @@ using Random
using QEDbase
using QEDprocesses

@testset "constructors" begin
@testset "default" begin
proc = Compton()
@test QEDprocesses._spin_or_pol(proc, Photon(), Incoming()) == AllPol()
@test QEDprocesses._spin_or_pol(proc, Electron(), Incoming()) == AllSpin()
@test QEDprocesses._spin_or_pol(proc, Photon(), Outgoing()) == AllPol()
@test QEDprocesses._spin_or_pol(proc, Electron(), Outgoing()) == AllSpin()
end
POLS = [PolX(), PolY(), AllPol()]
SPINS = [SpinUp(), SpinDown(), AllSpin()]
POL_AND_SPIN_COMBINATIONS = Iterators.product(POLS, POLS, SPINS, SPINS)

@testset "non-default" begin
pols = [PolX(), PolY(), AllPol()]
spins = [SpinUp(), SpinDown(), AllSpin()]
pol_and_spin_combinations = Iterators.product(pols, pols, spins, spins)
for (pol1, pol2, spin1, spin2) in pol_and_spin_combinations
proc = Compton((pol1, pol2), (spin1, spin2))
@test QEDprocesses._spin_or_pol(proc, Photon(), Incoming()) == pol1
@test QEDprocesses._spin_or_pol(proc, Electron(), Incoming()) == spin1
@test QEDprocesses._spin_or_pol(proc, Photon(), Outgoing()) == pol2
@test QEDprocesses._spin_or_pol(proc, Electron(), Outgoing()) == spin2
end
end
end

@testset "scattering process interface" begin
@testset "Default Compton constructor" begin
proc = Compton()
@test QEDprocesses._spin_or_pol(proc, Photon(), Incoming()) == AllPol()
@test QEDprocesses._spin_or_pol(proc, Electron(), Incoming()) == AllSpin()
@test QEDprocesses._spin_or_pol(proc, Photon(), Outgoing()) == AllPol()
@test QEDprocesses._spin_or_pol(proc, Electron(), Outgoing()) == AllSpin()
end

@test incoming_particles(proc) == (Photon(), Electron())
@test outgoing_particles(proc) == (Photon(), Electron())
@testset "Compton with ($pol1, $pol2), ($spin1, $spin2)" for (pol1, pol2, spin1, spin2) in
POL_AND_SPIN_COMBINATIONS
proc = nothing
@testset "constructor" begin
proc = Compton((pol1, pol2), (spin1, spin2))
@test QEDprocesses._spin_or_pol(proc, Photon(), Incoming()) == pol1
@test QEDprocesses._spin_or_pol(proc, Electron(), Incoming()) == spin1
@test QEDprocesses._spin_or_pol(proc, Photon(), Outgoing()) == pol2
@test QEDprocesses._spin_or_pol(proc, Electron(), Outgoing()) == spin2
end

@test number_incoming_particles(proc) == 2
@test number_outgoing_particles(proc) == 2
end
@testset "scattering process interface" begin
@test incoming_particles(proc) == (Photon(), Electron())
@test outgoing_particles(proc) == (Photon(), Electron())
@test number_incoming_particles(proc) == 2
@test number_outgoing_particles(proc) == 2
end

@testset "invalid inputs" begin
model = PerturbativeQED()
proc = Compton()
@testset "invalid inputs" begin
model = PerturbativeQED()
proc = Compton()

momenta_2 = [zero(SFourMomentum) for _ = 1:2]
momenta_3 = [zero(SFourMomentum) for _ = 1:3]
momenta_2 = [zero(SFourMomentum) for _ = 1:2]
momenta_3 = [zero(SFourMomentum) for _ = 1:3]

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

for (valid, invalid) in
Iterators.product([momenta_2, momenta_2_2], [momenta_3, momenta_3_2])
# try compute single input with incorrect dimensions
@test_throws DimensionMismatch differential_cross_section(
proc,
model,
invalid,
valid,
)
@test_throws "incoming" differential_cross_section(proc, model, invalid, valid)
@test_throws DimensionMismatch differential_cross_section(
proc,
model,
valid,
invalid,
)
@test_throws "outgoing" differential_cross_section(proc, model, valid, invalid)
for (valid, invalid) in
Iterators.product([momenta_2, momenta_2_2], [momenta_3, momenta_3_2])
# try compute single input with incorrect dimensions
@test_throws DimensionMismatch differential_cross_section(
proc,
model,
invalid,
valid,
)
@test_throws "incoming" differential_cross_section(proc, model, invalid, valid)
@test_throws DimensionMismatch differential_cross_section(
proc,
model,
valid,
invalid,
)
@test_throws "outgoing" differential_cross_section(proc, model, valid, invalid)
end
end
end

0 comments on commit 86b319a

Please sign in to comment.