Python implementation of time-domain solutions of Maxwell's equations using the cartesian multipole expansion. These solutions can be computed in homogeneous and isotropic media thanks to an explicit knowledge of Green’s function.
Currently, only the electric field computation is supported, and the current density must be time-separable, i.e.,
To install, clone the repository. From the root pynoza folder, run pip install -e ..
The Python >= 3.10 script tests/test_EPFL_logo.py shows some examples. A Jupyter notebook is also provided. The general procedure is the following:
- Given the current density J(t, x), compute the charge density ρ, given by
- Compute the electric time-domain current moments
and the electric time-domain charge moment
Define two corresponding Python functions that return the space-dependence, whose signature must be moment(ind: tuple[int, int, int]) -> list[Number, Number, Number]. The time dependence is kept separate; see later.
- pynoza works in natural units, as does meep (see https://meep.readthedocs.io/en/latest/Introduction/#units-in-meep).
- Define NumPy arrays for the coordinates of interest, for example
x1 = np.array([0, ]) x2 = x1.copy() x3 = np.array([wavelength, 2*wavelength, ]) t = np.linspace(-T, T, 100)
- Define a symbolic function for the time-dependence, for example
t_sym = sympy.Symbol("t", real=True) h_sym = sympy.cos(2*sympy.pi*f*t_sym)
- Create a pynoza.Solution object with the given medium light speed (in natural units) and given multipole expansion order.
- Run the recurse method to initialize the Green’s function approximation (which gets slower for high orders) and the set_moments method to pass the current and charge moments you computed above.
- Run the compute_e_field method to compute the electric field from the Green’s functions approximation and the charge and current moments. Under the hood, this method will integrate and differentiate the time-dependent function h_sym to the needed order.