pynoza¶
Pynoza is a Python implementation of the time-domain multipole expansion of electromagnetic fields in Cartesian coordinates.
Currently, 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)
threshold – Minimum moment absolute value to be considered for computations
- compute_b_field(x1: ndarray, x2: ndarray, x3: ndarray, t: ndarray, h, t_sym=None, verbose=False, delayed=True, compute_grid=True, compute_txt=False, shift=0)¶
Compute the magnetic field B from the moments. The method recurse() 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, t_sym=None, verbose=False, delayed=True, compute_grid=True, compute_txt=False, shift=0)¶
Compute the electric field from the moments. The method recurse() must be run beforehand. If separability is assumed, the method set_moments(…) must also be run beforehand. In this case, the time-dependent excitation is assumed to be a function. Otherwise, the moments are embedded in the time-dependent excitation :h: (see below).
- 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 –
time-dependent excitation. If separability is assumed, it is: - either a symbolic expression of :t_sym: - or a 1D numpy array of samples, of the same size as :t:. If separability is not assumed, meaning each moment is permitted to exhibit distinct time-dependences, then :h: must be a dictionary following:
(a1, a2, a3) -> [f1, f2, f3]
where (a1, a2, a3) is the multi-index of a given moment, and f1, f2, f3 are the corresponding time-dependent excitations, for the first to last dimensions. f1, f2, f3 must be as above: either a symbolic expression of :t_sym:, or a 1D numpy array of samples the same size as :t:.
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:.