88
99import tidy3d as td
1010from tidy3d .plugins .mode import ModeSolver
11- from tidy3d .plugins .smatrix .ports .wave import DEFAULT_WAVE_PORT_MODE_SPEC
1211
12+ # from tidy3d.plugins.smatrix.ports.wave import DEFAULT_WAVE_PORT_MODE_SPEC
1313from ..test_data .test_data_arrays import MODE_SPEC , SIZE_2D
1414from ..utils import AssertLogLevel
1515
@@ -322,12 +322,10 @@ def get_mode_solver_data():
322322 """Create a simple ModeSolverData object for testing."""
323323 from tidy3d .components .data .data_array import GroupIndexDataArray , ModeDispersionDataArray
324324
325- from ..test_data .test_data_arrays import (
326- make_scalar_mode_field_data_array ,
327- )
325+ from ..test_data .test_data_arrays import SIM , make_scalar_mode_field_data_array
328326 from ..test_data .test_monitor_data import N_COMPLEX
329327
330- freqs = np . linspace ( 1e14 , 2e14 , 5 )
328+ freqs = N_COMPLEX . f . data
331329 num_modes = len (N_COMPLEX .mode_index )
332330 mode_indices = np .arange (num_modes )
333331 mode_spec = td .ModeSpec (num_modes = num_modes , sort_spec = td .ModeSortSpec (track_freq = "central" ))
@@ -337,6 +335,7 @@ def get_mode_solver_data():
337335 freqs = freqs ,
338336 mode_spec = mode_spec ,
339337 name = "test_monitor" ,
338+ colocate = False ,
340339 )
341340
342341 # Create n_group_raw and dispersion_raw with same shape as n_complex
@@ -353,18 +352,18 @@ def get_mode_solver_data():
353352 # Create mode data with the right frequencies
354353 mode_data = td .ModeSolverData (
355354 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 () ,
355+ Ex = make_scalar_mode_field_data_array ("Ex" , symmetry = False ),
356+ Ey = make_scalar_mode_field_data_array ("Ey" , symmetry = False ),
357+ Ez = make_scalar_mode_field_data_array ("Ez" , symmetry = False ),
358+ Hx = make_scalar_mode_field_data_array ("Hx" , symmetry = False ),
359+ Hy = make_scalar_mode_field_data_array ("Hy" , symmetry = False ),
360+ Hz = make_scalar_mode_field_data_array ("Hz" , symmetry = False ),
361+ n_complex = N_COMPLEX ,
363362 n_group_raw = n_group_raw ,
364363 dispersion_raw = dispersion_raw ,
365364 symmetry = (0 , 0 , 0 ),
366365 symmetry_center = (0 , 0 , 0 ),
367- grid_expanded = td . Grid ( boundaries = td . Coords ( x = [ 0 , 1 ], y = [ 0 , 1 ], z = [ 0 , 1 ]) ),
366+ grid_expanded = SIM . discretize_monitor ( monitor ),
368367 )
369368 return mode_data
370369
@@ -425,23 +424,24 @@ def test_mode_solver_data_interp_cheb():
425424 freqs = freqs_cheb ,
426425 mode_spec = mode_spec ,
427426 name = "test_cheb" ,
427+ colocate = False ,
428428 )
429429
430- from ..test_data .test_data_arrays import make_scalar_mode_field_data_array
430+ from ..test_data .test_data_arrays import SIM , make_scalar_mode_field_data_array
431431 from ..test_data .test_monitor_data import N_COMPLEX
432432
433433 mode_data = td .ModeSolverData (
434434 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" ),
435+ Ex = make_scalar_mode_field_data_array ("Ex" , symmetry = False ),
436+ Ey = make_scalar_mode_field_data_array ("Ey" , symmetry = False ),
437+ Ez = make_scalar_mode_field_data_array ("Ez" , symmetry = False ),
438+ Hx = make_scalar_mode_field_data_array ("Hx" , symmetry = False ),
439+ Hy = make_scalar_mode_field_data_array ("Hy" , symmetry = False ),
440+ Hz = make_scalar_mode_field_data_array ("Hz" , symmetry = False ),
441441 n_complex = N_COMPLEX .copy (),
442442 symmetry = (0 , 0 , 0 ),
443443 symmetry_center = (0 , 0 , 0 ),
444- grid_expanded = td . Grid ( boundaries = td . Coords ( x = [ 0 , 1 ], y = [ 0 , 1 ], z = [ 0 , 1 ]) ),
444+ grid_expanded = SIM . discretize_monitor ( monitor ),
445445 )
446446
447447 # Interpolate to 50 frequencies
@@ -895,32 +895,27 @@ def test_mode_monitor_interp_spec_none():
895895# ============================================================================
896896
897897
898- def make_wave_port ():
898+ def make_wave_port (num_interp_points = 3 , method = "linear" ):
899899 """Make a WavePort."""
900- from tidy3d .components .microwave .path_integrals .integrals .current import (
901- AxisAlignedCurrentIntegral ,
902- )
903900 from tidy3d .plugins .smatrix .ports .wave import WavePort
904901
905902 return WavePort (
906903 center = (0 , 0 , 0 ),
907904 size = (1 , 1 , 0 ),
908905 direction = "+" ,
909906 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 ,
907+ mode_spec = td .MicrowaveModeSpec (
908+ num_modes = 1 ,
909+ sort_spec = td .ModeSortSpec (track_freq = "central" ),
910+ interp_spec = td .ModeInterpSpec (num_points = num_interp_points , method = method ),
916911 ),
917912 )
918913
919914
920915def test_wave_port_to_monitors_propagates_default_interp_spec ():
921916 """Test that WavePort.to_monitors() propagates default interp_spec to ModeMonitor."""
922917
923- port = make_wave_port ()
918+ port = make_wave_port (num_interp_points = 3 , method = "linear" )
924919
925920 freqs = np .linspace (1e14 , 2e14 , 20 )
926921 monitors = port .to_monitors (freqs = freqs )
@@ -929,16 +924,13 @@ def test_wave_port_to_monitors_propagates_default_interp_spec():
929924 monitor = monitors [0 ]
930925 assert isinstance (monitor , td .ModeMonitor )
931926 assert monitor .mode_spec .interp_spec is not None
932- assert (
933- monitor .mode_spec .interp_spec .num_points
934- == DEFAULT_WAVE_PORT_MODE_SPEC .interp_spec .num_points
935- )
936- assert monitor .mode_spec .interp_spec .method == DEFAULT_WAVE_PORT_MODE_SPEC .interp_spec .method
927+ assert monitor .mode_spec .interp_spec .num_points == 3
928+ assert monitor .mode_spec .interp_spec .method == "linear"
937929
938930
939931def test_wave_port_to_monitors_propagates_custom_interp_spec ():
940932 """Test that WavePort.to_monitors() propagates custom interp_spec to ModeMonitor."""
941- custom_mode_spec = td .ModeSpec (
933+ custom_mode_spec = td .MicrowaveModeSpec (
942934 num_modes = 1 ,
943935 sort_spec = td .ModeSortSpec (track_freq = "central" ),
944936 interp_spec = td .ModeInterpSpec (num_points = 8 , method = "cheb" ),
@@ -958,7 +950,7 @@ def test_wave_port_to_monitors_propagates_custom_interp_spec():
958950
959951def test_wave_port_to_monitors_propagates_none_interp_spec ():
960952 """Test that WavePort.to_monitors() propagates interp_spec=None to ModeMonitor."""
961- mode_spec_no_interp = td .ModeSpec (
953+ mode_spec_no_interp = td .MicrowaveModeSpec (
962954 num_modes = 1 , sort_spec = td .ModeSortSpec (track_freq = "central" ), interp_spec = None
963955 )
964956 port = make_wave_port ().updated_copy (mode_spec = mode_spec_no_interp )
0 commit comments