Skip to content

stencil.grating

grating(
period,
num_periods,
width,
fill_factor=0.5,
taper_length=0,
taper_width=0,
)

Create a linear grating.

Args

  • period (float): Grating period (distance between adjacent teeth centers).
  • num_periods (int): Number of grating periods.
  • width (float): Lateral grating width.
  • fill_factor (float | str | Expression): Ratio between the grating teeth and the grating period. An string parametrized by "u" or a expression of a single parameter (varied from 0 to 1) can be used to vary the fill factor along the grating.
  • taper_length (float): length of an optional linear taper ending at the grating.
  • taper_width (float): width at the start of the linear taper.

Returns

list[Rectangle | Polygon]: Grating structures.

Example

>>> # Grating with taper
>>> grating1 = pf.stencil.grating(
... period=0.6, num_periods=20, width=10, taper_length=30, taper_width=0.5
... )
>>> # Apodized grating
>>> grating2 = pf.stencil.grating(
... period=0.6, num_periods=25, width=10, fill_factor="0.8 - 1.2 * (1 - u) * u"
... )
>>> grating2 = [s.translate((50, 0)) for s in grating2]
>>> component = pf.Component().add(*grating1, *grating2)

grating