pynoza¶
Pynoza is a Python implementation of the time-domain multipole expansion of electromagnetic fields in Cartesian coordinates.
Currently, only the electric field computation is supported, and the current density must be time-separable, i.e., the current density must be the product of two time- and space-dependent functions.
The source is code is available on GitHub.
- class pynoza.solution.Solution¶
Bases:
objectA class to compute solutions of Maxwell’s equations, based on time-domain multipole moments.
- __init__()¶
Initialize the solution class.
- Parameters:
max_order – The maximum order to which multipole moments will be computed (default 0)
wave_speed – The Wave speed c used to compute the retarded time t-r/c, in natural units (default 1)
- compute_b_field(x1: ndarray, x2: ndarray, x3: ndarray, t: ndarray, h_sym, t_sym, verbose=False, delayed=True, compute_grid=True, compute_txt=False, shift=0)¶
Compute the magnetic field B from the moments. The method recurse() and set_moments(…) must be run beforehand.
- Returns:
the magnetic field as a 5-dimensional array. If :compute_grid: is True, the dimensions correspond to (dimension, x1, x2, x3, t), otherwise, (dimension, x, t).
See the method :compute_e_field: for a full description of the arguments.
- compute_e_field(x1: ndarray, x2: ndarray, x3: ndarray, t: ndarray, h_sym, t_sym, verbose=False, delayed=True, compute_grid=True, compute_txt=False, shift=0)¶
Compute the electric field from the moments. The method recurse() and set_moments(…) must be run beforehand.
- Returns:
the electric field as a 5-dimensional array. If :compute_grid: is True, the dimensions correspond to (dimension, x1, x2, x3, t), otherwise, (dimension, x, t).
- Parameters:
x1 – array of the spatial coordinates to evaluate the e_field-field at (aka x)
x2 – array of the spatial coordinates to evaluate the e_field-field at (aka y)
x3 – array of the spatial coordinates to evaluate the e_field-field at (aka z)
t – array of the time coordinates to evaluate the e_field-field at
h_sym – time-dependent excitation
t_sym – symbolic variable representing time, used in h_sym
verbose – whether to display the progress (default False)
delayed – whether to evaluate the field at the retarded time t-r/c (default True)
compute_grid – whether to compute all combinations of coordinates
compute_txt – whether to compute a text representation of the solution or not
shift – experimental
- Raises:
RuntimeError – when any of recurse or set_moments have not been run.
ValueError – when h_sym does not look like what is described below
- Return type:
a np.ndarray with the electric field, whose shape is (3, x1.size, t.size)
The time-dependent excitation h_sym can either be a symbolic time-dependent (t_sym) function describing the shape of the current or a dictionary of numpy arrays of the same shape as t, each array containing the values of the nth order derivative of the time-dependent function. The keys of the dictionary must be the integers in the range -1..max_order+2.
- get_b_field_text() str¶
Get a text description of the magnetic field. Returns an empty string if the method :compute_b_field: has not yet been called.
- Returns:
a human-readable description of the magnetic field
- get_e_field_text() str¶
Get a text description of the electric field. Returns an empty string if the method :compute_e_field: has not yet been called.
- Returns:
a human-readable description of the electric field
- get_magnetic_moment()¶
- get_mu()¶
- recurse(verbose: bool = False) None¶
Compute the auxiliary function up to the max order.
- Parameters:
verbose – whether to print the computed multi-index (default False)
- set_moments(current_moment=<cyfunction Solution.<lambda>>, charge_moment=None) None¶
Set the current and charge moment functions.
- Parameters:
current_moment – a callable returning the current moment for a given multi-index a1, a2, a3
charge_moment – a callable returning the charge moment for a given multi-index a1, a2, a3 (optional)
If the parameter :charge_moment: is not given, it is automatically computed according to :pynoza.helpers.get_charge_moment:.
- pynoza.helpers.get_charge_moment(current_moment: ndarray) ndarray¶
Compute a charge moment that is compatible with the conservation of charge
- Parameters:
current_moment – an array with the current moments
- Returns:
the corresponding charge moment
- Return type:
ndarray
The moment at index (i, a1, a2, a3) is the moment of the i-th coordinate corresponding to the multi-index (a1, a2, a3)