Small changes
This commit is contained in:
parent
e8bc26b0c0
commit
f6084065e5
@ -1,21 +1,29 @@
|
||||
# patch QEDprocesses
|
||||
# see issue https://github.com/QEDjl-project/QEDprocesses.jl/issues/77
|
||||
@inline function QEDprocesses.number_particles(
|
||||
proc_def::QEDbase.AbstractProcessDefinition, dir::DIR, ::PT
|
||||
) where {DIR<:QEDbase.ParticleDirection,PT<:QEDbase.AbstractParticleType}
|
||||
return count(x -> x isa PT, particles(proc_def, dir))
|
||||
|
||||
|
||||
function _number_particles_helper(
|
||||
particles::Tuple{}, species::SPECIES, n::Val{N}
|
||||
) where {SPECIES,N}
|
||||
return N
|
||||
end
|
||||
|
||||
function _number_particles_helper(
|
||||
particles::Tuple{SPECIES,Vararg}, species::SPECIES2, n::Val{N}
|
||||
) where {SPECIES,SPECIES2,N}
|
||||
return _number_particles_helper(particles[2:end], species, Val(N))
|
||||
end
|
||||
|
||||
"""
|
||||
number_particles(proc_def::AbstractProcessDefinition, dir::ParticleDirection, species::AbstractParticleType)
|
||||
function _number_particles_helper(
|
||||
particles::Tuple{SPECIES,Vararg}, species::SPECIES, n::Val{N}
|
||||
) where {SPECIES,N}
|
||||
return _number_particles_helper(particles[2:end], species, Val(N + 1))
|
||||
end
|
||||
|
||||
Return the number of particles of the given direction and species in the given process definition.
|
||||
"""
|
||||
@inline function QEDbase.number_particles(
|
||||
@inline function QEDprocesses.number_particles(
|
||||
proc_def::AbstractProcessDefinition, dir::DIR, species::PT
|
||||
) where {DIR<:ParticleDirection,PT<:AbstractParticleType}
|
||||
return count(x -> x isa PT, particles(proc_def, dir))
|
||||
return _number_particles_helper(particles(proc_def, dir), species, Val(0))
|
||||
end
|
||||
|
||||
"""
|
||||
|
@ -105,6 +105,9 @@ function normalize(virtual_particle::VirtualParticle{P,S,IN_T,OUT_T}) where {P,S
|
||||
end
|
||||
|
||||
function _momentum_contribution(proc::AbstractProcessDefinition, dir::ParticleDirection, species::AbstractParticleType, index::Int)
|
||||
I = number_incoming_particles(proc)
|
||||
O = number_outgoing_particles(proc)
|
||||
|
||||
# get index of n-th "dir species" particle in proc
|
||||
particles_seen = 0
|
||||
c = 0
|
||||
@ -114,9 +117,11 @@ function _momentum_contribution(proc::AbstractProcessDefinition, dir::ParticleDi
|
||||
particles_seen += 1
|
||||
end
|
||||
if particles_seen == index
|
||||
return (ntuple(x -> is_incoming(dir) && x == c, number_incoming_particles(proc)), ntuple(x -> is_outgoing(dir) && x == c, number_outgoing_particles(proc)))
|
||||
return (((is_incoming(dir) && x == c for x in 1:I)...,), ((is_outgoing(dir) && x == c for x in 1:O)...,))
|
||||
end
|
||||
end
|
||||
|
||||
@assert false "tried to get momentum contribution of $dir $species $index but it does not exist in $proc"
|
||||
end
|
||||
|
||||
function _momentum_contribution(proc::AbstractProcessDefinition, diagram::FeynmanDiagram{N,E,U,T,M,FM}, n::Int) where {N,E,U,T,M,FM}
|
||||
|
@ -25,8 +25,8 @@ struct GenericQEDProcess{INT,OUTT} <: QEDbase.AbstractProcessDefinition where {I
|
||||
end
|
||||
end
|
||||
|
||||
QEDprocesses.incoming_particles(proc::GenericQEDProcess) = proc.incoming_particles
|
||||
QEDprocesses.outgoing_particles(proc::GenericQEDProcess) = proc.outgoing_particles
|
||||
QEDprocesses.incoming_particles(proc::GenericQEDProcess{INT,OUTT}) where {INT,OUTT} = proc.incoming_particles
|
||||
QEDprocesses.outgoing_particles(proc::GenericQEDProcess{INT,OUTT}) where {INT,OUTT} = proc.outgoing_particles
|
||||
|
||||
function isphysical(proc::GenericQEDProcess)
|
||||
return (number_particles(proc, Incoming(), Electron()) + number_particles(proc, Outgoing(), Positron()) ==
|
||||
|
Loading…
x
Reference in New Issue
Block a user