Lack of a standardized way to inject particles into the simulation during runtime
Issue Context
This issue arises following the discussion in the binning merge request. !29 (merged)
Currently, it is not possible to run simulations where particles are injected during runtime (i.e., after the initial particle creation). For example, in the case of the AWA gun, the original OPAL samples all particles and "activates" them at each timestep. However, this approach is not feasible with IPPL/GPUs. In addition to technical and memory-related limitations, checks such as if (is_emitted[i]) ... could lead to issues like warp divergence.
Solution (IPPL-Related)
A more efficient solution is to sample particles at each timestep as needed. In IPPL, we can allocate ("reserve") space for particles in the bunch (by calling, for instance, create(N_new) followed by setLocalNum(N_old)) and then create or sample particles at each timestep as required. This approach was already considered in the SamplingBase class. The emitParticles function allows for particle creation during the simulation, which is necessary for the flattop distribution.
Solution (Structure in OPALX)
This is where I am not sure. As a minimal testing example, see this outdated commit. Including the emitParticles call within the tracker loop works for a single distribution but is not very general. If I remember correctly, there was an idea to implement this as a dedicated element.
Perhaps a more flexible option would be to create a separate "emitter" class. This class could be coupled with a time distribution and be responsible for calling all necessary emitParticles functions during the simulation.