WIP on DAG generation

This commit is contained in:
2024-07-17 15:45:54 +02:00
parent a647801f12
commit 4f0da3dffb
3 changed files with 509 additions and 48 deletions

View File

@@ -9,6 +9,8 @@
"name": "stderr",
"output_type": "stream",
"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/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",
"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"
]
@@ -21,9 +23,40 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"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": [
"proc = GenericQEDProcess(3, 1, 1, 1, 0, 0)\n",
"all_particles = Set()\n",
@@ -36,27 +69,103 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"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": [
"pairs = FeynmanDiagramGenerator.particle_pairs(all_particles)"
"pairs = sort(FeynmanDiagramGenerator.particle_pairs(all_particles))"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"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",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"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",
@@ -80,13 +189,77 @@
"sort(triples)"
]
},
{
"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())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"generate_DAG(proc)"
"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)])"
]
}
],