Only use Ref of psp in propagator input

This commit is contained in:
Rubydragon 2024-07-19 08:50:59 +02:00
parent 00a1252c9a
commit 7de7aa2353
3 changed files with 114 additions and 54 deletions

View File

@ -9,9 +9,9 @@
"name": "stderr", "name": "stderr",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"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", "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/kQaEJ/src/QEDprocesses_patch.jl:15.\n",
"ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.\n", "ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.\n",
"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", "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/kQaEJ/src/QEDprocesses_patch.jl:15.\n",
"ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.\n" "ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.\n"
] ]
} }
@ -29,13 +29,27 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"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", "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",
" positron: \t000 | 11\n", " photon: \t00 | 00101\n",
" electron: \t001 | 10\n", " photon: \t00 | 00110\n",
" positron: \t010 | 01\n", " photon: \t00 | 01001\n",
" electron: \t011 | 00\n", " photon: \t00 | 01010\n",
" positron: \t100 | 01\n", " photon: \t00 | 10001\n",
" electron: \t101 | 00" " 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"
] ]
}, },
"metadata": {}, "metadata": {},
@ -50,7 +64,7 @@
} }
], ],
"source": [ "source": [
"proc = QEDProcess(2, 1, 1, 1, 0, 0)\n", "proc = QEDProcess(1, 0, 1, 3, 0, 2)\n",
"all_particles = Set()\n", "all_particles = Set()\n",
"for fd in feynman_diagrams(proc)\n", "for fd in feynman_diagrams(proc)\n",
" push!(all_particles, virtual_particles(proc, fd)...)\n", " push!(all_particles, virtual_particles(proc, fd)...)\n",
@ -67,13 +81,27 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"OrderedCollections.OrderedDict{VirtualParticle, Vector{Tuple{VirtualParticle, VirtualParticle}}} with 6 entries:\n", "OrderedCollections.OrderedDict{VirtualParticle, Vector{Tuple{VirtualParticle, VirtualParticle}}} with 42 entries:\n",
" positron: \t000 | 11 => [(positron: \t000 | 01, photon: \t000 | 10)]\n", " photon: \t00 | 00101 => [(electron: \t00 | 00001, positron: \t00 | 00100)]\n",
" electron: \t001 | 10 => [(photon: \t000 | 10, electron: \t001 | 00)]\n", " photon: \t00 | 00110 => [(electron: \t00 | 00010, positron: \t00 | 00100)]\n",
" positron: \t010 | 01 => [(positron: \t000 | 01, photon: \t010 | 00)]\n", " photon: \t00 | 01001 => [(electron: \t00 | 00001, positron: \t00 | 01000)]\n",
" electron: \t011 | 00 => [(electron: \t001 | 00, photon: \t010 | 00)]\n", " photon: \t00 | 01010 => [(electron: \t00 | 00010, positron: \t00 | 01000)]\n",
" positron: \t100 | 01 => [(positron: \t000 | 01, photon: \t100 | 00)]\n", " photon: \t00 | 10001 => [(electron: \t00 | 00001, positron: \t00 | 10000)]\n",
" electron: \t101 | 00 => [(electron: \t001 | 00, photon: \t100 | 00)]" " 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",
" ⋮ => ⋮"
] ]
}, },
"metadata": {}, "metadata": {},
@ -92,13 +120,27 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"6-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n", "81-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
" (photon: \t000 | 10, electron: \t011 | 00, positron: \t100 | 01)\n", " (photon: \t00 | 00101, electron: \t01 | 10010, positron: \t10 | 01000)\n",
" (photon: \t000 | 10, electron: \t101 | 00, positron: \t010 | 01)\n", " (photon: \t00 | 00101, electron: \t11 | 00000, positron: \t00 | 11010)\n",
" (photon: \t010 | 00, electron: \t101 | 00, positron: \t000 | 11)\n", " (photon: \t00 | 00101, electron: \t10 | 00010, positron: \t01 | 11000)\n",
" (photon: \t010 | 00, electron: \t001 | 10, positron: \t100 | 01)\n", " (photon: \t00 | 00101, electron: \t01 | 01010, positron: \t10 | 10000)\n",
" (photon: \t100 | 00, electron: \t011 | 00, positron: \t000 | 11)\n", " (photon: \t00 | 00110, electron: \t11 | 00000, positron: \t00 | 11001)\n",
" (photon: \t100 | 00, electron: \t001 | 10, positron: \t010 | 01)" " (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)"
] ]
}, },
"metadata": {}, "metadata": {},
@ -118,20 +160,34 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"s: 6, should be: 6\n", "s: 252, should be: 252\n",
"number of triples: 6\n" "number of triples: 81\n"
] ]
}, },
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"6-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n", "81-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
" (photon: \t000 | 10, electron: \t011 | 00, positron: \t100 | 01)\n", " (photon: \t10 | 00000, electron: \t00 | 00111, positron: \t01 | 11000)\n",
" (photon: \t000 | 10, electron: \t101 | 00, positron: \t010 | 01)\n", " (photon: \t10 | 00000, electron: \t00 | 01011, positron: \t01 | 10100)\n",
" (photon: \t010 | 00, electron: \t001 | 10, positron: \t100 | 01)\n", " (photon: \t10 | 00000, electron: \t00 | 10011, positron: \t01 | 01100)\n",
" (photon: \t010 | 00, electron: \t101 | 00, positron: \t000 | 11)\n", " (photon: \t10 | 00000, electron: \t01 | 00101, positron: \t00 | 11010)\n",
" (photon: \t100 | 00, electron: \t001 | 10, positron: \t010 | 01)\n", " (photon: \t10 | 00000, electron: \t01 | 00110, positron: \t00 | 11001)\n",
" (photon: \t100 | 00, electron: \t011 | 00, positron: \t000 | 11)" " (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)"
] ]
}, },
"metadata": {}, "metadata": {},
@ -170,11 +226,11 @@
"data": { "data": {
"text/plain": [ "text/plain": [
"Graph:\n", "Graph:\n",
" Nodes: Total: 642, FeynmanDiagramGenerator.ComputeTask_PropagatePairs: 24, FeynmanDiagramGenerator.ComputeTask_CollectPairs: 24, \n", " Nodes: Total: 23250, FeynmanDiagramGenerator.ComputeTask_CollectTriples: 128, FeynmanDiagramGenerator.ComputeTask_Pair: 492, \n",
" FeynmanDiagramGenerator.ComputeTask_Triple: 192, FeynmanDiagramGenerator.ComputeTask_SpinPolCumulation: 1, MetagraphOptimization.DataTask: 329, \n", " FeynmanDiagramGenerator.ComputeTask_BaseState: 14, MetagraphOptimization.DataTask: 11653, FeynmanDiagramGenerator.ComputeTask_Triple: 10368, \n",
" FeynmanDiagramGenerator.ComputeTask_BaseState: 10, FeynmanDiagramGenerator.ComputeTask_Pair: 24, FeynmanDiagramGenerator.ComputeTask_Propagator: 6, \n", " FeynmanDiagramGenerator.ComputeTask_PropagatePairs: 276, FeynmanDiagramGenerator.ComputeTask_CollectPairs: 276, FeynmanDiagramGenerator.ComputeTask_Propagator: 42, \n",
" FeynmanDiagramGenerator.ComputeTask_CollectTriples: 32\n", " FeynmanDiagramGenerator.ComputeTask_SpinPolCumulation: 1\n",
" Edges: 1249\n", " Edges: 55281\n",
" Total Compute Effort: 0.0\n", " Total Compute Effort: 0.0\n",
" Total Data Transfer: 0.0\n", " Total Data Transfer: 0.0\n",
" Total Compute Intensity: 0.0\n" " Total Compute Intensity: 0.0\n"
@ -231,7 +287,7 @@
{ {
"data": { "data": {
"text/plain": [ "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}" "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}"
] ]
}, },
"metadata": {}, "metadata": {},
@ -253,21 +309,25 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"ename": "Base.Meta.ParseError",
"evalue": "Error trying to display an error.",
"output_type": "error",
"traceback": [
"Error trying to display an error."
]
}
],
"source": [ "source": [
"using MetagraphOptimization: unpack_identity\n",
"\n",
"func = eval(get_compute_function(graph, proc, mock_machine()))\n", "func = eval(get_compute_function(graph, proc, mock_machine()))\n",
"\n", "\n",
"func(psp)" "func(psp)"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"using BenchmarkTools\n",
"\n",
"@benchmark func($psp)"
]
} }
], ],
"metadata": { "metadata": {

View File

@ -63,21 +63,21 @@ end
struct PropagatorInput{VP_T<:VirtualParticle,PSP_T<:AbstractPhaseSpacePoint} struct PropagatorInput{VP_T<:VirtualParticle,PSP_T<:AbstractPhaseSpacePoint}
vp::VP_T vp::VP_T
psp::PSP_T psp::Ref{PSP_T}
end end
@inline function compute( @inline function compute(
::ComputeTask_Propagator, input::PropagatorInput{VP_T,PSP_T} ::ComputeTask_Propagator, input::PropagatorInput{VP_T,PSP_T}
) where {VP_T,PSP_T} ) where {VP_T,PSP_T}
vp_mom = zero(typeof(momentum(input.psp, Incoming(), 1))) vp_mom = zero(typeof(momentum(input.psp[], Incoming(), 1)))
for i in eachindex(in_contributions(input.vp)) for i in eachindex(in_contributions(input.vp))
if in_contributions(input.vp)[i] if in_contributions(input.vp)[i]
vp_mom += momentum(input.psp, Incoming(), i) vp_mom += momentum(input.psp[], Incoming(), i)
end end
end end
for o in eachindex(out_contributions(input.vp)) for o in eachindex(out_contributions(input.vp))
if (out_contributions(input.vp))[o] if (out_contributions(input.vp))[o]
vp_mom -= momentum(input.psp, Outgoing(), o) vp_mom -= momentum(input.psp[], Outgoing(), o)
end end
end end

View File

@ -87,7 +87,7 @@ function MetagraphOptimization.input_expr(
$(vp.in_particle_contributions), $(vp.in_particle_contributions),
$(vp.out_particle_contributions) $(vp.out_particle_contributions)
), ),
$psp_symbol Ref($psp_symbol)
)") )")
else else
throw(InvalidInputError("failed to parse node name \"$name\"")) throw(InvalidInputError("failed to parse node name \"$name\""))