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
- class Field(field_map_path: Path, length_m: float, z_0: float = 0.0)
Bases:
ABCGeneric electro-magnetic field.
This object can be shared by several
Elementand we create as few as possible.- extensions: Collection[str]
- 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:
- 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>