From 5cf8c619b9852c3ecba87c2b480e6f3641f766f7 Mon Sep 17 00:00:00 2001 From: Yannick Augenstein Date: Wed, 6 Nov 2024 12:21:55 +0100 Subject: [PATCH] Use default `td.ModeSpec` in mode monitors --- CHANGELOG.md | 3 ++- tests/test_components/test_monitor.py | 8 ++++---- tidy3d/components/monitor.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cb696e25..c2ad4d00c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - `CustomMedium` design regions require far less data when performing inverse design by reducing adjoint field monitor size for dims with one pixel. -- Calling `.values` on `DataArray` no longer raises a `DeprecationWarning` during automatic differentiation +- Calling `.values` on `DataArray` no longer raises a `DeprecationWarning` during automatic differentiation. +- `ModeMonitor` and `ModeSolverMonitor` now use the default `td.ModeSpec()` when `mode_spec` is not provided. ### Fixed - Regression in local field projection leading to incorrect results for `far_field_approx=True`. diff --git a/tests/test_components/test_monitor.py b/tests/test_components/test_monitor.py index 1daadc3ea..501295fc2 100644 --- a/tests/test_components/test_monitor.py +++ b/tests/test_components/test_monitor.py @@ -333,19 +333,19 @@ def test_monitor(): m5 = td.ModeMonitor( size=(1, 1, 0), center=center, mode_spec=td.ModeSpec(), freqs=FREQS, name="test_mon" ) - m6 = td.ModeSolverMonitor( + m6 = td.ModeMonitor(size=(1, 1, 0), center=center, freqs=FREQS, name="test_mon") + m7 = td.ModeSolverMonitor( size=(1, 1, 0), center=center, - mode_spec=td.ModeSpec(), freqs=FREQS, name="test_mon", direction="-", ) - m7 = td.PermittivityMonitor(size=size, center=center, freqs=FREQS, name="perm") + m8 = td.PermittivityMonitor(size=size, center=center, freqs=FREQS, name="perm") tmesh = np.linspace(0, 1, 10) - for m in [m1, m2, m3, m4, m5, m6, m7]: + for m in [m1, m2, m3, m4, m5, m6, m7, m8]: # m.plot(y=2) # plt.close() m.storage_size(num_cells=100, tmesh=tmesh) diff --git a/tidy3d/components/monitor.py b/tidy3d/components/monitor.py index 45e11b7c6..32a228cb8 100644 --- a/tidy3d/components/monitor.py +++ b/tidy3d/components/monitor.py @@ -279,7 +279,7 @@ class AbstractModeMonitor(PlanarMonitor, FreqMonitor): """:class:`Monitor` that records mode-related data.""" mode_spec: ModeSpec = pydantic.Field( - ..., + default_factory=ModeSpec, title="Mode Specification", description="Parameters to feed to mode solver which determine modes measured by monitor.", )