2024-07-12 01:08:09 +02:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
2024-07-17 18:22:54 +02:00
"WARNING: Method definition (::Type{QEDcore.ParticleStateful{DIR, SPECIES, ELEMENT} where ELEMENT<:QEDbase.AbstractFourMomentum})(QEDbase.AbstractFourMomentum) where {DIR<:QEDbase.ParticleDirection, SPECIES<:QEDbase.AbstractParticleType} in module QEDcore at /home/antonr/.julia/packages/QEDcore/uVldP/src/phase_spaces/create.jl:7 overwritten in module MetagraphOptimization at /home/antonr/.julia/packages/MetagraphOptimization/0iydf/src/QEDprocesses_patch.jl:15.\n",
2024-07-17 15:45:54 +02:00
"ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.\n",
2024-07-17 18:22:54 +02:00
"WARNING: Method definition (::Type{QEDcore.ParticleStateful{DIR, SPECIES, ELEMENT} where ELEMENT<:QEDbase.AbstractFourMomentum})(QEDbase.AbstractFourMomentum) where {DIR<:QEDbase.ParticleDirection, SPECIES<:QEDbase.AbstractParticleType} in module QEDcore at /home/antonr/.julia/packages/QEDcore/uVldP/src/phase_spaces/create.jl:7 overwritten in module MetagraphOptimization at /home/antonr/.julia/packages/MetagraphOptimization/0iydf/src/QEDprocesses_patch.jl:15.\n",
2024-07-12 01:08:09 +02:00
"ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.\n"
]
}
],
"source": [
2024-07-16 18:51:09 +02:00
"using Revise\n",
2024-07-12 01:08:09 +02:00
"using FeynmanDiagramGenerator"
]
},
{
"cell_type": "code",
2024-07-17 15:45:54 +02:00
"execution_count": 2,
2024-07-12 01:08:09 +02:00
"metadata": {},
2024-07-17 15:45:54 +02:00
"outputs": [
{
"data": {
"text/plain": [
2024-07-17 18:22:54 +02:00
"6-element Vector{VirtualParticle{QEDProcess{Tuple{Photon, Photon, Electron}, Tuple{Photon, Electron}, Tuple{AllPolarization, AllPolarization, AllSpin}, Tuple{AllPolarization, AllSpin}}, PT, 3, 2} where PT<:AbstractParticleType}:\n",
" positron: \t000 | 11\n",
" electron: \t001 | 10\n",
" positron: \t010 | 01\n",
" electron: \t011 | 00\n",
" positron: \t100 | 01\n",
" electron: \t101 | 00"
2024-07-17 15:45:54 +02:00
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING: both QEDcore and QEDbase export \"mul\"; uses of it in module FeynmanDiagramGenerator must be qualified\n"
]
}
],
2024-07-12 01:08:09 +02:00
"source": [
2024-07-17 18:22:54 +02:00
"proc = QEDProcess(2, 1, 1, 1, 0, 0)\n",
2024-07-12 01:08:09 +02:00
"all_particles = Set()\n",
2024-07-16 18:51:09 +02:00
"for fd in feynman_diagrams(proc)\n",
2024-07-12 01:08:09 +02:00
" push!(all_particles, virtual_particles(proc, fd)...)\n",
"end\n",
"all_particles = sort([all_particles...])\n",
"display(all_particles)\n"
]
},
{
"cell_type": "code",
2024-07-17 15:45:54 +02:00
"execution_count": 3,
2024-07-12 01:08:09 +02:00
"metadata": {},
2024-07-17 15:45:54 +02:00
"outputs": [
{
"data": {
"text/plain": [
2024-07-17 18:22:54 +02:00
"OrderedCollections.OrderedDict{VirtualParticle, Vector{Tuple{VirtualParticle, VirtualParticle}}} with 6 entries:\n",
" positron: \t000 | 11 => [(positron: \t000 | 01, photon: \t000 | 10)]\n",
" electron: \t001 | 10 => [(photon: \t000 | 10, electron: \t001 | 00)]\n",
" positron: \t010 | 01 => [(positron: \t000 | 01, photon: \t010 | 00)]\n",
" electron: \t011 | 00 => [(electron: \t001 | 00, photon: \t010 | 00)]\n",
" positron: \t100 | 01 => [(positron: \t000 | 01, photon: \t100 | 00)]\n",
" electron: \t101 | 00 => [(electron: \t001 | 00, photon: \t100 | 00)]"
2024-07-17 15:45:54 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
2024-07-12 01:08:09 +02:00
"source": [
2024-07-17 15:45:54 +02:00
"pairs = sort(FeynmanDiagramGenerator.particle_pairs(all_particles))"
2024-07-12 01:08:09 +02:00
]
},
{
"cell_type": "code",
2024-07-17 15:45:54 +02:00
"execution_count": 4,
2024-07-12 01:08:09 +02:00
"metadata": {},
2024-07-17 15:45:54 +02:00
"outputs": [
{
"data": {
"text/plain": [
2024-07-17 18:22:54 +02:00
"6-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
" (photon: \t000 | 10, electron: \t011 | 00, positron: \t100 | 01)\n",
" (photon: \t000 | 10, electron: \t101 | 00, positron: \t010 | 01)\n",
" (photon: \t010 | 00, electron: \t101 | 00, positron: \t000 | 11)\n",
" (photon: \t010 | 00, electron: \t001 | 10, positron: \t100 | 01)\n",
" (photon: \t100 | 00, electron: \t011 | 00, positron: \t000 | 11)\n",
" (photon: \t100 | 00, electron: \t001 | 10, positron: \t010 | 01)"
2024-07-17 15:45:54 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
2024-07-12 01:08:09 +02:00
"source": [
"triples = FeynmanDiagramGenerator.total_particle_triples(all_particles)"
]
},
{
"cell_type": "code",
2024-07-17 15:45:54 +02:00
"execution_count": 5,
2024-07-12 01:08:09 +02:00
"metadata": {},
2024-07-17 15:45:54 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-07-17 18:22:54 +02:00
"s: 6, should be: 6\n",
"number of triples: 6\n"
2024-07-17 15:45:54 +02:00
]
},
{
"data": {
"text/plain": [
2024-07-17 18:22:54 +02:00
"6-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
" (photon: \t000 | 10, electron: \t011 | 00, positron: \t100 | 01)\n",
" (photon: \t000 | 10, electron: \t101 | 00, positron: \t010 | 01)\n",
" (photon: \t010 | 00, electron: \t001 | 10, positron: \t100 | 01)\n",
" (photon: \t010 | 00, electron: \t101 | 00, positron: \t000 | 11)\n",
" (photon: \t100 | 00, electron: \t001 | 10, positron: \t010 | 01)\n",
" (photon: \t100 | 00, electron: \t011 | 00, positron: \t000 | 11)"
2024-07-17 15:45:54 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
2024-07-12 01:08:09 +02:00
"source": [
"function n(vp::VirtualParticle)\n",
" if !haskey(pairs, vp)\n",
" return 1\n",
" end\n",
" s = 0\n",
" for (l, r) in pairs[vp]\n",
" s += n(l) * n(r)\n",
" end\n",
" return s\n",
"end\n",
"\n",
"s = 0\n",
"for (ph, e, p) in triples\n",
" s += n(ph) * n(e) * n(p)\n",
"end\n",
"\n",
"println(\"s: $s, should be: $(length(feynman_diagrams(proc)))\")\n",
"println(\"number of triples: $(length(triples))\")\n",
"\n",
"sort(triples)"
]
2024-07-16 18:51:09 +02:00
},
2024-07-17 15:45:54 +02:00
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Graph:\n",
2024-07-17 18:22:54 +02:00
" Nodes: Total: 642, FeynmanDiagramGenerator.ComputeTask_PropagatePairs: 24, FeynmanDiagramGenerator.ComputeTask_CollectPairs: 24, \n",
" FeynmanDiagramGenerator.ComputeTask_Triple: 192, FeynmanDiagramGenerator.ComputeTask_SpinPolCumulation: 1, MetagraphOptimization.DataTask: 329, \n",
" FeynmanDiagramGenerator.ComputeTask_BaseState: 10, FeynmanDiagramGenerator.ComputeTask_Pair: 24, FeynmanDiagramGenerator.ComputeTask_Propagator: 6, \n",
" FeynmanDiagramGenerator.ComputeTask_CollectTriples: 32\n",
" Edges: 1249\n",
2024-07-17 15:45:54 +02:00
" Total Compute Effort: 0.0\n",
" Total Data Transfer: 0.0\n",
" Total Compute Intensity: 0.0\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"graph = generate_DAG(proc)"
]
},
{
"cell_type": "code",
2024-07-17 18:22:54 +02:00
"execution_count": 7,
2024-07-17 15:45:54 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
2024-07-17 18:22:54 +02:00
"mock_machine (generic function with 1 method)"
2024-07-17 15:45:54 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"using MetagraphOptimization\n",
"using UUIDs\n",
"\n",
"function mock_machine()\n",
" return Machine(\n",
" [\n",
" MetagraphOptimization.NumaNode(\n",
" 0,\n",
" 1,\n",
" MetagraphOptimization.default_strategy(MetagraphOptimization.NumaNode),\n",
" -1.0,\n",
" UUIDs.uuid1(),\n",
" ),\n",
" ],\n",
" [-1.0;;],\n",
" )\n",
2024-07-17 18:22:54 +02:00
"end"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"PhaseSpacePoint{QEDProcess{Tuple{Photon, Photon, Electron}, Tuple{Photon, Electron}, Tuple{AllPolarization, AllPolarization, AllSpin}, Tuple{AllPolarization, AllSpin}}, PerturbativeQED, PhasespaceDefinition{SphericalCoordinateSystem, ElectronRestFrame}, Tuple{ParticleStateful{Incoming, Photon, SFourMomentum}, ParticleStateful{Incoming, Photon, SFourMomentum}, ParticleStateful{Incoming, Electron, SFourMomentum}}, Tuple{ParticleStateful{Outgoing, Photon, SFourMomentum}, ParticleStateful{Outgoing, Electron, SFourMomentum}}, SFourMomentum}"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"psp = PhaseSpacePoint(\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",
"typeof(psp)"
2024-07-17 15:45:54 +02:00
]
},
2024-07-16 18:51:09 +02:00
{
"cell_type": "code",
2024-07-17 18:22:54 +02:00
"execution_count": 9,
2024-07-16 18:51:09 +02:00
"metadata": {},
2024-07-17 18:22:54 +02:00
"outputs": [
{
"ename": "Base.Meta.ParseError",
"evalue": "Error trying to display an error.",
"output_type": "error",
"traceback": [
"Error trying to display an error."
]
}
],
2024-07-16 18:51:09 +02:00
"source": [
2024-07-17 18:22:54 +02:00
"func = eval(get_compute_function(graph, proc, mock_machine()))\n",
"\n",
"func(psp)"
2024-07-16 18:51:09 +02:00
]
2024-07-12 01:08:09 +02:00
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.10.4",
"language": "julia",
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}