fdtdx.gds_layer_stack

fdtdx.gds_layer_stack#

fdtdx.gds_layer_stack(gds_source, cell_name, layers, materials, simulation_volume, gds_center, flatten=True)[source]#

Build simulation objects from a GDS file according to a layer stack specification.

For each GDSLayerSpec, polygons are extracted from the named GDS cell, optionally etched by other layers, converted to metres, and wrapped in a GDSLayerObject. Layers are always extruded along z (axis 2) — GDS encodes only x/y polygon geometry, so z is the only axis that can be inferred from the file. For non-z extrusion (e.g. cross-section simulations), construct GDSLayerObject instances directly with the desired axis. Two constraints are generated per object:

  • A position constraint aligning the object’s bottom face (z) with the simulation volume’s bottom face offset by spec.z_base.

  • A size constraint matching the simulation volume’s extent in the x/y axes.

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

  • cell_name (str) – Name of the GDS cell to read polygons from.

  • layers (list[GDSLayerSpec]) – Ordered list of GDSLayerSpec objects.

  • materials (dict[str, Material]) – Materials dictionary forwarded to every GDSLayerObject.

  • simulation_volume (SimulationVolume) – Used for size/position constraints.

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

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

Return type:

tuple[list[GDSLayerObject], list[Any]]

Returns:

(objects, constraints) - one GDSLayerObject and two constraints per layer spec.

Raises:

ValueError – If cell_name is not found in the library. If layers is empty