AnalyticalField#
- class wake_t.fields.analytical_field.AnalyticalField(e_x=None, e_y=None, e_z=None, b_x=None, b_y=None, b_z=None, constants=None)[source]#
Class used to define fields with analytical components.
The given components (Ex, Ey, Ez, Bx, By, Bz) must be functions taking 5 arguments (3 arrays containing the x, y, z positions where to calculate the field; 1 array with the same size where the field values will be stored; and a list of constants). The given functions must be written in a way which allows them to be compiled with
numba.Not all components need to be given. Those which are not specified will simply return a zero array when gathered.
In addition to the field components, a list of constants can also be given. This list of constants is always passed to the field functions and can be used to compute the field.
- Parameters:
- e_xcallable, optional
Function defining the Ex component.
- e_ycallable, optional
Function defining the Ey component.
- e_zcallable, optional
Function defining the Ez component.
- b_xcallable, optional
Function defining the Bx component.
- b_ycallable, optional
Function defining the By component.
- b_zcallable, optional
Function defining the Bz component.
- constantslist, optional
List of constants to be passed to each component.
Examples
>>> from numba import prange >>> def linear_ex(x, y, z, t, ex, constants): ... ex_slope = constants[0] ... for i in prange(x.shape[0]): ... ex[i] = ex_slope * x[i] ... >>> ex = AnalyticField(e_x=linear_ex, constants=[1e6])
Methods
gather(x, y, z, t, ex, ey, ez, bx, by, bz, ...)Gather all field components at the specified locations.
get_openpmd_diagnostics_data(global_time)Get the data for including the field in the openPMD diagnostics.