Multi turn injection
Added an object to handle multi turn injection. Creates a new trackable object (MultiTurnInjection
) to which a list of Beam
objects can be added. On turns where a new injection is expected, calls to MultiTurnInjection.track()
will add the next injection to the Beam
object being used in the simulation.
The MultiTurnInjection
object is an iterable
, which will allow use cases like:
for i in multi_turn_injection:
tracker.track()
Alternatively:
for i in range(n_turns_injection):
tracker.track()
multi_turn_injection.track()
Once the injection has been exhausted a StopIteration
is raised, equivalently to other iterables. Intended use case is things like longitudinal painting and multiple injections on a long flat bottom. To avoid unnecessary dependence on the RFStation
object, a reference to the counter should be passed instead.
A unit test has been included.
Added type hints to the Beam object and moved the __iadd__
special function to the top of the class to follow convention. Added a check in the Beam.add_beam
function that raises a ValueError
if Beam.ratio
does not match in both cases to prevent accidentally adding beams with different ratios. Modified the corresponding test case to match.
Also includes the changes found in merge request !38 (merged) As there, either the others should be merged first, or all should be combined into a single merge.