88
99import tidy3d as td
1010from tidy3d .plugins .mode import ModeSolver
11- from tidy3d .plugins .smatrix .ports .wave import DEFAULT_WAVE_PORT_MODE_SPEC
11+ # from tidy3d.plugins.smatrix.ports.wave import DEFAULT_WAVE_PORT_MODE_SPEC
1212
1313from ..test_data .test_data_arrays import MODE_SPEC , SIZE_2D
1414from ..utils import AssertLogLevel
@@ -323,11 +323,11 @@ def get_mode_solver_data():
323323 from tidy3d .components .data .data_array import GroupIndexDataArray , ModeDispersionDataArray
324324
325325 from ..test_data .test_data_arrays import (
326- make_scalar_mode_field_data_array ,
326+ make_scalar_mode_field_data_array , SIM
327327 )
328328 from ..test_data .test_monitor_data import N_COMPLEX
329329
330- freqs = np . linspace ( 1e14 , 2e14 , 5 )
330+ freqs = N_COMPLEX . f . data
331331 num_modes = len (N_COMPLEX .mode_index )
332332 mode_indices = np .arange (num_modes )
333333 mode_spec = td .ModeSpec (num_modes = num_modes , sort_spec = td .ModeSortSpec (track_freq = "central" ))
@@ -337,6 +337,7 @@ def get_mode_solver_data():
337337 freqs = freqs ,
338338 mode_spec = mode_spec ,
339339 name = "test_monitor" ,
340+ colocate = False ,
340341 )
341342
342343 # Create n_group_raw and dispersion_raw with same shape as n_complex
@@ -353,18 +354,18 @@ def get_mode_solver_data():
353354 # Create mode data with the right frequencies
354355 mode_data = td .ModeSolverData (
355356 monitor = monitor ,
356- Ex = make_scalar_mode_field_data_array ("Ex" ),
357- Ey = make_scalar_mode_field_data_array ("Ey" ),
358- Ez = make_scalar_mode_field_data_array ("Ez" ),
359- Hx = make_scalar_mode_field_data_array ("Hx" ),
360- Hy = make_scalar_mode_field_data_array ("Hy" ),
361- Hz = make_scalar_mode_field_data_array ("Hz" ),
362- n_complex = N_COMPLEX . copy () ,
357+ Ex = make_scalar_mode_field_data_array ("Ex" , symmetry = False ),
358+ Ey = make_scalar_mode_field_data_array ("Ey" , symmetry = False ),
359+ Ez = make_scalar_mode_field_data_array ("Ez" , symmetry = False ),
360+ Hx = make_scalar_mode_field_data_array ("Hx" , symmetry = False ),
361+ Hy = make_scalar_mode_field_data_array ("Hy" , symmetry = False ),
362+ Hz = make_scalar_mode_field_data_array ("Hz" , symmetry = False ),
363+ n_complex = N_COMPLEX ,
363364 n_group_raw = n_group_raw ,
364365 dispersion_raw = dispersion_raw ,
365366 symmetry = (0 , 0 , 0 ),
366367 symmetry_center = (0 , 0 , 0 ),
367- grid_expanded = td . Grid ( boundaries = td . Coords ( x = [ 0 , 1 ], y = [ 0 , 1 ], z = [ 0 , 1 ]) ),
368+ grid_expanded = SIM . discretize_monitor ( monitor ),
368369 )
369370 return mode_data
370371
@@ -425,23 +426,24 @@ def test_mode_solver_data_interp_cheb():
425426 freqs = freqs_cheb ,
426427 mode_spec = mode_spec ,
427428 name = "test_cheb" ,
429+ colocate = False ,
428430 )
429431
430- from ..test_data .test_data_arrays import make_scalar_mode_field_data_array
432+ from ..test_data .test_data_arrays import make_scalar_mode_field_data_array , SIM
431433 from ..test_data .test_monitor_data import N_COMPLEX
432434
433435 mode_data = td .ModeSolverData (
434436 monitor = monitor ,
435- Ex = make_scalar_mode_field_data_array ("Ex" ),
436- Ey = make_scalar_mode_field_data_array ("Ey" ),
437- Ez = make_scalar_mode_field_data_array ("Ez" ),
438- Hx = make_scalar_mode_field_data_array ("Hx" ),
439- Hy = make_scalar_mode_field_data_array ("Hy" ),
440- Hz = make_scalar_mode_field_data_array ("Hz" ),
437+ Ex = make_scalar_mode_field_data_array ("Ex" , symmetry = False ),
438+ Ey = make_scalar_mode_field_data_array ("Ey" , symmetry = False ),
439+ Ez = make_scalar_mode_field_data_array ("Ez" , symmetry = False ),
440+ Hx = make_scalar_mode_field_data_array ("Hx" , symmetry = False ),
441+ Hy = make_scalar_mode_field_data_array ("Hy" , symmetry = False ),
442+ Hz = make_scalar_mode_field_data_array ("Hz" , symmetry = False ),
441443 n_complex = N_COMPLEX .copy (),
442444 symmetry = (0 , 0 , 0 ),
443445 symmetry_center = (0 , 0 , 0 ),
444- grid_expanded = td . Grid ( boundaries = td . Coords ( x = [ 0 , 1 ], y = [ 0 , 1 ], z = [ 0 , 1 ]) ),
446+ grid_expanded = SIM . discretize_monitor ( monitor ),
445447 )
446448
447449 # Interpolate to 50 frequencies
@@ -895,7 +897,7 @@ def test_mode_monitor_interp_spec_none():
895897# ============================================================================
896898
897899
898- def make_wave_port ():
900+ def make_wave_port (num_interp_points = 3 , method = "linear" ):
899901 """Make a WavePort."""
900902 from tidy3d .components .microwave .path_integrals .integrals .current import (
901903 AxisAlignedCurrentIntegral ,
@@ -907,20 +909,18 @@ def make_wave_port():
907909 size = (1 , 1 , 0 ),
908910 direction = "+" ,
909911 name = "port1" ,
910- current_integral = AxisAlignedCurrentIntegral (
911- center = (0 , 0 , 0 ),
912- size = (1 , 1 , 0 ),
913- sign = "+" ,
914- extrapolate_to_endpoints = True ,
915- snap_contour_to_grid = True ,
912+ mode_spec = td .MicrowaveModeSpec (
913+ num_modes = 1 ,
914+ sort_spec = td .ModeSortSpec (track_freq = "central" ),
915+ interp_spec = td .ModeInterpSpec (num_points = num_interp_points , method = method ),
916916 ),
917917 )
918918
919919
920920def test_wave_port_to_monitors_propagates_default_interp_spec ():
921921 """Test that WavePort.to_monitors() propagates default interp_spec to ModeMonitor."""
922922
923- port = make_wave_port ()
923+ port = make_wave_port (num_interp_points = 3 , method = "linear" )
924924
925925 freqs = np .linspace (1e14 , 2e14 , 20 )
926926 monitors = port .to_monitors (freqs = freqs )
@@ -931,14 +931,14 @@ def test_wave_port_to_monitors_propagates_default_interp_spec():
931931 assert monitor .mode_spec .interp_spec is not None
932932 assert (
933933 monitor .mode_spec .interp_spec .num_points
934- == DEFAULT_WAVE_PORT_MODE_SPEC . interp_spec . num_points
934+ == 3
935935 )
936- assert monitor .mode_spec .interp_spec .method == DEFAULT_WAVE_PORT_MODE_SPEC . interp_spec . method
936+ assert monitor .mode_spec .interp_spec .method == "linear"
937937
938938
939939def test_wave_port_to_monitors_propagates_custom_interp_spec ():
940940 """Test that WavePort.to_monitors() propagates custom interp_spec to ModeMonitor."""
941- custom_mode_spec = td .ModeSpec (
941+ custom_mode_spec = td .MicrowaveModeSpec (
942942 num_modes = 1 ,
943943 sort_spec = td .ModeSortSpec (track_freq = "central" ),
944944 interp_spec = td .ModeInterpSpec (num_points = 8 , method = "cheb" ),
@@ -958,7 +958,7 @@ def test_wave_port_to_monitors_propagates_custom_interp_spec():
958958
959959def test_wave_port_to_monitors_propagates_none_interp_spec ():
960960 """Test that WavePort.to_monitors() propagates interp_spec=None to ModeMonitor."""
961- mode_spec_no_interp = td .ModeSpec (
961+ mode_spec_no_interp = td .MicrowaveModeSpec (
962962 num_modes = 1 , sort_spec = td .ModeSortSpec (track_freq = "central" ), interp_spec = None
963963 )
964964 port = make_wave_port ().updated_copy (mode_spec = mode_spec_no_interp )
0 commit comments