Monitors API
Base Monitor
- class prismo.monitors.base.Monitor(center, size, name=None)[source]
Abstract base class for all field monitors.
- Parameters:
center (Tuple[float, float, float]) – Physical coordinates of the monitor center (x, y, z) in meters.
size (Tuple[float, float, float]) – Physical dimensions of the monitor region (Lx, Ly, Lz) in meters. For point monitors, use (0, 0, 0).
name (str, optional) – Name of the monitor for identification.
Field Monitor
- class prismo.monitors.field.FieldMonitor(center, size, components='all', name=None, time_domain=True, frequencies=None)[source]
Monitor for recording electromagnetic field data.
- Parameters:
center (Tuple[float, float, float]) – Physical coordinates of the monitor center (x, y, z) in meters.
size (Tuple[float, float, float]) – Physical dimensions of the monitor region (Lx, Ly, Lz) in meters.
components (List[str] or str, optional) – Field components to record, default=”all”.
name (str, optional) – Name of the monitor for identification.
time_domain (bool, optional) – Whether to record time-domain data, default=True.
frequencies (List[float], optional) – Frequencies to record in the frequency domain, in Hz.
- initialize(grid)[source]
Initialize the field monitor on a specific grid.
- Parameters:
grid (YeeGrid) – The grid on which to initialize the monitor.
- Return type:
- get_time_data(component)[source]
Get time-domain data for a specific field component.
- Parameters:
component (str) – Field component to retrieve (“Ex”, “Ey”, “Ez”, “Hx”, “Hy”, “Hz”).
- Returns:
Tuple containing (time_points, field_data).
- Return type:
- get_frequency_data(component, frequency)[source]
Get frequency-domain data for a specific field component and frequency.
- Parameters:
- Returns:
Complex-valued field data at the specified frequency.
- Return type:
- get_power_flow(frequency=None)[source]
Calculate Poynting vector (power flow) through the monitor.
- Parameters:
frequency (float, optional) – Frequency in Hz for frequency-domain calculation. If None, calculate time-domain Poynting vector.
- Returns:
If frequency is None, returns tuple (time_points, poynting_vector). Otherwise, returns poynting_vector at the specified frequency.
- Return type:
numpy.ndarray or tuple of numpy.ndarray
DFT Monitor
- class prismo.monitors.dft.DFTMonitor(center, size, frequencies, components=None, name=None, backend=None)[source]
Discrete Fourier Transform monitor for frequency-domain analysis.
This monitor computes frequency-domain fields on-the-fly during time-domain simulation using: F(ω) = ∫ f(t) * exp(-jωt) dt
Discretized as: F(ω) ≈ Σ f(n*dt) * exp(-jω*n*dt) * dt
- Parameters:
center (Tuple[float, float, float]) – Physical coordinates of monitor center (x, y, z) in meters.
size (Tuple[float, float, float]) – Physical dimensions of monitor (Lx, Ly, Lz) in meters.
frequencies (List[float]) – List of frequencies to monitor (Hz).
components (List[str], optional) – Field components to record. Default is all E components.
name (str, optional) – Monitor name.
backend (Backend, optional) – Computational backend to use.
- get_frequency_data(component, frequency_index=None)[source]
Get frequency-domain field data.
- Parameters:
- Returns:
Complex frequency-domain field data. If frequency_index is None, returns dict mapping frequency to data.
- Return type:
ndarray or dict
Flux Monitor
- class prismo.monitors.flux.FluxMonitor(center, size, direction, name=None, frequencies=None, backend=None)[source]
Flux monitor for computing power flow through a surface.
Computes the Poynting vector S = E × H and integrates over a surface to determine power flow. Can compute both time-domain and frequency-domain flux.
- Parameters:
center (Tuple[float, float, float]) – Physical coordinates of monitor center.
size (Tuple[float, float, float]) – Physical dimensions of monitor surface.
direction (str) – Normal direction of flux surface (‘x’, ‘y’, or ‘z’).
name (str, optional) – Monitor name.
frequencies (List[float], optional) – Frequencies for frequency-domain flux computation.
backend (Backend, optional) – Computational backend.
- update(fields, time, dt)[source]
Update flux monitor with current fields.
Computes instantaneous power flow and updates DFT if frequencies are specified.
- get_time_domain_power()[source]
Get time-domain power flow history.
- Returns:
(time_array, power_array)
- Return type:
Tuple[ndarray, ndarray]
Mode Expansion Monitor
- class prismo.monitors.mode_monitor.ModeExpansionMonitor(center, size, modes, direction='x', frequencies=None, name=None, backend=None)[source]
Mode expansion monitor for decomposing fields into mode coefficients.
Computes overlap integrals between simulation fields and waveguide modes to extract forward and backward propagating mode amplitudes.
The overlap integral is: a_m = ∫∫ (E_sim × H_mode* - E_mode* × H_sim) · n dA
- Parameters:
center (Tuple[float, float, float]) – Physical coordinates of monitor center.
size (Tuple[float, float, float]) – Physical dimensions of monitor.
modes (List[WaveguideMode]) – List of modes to decompose into.
direction (str) – Normal direction of monitor plane (‘x’, ‘y’, or ‘z’).
frequencies (List[float], optional) – Frequencies for frequency-domain decomposition.
name (str, optional) – Monitor name.
backend (Backend, optional) – Computational backend.
- update(fields, time, dt)[source]
Update mode expansion with current fields.
Computes overlap integrals and stores mode coefficients.
- get_mode_coefficient(mode_index, domain='time')[source]
Get mode coefficient time series or frequency spectrum.
- separate_forward_backward(mode_index, frequency_index)[source]
Separate forward and backward propagating mode amplitudes.
Uses phase information to separate directions.
- get_mode_transmission(mode_index, reference_power=None)[source]
Calculate mode transmission vs frequency.
- compute_s_parameters(source_mode_index=0, source_power=1.0)[source]
Compute S-parameters from mode coefficients.
For a two-port device with input and output monitors: - S11: Reflection coefficient at input port - S21: Transmission coefficient from port 1 to port 2
- Parameters:
- Returns:
Dictionary with ‘S11’, ‘S21’, etc. vs frequency.
- Return type:
Dict[str, ndarray]
Notes
This method assumes this monitor is the output/reflection monitor. For full S-parameters, you need multiple monitors.
- compute_s_matrix(other_monitor, frequency_index, source_mode_index=0)[source]
Compute full S-matrix between this and another monitor.
- Parameters:
other_monitor (ModeExpansionMonitor) – The other port monitor.
frequency_index (int) – Frequency index to compute S-matrix at.
source_mode_index (int) – Index of excited mode.
- Returns:
2x2 or NxN S-matrix.
- Return type:
ndarray
Examples
>>> # With input and output monitors >>> S = output_monitor.compute_s_matrix(input_monitor, freq_idx=0) >>> S11 = S[0, 0] # Reflection >>> S21 = S[1, 0] # Transmission