Пример #1
0
def test_inductor_ac(convert_compile_load, VAC1, theta, f):

    # Maybe delete?
    # # Set sources before starting the simulation
    # hil.set_source_sine_waveform("VAC1", VAC1, f, theta)

    IL2 = VAC1 / np.pi
    IL3 = VAC1 / np.pi / np.sqrt(2)

    # Start simulation
    hil.start_simulation()

    # Set sources
    hil.set_source_sine_waveform(name='VAC1',
                                 rms=VAC1,
                                 frequency=f,
                                 phase=theta)
    hil.wait_sec(1)

    # Tests
    assert capture.read('IL2') == pytest.approx(IL2, rel=1e-3)
    assert capture.read('IL3') == pytest.approx(IL3, rel=1e-3)

    # Stop simulation
    hil.stop_simulation()
Пример #2
0
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()
Пример #3
0
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()
Пример #4
0
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 = np.mean(capture['Id1'])
    Id2 = np.mean(capture['Id2'])
    Id3 = np.mean(capture['Id3'])

    # Expected currents
    R = 10
    Id1_exp = Vd1 / R
    Id2_exp = 0
    Id3_exp = Vd3 / R / np.sqrt(2)

    # Tests
    assert Id1 == pytest.approx(Id1_exp, rel=1e-2)
    assert Id2 == pytest.approx(Id2_exp, abs=0.1)
    assert Id3 == pytest.approx(Id3_exp, rel=1e-2)

    # Stop simulation
    hil.stop_simulation()
Пример #5
0
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_wound_rotor_ind_machine(convert_compile_load, Vsin3_wrim, f, torque, Iwrim_s_exp, Iwrim_r_exp, nr_exp):

    # Set source value
    hil.set_source_sine_waveform(name='Vsin3_wrim', rms=Vsin3_wrim, frequency=f)

    # Set machine torque
    hil.set_machine_constant_torque(name='WRIM', value=torque)

    # Start capture
    start_capture(duration=2.5, rate=10000, signals=['Iwrim_s', 'Iwrim_r', 'machine mechanical speed'], executeAt=0.5)

    # Start simulation
    hil.start_simulation()
    wait_capture_finish()

    # Data acquisition
    capture = get_capture_results()
    Iwrim_s = np.mean(capture['Iwrim_s'])
    #Iwrim_r = np.mean(util.window_rms(capture['Iwrim_r'].values, window_size=5000))
    nr = np.mean(capture['machine mechanical speed'])/2/np.pi*60

    # Stop simulation
    hil.stop_simulation()

    # Tests
    assert Iwrim_s == pytest.approx(expected=Iwrim_s_exp, rel=1e-2)
    #assert Iwrim_r == pytest.approx(expected=Iwrim_r_exp, rel=1e-2)
    assert nr == pytest.approx(expected=nr_exp, rel=1e-3)
def test_1ph_2w_transformer(load_and_compile, Vt, Vti, f, ss1_closed, ss2_closed, Vt_ac_expected, Vti_ac_expected):

    # Set source value
    hil.set_source_sine_waveform(name='Vt', rms=Vt, frequency=f)
    hil.set_source_sine_waveform(name='Vti', rms=Vti, frequency=f)

    # Set switch state
    hil.set_contactor('SS1', swControl=True, swState=ss1_closed)
    hil.set_contactor('SS2', swControl=True, swState=ss2_closed)

    # Start capture
    start_capture(duration=0.9, signals=['Vt_ac', 'Vti_ac', 'It_ac', 'Iti_ac'], executeAt=0)

    # Start simulation
    hil.start_simulation()

    # Data acquisition
    capture = get_capture_results(wait_capture=True)
    Vt_ac = capture['Vt_ac']
    Vti_ac = capture['Vti_ac']
    It_ac = capture['It_ac']
    Iti_ac = capture['Iti_ac']

    # Tests

    sig.assert_is_constant(Vt_ac, during=(0.4 - 0.0000001, 0.4 + 0.0000001), at_value=around(Vt_ac_expected, tol_p=0.01))
    sig.assert_is_constant(Vti_ac, during=(0.4 - 0.0000001, 0.4 + 0.0000001), at_value=around(Vti_ac_expected, tol_p=0.01))
    sig.assert_is_constant(It_ac, during=(0.8 - 0.0000001, 0.8 + 0.0000001), at_value=(1237.3 - 0.02, 1237.3 + 0.02 ))
    sig.assert_is_constant(It_ac, during=(0.81 - 0.0000001, 0.81 + 0.0000001), at_value=(-1236.7 - 0.02,-1236.7 + 0.02 ))
    sig.assert_is_constant(Iti_ac, during=(0.8 - 0.0000001, 0.8 + 0.0000001), at_value=(1237.3 - 0.02,1237.3 + 0.02 ))
    sig.assert_is_constant(Iti_ac, during=(0.81 - 0.0000001, 0.81 + 0.0000001),at_value=(-1236.75 - 0.02,-1236.75 + 0.02 ))

    # Stop simulation
    hil.stop_simulation()
