@@ -311,16 +311,16 @@ def test_eme_simulation():
311311
312312 # test warning for not providing wavelength in autogrid
313313 grid_spec = td .GridSpec .auto (min_steps_per_wvl = 20 )
314+ sim = sim .updated_copy (grid_spec = grid_spec )
314315 with AssertLogLevel ("INFO" , contains_str = "wavelength" ):
315- sim = sim .updated_copy (grid_spec = grid_spec )
316+ _ = sim .updated_copy (monitors = [] )
316317 # multiple freqs are ok, but not for autogrid
317318 _ = sim .updated_copy (
318319 grid_spec = td .GridSpec .uniform (dl = 0.2 ), freqs = [10000000000.0 , * list (sim .freqs )]
319320 )
320321 with AssertLogLevel ("INFO" , contains_str = "wavelength" ):
321322 _ = sim .updated_copy (
322- freqs = [* list (sim .freqs ), 10000000000.0 ],
323- grid_spec = grid_spec ,
323+ freqs = [* list (sim .freqs ), 10000000000.0 ], grid_spec = grid_spec , monitors = []
324324 )
325325
326326 # test port offsets
@@ -558,12 +558,14 @@ def test_eme_simulation():
558558 constraint = "passive" ,
559559 eme_grid_spec = td .EMEUniformGrid (num_cells = 1 , mode_spec = td .EMEModeSpec (num_modes = 40 )),
560560 grid_spec = sim .grid_spec .updated_copy (wavelength = 1 ),
561+ monitors = [],
561562 )
562563 sim_good .validate_pre_upload ()
563564 sim_good = sim .updated_copy (
564565 constraint = None ,
565566 eme_grid_spec = td .EMEUniformGrid (num_cells = 1 , mode_spec = td .EMEModeSpec (num_modes = 60 )),
566567 grid_spec = sim .grid_spec .updated_copy (wavelength = 1 ),
568+ monitors = [],
567569 )
568570 sim_good .validate_pre_upload ()
569571 # warn about num modes with constraint
@@ -731,6 +733,47 @@ def _get_eme_smatrix_data_array(num_modes_in=2, num_modes_out=3, num_freqs=2, nu
731733 return smatrix_entry
732734
733735
736+ def _get_eme_interface_smatrix_data_array (
737+ num_modes_in = 2 , num_modes_out = 3 , num_freqs = 2 , num_sweep = 0
738+ ):
739+ if num_modes_in != 0 :
740+ mode_index_in = np .arange (num_modes_in )
741+ else :
742+ mode_index_in = [0 ]
743+ if num_modes_out != 0 :
744+ mode_index_out = np .arange (num_modes_out )
745+ else :
746+ mode_index_out = [0 ]
747+ if num_sweep != 0 :
748+ sweep_index = np .arange (num_sweep )
749+ else :
750+ sweep_index = [0 ]
751+ eme_cell_index = np .arange (3 )
752+
753+ f = td .C_0 * np .linspace (1 , 2 , num_freqs )
754+
755+ data = (1 + 1j ) * np .random .random (
756+ (len (f ), len (mode_index_out ), len (mode_index_in ), len (sweep_index ), len (eme_cell_index ))
757+ )
758+ coords = {
759+ "f" : f ,
760+ "mode_index_out" : mode_index_out ,
761+ "mode_index_in" : mode_index_in ,
762+ "sweep_index" : sweep_index ,
763+ "eme_cell_index" : eme_cell_index ,
764+ }
765+ smatrix_entry = td .EMEInterfaceSMatrixDataArray (data , coords = coords )
766+
767+ if num_modes_in == 0 :
768+ smatrix_entry = smatrix_entry .drop_vars ("mode_index_in" )
769+ if num_modes_out == 0 :
770+ smatrix_entry = smatrix_entry .drop_vars ("mode_index_out" )
771+ if num_sweep == 0 :
772+ smatrix_entry = smatrix_entry .drop_vars ("sweep_index" )
773+
774+ return smatrix_entry
775+
776+
734777def _get_eme_smatrix_dataset (num_modes_1 = 3 , num_modes_2 = 4 , num_sweep = 0 ):
735778 S11 = _get_eme_smatrix_data_array (
736779 num_modes_in = num_modes_1 , num_modes_out = num_modes_1 , num_sweep = num_sweep
@@ -747,6 +790,22 @@ def _get_eme_smatrix_dataset(num_modes_1=3, num_modes_2=4, num_sweep=0):
747790 return td .EMESMatrixDataset (S11 = S11 , S12 = S12 , S21 = S21 , S22 = S22 )
748791
749792
793+ def _get_eme_interface_smatrix_dataset (num_modes_1 = 3 , num_modes_2 = 4 , num_sweep = 0 ):
794+ S11 = _get_eme_interface_smatrix_data_array (
795+ num_modes_in = num_modes_1 , num_modes_out = num_modes_1 , num_sweep = num_sweep
796+ )
797+ S12 = _get_eme_interface_smatrix_data_array (
798+ num_modes_in = num_modes_2 , num_modes_out = num_modes_1 , num_sweep = num_sweep
799+ )
800+ S21 = _get_eme_interface_smatrix_data_array (
801+ num_modes_in = num_modes_1 , num_modes_out = num_modes_2 , num_sweep = num_sweep
802+ )
803+ S22 = _get_eme_interface_smatrix_data_array (
804+ num_modes_in = num_modes_2 , num_modes_out = num_modes_2 , num_sweep = num_sweep
805+ )
806+ return td .EMEInterfaceSMatrixDataset (S11 = S11 , S12 = S12 , S21 = S21 , S22 = S22 )
807+
808+
750809def _get_eme_coeff_data_array (num_sweep = 0 ):
751810 f = [2e14 ]
752811 mode_index_out = [0 , 1 ]
@@ -787,7 +846,20 @@ def _get_eme_coeff_data_array(num_sweep=0):
787846def _get_eme_coeff_dataset (num_sweep = 0 ):
788847 A = _get_eme_coeff_data_array (num_sweep = num_sweep )
789848 B = _get_eme_coeff_data_array (num_sweep = num_sweep )
790- return td .EMECoefficientDataset (A = A , B = B )
849+ flux = _get_eme_flux_data_array (num_sweep = num_sweep )
850+ n_complex = _get_eme_mode_index_data_array (num_sweep = num_sweep )
851+ interface_smatrices = _get_eme_interface_smatrix_dataset (num_sweep = num_sweep )
852+ return td .EMECoefficientDataset (
853+ A = A , B = B , flux = flux , n_complex = n_complex , interface_smatrices = interface_smatrices
854+ )
855+
856+
857+ def test_eme_normalize_coeff_dataset ():
858+ coeffs = _get_eme_coeff_dataset ()
859+ coeffs_normalized = coeffs .normalized_copy
860+ assert coeffs_normalized .flux is None
861+ with pytest .raises (ValidationError ):
862+ _ = coeffs_normalized .normalized_copy
791863
792864
793865def test_eme_coeff_data_array ():
@@ -819,6 +891,29 @@ def _get_eme_mode_index_data_array(num_sweep=0):
819891 return data
820892
821893
894+ def _get_eme_flux_data_array (num_sweep = 0 ):
895+ f = [td .C_0 , 3e14 ]
896+ mode_index = np .arange (10 )
897+ eme_cell_index = np .arange (7 )
898+ if num_sweep != 0 :
899+ sweep_index = np .arange (num_sweep )
900+ else :
901+ sweep_index = [0 ]
902+ coords = {
903+ "f" : f ,
904+ "sweep_index" : sweep_index ,
905+ "eme_cell_index" : eme_cell_index ,
906+ "mode_index" : mode_index ,
907+ }
908+ data = td .EMEModeIndexDataArray (
909+ np .random .random ((len (f ), len (sweep_index ), len (eme_cell_index ), len (mode_index ))),
910+ coords = coords ,
911+ )
912+ if num_sweep == 0 :
913+ data = data .drop_vars ("sweep_index" )
914+ return data
915+
916+
822917def test_eme_mode_index_data_array ():
823918 _ = _get_eme_mode_index_data_array ()
824919
@@ -1305,7 +1400,7 @@ def test_eme_periodicity():
13051400
13061401 # remove the field monitor, now it passes
13071402 desired_cell_index_pairs = set ([(i , i + 1 ) for i in range (6 )] + [(5 , 1 )])
1308- with AssertLogLevel (None ):
1403+ with AssertLogLevel ("WARNING" , contains_str = "deprecated" ):
13091404 sim = sim .updated_copy (
13101405 monitors = [m for m in sim .monitors if not isinstance (m , td .EMEFieldMonitor )]
13111406 )
0 commit comments