@@ -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 (sweep_index ), len (eme_cell_index ), len (mode_index_out ), len (mode_index_in ))
757+ )
758+ coords = {
759+ "f" : f ,
760+ "sweep_index" : sweep_index ,
761+ "eme_cell_index" : eme_cell_index ,
762+ "mode_index_out" : mode_index_out ,
763+ "mode_index_in" : mode_index_in ,
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,35 @@ 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+
809+ def _get_eme_overlaps_dataset (num_modes_1 = 3 , num_modes_2 = 4 , num_sweep = 0 ):
810+ O11 = _get_eme_interface_smatrix_data_array (
811+ num_modes_in = num_modes_1 , num_modes_out = num_modes_1 , num_sweep = num_sweep
812+ )
813+ O12 = _get_eme_interface_smatrix_data_array (
814+ num_modes_in = num_modes_2 , num_modes_out = num_modes_1 , num_sweep = num_sweep
815+ )
816+ O21 = _get_eme_interface_smatrix_data_array (
817+ num_modes_in = num_modes_1 , num_modes_out = num_modes_2 , num_sweep = num_sweep
818+ )
819+ return td .EMEOverlapDataset (O11 = O11 , O12 = O12 , O21 = O21 )
820+
821+
750822def _get_eme_coeff_data_array (num_sweep = 0 ):
751823 f = [2e14 ]
752824 mode_index_out = [0 , 1 ]
@@ -787,7 +859,26 @@ def _get_eme_coeff_data_array(num_sweep=0):
787859def _get_eme_coeff_dataset (num_sweep = 0 ):
788860 A = _get_eme_coeff_data_array (num_sweep = num_sweep )
789861 B = _get_eme_coeff_data_array (num_sweep = num_sweep )
790- return td .EMECoefficientDataset (A = A , B = B )
862+ flux = _get_eme_flux_data_array (num_sweep = num_sweep )
863+ n_complex = _get_eme_mode_index_data_array (num_sweep = num_sweep )
864+ interface_smatrices = _get_eme_interface_smatrix_dataset (num_sweep = num_sweep )
865+ overlaps = _get_eme_overlaps_dataset (num_sweep = num_sweep )
866+ return td .EMECoefficientDataset (
867+ A = A ,
868+ B = B ,
869+ flux = flux ,
870+ n_complex = n_complex ,
871+ interface_smatrices = interface_smatrices ,
872+ overlaps = overlaps ,
873+ )
874+
875+
876+ def test_eme_normalize_coeff_dataset ():
877+ coeffs = _get_eme_coeff_dataset ()
878+ coeffs_normalized = coeffs .normalized_copy
879+ assert coeffs_normalized .flux is None
880+ with pytest .raises (ValidationError ):
881+ _ = coeffs_normalized .normalized_copy
791882
792883
793884def test_eme_coeff_data_array ():
@@ -819,6 +910,29 @@ def _get_eme_mode_index_data_array(num_sweep=0):
819910 return data
820911
821912
913+ def _get_eme_flux_data_array (num_sweep = 0 ):
914+ f = [td .C_0 , 3e14 ]
915+ mode_index = np .arange (10 )
916+ eme_cell_index = np .arange (7 )
917+ if num_sweep != 0 :
918+ sweep_index = np .arange (num_sweep )
919+ else :
920+ sweep_index = [0 ]
921+ coords = {
922+ "f" : f ,
923+ "sweep_index" : sweep_index ,
924+ "eme_cell_index" : eme_cell_index ,
925+ "mode_index" : mode_index ,
926+ }
927+ data = td .EMEFluxDataArray (
928+ np .random .random ((len (f ), len (sweep_index ), len (eme_cell_index ), len (mode_index ))),
929+ coords = coords ,
930+ )
931+ if num_sweep == 0 :
932+ data = data .drop_vars ("sweep_index" )
933+ return data
934+
935+
822936def test_eme_mode_index_data_array ():
823937 _ = _get_eme_mode_index_data_array ()
824938
@@ -1305,7 +1419,7 @@ def test_eme_periodicity():
13051419
13061420 # remove the field monitor, now it passes
13071421 desired_cell_index_pairs = set ([(i , i + 1 ) for i in range (6 )] + [(5 , 1 )])
1308- with AssertLogLevel (None ):
1422+ with AssertLogLevel ("WARNING" , contains_str = "deprecated" ):
13091423 sim = sim .updated_copy (
13101424 monitors = [m for m in sim .monitors if not isinstance (m , td .EMEFieldMonitor )]
13111425 )
0 commit comments