pyoptics.fdtd.monitors¶
Monitors record data during a run, so the full time history never has to be stored.
Probe: time series of one component at a point (spectra, ring-downs).
Snapshots: decimated frames of a component for plots and animations, optionally cropped, subsampled, stored as float16, kept as a ring buffer (keep_last) or streamed to an HDF5 file.
DFTField: running discrete Fourier transform at a few wavelengths. The complex amplitudes follow the pyoptics convention (time dependence exp(-i omega t)): a field f(t) gives F = sum f(t) exp(+i omega t) dt, so a wave travelling towards +x has the phase exp(+ikx). For a continuous wave, Re{F exp(-i omega t)} animates the steady state over one period.
Flux: power through a line (2D) or a point (1D) per wavelength, from the DFT of E and H; ratios of two runs (with and without a structure) give reflectance and transmittance.
Monitor regions are given as ((xmin, xmax), (ymin, ymax)) (None for the whole domain); each component keeps the nodes that fall inside.
Classes
Running DFT of field components at vacuum wavelengths. |
|
Complex field amplitudes at some wavelengths: fields[component] has the shape (n_wavelengths, ...), coords[component] one array per axis. |
|
Spectral power flux through a line (2D) or a point (1D). |
|
Base class: setup(sim) once, record(sim) after every step. |
|
Time series of one field component at the node nearest to a point. |
|
Frames of one component: times (n,), coords (one array per axis), frames (n, ...) and the component name. |
|
Decimated frames of one field component. |
- class pyoptics.fdtd.monitors.Monitor[source]¶
Bases:
objectBase class: setup(sim) once, record(sim) after every step.
- class pyoptics.fdtd.monitors.Probe(position, component=None)[source]¶
Bases:
MonitorTime series of one field component at the node nearest to a point.
Attributes after a run: times, values (arrays).
- class pyoptics.fdtd.monitors.SnapshotStack(times, coords, frames, component, mode='Ez')[source]¶
Bases:
objectFrames of one component: times (n,), coords (one array per axis), frames (n, …) and the component name.
- class pyoptics.fdtd.monitors.Snapshots(component=None, every=10, region=None, stride=1, dtype=<class 'numpy.float16'>, keep_last=None, start=0.0, path=None)[source]¶
Bases:
MonitorDecimated frames of one field component.
- Parameters:
- componentstr, optional
Default: Ez in the Ez mode, Hz in the Hz mode.
- everyint
Record every
everysteps.- regiontuple, optional
Crop, ((xmin, xmax), (ymin, ymax)).
- strideint
Spatial subsampling.
- dtypenumpy dtype
Storage type of the frames; float16 halves the memory of float32 and is plenty for plots.
- keep_lastint, optional
Keep only the last frames (ring buffer).
- startnumber
Time at which recording starts.
- pathstr, optional
Stream the frames to this HDF5 file (needs h5py) instead of keeping them in memory.
- class pyoptics.fdtd.monitors.DFTFieldData(wavelengths, fields, coords, mode='Ez')[source]¶
Bases:
objectComplex field amplitudes at some wavelengths: fields[component] has the shape (n_wavelengths, …), coords[component] one array per axis.
- class pyoptics.fdtd.monitors.DFTField(wavelengths, components=None, region=None, start=0.0, stride=1)[source]¶
Bases:
MonitorRunning DFT of field components at vacuum wavelengths.
- Parameters:
- wavelengthsnumber or array
- componentssequence of str, optional
Default: all components of the mode.
- regiontuple, optional
((xmin, xmax), (ymin, ymax)); default: the whole grid.
- startnumber
Time from which on to accumulate (e.g. after a CW source has reached the steady state).
- strideint
Spatial subsampling.
- class pyoptics.fdtd.monitors.Flux(position, wavelengths, axis=0, extent=None)[source]¶
Bases:
MonitorSpectral power flux through a line (2D) or a point (1D).
The line is normal to
axisatposition, optionally limited toextentalong the other axis; the flux counts positive along +axis. H is interpolated to the E nodes. flux() returns 1/2 Re(sum E H*) dA per wavelength (arbitrary units: divide by the flux of a reference run).