experiments #1

Merged
rubydragon merged 39 commits from experiments into main 2024-05-08 12:03:28 +02:00
3 changed files with 89 additions and 2 deletions
Showing only changes of commit 007d970a12 - Show all commits

View File

@ -6,6 +6,7 @@ version = "0.1.0"
[deps]
AccurateArithmetic = "22286c92-06ac-501d-9306-4abd417d9753"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"

View File

@ -7,7 +7,8 @@ function get_properties(graph::DAG)
# make sure the graph is fully generated
apply_all!(graph)
if (graph.properties.computeEffort == 0.0)
# TODO: tests stop working without the if condition, which means there is probably a bug in the lazy evaluation and in the tests
if (graph.properties.computeEffort <= 0.0)
graph.properties = GraphProperties(graph)
end

View File

@ -1,3 +1,4 @@
using Combinatorics
import Base.copy
import Base.hash
@ -265,11 +266,12 @@ function add_vertex!(fd::FeynmanDiagram, vertex::FeynmanVertex)
end
if !can_apply_vertex(get_particles(fd), vertex)
#@assert false "Can't add vertex $vertex to diagram"
@assert false "Can't add vertex $vertex to diagram $(get_particles(fd))"
end
push!(fd.vertices, Set{FeynmanVertex}())
push!(fd.vertices[end], vertex)
fd.type_ids[vertex.out.particle] += 1
return nothing
@ -437,12 +439,95 @@ function remove_duplicates(compare_set::Set{FeynmanDiagram})
return result
end
"""
is_compton(fd::FeynmanDiagram)
Returns true iff the given feynman diagram is an (empty) diagram of a compton process like ke->k^ne
"""
function is_compton(fd::FeynmanDiagram)
return fd.type_ids[FermionStateful{Incoming, SpinUp}] == 1 &&
fd.type_ids[FermionStateful{Outgoing, SpinUp}] == 1 &&
fd.type_ids[PhotonStateful{Incoming, PolX}] == 1 &&
fd.type_ids[PhotonStateful{Outgoing, PolX}] >= 1
end
"""
n_photon_compton_diagrams(n::Int)
Special case diagram generation for n-Photon Compton processes, i.e., processes of the form ke->k^ne
"""
function n_photon_compton_diagram(n::Int)
inEl = FeynmanParticle(FermionStateful{Incoming, SpinUp}, 1)
outEl = FeynmanParticle(FermionStateful{Outgoing, SpinUp}, 1)
photons = [FeynmanParticle(PhotonStateful{Outgoing, PolX}, i) for i in 1:n]
push!(photons, FeynmanParticle(PhotonStateful{Incoming, PolX}, 1))
perms = permutations([i for i in 1:length(photons)])
diagrams = Vector{FeynmanDiagram}()
for order in perms
new_diagram = FeynmanDiagram(
[],
missing,
[inEl, outEl, photons...],
Dict{Type, Int64}(
FermionStateful{Incoming, SpinUp} => 1,
FermionStateful{Outgoing, SpinUp} => 1,
PhotonStateful{Incoming, PolX} => 1,
PhotonStateful{Outgoing, PolX} => n,
),
)
left_index = 1
right_index = length(order)
iterations = 1
while left_index <= right_index
# left side
v_left = FeynmanVertex(
FeynmanParticle(FermionStateful{Incoming, SpinUp}, iterations),
photons[order[left_index]],
FeynmanParticle(FermionStateful{Incoming, SpinUp}, iterations + 1),
)
left_index += 1
add_vertex!(new_diagram, v_left)
if (left_index > right_index)
break
end
# right side
v_right = FeynmanVertex(
FeynmanParticle(FermionStateful{Outgoing, SpinUp}, iterations),
photons[order[right_index]],
FeynmanParticle(FermionStateful{Outgoing, SpinUp}, iterations + 1),
)
right_index -= 1
add_vertex!(new_diagram, v_right)
iterations += 1
end
@assert possible_tie(new_diagram) !== missing
add_tie!(new_diagram, possible_tie(new_diagram))
push!(diagrams, new_diagram)
end
return diagrams
end
"""
gen_diagrams(fd::FeynmanDiagram)
From a given feynman diagram in its initial state, e.g. when created through the [`FeynmanDiagram(pd::ProcessDescription)`](@ref) constructor, generate and return all possible [`FeynmanDiagram`](@ref)s that describe that process.
"""
function gen_diagrams(fd::FeynmanDiagram)
if is_compton(fd)
return n_photon_compton_diagram(fd.type_ids[PhotonStateful{Outgoing, PolX}])
end
working = Set{FeynmanDiagram}()
results = Set{FeynmanDiagram}()