fdtdx.gds_layer_stack_from_component

fdtdx.gds_layer_stack_from_component#

fdtdx.gds_layer_stack_from_component(component, layers, materials, simulation_volume, gds_center, cell_name=None, flatten=True)[source]#

Build a layer stack from a gdsfactory Component.

This is a thin wrapper around gds_layer_stack() that accepts a gdsfactory Component object instead of a GDS file path. gdsfactory is not a required dependency of fdtdx; it must be installed separately (pip install gdsfactory).

The component is exported to a temporary GDS file, which is read back via gdstk.read_gds(). This approach is version-agnostic and works with all current gdsfactory releases.

Parameters:
  • component (Any) – A gdsfactory.Component instance.

  • layers (list[GDSLayerSpec]) – Layer specifications forwarded to gds_layer_stack().

  • 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.

  • cell_name (str | None) – GDS cell name to read. Defaults to component.name.

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

Return type:

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

Returns:

(objects, constraints) - same as gds_layer_stack().

Raises:
  • ImportError – If gdsfactory is not installed.

  • ValueError – If the resolved cell name is not found in the exported GDS.