Skip to content

Implement __iadd__ on BeamBaseClass

Implements the option to do in-place addition on BeamBaseClass by adding magic __iadd__, along with related features elsewhere. First step towards re-implementation of multi-turn injection for #141.

Main changes:

  • Add functions __iadd__, add_beam, add_particles and _append_to_self to BeamBaseClass
    • __iadd__ takes either a BeamBaseClass object or a 2D ArrayLike of [dt, dE] and then calls either add_beam or add_particles as required
    • add_beam and add_particles do some sanity checks and then pass the coordinates of the new particles, and if a BeamBaseClass the flags and intensity, to _append_to_self
    • _append_to_self joins all the relevant parameters from the input beam/coordinates to the existing beam
  • Add functions unique, concatenate and max to backend
  • Move BeamFlags from blond.core.beam.base to blond.core.beam.flags to avoid circular import between backend and beam
  • Convert ParticleType to a frozen dataclass to simplify equality comparison whilst keeping it hashable, also prevents attribute values changing, which avoids the need for wrapping everything in a property

Merge request reports

Loading