def test_rlc3(load_and_compile, Vsin3P, f, iRLCA_expected): # Set source value hil.set_source_sine_waveform(name='Vsin3P', rms=Vsin3P, frequency=f) # Start capture start_capture(duration=0.2, signals=['iRLCA'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) iRLCA = capture['iRLCA'] # Tests sig.assert_is_constant(iRLCA, during=(0.02107 - 0.000001, 0.02107 + 0.000001), at_value=around(iRLCA_expected, tol_p=0.01)) sig.assert_is_constant(iRLCA, during=(0.0160685 - 0.000001, 0.0160685 + 0.000001), at_value=(-0.02, 0.02)) # Stop simulation hil.stop_simulation()
def test_bi_directional_switch(load_and_compile, VAC, f, s1_closed, iR1_expected): # Set source value hil.set_source_sine_waveform(name='VAC', rms=VAC, frequency=f) # Set switch state hil.set_contactor('S1', swControl=True, swState=s1_closed) # 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 # Peak sig.assert_is_constant(iR1, during=(0.005 - 0.000001, 0.005 + 0.000001), at_value=around(iR1_expected, tol_p=0.01)) # Half 50 Hz sine sig.assert_is_constant(iR1, during=(0.01 - 0.000001, 0.01 + 0.000001), at_value=(-0.02, 0.02)) # Stop simulation hil.stop_simulation()
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_3ph_w1w2_transformer(load_cpd, source_value, contactor_state, expected_value, source_name, contactor_name, measurement_name): # Set source value. hil.set_source_sine_waveform(name=source_name, rms=source_value / np.sqrt(3), frequency=50) # Set switch state hil.set_contactor(name=contactor_name, swControl=True, swState=contactor_state) # Start_capture sim_time = hil.get_sim_time() capture.start_capture(duration=0.1, signals=[measurement_name], executeAt=sim_time + 2) # Data acquisition cap_data = capture.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.001))
def test_three_ph_3w_ydd_transformer(load_cpd, contactor_state1, contactor_state2, expected_values, contactor_name1, contactor_name2, measurement_names): # Set switch state hil.set_contactor(contactor_name1, swControl=True, swState=contactor_state1) hil.set_contactor(contactor_name2, swControl=True, swState=contactor_state2) # Start capture sim_time = hil.get_sim_time() capture.start_capture(duration=0.1, signals=measurement_names, executeAt=sim_time + 1.5) # Data acquisition cap_data = capture.get_capture_results(wait_capture=True) measurements = cap_data # Tests for i, expected_value in enumerate(expected_values): sig.assert_is_constant(measurements[measurement_names[i]], at_value=around(expected_value, tol_p=0.001))
def test_single_ph_3w_transformer(compile_tse, ss3_value, ss4_value, expected_values, measurement_names): # Loading model frome function 'compile_tse' cpd_path = compile_tse hil.load_model(file=cpd_path, offlineMode=False, vhil_device=vhil) # Set switch state hil.set_contactor('SS3', swControl=True, swState=ss3_value) hil.set_contactor('SS4', swControl=True, swState=ss4_value) # Set source value. hil.set_source_sine_waveform(name='Vt3w', rms=110.0, frequency=50.0) # Start capture capture.start_capture(duration=0.1, signals=measurement_names, executeAt=0.6) # Start simulation hil.start_simulation() # Data acquisition cap_data = capture.get_capture_results(wait_capture=True) measurements=cap_data # Tests for i, expected_value in enumerate(expected_values): sig.assert_is_constant(measurements[measurement_names[i]], at_value=around(expected_values[i], tol_p=0.001)) # Stop simulation hil.stop_simulation()
def test_permanent_magnet_sync_machine(convert_compile_load, Vpmsm, f, torque, Ipmsm_exp, nr_exp): # Set source value hil.set_source_sine_waveform(name='Vpmsm', rms=Vpmsm, frequency=f) # Set machine torque hil.set_machine_constant_torque(name='PMSM', value=torque) # Start capture start_capture(duration=0.1, signals=['Ipmsm', 'machine mechanical speed'], executeAt=1.0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) Ipmsm = capture['Ipmsm'] nr = capture['machine mechanical speed'] # Stop simulation hil.stop_simulation() # Tests sig.assert_is_constant(Ipmsm, at_value=around(Ipmsm_exp, tol_p=0.02)) sig.assert_is_constant(nr, at_value=around(nr_exp, tol_p=0.01))
def test_c3(load_and_compile, Vsin3P, f, ICa_expected): # Set source value hil.set_source_sine_waveform(name='Vsin3P', rms=Vsin3P, frequency=f) # Start capture start_capture(duration=0.2, signals=['ICa'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) ICa = capture['ICa'] # Tests sig.assert_is_constant(ICa, during=(0.01 - 0.000001, 0.01 + 0.000001), at_value=around(ICa_expected, tol_p=0.01)) sig.assert_is_constant(ICa, during=(0.02 - 0.000001, 0.02 + 0.000001), at_value=around(-ICa_expected, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_single_ph_2w_transformer(compile_tse, ss_value, expected, measurement_name): #Loading model frome funtion 'compile_tse' cpd_path = compile_tse hil.load_model(file=cpd_path, offlineMode=False, vhil_device=vhil) # Set switch state hil.set_contactor('SS1', swControl=True, swState=ss_value) hil.set_contactor('SS2', swControl=True, swState=ss_value) # Start simulation hil.start_simulation() capture.start_capture(duration=0.1, signals=[measurement_name], executeAt=1.0) # Data acquisition cap_data = capture.get_capture_results(wait_capture=True) measurement = cap_data[measurement_name] # Tests sig.assert_is_constant(measurement, at_value=around(expected, tol_p=0.001)) # 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_pv_pvanel(convert_compile_load): # Start capture sim_time = hil.get_sim_time() start_capture(duration=0.1, signals=["I1"], executeAt=sim_time + 0.5) # Data acquisition cap_data = get_capture_results(wait_capture=True) measurement = cap_data # Tests sig.assert_is_constant(measurement["I1"], at_value=around(5.21, tol_p=0.001))
def test_three_phase_thyristor_rectifier(load_and_compile, Vsin3P, f, iDC_expected): # Set source value hil.set_source_sine_waveform(name='Vsin3P', rms=Vsin3P, 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) hil.set_pe_switching_block_control_mode('Rectifier', "Sc_top", swControl=True) hil.set_pe_switching_block_software_value('Rectifier', "Sc_top", value=1) hil.set_pe_switching_block_control_mode('Rectifier', "Sc_bot", swControl=True) hil.set_pe_switching_block_software_value('Rectifier', "Sc_bot", value=1) # Start capture start_capture(duration=0.2, signals=['iDC'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) iDC = capture['iDC'] # Tests sig.assert_is_constant(iDC, during=(0.00668 - 0.000001, 0.00668 + 0.000001), at_value=around(iDC_expected, tol_p=0.01)) sig.assert_is_constant(iDC, during=(0.01 - 0.000001, 0.01 + 0.000001), at_value=around(iDC_expected, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_electrolitic_capacitor(load_and_compile, VAC1, f, VC1_expected): # Set source value hil.set_source_sine_waveform(name='VAC1', rms=VAC1, frequency=f) # Start capture start_capture(duration=0.5, signals=['VC1', 'VC2'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) VC1 = capture['VC1'] VC2 = capture['VC2'] # Tests 6.400e-03 sig.assert_is_constant(VC1, during=(0.0064 - 0.000001, 0.0064 + 0.000001), at_value=around(VC1_expected, tol_p=0.02)) sig.assert_is_constant(VC1, during=(0.016 - 0.000001, 0.016 + 0.000001), at_value=around(-VC1_expected, tol_p=0.02)) sig.assert_is_constant(VC2, during=(0.045 - 0.000001, 0.045 + 0.000001), at_value=around(50, tol_p=0.01)) sig.assert_is_constant(VC2, during=(0.5 - 0.000001, 0.5 + 0.000001), at_value=around(50, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_1_ph_2w_transformer(load_and_compile, Vit, Viti1, f, Vit_ac_expected, Viti_ac_expected): # Set source value hil.set_source_sine_waveform(name='Vit', rms=Vit, frequency=f) hil.set_source_sine_waveform(name='Viti1', rms=Viti1, frequency=f) # Start capture start_capture(duration=0.5, signals=['Vit_ac', 'Viti_ac'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) Vit_ac = capture['Vit_ac'] Viti_ac = capture['Viti_ac'] # Tests sig.assert_is_constant(Vit_ac, during=(0.005 - 0.00000001, 0.005 + 0.00000001), at_value=around(Vit_ac_expected, tol_p=0.01)) sig.assert_is_constant(Vit_ac, during=(0.01 - 0.00000001, 0.01 + 0.00000001), at_value=(-0.02,0.02)) sig.assert_is_constant(Viti_ac, during=(0.015 - 0.00000001, 0.015 + 0.00000001), at_value=around(Viti_ac_expected, tol_p=0.01)) sig.assert_is_constant(Viti_ac, during=(0.01 - 0.00000001, 0.01 + 0.00000001), at_value=(-0.02,0.02)) # Stop simulation hil.stop_simulation()
def test_inductor(load_and_compile, VAC1, f, iL1_expected, i_init_expected): # Set source value hil.set_source_sine_waveform(name='VAC1', rms=VAC1, frequency=f) # Start capture start_capture(duration=0.2, signals=['iL1', 'i_init'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) iL1 = capture['iL1'] i_init = capture['i_init'] # Tests 5.87643e-002 sig.assert_is_constant(iL1, during=(0.00462 - 0.000001, 0.00462 + 0.000001), at_value=around(iL1_expected, tol_p=0.01)) sig.assert_is_constant(iL1, during=(0.05876 - 0.000001, 0.05876 + 0.000001), at_value=(-0.02, 0.02)) sig.assert_is_constant(i_init, during=(0.005 - 0.000001, 0.005 + 0.000001), at_value=around(i_init_expected, tol_p=0.01)) sig.assert_is_constant(i_init, during=(0.05 - 0.000001, 0.05 + 0.000001), at_value=around(i_init_expected, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_three_ph_3w_ydd_transformer(load_cpd, ss_ydd2, ss_ydd3, expected_values): measurement_names = ['Vydd2', 'Vydd3', 'Iydd2', 'Iydd3'] # Set switch state hil.set_contactor('ss_ydd2', swControl=True, swState=ss_ydd2) hil.set_contactor('ss_ydd3', swControl=True, swState=ss_ydd3) # Start capture sim_time = hil.get_sim_time() capture.start_capture(duration=0.1, signals=measurement_names, executeAt=sim_time + 1.5) # Data acquisition cap_data = capture.get_capture_results(wait_capture=True) # Tests for i,expected_value in enumerate(expected_values): sig.assert_is_constant(cap_data[measurement_names[i]], at_value=around(expected_value, tol_p=0.001))
def test_coupled_inductors(convert_compile_load, expected_values, measurement_names): # Start capture sim_time = hil.get_sim_time() start_capture(duration=0.1, signals=measurement_names, executeAt=sim_time + 0.5) # Data acquisition cap_data = get_capture_results(wait_capture=True) measurement = cap_data # Tests for i, expected_value in enumerate(expected_values): sig.assert_is_constant(measurement[measurement_names[i]], at_value=around(expected_value, tol_p=0.001))
def test_three_phase_diode_rectifier(load_and_compile, Vsin3P, f, iDC_expected): # Set source value hil.set_source_sine_waveform(name='Vsin3P', rms=Vsin3P, frequency=f) # Start capture start_capture(duration=0.2, signals=['iDC'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) iDC = capture['iDC'] # Tests sig.assert_is_constant(iDC, during=(0.00033 - 0.000001, 0.00033 + 0.000001), at_value=around(iDC_expected, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_rectifiers(convert_compile_load, expected_values, measurement_names, source_name): # Set source value. hil.set_source_sine_waveform(name=source_name, rms=Vsrc, frequency=f) # Start capture start_capture(duration=0.1, signals=measurement_names, executeAt=1.0) # Start simulation hil.start_simulation() # Data acquisition cap_data = get_capture_results(wait_capture=True) measurements = cap_data # Tests for i, expected_value in enumerate(expected_values): sig.assert_is_constant(measurements[measurement_names[i]], at_value=around(expected_value, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_diode(convert_compile_load, Vd1, Vd2, Vd3, f): # Set source value. hil.set_source_constant_value(name='Vd1', value=Vd1) hil.set_source_constant_value(name='Vd2', value=Vd2) hil.set_source_sine_waveform(name='Vd3', rms=Vd3, frequency=f) # Start capture start_capture(duration=0.1, signals=['Id1', 'Id2', 'Id3'], executeAt=0.2) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) Id1 = capture['Id1'] Id2 = capture['Id2'] Id3 = capture['Id3'] # Expected currents R = 10 Id1_exp = Vd1/R Id2_exp = 0 Id3_exp = Vd3/R/np.sqrt(2) # Tests sig.assert_is_constant(Id1, at_value=around(Id1_exp, tol_p=0.01)) sig.assert_is_constant(Id2, at_value=around(Id2_exp, tol_p=0.01)) sig.assert_is_constant(Id3, at_value=around(Id3_exp, tol_p=0.01)) # 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_1ph_core_coupling(load_and_compile, VDC, iR1_expected): # Set source value hil.set_source_constant_value(name='VDC', value=VDC) # 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 # Peak sig.assert_is_constant(iR1, during=(0 + 0.000001, 0.04), at_value=around(iR1_expected, tol_p=0.001)) # Stop simulation hil.stop_simulation()
def test_bi_directional_switch(convert_compile_load, Vss, f, ss_value, Iss_exp): # Set source value hil.set_source_sine_waveform(name='Vss', rms=Vss, frequency=f) # Set switch state hil.set_contactor('SS', swControl=True, swState=ss_value) # Start capture start_capture(duration=0.1, signals=['Iss'], executeAt=0.2) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) Iss = capture['Iss'] # Tests sig.assert_is_constant(Iss, at_value=around(Iss_exp, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_3ph_dy_transformer(load_cpd, Vsin_dy, f, SS_dy, expected_values, measurement_names): # Set source value. hil.set_source_sine_waveform(name='Vsin_dy', rms=Vsin_dy / np.sqrt(3), frequency=f) # Set switch state hil.set_contactor('SS_dy', swControl=True, swState=SS_dy) # Start_capture sim_time = hil.get_sim_time() capture.start_capture(duration=0.1, signals=measurement_names, executeAt=sim_time + 1.5) # Data acquisition cap_data = capture.get_capture_results(wait_capture=True) # Tests for i, expected_value in enumerate(expected_values): sig.assert_is_constant(cap_data[measurement_names[i]], at_value=around(expected_value, tol_p=0.001))
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_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_5ph_core_coupling(load_and_compile, VDC1, iRA_expected, VDC2, iRB_expected, VDC3, iRC_expected, VDC4, iRD_expected): # Set source value hil.set_source_constant_value(name='VDC1', value=VDC1) hil.set_source_constant_value(name='VDC2', value=VDC2) hil.set_source_constant_value(name='VDC3', value=VDC3) hil.set_source_constant_value(name='VDC4', value=VDC4) # Start capture start_capture(duration=0.04, signals=['iRA', 'iRB', 'iRC', 'iRD'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) iRA = capture['iRA'] iRB = capture['iRB'] iRC = capture['iRC'] iRD = capture['iRD'] # Tests sig.assert_is_constant(iRA, during=(0 + 0.000001, 0.04), at_value=around(iRA_expected, tol_p=0.001)) sig.assert_is_constant(iRB, during=(0 + 0.000001, 0.04), at_value=around(iRB_expected, tol_p=0.001)) sig.assert_is_constant(iRC, during=(0 + 0.000001, 0.04), at_value=around(iRC_expected, tol_p=0.001)) sig.assert_is_constant(iRD, during=(0 + 0.000001, 0.04), at_value=around(iRD_expected, tol_p=0.001)) # Stop simulation hil.stop_simulation()
def test_resistor(load_and_compile, VDC, iR1_expected, Vout_expected, Vin_expected): # Set source value hil.set_source_constant_value(name='VDC', value=VDC) # Start capture start_capture(duration=0.2, signals=['iR1', 'Vout', 'Vin'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) iR1 = capture['iR1'] Vout = capture['Vout'] Vin = capture['Vin'] # Tests sig.assert_is_constant(iR1, during=(0.005 - 0.000001, 0.005 + 0.000001), at_value=around(iR1_expected, tol_p=0.01)) sig.assert_is_constant(iR1, during=(0.01 - 0.000001, 0.01 + 0.000001), at_value=around(iR1_expected, tol_p=0.01)) sig.assert_is_constant(Vout, during=(0.005 - 0.000001, 0.005 + 0.000001), at_value=around(Vout_expected, tol_p=0.01)) sig.assert_is_constant(Vout, during=(0.01 - 0.000001, 0.01 + 0.000001), at_value=around(Vout_expected, tol_p=0.01)) sig.assert_is_constant(Vin, during=(0.005 - 0.000001, 0.005 + 0.000001), at_value=around(Vin_expected, tol_p=0.01)) sig.assert_is_constant(Vin, during=(0.01 - 0.000001, 0.01 + 0.000001), at_value=around(Vin_expected, tol_p=0.01)) # Stop simulation hil.stop_simulation()
def test_3ph_core_couplingh(load_and_compile, Vsin3P, f, iR_expected): # Set source value hil.set_source_sine_waveform(name='Vsin3P', rms=Vsin3P, frequency=f) # Start capture start_capture(duration=0.04, signals=['iRA', 'iRB', 'iRC'], executeAt=0) # Start simulation hil.start_simulation() # Data acquisition capture = get_capture_results(wait_capture=True) iRA = capture['iRA'] iRB = capture['iRB'] iRC = capture['iRC'] # Tests sig.assert_is_constant(iRA, during=(0.00503 - 0.000001, 0.00503 + 0.000001), at_value=around(iR_expected, tol_p=0.01)) sig.assert_is_constant(iRA, during=(0.01503 - 0.000001, 0.01503 + 0.000001), at_value=around(-iR_expected, tol_p=0.01)) sig.assert_is_constant(iRA, during=(0.01 - 0.000001, 0.01 + 0.000001), at_value=(-0.02, 0.02)) sig.assert_is_constant(iRB, during=(0.0115 - 0.000001, 0.0115 + 0.000001), at_value=around(iR_expected, tol_p=0.01)) sig.assert_is_constant(iRB, during=(0.00165 - 0.000001, 0.00165 + 0.000001), at_value=around(-iR_expected, tol_p=0.01)) sig.assert_is_constant(iRB, during=(0.0066666 - 0.000001, 0.0066666 + 0.000001), at_value=(-0.02, 0.02)) sig.assert_is_constant(iRC, during=(0.0183 - 0.000001, 0.0183 + 0.000001), at_value=around(iR_expected, tol_p=0.01)) sig.assert_is_constant(iRC, during=(0.0083 - 0.000001, 0.0083 + 0.000001), at_value=around(-iR_expected, tol_p=0.01)) sig.assert_is_constant(iRC, during=(0.0033333 - 0.000001, 0.0033333 + 0.000001), at_value=(-0.02, 0.02)) # Stop simulation hil.stop_simulation()