def test_run(): result = script.RESULT_FAIL load = None try: load = loadsim.loadsim_init(ts) ts.log('Load device: %s' % load.info()) result = script.RESULT_COMPLETE except script.ScriptFail, e: reason = str(e) if reason: ts.log_error(reason)
def test_run(): result = script.RESULT_FAIL load = None try: load = loadsim.loadsim_init(ts) ts.log('Load device: %s' % load.info()) result = script.RESULT_COMPLETE except script.ScriptFail as e: reason = str(e) if reason: ts.log_error(reason) finally: if load is not None: load.close() return result
def test_run(): result = script.RESULT_FAIL eut = grid = load = pv = daq_rms = daq_wf = chil = None ### Correction as graph is not displayed ### <START> ### sc_points = ['AC_IRMS_MIN'] sc_points = ['TIME', 'AC_FREQ_1', 'AC_IRMS_1', 'AC_IRMS_MIN'] ### <END> # result params result_params = { 'plot.title': ts.name, 'plot.x.title': 'Time (secs)', 'plot.x.points': 'TIME', 'plot.y.points': 'AC_FREQ_1', 'plot.y.title': 'Frequency (Hz)', 'plot.y2.points': 'AC_IRMS_1, AC_IRMS_MIN', 'plot.y2.title': 'Current (A)' } try: test_label = ts.param_value('frt.test_label') # get test parameters freq_msa = ts.param_value('eut.freq_msa') p_rated = ts.param_value('eut.p_rated') v_nom = ts.param_value('eut.v_nom') t_msa = ts.param_value('eut.t_msa') t_dwell = ts.param_value('eut.frt_t_dwell') freq_nom = ts.param_value('eut.freq_nom') freq_grid_min = ts.param_value('frt.freq_grid_min') freq_grid_max = ts.param_value('frt.freq_grid_max') freq_test = ts.param_value('frt.freq_test') t_hold = ts.param_value('frt.t_hold') n_r = ts.param_value('frt.n_r') # calculate voltage adjustment based on msa freq_msa_adj = freq_msa * 1.5 if freq_test > freq_nom: # apply HFRT msa adjustments freq_n = freq_grid_min + freq_msa_adj freq_t = freq_test - freq_msa_adj else: # apply LFRT msa adjustments freq_n = freq_grid_max - freq_msa_adj freq_t = freq_test + freq_msa_adj # set power levels that are enabled power_levels = [] if ts.param_value('frt.p_100') == 'Enabled': power_levels.append((100, '100')) if ts.param_value('frt.p_20') == 'Enabled': power_levels.append((20, '20')) # initialize HIL environment, if necessary chil = hil.hil_init(ts) if chil is not None: chil.config() # grid simulator is initialized with test parameters and enabled grid = gridsim.gridsim_init(ts) profile_supported = False # In cases where the grid simulator has voltage rise/loss on the line to the EUT or operates through a # transformer, the nominal voltage of the grid simulator won't be the same as the EUT and a correction # factor is applied. try: v_nom_grid = grid.v_nom_param except Exception, e: v_nom_grid = v_nom ### grid.voltage((v_nom_grid, v_nom_grid, v_nom_grid)) <- Commented out because middleware is communicated using gridsim grid.voltageRH(v_nom_grid, v_nom_grid, v_nom_grid) # <- Change to control from grid # load simulator initialization load = loadsim.loadsim_init(ts) if load is not None: ts.log('Load device: %s' % load.info()) ### Commented out because middleware is communicated using gridsim ### <START> ### # pv simulator is initialized with test parameters and enabled ### pv = pvsim.pvsim_init(ts) ### pv.power_set(p_rated) ### pv.power_on() ### <END> # initialize rms data acquisition daq_rms = das.das_init(ts, 'das_rms', sc_points=sc_points) if daq_rms is not None: ts.log('DAS RMS device: %s' % (daq_rms.info())) daq_rms.sc['SC_TRIG'] = 0 daq_rms.sc['AC_IRMS_MIN'] = '' # initialize waveform data acquisition daq_wf = das.das_init(ts, 'das_wf') if daq_wf is not None: ts.log('DAS Waveform device: %s' % (daq_wf.info())) # it is assumed the EUT is on eut = der.der_init(ts) if eut is not None: eut.config() # perform all power levels for power_level in power_levels: # set test power level power = float(power_level[0]) / 100 * p_rated ### pv.power_set(power) <- Commented out because middleware is communicated using gridsim grid.power_set(power) # <- Change to control from grid ts.log('Setting power level to %s%% of rated' % (power_level[0])) if daq_rms is not None: ### daq_rms.sc['AC_IRMS_MIN'] = '' data = grid.wt3000_data_capture_read() daq_rms.sc['TIME'] = time.time( ) # <- Since the graph is not displayed, it is added daq_rms.sc['AC_FREQ_1'] = data.get( 'AC_FREQ_1' ) # <- Since the graph is not displayed, it is added daq_rms.sc['AC_IRMS_1'] = data.get( 'AC_IRMS_1' ) # <- Since the graph is not displayed, it is added irms = data.get( 'AC_IRMS_1' ) # <- Since the graph is not displayed, it is added daq_rms.sc['AC_IRMS_MIN'] = round( irms * .8, 2) # <- Since the graph is not displayed, it is added ts.log('Starting RMS data capture') daq_rms.data_capture(True) ts.log('Waiting 5 seconds to start test') ts.sleep(5) if profile_supported: # create and execute test profile profile = freq_rt_profile(v_nom=v_nom, freq_nom=freq_n / freq_nom, freq_t=freq_t / freq_nom, t_hold=t_hold, t_dwell=t_dwell, n=n_r) grid.profile_load(profile=profile) grid.profile_start() # create countdown timer start_time = time.time() profile_time = profile[-1][0] ts.log('Profile duration is %s seconds' % profile_time) while (time.time() - start_time) < profile_time: remaining_time = profile_time - (time.time() - start_time) ts.log('Sleeping for another %0.1f seconds' % remaining_time) sleep_time = min(remaining_time, 10) ts.sleep(sleep_time) grid.profile_stop() else: # execute test sequence ts.log('Test duration is %s seconds' % ((float(t_dwell) + float(t_hold)) * float(n_r) + float(t_dwell))) # get initial current level to determine threshold if daq_rms is not None: daq_rms.data_sample() ### data = daq_rms.data_capture_read() <- Commented out because middleware is communicated using gridsim data = grid.wt3000_data_capture_read( ) # <- Change to control from grid daq_rms.sc['TIME'] = time.time( ) # <- Since the graph is not displayed, it is added daq_rms.sc['AC_FREQ_1'] = data.get( 'AC_FREQ_1' ) # <- Since the graph is not displayed, it is added daq_rms.sc['AC_IRMS_1'] = data.get( 'AC_IRMS_1' ) # <- Since the graph is not displayed, it is added irms = data.get('AC_IRMS_1') if irms is not None: daq_rms.sc['AC_IRMS_MIN'] = round(irms * .8, 2) for i in range(n_r): grid.freq(freq=freq_n) ts.log('Setting frequency: freq = %s for %s seconds' % (freq_n, t_dwell)) ts.sleep(t_dwell) grid.freq(freq=freq_t) ts.log('Setting frequency: freq = %s for %s seconds' % (freq_t, t_hold)) ts.sleep(t_hold) grid.freq(freq=freq_n) ts.log('Setting frequency: freq = %s for %s seconds' % (freq_n, t_dwell)) ts.sleep(t_dwell) if daq_rms is not None: daq_rms.data_capture(False) ds = daq_rms.data_capture_dataset() test_name = '%s_rms_%s' % (test_label, power_level[1]) filename = '%s.csv' % (test_name) ds.to_csv(ts.result_file_path(filename)) result_params['plot.title'] = test_name ts.result_file(filename, params=result_params) ts.log('Saving data capture %s' % (filename)) result = script.RESULT_COMPLETE
def test_run(): result = script.RESULT_FAIL eut = grid = load = pv = daq_rms = daq_wf = chil = None ### Correction as graph is not displayed ### <START> ### sc_points = ['AC_IRMS_MIN'] sc_points = ['TIME', 'AC_VRMS_1', 'AC_IRMS_1', 'SC_TRIG', 'AC_IRMS_MIN'] ### <END> # result params result_params = { 'plot.title': ts.name, 'plot.x.title': 'Time (secs)', 'plot.x.points': 'TIME', 'plot.y.points': 'AC_VRMS_1', 'plot.y.title': 'Voltage (V)', 'plot.y2.points': 'AC_IRMS_1, AC_IRMS_MIN', 'plot.y2.title': 'Current (A)' } try: test_label = ts.param_value('vrt.test_label') # get test parameters phases = ts.param_value('eut.phases') p_rated = ts.param_value('eut.p_rated') v_nom = ts.param_value('eut.v_nom') v_msa = ts.param_value('eut.v_msa') t_msa = ts.param_value('eut.t_msa') t_dwell = ts.param_value('eut.vrt_t_dwell') v_grid_min = ts.param_value('vrt.v_grid_min') v_grid_max = ts.param_value('vrt.v_grid_max') v_test = ts.param_value('vrt.v_test') t_hold = ts.param_value('vrt.t_hold') n_r = ts.param_value('vrt.n_r') # calculate voltage adjustment based on msa v_msa_adj = v_msa * 1.5 if v_test > 100.0: # apply HVRT msa adjustments v_n = v_grid_min + v_msa_adj v_t = v_test - v_msa_adj else: # apply LVRT msa adjustments v_n = v_grid_max - v_msa_adj v_t = v_test + v_msa_adj # set power levels that are enabled power_levels = [] if ts.param_value('vrt.p_100') == 'Enabled': power_levels.append((100.0, '100')) if ts.param_value('vrt.p_20') == 'Enabled': power_levels.append((20.0, '20')) # set phase tests that are enabled phase_tests = [] # set single phase test voltages and test labels if phases == 'Single Phase': phase_tests.append(((v_t, v_n, v_n), 'Phase 1 Fault Test', 'p1')) # set 3-phase 3-wire/4-wire voltages and test label for each enabled test #??? calculation of 3/4 wire phase test levels if phases == '3-Phase 3-Wire' or phases == '3-Phase 4-Wire': if ts.param_value('vrt.phase_all') == 'Enabled': phase_tests.append( ((v_t, v_t, v_t), 'All Phase Fault Test', 'all')) if ts.param_value('vrt.phase_1') == 'Enabled': phase_tests.append( ((v_t, v_n, v_n), 'Phase 1 Fault Test', 'p1')) if ts.param_value('vrt.phase_2') == 'Enabled': phase_tests.append( ((v_n, v_t, v_n), 'Phase 2 Fault Test', 'p2')) if ts.param_value('vrt.phase_3') == 'Enabled': phase_tests.append( ((v_n, v_n, v_t), 'Phase 3 Fault Test', 'p3')) if phases == '3-Phase 4-Wire': if ts.param_value('vrt.phase_1_2') == 'Enabled': phase_tests.append( ((v_t, v_t, v_n), 'Phase 1-2 Fault Test', 'p12')) if ts.param_value('vrt.phase_2_3') == 'Enabled': phase_tests.append( ((v_n, v_t, v_t), 'Phase 2-3 Fault Test', 'p23')) if ts.param_value('vrt.phase_1_3') == 'Enabled': phase_tests.append( ((v_t, v_n, v_t), 'Phase 1-3 Fault Test', 'p13')) # initialize HIL environment, if necessary chil = hil.hil_init(ts) if chil is not None: chil.config() # grid simulator is initialized with test parameters and enabled grid = gridsim.gridsim_init(ts) profile_supported = False # In cases where the grid simulator has voltage rise/loss on the line to the EUT or operates through a # transformer, the nominal voltage of the grid simulator won't be the same as the EUT and a correction # factor is applied. try: v_nom_grid = grid.v_nom_param except Exception, e: v_nom_grid = v_nom # load simulator initialization load = loadsim.loadsim_init(ts) if load is not None: ts.log('Load device: %s' % load.info()) # pv simulator is initialized with test parameters and enabled ### pv = pvsim.pvsim_init(ts) ### pv.power_set(p_rated) ### pv.power_on() # initialize rms data acquisition daq_rms = das.das_init(ts, 'das_rms', sc_points=sc_points) if daq_rms is not None: ts.log('DAS RMS device: %s' % (daq_rms.info())) ### daq_rms.sc['SC_TRIG'] = 0 ### daq_rms.sc['AC_IRMS_MIN'] = '' # initialize waveform data acquisition daq_wf = das.das_init(ts, 'das_wf') if daq_wf is not None: ts.log('DAS Waveform device: %s' % (daq_wf.info())) # it is assumed the EUT is on eut = der.der_init(ts) if eut is not None: eut.config() # open result summary file ''' result_summary_filename = 'result_summary.csv' result_summary = open(ts.result_file_path(result_summary_filename), 'a+') ts.result_file(result_summary_filename) result_summary.write('Result, Test Name, Power Level, Phase, Dataset File\n') ''' # perform all power levels and phase tests for power_level in power_levels: # set test power level power = power_level[0] / 100 * p_rated ### pv.power_set(power) grid.power_set(power) ts.log('Setting power level to %s%% of rated' % (power_level[0])) ''' # initializing to nominal v = v_nom_grid ### grid.voltage((v, v, v)) grid.voltageRH(v, v, v) ts.log('Initializing to nominal voltage: v_1 = %s v_2 = %s v_3 = %s for %s seconds' % (v, v, v, t_dwell)) ts.sleep(t_dwell) ''' for phase_test in phase_tests: if daq_rms is not None: ### daq_rms.sc['AC_IRMS_MIN'] = '' data = grid.wt3000_data_capture_read( ) # <- Since the graph is not displayed, it is added daq_rms.sc['TIME'] = time.time( ) # <- Since the graph is not displayed, it is added daq_rms.sc['AC_VRMS_1'] = data.get( 'AC_VRMS_1' ) # <- Since the graph is not displayed, it is added daq_rms.sc['AC_IRMS_1'] = data.get( 'AC_IRMS_1' ) # <- Since the graph is not displayed, it is added daq_rms.sc[ 'SC_TRIG'] = '' # <- Since the graph is not displayed, it is added irms = data.get( 'AC_IRMS_1' ) # <- Since the graph is not displayed, it is added daq_rms.sc['AC_IRMS_MIN'] = round( irms * .8, 2) # <- Since the graph is not displayed, it is added ts.log('Starting RMS data capture') daq_rms.data_capture(True) ts.log('Waiting 5 seconds to start test') ts.sleep(5) v_1, v_2, v_3 = phase_test[0] ts.log('Starting %s, v1 = %s%% v2 = %s%% v3 = %s%%' % (phase_test[1], v_1, v_2, v_3)) if profile_supported: # create and execute test profile profile = voltage_rt_profile(v1_t=v_1, v2_t=v_2, v3_t=v_3, t_hold=t_hold, t_dwell=t_dwell, n=n_r) grid.profile_load(profile=profile) grid.profile_start() # create countdown timer start_time = time.time() profile_time = profile[-1][0] ts.log('Profile duration is %s seconds' % profile_time) while (time.time() - start_time) < profile_time: remaining_time = profile_time - (time.time() - start_time) ts.log('Sleeping for another %0.1f seconds' % remaining_time) sleep_time = min(remaining_time, 10) ts.sleep(sleep_time) grid.profile_stop() else: # execute test sequence ts.log('Test duration is %s seconds' % ((float(t_dwell) + float(t_hold)) * float(n_r) + float(t_dwell))) # get initial current level to determine threshold if daq_rms is not None: daq_rms.data_sample() ### data = daq_rms.data_capture_read() data = grid.wt3000_data_capture_read( ) # <- Since the graph is not displayed, it is added irms = data.get('AC_IRMS_1') if irms is not None: daq_rms.sc['TIME'] = time.time( ) # <- Since the graph is not displayed, it is added daq_rms.sc['AC_VRMS_1'] = data.get( 'AC_VRMS_1' ) # <- Since the graph is not displayed, it is added daq_rms.sc['AC_IRMS_1'] = data.get( 'AC_IRMS_1' ) # <- Since the graph is not displayed, it is added daq_rms.sc[ 'SC_TRIG'] = '' # <- Since the graph is not displayed, it is added daq_rms.sc['AC_IRMS_MIN'] = round(irms * .8, 2) ts.sleep(t_hold) for i in range(n_r): v = (v_n / 100) * v_nom_grid v1 = (v_1 / 100) * v_nom_grid v2 = (v_2 / 100) * v_nom_grid v3 = (v_3 / 100) * v_nom_grid ### grid.voltage((v, v, v)) grid.voltageRH(v, v, v) ts.log( 'Setting voltage: v_1 = %s v_2 = %s v_3 = %s for %s seconds' % (v, v, v, t_dwell)) ts.sleep(t_dwell) ### grid.voltage((v1, v2, v3)) grid.voltageRH(v1, v2, v3) ts.log( 'Setting voltage: v_1 = %s v_2 = %s v_3 = %s for %s seconds' % (v1, v2, v3, t_hold)) ts.sleep(t_hold) ### grid.voltage((v, v, v)) grid.voltageRH(v, v, v) ts.log( 'Setting voltage: v_1 = %s v_2 = %s v_3 = %s for %s seconds' % (v, v, v, t_dwell)) ts.sleep(t_dwell) if daq_rms is not None: daq_rms.data_capture(False) ds = daq_rms.data_capture_dataset() test_name = '%s_rms_%s_%s' % (test_label, phase_test[2], power_level[1]) filename = '%s.csv' % (test_name) ds.to_csv(ts.result_file_path(filename)) result_params['plot.title'] = test_name ts.result_file(filename, params=result_params) ts.log('Saving data capture %s' % (filename)) result = script.RESULT_COMPLETE
def test_run(): result = script.RESULT_FAIL grid = None load = None pv = None daq_rms = None daq_wf = None eut = None chil = None ### Correction as graph is not displayed ### <START> sc_points = ['TIME', 'AC_IRMS_1'] ### <END> # result params ### 'plot.title': 'title_name', result_params = { 'plot.title': ts.name, 'plot.x.title': 'Time (secs)', 'plot.x.points': 'TIME', 'plot.y.points': 'AC_IRMS_1', 'plot.y.title': 'Current (A)' } try: # read aist parameters s_version = ts.param_value('aist.script_version') l1_version = ts.param_value('aist.library_version_1') l2_version = ts.param_value('aist.library_version_2') l3_version = ts.param_value('aist.library_version_3') v_nom = ts.param_value('eut.v_nom') i_rated = ts.param_value('eut.i_rated') i_low = ts.param_value('eut.i_low') rr_up_min = ts.param_value('eut.rr_up_min') rr_up_max = ts.param_value('eut.rr_up_max') rr_msa = ts.param_value('eut.rr_msa') t_dwell = ts.param_value('eut.t_dwell') ramp_rates = [] if ts.param_value('rr.rr_max') == 'Enabled': ramp_rates.append(rr_up_max) if ts.param_value('rr.rr_mid') == 'Enabled': ramp_rates.append((rr_up_min + rr_up_max) / 2) if ts.param_value('rr.rr_min') == 'Enabled': ramp_rates.append(rr_up_min) soft_start = ts.param_value('rr.soft_start') == 'Enabled' n_r = ts.param_value('rr.n_r') v_trip = ts.param_value('rr.v_trip') t_reconnect = ts.param_value('rr.t_reconnect') p_low = i_low * v_nom p_rated = i_rated * v_nom ''' Test assumes the following steps have been performed: - Connect the EUT according to test requirements. - Set all AC source parameters to the nominal operating conditions for the EUT. - Turn on the EUT and allow to reach steady state. ''' # initialize HIL environment, if necessary chil = hil.hil_init(ts) if chil is not None: chil.config() # grid simulator is initialized with test parameters and enabled grid = gridsim.gridsim_init(ts) profile_supported = False # load simulator initialization load = loadsim.loadsim_init(ts) if load is not None: ts.log('Load device: %s' % load.info()) ### Commented out because middleware is communicated using gridsim ### <START> ### # pv simulator is initialized with test parameters and enabled ### pv = pvsim.pvsim_init(ts) ### pv.power_set(p_low) ### pv.power_on() ### <END> ### Commented out because middleware is communicated using gridsim ### <START> ### # batt simulator is initialized with test parameters and enabled ### batt = battsim.battsim_init(ts) ### batt.power_set(p_max) ### batt.power_on() ### <END> # initialize rms data acquisition ### daq_rms = das.das_init(ts, 'das_rms') daq_rms = das.das_init(ts, 'das_rms', sc_points=sc_points) if daq_rms is not None: ts.log('DAS RMS device: %s' % (daq_rms.info())) # initialize waveform data acquisition daq_wf = das.das_init(ts, 'das_wf') if daq_wf is not None: ts.log('DAS Waveform device: %s' % (daq_wf.info())) ### Commented out because middleware is communicated using gridsim ### <START> ### # it is assumed the EUT is on ### eut = der.der_init(ts) ### if eut is not None: ### eut.config() ### <END> if soft_start: test_label = 'ss' else: test_label = 'rr' # For each ramp rate test level in Table SA11.1 for rr in ramp_rates: duration = 100 / rr + (t_dwell * 2) if soft_start: # set soft start ramp rate ### Commented out because middleware is communicated using gridsim ### <START> ### if eut is not None: ### # eut.soft_start_ramp_rate(rr) ### batt.ramp_rates(params={'power': 0 ,'ramp_rate': rr * 100}) <- Commented out because middleware is communicated using gridsim grid.ramp_rates(params={ 'power': 0, 'ramp_rate': rr * 100 }) # <- Change to control from grid ### <END> sample_duration = duration + TRIP_WAIT_DELAY + t_reconnect else: # set normal ramp rate ### Commented out because middleware is communicated using gridsim ### <START> ### if eut is not None: ### # eut.ramp_rate(rr) ### batt.ramp_rates(params={'power': 0 ,'ramp_rate': rr * 100}) <- Commented out because middleware is communicated using gridsim grid.ramp_rates(params={ 'power': 0, 'ramp_rate': rr * 100 }) # <- Change to control from grid ### <END> sample_duration = duration + POWER_WAIT_DELAY for count in range(1, n_r + 1): if daq_rms is not None: data = grid.wt3000_data_capture_read( ) # <- Since the graph is not displayed, it is added daq_rms.sc['TIME'] = time.time( ) # <- Since the graph is not displayed, it is added daq_rms.sc['AC_IRMS_1'] = data.get( 'AC_IRMS_1' ) # <- Since the graph is not displayed, it is added ts.log('Starting data capture %s' % (rr)) daq_rms.data_capture(True) ts.log('Waiting for 3 seconds to start test') ts.sleep(3) if soft_start: # set soft start ramp rate ### batt.ramp_rates(params={'power': p_rated ,'ramp_rate': rr * 100}) <- Commented out because middleware is communicated using gridsim grid.ramp_rates(params={ 'power': p_rated, 'ramp_rate': rr * 100 }) # <- Change to control from grid # set to trip voltage ### Commented out because middleware is communicated using gridsim ### <START> ### v1, v2, v3 = grid.voltage() ### ts.log('Waiting for 5 seconds to start test') ### ts.sleep(5) ### v1, v2, v3 = grid.voltageRR() ### ts.sleep(5) v1, v2, v3 = grid.voltageRR( ) # <- Change to control from grid ### <END> ts.log('Nominal voltage V1= %s' % (v1)) ts.log('Nominal voltage V2= %s' % (v2)) ts.log('Nominal voltage V3= %s' % (v3)) ### v_trip_grid = (v1 * v_trip/100) # <- Adapted to library type v_trip_grid = (float(v1) * float(v_trip) / 100 ) # <- Adapted to library type ### grid.voltage((v_trip_grid, v2, v3)) ts.log('Setting voltage to trip voltage (%s V)' % v_trip_grid) ### for test ts.log('Waiting for 5 seconds to start test') ### for test ts.sleep(5) ### for test ts.log('Nominal voltage V1= %s' % (v_trip_grid)) ### for test ts.log('Nominal voltage V2= %s' % (v2)) ### for test ts.log('Nominal voltage V3= %s' % (v3)) grid.voltageRR(str(v_trip_grid), str(v2), str(v3)) ts.log('Waiting %s seconds' % (TRIP_WAIT_DELAY)) ts.sleep(TRIP_WAIT_DELAY) ts.log( 'Setting voltage to original nominal voltage (%s V)' % v1) ### grid.voltage((v1, v2, v3)) <- Commented out because middleware is communicated using gridsim grid.voltageRR(str(v1), str(v2), str(v3)) # <- Change to control from grid else: ts.log('Setting to low power threshold (%s W)' % p_low) ### pv.power_set(p_low) <- Commented out because middleware is communicated using gridsim ### batt.ramp_rates(params={'power': p_low ,'ramp_rate': rr * 100}) <- Commented out because middleware is communicated using gridsim grid.ramp_rates(params={ 'power': p_low, 'ramp_rate': rr * 100 }) # <- Change to control from grid ts.log('Waiting for %s seconds' % (POWER_WAIT_DELAY)) ts.sleep(POWER_WAIT_DELAY) ts.log('Ramp rate: %s%%/sec - pass %s' % (rr, count)) ts.log('Setting to I_rated: %s' % (i_rated)) ### pv.power_set(p_rated) <- Commented out because middleware is communicated using gridsim ### batt.ramp_rates(params={'power': p_rated ,'ramp_rate': rr * 100}) <- Commented out because middleware is communicated using gridsim grid.ramp_rates(params={ 'power': p_rated, 'ramp_rate': rr * 100 }) # <- Change to control from grid ts.log('Sampling for %s seconds' % (sample_duration)) ts.sleep(sample_duration) if daq_rms is not None: daq_rms.data_sample( ) # <- Since the graph is not displayed, it is added data = grid.wt3000_data_capture_read( ) # <- Since the graph is not displayed, it is added daq_rms.sc['TIME'] = time.time( ) # <- Since the graph is not displayed, it is added daq_rms.sc['AC_IRMS_1'] = data.get( 'AC_IRMS_1' ) # <- Since the graph is not displayed, it is added # Increase available input power to I_rated ts.log('Sampling complete') daq_rms.data_capture(False) ds = daq_rms.data_capture_dataset() test_name = '%s_%s_%s' % (test_label, str( int(rr)), str(count)) filename = '%s.csv' % (test_name) ds.to_csv(ts.result_file_path(filename)) result_params['plot.title'] = test_name ts.result_file(filename, params=result_params) ts.log('Saving data capture %s' % (filename)) result = script.RESULT_COMPLETE except script.ScriptFail, e: reason = str(e) if reason: ts.log_error(reason)
def test_run(): result = script.RESULT_FAIL grid = None load = None pv = None daq_rms = None daq_wf = None eut = None try: v_nom = ts.param_value('eut.v_nom') i_rated = ts.param_value('eut.i_rated') i_low = ts.param_value('eut.i_low') rr_up_min = ts.param_value('eut.rr_up_min') rr_up_max = ts.param_value('eut.rr_up_max') rr_msa = ts.param_value('eut.rr_msa') t_dwell = ts.param_value('eut.t_dwell') ramp_rates = [] if ts.param_value('rr.rr_max') == 'Enabled': ramp_rates.append(rr_up_max) if ts.param_value('rr.rr_mid') == 'Enabled': ramp_rates.append((rr_up_min + rr_up_max) / 2) if ts.param_value('rr.rr_min') == 'Enabled': ramp_rates.append(rr_up_min) soft_start = ts.param_value('rr.soft_start') == 'Enabled' n_r = ts.param_value('rr.n_r') v_trip = ts.param_value('rr.v_trip') t_reconnect = ts.param_value('rr.t_reconnect') p_low = i_low * v_nom p_rated = i_rated * v_nom ''' Test assumes the following steps have been performed: - Connect the EUT according to test requirements. - Set all AC source parameters to the nominal operating conditions for the EUT. - Turn on the EUT and allow to reach steady state. ''' # grid simulator is initialized with test parameters and enabled grid = gridsim.gridsim_init(ts) profile_supported = False # load simulator initialization load = loadsim.loadsim_init(ts) if load is not None: ts.log('Load device: %s' % load.info()) # pv simulator is initialized with test parameters and enabled pv = pvsim.pvsim_init(ts) pv.power_set(p_low) pv.power_on() # initialize rms data acquisition daq_rms = das.das_init(ts, 'das_rms') if daq_rms is not None: ts.log('DAS RMS device: %s' % (daq_rms.info())) # initialize waveform data acquisition daq_wf = das.das_init(ts, 'das_wf') if daq_wf is not None: ts.log('DAS Waveform device: %s' % (daq_wf.info())) # it is assumed the EUT is on eut = der.der_init(ts) if eut is not None: eut.config() if soft_start: test_str = 'ss' else: test_str = 'rr' # For each ramp rate test level in Table SA11.1 for rr in ramp_rates: duration = 100 / rr + (t_dwell * 2) if soft_start: # set soft start ramp rate if eut is not None: eut.soft_start_ramp_rate(rr) sample_duration = duration + TRIP_WAIT_DELAY + t_reconnect else: # set normal ramp rate if eut is not None: eut.ramp_rate(rr) sample_duration = duration + POWER_WAIT_DELAY for count in range(1, n_r + 1): if daq_rms is not None: ts.log('Starting data capture %s' % (rr)) daq_rms.data_capture(True) if soft_start: # set to trip voltage v1, v2, v3 = grid.voltage() ts.log('Nominal voltage = %s' % (v1)) ts.log('Setting voltage to trip voltage (%s V)' % (v1 * v_trip / 100)) grid.voltage((v_trip, v2, v3)) ts.log('Waiting %s seconds' % (TRIP_WAIT_DELAY)) ts.sleep(TRIP_WAIT_DELAY) ts.log( 'Setting voltage to original nominal voltage (%s V)' % v1) grid.voltage((v1, v2, v3)) else: ts.log('Setting to low power threshold (%s W)' % p_low) pv.power_set(p_low) ts.log('Waiting for %s seconds' % (POWER_WAIT_DELAY)) ts.sleep(POWER_WAIT_DELAY) ts.log('Ramp rate: %s%%/sec - pass %s' % (rr, count)) ts.log('Setting to I_rated: %s' % (i_rated)) pv.power_set(p_rated) ts.log('Sampling for %s seconds' % (sample_duration)) ts.sleep(sample_duration) if daq_rms is not None: # Increase available input power to I_rated ts.log('Sampling complete') daq_rms.data_capture(False) ds = daq_rms.data_capture_dataset() filename = '%s_%s_%s.csv' % (test_str, str( int(rr)), str(count)) ds.to_csv(ts.result_file_path(filename)) ts.result_file(filename) ts.log('Saving data capture %s' % (filename)) result = script.RESULT_COMPLETE except script.ScriptFail, e: reason = str(e) if reason: ts.log_error(reason)
def test_run(): result = script.RESULT_FAIL eut = grid = load = pv = daq_rms = daq_wf = None try: test_label = ts.param('frt') # get test parameters freq_msa = ts.param_value('eut.freq_msa') v_nom = ts.param_value('eut.v_nom') t_msa = ts.param_value('eut.t_msa') t_dwell = ts.param_value('eut.frt_t_dwell') freq_nom = ts.param_value('frt.freq_nom') freq_grid_min = ts.param_value('frt.freq_grid_min') freq_grid_max = ts.param_value('frt.freq_grid_max') freq_test = ts.param_value('frt.freq_test') t_hold = ts.param_value('frt.t_hold') n_r = ts.param_value('frt.n_r') # calculate voltage adjustment based on msa freq_msa_adj = freq_msa * 1.5 if freq_test > freq_nom: # apply HFRT msa adjustments freq_n = freq_grid_min + freq_msa_adj freq_t = freq_test - freq_msa_adj else: # apply LFRT msa adjustments freq_n = freq_grid_max - freq_msa_adj freq_t = freq_test + freq_msa_adj # set power levels that are enabled power_levels = [] if ts.param_value('frt.p_100') == 'Enabled': power_levels.append((100, '100')) if ts.param_value('frt.p_20') == 'Enabled': power_levels.append((20, '20')) # grid simulator is initialized with test parameters and enabled grid = gridsim.gridsim_init(ts) profile_supported = False grid.voltage((v_nom, v_nom, v_nom)) # load simulator initialization load = loadsim.loadsim_init(ts) ts.log('Load device: %s' % load.info()) # pv simulator is initialized with test parameters and enabled pv = pvsim.pvsim_init(ts) pv.power_set(p_rated) pv.power_on() # initialize rms data acquisition daq_rms = das.das_init(ts, 'das_rms') if daq_rms is not None: ts.log('DAS RMS device: %s' % (daq_rms.info())) # initialize waveform data acquisition daq_wf = das.das_init(ts, 'das_wf') if daq_wf is not None: ts.log('DAS Waveform device: %s' % (daq_wf.info())) # it is assumed the EUT is on eut = der.der_init(ts) eut.config() # perform all power levels for power_level in power_levels: # set test power level power = power_level[0] / 100 * p_rated pv.power_set(power) ts.log('Setting power level to %s%% of rated, waiting 5 seconds' % (power_level[0])) # delay to allow power change to take effect ts.sleep(5) if daq_rms is not None: ts.log('Starting RMS data capture') daq_rms.data_capture(True) if profile_supported: # create and execute test profile profile = freq_rt_profile(v_nom=v_nom, freq_nom=freq_n / freq_nom, freq_t=freq_t / freq_nom, t_hold=t_hold, t_dwell=t_dwell, n=n_r) grid.profile_load(profile=profile) grid.profile_start() # create countdown timer start_time = time.time() profile_time = profile[-1][0] ts.log('Profile duration is %s seconds' % profile_time) while (time.time() - start_time) < profile_time: remaining_time = profile_time - (time.time() - start_time) ts.log('Sleeping for another %0.1f seconds' % remaining_time) sleep_time = min(remaining_time, 10) ts.sleep(sleep_time) grid.profile_stop() else: # execute test sequence ts.log('Test duration is %s seconds' % ((float(t_dwell) + float(t_hold)) * float(n_r) + float(t_dwell))) for i in range(n_r): grid.freq(freq=freq_n) ts.log('Setting frequency: freq = %s for %s seconds' % (freq_n, t_dwell)) ts.sleep(t_dwell) grid.voltage(freq=freq_t) ts.log('Setting frequency: freq = %s for %s seconds' % (freq_t, t_hold)) ts.sleep(t_hold) grid.freq(freq=freq_n) ts.log('Setting frequency: freq = %s for %s seconds' % (freq_n, t_dwell)) ts.sleep(t_dwell) if daq_rms is not None: daq_rms.data_capture(False) ds = daq_rms.data_capture_dataset() filename = '%s_rms_%s.csv' % (test_label, power_level[1]) ds.to_csv(ts.result_file_path(filename)) ts.result_file(filename) ts.log('Saving data capture %s' % (filename)) result = script.RESULT_COMPLETE except script.ScriptFail, e: reason = str(e) if reason: ts.log_error(reason)