Skip to content

Commit 815e795

Browse files
committed
Merge branch 'develop' into latest
2 parents f8c27cc + eb12207 commit 815e795

File tree

13 files changed

+52
-39
lines changed

13 files changed

+52
-39
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [2.7.9] - 2025-01-22
11+
12+
### Fixed
13+
- Potential task name mismatches between forward and adjoint simulations in batch tasks.
14+
- Magnitude of gradient computation in `CustomMedium` by accounting properly for full volume element when permittivity data is defined over fewer dimensions than the medium.
15+
1016
## [2.7.8] - 2024-11-27
1117

1218
### Changed
@@ -1395,8 +1401,9 @@ which fields are to be projected is now determined automatically based on the me
13951401
- Job and Batch classes for better simulation handling (eventually to fully replace webapi functions).
13961402
- A large number of small improvements and bug fixes.
13971403

1398-
[Unreleased]: https://github.com/flexcompute/tidy3d/compare/v2.7.8...develop
1399-
[2.7.8]: https://github.com/flexcompute/tidy3d/compare/v2.7.6...v2.7.7
1404+
[Unreleased]: https://github.com/flexcompute/tidy3d/compare/v2.7.9...develop
1405+
[2.7.9]: https://github.com/flexcompute/tidy3d/compare/v2.7.8...v2.7.9
1406+
[2.7.8]: https://github.com/flexcompute/tidy3d/compare/v2.7.7...v2.7.8
14001407
[2.7.7]: https://github.com/flexcompute/tidy3d/compare/v2.7.6...v2.7.7
14011408
[2.7.6]: https://github.com/flexcompute/tidy3d/compare/v2.7.5...v2.7.6
14021409
[2.7.5]: https://github.com/flexcompute/tidy3d/compare/v2.7.4...v2.7.5

docs/faq

Submodule faq updated 31 files

docs/notebooks

poetry.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "tidy3d"
3-
version = "2.7.8"
3+
version = "2.7.9"
44
description = "A fast FDTD solver"
55
authors = ["Tyler Hughes <[email protected]>"]
66
license = "LGPLv2+"
@@ -68,8 +68,8 @@ gdspy = { version = "*", optional = true }
6868
gdstk = { version = ">=0.9.49", optional = true }
6969

7070
# jax
71-
jaxlib = { version = ">=0.4.25", source = "jaxsource", optional = true }
72-
jax = { version = ">=0.4.25", extras = [
71+
jaxlib = { version = ">=0.4.26", source = "jaxsource", optional = true }
72+
jax = { version = ">=0.4.26", extras = [
7373
"cpu",
7474
], source = "jaxsource", optional = true }
7575

@@ -273,7 +273,7 @@ testpaths = ["tidy3d", "tests", "docs"]
273273
python_files = "*.py"
274274

275275
[tool.bumpversion]
276-
current_version = "2.7.8"
276+
current_version = "2.7.9"
277277
parse = """(?x)
278278
(?P<major>0|[1-9]\\d*)\\.
279279
(?P<minor>0|[1-9]\\d*)\\.

tests/sims/simulation_sample.h5

0 Bytes
Binary file not shown.

tests/sims/simulation_sample.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2897,7 +2897,7 @@
28972897
"snapping_points": [],
28982898
"type": "GridSpec"
28992899
},
2900-
"version": "2.7.8",
2900+
"version": "2.7.9",
29012901
"lumped_elements": [],
29022902
"subpixel": false,
29032903
"simulation_type": "tidy3d",

tests/test_components/test_autograd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ def test_autograd_async(use_emulated_run, structure_key, monitor_key):
755755
make_sim = fn_dict["sim"]
756756
postprocess = fn_dict["postprocess"]
757757

758-
task_names = {"1", "2", "3", "4"}
758+
task_names = {"test_a", "adjoint", "task1", "_test"}
759759

760760
def objective(*args):
761761
sims = {task_name: make_sim(*args) for task_name in task_names}

tidy3d/components/grid/grid_spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class UniformGrid(GridSpec1d):
223223
Specification for non-uniform grid along a given dimension.
224224
225225
**Notebooks:**
226-
* `Photonic crystal waveguide polarization filter <../../../notebooks/PhotonicCrystalWaveguidePolarizationFilter.html>`_
226+
* `Photonic crystal waveguide polarization filter <../../notebooks/PhotonicCrystalWaveguidePolarizationFilter.html>`_
227227
* `Using automatic nonuniform meshing <../../notebooks/AutoGrid.html>`_
228228
"""
229229

tidy3d/components/medium.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2582,7 +2582,17 @@ def _derivative_field_cmp(
25822582

25832583
coords_interp = {key: eps_data.coords[key] for key in "xyz"}
25842584
coords_interp = {key: val for key, val in coords_interp.items() if len(val) > 1}
2585-
dims_sum = [dim for dim in "xyz" if dim not in coords_interp]
2585+
2586+
E_der_dim_interp = E_der_map[f"E{dim}"]
2587+
2588+
for dim_ in "xyz":
2589+
if dim_ not in coords_interp:
2590+
bound_max = np.max(E_der_dim_interp.coords[dim_])
2591+
bound_min = np.min(E_der_dim_interp.coords[dim_])
2592+
dimension_size = bound_max - bound_min
2593+
2594+
if dimension_size > 0.0:
2595+
E_der_dim_interp = E_der_dim_interp.integrate(dim_)
25862596

25872597
# compute sizes along each of the interpolation dimensions
25882598
sizes_list = []
@@ -2610,28 +2620,24 @@ def _derivative_field_cmp(
26102620
d_vol = np.array(1.0)
26112621

26122622
# TODO: probably this could be more robust. eg if the DataArray has weird edge cases
2613-
E_der_dim = E_der_map[f"E{dim}"]
26142623
E_der_dim_interp = (
2615-
E_der_dim.interp(**coords_interp, assume_sorted=True).fillna(0.0).sum(dims_sum).real
2624+
E_der_dim_interp.interp(**coords_interp, assume_sorted=True).fillna(0.0).real.sum("f")
26162625
)
2617-
E_der_dim_interp = E_der_dim_interp.sum("f")
2618-
2619-
vjp_array = np.array(E_der_dim_interp.values, dtype=float)
2620-
2621-
vjp_array = vjp_array.reshape(eps_data.shape)
26222626

2623-
# multiply by volume elements (if possible, being defensive here..)
26242627
try:
2625-
vjp_array *= d_vol.reshape(vjp_array.shape)
2628+
E_der_dim_interp = E_der_dim_interp * d_vol.reshape(E_der_dim_interp.shape)
26262629
except ValueError:
26272630
log.warning(
26282631
"Skipping volume element normalization of 'CustomMedium' gradients. "
26292632
f"Could not reshape the volume elements of shape {d_vol.shape} "
2630-
f"to the shape of the gradient {vjp_array.shape}. "
2633+
f"to the shape of the fields {E_der_dim_interp.shape}. "
26312634
"If you encounter this warning, gradient direction will be accurate but the norm "
26322635
"will be inaccurate. Please raise an issue on the tidy3d front end with this "
26332636
"message and some information about your simulation setup and we will investigate. "
26342637
)
2638+
vjp_array = E_der_dim_interp.values
2639+
vjp_array = vjp_array.reshape(eps_data.shape)
2640+
26352641
return vjp_array
26362642

26372643

0 commit comments

Comments
 (0)