¶
Devices¶
In FDTDX, devices are objects whose shape can be optimized. A device has a corresponding set of latent parameters, which are mapped to produce the current shape of the device.
fdtdx.objects.device.DiscreteDevice
¶
Bases: BaseDevice
A device with discrete material states.
This class represents a simulation object whose permittivity distribution can be optimized through gradient-based methods, with discrete transitions between materials. The permittivity values are controlled by parameters that are mapped through constraints to produce the final device structure.
Attributes:
Name | Type | Description |
---|---|---|
name |
Optional name identifier for the device |
|
constraint_mapping |
Maps optimization parameters to permittivity values |
|
dtype |
Data type for device parameters, defaults to float32 |
|
color |
RGB color tuple for visualization, defaults to pink |
Source code in src/fdtdx/objects/device/device.py
Parameter Mapping¶
fdtdx.objects.device.DiscreteParameterMapping
¶
Bases: LatentParameterMapping
Source code in src/fdtdx/objects/device/parameters/mapping.py
Tranformation of latent parameters¶
fdtdx.objects.device.StandardToInversePermittivityRange
¶
Bases: SameShapeDtypeLatentTransform
Maps standard [0,1] range to inverse permittivity range.
Linearly maps values from [0,1] to the range between minimum and maximum inverse permittivity values allowed by the material configuration.
Source code in src/fdtdx/objects/device/parameters/latent.py
fdtdx.objects.device.StandardToPlusOneMinusOneRange
¶
Bases: StandardToCustomRange
Maps standard [0,1] range to [-1,1] range.
Special case of StandardToCustomRange that maps to [-1,1] range. Used for symmetric value ranges around zero.
Attributes:
Name | Type | Description |
---|---|---|
min_value |
float
|
Fixed to -1 |
max_value |
float
|
Fixed to 1 |
Source code in src/fdtdx/objects/device/parameters/latent.py
fdtdx.objects.device.StandardToCustomRange
¶
Bases: SameShapeDtypeLatentTransform
Maps standard [0,1] range to custom range [min_value, max_value].
Linearly maps values from [0,1] to a custom range specified by min_value and max_value parameters.
Attributes:
Name | Type | Description |
---|---|---|
min_value |
float
|
Minimum value of target range |
max_value |
float
|
Maximum value of target range |
Source code in src/fdtdx/objects/device/parameters/latent.py
Discretizations¶
fdtdx.objects.device.ClosestIndex
¶
Bases: Discretization
Maps continuous latent values to nearest allowed material indices.
For each input value, finds the index of the closest allowed inverse permittivity value. Uses straight-through gradient estimation to maintain differentiability.
Source code in src/fdtdx/objects/device/parameters/discretization.py
fdtdx.objects.device.PillarDiscretization
¶
Bases: Discretization
Constraint module for mapping pillar structures to allowed configurations.
Maps arbitrary pillar structures to the nearest allowed configurations based on material constraints and geometry requirements. Ensures structures meet fabrication rules like single polymer columns and no trapped air holes.
Attributes:
Name | Type | Description |
---|---|---|
axis |
int
|
Axis along which to enforce pillar constraints (0=x, 1=y, 2=z). |
single_polymer_columns |
bool
|
If True, restrict to single polymer columns. |
distance_metric |
Literal['euclidean', 'permittivity_differences_plus_average_permittivity']
|
Method to compute distances between material distributions: - "euclidean": Standard Euclidean distance between permittivity values - "permittivity_differences_plus_average_permittivity": Weighted combination of permittivity differences and average permittivity values, optimized for material distribution comparisons |
Source code in src/fdtdx/objects/device/parameters/discretization.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
fdtdx.objects.device.BrushConstraint2D
¶
Bases: Discretization
Applies 2D brush-based constraints to ensure minimum feature sizes.
Implements the brush-based constraint method described in: https://pubs.acs.org/doi/10.1021/acsphotonics.2c00313
This ensures minimum feature sizes and connectivity in 2D designs by using morphological operations with a brush kernel.
Attributes:
Name | Type | Description |
---|---|---|
brush |
Array
|
JAX array defining the brush kernel for morphological operations. |
axis |
int
|
Axis along which to apply the 2D constraint (perpendicular plane). |
Source code in src/fdtdx/objects/device/parameters/discretization.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
fdtdx.objects.device.circular_brush(diameter, size=None)
¶
Creates a circular binary mask/brush for morphological operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
diameter
|
float
|
Diameter of the circle in grid units. |
required |
size
|
int | None
|
Optional size of the output array. If None, uses ceil(diameter) rounded up to next odd number. |
None
|
Returns:
Type | Description |
---|---|
Array
|
Binary JAX array containing a circular mask where True indicates points |
Array
|
within the circle diameter. |
Source code in src/fdtdx/objects/device/parameters/discretization.py
Discrete PostProcessing¶
fdtdx.objects.device.BinaryMedianFilterModule
¶
Bases: DiscreteTransformation
Performs 3D binary median filtering on the design.
Applies a 3D median filter to smooth and clean up binary material distributions. This helps remove small features and noise while preserving larger structures.
Attributes:
Name | Type | Description |
---|---|---|
padding_cfg |
PaddingConfig
|
Configuration for padding behavior at boundaries. |
kernel_sizes |
tuple[int, int, int]
|
3-tuple of kernel sizes for each dimension. |
num_repeats |
int
|
Number of times to apply the filter consecutively. |
Source code in src/fdtdx/objects/device/parameters/discrete.py
fdtdx.objects.device.ConnectHolesAndStructures
¶
Bases: DiscreteTransformation
Connects floating polymer regions and ensures air holes connect to outside.
This constraint module ensures physical realizability of designs by: 1. Either connecting floating polymer regions to the substrate or removing them 2. Ensuring all air holes are connected to the outside (no trapped air)
The bottom (lower z) is treated as the substrate reference.
Attributes:
Name | Type | Description |
---|---|---|
fill_material |
str | None
|
Name of material to use for filling gaps when connecting regions. Required when working with more than 2 materials. |
Source code in src/fdtdx/objects/device/parameters/discrete.py
fdtdx.objects.device.RemoveFloatingMaterial
¶
Bases: DiscreteTransformation
Finds all material that floats in the air and sets their permittivity to air.
This constraint module identifies regions of material that are not connected to any substrate or boundary and converts them to air. This helps ensure physically realizable designs by eliminating floating/disconnected material regions.
The module only works with binary material systems (2 permittivities) where one material represents air.
Source code in src/fdtdx/objects/device/parameters/discrete.py
fdtdx.objects.device.BinaryMedianFilterModule
¶
Bases: DiscreteTransformation
Performs 3D binary median filtering on the design.
Applies a 3D median filter to smooth and clean up binary material distributions. This helps remove small features and noise while preserving larger structures.
Attributes:
Name | Type | Description |
---|---|---|
padding_cfg |
PaddingConfig
|
Configuration for padding behavior at boundaries. |
kernel_sizes |
tuple[int, int, int]
|
3-tuple of kernel sizes for each dimension. |
num_repeats |
int
|
Number of times to apply the filter consecutively. |