def test_thyristor_bridge(convert_compile_load, expected_value, ss_state): measurement_name = 'Itb_ac' # Set source value. start_capture(duration=0.1, signals=[measurement_name], executeAt=1.0) # Set switch state for i, switch_name in enumerate(['Sa_bot', 'Sa_top', 'Sb_bot', 'Sb_top']): hil.set_pe_switching_block_control_mode(blockName='BT1', switchName=switch_name, swControl=True) hil.set_pe_switching_block_software_value(blockName='BT1', switchName=switch_name, value=ss_state) # Start simulation hil.start_simulation() # Data acquisition cap_data = get_capture_results(wait_capture=True) measurement = cap_data[measurement_name] # Tests: sig.assert_is_constant(measurement, at_value=around(expected_value, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_thyristor(convert_compile_load, Vthy, f, thy_value, Ithy_exp): # Set source value hil.set_source_sine_waveform(name='Vthy', rms=Vthy, frequency=f) # Set switch state hil.set_pe_switching_block_control_mode(blockName='THY', switchName='S1', swControl=True) hil.set_pe_switching_block_software_value(blockName='THY', switchName='S1', value=thy_value) # Start capture start_capture(duration=0.1, signals=['Ithy'], executeAt=0.2) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) Ithy = capture['Ithy'] # Tests sig.assert_is_constant(Ithy, at_value=around(Ithy_exp, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_thyristor(convert_compile_load, Vthy, f, thy_value, Ithy_exp): # Set source value hil.set_source_sine_waveform(name='Vthy', rms=Vthy, frequency=f) # Set switch state hil.set_pe_switching_block_control_mode(blockName='THY', switchName='S1', swControl=True) hil.set_pe_switching_block_software_value(blockName='THY', switchName='S1', value=thy_value) # Start capture start_capture(duration=0.1, signals=['Ithy'], executeAt=0.2) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) Ithy = np.mean(capture['Ithy']) # Tests assert Ithy == pytest.approx(Ithy_exp, rel=1e-2, abs=0.2) # Stop simulation hil.stop_simulation()
def test_three_level_flying_cap_leg(load_and_compile, VDC1,VDC2, iR1_expected): # Set source value hil.set_source_constant_value(name='VDC1', value=VDC1) hil.set_source_constant_value(name='VDC2', value=VDC2) for switch in range(1, 5): hil.set_pe_switching_block_control_mode(blockName='SwCapLeg7', switchName="S_" + str(switch), swControl=True) hil.set_pe_switching_block_software_value(blockName='SwCapLeg7', switchName="S_" + str(switch), value=1) # Start capture start_capture(duration=0.04, signals=['iR1'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) iR1 = capture['iR1'] # Tests sig.assert_is_constant(iR1, during=(0.03 - 0.0001, 0.03 + 0.0001), at_value=around(iR1_expected, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_mosfet(convert_compile_load, Vmosfet1, Vmosfet2, f): # Set source value. hil.set_source_sine_waveform(name='Vmosfet1', rms=Vmosfet1, frequency=f) hil.set_source_sine_waveform(name='Vmosfet2', rms=Vmosfet2, frequency=f) # Start capture start_capture(duration=0.1, signals=['Imosfet1', 'Imosfet2'], executeAt=0.2) # Start simulation hil.start_simulation() # Data acquisition hil.set_pe_switching_block_control_mode(blockName='Q1', switchName='S1', swControl=True) hil.set_pe_switching_block_software_value(blockName='Q1', switchName='S1', value=1) hil.set_pe_switching_block_control_mode(blockName='Q2', switchName='S1', swControl=True) hil.set_pe_switching_block_software_value(blockName='Q2', switchName='S1', value=0) capture = get_capture_results(wait_capture=True) Imosfet1 = np.mean(capture['Imosfet1']) Imosfet2 = np.mean(capture['Imosfet2']) # Expected currents R = 10 Imosfet1_exp = Vmosfet1 / R Imosfet2_exp = Vmosfet2 / R / np.sqrt(2) # Tests assert Imosfet1 == pytest.approx(Imosfet1_exp, rel=1e-2) assert Imosfet2 == pytest.approx(Imosfet2_exp, abs=0.2) # Stop simulation hil.stop_simulation()
def test_igbt(convert_compile_load, Vigbt1, Vigbt2, f): # Set source value. hil.set_source_sine_waveform(name='Vigbt1', rms=Vigbt1, frequency=f) hil.set_source_sine_waveform(name='Vigbt2', rms=Vigbt2, frequency=f) # Start capture start_capture(duration=0.1, signals=['Iigbt1', 'Iigbt2'], executeAt=0.2) # Start simulation hil.start_simulation() # Data acquisition hil.set_pe_switching_block_control_mode(blockName='IGBT1', switchName='S1', swControl=True) hil.set_pe_switching_block_software_value(blockName='IGBT1', switchName='S1', value=1) hil.set_pe_switching_block_control_mode(blockName='IGBT2', switchName='S1', swControl=True) hil.set_pe_switching_block_software_value(blockName='IGBT2', switchName='S1', value=0) capture = get_capture_results(wait_capture=True) Iigbt1 = capture['Iigbt1'] Iigbt2 = capture['Iigbt2'] # Expected currents R = 10 Iigbt1_exp = Vigbt1 / R Iigbt2_exp = Vigbt2 / R / np.sqrt(2) # Tests sig.assert_is_constant(Iigbt1, at_value=around(Iigbt1_exp, tol_p=0.01)) sig.assert_is_constant(Iigbt2, at_value=around(Iigbt2_exp, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_thyristor_bridge(convert_compile_load, Vtb, f, ss_tb): # Set source value. hil.set_source_sine_waveform(name='Vtb', rms=Vtb, frequency=f) # Start capture start_capture(duration=0.1, signals=['Itb_ac', 'Itb_dc'], executeAt=1.0) # Start simulation hil.start_simulation() # Set switch state hil.set_pe_switching_block_control_mode(blockName='BT1', switchName='Sa_bot', swControl=True) hil.set_pe_switching_block_software_value(blockName='BT1', switchName='Sa_bot', value=ss_tb) hil.set_pe_switching_block_control_mode(blockName='BT1', switchName='Sa_top', swControl=True) hil.set_pe_switching_block_software_value(blockName='BT1', switchName='Sa_top', value=ss_tb) hil.set_pe_switching_block_control_mode(blockName='BT1', switchName='Sb_bot', swControl=True) hil.set_pe_switching_block_software_value(blockName='BT1', switchName='Sb_bot', value=ss_tb) hil.set_pe_switching_block_control_mode(blockName='BT1', switchName='Sb_top', swControl=True) hil.set_pe_switching_block_software_value(blockName='BT1', switchName='Sb_top', value=ss_tb) # Data acquisition capture = get_capture_results(wait_capture=True) Itb_ac = np.mean(capture['Itb_ac']) Itb_dc = np.mean(capture['Itb_dc']) # Expected currents R = 10.0 if ss_tb == 1: Itb_ac_exp = Vtb/R Itb_dc_exp = Vtb/R*2*np.sqrt(2)/np.pi else: Itb_ac_exp = 0 Itb_dc_exp = 0 # Stop simulation hil.stop_simulation() # Tests assert Itb_ac == pytest.approx(Itb_ac_exp, rel=1e-2, abs=0.2) assert Itb_dc == pytest.approx(Itb_dc_exp, rel=1e-2, abs=0.2)
def test_igbt_leg(load_and_compile, VDC1, iR1_expected): # Set source value hil.set_source_constant_value(name='VDC1', value=VDC1) hil.set_pe_switching_block_control_mode('SwitchingLeg', "S_top", swControl=True) hil.set_pe_switching_block_software_value('SwitchingLeg', "S_top", value=1) hil.set_pe_switching_block_control_mode('SwitchingLeg', "S_bot", swControl=True) hil.set_pe_switching_block_software_value('SwitchingLeg', "S_bot", value=1) start_capture(duration=0.04, signals=['iR1'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) iR1 = capture['iR1'] # Tests sig.assert_is_constant(iR1, during=(0.01 - 0.0001, 0.01 + 0.0001), at_value=around(iR1_expected, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_three_phase_T_type_converter(load_and_compile, VDC1, VDC2, iA_expected, iB_expected, iC_expected): # Set source value hil.set_source_constant_value(name='VDC1', value=VDC1) hil.set_source_constant_value(name='VDC2', value=VDC2) for switch in range(1, 5): hil.set_pe_switching_block_control_mode(blockName='Ttype', switchName="Sa_" + str(switch), swControl=True) hil.set_pe_switching_block_software_value(blockName='Ttype', switchName="Sa_" + str(switch), value=1) hil.set_pe_switching_block_control_mode(blockName='Ttype', switchName="Sb_" + str(switch), swControl=True) hil.set_pe_switching_block_software_value(blockName='Ttype', switchName="Sb_" + str(switch), value=1) hil.set_pe_switching_block_control_mode(blockName='Ttype', switchName="Sc_" + str(switch), swControl=True) hil.set_pe_switching_block_software_value(blockName='Ttype', switchName="Sc_" + str(switch), value=1) # Start capture start_capture(duration=0.04, signals=['iA', 'iB', 'iC'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) iA = capture['iA'] iB = capture['iB'] iC = capture['iC'] # Tests sig.assert_is_constant(iA, during=(0.015 - 0.001, 0.015 + 0.001), at_value=around(iA_expected, tol_p=0.01)) sig.assert_is_constant(iB, during=(0.015 - 0.001, 0.015 + 0.001), at_value=around(iB_expected, tol_p=0.01)) sig.assert_is_constant(iC, during=(0.03 - 0.001, 0.03 + 0.001), at_value=around(iC_expected, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_single_phase_thyristor_rectifier(load_and_compile, VAC, f, iDC_expected): # Set source value hil.set_source_sine_waveform(name='VAC', rms=VAC, frequency=f) #set switching blocks hil.set_pe_switching_block_control_mode('Rectifier', "Sa_top", swControl=True) hil.set_pe_switching_block_software_value('Rectifier', "Sa_top", value=1) hil.set_pe_switching_block_control_mode('Rectifier', "Sa_bot", swControl=True) hil.set_pe_switching_block_software_value('Rectifier', "Sa_bot", value=1) hil.set_pe_switching_block_control_mode('Rectifier', "Sb_top", swControl=True) hil.set_pe_switching_block_software_value('Rectifier', "Sb_top", value=1) hil.set_pe_switching_block_control_mode('Rectifier', "Sb_bot", swControl=True) hil.set_pe_switching_block_software_value('Rectifier', "Sb_bot", value=1) # Start capture start_capture(duration=0.04, signals=['iDC'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) iDC = capture['iDC'] # Tests # Peak sig.assert_is_constant(iDC, during=(0.005015 - 0.0001, 0.005015 + 0.0001), at_value=around(iDC_expected, tol_p=0.01)) # Stop simulation hil.stop_simulation()