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:
objectConvolutional 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:
- 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.
PMLParams
- class prismo.boundaries.pml.PMLParams(thickness, sigma_max=None, kappa_max=15.0, alpha_max=0.0, polynomial_order=3)[source]
Bases:
objectParameters 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.
- __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:
objectMode 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')
- initialize(grid)[source]
Initialize the mode port on the simulation grid.
- Parameters:
grid (YeeGrid) – Simulation grid.
- Return type:
- 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.
- extract_mode_coefficients(fields, time)[source]
Extract mode coefficients from simulation fields.
Uses overlap integrals to decompose fields into mode amplitudes.
ModePortConfig
- class prismo.boundaries.mode_port.ModePortConfig(center, size, direction, modes, inject=False)[source]
Bases:
objectConfiguration for a mode port.
- modes
Modes supported by this port.
- Type:
List[WaveguideMode]
-
modes:
list[WaveguideMode]
- __init__(center, size, direction, modes, inject=False)
See Also
Boundary Conditions - Boundary conditions guide
Mode Ports - Mode ports guide
Tutorial 2: Waveguide Mode Coupling - Using mode ports in simulations