domain_class
This class defines 2-dimensional spatial domains in cartesian and/or spherical coordinates used for field calculations of all multipolar fields. The planes are always centered around origo. It supports customizable size, meaning that it can be defined in terms of wavelength multiples. Furthermore, resolution and plane selection are customizable.
Creating an instance of a domain
object initializes the
desired planes as 2D numpy
arrays with a specified
resolution.
domain(size, points = 150, planes = {'xy', 'xz'})
float — width of the domain from center to edge in microns.
int — number of points along each axis in the grid. Default is 150.
set — must be any of ’xy’
, ’xz’
or
’yz’
. Defaults to {’xy’, ’xz’}
.
Ensures size
and points
are positive
numbers and planes
are valid. Called directly upon
initialization.
Defines 2D cartesian grids based on inputs.
Returns a dict with planes as keys and corresponding
numpy.meshgrid()
2D arrays as values with Cartesian
coordinates. For example, the ’xy’
key maps to
numpy.array([x, y])
.
Returns a dict with keys corresponding to planes and values being 3D
numpy
arrays [x, y, z]
. The missing coordinate
for each plane is filled with zeros.
Used for plotting on cartesian grids rather than spherical.
Returns a dict with identical keys (planes). The values are 3D
numpy
arrays with radial, polar, and azimuthal coordinates
of the plane, defined as
\[\begin{aligned} r &= \sqrt{x^2 + y^2 + z^2} \\ \theta &= \arccos\left(\frac{z}{r}\right) \quad \in [0, \pi] \\ \phi &= \begin{cases} \arctan2(y, x) & \text{for xy and xz planes} \\ \arctan2(x, y) + \pi/2 & \text{for yz plane} \end{cases} \end{aligned}\]
Visualizes the spherical coordinate values. coord
is
either ’r’
, ’theta’
, or ’phi’
,
and spherical_grids
is the dict returned by
spherical_grid()
. Plots the requested coordinate in all
defined planes using matplotlib
.