initial_beam_parameters module

Gather beam parameters at the entrance of a ListOfElements.

For a list of the units associated with every parameter, see Units and conventions.

class InitialBeamParameters(z_abs: float, gamma_kin: float, beta_kin: float)

Bases: object

Hold all emittances, envelopes, etc in various planes at a single position.

Parameters:
  • z_abs (float) – Absolute position in the linac in \(\mathrm{m}\).

  • gamma_kin (float) – Lorentz gamma factor.

  • beta_kin (float) – Lorentz beta factor.

  • zdelta (InitialPhaseSpaceBeamParameters) – Beam parameters respectively in the \([z-z\delta]\), \([z-z']\), \([\phi-W]\), \([x-x']\), \([y-y']\) and \([t-t']\) planes.

  • z (InitialPhaseSpaceBeamParameters) – Beam parameters respectively in the \([z-z\delta]\), \([z-z']\), \([\phi-W]\), \([x-x']\), \([y-y']\) and \([t-t']\) planes.

  • phiw (InitialPhaseSpaceBeamParameters) – Beam parameters respectively in the \([z-z\delta]\), \([z-z']\), \([\phi-W]\), \([x-x']\), \([y-y']\) and \([t-t']\) planes.

  • x (InitialPhaseSpaceBeamParameters) – Beam parameters respectively in the \([z-z\delta]\), \([z-z']\), \([\phi-W]\), \([x-x']\), \([y-y']\) and \([t-t']\) planes.

  • y (InitialPhaseSpaceBeamParameters) – Beam parameters respectively in the \([z-z\delta]\), \([z-z']\), \([\phi-W]\), \([x-x']\), \([y-y']\) and \([t-t']\) planes.

  • t (InitialPhaseSpaceBeamParameters) – Beam parameters respectively in the \([z-z\delta]\), \([z-z']\), \([\phi-W]\), \([x-x']\), \([y-y']\) and \([t-t']\) planes.

  • phiw99 (InitialPhaseSpaceBeamParameters) – 99% beam parameters respectively in the \([\phi-W]\), \([x-x']\) and \([y-y']\) planes. Only used with multiparticle simulations.

  • x99 (InitialPhaseSpaceBeamParameters) – 99% beam parameters respectively in the \([\phi-W]\), \([x-x']\) and \([y-y']\) planes. Only used with multiparticle simulations.

  • y99 (InitialPhaseSpaceBeamParameters) – 99% beam parameters respectively in the \([\phi-W]\), \([x-x']\) and \([y-y']\) planes. Only used with multiparticle simulations.

z_abs: float
gamma_kin: float
beta_kin: float
__post_init__() None

Declare the phase spaces without initalizing them.

__str__() str

Give compact information on the data that is stored.

has(key: str) bool

Tell if the required attribute is in this class.

Notes

key = 'property_phasespace' will return True if 'property' exists in phasespace. Hence, the following two commands will have the same return values:

self.has('twiss_zdelta')
self.zdelta.has('twiss')

See also

get

get(*keys: str, to_numpy: bool = True, none_to_nan: bool = False, phase_space_name: Literal['zdelta', 'z', 'phiw', 'x', 'y', 't', 'phiw99', 'x99', 'y99'] | None = None, **kwargs: Any) Any

Get attributes from this class or its attributes.

Notes

What is particular in this getter is that all InitialPhaseSpaceBeamParameters attributes have attributes with the same name: twiss, alpha, beta, gamma, eps, envelope_pos and envelope_energy.

Hence, you must provide either a phase_space argument which shall be in PHASE_SPACES, either you must append the name of the phase space to the name of the desired variable with an underscore.

See also

has()

Parameters:
  • *keys (str) – Name of the desired attributes.

  • to_numpy (bool, optional) – If you want the list output to be converted to a np.ndarray. The default is True.

  • none_to_nan (bool, optional) – To convert None to np.nan. The default is True.

  • phase_space_name (str | None, optional) – Phase space in which you want the key. The default is None. In this case, the quantities from the zdelta phase space are taken. Otherwise, it must be in PHASE_SPACES.

  • **kwargs (Any) – Other arguments passed to recursive getter.

Returns:

out – Attribute(s) value(s).

Return type:

Any

property tracewin_command: list[str]

Return the proper input beam parameters command.

property sigma: ndarray

Give value of sigma.

Todo

Could be cleaner.

_create_tracewin_command(warn_missing_phase_space: bool = True) list[str]

Turn emittance, alpha, beta from the proper phase-spaces into command.

When phase-spaces were not created, we return np.nan which will ultimately lead TraceWin to take this data from its .ini file.

__init__(z_abs: float, gamma_kin: float, beta_kin: float) None
phase_space_name_hidden_in_key(key: str) bool

Look for the name of a phase-space in a key name.

separate_var_from_phase_space(key: str) tuple[str, Literal['zdelta', 'z', 'phiw', 'x', 'y', 't', 'phiw99', 'x99', 'y99']]

Separate variable name from phase space name.