Skip to content

Commit 4f18e7a

Browse files
committed
fix: Change EME validation to only depend on transverse grids
1 parent 9a77294 commit 4f18e7a

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7171
- Fixed frequency sampling of `TransmissionLineDataset` within `MicrowaveModeData` when using group index calculation.
7272
- Fixed DRC parsing for quoted categories in klayout plugin.
7373
- Removed mode solver warnings about evaluating permittivity of a `Medium2D`.
74+
- Maximum number of grid points in an EME simulation is now based solely on transverse grid points. Maximum number of EME cells is unchanged.
7475

7576
### Removed
7677
- Removed deprecated `use_complex_fields` parameter from `TwoPhotonAbsorption` and `KerrNonlinearity`. Parameters `beta` and `n2` are now real-valued only, as is `n0` if specified.

tests/test_components/test_eme.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -412,16 +412,10 @@ def test_eme_simulation():
412412
_ = sim.updated_copy(monitors=[monitor])
413413

414414
# test max sim size and freqs
415-
sim_bad = sim.updated_copy(size=(1000, 1000, 1000))
415+
sim_bad = sim.updated_copy(size=(150, 150, 3))
416416
with pytest.raises(SetupError):
417417
sim_bad.validate_pre_upload()
418-
sim_bad = sim.updated_copy(size=(1000, 500, 3), monitors=[], store_port_modes=True)
419-
with pytest.raises(SetupError):
420-
sim_bad.validate_pre_upload()
421-
sim_bad = sim.updated_copy(size=(1000, 500, 3), monitors=[], store_port_modes=False)
422-
with pytest.raises(SetupError):
423-
sim_bad.validate_pre_upload()
424-
sim_bad = sim.updated_copy(size=(500, 500, 3), monitors=[])
418+
sim_bad = sim.updated_copy(size=(50, 50, 3), monitors=[])
425419
with AssertLogLevel("WARNING", "slow-down"):
426420
sim_bad.validate_pre_upload()
427421

tidy3d/components/eme/simulation.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
from .sweep import EMEFreqSweep, EMELengthSweep, EMEModeSweep, EMEPeriodicitySweep, EMESweepSpecType
4444

4545
# maximum numbers of simulation parameters
46-
MAX_GRID_CELLS = 20e9
4746
WARN_MONITOR_DATA_SIZE_GB = 10
4847
MAX_MONITOR_INTERNAL_DATA_SIZE_GB = 50
4948
MAX_SIMULATION_DATA_SIZE_GB = 50
5049
WARN_MODE_NUM_CELLS = 1e5
50+
MAX_MODE_NUM_CELLS = 5e6
5151

5252

5353
# eme specific simulation parameters
@@ -807,14 +807,6 @@ def _validate_monitor_setup(self) -> None:
807807

808808
def _validate_size(self) -> None:
809809
"""Ensures the simulation is within size limits before simulation is uploaded."""
810-
811-
num_comp_cells = self.num_cells / 2 ** (np.sum(np.abs(self.symmetry)))
812-
if num_comp_cells > MAX_GRID_CELLS:
813-
raise SetupError(
814-
f"Simulation has {num_comp_cells:.2e} computational cells, "
815-
f"a maximum of {MAX_GRID_CELLS:.2e} are allowed."
816-
)
817-
818810
num_freqs = len(self.freqs)
819811
if num_freqs > MAX_NUM_FREQS:
820812
raise SetupError(
@@ -876,6 +868,12 @@ def _validate_modes_size(self) -> None:
876868
def warn_mode_size(monitor: AbstractModeMonitor, msg_header: str, custom_loc: list) -> None:
877869
"""Warn if a mode component has a large number of points."""
878870
num_cells = np.prod(self.discretize_monitor(monitor).num_cells)
871+
if num_cells > MAX_MODE_NUM_CELLS:
872+
raise SetupError(
873+
msg_header + f"has {num_cells:.2e} computational cells "
874+
"in the transverse directions, "
875+
f"a maximum of {MAX_MODE_NUM_CELLS:.2e} are allowed."
876+
)
879877
if num_cells > WARN_MODE_NUM_CELLS:
880878
consolidated_logger.warning(
881879
msg_header + f"has a large number ({num_cells:1.2e}) of grid points. "

0 commit comments

Comments
 (0)