Пример #8
0
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_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()
Пример #10
0
def test_squirrel_cage_ind_machine(convert_compile_load, Vsin3_sqim, f, torque,
                                   Isqim_exp, nr_exp):

    # Set source value
    hil.set_source_sine_waveform(name='Vsin3_sqim',
                                 rms=Vsin3_sqim,
                                 frequency=f)

    # Set machine torque
    hil.set_machine_constant_torque(name='SQIM', value=torque)

    # Start capture
    start_capture(duration=0.1,
                  signals=['Isqim', 'machine mechanical speed'],
                  executeAt=1.0)

    # Start simulation
    hil.start_simulation()

    # Data acquisition
    capture = get_capture_results(wait_capture=True)
    Isqim = np.mean(capture['Isqim'])
    nr = np.mean(capture['machine mechanical speed'])

    # Stop simulation
    hil.stop_simulation()

    # Tests
    assert Isqim == pytest.approx(expected=Isqim_exp, rel=1e-2)
    assert nr == pytest.approx(expected=nr_exp, rel=1e-3)
Пример #11
0
def test_bi_directional_switch(load_and_compile, Vsin3P, f, s3p_closed,
                               iR1_expected):

    # Set source value
    hil.set_source_sine_waveform(name='Vsin3P', rms=Vsin3P, frequency=f)

    # Set switch state
    hil.set_contactor('S3P', swControl=True, swState=s3p_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.00500298 - 0.0001, 0.005 + 0.0001),
                           at_value=around(iR1_expected, tol_p=0.01))
    # Min
    sig.assert_is_constant(iR1,
                           during=(0.015 - 0.000001, 0.015 + 0.000001),
                           at_value=around(-iR1_expected, tol_p=0.01))
    #Zero
    sig.assert_is_constant(iR1,
                           during=(0.01 - 0.000001, 0.01 + 0.000001),
                           at_value=(-0.01, 0.01))

    # Stop simulation
    hil.stop_simulation()
def test_coupled_inductors3(convert_compile_load, Vsin2, f, theta):

    # Set source value
    hil.set_source_sine_waveform(name='Vsin2', rms=Vsin2, frequency=f, phase=theta)

    # Start capture
    start_capture(duration=0.1, signals=['I_C3_1', 'I_C3_2', 'I_C3_3'], executeAt=0.5)

    # Start simulation
    hil.start_simulation()

    # Data acquisition
    capture = get_capture_results(wait_capture=True)
    I_C3_1 = np.mean(capture['I_C3_1'])
    I_C3_2 = np.mean(capture['I_C3_2'])
    I_C3_3 = np.mean(capture['I_C3_3'])

    # Expected currents
    I_C3_1_exp = 21.942844
    I_C3_2_exp = 10.971465
    I_C3_3_exp = 0.6202843

    # Tests
    assert I_C3_1 == pytest.approx(I_C3_1_exp, rel=1e-2)
    assert I_C3_2 == pytest.approx(I_C3_2_exp, rel=1e-2)
    assert I_C3_3 == pytest.approx(I_C3_3_exp, rel=1e-2)

    # Stop simulation
    hil.stop_simulation()
