Finish DAG generation and function
This commit is contained in:
parent
4f0da3dffb
commit
00a1252c9a
@ -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/mvCVq/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/0iydf/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/mvCVq/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/0iydf/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,21 +29,13 @@
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"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",
|
"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: \t0000 | 11\n",
|
" positron: \t000 | 11\n",
|
||||||
" electron: \t0001 | 10\n",
|
" electron: \t001 | 10\n",
|
||||||
" positron: \t0010 | 01\n",
|
" positron: \t010 | 01\n",
|
||||||
" electron: \t0011 | 00\n",
|
" electron: \t011 | 00\n",
|
||||||
" positron: \t0100 | 01\n",
|
" positron: \t100 | 01\n",
|
||||||
" electron: \t0101 | 00\n",
|
" electron: \t101 | 00"
|
||||||
" 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": {},
|
"metadata": {},
|
||||||
@ -58,7 +50,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"proc = GenericQEDProcess(3, 1, 1, 1, 0, 0)\n",
|
"proc = QEDProcess(2, 1, 1, 1, 0, 0)\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",
|
||||||
@ -75,21 +67,13 @@
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"OrderedCollections.OrderedDict{VirtualParticle, Vector{Tuple{VirtualParticle, VirtualParticle}}} with 14 entries:\n",
|
"OrderedCollections.OrderedDict{VirtualParticle, Vector{Tuple{VirtualParticle, VirtualParticle}}} with 6 entries:\n",
|
||||||
" positron: \t0000 | 11 => [(positron: \t0000 | 01, photon: \t0000 | 10)]\n",
|
" positron: \t000 | 11 => [(positron: \t000 | 01, photon: \t000 | 10)]\n",
|
||||||
" electron: \t0001 | 10 => [(photon: \t0000 | 10, electron: \t0001 | 00)]\n",
|
" electron: \t001 | 10 => [(photon: \t000 | 10, electron: \t001 | 00)]\n",
|
||||||
" positron: \t0010 | 01 => [(positron: \t0000 | 01, photon: \t0010 | 00)]\n",
|
" positron: \t010 | 01 => [(positron: \t000 | 01, photon: \t010 | 00)]\n",
|
||||||
" electron: \t0011 | 00 => [(electron: \t0001 | 00, photon: \t0010 | 00)]\n",
|
" electron: \t011 | 00 => [(electron: \t001 | 00, photon: \t010 | 00)]\n",
|
||||||
" positron: \t0100 | 01 => [(positron: \t0000 | 01, photon: \t0100 | 00)]\n",
|
" positron: \t100 | 01 => [(positron: \t000 | 01, photon: \t100 | 00)]\n",
|
||||||
" electron: \t0101 | 00 => [(electron: \t0001 | 00, photon: \t0100 | 00)]\n",
|
" electron: \t101 | 00 => [(electron: \t001 | 00, photon: \t100 | 00)]"
|
||||||
" 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": {},
|
"metadata": {},
|
||||||
@ -108,19 +92,13 @@
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"12-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
|
"6-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
|
||||||
" (photon: \t0000 | 10, electron: \t0011 | 00, positron: \t1100 | 01)\n",
|
" (photon: \t000 | 10, electron: \t011 | 00, positron: \t100 | 01)\n",
|
||||||
" (photon: \t0000 | 10, electron: \t0101 | 00, positron: \t1010 | 01)\n",
|
" (photon: \t000 | 10, electron: \t101 | 00, positron: \t010 | 01)\n",
|
||||||
" (photon: \t0000 | 10, electron: \t1101 | 00, positron: \t0010 | 01)\n",
|
" (photon: \t010 | 00, electron: \t101 | 00, positron: \t000 | 11)\n",
|
||||||
" (photon: \t0000 | 10, electron: \t1011 | 00, positron: \t0100 | 01)\n",
|
" (photon: \t010 | 00, electron: \t001 | 10, positron: \t100 | 01)\n",
|
||||||
" (photon: \t0010 | 00, electron: \t0001 | 10, positron: \t1100 | 01)\n",
|
" (photon: \t100 | 00, electron: \t011 | 00, positron: \t000 | 11)\n",
|
||||||
" (photon: \t0010 | 00, electron: \t0101 | 00, positron: \t1000 | 11)\n",
|
" (photon: \t100 | 00, electron: \t001 | 10, positron: \t010 | 01)"
|
||||||
" (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": {},
|
"metadata": {},
|
||||||
@ -140,26 +118,20 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"s: 24, should be: 24\n",
|
"s: 6, should be: 6\n",
|
||||||
"number of triples: 12\n"
|
"number of triples: 6\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"12-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
|
"6-element Vector{Tuple{VirtualParticle, VirtualParticle, VirtualParticle}}:\n",
|
||||||
" (photon: \t0000 | 10, electron: \t0011 | 00, positron: \t1100 | 01)\n",
|
" (photon: \t000 | 10, electron: \t011 | 00, positron: \t100 | 01)\n",
|
||||||
" (photon: \t0000 | 10, electron: \t0101 | 00, positron: \t1010 | 01)\n",
|
" (photon: \t000 | 10, electron: \t101 | 00, positron: \t010 | 01)\n",
|
||||||
" (photon: \t0000 | 10, electron: \t1011 | 00, positron: \t0100 | 01)\n",
|
" (photon: \t010 | 00, electron: \t001 | 10, positron: \t100 | 01)\n",
|
||||||
" (photon: \t0000 | 10, electron: \t1101 | 00, positron: \t0010 | 01)\n",
|
" (photon: \t010 | 00, electron: \t101 | 00, positron: \t000 | 11)\n",
|
||||||
" (photon: \t0010 | 00, electron: \t0001 | 10, positron: \t1100 | 01)\n",
|
" (photon: \t100 | 00, electron: \t001 | 10, positron: \t010 | 01)\n",
|
||||||
" (photon: \t0010 | 00, electron: \t0101 | 00, positron: \t1000 | 11)\n",
|
" (photon: \t100 | 00, electron: \t011 | 00, positron: \t000 | 11)"
|
||||||
" (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": {},
|
"metadata": {},
|
||||||
@ -198,11 +170,11 @@
|
|||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"Graph:\n",
|
"Graph:\n",
|
||||||
" Nodes: Total: 2320, FeynmanDiagramGenerator.ComputeTask_CollectTriples: 64, MetagraphOptimization.DataTask: 1173, \n",
|
" Nodes: Total: 642, FeynmanDiagramGenerator.ComputeTask_PropagatePairs: 24, FeynmanDiagramGenerator.ComputeTask_CollectPairs: 24, \n",
|
||||||
" FeynmanDiagramGenerator.ComputeTask_CollectPairs: 80, FeynmanDiagramGenerator.ComputeTask_SpinPolCumulation: 1, FeynmanDiagramGenerator.ComputeTask_Propagator: 14, \n",
|
" FeynmanDiagramGenerator.ComputeTask_Triple: 192, FeynmanDiagramGenerator.ComputeTask_SpinPolCumulation: 1, MetagraphOptimization.DataTask: 329, \n",
|
||||||
" FeynmanDiagramGenerator.ComputeTask_Triple: 768, FeynmanDiagramGenerator.ComputeTask_BaseState: 12, FeynmanDiagramGenerator.ComputeTask_PropagatePairs: 80, \n",
|
" FeynmanDiagramGenerator.ComputeTask_BaseState: 10, FeynmanDiagramGenerator.ComputeTask_Pair: 24, FeynmanDiagramGenerator.ComputeTask_Propagator: 6, \n",
|
||||||
" FeynmanDiagramGenerator.ComputeTask_Pair: 128\n",
|
" FeynmanDiagramGenerator.ComputeTask_CollectTriples: 32\n",
|
||||||
" Edges: 4853\n",
|
" Edges: 1249\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"
|
||||||
@ -218,13 +190,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 16,
|
"execution_count": 7,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"compute__2e0e67fe_4441_11ef_36f2_5fda31178519 (generic function with 1 method)"
|
"mock_machine (generic function with 1 method)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
@ -248,18 +220,53 @@
|
|||||||
" ],\n",
|
" ],\n",
|
||||||
" [-1.0;;],\n",
|
" [-1.0;;],\n",
|
||||||
" )\n",
|
" )\n",
|
||||||
"end\n",
|
"end"
|
||||||
"\n",
|
|
||||||
"func = get_compute_function(graph, proc, mock_machine())"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 8,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"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": [
|
"source": [
|
||||||
"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)])"
|
"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)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 9,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"ename": "Base.Meta.ParseError",
|
||||||
|
"evalue": "Error trying to display an error.",
|
||||||
|
"output_type": "error",
|
||||||
|
"traceback": [
|
||||||
|
"Error trying to display an error."
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"func = eval(get_compute_function(graph, proc, mock_machine()))\n",
|
||||||
|
"\n",
|
||||||
|
"func(psp)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -14,7 +14,7 @@ import QEDbase.process
|
|||||||
|
|
||||||
export FlatMatrix
|
export FlatMatrix
|
||||||
|
|
||||||
export GenericQEDProcess, isphysical
|
export QEDProcess, isphysical
|
||||||
|
|
||||||
export AbstractTreeLevelFeynmanDiagram, FeynmanVertex, FeynmanDiagram
|
export AbstractTreeLevelFeynmanDiagram, FeynmanVertex, FeynmanDiagram
|
||||||
export external_particles, virtual_particles, process, generate_DAG
|
export external_particles, virtual_particles, process, generate_DAG
|
||||||
|
@ -682,7 +682,7 @@ function Base.iterate(iter::FeynmanDiagramIterator{E,U,T,M}, ::Nothing) where {E
|
|||||||
return (f, nothing)
|
return (f, nothing)
|
||||||
end
|
end
|
||||||
|
|
||||||
function feynman_diagrams(proc::PROC) where {PROC<:GenericQEDProcess}
|
function feynman_diagrams(proc::PROC) where {PROC<:QEDProcess}
|
||||||
return feynman_diagrams(incoming_particles(proc), outgoing_particles(proc))
|
return feynman_diagrams(incoming_particles(proc), outgoing_particles(proc))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -727,7 +727,7 @@ function feynman_diagrams(in_particles::Tuple, out_particles::Tuple)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
function virtual_particles(proc::GenericQEDProcess)
|
function virtual_particles(proc::QEDProcess)
|
||||||
if !isempty(proc.virtual_particles_cache)
|
if !isempty(proc.virtual_particles_cache)
|
||||||
return proc.virtual_particles_cache
|
return proc.virtual_particles_cache
|
||||||
end
|
end
|
||||||
|
@ -5,12 +5,12 @@ end
|
|||||||
function _assert_particle_type_tuple(t::Any)
|
function _assert_particle_type_tuple(t::Any)
|
||||||
throw(
|
throw(
|
||||||
InvalidInputError(
|
InvalidInputError(
|
||||||
"invalid input, provide a tuple of AbstractParticleTypes to construct a GenericQEDProcess",
|
"invalid input, provide a tuple of AbstractParticleTypes to construct a QEDProcess",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
mutable struct GenericQEDProcess{INT,OUTT,INSP,OUTSP} <: AbstractProcessDefinition where {
|
mutable struct QEDProcess{INT,OUTT,INSP,OUTSP} <: AbstractProcessDefinition where {
|
||||||
INT<:Tuple,OUTT<:Tuple,INSP<:Tuple,OUTSP<:Tuple
|
INT<:Tuple,OUTT<:Tuple,INSP<:Tuple,OUTSP<:Tuple
|
||||||
}
|
}
|
||||||
incoming_particles::INT
|
incoming_particles::INT
|
||||||
@ -21,7 +21,7 @@ mutable struct GenericQEDProcess{INT,OUTT,INSP,OUTSP} <: AbstractProcessDefiniti
|
|||||||
|
|
||||||
virtual_particles_cache::Vector
|
virtual_particles_cache::Vector
|
||||||
|
|
||||||
function GenericQEDProcess(
|
function QEDProcess(
|
||||||
in_particles::INT, out_particles::OUTT, in_sp::INSP, out_sp::OUTSP
|
in_particles::INT, out_particles::OUTT, in_sp::INSP, out_sp::OUTSP
|
||||||
) where {INT<:Tuple,OUTT<:Tuple,INSP<:Tuple,OUTSP<:Tuple}
|
) where {INT<:Tuple,OUTT<:Tuple,INSP<:Tuple,OUTSP<:Tuple}
|
||||||
_assert_particle_type_tuple(in_particles)
|
_assert_particle_type_tuple(in_particles)
|
||||||
@ -31,12 +31,12 @@ mutable struct GenericQEDProcess{INT,OUTT,INSP,OUTSP} <: AbstractProcessDefiniti
|
|||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
GenericQEDProcess(in_ph::Int, out_ph::Int, in_el::Int, out_el::Int, in_po::Int, out_po::Int)
|
QEDProcess(in_ph::Int, out_ph::Int, in_el::Int, out_el::Int, in_po::Int, out_po::Int)
|
||||||
|
|
||||||
Convenience constructor from numbers of input/output photons, electrons and positrons.
|
Convenience constructor from numbers of input/output photons, electrons and positrons.
|
||||||
Uses `AllSpin()` and `AllPol()` for every particle's spin/pol by default.
|
Uses `AllSpin()` and `AllPol()` for every particle's spin/pol by default.
|
||||||
"""
|
"""
|
||||||
function GenericQEDProcess(
|
function QEDProcess(
|
||||||
in_ph::Int, out_ph::Int, in_el::Int, out_el::Int, in_po::Int, out_po::Int
|
in_ph::Int, out_ph::Int, in_el::Int, out_el::Int, in_po::Int, out_po::Int
|
||||||
)
|
)
|
||||||
in_p = ntuple(i -> if i <= in_ph
|
in_p = ntuple(i -> if i <= in_ph
|
||||||
@ -55,15 +55,12 @@ mutable struct GenericQEDProcess{INT,OUTT,INSP,OUTSP} <: AbstractProcessDefiniti
|
|||||||
end, out_ph + out_el + out_po)
|
end, out_ph + out_el + out_po)
|
||||||
in_sp = tuple([i <= in_ph ? AllPol() : AllSpin() for i in 1:length(in_p)]...)
|
in_sp = tuple([i <= in_ph ? AllPol() : AllSpin() for i in 1:length(in_p)]...)
|
||||||
out_sp = tuple([i <= out_ph ? AllPol() : AllSpin() for i in 1:length(out_p)]...)
|
out_sp = tuple([i <= out_ph ? AllPol() : AllSpin() for i in 1:length(out_p)]...)
|
||||||
return GenericQEDProcess(in_p, out_p, in_sp, out_sp)
|
return QEDProcess(in_p, out_p, in_sp, out_sp)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function spin_or_pol(
|
function spin_or_pol(
|
||||||
process::GenericQEDProcess,
|
process::QEDProcess, dir::ParticleDirection, species::AbstractParticleType, n::Int
|
||||||
dir::ParticleDirection,
|
|
||||||
species::AbstractParticleType,
|
|
||||||
n::Int,
|
|
||||||
)
|
)
|
||||||
i = 0
|
i = 0
|
||||||
c = n
|
c = n
|
||||||
@ -94,14 +91,14 @@ function spin_or_pol(
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function QEDprocesses.incoming_particles(proc::GenericQEDProcess{INT,OUTT}) where {INT,OUTT}
|
function QEDprocesses.incoming_particles(proc::QEDProcess{INT,OUTT}) where {INT,OUTT}
|
||||||
return proc.incoming_particles
|
return proc.incoming_particles
|
||||||
end
|
end
|
||||||
function QEDprocesses.outgoing_particles(proc::GenericQEDProcess{INT,OUTT}) where {INT,OUTT}
|
function QEDprocesses.outgoing_particles(proc::QEDProcess{INT,OUTT}) where {INT,OUTT}
|
||||||
return proc.outgoing_particles
|
return proc.outgoing_particles
|
||||||
end
|
end
|
||||||
|
|
||||||
function isphysical(proc::GenericQEDProcess)
|
function isphysical(proc::QEDProcess)
|
||||||
return (
|
return (
|
||||||
number_particles(proc, Incoming(), Electron()) +
|
number_particles(proc, Incoming(), Electron()) +
|
||||||
number_particles(proc, Outgoing(), Positron()) ==
|
number_particles(proc, Outgoing(), Positron()) ==
|
||||||
@ -110,6 +107,6 @@ function isphysical(proc::GenericQEDProcess)
|
|||||||
) && number_particles(proc, Incoming()) + number_particles(proc, Outgoing()) >= 2
|
) && number_particles(proc, Incoming()) + number_particles(proc, Outgoing()) >= 2
|
||||||
end
|
end
|
||||||
|
|
||||||
function matrix_element(proc::GenericQEDProcess, psp::PhaseSpacePoint)
|
function matrix_element(proc::QEDProcess, psp::PhaseSpacePoint)
|
||||||
return nothing
|
return nothing
|
||||||
end
|
end
|
||||||
|
@ -16,6 +16,9 @@ end
|
|||||||
# import compute so we don't have to repeat it all the time
|
# import compute so we don't have to repeat it all the time
|
||||||
import MetagraphOptimization: compute, compute_effort, children
|
import MetagraphOptimization: compute, compute_effort, children
|
||||||
|
|
||||||
|
const e = sqrt(4π / 137)
|
||||||
|
_vertex() = -1im * e * gamma()
|
||||||
|
|
||||||
compute_effort(::ComputeTask_BaseState) = 0
|
compute_effort(::ComputeTask_BaseState) = 0
|
||||||
compute_effort(::ComputeTask_Propagator) = 0
|
compute_effort(::ComputeTask_Propagator) = 0
|
||||||
compute_effort(::ComputeTask_Pair) = 0
|
compute_effort(::ComputeTask_Pair) = 0
|
||||||
@ -42,8 +45,12 @@ end
|
|||||||
@inline function compute(
|
@inline function compute(
|
||||||
::ComputeTask_BaseState, input::BaseStateInput{PS,SPIN_POL}
|
::ComputeTask_BaseState, input::BaseStateInput{PS,SPIN_POL}
|
||||||
) where {PS,SPIN_POL}
|
) where {PS,SPIN_POL}
|
||||||
|
species = particle_species(input.particle)
|
||||||
|
if is_outgoing(input.particle)
|
||||||
|
species = invert(species)
|
||||||
|
end
|
||||||
return Propagated( # "propagated" because it goes directly into the next pair
|
return Propagated( # "propagated" because it goes directly into the next pair
|
||||||
input.particle,
|
species,
|
||||||
QEDbase.base_state(
|
QEDbase.base_state(
|
||||||
particle_species(input.particle),
|
particle_species(input.particle),
|
||||||
particle_direction(input.particle),
|
particle_direction(input.particle),
|
||||||
@ -84,6 +91,11 @@ struct Unpropagated{PARTICLE_T<:AbstractParticleType,VALUE_T}
|
|||||||
value::VALUE_T
|
value::VALUE_T
|
||||||
end
|
end
|
||||||
|
|
||||||
|
import Base.+
|
||||||
|
function +(a::Unpropagated{P,V}, b::Unpropagated{P,V}) where {P,V}
|
||||||
|
return Unpropagated(a.particle, a.value + b.value)
|
||||||
|
end
|
||||||
|
|
||||||
struct Propagated{PARTICLE_T<:AbstractParticleType,VALUE_T}
|
struct Propagated{PARTICLE_T<:AbstractParticleType,VALUE_T}
|
||||||
particle::PARTICLE_T
|
particle::PARTICLE_T
|
||||||
value::VALUE_T
|
value::VALUE_T
|
||||||
@ -93,33 +105,33 @@ end
|
|||||||
@inline function compute(
|
@inline function compute(
|
||||||
::ComputeTask_Pair, electron::Propagated{Electron,V1}, positron::Propagated{Positron,V2}
|
::ComputeTask_Pair, electron::Propagated{Electron,V1}, positron::Propagated{Positron,V2}
|
||||||
) where {V1,V2}
|
) where {V1,V2}
|
||||||
return Unpropagated(Photon(), positron.value * electron.value) # fermion - antifermion -> photon
|
return Unpropagated(Photon(), positron.value * _vertex() * electron.value) # fermion - antifermion -> photon
|
||||||
end
|
end
|
||||||
@inline function compute(
|
@inline function compute(
|
||||||
::ComputeTask_Pair, positron::Propagated{Positron,V1}, electron::Propagated{Electron,V2}
|
::ComputeTask_Pair, positron::Propagated{Positron,V1}, electron::Propagated{Electron,V2}
|
||||||
) where {V1,V2}
|
) where {V1,V2}
|
||||||
return Unpropagated(Photon(), positron.value * electron.value) # antifermion - fermion -> photon
|
return Unpropagated(Photon(), positron.value * _vertex() * electron.value) # antifermion - fermion -> photon
|
||||||
end
|
end
|
||||||
@inline function compute(
|
@inline function compute(
|
||||||
::ComputeTask_Pair, photon::Propagated{Photon,V1}, fermion::Propagated{F,V2}
|
::ComputeTask_Pair, photon::Propagated{Photon,V1}, fermion::Propagated{F,V2}
|
||||||
) where {F<:FermionLike,V1,V2}
|
) where {F<:FermionLike,V1,V2}
|
||||||
return Unpropagated(invert(fermion.particle), fermion.value * photon.value) # (anti-)fermion - photon -> (anti-)fermion
|
return Unpropagated(fermion.particle, photon.value * _vertex() * fermion.value) # (anti-)fermion - photon -> (anti-)fermion
|
||||||
end
|
end
|
||||||
@inline function compute(
|
@inline function compute(
|
||||||
::ComputeTask_Pair, fermion::Propagated{F,V2}, photon::Propagated{Photon,V1}
|
::ComputeTask_Pair, fermion::Propagated{F,V2}, photon::Propagated{Photon,V1}
|
||||||
) where {F<:FermionLike,V1,V2}
|
) where {F<:FermionLike,V1,V2}
|
||||||
return Unpropagated(invert(fermion.particle), fermion.value * photon.value) # photon - (anti-)fermion -> (anti-)fermion
|
return Unpropagated(fermion.particle, photon.value * _vertex() * fermion.value) # photon - (anti-)fermion -> (anti-)fermion
|
||||||
end
|
end
|
||||||
|
|
||||||
@inline function compute(
|
@inline function compute(
|
||||||
::ComputeTask_PropagatePairs, left::PROP_V, right::Unpropagated{P,VAL}
|
::ComputeTask_PropagatePairs, left::PROP_V, right::Unpropagated{P,VAL}
|
||||||
) where {PROP_V,P<:AbstractParticleType,VAL}
|
) where {PROP_V,P<:AbstractParticleType,VAL}
|
||||||
return Propagated(right.particle, right.value * left.value)
|
return Propagated(right.particle, left * right.value)
|
||||||
end
|
end
|
||||||
@inline function compute(
|
@inline function compute(
|
||||||
::ComputeTask_PropagatePairs, left::Unpropagated{P,VAL}, right::PROP_V
|
::ComputeTask_PropagatePairs, left::Unpropagated{P,VAL}, right::PROP_V
|
||||||
) where {PROP_V,P<:AbstractParticleType,VAL}
|
) where {PROP_V,P<:AbstractParticleType,VAL}
|
||||||
return Propagated(left.particle, left.value * right.value)
|
return Propagated(left.particle, right * left.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
@inline function compute(
|
@inline function compute(
|
||||||
@ -128,7 +140,7 @@ end
|
|||||||
electron::Propagated{Electron,V2},
|
electron::Propagated{Electron,V2},
|
||||||
positron::Propagated{Positron,V3},
|
positron::Propagated{Positron,V3},
|
||||||
) where {V1,V2,V3}
|
) where {V1,V2,V3}
|
||||||
return positron.value * photon.value * electron.input
|
return positron.value * _vertex() * photon.value * electron.value
|
||||||
end
|
end
|
||||||
@inline function compute(
|
@inline function compute(
|
||||||
c::ComputeTask_Triple,
|
c::ComputeTask_Triple,
|
||||||
|
@ -70,7 +70,7 @@ function MetagraphOptimization.input_expr(
|
|||||||
sp_str = _construction_string(spin_pol)
|
sp_str = _construction_string(spin_pol)
|
||||||
|
|
||||||
return Meta.parse(
|
return Meta.parse(
|
||||||
"BaseStateInput(
|
"FeynmanDiagramGenerator.BaseStateInput(
|
||||||
ParticleStateful($dir_str, $species_str, momentum($psp_symbol, $dir_str, $species_str, $index)),
|
ParticleStateful($dir_str, $species_str, momentum($psp_symbol, $dir_str, $species_str, $index)),
|
||||||
$sp_str,
|
$sp_str,
|
||||||
)",
|
)",
|
||||||
@ -80,10 +80,10 @@ function MetagraphOptimization.input_expr(
|
|||||||
index = parse(Int, name[4:end]) # get index of the virtual particle in the process
|
index = parse(Int, name[4:end]) # get index of the virtual particle in the process
|
||||||
|
|
||||||
vp = virtual_particles(proc)[index]
|
vp = virtual_particles(proc)[index]
|
||||||
return Meta.parse("PropagatorInput(
|
return Meta.parse("FeynmanDiagramGenerator.PropagatorInput(
|
||||||
VirtualParticle(
|
FeynmanDiagramGenerator.VirtualParticle(
|
||||||
process($psp_symbol),
|
process($psp_symbol),
|
||||||
$(_species_str(particle_species(vp))),
|
$(_construction_string(particle_species(vp))),
|
||||||
$(vp.in_particle_contributions),
|
$(vp.in_particle_contributions),
|
||||||
$(vp.out_particle_contributions)
|
$(vp.out_particle_contributions)
|
||||||
),
|
),
|
||||||
@ -95,6 +95,7 @@ function MetagraphOptimization.input_expr(
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MetagraphOptimization.input_type(p::AbstractProcessDefinition)
|
function MetagraphOptimization.input_type(p::AbstractProcessDefinition)
|
||||||
|
return Any
|
||||||
in_t = QEDcore._assemble_tuple_type(incoming_particles(p), Incoming(), SFourMomentum)
|
in_t = QEDcore._assemble_tuple_type(incoming_particles(p), Incoming(), SFourMomentum)
|
||||||
out_t = QEDcore._assemble_tuple_type(outgoing_particles(p), Outgoing(), SFourMomentum)
|
out_t = QEDcore._assemble_tuple_type(outgoing_particles(p), Outgoing(), SFourMomentum)
|
||||||
return PhaseSpacePoint{
|
return PhaseSpacePoint{
|
||||||
@ -274,7 +275,7 @@ function _make_node_name(
|
|||||||
return node_name
|
return node_name
|
||||||
end
|
end
|
||||||
|
|
||||||
function generate_DAG(proc::GenericQEDProcess)
|
function generate_DAG(proc::QEDProcess)
|
||||||
external_particles = _pseudo_virtual_particles(proc) # external particles that will be input to base_state tasks
|
external_particles = _pseudo_virtual_particles(proc) # external particles that will be input to base_state tasks
|
||||||
particles = virtual_particles(proc) # virtual particles that will be input to propagator tasks
|
particles = virtual_particles(proc) # virtual particles that will be input to propagator tasks
|
||||||
pairs = sort(particle_pairs(particles)) # pairs to generate the pair tasks
|
pairs = sort(particle_pairs(particles)) # pairs to generate the pair tasks
|
||||||
|
Loading…
x
Reference in New Issue
Block a user