From 1bb3c49bc833b373bb045b80ae7ecf84c4f6dd9b Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Mon, 19 Aug 2024 15:32:44 +0200 Subject: [PATCH 1/5] Add GenericQEDProcess definition --- src/QEDprocesses.jl | 9 ++-- .../perturbative/cross_section.jl | 22 +++++++++ src/processes/generic_process/process.jl | 49 +++++++++++++++++++ src/processes/generic_process/utility.jl | 11 +++++ .../perturbative/cross_section.jl | 6 +-- .../perturbative/total_probability.jl | 2 +- 6 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 src/processes/generic_process/perturbative/cross_section.jl create mode 100644 src/processes/generic_process/process.jl create mode 100644 src/processes/generic_process/utility.jl diff --git a/src/QEDprocesses.jl b/src/QEDprocesses.jl index 528d1c9..c8d9084 100644 --- a/src/QEDprocesses.jl +++ b/src/QEDprocesses.jl @@ -4,14 +4,12 @@ module QEDprocesses export ALPHA, ALPHA_SQUARE, ELEMENTARY_CHARGE, ELEMENTARY_CHARGE_SQUARE, ELECTRONMASS, ONE_OVER_FOURPI -# propagator -export propagator - # specific compute models export PerturbativeQED # specific scattering processes export Compton, omega_prime +export GenericQEDProcess, isphysical using QEDbase using QEDcore @@ -23,6 +21,11 @@ include("utils.jl") include("models/models.jl") +# generic qed process +include("processes/generic_process/utility.jl") +include("processes/generic_process/process.jl") +include("processes/generic_process/perturbative/cross_section.jl") + # one photon compton include("processes/one_photon_compton/process.jl") include("processes/one_photon_compton/perturbative/kinematics.jl") diff --git a/src/processes/generic_process/perturbative/cross_section.jl b/src/processes/generic_process/perturbative/cross_section.jl new file mode 100644 index 0000000..085ed09 --- /dev/null +++ b/src/processes/generic_process/perturbative/cross_section.jl @@ -0,0 +1,22 @@ +# None of these functions are currently implemented. +# They will be implemented using the QEDFeynmanDiagrams project when that is released. + +#= +function QEDbase._incident_flux(psp::InPhaseSpacePoint{<:GenericQEDProcess,PerturbativeQED}) end + +function QEDbase._matrix_element(psp::PhaseSpacePoint{<:GenericQEDProcess,PerturbativeQED}) + proc = process(psp) + # by using FeynmanDiagramGenerator.jl + return sqrt(proc.matrix_element_squared(psp)) +end + +function QEDbase._averaging_norm(proc::<:GenericQEDProcess) end + +function QEDbase._is_in_phasespace(psp::PhaseSpacePoint{<:GenericQEDProcess,PerturbativeQED}) end + +function QEDbase._phase_space_factor( + psp::PhaseSpacePoint{<:GenericQEDProcess,PerturbativeQED,CustomPhasespaceDefinition} +) end + +function QEDbase._total_probability(in_psp::InPhaseSpacePoint{<:GenericQEDProcess,PerturbativeQED}) end +=# diff --git a/src/processes/generic_process/process.jl b/src/processes/generic_process/process.jl new file mode 100644 index 0000000..031cad8 --- /dev/null +++ b/src/processes/generic_process/process.jl @@ -0,0 +1,49 @@ +mutable struct GenericQEDProcess{INT,OUTT,INSP,OUTSP} <: AbstractProcessDefinition where { + INT<:Tuple,OUTT<:Tuple,INSP<:Tuple,OUTSP<:Tuple +} + incoming_particles::INT + outgoing_particles::OUTT + + incoming_spins_pols::INSP + outgoing_spins_pols::OUTSP + + matrix_element_squared::Function + + function GenericQEDProcess( + in_particles::INT, out_particles::OUTT, in_sp::INSP, out_sp::OUTSP + ) where {INT<:Tuple,OUTT<:Tuple,INSP<:Tuple,OUTSP<:Tuple} + _assert_particle_type_tuple(in_particles) + _assert_particle_type_tuple(out_particles) + + return new{INT,OUTT,INSP,OUTSP}( + in_particles, out_particles, in_sp, out_sp, _ -> error("unimplemented") + ) + end +end + +function QEDbase.incoming_particles(proc::GenericQEDProcess) + return proc.incoming_particles +end +function QEDbase.outgoing_particles(proc::GenericQEDProcess) + return proc.outgoing_particles +end +function QEDbase.incoming_spin_pols(proc::GenericQEDProcess) + return proc.incoming_spins_pols +end +function QEDbase.outgoing_spin_pols(proc::GenericQEDProcess) + return proc.outgoing_spins_pols +end + +""" + isphysical(proc::GenericQEDProcess) + +A utility function that returns whether a given GenericQEDProcess conserves the number and charge of fermions and has at least 2 participating particles. +""" +function isphysical(proc::GenericQEDProcess) + return ( + number_particles(proc, Incoming(), Electron()) + + number_particles(proc, Outgoing(), Positron()) == + number_particles(proc, Incoming(), Positron()) + + number_particles(proc, Outgoing(), Electron()) + ) && number_particles(proc, Incoming()) + number_particles(proc, Outgoing()) >= 2 +end diff --git a/src/processes/generic_process/utility.jl b/src/processes/generic_process/utility.jl new file mode 100644 index 0000000..86d1bc0 --- /dev/null +++ b/src/processes/generic_process/utility.jl @@ -0,0 +1,11 @@ +_assert_particle_type_tuple(::Tuple{}) = nothing +function _assert_particle_type_tuple(t::Tuple{AbstractParticleType,Vararg}) + return _assert_particle_type_tuple(t[2:end]) +end +function _assert_particle_type_tuple(t::Any) + throw( + InvalidInputError( + "invalid input, provide a tuple of AbstractParticleTypes to construct a QEDProcess", + ), + ) +end diff --git a/src/processes/one_photon_compton/perturbative/cross_section.jl b/src/processes/one_photon_compton/perturbative/cross_section.jl index ead1f28..5464339 100644 --- a/src/processes/one_photon_compton/perturbative/cross_section.jl +++ b/src/processes/one_photon_compton/perturbative/cross_section.jl @@ -3,7 +3,7 @@ # Implementation of the cross section interface ##### -function QEDbase._incident_flux(in_psp::InPhaseSpacePoint{<:Compton,<:PerturbativeQED}) +function QEDbase._incident_flux(in_psp::InPhaseSpacePoint{<:Compton,PerturbativeQED}) return momentum(in_psp, Incoming(), 1) * momentum(in_psp, Incoming(), 2) end @@ -39,9 +39,7 @@ end ) end -@inline function QEDbase._is_in_phasespace( - psp::PhaseSpacePoint{<:Compton,<:PerturbativeQED} -) +@inline function QEDbase._is_in_phasespace(psp::PhaseSpacePoint{<:Compton,PerturbativeQED}) @inbounds if ( !isapprox( momentum(psp, Incoming(), 1) + momentum(psp, Incoming(), 2), diff --git a/src/processes/one_photon_compton/perturbative/total_probability.jl b/src/processes/one_photon_compton/perturbative/total_probability.jl index e3cca7e..838a730 100644 --- a/src/processes/one_photon_compton/perturbative/total_probability.jl +++ b/src/processes/one_photon_compton/perturbative/total_probability.jl @@ -1,4 +1,4 @@ -function QEDbase._total_probability(in_psp::InPhaseSpacePoint{<:Compton,<:PerturbativeQED}) +function QEDbase._total_probability(in_psp::InPhaseSpacePoint{<:Compton,PerturbativeQED}) omega = getE(momentum(in_psp[Incoming(), 2])) function func(x) From 3f67b0fde56fe781e9f4be93234b248f8b3d8e6f Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Mon, 19 Aug 2024 17:09:03 +0200 Subject: [PATCH 2/5] Add tests for generic process --- src/processes/generic_process/process.jl | 98 ++++++++- src/processes/generic_process/utility.jl | 36 +++- .../processes/generic_process/groundtruths.jl | 25 +++ test/processes/generic_process/process.jl | 197 ++++++++++++++++++ test/processes/run_process_test.jl | 3 + 5 files changed, 348 insertions(+), 11 deletions(-) create mode 100644 test/processes/generic_process/groundtruths.jl create mode 100644 test/processes/generic_process/process.jl diff --git a/src/processes/generic_process/process.jl b/src/processes/generic_process/process.jl index 031cad8..f426fa0 100644 --- a/src/processes/generic_process/process.jl +++ b/src/processes/generic_process/process.jl @@ -1,26 +1,73 @@ -mutable struct GenericQEDProcess{INT,OUTT,INSP,OUTSP} <: AbstractProcessDefinition where { - INT<:Tuple,OUTT<:Tuple,INSP<:Tuple,OUTSP<:Tuple -} +""" + GenericQEDProcess <: AbstractProcessDefinition + +An implementation of the `AbstractProcessDefinition` interface for a generic particle process in QED +with any number of incoming and outgoing particles, and any combination of spins or polarizations for the particles set. + +The [`isphysical`](@ref) function can be used to check whether the process is possible in QED. + +!!! note + The computation of cross sections and probabilities is currently unimplemented. +""" +struct GenericQEDProcess{INT,OUTT,INSP,OUTSP} <: + AbstractProcessDefinition where {INT<:Tuple,OUTT<:Tuple,INSP<:Tuple,OUTSP<:Tuple} incoming_particles::INT outgoing_particles::OUTT - incoming_spins_pols::INSP - outgoing_spins_pols::OUTSP + incoming_spin_pols::INSP + outgoing_spin_pols::OUTSP - matrix_element_squared::Function + """ + GenericQEDProcess( + in_particles::Tuple{AbstractParticleType}, + out_particles::Tuple{AbstractParticleType}, + in_sp::Tuple{AbstractSpinOrPolarization}, + out_sp::Tuple{AbstractSpinOrPolarization} + ) + Constructor for a GenericQEDProcess with the given incoming and outgoing particles and their respective spins and pols. + The constructor asserts that the particles are compatible with their respective spins and polarizations. If the assertion fails, an + `InvalidInputError` is thrown. + """ function GenericQEDProcess( - in_particles::INT, out_particles::OUTT, in_sp::INSP, out_sp::OUTSP + in_particles::INT, out_particles::OUTT, in_spin_pols::INSP, out_spin_pols::OUTSP ) where {INT<:Tuple,OUTT<:Tuple,INSP<:Tuple,OUTSP<:Tuple} _assert_particle_type_tuple(in_particles) _assert_particle_type_tuple(out_particles) + _assert_spin_pol_particle_compatability(in_particles, in_spin_pols) + _assert_spin_pol_particle_compatability(out_particles, out_spin_pols) + return new{INT,OUTT,INSP,OUTSP}( - in_particles, out_particles, in_sp, out_sp, _ -> error("unimplemented") + in_particles, out_particles, in_spin_pols, out_spin_pols ) end end +""" + GenericQEDProcess(in_particles::Tuple{AbstractParticleType}, out_particles::Tuple{AbstractParticleType}) + +Constructor for a GenericQEDProcess, setting `AllPol` and `AllSpin` for every boson and fermion, respectively. +""" +function GenericQEDProcess( + in_particles::INT, out_particles::OUTT +) where {INT<:Tuple,OUTT<:Tuple} + # this will be called again by the default constructor, but it produces a nicer warning here + # than the following spin/pol generation failing because is_fermion or is_boson isn't defined on not allowed types + _assert_particle_type_tuple(in_particles) + _assert_particle_type_tuple(out_particles) + + in_spin_pols = ntuple( + x -> is_fermion(in_particles[x]) ? AllSpin() : AllPolarization(), + length(in_particles), + ) + out_spin_pols = ntuple( + x -> is_fermion(out_particles[x]) ? AllSpin() : AllPolarization(), + length(out_particles), + ) + return GenericQEDProcess(in_particles, out_particles, in_spin_pols, out_spin_pols) +end + function QEDbase.incoming_particles(proc::GenericQEDProcess) return proc.incoming_particles end @@ -28,10 +75,10 @@ function QEDbase.outgoing_particles(proc::GenericQEDProcess) return proc.outgoing_particles end function QEDbase.incoming_spin_pols(proc::GenericQEDProcess) - return proc.incoming_spins_pols + return proc.incoming_spin_pols end function QEDbase.outgoing_spin_pols(proc::GenericQEDProcess) - return proc.outgoing_spins_pols + return proc.outgoing_spin_pols end """ @@ -47,3 +94,34 @@ function isphysical(proc::GenericQEDProcess) number_particles(proc, Outgoing(), Electron()) ) && number_particles(proc, Incoming()) + number_particles(proc, Outgoing()) >= 2 end + +function Base.show(io::IO, proc::GenericQEDProcess) + print(io, "generic QED process \"") + for p in incoming_particles(proc) + print(io, _particle_to_letter(p)) + end + print(io, " -> ") + for p in outgoing_particles(proc) + print(io, _particle_to_letter(p)) + end + print(io, "\"") + return nothing +end + +function Base.show(io::IO, ::MIME"text/plain", proc::GenericQEDProcess) + println(io, "generic QED process") + for dir in (Incoming(), Outgoing()) + first = true + for (p, sp) in zip(particles(proc, dir), spin_pols(proc, dir)) + if !first + print(io, ", ") + else + print(io, " $(dir): ") + first = false + end + print(io, "$(p) ($(sp))") + end + println(io) + end + return nothing +end diff --git a/src/processes/generic_process/utility.jl b/src/processes/generic_process/utility.jl index 86d1bc0..49603e9 100644 --- a/src/processes/generic_process/utility.jl +++ b/src/processes/generic_process/utility.jl @@ -5,7 +5,41 @@ end function _assert_particle_type_tuple(t::Any) throw( InvalidInputError( - "invalid input, provide a tuple of AbstractParticleTypes to construct a QEDProcess", + "invalid input, provide a tuple of AbstractParticleTypes to construct a GenericQEDProcess", ), ) end + +_assert_spin_pol_particle_compatability(::Tuple{}, ::Tuple{}) = nothing +function _assert_spin_pol_particle_compatability(::Tuple{}, ::Tuple{Vararg}) + throw(InvalidInputError("more spins/pols than particles given")) +end +function _assert_spin_pol_particle_compatability(::Tuple{Vararg}, ::Tuple{}) + throw(InvalidInputError("more particles than spins/pols given")) +end + +function _assert_spin_pol_particle_compatability( + particles::Tuple{AbstractParticleType,Vararg}, + spin_pols::Tuple{AbstractSpinOrPolarization,Vararg}, +) + if is_fermion(particles[1]) && !(spin_pols[1] isa AbstractSpin) + throw( + InvalidInputError( + "particle \"$(particles[1])\" is a fermion and should have a spin, but has \"$(spin_pols[1])\"", + ), + ) + end + if is_boson(particles[1]) && !(spin_pols[1] isa AbstractPolarization) + throw( + InvalidInputError( + "particle \"$(particles[1])\" is a boson and should have a polarization, but has \"$(spin_pols[1])\"", + ), + ) + end + return _assert_spin_pol_particle_compatability(particles[2:end], spin_pols[2:end]) +end + +# this should move to QEDbase as part of the interface, see https://github.com/QEDjl-project/QEDbase.jl/issues/114 +_particle_to_letter(::Electron) = "e" +_particle_to_letter(::Positron) = "p" +_particle_to_letter(::Photon) = "k" diff --git a/test/processes/generic_process/groundtruths.jl b/test/processes/generic_process/groundtruths.jl new file mode 100644 index 0000000..9fe97d2 --- /dev/null +++ b/test/processes/generic_process/groundtruths.jl @@ -0,0 +1,25 @@ +POLS = [PolX(), PolY(), AllPol()] +SPINS = [SpinUp(), SpinDown(), AllSpin()] + +function _groundtruth_is_physical(proc::GenericQEDProcess) + incoming_electrons = number_particles(proc, Incoming(), Electron()) + incoming_positrons = number_particles(proc, Incoming(), Positron()) + outgoing_electrons = number_particles(proc, Outgoing(), Electron()) + outgoing_positrons = number_particles(proc, Outgoing(), Positron()) + + return incoming_electrons + outgoing_positrons == + outgoing_electrons + incoming_positrons +end + +function _groundtruth_spin_pols(particles) + return ntuple( + x -> is_fermion(particles[x]) ? AllSpin() : AllPolarization(), length(particles) + ) +end + +function _random_spin_pols(RNG, particles) + return ntuple( + x -> is_fermion(particles[x]) ? rand(RNG, SPINS) : rand(RNG, POLS), + length(particles), + ) +end diff --git a/test/processes/generic_process/process.jl b/test/processes/generic_process/process.jl new file mode 100644 index 0000000..0216c22 --- /dev/null +++ b/test/processes/generic_process/process.jl @@ -0,0 +1,197 @@ +using QEDprocesses +using Random +using QEDcore + +include("groundtruths.jl") + +const RNG = MersenneTwister(77697185) + +PARTICLES = [Electron(), Positron(), Photon()] +POLS = [PolX(), PolY(), AllPol()] +SPINS = [SpinUp(), SpinDown(), AllSpin()] +POL_AND_SPIN_COMBINATIONS = Iterators.product(SPINS, POLS, SPINS, POLS) +BUF = IOBuffer() + +@testset "constructor" begin + @testset "default" begin + proc = GenericQEDProcess((Photon(), Electron()), (Photon(), Electron())) + + @test QEDprocesses.spin_pols(proc, Incoming())[1] == AllPol() + @test QEDprocesses.spin_pols(proc, Incoming())[2] == AllSpin() + @test QEDprocesses.spin_pols(proc, Outgoing())[1] == AllPol() + @test QEDprocesses.spin_pols(proc, Outgoing())[2] == AllSpin() + + print(BUF, proc) + @test String(take!(BUF)) == "generic QED process \"ke -> ke\"" + + show(BUF, MIME"text/plain"(), proc) + @test String(take!(BUF)) == + "generic QED process\n incoming: photon ($(AllPol())), electron ($(AllSpin()))\n outgoing: photon ($(AllPol())), electron ($(AllSpin()))\n" + + @test isphysical(proc) + end + + @testset "all spins+pols" begin + @testset "$in_spin, $in_pol, $out_spin, $out_pol" for ( + in_spin, in_pol, out_spin, out_pol + ) in POL_AND_SPIN_COMBINATIONS + proc = GenericQEDProcess( + (Photon(), Electron()), + (Photon(), Electron()), + (in_pol, in_spin), + (out_pol, out_spin), + ) + + @test QEDprocesses.spin_pols(proc, Incoming())[1] == in_pol + @test QEDprocesses.spin_pols(proc, Incoming())[2] == in_spin + @test QEDprocesses.spin_pols(proc, Outgoing())[1] == out_pol + @test QEDprocesses.spin_pols(proc, Outgoing())[2] == out_spin + + print(BUF, proc) + @test String(take!(BUF)) == "generic QED process \"ke -> ke\"" + + show(BUF, MIME"text/plain"(), proc) + @test String(take!(BUF)) == + "generic QED process\n incoming: photon ($(in_pol)), electron ($(in_spin))\n outgoing: photon ($(out_pol)), electron ($(out_spin))\n" + + @test isphysical(proc) + end + end + + @testset "invalid types passed" begin + struct INVALID_PARTICLE end + + @test_throws "invalid input, provide a tuple of AbstractParticleTypes to construct a GenericQEDProcess" GenericQEDProcess( + (INVALID_PARTICLE(), Electron()), (Photon(), Electron()) + ) + @test_throws InvalidInputError GenericQEDProcess( + (INVALID_PARTICLE(), Electron()), (Photon(), Electron()) + ) + + @test_throws "invalid input, provide a tuple of AbstractParticleTypes to construct a GenericQEDProcess" GenericQEDProcess( + (Photon(), Electron()), (Photon(), INVALID_PARTICLE()) + ) + @test_throws InvalidInputError GenericQEDProcess( + (Photon(), Electron()), (Photon(), INVALID_PARTICLE()) + ) + end + + @testset "incompatible spin/pols" begin + @test_throws InvalidInputError GenericQEDProcess( + (Electron(), Photon()), + (Electron(), Photon()), + (AllPol(), AllPol()), + (AllSpin(), AllPol()), + ) + @test_throws "particle \"electron\" is a fermion and should have a spin, but has \"all polarizations\"" GenericQEDProcess( + (Electron(), Photon()), + (Electron(), Photon()), + (AllPol(), AllPol()), + (AllSpin(), AllPol()), + ) + + @test_throws InvalidInputError GenericQEDProcess( + (Electron(), Photon()), + (Electron(), Photon()), + (AllSpin(), AllSpin()), + (AllSpin(), AllPol()), + ) + @test_throws "particle \"photon\" is a boson and should have a polarization, but has \"all spins\"" GenericQEDProcess( + (Electron(), Photon()), + (Electron(), Photon()), + (AllSpin(), AllSpin()), + (AllSpin(), AllPol()), + ) + end + + @testset "incompatible number of spins/pols" begin + IN_PARTICLES = Tuple(rand(RNG, PARTICLES, 2)) + OUT_PARTICLES = Tuple(rand(RNG, PARTICLES, 2)) + @testset "2 particles, 1 spin/pol" begin + @test_throws InvalidInputError GenericQEDProcess( + IN_PARTICLES, + OUT_PARTICLES, + _random_spin_pols(RNG, IN_PARTICLES)[1:1], + _random_spin_pols(RNG, OUT_PARTICLES), + ) + @test_throws "more particles than spins/pols given" GenericQEDProcess( + IN_PARTICLES, + OUT_PARTICLES, + _random_spin_pols(RNG, IN_PARTICLES)[1:1], + _random_spin_pols(RNG, OUT_PARTICLES), + ) + + @test_throws InvalidInputError GenericQEDProcess( + IN_PARTICLES, + OUT_PARTICLES, + _random_spin_pols(RNG, IN_PARTICLES), + _random_spin_pols(RNG, OUT_PARTICLES)[1:1], + ) + @test_throws "more particles than spins/pols given" GenericQEDProcess( + IN_PARTICLES, + OUT_PARTICLES, + _random_spin_pols(RNG, IN_PARTICLES), + _random_spin_pols(RNG, OUT_PARTICLES)[1:1], + ) + end + @testset "2 particles, 3 spin/pols" begin + @test_throws InvalidInputError GenericQEDProcess( + IN_PARTICLES, + OUT_PARTICLES, + (_random_spin_pols(RNG, IN_PARTICLES)..., AllPol()), + _random_spin_pols(RNG, OUT_PARTICLES), + ) + @test_throws "more spins/pols than particles given" GenericQEDProcess( + IN_PARTICLES, + OUT_PARTICLES, + (_random_spin_pols(RNG, IN_PARTICLES)..., AllSpin()), + _random_spin_pols(RNG, OUT_PARTICLES), + ) + + @test_throws InvalidInputError GenericQEDProcess( + IN_PARTICLES, + OUT_PARTICLES, + _random_spin_pols(RNG, IN_PARTICLES), + (_random_spin_pols(RNG, OUT_PARTICLES)..., AllPol()), + ) + @test_throws "more spins/pols than particles given" GenericQEDProcess( + IN_PARTICLES, + OUT_PARTICLES, + _random_spin_pols(RNG, IN_PARTICLES), + (_random_spin_pols(RNG, OUT_PARTICLES)..., AllSpin()), + ) + end + end +end + +@testset "particle content" begin + @testset "$n -> $m processes" for (n, m) in Base.product((2, 4), (3, 5)) + IN_PARTICLES = Tuple(rand(RNG, PARTICLES, n)) + OUT_PARTICLES = Tuple(rand(RNG, PARTICLES, m)) + proc = GenericQEDProcess(IN_PARTICLES, OUT_PARTICLES) + @testset "process $(proc)" begin + @test incoming_particles(proc) == IN_PARTICLES + @test outgoing_particles(proc) == OUT_PARTICLES + @test number_incoming_particles(proc) == n + @test number_outgoing_particles(proc) == m + @test incoming_spin_pols(proc) == _groundtruth_spin_pols(IN_PARTICLES) + @test outgoing_spin_pols(proc) == _groundtruth_spin_pols(OUT_PARTICLES) + + @test isphysical(proc) == _groundtruth_is_physical(proc) + end + + IN_SPIN_POLS = _random_spin_pols(RNG, IN_PARTICLES) + OUT_SPIN_POLS = _random_spin_pols(RNG, OUT_PARTICLES) + proc = GenericQEDProcess(IN_PARTICLES, OUT_PARTICLES, IN_SPIN_POLS, OUT_SPIN_POLS) + @testset "process $(proc) with set spins/pols" begin + @test incoming_particles(proc) == IN_PARTICLES + @test outgoing_particles(proc) == OUT_PARTICLES + @test number_incoming_particles(proc) == n + @test number_outgoing_particles(proc) == m + @test incoming_spin_pols(proc) == IN_SPIN_POLS + @test outgoing_spin_pols(proc) == OUT_SPIN_POLS + + @test isphysical(proc) == _groundtruth_is_physical(proc) + end + end +end diff --git a/test/processes/run_process_test.jl b/test/processes/run_process_test.jl index 509b379..d8bf4a3 100644 --- a/test/processes/run_process_test.jl +++ b/test/processes/run_process_test.jl @@ -1,3 +1,6 @@ +@time @safetestset "generic process" begin + include("generic_process/process.jl") +end @time @safetestset "general one photon compton" begin include("one_photon_compton/process.jl") From c11b320573d8767ff3d99363d64b13275cd371a5 Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Wed, 21 Aug 2024 20:48:58 +0200 Subject: [PATCH 3/5] Fix tests for older versions of Julia --- test/processes/generic_process/process.jl | 74 ++++++----------------- 1 file changed, 17 insertions(+), 57 deletions(-) diff --git a/test/processes/generic_process/process.jl b/test/processes/generic_process/process.jl index 0216c22..a7f3953 100644 --- a/test/processes/generic_process/process.jl +++ b/test/processes/generic_process/process.jl @@ -61,42 +61,27 @@ BUF = IOBuffer() @testset "invalid types passed" begin struct INVALID_PARTICLE end - @test_throws "invalid input, provide a tuple of AbstractParticleTypes to construct a GenericQEDProcess" GenericQEDProcess( - (INVALID_PARTICLE(), Electron()), (Photon(), Electron()) - ) - @test_throws InvalidInputError GenericQEDProcess( - (INVALID_PARTICLE(), Electron()), (Photon(), Electron()) - ) + @test_throws InvalidInputError( + "invalid input, provide a tuple of AbstractParticleTypes to construct a GenericQEDProcess", + ) GenericQEDProcess((INVALID_PARTICLE(), Electron()), (Photon(), Electron())) - @test_throws "invalid input, provide a tuple of AbstractParticleTypes to construct a GenericQEDProcess" GenericQEDProcess( - (Photon(), Electron()), (Photon(), INVALID_PARTICLE()) - ) - @test_throws InvalidInputError GenericQEDProcess( - (Photon(), Electron()), (Photon(), INVALID_PARTICLE()) - ) + @test_throws InvalidInputError( + "invalid input, provide a tuple of AbstractParticleTypes to construct a GenericQEDProcess", + ) GenericQEDProcess((Photon(), Electron()), (Photon(), INVALID_PARTICLE())) end @testset "incompatible spin/pols" begin - @test_throws InvalidInputError GenericQEDProcess( - (Electron(), Photon()), - (Electron(), Photon()), - (AllPol(), AllPol()), - (AllSpin(), AllPol()), - ) - @test_throws "particle \"electron\" is a fermion and should have a spin, but has \"all polarizations\"" GenericQEDProcess( + @test_throws InvalidInputError( + "particle \"electron\" is a fermion and should have a spin, but has \"all polarizations\"", + ) GenericQEDProcess( (Electron(), Photon()), (Electron(), Photon()), (AllPol(), AllPol()), (AllSpin(), AllPol()), ) - - @test_throws InvalidInputError GenericQEDProcess( - (Electron(), Photon()), - (Electron(), Photon()), - (AllSpin(), AllSpin()), - (AllSpin(), AllPol()), - ) - @test_throws "particle \"photon\" is a boson and should have a polarization, but has \"all spins\"" GenericQEDProcess( + @test_throws InvalidInputError( + "particle \"photon\" is a boson and should have a polarization, but has \"all spins\"", + ) GenericQEDProcess( (Electron(), Photon()), (Electron(), Photon()), (AllSpin(), AllSpin()), @@ -108,58 +93,33 @@ BUF = IOBuffer() IN_PARTICLES = Tuple(rand(RNG, PARTICLES, 2)) OUT_PARTICLES = Tuple(rand(RNG, PARTICLES, 2)) @testset "2 particles, 1 spin/pol" begin - @test_throws InvalidInputError GenericQEDProcess( - IN_PARTICLES, - OUT_PARTICLES, - _random_spin_pols(RNG, IN_PARTICLES)[1:1], - _random_spin_pols(RNG, OUT_PARTICLES), - ) - @test_throws "more particles than spins/pols given" GenericQEDProcess( + @test_throws InvalidInputError("more particles than spins/pols given") GenericQEDProcess( IN_PARTICLES, OUT_PARTICLES, _random_spin_pols(RNG, IN_PARTICLES)[1:1], _random_spin_pols(RNG, OUT_PARTICLES), ) - - @test_throws InvalidInputError GenericQEDProcess( - IN_PARTICLES, - OUT_PARTICLES, - _random_spin_pols(RNG, IN_PARTICLES), - _random_spin_pols(RNG, OUT_PARTICLES)[1:1], - ) - @test_throws "more particles than spins/pols given" GenericQEDProcess( + @test_throws InvalidInputError("more particles than spins/pols given") GenericQEDProcess( IN_PARTICLES, OUT_PARTICLES, _random_spin_pols(RNG, IN_PARTICLES), _random_spin_pols(RNG, OUT_PARTICLES)[1:1], ) end + @testset "2 particles, 3 spin/pols" begin - @test_throws InvalidInputError GenericQEDProcess( + @test_throws InvalidInputError("more spins/pols than particles given") GenericQEDProcess( IN_PARTICLES, OUT_PARTICLES, (_random_spin_pols(RNG, IN_PARTICLES)..., AllPol()), _random_spin_pols(RNG, OUT_PARTICLES), ) - @test_throws "more spins/pols than particles given" GenericQEDProcess( - IN_PARTICLES, - OUT_PARTICLES, - (_random_spin_pols(RNG, IN_PARTICLES)..., AllSpin()), - _random_spin_pols(RNG, OUT_PARTICLES), - ) - - @test_throws InvalidInputError GenericQEDProcess( + @test_throws InvalidInputError("more spins/pols than particles given") GenericQEDProcess( IN_PARTICLES, OUT_PARTICLES, _random_spin_pols(RNG, IN_PARTICLES), (_random_spin_pols(RNG, OUT_PARTICLES)..., AllPol()), ) - @test_throws "more spins/pols than particles given" GenericQEDProcess( - IN_PARTICLES, - OUT_PARTICLES, - _random_spin_pols(RNG, IN_PARTICLES), - (_random_spin_pols(RNG, OUT_PARTICLES)..., AllSpin()), - ) end end end From 117a5ba803c491f6496d82a3e9cb802e788d54f3 Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Mon, 26 Aug 2024 19:33:24 +0200 Subject: [PATCH 4/5] Review comments --- src/QEDprocesses.jl | 2 +- src/models/perturbative_qed.jl | 14 +++ .../perturbative/cross_section.jl | 14 +-- src/processes/generic_process/process.jl | 103 ++++++++---------- src/processes/generic_process/utility.jl | 21 +--- .../processes/generic_process/groundtruths.jl | 2 +- test/processes/generic_process/process.jl | 46 ++++---- 7 files changed, 93 insertions(+), 109 deletions(-) diff --git a/src/QEDprocesses.jl b/src/QEDprocesses.jl index c8d9084..268d5ab 100644 --- a/src/QEDprocesses.jl +++ b/src/QEDprocesses.jl @@ -9,7 +9,7 @@ export PerturbativeQED # specific scattering processes export Compton, omega_prime -export GenericQEDProcess, isphysical +export ScatteringProcess, isphysical using QEDbase using QEDcore diff --git a/src/models/perturbative_qed.jl b/src/models/perturbative_qed.jl index 8592b33..b045619 100644 --- a/src/models/perturbative_qed.jl +++ b/src/models/perturbative_qed.jl @@ -28,3 +28,17 @@ function Base.show(io::IO, ::PerturbativeQED) print(io, "perturbative QED") return nothing end + +""" + isphysical(proc::AbstractProcessDefinition, model::PerturbativeQED) + +A utility function that returns whether a given `AbstractProcessDefinition` conserves the number and charge of fermions and has at least 2 participating particles. +""" +function isphysical(proc::AbstractProcessDefinition, ::PerturbativeQED) + return ( + number_particles(proc, Incoming(), Electron()) + + number_particles(proc, Outgoing(), Positron()) == + number_particles(proc, Incoming(), Positron()) + + number_particles(proc, Outgoing(), Electron()) + ) && number_particles(proc, Incoming()) + number_particles(proc, Outgoing()) >= 2 +end diff --git a/src/processes/generic_process/perturbative/cross_section.jl b/src/processes/generic_process/perturbative/cross_section.jl index 085ed09..5235bb6 100644 --- a/src/processes/generic_process/perturbative/cross_section.jl +++ b/src/processes/generic_process/perturbative/cross_section.jl @@ -2,21 +2,19 @@ # They will be implemented using the QEDFeynmanDiagrams project when that is released. #= -function QEDbase._incident_flux(psp::InPhaseSpacePoint{<:GenericQEDProcess,PerturbativeQED}) end +function QEDbase._incident_flux(psp::InPhaseSpacePoint{<:ScatteringProcess,PerturbativeQED}) end -function QEDbase._matrix_element(psp::PhaseSpacePoint{<:GenericQEDProcess,PerturbativeQED}) +function QEDbase._matrix_element_squared(psp::PhaseSpacePoint{<:ScatteringProcess,PerturbativeQED}) proc = process(psp) # by using FeynmanDiagramGenerator.jl - return sqrt(proc.matrix_element_squared(psp)) + return proc.matrix_element_squared(psp) end -function QEDbase._averaging_norm(proc::<:GenericQEDProcess) end +function QEDbase._averaging_norm(proc::<:ScatteringProcess) end -function QEDbase._is_in_phasespace(psp::PhaseSpacePoint{<:GenericQEDProcess,PerturbativeQED}) end +function QEDbase._is_in_phasespace(psp::PhaseSpacePoint{<:ScatteringProcess,PerturbativeQED}) end function QEDbase._phase_space_factor( - psp::PhaseSpacePoint{<:GenericQEDProcess,PerturbativeQED,CustomPhasespaceDefinition} + psp::PhaseSpacePoint{<:ScatteringProcess,PerturbativeQED,CustomPhasespaceDefinition} ) end - -function QEDbase._total_probability(in_psp::InPhaseSpacePoint{<:GenericQEDProcess,PerturbativeQED}) end =# diff --git a/src/processes/generic_process/process.jl b/src/processes/generic_process/process.jl index f426fa0..c642fce 100644 --- a/src/processes/generic_process/process.jl +++ b/src/processes/generic_process/process.jl @@ -1,15 +1,30 @@ """ - GenericQEDProcess <: AbstractProcessDefinition + ScatteringProcess <: AbstractProcessDefinition -An implementation of the `AbstractProcessDefinition` interface for a generic particle process in QED -with any number of incoming and outgoing particles, and any combination of spins or polarizations for the particles set. +Generic implementation for scattering processes of arbitrary particles. Currently, only calculations in combination with `PerturbativeQED` are supported. +However, this is supposed to describe scattering processes with any number of incoming and outgoing particles, and any combination of spins or polarizations for the particles. -The [`isphysical`](@ref) function can be used to check whether the process is possible in QED. +The [`isphysical`](@ref) function can be used to check whether the process is possible in perturbative QED. -!!! note +!!! warning The computation of cross sections and probabilities is currently unimplemented. + +## Constructors + + ScatteringProcess( + in_particles::Tuple{AbstractParticleType}, + out_particles::Tuple{AbstractParticleType}, + [in_sp::Tuple{AbstractSpinOrPolarization}, + out_sp::Tuple{AbstractSpinOrPolarization}] + ) + +Constructor for a ScatteringProcess with the given incoming and outgoing particles and their respective spins and pols. +The constructor asserts that the particles are compatible with their respective spins and polarizations. If the assertion fails, an +`InvalidInputError` is thrown. + +The `in_sp` and `out_sp` parameters can be omitted in which case all spins and polarizations will be set to `AllSpin` and `AllPol` for every fermion and boson, respectively. """ -struct GenericQEDProcess{INT,OUTT,INSP,OUTSP} <: +struct ScatteringProcess{INT,OUTT,INSP,OUTSP} <: AbstractProcessDefinition where {INT<:Tuple,OUTT<:Tuple,INSP<:Tuple,OUTSP<:Tuple} incoming_particles::INT outgoing_particles::OUTT @@ -17,46 +32,30 @@ struct GenericQEDProcess{INT,OUTT,INSP,OUTSP} <: incoming_spin_pols::INSP outgoing_spin_pols::OUTSP - """ - GenericQEDProcess( - in_particles::Tuple{AbstractParticleType}, - out_particles::Tuple{AbstractParticleType}, - in_sp::Tuple{AbstractSpinOrPolarization}, - out_sp::Tuple{AbstractSpinOrPolarization} - ) - - Constructor for a GenericQEDProcess with the given incoming and outgoing particles and their respective spins and pols. - The constructor asserts that the particles are compatible with their respective spins and polarizations. If the assertion fails, an - `InvalidInputError` is thrown. - """ - function GenericQEDProcess( - in_particles::INT, out_particles::OUTT, in_spin_pols::INSP, out_spin_pols::OUTSP - ) where {INT<:Tuple,OUTT<:Tuple,INSP<:Tuple,OUTSP<:Tuple} - _assert_particle_type_tuple(in_particles) - _assert_particle_type_tuple(out_particles) - + function ScatteringProcess( + in_particles::NTuple{I,AbstractParticleType}, + out_particles::NTuple{O,AbstractParticleType}, + in_spin_pols::NTuple{I,AbstractSpinOrPolarization}, + out_spin_pols::NTuple{O,AbstractSpinOrPolarization}, + ) where {I,O} _assert_spin_pol_particle_compatability(in_particles, in_spin_pols) _assert_spin_pol_particle_compatability(out_particles, out_spin_pols) - return new{INT,OUTT,INSP,OUTSP}( + return new{ + typeof(in_particles), + typeof(out_particles), + typeof(in_spin_pols), + typeof(out_spin_pols), + }( in_particles, out_particles, in_spin_pols, out_spin_pols ) end end -""" - GenericQEDProcess(in_particles::Tuple{AbstractParticleType}, out_particles::Tuple{AbstractParticleType}) - -Constructor for a GenericQEDProcess, setting `AllPol` and `AllSpin` for every boson and fermion, respectively. -""" -function GenericQEDProcess( - in_particles::INT, out_particles::OUTT -) where {INT<:Tuple,OUTT<:Tuple} - # this will be called again by the default constructor, but it produces a nicer warning here - # than the following spin/pol generation failing because is_fermion or is_boson isn't defined on not allowed types - _assert_particle_type_tuple(in_particles) - _assert_particle_type_tuple(out_particles) - +function ScatteringProcess( + in_particles::NTuple{I,AbstractParticleType}, + out_particles::NTuple{O,AbstractParticleType}, +) where {I,O} in_spin_pols = ntuple( x -> is_fermion(in_particles[x]) ? AllSpin() : AllPolarization(), length(in_particles), @@ -65,37 +64,23 @@ function GenericQEDProcess( x -> is_fermion(out_particles[x]) ? AllSpin() : AllPolarization(), length(out_particles), ) - return GenericQEDProcess(in_particles, out_particles, in_spin_pols, out_spin_pols) + return ScatteringProcess(in_particles, out_particles, in_spin_pols, out_spin_pols) end -function QEDbase.incoming_particles(proc::GenericQEDProcess) +function QEDbase.incoming_particles(proc::ScatteringProcess) return proc.incoming_particles end -function QEDbase.outgoing_particles(proc::GenericQEDProcess) +function QEDbase.outgoing_particles(proc::ScatteringProcess) return proc.outgoing_particles end -function QEDbase.incoming_spin_pols(proc::GenericQEDProcess) +function QEDbase.incoming_spin_pols(proc::ScatteringProcess) return proc.incoming_spin_pols end -function QEDbase.outgoing_spin_pols(proc::GenericQEDProcess) +function QEDbase.outgoing_spin_pols(proc::ScatteringProcess) return proc.outgoing_spin_pols end -""" - isphysical(proc::GenericQEDProcess) - -A utility function that returns whether a given GenericQEDProcess conserves the number and charge of fermions and has at least 2 participating particles. -""" -function isphysical(proc::GenericQEDProcess) - return ( - number_particles(proc, Incoming(), Electron()) + - number_particles(proc, Outgoing(), Positron()) == - number_particles(proc, Incoming(), Positron()) + - number_particles(proc, Outgoing(), Electron()) - ) && number_particles(proc, Incoming()) + number_particles(proc, Outgoing()) >= 2 -end - -function Base.show(io::IO, proc::GenericQEDProcess) +function Base.show(io::IO, proc::ScatteringProcess) print(io, "generic QED process \"") for p in incoming_particles(proc) print(io, _particle_to_letter(p)) @@ -108,7 +93,7 @@ function Base.show(io::IO, proc::GenericQEDProcess) return nothing end -function Base.show(io::IO, ::MIME"text/plain", proc::GenericQEDProcess) +function Base.show(io::IO, ::MIME"text/plain", proc::ScatteringProcess) println(io, "generic QED process") for dir in (Incoming(), Outgoing()) first = true diff --git a/src/processes/generic_process/utility.jl b/src/processes/generic_process/utility.jl index 49603e9..e84ffdf 100644 --- a/src/processes/generic_process/utility.jl +++ b/src/processes/generic_process/utility.jl @@ -1,23 +1,8 @@ -_assert_particle_type_tuple(::Tuple{}) = nothing -function _assert_particle_type_tuple(t::Tuple{AbstractParticleType,Vararg}) - return _assert_particle_type_tuple(t[2:end]) -end -function _assert_particle_type_tuple(t::Any) - throw( - InvalidInputError( - "invalid input, provide a tuple of AbstractParticleTypes to construct a GenericQEDProcess", - ), - ) -end - +# recursion success, all particles are compatible with their spin/pol _assert_spin_pol_particle_compatability(::Tuple{}, ::Tuple{}) = nothing -function _assert_spin_pol_particle_compatability(::Tuple{}, ::Tuple{Vararg}) - throw(InvalidInputError("more spins/pols than particles given")) -end -function _assert_spin_pol_particle_compatability(::Tuple{Vararg}, ::Tuple{}) - throw(InvalidInputError("more particles than spins/pols given")) -end +# recursion base case: check first particle against first spin/pol, then recurse +# note: the length of the tuples is expected to be the same, the constructor ensures this by using NTuples function _assert_spin_pol_particle_compatability( particles::Tuple{AbstractParticleType,Vararg}, spin_pols::Tuple{AbstractSpinOrPolarization,Vararg}, diff --git a/test/processes/generic_process/groundtruths.jl b/test/processes/generic_process/groundtruths.jl index 9fe97d2..d6fa4a7 100644 --- a/test/processes/generic_process/groundtruths.jl +++ b/test/processes/generic_process/groundtruths.jl @@ -1,7 +1,7 @@ POLS = [PolX(), PolY(), AllPol()] SPINS = [SpinUp(), SpinDown(), AllSpin()] -function _groundtruth_is_physical(proc::GenericQEDProcess) +function _groundtruth_is_physical(proc::ScatteringProcess, ::PerturbativeQED) incoming_electrons = number_particles(proc, Incoming(), Electron()) incoming_positrons = number_particles(proc, Incoming(), Positron()) outgoing_electrons = number_particles(proc, Outgoing(), Electron()) diff --git a/test/processes/generic_process/process.jl b/test/processes/generic_process/process.jl index a7f3953..fd758f1 100644 --- a/test/processes/generic_process/process.jl +++ b/test/processes/generic_process/process.jl @@ -7,14 +7,14 @@ include("groundtruths.jl") const RNG = MersenneTwister(77697185) PARTICLES = [Electron(), Positron(), Photon()] -POLS = [PolX(), PolY(), AllPol()] -SPINS = [SpinUp(), SpinDown(), AllSpin()] +POLS = [PolX(), PolY(), AllPol(), SyncedPolarization(1)] +SPINS = [SpinUp(), SpinDown(), AllSpin(), SyncedSpin(1)] POL_AND_SPIN_COMBINATIONS = Iterators.product(SPINS, POLS, SPINS, POLS) BUF = IOBuffer() @testset "constructor" begin @testset "default" begin - proc = GenericQEDProcess((Photon(), Electron()), (Photon(), Electron())) + proc = ScatteringProcess((Photon(), Electron()), (Photon(), Electron())) @test QEDprocesses.spin_pols(proc, Incoming())[1] == AllPol() @test QEDprocesses.spin_pols(proc, Incoming())[2] == AllSpin() @@ -28,14 +28,14 @@ BUF = IOBuffer() @test String(take!(BUF)) == "generic QED process\n incoming: photon ($(AllPol())), electron ($(AllSpin()))\n outgoing: photon ($(AllPol())), electron ($(AllSpin()))\n" - @test isphysical(proc) + @test isphysical(proc, PerturbativeQED()) end @testset "all spins+pols" begin @testset "$in_spin, $in_pol, $out_spin, $out_pol" for ( in_spin, in_pol, out_spin, out_pol ) in POL_AND_SPIN_COMBINATIONS - proc = GenericQEDProcess( + proc = ScatteringProcess( (Photon(), Electron()), (Photon(), Electron()), (in_pol, in_spin), @@ -54,26 +54,26 @@ BUF = IOBuffer() @test String(take!(BUF)) == "generic QED process\n incoming: photon ($(in_pol)), electron ($(in_spin))\n outgoing: photon ($(out_pol)), electron ($(out_spin))\n" - @test isphysical(proc) + @test isphysical(proc, PerturbativeQED()) end end @testset "invalid types passed" begin struct INVALID_PARTICLE end - @test_throws InvalidInputError( - "invalid input, provide a tuple of AbstractParticleTypes to construct a GenericQEDProcess", - ) GenericQEDProcess((INVALID_PARTICLE(), Electron()), (Photon(), Electron())) + @test_throws MethodError ScatteringProcess( + (INVALID_PARTICLE(), Electron()), (Photon(), Electron()) + ) - @test_throws InvalidInputError( - "invalid input, provide a tuple of AbstractParticleTypes to construct a GenericQEDProcess", - ) GenericQEDProcess((Photon(), Electron()), (Photon(), INVALID_PARTICLE())) + @test_throws MethodError ScatteringProcess( + (Photon(), Electron()), (Photon(), INVALID_PARTICLE()) + ) end @testset "incompatible spin/pols" begin @test_throws InvalidInputError( "particle \"electron\" is a fermion and should have a spin, but has \"all polarizations\"", - ) GenericQEDProcess( + ) ScatteringProcess( (Electron(), Photon()), (Electron(), Photon()), (AllPol(), AllPol()), @@ -81,7 +81,7 @@ BUF = IOBuffer() ) @test_throws InvalidInputError( "particle \"photon\" is a boson and should have a polarization, but has \"all spins\"", - ) GenericQEDProcess( + ) ScatteringProcess( (Electron(), Photon()), (Electron(), Photon()), (AllSpin(), AllSpin()), @@ -93,13 +93,13 @@ BUF = IOBuffer() IN_PARTICLES = Tuple(rand(RNG, PARTICLES, 2)) OUT_PARTICLES = Tuple(rand(RNG, PARTICLES, 2)) @testset "2 particles, 1 spin/pol" begin - @test_throws InvalidInputError("more particles than spins/pols given") GenericQEDProcess( + @test_throws MethodError ScatteringProcess( IN_PARTICLES, OUT_PARTICLES, _random_spin_pols(RNG, IN_PARTICLES)[1:1], _random_spin_pols(RNG, OUT_PARTICLES), ) - @test_throws InvalidInputError("more particles than spins/pols given") GenericQEDProcess( + @test_throws MethodError ScatteringProcess( IN_PARTICLES, OUT_PARTICLES, _random_spin_pols(RNG, IN_PARTICLES), @@ -108,13 +108,13 @@ BUF = IOBuffer() end @testset "2 particles, 3 spin/pols" begin - @test_throws InvalidInputError("more spins/pols than particles given") GenericQEDProcess( + @test_throws MethodError ScatteringProcess( IN_PARTICLES, OUT_PARTICLES, (_random_spin_pols(RNG, IN_PARTICLES)..., AllPol()), _random_spin_pols(RNG, OUT_PARTICLES), ) - @test_throws InvalidInputError("more spins/pols than particles given") GenericQEDProcess( + @test_throws MethodError ScatteringProcess( IN_PARTICLES, OUT_PARTICLES, _random_spin_pols(RNG, IN_PARTICLES), @@ -128,7 +128,7 @@ end @testset "$n -> $m processes" for (n, m) in Base.product((2, 4), (3, 5)) IN_PARTICLES = Tuple(rand(RNG, PARTICLES, n)) OUT_PARTICLES = Tuple(rand(RNG, PARTICLES, m)) - proc = GenericQEDProcess(IN_PARTICLES, OUT_PARTICLES) + proc = ScatteringProcess(IN_PARTICLES, OUT_PARTICLES) @testset "process $(proc)" begin @test incoming_particles(proc) == IN_PARTICLES @test outgoing_particles(proc) == OUT_PARTICLES @@ -137,12 +137,13 @@ end @test incoming_spin_pols(proc) == _groundtruth_spin_pols(IN_PARTICLES) @test outgoing_spin_pols(proc) == _groundtruth_spin_pols(OUT_PARTICLES) - @test isphysical(proc) == _groundtruth_is_physical(proc) + @test isphysical(proc, PerturbativeQED()) == + _groundtruth_is_physical(proc, PerturbativeQED()) end IN_SPIN_POLS = _random_spin_pols(RNG, IN_PARTICLES) OUT_SPIN_POLS = _random_spin_pols(RNG, OUT_PARTICLES) - proc = GenericQEDProcess(IN_PARTICLES, OUT_PARTICLES, IN_SPIN_POLS, OUT_SPIN_POLS) + proc = ScatteringProcess(IN_PARTICLES, OUT_PARTICLES, IN_SPIN_POLS, OUT_SPIN_POLS) @testset "process $(proc) with set spins/pols" begin @test incoming_particles(proc) == IN_PARTICLES @test outgoing_particles(proc) == OUT_PARTICLES @@ -151,7 +152,8 @@ end @test incoming_spin_pols(proc) == IN_SPIN_POLS @test outgoing_spin_pols(proc) == OUT_SPIN_POLS - @test isphysical(proc) == _groundtruth_is_physical(proc) + @test isphysical(proc, PerturbativeQED()) == + _groundtruth_is_physical(proc, PerturbativeQED()) end end end From fcff9cb167f8b8146fe7b7171628887c9598dae1 Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Mon, 26 Aug 2024 19:45:19 +0200 Subject: [PATCH 5/5] Fix formatter julia version (?) --- .github/workflows/formatter.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/formatter.yaml b/.github/workflows/formatter.yaml index 5cbe730..c5e31e4 100644 --- a/.github/workflows/formatter.yaml +++ b/.github/workflows/formatter.yaml @@ -9,7 +9,7 @@ jobs: - name: install Julia uses: julia-actions/setup-julia@v1 with: - version: 1.10 + version: "1.10" - name: Install Julia requirements run: julia --project=${GITHUB_WORKSPACE}/.formatting -e 'import Pkg; Pkg.instantiate()' - name: Check code style