electric_field module

Hold parameters that are shared by all cavities of same type.

See also

CavitySettings

compute_param_cav(integrated_field: complex) dict[str, float]

Compute synchronous phase and accelerating field.

class RfField(k_e: float = nan, absolute_phase_flag: bool = False, phi_0: float | None = None)

Bases: object

Cos-like RF field.

Deprecated since version 0.6.16: Will be separated into NewRfField for parameters specific to cavity design and CavitySettings for parameters specific to the cavity under study.

Warning, all phases are defined as:

\[\phi = \omega_0^{rf} t\]

While in the rest of the code it is defined as:

\[\phi = \omega_0_^{bunch} t\]

All phases are stored in radian.

Parameters:
  • e_spat (Callable[[float], float]) – Spatial component of the electric field. Needs to be multiplied by the cos(omega t) to have the full electric field. Initialized to null function.

  • k_e (float) – Norm of the electric field.

  • phi_0 (dict[str, None | float | bool]) –

    Holds the electric field phase. The keys are:

    phi_0_rel : relative phi_0 in rad phi_0_abs : absolute phi_0 in rad nominal_rel : relative phi_0 in rad in the nominal (ref) linac abs_phase_flag : if the relative or absolute phi_0 must be used phi_0_abs_but_reference_phase_is_different : used when the ListOfElements under study does not start at the beginning of the linac and we use TraceWin. new_reference_phase : phase at the entrance of this ListOfElements.

  • v_cav_mv (float) – Cavity accelerating field in MV.

  • phi_s (float) – Cavity synchronous phase in rad.

  • omega0_rf (float) – RF pulsation of the cavity in rad/s.

  • bunch_to_rf (float) – \(f_{rf} / f_{bunch}\). In particular, it is used to convert the rf absolute phase given by the transfer matrix function of Envelope1D and Envelope3D to bunch absolute phase.

  • n_cell (int) – Number of cells in the cavity.

  • n_z (int | None) – Number of points in the file that gives e_spat, the spatial component of the electric field.

__init__(k_e: float = nan, absolute_phase_flag: bool = False, phi_0: float | None = None) None

Instantiate object.

has(key: str) bool

Tell if the required attribute is in this class.

get(*keys: str, to_deg: bool = False, **kwargs: bool | str) list | ndarray | float | None

Shorthand to get attributes from this class.

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

  • to_deg (bool, optional) – To apply np.rad2deg function over every key containing the string ‘phi’. The default is False.

  • **kwargs (bool | str) – Other arguments passed to recursive getter.

Returns:

out – Attribute(s) value(s).

Return type:

list | numpy.ndarray | float | None

set_rf_freq(f_mhz: float) None

Initialize the pulsation and the rf / bunch fraction.

set_e_spat(e_spat: Callable[[float], float], n_cell: int) None

Set the pos. component of electric field, set number of cells.

update_phi_0_abs_to_adapt_to_new_ref_phase(old_phi_in: float, new_phi_in: float, phases_are_bunch: bool = True) float

Calculate the new phi_0_abs, with a new reference phase.

class NewRfField

Bases: object

Cos-like RF field.

Warning, all phases are defined as:

\[\phi = \omega_0^{rf} t\]

While in the rest of the code it is defined as:

\[\phi = \omega_0_^{bunch} t\]

All phases are stored in radian.

Parameters:
  • e_spat (Callable[[float], float]) – Spatial component of the electric field. Needs to be multiplied by the cos(omega t) to have the full electric field. Initialized to null function.

  • n_cell (int) – Number of cells in the cavity.

  • n_z (int | None) – Number of points in the file that gives e_spat, the spatial component of the electric field.

__init__() None

Instantiate object.

has(key: str) bool

Tell if the required attribute is in this class.

get(*keys: str, **kwargs: bool | str | None) Any

Shorthand to get attributes from this class or its attributes.

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

  • **kwargs (bool | str | None) – Other arguments passed to recursive getter.

Returns:

out – Attribute(s) value(s).

Return type:

Any

set_e_spat(e_spat: Callable[[float], float], n_cell: int) None

Set the pos. component of electric field, set number of cells.