@@ -200,10 +200,13 @@ def make_mw_sim(
200200 size_port = [0 , sim_width , size_sim [2 ]]
201201 center_port = [0 , 0 , center_sim [2 ]]
202202 impedance_specs = (td .AutoImpedanceSpec (),) * 4
203- mode_spec = td .MicrowaveModeSpec (
203+ microwave_spec = td .MicrowaveModeSpec (
204+ impedance_specs = impedance_specs ,
205+ )
206+ mode_spec = td .ModeSpec (
204207 num_modes = 4 ,
205208 target_neff = 1.8 ,
206- impedance_specs = impedance_specs ,
209+ microwave_spec = microwave_spec ,
207210 )
208211
209212 mode_monitor = td .ModeMonitor (
@@ -484,7 +487,12 @@ def test_impedance_spec_validation():
484487 with pytest .raises (pd .ValidationError ):
485488 _ = td .CustomImpedanceSpec (voltage_spec = None , current_spec = None )
486489
487- _ = td .MicrowaveModeSpec (num_modes = 4 , impedance_specs = (both , voltage_only , current_only , None ))
490+ _ = td .ModeSpec (
491+ num_modes = 4 ,
492+ microwave_spec = td .MicrowaveModeSpec (
493+ impedance_specs = (both , voltage_only , current_only , None )
494+ ),
495+ )
488496
489497
490498def test_path_integral_factory_voltage_validation ():
@@ -570,21 +578,19 @@ def test_make_path_integrals_validation():
570578 voltage_spec = v_spec ,
571579 current_spec = i_spec ,
572580 )
573- microwave_mode_spec = td .MicrowaveModeSpec (impedance_specs = (impedance_spec ,))
581+ microwave_spec = td .MicrowaveModeSpec (impedance_specs = (impedance_spec ,))
574582
575583 # Test successful creation
576- voltage_integrals , current_integrals = make_path_integrals (microwave_mode_spec , mode_monitor )
584+ voltage_integrals , current_integrals = make_path_integrals (microwave_spec , mode_monitor )
577585 assert len (voltage_integrals ) == 1
578586 assert len (current_integrals ) == 1
579587 assert voltage_integrals [0 ] is not None
580588 assert current_integrals [0 ] is not None
581589
582590 # Test with None specs - when both are None, use_automatic_setup is True
583591 # This means current integrals will be auto-generated, not None
584- microwave_mode_spec_none = td .MicrowaveModeSpec (impedance_specs = (None ,))
585- voltage_integrals , current_integrals = make_path_integrals (
586- microwave_mode_spec_none , mode_monitor
587- )
592+ microwave_spec_none = td .MicrowaveModeSpec (impedance_specs = (None ,))
593+ voltage_integrals , current_integrals = make_path_integrals (microwave_spec_none , mode_monitor )
588594 assert len (voltage_integrals ) == mode_monitor .mode_spec .num_modes
589595 assert len (current_integrals ) == mode_monitor .mode_spec .num_modes
590596 assert all (vi is None for vi in voltage_integrals )
@@ -601,7 +607,7 @@ def test_make_path_integrals_construction_errors(monkeypatch):
601607 v_spec = td .AxisAlignedVoltageIntegralSpec (center = (1 , 2 , 3 ), size = (0 , 0 , 1 ), sign = "-" )
602608
603609 impedance_spec = td .CustomImpedanceSpec (voltage_spec = v_spec , current_spec = None )
604- microwave_mode_spec = td .MicrowaveModeSpec (impedance_specs = (impedance_spec ,))
610+ microwave_spec = td .MicrowaveModeSpec (impedance_specs = (impedance_spec ,))
605611
606612 # Mock make_voltage_integral to raise an exception
607613 def mock_make_voltage_integral (path_spec ):
@@ -614,7 +620,7 @@ def mock_make_voltage_integral(path_spec):
614620
615621 # This should raise a SetupError due to construction failure
616622 with pytest .raises (SetupError , match = "Failed to construct path integrals" ):
617- make_path_integrals (microwave_mode_spec , mode_monitor )
623+ make_path_integrals (microwave_spec , mode_monitor )
618624
619625
620626def test_path_integral_factory_composite_current ():
@@ -662,14 +668,14 @@ def test_path_integral_factory_mixed_specs():
662668 # Test with mixed specs - some None, some specified
663669 impedance_spec1 = td .CustomImpedanceSpec (voltage_spec = v_spec , current_spec = None )
664670 impedance_spec2 = td .CustomImpedanceSpec (voltage_spec = None , current_spec = i_spec )
665- microwave_mode_spec = td .MicrowaveModeSpec (
666- num_modes = 2 ,
671+ microwave_spec = td .MicrowaveModeSpec (
667672 impedance_specs = (
668673 impedance_spec1 ,
669674 impedance_spec2 ,
670675 ),
671676 )
672- voltage_integrals , current_integrals = make_path_integrals (microwave_mode_spec , mode_monitor )
677+
678+ voltage_integrals , current_integrals = make_path_integrals (microwave_spec , mode_monitor )
673679
674680 assert len (voltage_integrals ) == 2
675681 assert len (current_integrals ) == 2
@@ -697,11 +703,15 @@ def test_mode_solver_with_microwave_mode_spec():
697703
698704 plane = td .Box (center = (0 , 0 , 0 ), size = (0 , 10 * width , 2 * height + metal_thickness ))
699705 num_modes = 3
700- impedance_specs = (td .AutoImpedanceSpec (), None , None )
701- mode_spec = td .MicrowaveModeSpec (
706+ # impedance_specs = (td.AutoImpedanceSpec(), None, None)
707+ impedance_specs = td .AutoImpedanceSpec ()
708+ microwave_spec = td .MicrowaveModeSpec (
709+ impedance_specs = impedance_specs ,
710+ )
711+ mode_spec = td .ModeSpec (
702712 num_modes = num_modes ,
703713 target_neff = 2.2 ,
704- impedance_specs = impedance_specs ,
714+ microwave_spec = microwave_spec ,
705715 )
706716 mms = ModeSolver (
707717 simulation = stripline_sim ,
@@ -729,7 +739,8 @@ def test_mode_solver_with_microwave_mode_spec():
729739 ),
730740 )
731741 impedance_specs = (custom_spec , None , None )
732- mms = mms .updated_copy (path = "mode_spec/" , impedance_specs = impedance_specs )
742+ microwave_spec_custom = td .MicrowaveModeSpec (impedance_specs = impedance_specs )
743+ mms = mms .updated_copy (path = "mode_spec/" , microwave_spec = microwave_spec_custom )
733744 mms_data : ModeSolverData = mms .data
734745
735746 # _, ax = plt.subplots(1, 1, tight_layout=True, figsize=(15, 15))
@@ -738,4 +749,10 @@ def test_mode_solver_with_microwave_mode_spec():
738749 # plt.show()
739750 mms_data .to_dataframe ()
740751
741- assert np .all (np .isclose (mms_data .microwave_data .Z0 .real , 28.6 , 0.2 ))
752+ assert np .all (np .isclose (mms_data .microwave_data .Z0 .real .sel (mode_index = 0 ), 28.6 , 0.2 ))
753+
754+ # Make sure a single spec can be used
755+ microwave_spec_custom = td .MicrowaveModeSpec (impedance_specs = custom_spec )
756+ mms = mms .updated_copy (path = "mode_spec/" , microwave_spec = microwave_spec_custom )
757+ mms_data : ModeSolverData = mms .data
758+ assert np .all (np .isclose (mms_data .microwave_data .Z0 .real .sel (mode_index = 0 ), 28.6 , 0.2 ))
0 commit comments