Core functions
Beam
This module contains the ‘beam-based’ functions to interact with lattice under study.
- pySC.core.beam.all_elements_reading(SC: SimulatedCommissioning) Tuple[ndarray, ndarray] [source]
Calculates horizontal and vertical positions with current injection setup SC.INJ. Returns the measured BPM positions at all BPMs as well as TRUE positions at all elements, i.e. provides information NOT available in actual commissioning. If SC.plot is True the reading is plotted.
- Parameters:
SC -- SimulatedCommissioning instance
- Returns:
Array of all horizontal and vertical BPM readings (2, T x B) for T turns and B BPMs
Array of all horizontal and vertical positions at all elements (2, P, B, T, S) for P particles B BPMs, T turns and S shots
- pySC.core.beam.beam_transmission(SC: SimulatedCommissioning, nParticles: int | None = None, nTurns: int | None = None, plot: bool = False) Tuple[int, ndarray] [source]
Calculates the turn-by-turn beam transmission with current injection setup as defined in SC.INJ.
- Parameters:
SC -- SimulatedCommissioning instance
nParticles -- Number of particles to track (for convenience, otherwise SC.INJ.nParticles is used)
nTurns -- Number of turns to track (for convenience, otherwise SC.INJ.nTurns is used)
plot -- If True, plots beam transmission
- Returns:
Number of survived turns following SC.INJ.beamLostAt criteria
Array of accumulated lost fraction of beam (turn-by-turn)
- pySC.core.beam.bpm_reading(SC: SimulatedCommissioning, bpm_ords: ndarray | None = None, calculate_errors: bool = False) Tuple [source]
Calculates BPM readings with current injection setup SC.INJ and included all BPM uncertainties. Included uncertainties are offsets, rolls, calibration errors, and position noise. When the beam is lost following SC.INJ.beamLostAt criteria with sum signal errors included, the readings are NaN. If SC.plot is True the reading is plotted.
- Parameters:
SC -- SimulatedCommissioning instance
bpm_ords -- array of element indices of registered BPMs for which to calculate readings (for convenience, otherwise SC.ORD.BPM is used)
calculate_errors -- If true orbit errors are calculated
- Returns:
Array of horizontal and vertical BPM readings (2, T x B) for T turns and B BPMs Array of fractional transmission (eq. BPM sum signal) (2, T x B) for T turns and B BPMs Optionally, in TBT mode and calculate_errors is True:
Array of measured errors for horizontal and vertical BPM readings (2, T x B) for T turns and B BPMs
- pySC.core.beam.generate_bunches(SC: SimulatedCommissioning, nParticles=None) ndarray [source]
Generates bunches according to the current injection setup as defined in SC.INJ. The random injection error is added to the mean injected beam trajectory for each bunch. Either a single particle (nParticles=1) is generated at the bunch centroid, or individual particles are randomly distributed around the bunch centroid using the beam sigma matrix. A function SC.INJ.postFun is applied to the generated coordinates.
- Parameters:
SC -- SimulatedCommissioning instance
nParticles -- Number of particles to generate (for convenience, otherwise SC.INJ.nParticles is used)
- Returns:
Array of particle coordinates (6, nParticles)
Lattice setting
This module contains the ‘machine-based’ functions to interact with lattice under study.
- pySC.core.lattice_setting.switch_cavity_and_radiation(ring: Lattice, *args: str) Lattice [source]
switch cavity / radiation to on / off
Depending on mode switch_cavity_and_radiation switches the cavities / the radiation in RING on or off. Possible `mode`s are “radiationoff”, “radiationon”, “cavityoff”, “cavityon”. Multiple modes can be specified.
- Parameters:
ring -- AT lattice, for example SC.RING
"radiationoff" -- turn OFF radiation. Priority is given to the *OFF modes.
"radiationon" -- turn ON radiation. Priority is given to the *OFF modes.
"cavityoff" -- turn OFF cavity. Priority is given to the *OFF modes.
"cavityon" -- turn ON cavity. Priority is given to the *OFF modes.
- Returns:
The modified base AT structure lattice.
- Return type:
ring
Examples
Switch cavities and radiation in SC.RING off.:
SC.RING = switch_cavity_and_radiation(SC.RING, 'cavityoff', 'radiationoff')