Skip to content

Commit 1cbb351

Browse files
caseyflexmomchil-flex
authored andcommitted
fix: change default EME store_coeffs to False and add validation
1 parent 7db47cf commit 1cbb351

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Added `symmetrize_mirror`, `symmetrize_rotation`, `symmetrize_diagonal` functions to the autograd plugin. They can be used for enforcing symmetries in topology optimization.
1212
- Klayout plugin automatically finds klayout installation path at common locations.
1313
- Added autograd support for `TriangleMesh`, allowing gradient computation with respect to mesh vertices for inverse design.
14-
- Added `EMESimulationData.coeffs` to store coefficients from the EME solver, including mode overlaps, interface S matrices, and effective propagation indices.
14+
- Added `EMESimulation.store_coeffs` to store coefficients from the EME solver, including mode overlaps, interface S matrices, and effective propagation indices.
1515
- Get cell-related information from violation markers in `DRCResults` and `DRCViolation` to the klayout plugin: Use for example `DRCResults.violations_by_cell` to group them.
1616

1717
### Changed

tests/test_components/test_eme.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def test_eme_simulation():
473473
grid_spec=sim.grid_spec.updated_copy(wavelength=1),
474474
)
475475
with AssertLogLevel("WARNING", contains_str="store_coeffs"):
476-
sim_bad.validate_pre_upload()
476+
sim_bad.updated_copy(store_coeffs=True).validate_pre_upload()
477477
sim_bad = sim.updated_copy(
478478
size=(10, 10, 10),
479479
monitors=[large_monitor],
@@ -1433,15 +1433,16 @@ def test_eme_periodicity():
14331433

14341434
# remove the field monitor, now it passes
14351435
desired_cell_index_pairs = set([(i, i + 1) for i in range(6)] + [(5, 1)])
1436-
with AssertLogLevel("WARNING", contains_str="deprecated"):
1437-
sim = sim.updated_copy(
1438-
monitors=[m for m in sim.monitors if not isinstance(m, td.EMEFieldMonitor)]
1439-
)
1440-
sim2 = sim.updated_copy(num_reps=2, path="eme_grid_spec/subgrids/1")
1441-
assert set(sim2._cell_index_pairs) == desired_cell_index_pairs
1436+
sim = sim.updated_copy(
1437+
monitors=[m for m in sim.monitors if not isinstance(m, td.EMEFieldMonitor)]
1438+
)
1439+
sim2 = sim.updated_copy(num_reps=2, path="eme_grid_spec/subgrids/1")
1440+
assert set(sim2._cell_index_pairs) == desired_cell_index_pairs
14421441
# sweep can't have coeff monitor
14431442
with pytest.raises(SetupError):
14441443
_ = sim.updated_copy(sweep_spec=sweep_spec)
1444+
with pytest.raises(SetupError):
1445+
_ = sim.updated_copy(sweep_spec=sweep_spec, store_coeffs=True, monitors=[])
14451446
# remove coeff monitor too, now it passes
14461447
with AssertLogLevel(None):
14471448
sim = sim.updated_copy(

tidy3d/components/eme/monitor.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,6 @@ class EMECoefficientMonitor(EMEMonitor):
286286
"Not all monitors support values different from 1.",
287287
)
288288

289-
num_sweep: Optional[pd.NonNegativeInt] = pd.Field(
290-
None,
291-
title="Number of Sweep Indices",
292-
description="Number of sweep indices for the monitor to record. "
293-
"Cannot exceed the number of sweep indices for the simulation. "
294-
"If the sweep does not change the monitor data, the sweep index "
295-
"will be omitted. A value of 'None' will record all sweep indices.",
296-
)
297-
298289
def storage_size(
299290
self,
300291
num_cells: int,

tidy3d/components/eme/simulation.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class EMESimulation(AbstractYeeGridSimulation):
235235
)
236236

237237
store_coeffs: bool = pd.Field(
238-
True,
238+
False,
239239
title="Store Coefficients",
240240
description="Whether to store the internal coefficients from the EME simulation. "
241241
"The results are stored in 'EMESimulationData.coeffs'.",
@@ -756,16 +756,14 @@ def _validate_sweep_spec(self) -> None:
756756
f"Monitor '{monitor.name}' at 'monitors[{i}]' is an 'EMECoefficientMonitor', "
757757
"which is not compatible with 'EMEPeriodicitySweep'."
758758
)
759+
if self.store_coeffs:
760+
raise SetupError(
761+
"'EMESimulation.store_coeffs' is not compatible with 'EMEPeriodicitySweep'."
762+
)
759763

760764
def _validate_monitor_setup(self) -> None:
761765
"""Check monitor setup."""
762766
for i, monitor in enumerate(self.monitors):
763-
if isinstance(monitor, EMECoefficientMonitor):
764-
log.warning(
765-
"'EMECoefficientMonitor' is deprecated. "
766-
"The full coefficient data is stored in "
767-
"'EMESimulationData.coeffs'."
768-
)
769767
if isinstance(monitor, EMEMonitor):
770768
_ = self._monitor_eme_cell_indices(monitor=monitor)
771769
if (

0 commit comments

Comments
 (0)