field_helpers module

Define functions to compute 1D longitudinal electric fields.

null_field_1d(pos)[source]

Define a null electric/magnetic field.

Parameters:

pos (Any)

Return type:

float

create_1d_field_func(field_values, pos_max, n_intervals, pos_min=0.0)[source]

Create functions computing field for a given position.

Parameters:
  • field_values (ndarray[tuple[Any, ...], dtype[double]]) – Field values on en evenly spaced grid.

  • pos_max (float) – Ending position of the field.

  • n_intervals (int) – Number of intervals in the field map; it is n_points - 1.

  • pos_min (float, default: 0.0) – Starting position of the field.

Return type:

Callable[[float], float]

Returns:

  • FieldFuncComponent1D – Function giving a field component at a given 1D position. It also have a xp and a fp attributes holding positions and field values. This is used for Cython implementations.

  • .. todo:: – Clean this xp fp thingy, not clean at all.

e_1d(pos, e_func, phi, amplitude, phi_0)[source]

Compute normed 1D electric field.

Parameters:
Return type:

float

e_1d_complex(pos, e_func, phi, amplitude, phi_0)[source]

Compute normed 1D electric field.

Parameters:
Return type:

complex

shifted_e_spat(e_spat, z_shift)[source]

Shift electric field by z_shift.

Parameters:
Return type:

Callable[[float], float]

rescale_array(array, norm, tol=1e-06)[source]

Rescale given array if norm is different from unity.

Parameters:
Return type:

ndarray[tuple[Any, ...], dtype[double]]