You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have an iterator to iterate over all possible definite spin/pol configurations of a given process. Something like a function definite_spin_pols(proc::AbstractProcessDefinition) that would allow code such as
proc = QEDprocesses.Compton()
for spin_pol_config indefinite_spin_pols(proc)
# do things with spin_pol_config, which is an NTuple of only definite spins and polarizationsend
The length of this iterator corresponds to the multiplicity of the whole process.
The text was updated successfully, but these errors were encountered:
…118)
As the title says, this adds an iterator to yield all possible
combinations of spins and polarizations allowed by a process' set
`spin_pols()`. For example:
```Julia
julia> using QEDbase; using QEDcore; using QEDprocesses;
julia> proc = ScatteringProcess((Photon(), Photon(), Photon(), Electron()), (Photon(), Electron()), (SyncedPolarization(1), SyncedPolarization(2), SyncedPolarization(1), SpinUp()), (SyncedPolarization(2), AllSpin()))
generic QED process
incoming: photon (synced polarization 1), photon (synced polarization 2), photon (synced polarization 1), electron (spin up)
outgoing: photon (synced polarization 2), electron (all spins)
julia> for sp_combo in spin_pols_iter(proc) println(sp_combo) end
((x-polarized, x-polarized, x-polarized, spin up), (x-polarized, spin up))
((y-polarized, x-polarized, y-polarized, spin up), (x-polarized, spin up))
((x-polarized, y-polarized, x-polarized, spin up), (y-polarized, spin up))
((y-polarized, y-polarized, y-polarized, spin up), (y-polarized, spin up))
((x-polarized, x-polarized, x-polarized, spin up), (x-polarized, spin down))
((y-polarized, x-polarized, y-polarized, spin up), (x-polarized, spin down))
((x-polarized, y-polarized, x-polarized, spin up), (y-polarized, spin down))
((y-polarized, y-polarized, y-polarized, spin up), (y-polarized, spin down))
julia> length(spin_pols_iter(proc))
8
```
The above is also a `jldoctest`.
As a side-note I also added an alias of `SyncedPol` to
`SyncedPolarization`.
The code is not incredibly concise and also not incredibly fast, but for
the reasonable cases that I tested `@benchmark` reports well under 1ms.
Since I don't think this iterator would be the critical path of anything
this should be fine.
The only problem I could see is that due to everything using `Tuple`s in
its arguments, the compile time is relatively large. If this becomes a
problem we could change it to using `Vector`s instead, likely trading
some runtime for much better compile time.
Fixes#107
It would be nice to have an iterator to iterate over all possible definite spin/pol configurations of a given process. Something like a function
definite_spin_pols(proc::AbstractProcessDefinition)
that would allow code such asThe
length
of this iterator corresponds to themultiplicity
of the whole process.The text was updated successfully, but these errors were encountered: