tidy3d.plugins.invdes.ErosionDilationPenalty#
- 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.- 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 anattr
obj.attrs['foo'] = bar
. Also note that Tidy3D` will raise aTypeError
ifattrs
contain objects that can not be serialized. One can check ifattrs
are serializable by callingobj.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 (PositiveFloat) – [units = um]. Length scale of erosion and dilation. Corresponds to
radius
in theConicFilter
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 (ConstrainedFloatValue = 100.0) – Strength of the
tanh
projection. Corresponds tobeta
in the :class:`BinaryProjector. Higher values correspond to stronger discretization.eta0 (ConstrainedFloatValue = 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 toeta
in theBinaryProjector
.delta_eta (ConstrainedFloatValue = 0.01) – The binarization threshold for erosion and dilation operations The thresholds are
0 + delta_eta
on the low end and1 - 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.
Note
For more details, refer to chapter 4 of Hammond, A., “High-Efficiency Topology Optimization for Very Large-Scale Integrated-Photonics Inverse Design” (2022).
Attributes
Methods
evaluate
(x, pixel_size)Evaluate this penalty.
Inherited Common Usage
- length_scale#
- beta#
- eta0#
- delta_eta#
- __hash__()#
Hash method.