def test_single_ph_3w_transformer(compile_tse, ss3_value, ss4_value, expected_values, measurement_names): # Loading model frome function 'compile_tse' cpd_path = compile_tse hil.load_model(file=cpd_path, offlineMode=False, vhil_device=vhil) # Set switch state hil.set_contactor('SS3', swControl=True, swState=ss3_value) hil.set_contactor('SS4', swControl=True, swState=ss4_value) # Set source value. hil.set_source_sine_waveform(name='Vt3w', rms=110.0, frequency=50.0) # Start capture capture.start_capture(duration=0.1, signals=measurement_names, executeAt=0.6) # Start simulation hil.start_simulation() # Data acquisition cap_data = capture.get_capture_results(wait_capture=True) measurements=cap_data # Tests for i, expected_value in enumerate(expected_values): sig.assert_is_constant(measurements[measurement_names[i]], at_value=around(expected_values[i], tol_p=0.001)) # Stop simulation hil.stop_simulation()
def test_single_ph_2w_transformer(compile_tse, ss_value, expected, measurement_name): #Loading model frome funtion 'compile_tse' cpd_path = compile_tse hil.load_model(file=cpd_path, offlineMode=False, vhil_device=vhil) # Set switch state hil.set_contactor('SS1', swControl=True, swState=ss_value) hil.set_contactor('SS2', swControl=True, swState=ss_value) # Start simulation hil.start_simulation() capture.start_capture(duration=0.1, signals=[measurement_name], executeAt=1.0) # Data acquisition cap_data = capture.get_capture_results(wait_capture=True) measurement = cap_data[measurement_name] # Tests sig.assert_is_constant(measurement, at_value=around(expected, tol_p=0.001)) # Stop simulation hil.stop_simulation()
def load_and_compile(tse_path, use_vhil=True): 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=use_vhil)
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)
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()
def convert_compile_load(): # Comment this if don't wont to compile model again ################################################### # Convert the model converter = Converter("psim", netlist_path) tse_path = converter.convert_schema(compile_model=False) # 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)
def convert_compile_load(): # Comment this if don't wont to compile model again # ################################################### # # Convert the model converter = Converter("psim", netlist_path) tse_path = converter.convert_schema(compile_model=False)[0] 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)
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 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) hil.set_pv_input_file("SCP1", psim_tests_dir + '\\E50530_Thin_Film.ipvx', illumination=1000.0, temperature=25.0) # Start simulation hil.start_simulation() yield hil.stop_simulation()
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()
def load_model_on_hil(self): ''' Load model ''' hil_model_file = self.hil_model_dir + self.model_name + r" Target files/" + self.model_name + r".cpd" self.ts.log("Model File: %s" % hil_model_file) if os.path.isfile(hil_model_file): self.ts.log_debug("HIL model (.cpd) file exists!") else: self.ts.log_debug("HIL model (.cpd) file does not exist!") status = False return status if not cp.load_model(file=hil_model_file): self.ts.log_warning("HIL model (.cpd) did not load!") return False return True
cp.set_debug_level(level=1) cp.stop_simulation() model.get_hw_settings() if not model.load( r'D:/SVP/SVP 1.4.3 Directories 5-2-17/svp_energy_lab-loadsim/Lib/svpelab/Typhoon/ASGC.tse' ): print("Model did not load!") if not model.compile(): print("Model did not compile!") # first we need to load model cp.load_model( file=r'D:/SVP/SVP 1.4.3 Directories 5-2-17/svp_energy_lab-loadsim/Lib' r'/svpelab/Typhoon/ASGC Target files/ASGC.cpd') # we could also open existing settings file... cp.load_settings_file( file=r'D:/SVP/SVP 1.4.3 Directories 5-2-17/svp_energy_lab-loadsim/Lib/' r'svpelab/Typhoon/settings2.runx') # after setting parameter we could start simulation cp.start_simulation() # let the inverter startup sleeptime = 15 for i in range(1, sleeptime): print(( "Waiting another %d seconds until the inverter starts. Power = %f."
return (status, theta_array) def mean(numbers): return float(sum(numbers)) / max(len(numbers), 1) modelName = 'Banshee_Feeder_1_v3_simpleR' # Define Path #PATH = get_settings_dir_path() PATH = 'C:\\Typhoon\\012 t_cprj\\00 Project management\\10 Customer projects\\91 Lincoln Laboratory 2017_workshop\\91.10 docs\\PowerFlow_Feeder1_Calculations\\Banshee_Feeder_1_v3_simpleR Target files\\' # load compiled model in VIRTUAL HIL hil.load_model(file=PATH + 'Banshee_Feeder_1_v3_simpleR.cpd', vhil_device=True) # load settings file hil.load_settings_file(file=PATH + 'Settings.runx') simulationStep = hil.get_sim_step() #define capture time period = 5.0 / 60.0 #define number of samples nSamples = 500.0e3 #calculates decimation decimation = 1 #period/(simulationStep*nSamples) #decimation, numberOfChannels, numberOfSamples print "Decimation: ", decimation capturedDataBuffer = []