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, length_m, z_0=0.0)[source]

Bases: ABC

Generic electro-magnetic field.

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

Parameters:
extensions: Collection[str]
is_implemented: bool
__init__(field_map_path, length_m, z_0=0.0)[source]

Instantiate object.

Parameters:
load_fieldmaps()[source]

Load all field components for class extensions.

Return type:

None

abstractmethod _load_fieldmap(path, **validity_check_kwargs)[source]

Generate field function corresponding to a single field file.

Parameters:

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

Return type:

tuple[Callable[..., float], Any, int]

Returns:

  • func – Give field at a given position, position being a tuple of 1, 2 or 3 floats.

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

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

_calculate_field(component_func, pos, phi, amplitude, phi_0_rel, *, complex_output=True)[source]

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, default: True) – Whether to return a complex value. Defaults to True.

Return type:

complex | float

Returns:

The calculated field value.

shift()[source]

Shift the field maps. Used in SUPERPOSE_MAP.

Return type:

None

e_x(pos, phi, amplitude, phi_0_rel)[source]

Give transverse x electric field value.

Parameters:
Return type:

complex

e_y(pos, phi, amplitude, phi_0_rel)[source]

Give transverse y electric field value.

Parameters:
Return type:

complex

e_z(pos, phi, amplitude, phi_0_rel)[source]

Give longitudinal electric field value.

Parameters:
Return type:

complex

b_x(pos, phi, amplitude, phi_0_rel)[source]

Give transverse x magnetic field value.

Parameters:
Return type:

complex

b_y(pos, phi, amplitude, phi_0_rel)[source]

Give transverse y magnetic field value.

Parameters:
Return type:

complex

b_z(pos, phi, amplitude, phi_0_rel)[source]

Give longitudinal magnetic field value.

Parameters:
Return type:

complex

partial_e_z(amplitude, phi_0_rel)[source]

Generate a function for longitudinal transfer matrix calculation.

Parameters:
Return type:

Callable[[float | tuple[float, float] | tuple[float, float, float], float], complex]

_abc_impl = <_abc._abc_data object at 0x7feea999d780>
partial_e_z_phis_fit(amplitude)[source]

Generate a function for longitudinal transfer matrix calculation.

Parameters:

amplitude (float)

Return type:

Callable[[float | tuple[float, float] | tuple[float, float, float], float, float], complex]

_patch_to_keep_consistency(n_interp, n_cell)[source]

Save n_cell and n_z. Temporary solution.

Parameters:
Return type:

None