class ErosionDilationPenalty[source]#

Bases: AbstractPenalty

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.

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

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

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

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


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




evaluate(x, pixel_size)

Evaluate this penalty.

Inherited Common Usage

evaluate(x, pixel_size)[source]#

Evaluate this penalty.


Hash method.