core.beam_parameters.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 @ single position.

z_abs

Absolute position in the linac in m.

Type:

float

gamma_kin

Lorentz gamma factor.

Type:

float

beta_kin

Lorentz gamma factor.

Type:

float

zdelta, z, phiw, x, y, t

Holds beam parameters respectively in the \([z-z\delta]\), \([z-z']\), \([\phi-W]\), \([x-x']\), \([y-y']\) and \([t-t']\) planes.

Type:

InitialPhaseSpaceBeamParameters

phiw99, x99, y99

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

Type:

InitialPhaseSpaceBeamParameters

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

Declare the phase spaces.

_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.

beta_kin: float
gamma_kin: float
get(*keys: str, to_numpy: bool = True, none_to_nan: bool = False, phase_space_name: str | None = None, **kwargs: Any) Any

Shorthand to 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 IMPLEMENTED_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 IMPLEMENTED_PHASE_SPACES.

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

Returns:

out – Attribute(s) value(s).

Return type:

Any

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

property sigma: ndarray

Give value of sigma.

Todo

Could be cleaner.

property tracewin_command: list[str]

Return the proper input beam parameters command.

z_abs: float
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, str]

Separate variable name from phase space name.