FeynmanDiagrams.jl/notebooks/diagram_generation.ipynb

282 lines
10 KiB
Plaintext
Raw Normal View History

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
2024-07-17 15:45: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/mvCVq/src/QEDprocesses_patch.jl:15.\n",
"ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.\n",
2024-07-16 18:51:09 +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/mvCVq/src/QEDprocesses_patch.jl:15.\n",
"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",
"using FeynmanDiagramGenerator"
]
},
{
"cell_type": "code",
2024-07-17 15:45:54 +02:00
"execution_count": 2,
"metadata": {},
2024-07-17 15:45:54 +02:00
"outputs": [
{
"data": {
"text/plain": [
"14-element Vector{VirtualParticle{GenericQEDProcess{Tuple{Photon, Photon, Photon, Electron}, Tuple{Photon, Electron}, Tuple{AllPolarization, AllPolarization, AllPolarization, AllSpin}, Tuple{AllPolarization, AllSpin}}, PT, 4, 2} where PT<:AbstractParticleType}:\n",
" positron: \t0000 | 11\n",
" electron: \t0001 | 10\n",
" positron: \t0010 | 01\n",
" electron: \t0011 | 00\n",
" positron: \t0100 | 01\n",
" electron: \t0101 | 00\n",
" positron: \t1000 | 01\n",
" electron: \t1001 | 00\n",
" positron: \t1000 | 11\n",
" electron: \t1001 | 10\n",
" positron: \t1010 | 01\n",
" electron: \t1011 | 00\n",
" positron: \t1100 | 01\n",
" electron: \t1101 | 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"
]
}
],
"source": [
2024-07-16 18:51:09 +02:00
"proc = GenericQEDProcess(3, 1, 1, 1, 0, 0)\n",
"all_particles = Set()\n",
2024-07-16 18:51:09 +02:00
"for fd in feynman_diagrams(proc)\n",
" 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,
"metadata": {},
2024-07-17 15:45:54 +02:00
"outputs": [
{
"data": {
"text/plain": [
"OrderedCollections.OrderedDict{VirtualParticle, Vector{Tuple{VirtualParticle, VirtualParticle}}} with 14 entries:\n",
" positron: \t0000 | 11 => [(positron: \t0000 | 01, photon: \t0000 | 10)]\n",
" electron: \t0001 | 10 => [(photon: \t0000 | 10, electron: \t0001 | 00)]\n",
" positron: \t0010 | 01 => [(positron: \t0000 | 01, photon: \t0010 | 00)]\n",
" electron: \t0011 | 00 => [(electron: \t0001 | 00, photon: \t0010 | 00)]\n",
" positron: \t0100 | 01 => [(positron: \t0000 | 01, photon: \t0100 | 00)]\n",
" electron: \t0101 | 00 => [(electron: \t0001 | 00, photon: \t0100 | 00)]\n",
" positron: \t1000 | 01 => [(positron: \t0000 | 01, photon: \t1000 | 00)]\n",
" electron: \t1001 | 00 => [(electron: \t0001 | 00, photon: \t1000 | 00)]\n",
" positron: \t1000 | 11 => [(photon: \t0000 | 10, positron: \t1000 | 01), (photon: \t10…\n",
" electron: \t1001 | 10 => [(photon: \t0000 | 10, electron: \t1001 | 00), (photon: \t10…\n",
" positron: \t1010 | 01 => [(photon: \t0010 | 00, positron: \t1000 | 01), (photon: \t10…\n",
" electron: \t1011 | 00 => [(photon: \t0010 | 00, electron: \t1001 | 00), (photon: \t10…\n",
" positron: \t1100 | 01 => [(photon: \t0100 | 00, positron: \t1000 | 01), (photon: \t10…\n",
" electron: \t1101 | 00 => [(photon: \t0100 | 00, electron: \t1001 | 00), (photon: \t10…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2024-07-17 15:45:54 +02:00
"pairs = sort(FeynmanDiagramGenerator.particle_pairs(all_particles))"
]
},
{
"cell_type": "code",
2024-07-17 15:45:54 +02:00
"execution_count": 4,
"metadata": {},
2024-07-17 15:45:54 +02:00
"outputs": [
{
"data": {
"text/plain": [
"12-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
" (photon: \t0000 | 10, electron: \t0011 | 00, positron: \t1100 | 01)\n",
" (photon: \t0000 | 10, electron: \t0101 | 00, positron: \t1010 | 01)\n",
" (photon: \t0000 | 10, electron: \t1101 | 00, positron: \t0010 | 01)\n",
" (photon: \t0000 | 10, electron: \t1011 | 00, positron: \t0100 | 01)\n",
" (photon: \t0010 | 00, electron: \t0001 | 10, positron: \t1100 | 01)\n",
" (photon: \t0010 | 00, electron: \t0101 | 00, positron: \t1000 | 11)\n",
" (photon: \t0010 | 00, electron: \t1101 | 00, positron: \t0000 | 11)\n",
" (photon: \t0010 | 00, electron: \t1001 | 10, positron: \t0100 | 01)\n",
" (photon: \t0100 | 00, electron: \t0001 | 10, positron: \t1010 | 01)\n",
" (photon: \t0100 | 00, electron: \t0011 | 00, positron: \t1000 | 11)\n",
" (photon: \t0100 | 00, electron: \t1011 | 00, positron: \t0000 | 11)\n",
" (photon: \t0100 | 00, electron: \t1001 | 10, positron: \t0010 | 01)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"triples = FeynmanDiagramGenerator.total_particle_triples(all_particles)"
]
},
{
"cell_type": "code",
2024-07-17 15:45:54 +02:00
"execution_count": 5,
"metadata": {},
2024-07-17 15:45:54 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"s: 24, should be: 24\n",
"number of triples: 12\n"
]
},
{
"data": {
"text/plain": [
"12-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
" (photon: \t0000 | 10, electron: \t0011 | 00, positron: \t1100 | 01)\n",
" (photon: \t0000 | 10, electron: \t0101 | 00, positron: \t1010 | 01)\n",
" (photon: \t0000 | 10, electron: \t1011 | 00, positron: \t0100 | 01)\n",
" (photon: \t0000 | 10, electron: \t1101 | 00, positron: \t0010 | 01)\n",
" (photon: \t0010 | 00, electron: \t0001 | 10, positron: \t1100 | 01)\n",
" (photon: \t0010 | 00, electron: \t0101 | 00, positron: \t1000 | 11)\n",
" (photon: \t0010 | 00, electron: \t1001 | 10, positron: \t0100 | 01)\n",
" (photon: \t0010 | 00, electron: \t1101 | 00, positron: \t0000 | 11)\n",
" (photon: \t0100 | 00, electron: \t0001 | 10, positron: \t1010 | 01)\n",
" (photon: \t0100 | 00, electron: \t0011 | 00, positron: \t1000 | 11)\n",
" (photon: \t0100 | 00, electron: \t1001 | 10, positron: \t0010 | 01)\n",
" (photon: \t0100 | 00, electron: \t1011 | 00, positron: \t0000 | 11)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"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",
" Nodes: Total: 2320, FeynmanDiagramGenerator.ComputeTask_CollectTriples: 64, MetagraphOptimization.DataTask: 1173, \n",
" FeynmanDiagramGenerator.ComputeTask_CollectPairs: 80, FeynmanDiagramGenerator.ComputeTask_SpinPolCumulation: 1, FeynmanDiagramGenerator.ComputeTask_Propagator: 14, \n",
" FeynmanDiagramGenerator.ComputeTask_Triple: 768, FeynmanDiagramGenerator.ComputeTask_BaseState: 12, FeynmanDiagramGenerator.ComputeTask_PropagatePairs: 80, \n",
" FeynmanDiagramGenerator.ComputeTask_Pair: 128\n",
" Edges: 4853\n",
" 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",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"compute__2e0e67fe_4441_11ef_36f2_5fda31178519 (generic function with 1 method)"
]
},
"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",
"end\n",
"\n",
"func = get_compute_function(graph, proc, mock_machine())"
]
},
2024-07-16 18:51:09 +02:00
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
2024-07-17 15:45:54 +02:00
"psp = PhaseSpacePoint(proc, PerturbativeQED(), PhasespaceDefinition(SphericalCoordinateSystem(), ElectronRestFrame()), [rand(SFourMomentum) for _ in 1:number_incoming_particles(proc)], [rand(SFourMomentum) for _ in 1:number_outgoing_particles(proc)])"
2024-07-16 18:51: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
}