Exemplo n.º 1
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()
Exemplo n.º 2
0
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()
Exemplo n.º 3
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()
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()
Exemplo n.º 5
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()
Exemplo n.º 6
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()
Exemplo n.º 7
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()
Exemplo n.º 8
0
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)
Exemplo n.º 9
0
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()
Exemplo n.º 10
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)
Exemplo n.º 11
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_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()
Exemplo n.º 14
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()
Exemplo n.º 15
0
def load_cpd(compile_tse):
    cpd_path = compile_tse
    # Load to VHIL
    hil.load_model(file=cpd_path, offlineMode=False, vhil_device=vhil)

    # Set source value
    hil.set_source_sine_waveform(name='Vsin_ydd', rms=1000 / np.sqrt(3), frequency=50)
    hil.set_source_sine_waveform(name='Vsin_yyd', rms=1000 / np.sqrt(3), frequency=50)

    # Start simulation
    hil.start_simulation()

    yield

    # Stop simulation
    hil.stop_simulation()
def load_simulate(compile_tse):
    # Load to VHIL
    cpd_path = compile_tse
    hil.load_model(file=cpd_path, offlineMode=False, vhil_device=vhil)
    # Set source value.
    hil.set_source_sine_waveform(name='Vit', rms=110, frequency=50)
    hil.set_source_sine_waveform(name='Viti1', rms=220, frequency=50)

    # Start capture
    capture.start_capture(duration=0.1, signals=['Vit_ac', 'Viti_ac'], executeAt=0.2)

    # Start simulation
    hil.start_simulation()

    yield capture.get_capture_results(wait_capture=True)

    # 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()
Exemplo n.º 18
0
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()
Exemplo n.º 19
0
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()
Exemplo n.º 21
0
def test_capacitor_ac(convert_compile_load, IAC1, theta, f, C2, C3):

    VC2 = IAC1 / (2 * np.pi * f * C2) * np.sqrt(2)
    VC3 = IAC1 / (2 * np.pi * f * C3)

    # Start simulation
    hil.start_simulation()

    # Set source
    hil.set_source_sine_waveform(name='IAC1',
                                 rms=IAC1,
                                 frequency=f,
                                 phase=theta)
    hil.wait_msec(1000)

    # Test
    assert capture.read('VC2') == pytest.approx(expected=VC2, rel=1e-2)
    assert capture.read('VC3') == pytest.approx(expected=VC3, rel=1e-2)

    # Stop simulation
    hil.stop_simulation()
Exemplo n.º 22
0
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()
Exemplo n.º 23
0
def test_ac_cable(convert_compile_load, Vsin3ph, f, theta):

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

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

    # Start simulation
    hil.start_simulation()

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

    # Expected currents
    Iac_cable_exp = 42.771

    # Tests
    assert Iac_cable == pytest.approx(Iac_cable_exp, rel=1e-3)

    # 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()
Exemplo n.º 25
0
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))
Exemplo n.º 26
0
def convert_compile_load(convert_xml2tse):
    tse_path = convert_xml2tse
    cpd_path = tse_path[:-4] + " Target files\\" + tse_path.split(
        "\\")[-1][:-4] + ".cpd"
    # Open the converted tse file
    model.load(tse_path)
    # Compile the model
    model.compile()

    # Load to VHIL
    hil.load_model(file=cpd_path, offlineMode=False, vhil_device=vhil)

    # Set source value
    hil.set_source_sine_waveform(name='Vsin3ph',
                                 rms=220,
                                 frequency=50,
                                 phase=0)

    hil.start_simulation()

    yield

    # Stop simulation
    hil.stop_simulation()
Exemplo n.º 27
0
def test_3ph_bi_directional_switch(convert_compile_load, Vss, f, ss_value,
                                   Iss_exp):

    # Set source value
    hil.set_source_sine_waveform(name='V3ph_ss', 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 = np.mean(capture['Iss'])

    # Tests
    assert Iss == pytest.approx(Iss_exp, rel=1e-2, abs=0.2)

    # Stop simulation
    hil.stop_simulation()
Exemplo n.º 28
0
    def config_asymmetric_phase_angles(self, mag=None, angle=None):
        """
        :param mag: list of voltages for the imbalanced test, e.g., [277.2, 277.2, 277.2]
        :param angle: list of phase angles for the imbalanced test, e.g., [0, 120, -120]

        :returns: voltage list and phase list
        """
        if mag is not None:
            if type(mag) is not list:
                raise gridsim.GridSimError(
                    'Waveform magnitudes were not provided as list. "mag" type: %s'
                    % type(mag))

        if angle is not None:
            if type(angle) is list:
                cp.set_source_sine_waveform(self.waveform_source_list[0],
                                            rms=mag[0],
                                            phase=angle[0])
                cp.set_source_sine_waveform(self.waveform_source_list[1],
                                            rms=mag[1],
                                            phase=angle[1])
                cp.set_source_sine_waveform(self.waveform_source_list[2],
                                            rms=mag[2],
                                            phase=angle[2])
                cp.update_sources(self.waveform_source_list, executeAt=None)
                # cp.wait_msec(100.0)
                self.v = (v1 + v2 + v3) / 3
                self.v1 = v1
                self.v2 = v2
                self.v3 = v3

            else:
                raise gridsim.GridSimError(
                    'Waveform angles were not provided as list.')

        voltages = [self.v1, self.v2, self.v3]
        phases = angle
        return voltages, phases
Exemplo n.º 29
0
 def config_phase_angles(self):
     # set the phase angles for the 3 phases
     if len(self.waveform_source_list) == 1:  # single phase
         cp.set_source_sine_waveform(self.waveform_source_list[0],
                                     phase=0.0)
     elif len(self.waveform_source_list) == 2:  # split phase
         cp.set_source_sine_waveform(self.waveform_source_list[0],
                                     phase=0.0)
         cp.set_source_sine_waveform(self.waveform_source_list[1],
                                     phase=180.0)
     elif len(self.waveform_source_list) == 3:  # three phase
         cp.set_source_sine_waveform(self.waveform_source_list[0],
                                     phase=0.0)
         cp.set_source_sine_waveform(self.waveform_source_list[1],
                                     phase=-120.0)
         cp.set_source_sine_waveform(self.waveform_source_list[2],
                                     phase=120.0)
     else:
         self.ts.log_warning(
             'Phase angles not set for simulation because the number of grid simulation '
             'waveforms is not 1, 2, or 3.')