Пример #13
0
def test_capacitor(load_and_compile, VAC1, f, VC1_expected, VC2_expected):

    # Set source value
    hil.set_source_sine_waveform(name='VAC1', rms=VAC1, frequency=f)

    # Start capture
    start_capture(duration=0.2, signals=['VC1'], executeAt=0)
    start_capture(duration=0.2, signals=['VC2'], executeAt=0)

    # Start simulation
    hil.start_simulation()

    # Data acquisition
    capture = get_capture_results(wait_capture=True)
    VC1 = capture['VC1']
    VC2 = capture['VC2']

    # Tests
    sig.assert_is_constant(VC1,
                           during=(0.005 - 0.000001, 0.005 + 0.000001),
                           at_value=around(VC1_expected, tol_p=0.01))
    sig.assert_is_constant(VC1,
                           during=(0.010015 - 0.000001, 0.010015 + 0.000001),
                           at_value=(-0.02, -0.02))
    sig.assert_is_constant(VC2,
                           during=(0.005 - 0.000001, 0.005 + 0.000001),
                           at_value=around(VC2_expected, tol_p=0.01))

    # Stop simulation
    hil.stop_simulation()
Пример #14
0
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_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_synchronous_machine_i(convert_compile_load, Vf_i, torque, Ism_i_exp,
                               nr_exp):

    # Set source value
    hil.set_source_constant_value(name='Vf_i', value=Vf_i)

    # Set machine torque
    hil.set_machine_constant_torque(name='SM_I', value=torque)

    # Start capture
    start_capture(duration=0.1,
                  signals=['Ism_i', 'machine mechanical speed'],
                  executeAt=1.0)

    # Start simulation
    hil.start_simulation()

    # Data acquisition
    capture = get_capture_results(wait_capture=True)
    Ism_i = np.mean(capture['Ism_i'])
    nr = np.mean(capture['machine mechanical speed'])

    # Stop simulation
    hil.stop_simulation()

    # Tests
    assert Ism_i == pytest.approx(expected=Ism_i_exp, rel=1e-2)
    assert nr == pytest.approx(expected=nr_exp, rel=1e-3)
Пример #17
0
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()
Пример #18
0
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()
Пример #19
0
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()
Пример #20
0
def test_3ph_diode_bridge(convert_compile_load, V3ph_db, f):

    # Set source value.
    hil.set_source_sine_waveform(name='V3ph_db', rms=V3ph_db, frequency=f)

    # Start capture
    start_capture(duration=0.1, signals=['I3ph_db_ac', 'I3ph_db_dc'], executeAt=1.0)

    # Start simulation
    hil.start_simulation()

    # Data acquisition
    capture = get_capture_results(wait_capture=True)
    I3ph_db_ac = np.mean(capture['I3ph_db_ac'])
    I3ph_db_dc = np.mean(capture['I3ph_db_dc'])

    # Expected currents
    R = 10.0
    I3ph_db_ac_exp = V3ph_db/R*np.sqrt(2)*1.654
    I3ph_db_dc_exp = V3ph_db/R*np.sqrt(2)*1.655

    # Tests
    assert I3ph_db_ac == pytest.approx(I3ph_db_ac_exp, rel=1e-2)
    assert I3ph_db_dc == pytest.approx(I3ph_db_dc_exp, rel=1e-2)

    # 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))
