Fix computation and add trident example notebook

This commit is contained in:
2024-08-05 13:52:31 +02:00
parent 7de7aa2353
commit c8e26d13fe
5 changed files with 3814 additions and 148 deletions

View File

@@ -29,27 +29,15 @@
{
"data": {
"text/plain": [
"42-element Vector{VirtualParticle{QEDProcess{Tuple{Photon, Electron}, Tuple{Electron, Electron, Electron, Positron, Positron}, Tuple{AllPolarization, AllSpin}, NTuple{5, AllSpin}}, PT, 2, 5} where PT<:AbstractParticleType}:\n",
" photon: \t00 | 00101\n",
" photon: \t00 | 00110\n",
" photon: \t00 | 01001\n",
" photon: \t00 | 01010\n",
" photon: \t00 | 10001\n",
" photon: \t00 | 10010\n",
" photon: \t01 | 00100\n",
" photon: \t01 | 01000\n",
" photon: \t01 | 10000\n",
" electron: \t10 | 00001\n",
" ⋮\n",
" photon: \t10 | 00101\n",
" photon: \t10 | 00110\n",
" photon: \t10 | 01001\n",
" photon: \t10 | 01010\n",
" photon: \t10 | 10001\n",
" photon: \t10 | 10010\n",
" photon: \t11 | 00100\n",
" photon: \t11 | 01000\n",
" photon: \t11 | 10000"
"8-element Vector{VirtualParticle{QEDProcess{Tuple{Photon, Electron}, Tuple{Electron, Electron, Positron}, Tuple{AllPolarization, AllSpin}, Tuple{AllSpin, AllSpin, AllSpin}}, PT, 2, 3} where PT<:AbstractParticleType}:\n",
" photon: \t00 | 011\n",
" photon: \t00 | 101\n",
" photon: \t01 | 010\n",
" photon: \t01 | 100\n",
" electron: \t10 | 001\n",
" positron: \t10 | 010\n",
" positron: \t10 | 100\n",
" electron: \t11 | 000"
]
},
"metadata": {},
@@ -64,7 +52,7 @@
}
],
"source": [
"proc = QEDProcess(1, 0, 1, 3, 0, 2)\n",
"proc = QEDProcess(1, 0, 1, 2, 0, 1)\n",
"all_particles = Set()\n",
"for fd in feynman_diagrams(proc)\n",
" push!(all_particles, virtual_particles(proc, fd)...)\n",
@@ -81,27 +69,15 @@
{
"data": {
"text/plain": [
"OrderedCollections.OrderedDict{VirtualParticle, Vector{Tuple{VirtualParticle, VirtualParticle}}} with 42 entries:\n",
" photon: \t00 | 00101 => [(electron: \t00 | 00001, positron: \t00 | 00100)]\n",
" photon: \t00 | 00110 => [(electron: \t00 | 00010, positron: \t00 | 00100)]\n",
" photon: \t00 | 01001 => [(electron: \t00 | 00001, positron: \t00 | 01000)]\n",
" photon: \t00 | 01010 => [(electron: \t00 | 00010, positron: \t00 | 01000)]\n",
" photon: \t00 | 10001 => [(electron: \t00 | 00001, positron: \t00 | 10000)]\n",
" photon: \t00 | 10010 => [(electron: \t00 | 00010, positron: \t00 | 10000)]\n",
" photon: \t01 | 00100 => [(positron: \t00 | 00100, electron: \t01 | 00000)]\n",
" photon: \t01 | 01000 => [(positron: \t00 | 01000, electron: \t01 | 00000)]\n",
" photon: \t01 | 10000 => [(positron: \t00 | 10000, electron: \t01 | 00000)]\n",
" electron: \t10 | 00001 => [(electron: \t00 | 00001, photon: \t10 | 00000)]\n",
" electron: \t10 | 00010 => [(electron: \t00 | 00010, photon: \t10 | 00000)]\n",
" positron: \t10 | 00100 => [(positron: \t00 | 00100, photon: \t10 | 00000)]\n",
" positron: \t10 | 01000 => [(positron: \t00 | 01000, photon: \t10 | 00000)]\n",
" positron: \t10 | 10000 => [(positron: \t00 | 10000, photon: \t10 | 00000)]\n",
" electron: \t11 | 00000 => [(electron: \t01 | 00000, photon: \t10 | 00000)]\n",
" electron: \t00 | 00111 => [(electron: \t00 | 00001, photon: \t00 | 00110), (electro…\n",
" electron: \t00 | 01011 => [(electron: \t00 | 00001, photon: \t00 | 01010), (electro…\n",
" positron: \t00 | 01101 => [(positron: \t00 | 00100, photon: \t00 | 01001), (positro…\n",
" positron: \t00 | 01110 => [(positron: \t00 | 00100, photon: \t00 | 01010), (positro…\n",
" ⋮ => ⋮"
"OrderedCollections.OrderedDict{VirtualParticle, Vector{Tuple{VirtualParticle, VirtualParticle}}} with 8 entries:\n",
" photon: \t00 | 011 => [(electron: \t00 | 001, positron: \t00 | 010)]\n",
" photon: \t00 | 101 => [(electron: \t00 | 001, positron: \t00 | 100)]\n",
" photon: \t01 | 010 => [(positron: \t00 | 010, electron: \t01 | 000)]\n",
" photon: \t01 | 100 => [(positron: \t00 | 100, electron: \t01 | 000)]\n",
" electron: \t10 | 001 => [(electron: \t00 | 001, photon: \t10 | 000)]\n",
" positron: \t10 | 010 => [(positron: \t00 | 010, photon: \t10 | 000)]\n",
" positron: \t10 | 100 => [(positron: \t00 | 100, photon: \t10 | 000)]\n",
" electron: \t11 | 000 => [(electron: \t01 | 000, photon: \t10 | 000)]"
]
},
"metadata": {},
@@ -120,27 +96,15 @@
{
"data": {
"text/plain": [
"81-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
" (photon: \t00 | 00101, electron: \t01 | 10010, positron: \t10 | 01000)\n",
" (photon: \t00 | 00101, electron: \t11 | 00000, positron: \t00 | 11010)\n",
" (photon: \t00 | 00101, electron: \t10 | 00010, positron: \t01 | 11000)\n",
" (photon: \t00 | 00101, electron: \t01 | 01010, positron: \t10 | 10000)\n",
" (photon: \t00 | 00110, electron: \t11 | 00000, positron: \t00 | 11001)\n",
" (photon: \t00 | 00110, electron: \t10 | 00001, positron: \t01 | 11000)\n",
" (photon: \t00 | 00110, electron: \t01 | 10001, positron: \t10 | 01000)\n",
" (photon: \t00 | 00110, electron: \t01 | 01001, positron: \t10 | 10000)\n",
" (photon: \t00 | 01001, electron: \t01 | 10010, positron: \t10 | 00100)\n",
" (photon: \t00 | 01001, electron: \t11 | 00000, positron: \t00 | 10110)\n",
" ⋮\n",
" (photon: \t10 | 00000, electron: \t01 | 10010, positron: \t00 | 01101)\n",
" (photon: \t10 | 00000, electron: \t01 | 00110, positron: \t00 | 11001)\n",
" (photon: \t10 | 00000, electron: \t00 | 00111, positron: \t01 | 11000)\n",
" (photon: \t10 | 00000, electron: \t00 | 01011, positron: \t01 | 10100)\n",
" (photon: \t10 | 00000, electron: \t01 | 10001, positron: \t00 | 01110)\n",
" (photon: \t10 | 00000, electron: \t00 | 10011, positron: \t01 | 01100)\n",
" (photon: \t10 | 00000, electron: \t01 | 01001, positron: \t00 | 10110)\n",
" (photon: \t10 | 00000, electron: \t01 | 00101, positron: \t00 | 11010)\n",
" (photon: \t10 | 00000, electron: \t01 | 01010, positron: \t00 | 10101)"
"8-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
" (photon: \t00 | 011, electron: \t01 | 000, positron: \t10 | 100)\n",
" (photon: \t00 | 011, electron: \t11 | 000, positron: \t00 | 100)\n",
" (photon: \t00 | 101, electron: \t01 | 000, positron: \t10 | 010)\n",
" (photon: \t00 | 101, electron: \t11 | 000, positron: \t00 | 010)\n",
" (photon: \t01 | 010, electron: \t00 | 001, positron: \t10 | 100)\n",
" (photon: \t01 | 010, electron: \t10 | 001, positron: \t00 | 100)\n",
" (photon: \t01 | 100, electron: \t00 | 001, positron: \t10 | 010)\n",
" (photon: \t01 | 100, electron: \t10 | 001, positron: \t00 | 010)"
]
},
"metadata": {},
@@ -160,34 +124,22 @@
"name": "stdout",
"output_type": "stream",
"text": [
"s: 252, should be: 252\n",
"number of triples: 81\n"
"s: 8, should be: 8\n",
"number of triples: 8\n"
]
},
{
"data": {
"text/plain": [
"81-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
" (photon: \t10 | 00000, electron: \t00 | 00111, positron: \t01 | 11000)\n",
" (photon: \t10 | 00000, electron: \t00 | 01011, positron: \t01 | 10100)\n",
" (photon: \t10 | 00000, electron: \t00 | 10011, positron: \t01 | 01100)\n",
" (photon: \t10 | 00000, electron: \t01 | 00101, positron: \t00 | 11010)\n",
" (photon: \t10 | 00000, electron: \t01 | 00110, positron: \t00 | 11001)\n",
" (photon: \t10 | 00000, electron: \t01 | 01001, positron: \t00 | 10110)\n",
" (photon: \t10 | 00000, electron: \t01 | 01010, positron: \t00 | 10101)\n",
" (photon: \t10 | 00000, electron: \t01 | 10001, positron: \t00 | 01110)\n",
" (photon: \t10 | 00000, electron: \t01 | 10010, positron: \t00 | 01101)\n",
" (photon: \t00 | 00101, electron: \t10 | 00010, positron: \t01 | 11000)\n",
" ⋮\n",
" (photon: \t11 | 00100, electron: \t00 | 10011, positron: \t00 | 01000)\n",
" (photon: \t11 | 01000, electron: \t00 | 00001, positron: \t00 | 10110)\n",
" (photon: \t11 | 01000, electron: \t00 | 00010, positron: \t00 | 10101)\n",
" (photon: \t11 | 01000, electron: \t00 | 00111, positron: \t00 | 10000)\n",
" (photon: \t11 | 01000, electron: \t00 | 10011, positron: \t00 | 00100)\n",
" (photon: \t11 | 10000, electron: \t00 | 00001, positron: \t00 | 01110)\n",
" (photon: \t11 | 10000, electron: \t00 | 00010, positron: \t00 | 01101)\n",
" (photon: \t11 | 10000, electron: \t00 | 00111, positron: \t00 | 01000)\n",
" (photon: \t11 | 10000, electron: \t00 | 01011, positron: \t00 | 00100)"
"8-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
" (photon: \t00 | 011, electron: \t01 | 000, positron: \t10 | 100)\n",
" (photon: \t00 | 011, electron: \t11 | 000, positron: \t00 | 100)\n",
" (photon: \t00 | 101, electron: \t01 | 000, positron: \t10 | 010)\n",
" (photon: \t00 | 101, electron: \t11 | 000, positron: \t00 | 010)\n",
" (photon: \t01 | 010, electron: \t00 | 001, positron: \t10 | 100)\n",
" (photon: \t01 | 010, electron: \t10 | 001, positron: \t00 | 100)\n",
" (photon: \t01 | 100, electron: \t00 | 001, positron: \t10 | 010)\n",
" (photon: \t01 | 100, electron: \t10 | 001, positron: \t00 | 010)"
]
},
"metadata": {},
@@ -226,11 +178,11 @@
"data": {
"text/plain": [
"Graph:\n",
" Nodes: Total: 23250, FeynmanDiagramGenerator.ComputeTask_CollectTriples: 128, FeynmanDiagramGenerator.ComputeTask_Pair: 492, \n",
" FeynmanDiagramGenerator.ComputeTask_BaseState: 14, MetagraphOptimization.DataTask: 11653, FeynmanDiagramGenerator.ComputeTask_Triple: 10368, \n",
" FeynmanDiagramGenerator.ComputeTask_PropagatePairs: 276, FeynmanDiagramGenerator.ComputeTask_CollectPairs: 276, FeynmanDiagramGenerator.ComputeTask_Propagator: 42, \n",
" FeynmanDiagramGenerator.ComputeTask_SpinPolCumulation: 1\n",
" Edges: 55281\n",
" Nodes: Total: 824, FeynmanDiagramGenerator.ComputeTask_CollectPairs: 32, FeynmanDiagramGenerator.ComputeTask_Triple: 256, \n",
" MetagraphOptimization.DataTask: 421, FeynmanDiagramGenerator.ComputeTask_BaseState: 10, FeynmanDiagramGenerator.ComputeTask_SpinPolCumulation: 1, \n",
" FeynmanDiagramGenerator.ComputeTask_Pair: 32, FeynmanDiagramGenerator.ComputeTask_CollectTriples: 32, FeynmanDiagramGenerator.ComputeTask_Propagator: 8, \n",
" FeynmanDiagramGenerator.ComputeTask_PropagatePairs: 32\n",
" Edges: 1637\n",
" Total Compute Effort: 0.0\n",
" Total Data Transfer: 0.0\n",
" Total Compute Intensity: 0.0\n"
@@ -287,7 +239,7 @@
{
"data": {
"text/plain": [
"PhaseSpacePoint{QEDProcess{Tuple{Photon, Electron}, Tuple{Electron, Electron, Electron, Positron, Positron}, Tuple{AllPolarization, AllSpin}, NTuple{5, AllSpin}}, PerturbativeQED, PhasespaceDefinition{SphericalCoordinateSystem, ElectronRestFrame}, Tuple{ParticleStateful{Incoming, Photon, SFourMomentum}, ParticleStateful{Incoming, Electron, SFourMomentum}}, Tuple{ParticleStateful{Outgoing, Electron, SFourMomentum}, ParticleStateful{Outgoing, Electron, SFourMomentum}, ParticleStateful{Outgoing, Electron, SFourMomentum}, ParticleStateful{Outgoing, Positron, SFourMomentum}, ParticleStateful{Outgoing, Positron, SFourMomentum}}, SFourMomentum}"
"PhaseSpacePoint{QEDProcess{Tuple{Photon, Electron}, Tuple{Electron, Electron, Positron}, Tuple{AllPolarization, AllSpin}, Tuple{AllSpin, AllSpin, AllSpin}}, PerturbativeQED, PhasespaceDefinition{SphericalCoordinateSystem, ElectronRestFrame}, Tuple{ParticleStateful{Incoming, Photon, SFourMomentum}, ParticleStateful{Incoming, Electron, SFourMomentum}}, Tuple{ParticleStateful{Outgoing, Electron, SFourMomentum}, ParticleStateful{Outgoing, Electron, SFourMomentum}, ParticleStateful{Outgoing, Positron, SFourMomentum}}, SFourMomentum}"
]
},
"metadata": {},
@@ -296,9 +248,9 @@
],
"source": [
"psp = PhaseSpacePoint(\n",
" proc, \n",
" PerturbativeQED(), \n",
" PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame()), \n",
" proc,\n",
" PerturbativeQED(),\n",
" PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame()),\n",
" tuple((rand(SFourMomentum) for _ in 1:number_incoming_particles(proc))...),\n",
" tuple((rand(SFourMomentum) for _ in 1:number_outgoing_particles(proc))...)\n",
")\n",
@@ -307,9 +259,19 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 11,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"32.69810945002751"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"using MetagraphOptimization: unpack_identity\n",
"\n",
@@ -320,9 +282,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"BenchmarkTools.Trial: 10000 samples with 1 evaluation.\n",
" Range \u001b[90m(\u001b[39m\u001b[36m\u001b[1mmin\u001b[22m\u001b[39m … \u001b[35mmax\u001b[39m\u001b[90m): \u001b[39m\u001b[36m\u001b[1m35.405 μs\u001b[22m\u001b[39m … \u001b[35m627.297 μs\u001b[39m \u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmin … max\u001b[90m): \u001b[39m0.00% … 0.00%\n",
" Time \u001b[90m(\u001b[39m\u001b[34m\u001b[1mmedian\u001b[22m\u001b[39m\u001b[90m): \u001b[39m\u001b[34m\u001b[1m41.790 μs \u001b[22m\u001b[39m\u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmedian\u001b[90m): \u001b[39m0.00%\n",
" Time \u001b[90m(\u001b[39m\u001b[32m\u001b[1mmean\u001b[22m\u001b[39m ± \u001b[32mσ\u001b[39m\u001b[90m): \u001b[39m\u001b[32m\u001b[1m54.989 μs\u001b[22m\u001b[39m ± \u001b[32m 33.980 μs\u001b[39m \u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmean ± σ\u001b[90m): \u001b[39m0.00% ± 0.00%\n",
"\n",
" \u001b[39m█\u001b[39m▇\u001b[34m▆\u001b[39m\u001b[39m▅\u001b[39m▄\u001b[39m▄\u001b[39m▄\u001b[32m▃\u001b[39m\u001b[39m▃\u001b[39m▃\u001b[39m▃\u001b[39m▂\u001b[39m▂\u001b[39m▁\u001b[39m▂\u001b[39m▂\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m▂\n",
" \u001b[39m█\u001b[39m█\u001b[34m█\u001b[39m\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[32m█\u001b[39m\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m▇\u001b[39m▇\u001b[39m█\u001b[39m█\u001b[39m▇\u001b[39m▇\u001b[39m▇\u001b[39m▇\u001b[39m▇\u001b[39m▇\u001b[39m▇\u001b[39m▇\u001b[39m▇\u001b[39m▇\u001b[39m▇\u001b[39m▆\u001b[39m▇\u001b[39m▆\u001b[39m▆\u001b[39m▅\u001b[39m▆\u001b[39m▅\u001b[39m▆\u001b[39m▅\u001b[39m▆\u001b[39m▅\u001b[39m▆\u001b[39m▄\u001b[39m▄\u001b[39m▄\u001b[39m▅\u001b[39m▅\u001b[39m▅\u001b[39m▆\u001b[39m \u001b[39m█\n",
" 35.4 μs\u001b[90m \u001b[39m\u001b[90mHistogram: \u001b[39m\u001b[90m\u001b[1mlog(\u001b[22m\u001b[39m\u001b[90mfrequency\u001b[39m\u001b[90m\u001b[1m)\u001b[22m\u001b[39m\u001b[90m by time\u001b[39m 197 μs \u001b[0m\u001b[1m<\u001b[22m\n",
"\n",
" Memory estimate\u001b[90m: \u001b[39m\u001b[33m3.66 KiB\u001b[39m, allocs estimate\u001b[90m: \u001b[39m\u001b[33m50\u001b[39m."
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"using BenchmarkTools\n",
"\n",

3584
notebooks/trident.ipynb Normal file

File diff suppressed because it is too large Load Diff