tidy3d.plugins.autograd.invdes.smoothed_projection

tidy3d.plugins.autograd.invdes.smoothed_projection#

class smoothed_projection[source]#

Bases:

Apply a subpixel-smoothed projection method. The subpixel-smoothed projection method is discussed in [1] as follows:

This projection method eliminates discontinuities by applying first-order smoothing at material boundaries through analytical fill factors. Unlike traditional quadrature approaches, it works with maximum projection strength (\(\beta = \infty\)) and derives closed-form expressions for interfacial regions.

Prerequisites: input fields must be pre-filtered for continuity (for example using a conic filter).

The algorithm detects whether boundaries intersect grid cells. When interfaces are absent, standard projection is applied. For cells containing boundaries, analytical fill ratios are computed to maintain gradient continuity as interfaces move through cells and traverse pixel centers. This enables arbitrarily large \(\beta\) values while preserving differentiability throughout the transition process.

Warning

This function assumes that the device is placed on a uniform grid. When using `GridSpec.auto` in the simulation, make sure to place a MeshOverrideStructure at the position of the optimized geometry.

Parameters:
  • array (np.ndarray) – The input array to be projected.

  • beta (float = BETA_DEFAULT) – The steepness of the projection. Higher values result in a sharper transition.

  • eta (float = ETA_DEFAULT) – The midpoint of the projection.

  • scaling_factor (float = 1.0) – Optional scaling factor to adjust dx and dy to different resolutions.

Example

>>> import autograd.numpy as np
>>> from tidy3d.plugins.autograd.invdes.filters import ConicFilter
>>> arr = np.random.uniform(size=(50, 50))
>>> filter = ConicFilter(kernel_size=5)
>>> arr_filtered = filter(arr)
>>> eta = 0.5  # center of projection
>>> smoothed = smoothed_projection(arr_filtered, beta=np.inf, eta=eta)

Inherited Common Usage