Пример #22
0
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()
Пример #23
0
def test_3ph_thyristor_bridge(convert_compile_load, V3ph_tb, f, ss_3ph_tb):

    # Set source value.
    hil.set_source_sine_waveform(name='V3ph_tb', rms=V3ph_tb, frequency=f)

    # Start capture
    start_capture(duration=0.1, signals=['I3ph_tb_ac', 'I3ph_tb_dc'], executeAt=1.0)

    # Start simulation
    hil.start_simulation()

    # Set switch state
    hil.set_pe_switching_block_control_mode(blockName='BT32', switchName='Sa_bot',
                                            swControl=True)
    hil.set_pe_switching_block_software_value(blockName='BT32', switchName='Sa_bot',
                                              value=ss_3ph_tb)
    hil.set_pe_switching_block_control_mode(blockName='BT32', switchName='Sa_top',
                                            swControl=True)
    hil.set_pe_switching_block_software_value(blockName='BT32', switchName='Sa_top',
                                              value=ss_3ph_tb)
    hil.set_pe_switching_block_control_mode(blockName='BT32', switchName='Sb_bot',
                                            swControl=True)
    hil.set_pe_switching_block_software_value(blockName='BT32', switchName='Sb_bot',
                                              value=ss_3ph_tb)
    hil.set_pe_switching_block_control_mode(blockName='BT32', switchName='Sb_top',
                                            swControl=True)
    hil.set_pe_switching_block_software_value(blockName='BT32', switchName='Sb_top',
                                              value=ss_3ph_tb)
    hil.set_pe_switching_block_control_mode(blockName='BT32', switchName='Sc_bot',
                                            swControl=True)
    hil.set_pe_switching_block_software_value(blockName='BT32', switchName='Sc_bot',
                                              value=ss_3ph_tb)
    hil.set_pe_switching_block_control_mode(blockName='BT32', switchName='Sc_top',
                                            swControl=True)
    hil.set_pe_switching_block_software_value(blockName='BT32', switchName='Sc_top',
                                              value=ss_3ph_tb)

    # Data acquisition
    capture = get_capture_results(wait_capture=True)
    I3ph_tb_ac = np.mean(capture['I3ph_tb_ac'])
    I3ph_tb_dc = np.mean(capture['I3ph_tb_dc'])

    # Expected currents
    R = 10.0
    if ss_3ph_tb == 1:
        I3ph_tb_ac_exp = V3ph_tb / R * np.sqrt(2) * 1.654
        I3ph_tb_dc_exp = V3ph_tb / R * np.sqrt(2) * 1.655
    else:
        I3ph_tb_ac_exp = 0
        I3ph_tb_dc_exp = 0

    # Stop simulation
    hil.stop_simulation()

    # Tests
    assert I3ph_tb_ac == pytest.approx(I3ph_tb_ac_exp, rel=1e-2, abs=0.2)
    assert I3ph_tb_dc == pytest.approx(I3ph_tb_dc_exp, rel=1e-2, abs=0.2)
Пример #24
0
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()
Пример #25
0
def load_cpd(compile_tse):
    cpd_path = compile_tse
    # Load to VHIL
    hil.load_model(file=cpd_path, offlineMode=False, vhil_device=vhil)
    # Start simulation
    hil.start_simulation()

    yield

    # Stop simulation
    hil.stop_simulation()
