n-Pair Trident Scattering Process

In this file, we set up an n-pair trident scattering process. A trident process looks like $k e^- \to e^- (e^- e^+)^n$.

You can download this file as a jupyter notebook.

using QEDFeynmanDiagrams

We need QEDcore of the QEDjl-project for base functionality and a process type, for which we can use the Mocks submodule from QEDbase for this tutorial. Downstream, a ScatteringProcess from QEDprocesses.jl could be used, for example.

using QEDcore
using QEDbase.Mocks

Let's decide how many pairs our trident should produce:

n = 2;

Now we setup the scattering process accordingly. We only consider a single spin/polarization combination here. For an example with many spin and polarization combinations, refer to the n-photon Compton example

proc = QEDbase.Mocks.MockProcessSP(
    (Electron(), Photon()),                                                         # incoming particles
    (Electron(), ntuple(_ -> Electron(), n)..., ntuple(_ -> Positron(), n)...),     # outgoing particles
    (SpinUp(), PolX()),                                                             # incoming particle spin/pols
    (SpinUp(), ntuple(_ -> SpinUp(), 2 * n)...),                                    # outgoing particle spin/pols
)
QEDbase.Mocks.MockProcessSP{Tuple{Electron, Photon}, Tuple{Electron, Electron, Electron, Positron, Positron}, Tuple{SpinUp, PolarizationX}, NTuple{5, SpinUp}}((electron, photon), (electron, electron, electron, positron, positron), (spin up, x-polarized), (spin up, spin up, spin up, spin up, spin up))

The number_of_diagrams function returns how many valid Feynman diagrams there are for a given process.

number_of_diagrams(proc)
252

Next, we can generate the DAG representing the computation for our scattering process' squared matrix element. This uses ComputableDAGs.jl.

dag = graph(proc)
Graph:
  Nodes: Total: 943, QEDFeynmanDiagrams.ComputeTask_Pair: 60, ComputableDAGs.DataTask: 505, 
         QEDFeynmanDiagrams.ComputeTask_PropagatePairs: 60, QEDFeynmanDiagrams.ComputeTask_Propagator: 60, QEDFeynmanDiagrams.ComputeTask_BaseState: 7, 
         QEDFeynmanDiagrams.ComputeTask_CollectTriples: 1, QEDFeynmanDiagrams.ComputeTask_PairNegated: 9, QEDFeynmanDiagrams.ComputeTask_Triple: 30, 
         QEDFeynmanDiagrams.ComputeTask_SpinPolCumulation: 1, QEDFeynmanDiagrams.ComputeTask_CollectPairs: 60, QEDFeynmanDiagrams.ComputeTask_TripleNegated: 150
  Edges: 1553
  Total Compute Effort: 0.0
  Total Data Transfer: 0.0
  Total Compute Intensity: 0.0

To continue, we will need ComputableDAGs.jl.

using ComputableDAGs

Now we need an input for the function, which is a QEDcore.PhaseSpacePoint. For now, we generate random momenta for every particle. In the future, QEDevents will be able to generate physical PhaseSpacePoints.

psp = PhaseSpacePoint(
    proc,
    MockModel(),
    FlatPhaseSpaceLayout(TwoBodyRestSystem()),
    tuple((rand(SFourMomentum) for _ in 1:number_incoming_particles(proc))...),
    tuple((rand(SFourMomentum) for _ in 1:number_outgoing_particles(proc))...),
)
PhaseSpacePoint:
    process: QEDbase.Mocks.MockProcessSP{Tuple{Electron, Photon}, Tuple{Electron, Electron, Electron, Positron, Positron}, Tuple{SpinUp, PolarizationX}, NTuple{5, SpinUp}}((electron, photon), (electron, electron, electron, positron, positron), (spin up, x-polarized), (spin up, spin up, spin up, spin up, spin up))
    model: mock model
    phase space layout: FlatPhaseSpaceLayout{TwoBodyTargetSystem{Energy{2}}}(TwoBodyTargetSystem{Energy{2}}(Energy{2}()))
    incoming particles:
     -> incoming electron: [0.9491453719556939, 0.7375039907735794, 0.392701392353769, 0.5969825259688953]
     -> incoming photon: [0.8683357199521979, 0.3332749222871413, 0.743797947687577, 0.8258666723879389]
    outgoing particles:
     -> outgoing electron: [0.8775127709148693, 0.7794144383962663, 0.594264104414048, 0.09253813858824489]
     -> outgoing electron: [0.19962974221881735, 0.9788260515957011, 0.13034311490023975, 0.5893987973099242]
     -> outgoing electron: [0.8200510619036495, 0.6323341879461816, 0.8660175572776856, 0.9569538768548399]
     -> outgoing positron: [0.5546599200375751, 0.37007355430529354, 0.940655881717064, 0.856928350429373]
     -> outgoing positron: [0.8778825922699105, 0.7429682266355705, 0.22967899519338497, 0.9655058510348267]

With the DAG, the process, and an input type to use, we can now generate the actual computable function:

func = compute_function(dag, proc, cpu_st(), @__MODULE__);

Finally, we can test that the function actually runs and computes something by simply calling it on the PhaseSpacePoint:

func(psp)
0.0015901127976770772

We can benchmark the execution speed too:

using BenchmarkTools
@benchmark func($psp)
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
 Range (minmax):  45.714 μs  4.637 ms   GC (min … max): 0.00% … 94.13%
 Time  (median):     48.710 μs                GC (median):    0.00%
 Time  (mean ± σ):   54.424 μs ± 111.884 μs   GC (mean ± σ):  5.48% ±  2.65%

   ▂▅▇██▆▅▄▃▂▁▁           ▁▁▂▁▁  ▂▂▂▂▃▂▂▁▁ ▁▁▁                ▂
  ▆██████████████▇▇▆▆▅▇▇█████████████████████▇▅▅▄▂▅▃▃▃▅▄▆▅▄▆ █
  45.7 μs       Histogram: log(frequency) by time      76.4 μs <

 Memory estimate: 68.98 KiB, allocs estimate: 661.

This page was generated using Literate.jl.