Add QED Model (#25)

Reviewed-on: Rubydragon/MetagraphOptimization.jl#25
Co-authored-by: Anton Reinhard <anton.reinhard@proton.me>
Co-committed-by: Anton Reinhard <anton.reinhard@proton.me>
This commit is contained in:
2023-12-07 02:54:15 +01:00
committed by Anton Reinhard
parent 938bf216e5
commit c90346e948
47 changed files with 4013 additions and 905 deletions

View File

@@ -61,13 +61,11 @@ function gen_input_assignment_code(
assignInputs = Vector{Expr}()
for (name, symbols) in inputSymbols
type = type_from_name(name)
index = parse(Int, name[2:end])
(type, index) = type_index_from_name(model(processDescription), name)
p = nothing
if (index > in_particles(processDescription)[type])
index -= in_particles(processDescription)[type]
if (index > get(in_particles(processDescription), type, 0))
index -= get(in_particles(processDescription), type, 0)
@assert index <= out_particles(processDescription)[type] "Too few particles of type $type in input particles for this process"
p = "filter(x -> typeof(x) <: $type, out_particles($(processInputSymbol)))[$(index)]"
@@ -76,10 +74,9 @@ function gen_input_assignment_code(
end
for symbol in symbols
# TODO: how to get the "default" cpu device?
device = entry_device(machine)
evalExpr = eval(gen_access_expr(device, symbol))
push!(assignInputs, Meta.parse("$(evalExpr)::ParticleValue{$type} = ParticleValue($p, 1.0)"))
push!(assignInputs, Meta.parse("$(evalExpr)::ParticleValue{$type} = ParticleValue($p, one(ComplexF64))"))
end
end