Пример #26
0
def test_1ph_3w_transformer(load_and_compile, Vt3w, f, ss3_closed, ss4_closed,
                            Vt_3w_2_ac_expected, Vt_3w_3_ac_expected,
                            It_3w_2_ac_expected, It_3w_3_ac_expected):

    # Set source value
    hil.set_source_sine_waveform(name='Vt3w', rms=Vt3w, frequency=f)

    # Set switch state
    hil.set_contactor('SS3', swControl=True, swState=ss3_closed)
    hil.set_contactor('SS4', swControl=True, swState=ss4_closed)

    # Start capture
    start_capture(
        duration=0.9,
        signals=['Vt_3w_2_ac', 'Vt_3w_3_ac', 'It_3w_2_ac', 'It_3w_3_ac'],
        executeAt=0)

    # Start simulation
    hil.start_simulation()

    # Data acquisition
    capture = get_capture_results(wait_capture=True)
    Vt_3w_2_ac = capture['Vt_3w_2_ac']
    Vt_3w_3_ac = capture['Vt_3w_3_ac']
    It_3w_2_ac = capture['It_3w_2_ac']
    It_3w_3_ac = capture['It_3w_3_ac']

    # Tests

    sig.assert_is_constant(Vt_3w_2_ac,
                           during=(0.41 - 0.0001, 0.41 + 0.0001),
                           at_value=around(Vt_3w_2_ac_expected, tol_p=0.01))
    sig.assert_is_constant(Vt_3w_3_ac,
                           during=(0.41 - 0.0001, 0.41 + 0.0001),
                           at_value=around(Vt_3w_3_ac_expected, tol_p=0.01))

    sig.assert_is_constant(It_3w_2_ac,
                           during=(0.8 - 0.0001, 0.8 + 0.0001),
                           at_value=around(It_3w_2_ac_expected, tol_p=0.02))
    sig.assert_is_constant(It_3w_2_ac,
                           during=(0.81 - 0.0001, 0.81 + 0.0001),
                           at_value=around(-It_3w_2_ac_expected, tol_p=0.02))

    sig.assert_is_constant(It_3w_3_ac,
                           during=(0.8 - 0.0001, 0.8 + 0.0001),
                           at_value=around(-It_3w_3_ac_expected, tol_p=0.02))
    sig.assert_is_constant(It_3w_3_ac,
                           during=(0.81 - 0.0001, 0.81 + 0.0001),
                           at_value=around(It_3w_3_ac_expected, tol_p=0.02))

    # Stop simulation
    hil.stop_simulation()
