Skip to content

Commit 7c093b1

Browse files
committed
Fixed bug when validating the grid resolution near
1 parent 840b07f commit 7c093b1

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Fixed handling of symmetry when creating adjoint field sources and added warning when broken up adjoint simulations do not have the same symmetry as the forward simulation.
3535
- Validation for `CustomGridBoundaries`, which was previously allowing unsorted arrays and arrays with less than two entries.
3636
- `DiffractionMonitor` results to apply finite grid field corrections for higher precision when comparing e.g. to `FluxMonitor` computations of total power.
37+
- Bug when validating the grid resolution near `CoaxialLumpedPort`.
3738

3839
### Changed
3940
- Relaxed bounds checking of path integrals during `WavePort` validation.

tests/test_plugins/smatrix/test_terminal_component_modeler.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
from ...utils import run_emulated
2525
from .terminal_component_modeler_def import make_coaxial_component_modeler, make_component_modeler
2626

27+
mm = 1e3
28+
2729

2830
def run_component_modeler(monkeypatch, modeler: TerminalComponentModeler):
2931
sim_dict = modeler.sim_dict
@@ -285,8 +287,27 @@ def test_run_coaxial_component_modeler(monkeypatch, tmp_path):
285287
)
286288

287289

288-
def test_coarse_grid_at_coaxial_port(monkeypatch, tmp_path):
289-
modeler = make_coaxial_component_modeler(path_dir=str(tmp_path), port_refinement=False)
290+
@pytest.mark.parametrize(
291+
"grid_spec",
292+
[
293+
None,
294+
td.GridSpec(
295+
grid_x=td.UniformGrid(dl=0.1 * mm),
296+
grid_y=td.UniformGrid(dl=10 * mm),
297+
grid_z=td.UniformGrid(dl=0.1 * mm),
298+
),
299+
td.GridSpec(
300+
grid_x=td.UniformGrid(dl=10 * mm),
301+
grid_y=td.UniformGrid(dl=0.1 * mm),
302+
grid_z=td.UniformGrid(dl=0.1 * mm),
303+
),
304+
],
305+
)
306+
def test_coarse_grid_at_coaxial_port(monkeypatch, tmp_path, grid_spec):
307+
"""Ensure that the grid is fine enough at the coaxial ports along the transverse dimensions."""
308+
modeler = make_coaxial_component_modeler(
309+
path_dir=str(tmp_path), port_refinement=False, grid_spec=grid_spec
310+
)
290311
# Without port refinement the grid is much too coarse for these port sizes
291312
with pytest.raises(SetupError):
292313
_ = run_component_modeler(monkeypatch, modeler)

tidy3d/plugins/smatrix/ports/coaxial_lumped.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def _check_grid_size(self, yee_grid: YeeGrid):
384384
"""Raises :class:``SetupError`` if the grid is too coarse at port locations"""
385385
trans_axes = self.remaining_axes
386386
for axis in trans_axes:
387-
e_component = "xyz"[trans_axes[0]]
387+
e_component = "xyz"[axis]
388388
e_grid = yee_grid.grid_dict[f"E{e_component}"]
389389
coords = e_grid.to_dict[e_component]
390390
min_bound = self.center[axis] - self.outer_diameter / 2

0 commit comments

Comments
 (0)