Boundaries API

Complete API reference for boundary conditions in Prismo.

PML Absorbing Boundaries

CPML

class prismo.boundaries.pml.CPML(grid, params, backend=None)[source]

Bases: object

Convolutional Perfectly Matched Layer (CPML) absorbing boundary.

The CPML is an efficient implementation of PML that uses convolution with time-domain recursive integration. It provides excellent absorption with minimal reflections at the simulation boundaries.

Parameters:
  • grid (YeeGrid) – The simulation grid.

  • params (PMLParams) – PML configuration parameters.

  • backend (Backend, optional) – Computational backend to use.

__init__(grid, params, backend=None)[source]
update_electric_pml(fields, curl_h_x, curl_h_y, curl_h_z)[source]

Update PML auxiliary fields for E-field and apply PML correction.

Parameters:
  • fields (ElectromagneticFields) – Field arrays.

  • curl_h_x (array) – Curl of H-field components.

  • curl_h_y (array) – Curl of H-field components.

  • curl_h_z (array) – Curl of H-field components.

Return type:

Tuple of corrected curl components with PML applied.

update_magnetic_pml(fields, curl_e_x, curl_e_y, curl_e_z)[source]

Update PML auxiliary fields for H-field and apply PML correction.

Parameters:
  • fields (ElectromagneticFields) – Field arrays.

  • curl_e_x (array) – Curl of E-field components.

  • curl_e_y (array) – Curl of E-field components.

  • curl_e_z (array) – Curl of E-field components.

Return type:

Tuple of corrected curl components with PML applied.

apply_pml(fields)[source]

Apply PML boundary conditions to fields.

This is called after standard FDTD field updates to apply the PML absorption in boundary regions.

Parameters:

fields (ElectromagneticFields) – Electromagnetic fields to apply PML to.

Return type:

None

get_reflection_coefficient(angle=0.0)[source]

Estimate theoretical reflection coefficient of PML.

Parameters:

angle (float) – Incidence angle in degrees.

Returns:

Theoretical reflection coefficient.

Return type:

float

PMLParams

class prismo.boundaries.pml.PMLParams(thickness, sigma_max=None, kappa_max=15.0, alpha_max=0.0, polynomial_order=3)[source]

Bases: object

Parameters for PML configuration.

Parameters:
  • thickness (int) – Number of PML layers in grid cells.

  • sigma_max (float, optional) – Maximum conductivity value. If None, uses optimal value.

  • kappa_max (float, optional) – Maximum kappa stretching factor, default=15.0.

  • alpha_max (float, optional) – Maximum alpha CFS parameter, default=0.0.

  • polynomial_order (int, optional) – Polynomial grading order, default=3.

thickness: int
sigma_max: Optional[float] = None
kappa_max: float = 15.0
alpha_max: float = 0.0
polynomial_order: int = 3
__init__(thickness, sigma_max=None, kappa_max=15.0, alpha_max=0.0, polynomial_order=3)

Mode Port Boundaries

ModePort

class prismo.boundaries.mode_port.ModePort(config, name=None, enabled=True)[source]

Bases: object

Mode port for injecting and extracting waveguide modes.

A mode port acts as both a source (injecting modes) and a monitor (extracting mode amplitudes) at a plane in the simulation domain.

Parameters:
  • config (ModePortConfig) – Port configuration.

  • name (str, optional) – Port name for identification.

  • enabled (bool, optional) – Enable/disable port, default=True.

Examples

>>> from prismo.modes.solver import ModeSolver
>>> # Solve for waveguide modes
>>> mode_solver = ModeSolver(wavelength=1.55e-6, x=x, y=y, epsilon=eps)
>>> modes = mode_solver.solve(num_modes=2, mode_type='TE')
>>>
>>> # Create mode port
>>> config = ModePortConfig(
...     center=(0.0, 0.0, 0.0),
...     size=(2e-6, 2e-6, 0.0),
...     direction='+z',
...     modes=modes,
...     inject=True,
... )
>>> port = ModePort(config, name='input_port')
__init__(config, name=None, enabled=True)[source]
initialize(grid)[source]

Initialize the mode port on the simulation grid.

Parameters:

grid (YeeGrid) – Simulation grid.

Return type:

None

inject_fields(fields, time, dt, mode_amplitudes=None)[source]

Inject mode fields into the simulation.

This method adds mode field patterns to the simulation fields at the port location, with proper Yee grid staggering.

Parameters:
  • fields (ElectromagneticFields) – Field arrays to update.

  • time (float) – Current simulation time.

  • dt (float) – Time step.

  • mode_amplitudes (List[complex], optional) – Complex amplitudes for each mode. If None, uses unit amplitude.

Return type:

None

extract_mode_coefficients(fields, time)[source]

Extract mode coefficients from simulation fields.

Uses overlap integrals to decompose fields into mode amplitudes.

Parameters:
  • fields (ElectromagneticFields) – Current simulation fields.

  • time (float) – Current time.

Returns:

Mode coefficients for each port mode.

Return type:

List[complex]

get_mode_coefficient(mode_index)[source]

Get time series of mode coefficient.

Parameters:

mode_index (int) – Mode index.

Returns:

Mode coefficient vs time.

Return type:

List[complex]

get_time_points()[source]

Get recorded time points.

Returns:

Time points where coefficients were recorded.

Return type:

List[float]

ModePortConfig

class prismo.boundaries.mode_port.ModePortConfig(center, size, direction, modes, inject=False)[source]

Bases: object

Configuration for a mode port.

center

Port center position.

Type:

Tuple[float, float, float]

size

Port size (transverse dimensions).

Type:

Tuple[float, float, float]

direction

Port normal direction and orientation (‘+x’, ‘-x’, ‘+y’, ‘-y’, ‘+z’, ‘-z’).

Type:

str

modes

Modes supported by this port.

Type:

List[WaveguideMode]

inject

Whether to inject modes (source) or only extract (monitor).

Type:

bool

center: tuple[float, float, float]
size: tuple[float, float, float]
direction: Literal['+x', '-x', '+y', '-y', '+z', '-z']
modes: list[WaveguideMode]
inject: bool = False
__init__(center, size, direction, modes, inject=False)

See Also