2929from tidy3d .plugins .smatrix .ports .base_lumped import AbstractLumpedPort
3030from tidy3d .plugins .smatrix .utils import s_to_z , validate_square_matrix
3131
32- from ...utils import run_emulated
32+ from ...utils import AssertLogLevel , run_emulated
3333from .terminal_component_modeler_def import (
3434 make_basic_filter_terminals ,
3535 make_coaxial_component_modeler ,
@@ -521,14 +521,16 @@ def test_ab_to_s_component_modeler():
521521 assert np .isclose (S_matrix , b_matrix ).all ()
522522
523523
524- def test_port_snapping (tmp_path ):
524+ def test_port_snapping ():
525525 """Make sure that the snapping behavior of the load resistor is mirrored
526526 by all other components in the modeler simulations with rectangular ports.
527527 """
528528 y_z_grid = td .UniformGrid (dl = 0.1 * 1e3 )
529529 x_grid = td .UniformGrid (dl = 11 * 1e3 )
530530 grid_spec = td .GridSpec (grid_x = x_grid , grid_y = y_z_grid , grid_z = y_z_grid )
531- modeler = make_component_modeler (planar_pec = True , port_refinement = False , grid_spec = grid_spec )
531+ modeler = make_component_modeler (
532+ planar_pec = True , port_refinement = False , port_snapping = False , grid_spec = grid_spec
533+ )
532534 check_lumped_port_components_snapped_correctly (modeler = modeler )
533535
534536
@@ -548,7 +550,7 @@ def test_coaxial_port_source_size(axis):
548550 assert np .isclose (source .size [axis ], 0 )
549551
550552
551- def test_coarse_grid_at_port (monkeypatch , tmp_path ):
553+ def test_coarse_grid_at_port (monkeypatch ):
552554 modeler = make_component_modeler (planar_pec = True , port_refinement = False , port_snapping = False )
553555 # Without port refinement the grid is much too coarse for these port sizes
554556 with pytest .raises (SetupError ):
@@ -819,8 +821,8 @@ def compute_current_patch(self, sim_data):
819821
820822def test_make_coaxial_component_modeler_with_wave_ports (tmp_path ):
821823 """Checks that the terminal component modeler is created successfully with wave ports."""
822- z_grid = td .UniformGrid (dl = 1 * 1e3 )
823- xy_grid = td .UniformGrid (dl = 0.1 * 1e3 )
824+ z_grid = td .QuasiUniformGrid (dl = 1 * 1e3 )
825+ xy_grid = td .QuasiUniformGrid (dl = 0.1 * 1e3 )
824826 grid_spec = td .GridSpec (grid_x = xy_grid , grid_y = xy_grid , grid_z = z_grid )
825827 _ = make_coaxial_component_modeler (
826828 port_types = (WavePort , WavePort ),
@@ -834,8 +836,8 @@ def test_run_coaxial_component_modeler_with_wave_ports(
834836 monkeypatch , tmp_path , voltage_enabled , current_enabled
835837):
836838 """Checks that the terminal component modeler runs with wave ports."""
837- z_grid = td .UniformGrid (dl = 1 * 1e3 )
838- xy_grid = td .UniformGrid (dl = 0.1 * 1e3 )
839+ z_grid = td .QuasiUniformGrid (dl = 1 * 1e3 )
840+ xy_grid = td .QuasiUniformGrid (dl = 0.1 * 1e3 )
839841 grid_spec = td .GridSpec (grid_x = xy_grid , grid_y = xy_grid , grid_z = z_grid )
840842 if not (voltage_enabled or current_enabled ):
841843 with pytest .raises (pd .ValidationError ):
@@ -891,8 +893,8 @@ def test_run_coaxial_component_modeler_with_wave_ports(
891893
892894def test_run_mixed_component_modeler_with_wave_ports (monkeypatch , tmp_path ):
893895 """Checks the terminal component modeler will allow mixed ports."""
894- z_grid = td .UniformGrid (dl = 1 * 1e3 )
895- xy_grid = td .UniformGrid (dl = 0.1 * 1e3 )
896+ z_grid = td .QuasiUniformGrid (dl = 1 * 1e3 )
897+ xy_grid = td .QuasiUniformGrid (dl = 0.1 * 1e3 )
896898 grid_spec = td .GridSpec (grid_x = xy_grid , grid_y = xy_grid , grid_z = z_grid )
897899 modeler = make_coaxial_component_modeler (
898900 port_types = (CoaxialLumpedPort , WavePort ), grid_spec = grid_spec
@@ -1359,8 +1361,8 @@ def test_get_combined_antenna_parameters_data(monkeypatch, tmp_path):
13591361
13601362def test_run_only_and_element_mappings (monkeypatch , tmp_path ):
13611363 """Checks the terminal component modeler works when running with a subset of excitations."""
1362- z_grid = td .UniformGrid (dl = 1 * 1e3 )
1363- xy_grid = td .UniformGrid (dl = 0.1 * 1e3 )
1364+ z_grid = td .QuasiUniformGrid (dl = 1 * 1e3 )
1365+ xy_grid = td .QuasiUniformGrid (dl = 0.1 * 1e3 )
13641366 grid_spec = td .GridSpec (grid_x = xy_grid , grid_y = xy_grid , grid_z = z_grid )
13651367 modeler = make_coaxial_component_modeler (
13661368 port_types = (CoaxialLumpedPort , CoaxialLumpedPort ), grid_spec = grid_spec
@@ -1674,8 +1676,8 @@ def test_low_freq_smoothing_spec_sim_dict():
16741676def test_S_parameter_deembedding (monkeypatch , tmp_path ):
16751677 """Test S-parameter de-embedding."""
16761678
1677- z_grid = td .UniformGrid (dl = 1 * 1e3 )
1678- xy_grid = td .UniformGrid (dl = 0.1 * 1e3 )
1679+ z_grid = td .QuasiUniformGrid (dl = 1 * 1e3 )
1680+ xy_grid = td .QuasiUniformGrid (dl = 0.1 * 1e3 )
16791681 grid_spec = td .GridSpec (grid_x = xy_grid , grid_y = xy_grid , grid_z = z_grid )
16801682 modeler = make_coaxial_component_modeler (port_types = (WavePort , WavePort ), grid_spec = grid_spec )
16811683
@@ -1974,8 +1976,8 @@ def test_validate_run_only_membership():
19741976
19751977def test_validate_run_only_with_wave_ports ():
19761978 """Test run_only validation with WavePorts in TerminalComponentModeler."""
1977- z_grid = td .UniformGrid (dl = 1 * 1e3 )
1978- xy_grid = td .UniformGrid (dl = 0.1 * 1e3 )
1979+ z_grid = td .QuasiUniformGrid (dl = 1 * 1e3 )
1980+ xy_grid = td .QuasiUniformGrid (dl = 0.1 * 1e3 )
19791981 grid_spec = td .GridSpec (grid_x = xy_grid , grid_y = xy_grid , grid_z = z_grid )
19801982 modeler = make_coaxial_component_modeler (port_types = (WavePort , WavePort ), grid_spec = grid_spec )
19811983
@@ -2197,8 +2199,8 @@ def test_wave_port_mode_index_validation():
21972199
21982200def test_wave_port_mode_index_with_modeler ():
21992201 """Test that WavePort.mode_index works correctly with TerminalComponentModeler."""
2200- z_grid = td .UniformGrid (dl = 1 * 1e3 )
2201- xy_grid = td .UniformGrid (dl = 0.1 * 1e3 )
2202+ z_grid = td .QuasiUniformGrid (dl = 1 * 1e3 )
2203+ xy_grid = td .QuasiUniformGrid (dl = 0.1 * 1e3 )
22022204 grid_spec = td .GridSpec (grid_x = xy_grid , grid_y = xy_grid , grid_z = z_grid )
22032205
22042206 # Create mode_spec with 4 modes - use defaults
@@ -2306,3 +2308,12 @@ def test_get_task_name():
23062308 # Test with wave port (no mode_index) - should work
23072309 task_name = TerminalComponentModeler .get_task_name (port = wave_port )
23082310 assert task_name == "wave@1"
2311+
2312+
2313+ def test_validate_port_refinement_with_uniform_grid ():
2314+ """Test that port refinement options raise error with uniform grid."""
2315+ uniform_grid = td .GridSpec .uniform (dl = 0.5 * mm )
2316+ with AssertLogLevel ("WARNING" , contains_str = "mesh refinement options enabled" ):
2317+ make_coaxial_component_modeler (
2318+ port_types = (CoaxialLumpedPort , WavePort ), grid_spec = uniform_grid
2319+ )
0 commit comments