def test_3ph_2w_transformer(load_and_compile, Vsin_yy, Vsin_dd, Vsin_yd, Vsin_dy, f, ss_yy_closed, ss_dd_closed, ss_yd_closed, ss_dy_closed, Vyy_expected, Iyy_expected, Vdd_expected, Idd_expected, Vyd_expected, Iyd_expected, Vdy_expected, Idy_expected):

    # Set source value
    hil.set_source_sine_waveform(name='Vsin_yy', rms=Vsin_yy, frequency=f)
    hil.set_source_sine_waveform(name='Vsin_dd', rms=Vsin_dd, frequency=f)
    hil.set_source_sine_waveform(name='Vsin_yd', rms=Vsin_yd, frequency=f)
    hil.set_source_sine_waveform(name='Vsin_dy', rms=Vsin_dy, frequency=f)

    hil.set_contactor('SS_yy', swControl=True, swState=ss_yy_closed)
    hil.set_contactor('SS_dd', swControl=True, swState=ss_dd_closed)
    hil.set_contactor('SS_yd', swControl=True, swState=ss_yd_closed)
    hil.set_contactor('SS_dy', swControl=True, swState=ss_dy_closed)

    # Start capture
    start_capture(duration=0.9, signals=['Vyy', 'Vyd', 'Vdy', 'Vdd','Iyy', 'Iyd','Idy', 'Idd'], executeAt=0)

    # Start simulation
    hil.start_simulation()

    # Data acquisition
    capture = get_capture_results(wait_capture=True)
    Vyy = capture['Vyy']
    Vyd = capture['Vyd']
    Vdy = capture['Vdy']
    Vdd = capture['Vdd']
    Iyy = capture['Iyy']
    Iyd = capture['Iyd']
    Idy = capture['Idy']
    Idd = capture['Idd']

    # Tests

    sig.assert_is_constant(Vyy, during=(0.41 - 0.0001, 0.41 + 0.0001), at_value=around(Vyy_expected, tol_p=0.02))
    sig.assert_is_constant(Vyd, during=(0.41 - 0.0001, 0.41 + 0.0001), at_value=around(Vyd_expected, tol_p=0.02))
    sig.assert_is_constant(Vdy, during=(0.41 - 0.0001, 0.41 + 0.0001), at_value=around(Vdy_expected, tol_p=0.02))
    sig.assert_is_constant(Vdd, during=(0.41 - 0.0001, 0.41 + 0.0001), at_value=around(Vdd_expected, tol_p=0.02))

    sig.assert_is_constant(Iyy, during=(0.8 - 0.0001, 0.8 + 0.0001), at_value=around(-Iyy_expected, tol_p=0.02))
    sig.assert_is_constant(Iyy, during=(0.81 - 0.0001, 0.81 + 0.0001), at_value=around(Iyy_expected, tol_p=0.02))

    sig.assert_is_constant(Iyd, during=(0.8 - 0.0001, 0.8 + 0.0001), at_value=around(-Iyd_expected, tol_p=0.02))
    sig.assert_is_constant(Iyd, during=(0.81 - 0.0001, 0.81 + 0.0001), at_value=around(Iyd_expected, tol_p=0.02))


    sig.assert_is_constant(Idy, during=(0.8 - 0.0001, 0.8 + 0.0001), at_value=around(-Idy_expected, tol_p=0.02))
    sig.assert_is_constant(Idy, during=(0.81 - 0.0001, 0.81 + 0.0001), at_value=around(Idy_expected, tol_p=0.02))

    sig.assert_is_constant(Idd, during=(0.8 - 0.0001, 0.8 + 0.0001), at_value=around(-Idd_expected, tol_p=0.02))
    sig.assert_is_constant(Idd, during=(0.81 - 0.0001, 0.81 + 0.0001), at_value=around(Idd_expected, tol_p=0.02))

    # Stop simulation
    hil.stop_simulation()
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_1_ph_4w_transformer(load_and_compile, Vt4w, f, Vt_4w_12_ac_expected,
                             Vt_4w_21_ac_expected, Vt_4w_22_ac_expected,
                             It_4w_12_ac_expected, It_4w_21_ac_expected,
                             It_4w_22_ac_expected):

    # Set source value
    hil.set_source_sine_waveform(name='Vt4w', rms=Vt4w, frequency=f)

    # Start capture
    start_capture(duration=0.5,
                  signals=[
                      'Vt_4w_12_ac', 'Vt_4w_21_ac', 'Vt_4w_22_ac',
                      'It_4w_12_ac', 'It_4w_21_ac', 'It_4w_22_ac'
                  ],
                  executeAt=0)

    # Start simulation
    hil.start_simulation()

    # Data acquisition
    capture = get_capture_results(wait_capture=True)
    Vt_4w_12_ac = capture['Vt_4w_12_ac']
    Vt_4w_21_ac = capture['Vt_4w_21_ac']
    Vt_4w_22_ac = capture['Vt_4w_22_ac']
    It_4w_12_ac = capture['It_4w_12_ac']
    It_4w_21_ac = capture['It_4w_21_ac']
    It_4w_22_ac = capture['It_4w_22_ac']

    # Tests

    sig.assert_is_constant(Vt_4w_12_ac,
                           during=(0.38 - 0.0001, 0.38 + 0.0001),
                           at_value=around(Vt_4w_12_ac_expected, tol_p=0.01))
    sig.assert_is_constant(Vt_4w_21_ac,
                           during=(0.38 - 0.0001, 0.38 + 0.0001),
                           at_value=around(Vt_4w_21_ac_expected, tol_p=0.01))
    sig.assert_is_constant(Vt_4w_22_ac,
                           during=(0.38 - 0.0001, 0.38 + 0.0001),
                           at_value=around(Vt_4w_22_ac_expected, tol_p=0.01))
    sig.assert_is_constant(It_4w_12_ac,
                           during=(0.268 - 0.0001, 0.268 + 0.0001),
                           at_value=around(It_4w_12_ac_expected, tol_p=0.01))
    sig.assert_is_constant(It_4w_21_ac,
                           during=(0.268 - 0.0001, 0.268 + 0.0001),
                           at_value=around(It_4w_21_ac_expected, tol_p=0.01))
    sig.assert_is_constant(It_4w_22_ac,
                           during=(0.268 - 0.0001, 0.268 + 0.0001),
                           at_value=around(It_4w_22_ac_expected, tol_p=0.01))

    # Stop simulation
    hil.stop_simulation()
Пример #30
0
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()