tidy3d.plugins.invdes.ErosionDilationPenalty#

class ErosionDilationPenalty[source]#

Bases: AbstractPenalty, ErosionDilationPenalty

Erosion and dilation penalty, addable to tdi.TopologyDesignRegion.penalties. Uses filtering and projection methods to erode and dilate the features within this array. Measures the change in the array after eroding and dilating (and also dilating and eroding). Returns a penalty proportional to the magnitude of this change. The amount of change under dilation and erosion is minimized if the structure has large feature sizes and large radius of curvature relative to the length scale.

Parameters:
  • attrs (dict = {}) – Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields, attrs are mutable. For example, the following is allowed for setting an attr obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a TypeError if attrs contain objects that can not be serialized. One can check if attrs are serializable by calling obj.json().

  • length_scale (NonNegativeFloat) – [units = um]. Length scale of erosion and dilation. Corresponds to radius in the ConicFilter used for filtering. The parameter array is dilated and eroded by half of this value with each operation. Roughly corresponds to the desired minimum feature size and radius of curvature.

  • pixel_size (Optional[PositiveFloat] = None) – [units = um]. Size of each pixel in the array (must be the same along all dimensions). Corresponds to design_region_dl in the ConicFilter used for filtering. NOTE: this is set internally in the invdes plugin. So supplied values will be ignored.

  • beta (PositiveFloat = 100.0) – Strength of the tanh projection. Corresponds to beta in the :class:`BinaryProjector. Higher values correspond to stronger discretization.

  • eta0 (PositiveFloat = 0.5) – Value between 0 and 1 that sets the projection midpoint. In other words, for values of eta0, the projected values are halfway between minimum and maximum. Corresponds to eta in the BinaryProjector.

  • delta_eta (PositiveFloat = 0.01) – The binarization threshold for erosion and dilation operations The thresholds are 0 + delta_eta on the low end and 1 - delta_eta on the high end. The default value balances binarization with differentiability so we strongly suggest using it unless there is a good reason to set it differently.

  • weight (NonNegativeFloat = 1.0) – When this penalty is evaluated, it will be weighted by this value. Note that the optimizer seeks to maximize the objective function and subtracts the penalty strength times this weight from the objective function.

Note

For more details, refer to chapter 4 of Hammond, A., “High-Efficiency Topology Optimization for Very Large-Scale Integrated-Photonics Inverse Design” (2022).

../../_images/erosion_dilation.png

Attributes

attrs

Methods

evaluate(x, pixel_size)

Evaluate this penalty.

to_tda(pixel_size)

Inherited Common Usage

pixel_size#
to_tda(pixel_size)[source]#
evaluate(x, pixel_size)[source]#

Evaluate this penalty.

__hash__()#

Hash method.