field module

Define an equivalent to TraceWin’s FIELD_MAP.

Note

For now, we expect that coordinates are always cartesian.

Todo

Define a FieldMapLoader function to easily choose between binary/ascii file format.

Todo

Should have a omega0_rf attribute

See also

CavitySettings

class Field(field_map_path: Path, length_m: float, z_0: float = 0.0)

Bases: ABC

Generic electro-magnetic field.

This object can be shared by several Element and we create as few as possible.

extensions: Collection[str]
is_implemented: bool
__init__(field_map_path: Path, length_m: float, z_0: float = 0.0) None

Instantiate object.

load_fieldmaps() None

Load all field components for class extensions.

abstract _load_fieldmap(path: Path, **validity_check_kwargs) tuple[Callable[[...], float], Any, int]

Generate field function corresponding to a single field file.

Parameters:

path (pathlib.Path) – Path to a field map file.

Returns:

  • func (Callable[…, float]) – Give field at a given position, position being a tuple of 1, 2 or 3 floats.

  • n_interp (Any) – Number of interpolation points in the various directions (tuple of 1, 2 or 3 integers).

  • n_cell (int) – Number of cells (makes sense only for .edz as for now).

_calculate_field(component_func: Callable[[...], float], pos: Any, phi: float, amplitude: float, phi_0_rel: float, *, complex_output: Literal[True]) complex
_calculate_field(component_func: Callable[[...], float], pos: Any, phi: float, amplitude: float, phi_0_rel: float, *, complex_output: Literal[False]) float

Calculate the field component value.

Parameters:
  • component_func (Callable[..., float]) – The spatial field component function (e.g., self._e_x_spat_rf). Must accept a tuple of 1 to 3 floats (position) and return a float.

  • pos (Any) – The position at which to evaluate the field.

  • phi (float) – The phase angle.

  • amplitude (float) – The amplitude of the field.

  • phi_0_rel (float) – The relative phase offset.

  • complex_output (bool, optional) – Whether to return a complex value. Defaults to True.

Returns:

The calculated field value.

Return type:

complex | float

shift() None

Shift the field maps. Used in SUPERPOSE_MAP.

e_x(pos: Any, phi: float, amplitude: float, phi_0_rel: float) complex

Give transverse x electric field value.

e_y(pos: Any, phi: float, amplitude: float, phi_0_rel: float) complex

Give transverse y electric field value.

e_z(pos: Any, phi: float, amplitude: float, phi_0_rel: float) complex

Give longitudinal electric field value.

b_x(pos: Any, phi: float, amplitude: float, phi_0_rel: float) complex

Give transverse x magnetic field value.

b_y(pos: Any, phi: float, amplitude: float, phi_0_rel: float) complex

Give transverse y magnetic field value.

b_z(pos: Any, phi: float, amplitude: float, phi_0_rel: float) complex

Give longitudinal magnetic field value.

partial_e_z(amplitude: float, phi_0_rel: float) Callable[[float | tuple[float, float] | tuple[float, float, float], float], complex]

Generate a function for longitudinal transfer matrix calculation.

_abc_impl = <_abc._abc_data object at 0x7f36fab11480>
partial_e_z_phis_fit(amplitude: float) Callable[[float | tuple[float, float] | tuple[float, float, float], float, float], complex]

Generate a function for longitudinal transfer matrix calculation.

_patch_to_keep_consistency(n_interp: Any, n_cell: int) None

Save n_cell and n_z. Temporary solution.