beam_parameters module
Gather the beam parameters of all the phase spaces.
For a list of the units associated with every parameter, see Units and conventions.
- class BeamParameters(z_abs: ~numpy.ndarray, gamma_kin: ~numpy.ndarray, beta_kin: ~numpy.ndarray, sigma_in: ~numpy.ndarray | None = None, element_to_index: ~typing.Callable[[str | ~lightwin.core.elements.element.Element, str | None], int | slice] = <function BeamParameters.<lambda> at 0x7fd3cea65620>)
Bases:
InitialBeamParametersHold all emittances, envelopes, etc in various planes.
- Parameters:
z_abs (numpy.ndarray) – Absolute position in the linac in m.
gamma_kin (numpy.ndarray) – Lorentz gamma factor.
beta_kin (numpy.ndarray) – Lorentz gamma factor.
sigma_in (numpy.ndarray | None, optional) – Holds the (6, 6) \(\sigma\) beam matrix at the entrance of the linac/portion of linac. The default is None.
zdelta (PhaseSpaceBeamParameters) – Holds beam parameters respectively in the \([z-z\delta]\), \([z-z']\), \([\phi-W]\), \([x-x']\), \([y-y']\) and \([t-t']\) planes.
z (PhaseSpaceBeamParameters) – Holds beam parameters respectively in the \([z-z\delta]\), \([z-z']\), \([\phi-W]\), \([x-x']\), \([y-y']\) and \([t-t']\) planes.
phiw (PhaseSpaceBeamParameters) – Holds beam parameters respectively in the \([z-z\delta]\), \([z-z']\), \([\phi-W]\), \([x-x']\), \([y-y']\) and \([t-t']\) planes.
x (PhaseSpaceBeamParameters) – Holds beam parameters respectively in the \([z-z\delta]\), \([z-z']\), \([\phi-W]\), \([x-x']\), \([y-y']\) and \([t-t']\) planes.
y (PhaseSpaceBeamParameters) – Holds beam parameters respectively in the \([z-z\delta]\), \([z-z']\), \([\phi-W]\), \([x-x']\), \([y-y']\) and \([t-t']\) planes.
t (PhaseSpaceBeamParameters) – Holds beam parameters respectively in the \([z-z\delta]\), \([z-z']\), \([\phi-W]\), \([x-x']\), \([y-y']\) and \([t-t']\) planes.
phiw99 (PhaseSpaceBeamParameters) – Holds 99% beam parameters respectively in the \([\phi-W]\), \([x-x']\) and \([y-y']\) planes. Only used with multiparticle simulations.
x99 (PhaseSpaceBeamParameters) – Holds 99% beam parameters respectively in the \([\phi-W]\), \([x-x']\) and \([y-y']\) planes. Only used with multiparticle simulations.
y99 (PhaseSpaceBeamParameters) – Holds 99% beam parameters respectively in the \([\phi-W]\), \([x-x']\) and \([y-y']\) planes. Only used with multiparticle simulations.
element_to_index (Callable[[str | Element, str | None], int | slice]) – Takes an
Element, its name,'first'or'last'as argument, and returns corresponding index. Index should be the same in all the arrays attributes of this class:z_abs,beam_parametersattributes, etc. Used to easilygetthe desired properties at the proper position.
- element_to_index(_pos)
- get(*keys: str, to_numpy: bool = True, none_to_nan: bool = False, elt: Element | None = None, pos: Literal['in', 'out'] | None = None, phase_space_name: str | None = None, **kwargs: Any) Any
Get attributes from this class or its attributes.
Notes
What is particular in this getter is that all
PhaseSpaceBeamParametersattributes have attributes with the same name:twiss,alpha,beta,gamma,eps,envelope_posandenvelope_energy.Hence, you must provide either a
phase_spaceargument which shall be inIMPLEMENTED_PHASE_SPACES, either or ypu must append the name of the phase space to the name of the desired variable with an underscore.- 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.
elt (Element | None, optional) – If provided, return the attributes only at the considered Element.
pos (Literal["in", "out"] | None, optional) – If you want the attribute at the entry, exit, or in the whole
Element. The default is None, in which case you get an array withkeysfrom the start to the end of the element.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
zdeltaphase space are taken. Otherwise, it must be inIMPLEMENTED_PHASE_SPACES.**kwargs (Any) – Other arguments passed to recursive getter.
- Returns:
out – Attribute(s) value(s).
- Return type:
Any
- sub_sigma_in(phase_space_name: Literal['x', 'y', 'zdelta']) ndarray
Give the entry \(\sigma\) beam matrix in a single phase space.
- Parameters:
phase_space_name (Literal["x", "y", "zdelta"]) – Name of the phase space from which you want the \(\sigma\) beam matrix.
- Returns:
sigma –
(2, 2)\(\sigma\) beam matrix at the linac entrance, in a single phase space.- Return type:
- _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
.inifile.
- set_mismatches(reference_beam_parameters: Self, *phase_space_names: str, **mismatch_kw: bool) None
Compute and set mismatch in every possible phase space.
- _get_phase_spaces(reference_beam_parameters: Self, phase_space_name: str, raise_missing_phase_space_error: bool, **mismatch_kw: bool) tuple[PhaseSpaceBeamParameters | None, PhaseSpaceBeamParameters | None]
Get the two phase spaces between which mismatch will be computed.