fdtdx.sources_from_gds_ports

fdtdx.sources_from_gds_ports#

fdtdx.sources_from_gds_ports(gds_source, cell_name, port_specs, wave_character, simulation_volume, gds_center, direction='+', mode_index=0, filter_pol=None, height_axis=2, flatten=True)[source]#

Create ModePlaneSource objects from GDS port markers.

Each polygon on a port marker layer becomes one source. The polygon’s centroid determines the position of the source’s left face along propagation_axis; the source’s width is set to match the port marker polygon’s width on the transverse axis.

Parameters:
  • gds_source (str | Path | Library) – Path to a .gds file or an already-loaded gdstk.Library.

  • cell_name (str) – GDS cell containing the port marker polygons.

  • port_specs (list[GDSPortSpec]) – List of GDSPortSpec objects (one per port layer).

  • wave_character (WaveCharacter) – Wavelength / frequency character forwarded to every source.

  • simulation_volume (SimulationVolume) – Reference object for cross-section size/position constraints. Its partial_real_shape must be set on propagation_axis.

  • gds_center (tuple[float, float]) – GDS coordinate (in metres) mapped to the x/y centre of the simulation volume.

  • direction (Union[Literal['+', '-'], dict[str, Literal['+', '-']]]) – Propagation direction passed to each source ("+" or "-"). Can also be a dict mapping port names to directions.

  • mode_index (int) – Waveguide mode index (default 0 = fundamental).

  • filter_pol (Optional[Literal['te', 'tm']]) – Optional polarisation filter ("te", "tm", or None).

  • height_axis (int) – Simulation axis treated as the out-of-plane height; sources are made to span the full simulation extent on this axis (default 2 = z). This assumes a single vertical stack — sources run from one face of the simulation volume to the other along height_axis.

  • flatten (bool) – Flatten sub-cell references before reading polygons.

Returns:

propagation position, transverse center, full-height size, and vertical center.

Return type:

(sources, constraints) — four constraints per source

Raises:

ValueError – If propagation_axis is not 0 or 1, or if simulation_volume.partial_real_shape is None on propagation_axis.