particle module

Define objects to store initial state/trajectory of a particle.

class ParticleInitialState(w_kin, phi_abs, z_in, synchronous)[source]

Bases: object

Hold the initial energy/phase of a particle, and if it is synchronous.

It is used for ListOfElements attribute.

Parameters:
w_kin: float
phi_abs: float
z_in: float
synchronous: bool
property tracewin_command: list[str]

Create the energy and phase arguments for TraceWin command.

__init__(w_kin, phi_abs, z_in, synchronous)
Parameters:
Return type:

None

class ParticleFullTrajectory(w_kin, phi_abs, synchronous, beam)[source]

Bases: object

Hold the full energy, phase, etc of a particle.

It is stored in a SimulationOutput.

Phase is defined as:

\[\phi = \omega_{0,\,\mathrm{bunch}} t\]

while in Field it is:

\[\phi = \omega_{0,\,\mathrm{rf}} t\]
Parameters:
w_kin: ndarray[tuple[Any, ...], dtype[_ScalarT]] | list
phi_abs: ndarray[tuple[Any, ...], dtype[_ScalarT]] | list
synchronous: bool
beam: BeamKwargs
__post_init__()[source]

Ensure that LightWin has everything it needs, with proper format.

__str__()[source]

Show amplitude of phase and energy.

Return type:

str

property tracewin_command: list[str]

Raise an error, this method should be called from InitialPart.

compute_reduced_velocity()[source]

Compute and store \(\beta\).

Return type:

None

has(key)[source]

Tell if the required attribute is in this class or its subfields.

Parameters:

key (str)

Return type:

bool

get(*keys, to_numpy=True, none_to_nan=False, to_deg=False, **kwargs)[source]

Get attributes from this class or its nested attributes.

Parameters:
  • *keys (Literal['beta', 'gamma', 'phi_abs', 'synchronous', 'w_kin', 'z_in'] | Literal['e_mev', 'e_rest_mev', 'f_bunch_mhz', 'i_milli_a', 'q_adim', 'sigma', 'inv_e_rest_mev', 'gamma_init', 'omega_0_bunch', 'lambda_bunch', 'q_over_m', 'm_over_q']) – Names of the desired attributes.

  • to_numpy (bool, default: True) – Convert list outputs to NumPy arrays.

  • none_to_nan (bool, default: False) – Convert None values to np.nan.

  • to_deg (bool, default: False) – Convert phase attributes (containing “phi”) to degrees.

  • **kwargs (Any) – Passed to recursive_getter.

Returns:

A single value if one key is given, or a tuple of values.

Return type:

Any

__init__(w_kin, phi_abs, synchronous, beam)
Parameters:
Return type:

None