File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
tidy3d/plugins/adjoint/components Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
12
12
13
13
### Fixed
14
14
- Ensure same ` Grid ` is generated in forward and adjoint simulations by setting ` GridSpec.wavelength ` manually in adjoint.
15
-
15
+ - Proper handling of ` JaxBox ` derivatives both for multi-cell and single cell thickness.
16
16
17
17
## [ 2.4.1] - 2023-9-20
18
18
Original file line number Diff line number Diff line change @@ -237,9 +237,20 @@ def store_vjp(
237
237
eps_data = grad_data_eps .field_components [eps_field_name ].isel (f = 0 )
238
238
239
239
# get the permittivity values just inside and outside the edge
240
- n_cells_in = 2
240
+
241
+ num_cells_normal_dim = len (eps_data .coords [dim_normal ])
242
+
243
+ # if the eps_data is <=3 grid cells thick, pick the middle cell
244
+ if num_cells_normal_dim <= 3 :
245
+ isel_ins = num_cells_normal_dim // 2
246
+
247
+ # otherwise, pick the cell 4 pixels from outside cell
248
+ else :
249
+ n_cells_in = 3
250
+ isel_ins = n_cells_in if min_max_index == 0 else - n_cells_in - 1
251
+
241
252
isel_out = 0 if min_max_index == 0 else - 1
242
- isel_ins = n_cells_in if min_max_index == 0 else - n_cells_in - 1
253
+
243
254
eps2 = eps_data .isel (** {dim_normal : isel_out })
244
255
eps1 = eps_data .isel (** {dim_normal : isel_ins })
245
256
You can’t perform that action at this time.
0 commit comments