Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed frequency sampling of `TransmissionLineDataset` within `MicrowaveModeData` when using group index calculation.
- Fixed DRC parsing for quoted categories in klayout plugin.
- Removed mode solver warnings about evaluating permittivity of a `Medium2D`.
- Maximum number of grid points in an EME simulation is now based solely on transverse grid points. Maximum number of EME cells is unchanged.

### Removed
- Removed deprecated `use_complex_fields` parameter from `TwoPhotonAbsorption` and `KerrNonlinearity`. Parameters `beta` and `n2` are now real-valued only, as is `n0` if specified.
Expand Down
10 changes: 2 additions & 8 deletions tests/test_components/test_eme.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,16 +412,10 @@ def test_eme_simulation():
_ = sim.updated_copy(monitors=[monitor])

# test max sim size and freqs
sim_bad = sim.updated_copy(size=(1000, 1000, 1000))
sim_bad = sim.updated_copy(size=(150, 150, 3))
with pytest.raises(SetupError):
sim_bad.validate_pre_upload()
sim_bad = sim.updated_copy(size=(1000, 500, 3), monitors=[], store_port_modes=True)
with pytest.raises(SetupError):
sim_bad.validate_pre_upload()
sim_bad = sim.updated_copy(size=(1000, 500, 3), monitors=[], store_port_modes=False)
with pytest.raises(SetupError):
sim_bad.validate_pre_upload()
sim_bad = sim.updated_copy(size=(500, 500, 3), monitors=[])
sim_bad = sim.updated_copy(size=(50, 50, 3), monitors=[])
with AssertLogLevel("WARNING", "slow-down"):
sim_bad.validate_pre_upload()

Expand Down
16 changes: 7 additions & 9 deletions tidy3d/components/eme/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
from .sweep import EMEFreqSweep, EMELengthSweep, EMEModeSweep, EMEPeriodicitySweep, EMESweepSpecType

# maximum numbers of simulation parameters
MAX_GRID_CELLS = 20e9
WARN_MONITOR_DATA_SIZE_GB = 10
MAX_MONITOR_INTERNAL_DATA_SIZE_GB = 50
MAX_SIMULATION_DATA_SIZE_GB = 50
WARN_MODE_NUM_CELLS = 1e5
MAX_MODE_NUM_CELLS = 5e6


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

def _validate_size(self) -> None:
"""Ensures the simulation is within size limits before simulation is uploaded."""

num_comp_cells = self.num_cells / 2 ** (np.sum(np.abs(self.symmetry)))
if num_comp_cells > MAX_GRID_CELLS:
raise SetupError(
f"Simulation has {num_comp_cells:.2e} computational cells, "
f"a maximum of {MAX_GRID_CELLS:.2e} are allowed."
)

num_freqs = len(self.freqs)
if num_freqs > MAX_NUM_FREQS:
raise SetupError(
Expand Down Expand Up @@ -876,6 +868,12 @@ def _validate_modes_size(self) -> None:
def warn_mode_size(monitor: AbstractModeMonitor, msg_header: str, custom_loc: list) -> None:
"""Warn if a mode component has a large number of points."""
num_cells = np.prod(self.discretize_monitor(monitor).num_cells)
if num_cells > MAX_MODE_NUM_CELLS:
raise SetupError(
msg_header + f"has {num_cells:.2e} computational cells "
"in the transverse directions, "
f"a maximum of {MAX_MODE_NUM_CELLS:.2e} are allowed."
)
if num_cells > WARN_MODE_NUM_CELLS:
consolidated_logger.warning(
msg_header + f"has a large number ({num_cells:1.2e}) of grid points. "
Expand Down