def callback_examine(self): mycmp=cmp_class() #ret=mycmp.init(self.sim_dir,get_exe_command()) ret=mycmp.init() if ret==False: error_dlg(self,_("Re-run the simulation with 'dump all slices' set to one to use this tool.")) return
def error_reported(self,sucess): self.label_reporting.hide() self.spin.hide() if sucess==True: error_dlg(self,"I have reported the error, for more information e-mail [email protected]") self.close() else: error_dlg(self,"I could not report the error please send the error message to [email protected]") self.close()
def callback_cluster_connect(self): if self.myserver.connect()==False: error_dlg(self,_("Can not connect to cluster.")) self.cluster_gui_update() if self.myserver.cluster==True: status_icon_stop(True) self.status_window.show() else: status_icon_stop(False) self.status_window.hide()
def build_mesh(self): self.x = [] self.y = [] data_min = 100.0 if self.tab.rowCount() != 0: for i in range(0, self.tab.rowCount()): val = float(tab_get_value(self.tab, i, 0)) if val < data_min: data_min = val # find max data_max = 0.0 for i in range(0, self.tab.rowCount()): val = float(tab_get_value(self.tab, i, 1)) if val > data_max: data_max = val w = data_min dx = (data_max - data_min) / (float(self.points)) for i in range(0, self.points): val = 0.0 for ii in range(0, self.tab.rowCount()): range_min = float(tab_get_value(self.tab, ii, 0)) range_max = float(tab_get_value(self.tab, ii, 1)) command = tab_get_value(self.tab, ii, 2) try: equ = eval(command) except: print(sys.exc_info()) error_dlg(self, _("You've made a mistake in the equation, use w for wavelength. " + command)) equ = -1 return if w >= range_min and w <= range_max: val = val + equ if val < 0.0: val = 1.0 self.x.append(w) self.y.append(val) w = w + dx a = open(os.path.join(self.path, self.out_file), "w") for i in range(0, len(self.y)): a.write(str(self.x[i]) + " " + str(self.y[i]) + "\n") a.close()
def tree_apply_click(self): index = self.dest_treeview.selectionModel().selectedRows() if len(index)>0: print("row=",index[0].row(),len(index)) pos=index[0].row() #print(path,scan_items_get_file(path),scan_items_get_token(path)) path=self.cal_path() file_name=scan_items_get_file(path) token=scan_items_get_token(path) print("adding",path,file_name,token) tab_set_value(self.dest_treeview,pos,0,file_name) tab_set_value(self.dest_treeview,pos,1,token) tab_set_value(self.dest_treeview,pos,2,path) self.close() else: error_dlg(self,"No row selected in the scan window, can't insert the selection")
def callback_next(self): help_window().help_set_help(["save.png",_("<big><b>Now save the simulation</b></big><br>Now select where you would like to save the simulation directory.")]) if len(self.window.listwidget.selectedItems())>0: file_path=save_as_gpvdm(self.window) if file_path!=None: selection=self.window.listwidget.selectedItems()[0].text() selection_file=selection[selection.find("(")+1:selection.find(")")] if not os.path.exists(file_path): os.makedirs(file_path) self.ret_path=file_path os.chdir(self.ret_path) gpvdm_clone(os.getcwd(),True) import_archive(os.path.join(get_device_lib_path(),selection_file),os.path.join(os.getcwd(),"sim.gpvdm"),False) self.window.close() else: error_dlg(self.window,_("Please select a device before clicking next"))
def save_model(self): thick=[] mat_file=[] dos_file=[] pl_file=[] name=[] for i in range(0,self.tab.rowCount()): name.append(str(tab_get_value(self.tab,i, 0))) thick.append(str(tab_get_value(self.tab,i, 1))) mat_file.append(str(tab_get_value(self.tab,i, 2))) dos_file.append(str(tab_get_value(self.tab,i, 4))) pl_file.append(str(tab_get_value(self.tab,i, 5))) ret=epitaxy_load_from_arrays(name,thick,mat_file,dos_file,pl_file) if ret==False: error_dlg(self,_("Error in epitaxy, check the input values.")) epitaxy_save() self.clean_dos_files()
def update_cb_model(self): self.cb_model.blockSignals(True) self.cb_model.clear() models=find_models() if len(models)==0: error_dlg(self,_("I can't find any optical plugins, I think the model is not installed properly.")) return for i in range(0, len(models)): self.cb_model.addItem(models[i]) used_model=inp_get_token_value("light.inp", "#light_model") print(models,used_model) if models.count(used_model)==0: used_model="exp" inp_update_token_value("light.inp", "#light_model","exp",1) self.cb_model.setCurrentIndex(self.cb_model.findText(used_model)) else: self.cb_model.setCurrentIndex(self.cb_model.findText(used_model)) scan_item_add("light.inp","#light_model","Optical model",1) self.cb_model.blockSignals(False)
def simulate(self,run_simulation,generate_simulations,args): base_dir=os.getcwd() run=True if self.tab.rowCount() == 0: error_dlg(self,_("You have not selected any parameters to scan through. Use the add button.")) return if self.sim_name=="": error_dlg(self,_("No sim dir name")) return self.make_sim_dir() if generate_simulations==True: scan_clean_dir(self,self.sim_dir) print("Running") program_list=[] for i in range(0,self.tab.rowCount()): program_list.append([tab_get_value(self.tab,i,0),tab_get_value(self.tab,i,1),tab_get_value(self.tab,i,3),tab_get_value(self.tab,i,4)]) print(program_list) tree_load_config(self.sim_dir) if generate_simulations==True: flat_simulation_list=[] if tree_gen(flat_simulation_list,program_list,base_dir,self.sim_dir)==False: error_dlg(self,_("Problem generating tree.")) return print("flat list",flat_simulation_list) tree_save_flat_list(self.sim_dir,flat_simulation_list) commands=tree_load_flat_list(self.sim_dir) print("loaded commands",commands) if run_simulation==True: self.send_commands_to_server(commands,args) self.save_combo() os.chdir(base_dir) gc.collect()
def fill_store(self): self.window.listwidget.clear() if os.path.isdir(self.dir)==False: error_dlg(self,_("The directory is gone, so I can't open it.")) for fl in os.listdir(self.dir): file_name=os.path.join(self.dir, fl) if os.path.isdir(file_name): if os.path.isfile(os.path.join(file_name,"mat.inp")): itm = QListWidgetItem( fl ) itm.setIcon(self.mat_icon) self.window.listwidget.addItem(itm) else: show_dir=True #if fl=="materials": # show_dir=False if os.path.isfile(os.path.join(file_name,"gpvdm_gui_config.inp"))==True: show_dir=False if show_dir==True: itm = QListWidgetItem( fl ) itm.setIcon(self.dir_icon) self.window.listwidget.addItem(itm) else: #append=False if (file_name.endswith(".dat")==True): f = open(file_name, 'rb') text = f.readline() f.close() #text=text.encode('utf-8').strip() #print(text) #text=text.rstrip() if len(text)>0: if text[len(text)-1]==10: text=text[:-1] if text==b"#gpvdm": itm = QListWidgetItem( fl ) itm.setIcon(self.dat_icon) self.window.listwidget.addItem(itm) if (file_name.endswith(".inp")==True) and self.show_inp_files==True: itm = QListWidgetItem( fl ) itm.setIcon(self.inp_icon) self.window.listwidget.addItem(itm) if (file_name.endswith(".spectra")==True): itm = QListWidgetItem( fl ) itm.setIcon(self.spectra_icon) self.window.listwidget.addItem(itm) if (file_name.endswith(".omat")==True): itm = QListWidgetItem( fl ) itm.setIcon(self.mat_icon) self.window.listwidget.addItem(itm) if file_name.endswith(".xlsx")==True or file_name.endswith(".xls")==True: itm = QListWidgetItem( fl ) itm.setIcon(self.xls_icon) self.window.listwidget.addItem(itm) if os.path.basename(file_name)=="sim_info.dat": itm = QListWidgetItem( fl ) itm.setIcon(self.info_icon) self.window.listwidget.addItem(itm)
def save(self): if self.update_contact_db()==True: contacts_save() self.changed.emit() else: error_dlg(self,_("There are some non numberic values in the table"))