Computation of time-domain solutions of Maxwell's equations using the Cartesian multipole expansion
Project description
pynoza
Python implementation of time-domain solutions of Maxwell's equations using the cartesian multipole expansion. In homogeneous and isotropic media, these solutions can be computed thanks to an explicit knowledge of the Green’s function.
Currently, the current density must be time-separable, i.e., $\mathbf{J}(t,\mathbf{x})=h(t)\mathbf{j}(\mathbf{x})$
The documentation is available here.
The theory behind the code can be found in E. Le Boudec et al., “The time-domain Cartesian multipole expansion of electromagnetic fields,” Sci Rep, vol. 14, no. 1, p. 8084, Apr. 2024, doi: 10.1038/s41598-024-58570-1.
Installation
To install directly from git, use
pip install "git+https://github.com/eliasleb/pynoza"
.
Tutorial
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:
-
Compute the electric time-domain current moments $C_\mathbf{\alpha}^{J_i}(t)=h^{'}(t)\iiint\mathbf{x}^\alpha j_i(\mathbf{x}) d^3\mathbf{x}$. Define a corresponding Python function that returns the space-dependence, whose signature must be
moment(ind: tuple[int, int, int]) -> list[Number, Number, Number]
. For a given multi-index(a1, a2, a3)
, the function must returnmoment(a1, a2, a3) = [j1, j2, j3]
whereji
is
$\iiint\mathbf{x}^\alpha \frac{\partial j_i(t,\mathbf{x})}{\partial t}d^3\mathbf{x}$The charge moments can be computed automatically by calling the function
pynoza.get_charge_moment
.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 $x_1,x_2,x_3,t$, for example
x1 = np.array([0, ]) x2 = x1.copy() x3 = np.array([wavelength, 2*wavelength, ]) t = np.linspace(-T, T, 100)
-
Define a function for the time-dependence, for example, a sympy symbolic expression
t_sym = sympy.Symbol("t", real=True) h_sym = sympy.cos(2*sympy.pi*f*t_sym)
or an array
t = np.linspace(0, T, dt) h = np.cos(2 * np.pi * f * t)
In the latter case, it is up to you to ensure that the sampling time
dt
is small enough to compute the highest-order derivative. We usenp.gradient
to compute the derivative; see the relevant numpy documentation. -
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 (this gets slower for high orders), and theset_moments
method to pass the current and charge moments that you computed above. -
Run the
compute_e_field
method to compute the electric field (orcompute_b_field
for the magnetic field) from Green’s functions approximations and the current moments. Under the hood, this method will integrate and differentiate the time-dependent function to the needed order.
Complete example
See applications/demos/demo_EPFL_logo.py
or tests/test_simple_example.py
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pynoza-0.3.1.tar.gz
.
File metadata
- Download URL: pynoza-0.3.1.tar.gz
- Upload date:
- Size: 223.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac8d1a9b6ffc9f2ba146d8be4948e0b101fb4b3f3bc93d9d2acca7bb7e9768ca |
|
MD5 | 4e4400b84b6ff75eeaeabe31f0b3ff8b |
|
BLAKE2b-256 | 0aa6a9b4e0a658f83314b3b1f2f892341a860d96c87b38cbef183ac4b78bcb72 |
File details
Details for the file pynoza-0.3.1-cp312-cp312-macosx_14_0_arm64.whl
.
File metadata
- Download URL: pynoza-0.3.1-cp312-cp312-macosx_14_0_arm64.whl
- Upload date:
- Size: 358.0 kB
- Tags: CPython 3.12, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 613f92bd6b1937fc42e477fd939d9d441cf8eb49333e096499a3a41337e9b9da |
|
MD5 | ddcb2cece3a0f7abe5cbc65371a945a3 |
|
BLAKE2b-256 | 55a3ce3745921f00e29ba7951ac67f06bad8959b13baeca2d929fd07f02ad85a |