pyoptics.fdtd.grid

The Yee grid: sizes, staggered sample positions and the time step.

Units are normalized: the vacuum speed of light, permittivity and permeability are 1, lengths are in any unit (the same as the wavelengths) and times are in that unit divided by c. The frequency of a vacuum wavelength wl is f = 1/wl, its angular frequency 2*pi/wl.

Arrays are indexed [ix] in 1D and [ix, iy] in 2D (x first). The grid has shape[a] cells along axis a, with origin + i*spacing (i = 0..shape[a] - 1) for the integer nodes and origin + (i + 1/2)*spacing for the half nodes. The outer walls lie at origin and origin + shape*spacing.

Classes

Grid

Regular Yee grid in 1D or 2D.

class pyoptics.fdtd.grid.Grid(size, spacing, center=None)[source]

Bases: object

Regular Yee grid in 1D or 2D.

Parameters:
sizenumber or tuple

Extent of the computational domain along each axis, including the absorbing layers. A number gives a 1D grid.

spacingnumber or tuple

Cell size, the same for all axes if a number. The number of cells is round(size/spacing).

centernumber or tuple, optional

Centre of the domain, 0 by default.

axis(a, offset=0.0)[source]

Coordinates of the nodes along axis a, shifted by offset cells.

coords(component, mode='Ez')[source]

1D coordinate arrays (one per axis) of a field component.

index(position, component, mode='Ez')[source]

Index tuple of the node of a component closest to a position.

time_step(courant=0.99)[source]

Time step as a fraction courant of the stability limit 1/sqrt(sum(1/spacing**2)).

property extent

(xmin, xmax[, ymin, ymax]) of the domain, for imshow().