def check_edit_material(self): if self.lineEdit_selected_material_name.text() == "": title = "None material selected" message = "Select a material in the material list to be edited." PrintMessageInput([title, message, window_title]) return # if self.selected_material_to_edit(): # return if self.editing: parameters = { "name": self.lineEdit_name_edit, "identifier": self.lineEdit_id_edit.text(), "density": self.lineEdit_density_edit, "young_modulus": self.lineEdit_youngModulus_edit, "poisson": self.lineEdit_poisson_edit, "thermal expansion coefficient": self.lineEdit_thermal_expansion_coefficient_edit, "color": self.lineEdit_color_edit } if self.check_add_edit(parameters): PrintMessageInput([self.title, self.message, window_title])
def default_library_gases(self): try: from ctREFPROP.ctREFPROP import REFPROPFunctionLibrary self.list_gases = {} self.fluid_file_to_final_name = {} refProp_path = os.environ['RPPREFIX'] if os.path.exists(refProp_path): self.RefProp = REFPROPFunctionLibrary(refProp_path) self.RefProp.SETPATHdll(refProp_path) refProp_fluids_path = get_new_path(refProp_path, "FLUIDS") list_files = os.listdir(refProp_fluids_path) for fluid_file in list_files: if ".BNC" not in fluid_file: filepath = get_new_path(refProp_fluids_path, fluid_file) f = open(filepath, 'r') line_0 = f.readline() line_1 = f.readline() line_2 = f.readline() f.close() short_name = line_0.split("!")[0] full_name = line_2.split("!")[0] letter = " " while letter == " ": short_name = short_name[:-1] letter = short_name[-1] letter = " " while letter == " ": full_name = full_name[:-1] letter = full_name[-1] final_name = short_name if short_name == full_name else f"{short_name} ({full_name})" self.list_gases[final_name] = [ fluid_file, short_name, full_name ] self.fluid_file_to_final_name[fluid_file] = final_name else: title = "REFPROP installation not detected" message = "Dear user, REFPROP application files were not found in the computer's default paths. " message += "Please, install the REFPROP on your computer to enable the set-up of the fluids mixture." PrintMessageInput([title, message, "ERROR"]) return True except Exception as log_error: title = "Error while loading REFPROP" message = "An error has been reached while trying to load REFPROP data. If the REFPROP module has already been " message += "installed we recommend running the 'pip install ctREFPROP' command at the terminal to install the " message += "necessary libraries." message += f"\n\n{str(log_error)}" PrintMessageInput([title, message, "ERROR"]) return True
def check_input_parameters(self, input_string, label, _float=True): title = "INPUT ERROR" value_string = input_string if value_string != "": try: if _float: value = float(value_string) else: value = int(value_string) if value < 0: message = "You cannot input a negative value to the {}.".format( label) PrintMessageInput([title, message, window_title1]) return True else: self.value = value except Exception: message = "You have typed an invalid value to the {}.".format( label) PrintMessageInput([title, message, window_title1]) return True else: title = "Empty entry to the " + label message = "Please, input a valid " + label + " value to continue." PrintMessageInput([title, message, window_title1]) self.tabWidget_element_type.setCurrentWidget(self.tab_damping) self.value = None return True return False
def check_complex_entries(self, lineEdit_real, lineEdit_imag): self.stop = False title = "Invalid entry to the acoustic pressure" if lineEdit_real.text() != "": try: real_F = float(lineEdit_real.text()) except Exception: message = "Wrong input for real part of acoustic pressure." PrintMessageInput([title, message, window_title_1]) self.lineEdit_acoustic_pressure_real.setFocus() self.stop = True return else: real_F = 0 if lineEdit_imag.text() != "": try: imag_F = float(lineEdit_imag.text()) except Exception: message = "Wrong input for imaginary part of acoustic pressure." PrintMessageInput([title, message, window_title_1]) self.lineEdit_acoustic_pressure_imag.setFocus() self.stop = True return else: imag_F = 0 if real_F == 0 and imag_F == 0: return None else: return real_F + 1j * imag_F
def reset_node(self): self.dict_node_to_compressor_excitation = self.project.file.get_dict_of_compressor_excitation_from_file( ) if self.node_ID_remove is None: node_id = self.lineEdit_node_ID_info.text() if node_id == "": title = "EMPTY NODE SELECTION" message = "You should to select a node from the list before continue." PrintMessageInput([title, message, window_title_2]) return else: self.selected_node = int(node_id) else: self.selected_node = self.node_ID_remove try: self.project.reset_compressor_info_by_node(self.selected_node) if self.remove_message: title = "Compressor excitation removal finished" message = f"The compressor excitation attributed to \n" message += f"the {self.selected_node} node has been removed." PrintMessageInput([title, message, window_title_2]) self.load_compressor_excitation_tables_info() self.opv.updateRendererMesh() except Exception as log_error: title = "Error while removing compressor excitation from node" message = "An error has been detected during the compressor \n" message += "excitation removal from selected node.\n\n" message += str(log_error) PrintMessageInput([title, message, window_title_1]) self.remove_message = True
def check_input_parameters(self, lineEdit, label, _float=True): title = "INPUT ERROR" value_string = lineEdit.text() if value_string != "": try: if _float: value = float(value_string) else: value = int(value_string) if value < 0: message = "You cannot input a negative value to the {}.".format( label) PrintMessageInput([title, message, window_title_1]) return True else: self.value = value except Exception: message = "You have typed an invalid value to the {}.".format( label) PrintMessageInput([title, message, window_title_1]) return True else: message = "None value has been typed to the {}.".format(label) PrintMessageInput([title, message, window_title_1]) return True return False
def check_complex_entries(self, lineEdit_real, lineEdit_imag, label): self.stop = False if lineEdit_real.text() != "": try: _real = float(lineEdit_real.text()) except Exception: window_title = "ERROR" title = f"Invalid entry to the {label}" message = f"Wrong input for real part of {label}." PrintMessageInput([title, message, window_title]) self.stop = True return else: _real = 0 if lineEdit_imag.text() != "": try: _imag = float(lineEdit_imag.text()) except Exception: window_title = "ERROR" title = f"Invalid entry to the {label}" message = f"Wrong input for imaginary part of {label}." PrintMessageInput([title, message, window_title]) self.stop = True return else: _imag = 0 if _real == 0 and _imag == 0: return None else: return _real + 1j * _imag
def selected_material_to_remove(self): try: if self.clicked_item is None: self.title = "NO MATERIAL SELECTION" self.message = "Select a material in the list to be removed." PrintMessageInput([self.title, self.message, window_title]) return True else: self.lineEdit_name_remove.setText(self.clicked_item.text(0)) self.lineEdit_id_remove.setText(self.clicked_item.text(1)) self.lineEdit_density_remove.setText(self.clicked_item.text(2)) self.lineEdit_youngModulus_remove.setText( self.clicked_item.text(3)) self.lineEdit_poisson_remove.setText(self.clicked_item.text(4)) self.lineEdit_thermal_expansion_coefficient_remove.setText( self.clicked_item.text(5)) self.lineEdit_color_remove.setText(self.clicked_item.text(6)) except Exception as error_log: self.title = "ERROR WHILE LOADING THE MATERIAL LIST DATA" self.message = str(error_log) PrintMessageInput([self.title, self.message, window_title]) return True return False
def confirm_and_generate_mesh(self): if self.check_element_size_input_value(): return if self.check_geometry_tolerance_input_value(): return if self.new_element_size > 0: if self.lineEdit_current_element_size.text( ) == self.lineEdit_new_element_size.text(): title = "Same element size" message = "Please, you should to insert a different value at the " message += "'New element size' input field to update the model." PrintMessageInput([title, message, window_title_1]) return else: self.print_error_message("element size", 'New element size') if self.geometry_tolerance > 0: pass else: self.print_error_message("geometry tolerance", 'Mesh tolerance') self.process_intermediate_actions() if len(self.dict_non_mapped_bcs) > 0: title = "Error while mapping boundary conditions" message = "The boundary conditions associated to the following nodal coordinates cannot be mapped directly after remesh:\n\n" for coord in list(self.dict_non_mapped_bcs.keys()): message += f"{coord};\n" message = message[:-2] message += ".\n\nPress the Return button if you want to change the element size and process remapping once, press the" message += "Remove button to remove unmapped boundary conditions or press Close button to abort the mesh operation." read = CallDoubleConfirmationInput(title, message, leftButton_label='Remove', rightButton_label='Return') if read._doNotRun: self.process_intermediate_actions(undo_remesh=True, mapping=False) elif read._stop: self.process_final_actions() title = "Removal of unmapped boundary conditions" message = "The boundary conditions associated to the following nodal coordinates " message += "has been removed from the current model setup:\n\n" for coord in list(self.dict_non_mapped_bcs.keys()): message += f"{coord};\n" message = message[:-2] message += ".\n\nPlease, take this information into account henceforward." PrintMessageInput([title, message, window_title_2]) elif read._continue: self.process_intermediate_actions(undo_remesh=True, mapping=False) return else: self.process_final_actions() self.project.time_to_load_or_create_project = time() - self.t0 self.close()
def check_complex_entries(self, lineEdit_real, lineEdit_imag, label): self.stop = False if lineEdit_real.text() != "": try: _real = float(lineEdit_real.text()) except Exception: window_title ="ERROR" title = f"Invalid entry to the {label}" message = f"Wrong input for real part of {label}." PrintMessageInput([title, message, window_title]) lineEdit_real.setFocus() self.stop = True return else: _real = None if lineEdit_imag.text() != "": try: _imag = float(lineEdit_imag.text()) except Exception: window_title ="ERROR" title = f"Invalid entry to the {label}" message = f"Wrong input for imaginary part of {label}." PrintMessageInput([title, message, window_title]) lineEdit_imag.setFocus() self.stop = True return else: _imag = None if label == 'all dofs': if _real is None and _imag is None: value = None elif _real is None: value = 1j*_imag elif _imag is None: value = complex(_real) else: value = _real + 1j*_imag output = [value, value, value, value, value, value] else: if _real is None and _imag is None: output = None elif _real is None: output = 1j*_imag elif _imag is None: output = complex(_real) else: output = _real + 1j*_imag return output
def open_gitHub_repository(self): title = "Error reached while trying to access the project repository" try: url = QUrl('https://github.com/open-pulse/OpenPulse') if not QDesktopServices.openUrl(url): message = "The OpenPulse repository at the GitHub's site cannot be accessed.\n" message += "We reccomend trying again later." PrintMessageInput([title, message, "ERROR"]) except Exception as log_error: message = str(log_error) PrintMessageInput([title, message, "OpenPulse"])
def confirm_material_attribution(self): if self.clicked_item is None: self.title = "NO MATERIAL SELECTION" self.message = "Select a material in the list before \nconfirming the material attribution." PrintMessageInput([self.title, self.message, window_title]) return try: name = self.clicked_item.text(0) identifier = int(self.clicked_item.text(1)) density = float(self.clicked_item.text(2)) young = float(self.clicked_item.text(3)) * (10**(9)) poisson = float(self.clicked_item.text(4)) thermal_expansion_coefficient = float(self.clicked_item.text(5)) color = self.clicked_item.text(6) new_material = Material( name, density, poisson_ratio=poisson, young_modulus=young, identifier=identifier, thermal_expansion_coefficient=thermal_expansion_coefficient, color=color) self.material = new_material if self.flagSelectedLines: lineEdit = self.lineEdit_selected_ID.text() self.stop, self.lines_typed = self.before_run.check_input_LineID( lineEdit) if self.stop: return True self.project.set_material_by_lines(self.lines_typed, self.material) print("[Set Material] - {} defined in the entities {}".format( self.material.name, self.lines_typed)) # self.opv.changeColorEntities(self.lines_typed, self.material.getNormalizedColorRGB()) else: self.project.set_material_to_all_lines(self.material) print("[Set Material] - {} defined in all entities".format( self.material.name)) # self.opv.changeColorEntities(entities, self.material.getNormalizedColorRGB()) self.close() except Exception as error_log: self.title = "ERROR WITH THE MATERIAL LIST DATA" self.message = str(error_log) PrintMessageInput([self.title, self.message, window_title]) return
def load_table(self, lineEdit, load_label, direct_load=False): window_title = "ERROR" title = "Error reached while loading table" try: if direct_load: self.path_imported_table = lineEdit.text() else: window_label = 'Choose a table to import the {} nodal load'.format( load_label) self.path_imported_table, _ = QFileDialog.getOpenFileName( None, window_label, self.userPath, 'Files (*.csv; *.dat; *.txt)') if self.path_imported_table == "": return None, None self.imported_filename = os.path.basename(self.path_imported_table) lineEdit.setText(self.path_imported_table) imported_file = np.loadtxt(self.path_imported_table, delimiter=",") if imported_file.shape[1] < 2: message = "The imported table has insufficient number of columns. The spectrum \n" message += "data must have frequencies, real and imaginary columns." PrintMessageInput([title, message, window_title]) lineEdit.setFocus() return None, None self.imported_values = imported_file[:, 1] + 1j * imported_file[:, 2] if imported_file.shape[1] > 2: self.frequencies = imported_file[:, 0] self.f_min = self.frequencies[0] self.f_max = self.frequencies[-1] self.f_step = self.frequencies[1] - self.frequencies[0] if self.project.change_project_frequency_setup( self.imported_filename, list(self.frequencies)): self.stop = True return None, None else: self.project.set_frequencies(self.frequencies, self.f_min, self.f_max, self.f_step) self.stop = False return self.imported_values, self.imported_filename except Exception as log_error: message = str(log_error) PrintMessageInput([title, message, window_title]) lineEdit.setFocus() return None, None
def get_information(self): try: if self.lineEdit_selected_ID.text() != "": # key = self.lineEdit_selected_ID.text() read = GetInformationOfGroup(self.project, self.selected_key) else: title = "UNSELECTED GROUP OF LINES" message = "Please, select a group in the list to get the information." PrintMessageInput([title, message, window_title2]) except Exception as e: title = "ERROR WHILE GETTING INFORMATION OF SELECTED GROUP" message = str(e) PrintMessageInput([title, message, window_title1])
def ExportResults(self): if self.lineEdit_FileName.text() != "": if self.save_path != "": self.export_path_folder = self.save_path + "/" else: title = "Additional action required" message = "Plese, choose a folder before trying export the results!" PrintMessageInput([title, message, window_title_2]) return else: title = "Additional action required" message = "Inform a file name before trying export the results!" PrintMessageInput([title, message, window_title_2]) return self.check(export=True) freq = self.frequencies self.export_path = self.export_path_folder + self.lineEdit_FileName.text( ) + ".dat" if self.save_Absolute: response = get_reactions(self.preprocessor, self.reactions, self.node_ID, self.localDof) header = ( "Frequency[Hz], Real part [{}], Imaginary part [{}], Absolute [{}]" ).format(self.unit_label, self.unit_label, self.unit_label) data_to_export = np.array( [freq, np.real(response), np.imag(response), np.abs(response)]).T elif self.save_Real_Imaginary: response = get_reactions(self.preprocessor, self.reactions, self.node_ID, self.localDof) header = ( "Frequency[Hz], Real part [{}], Imaginary part [{}]").format( self.unit_label, self.unit_label) data_to_export = np.array( [freq, np.real(response), np.imag(response)]).T np.savetxt(self.export_path, data_to_export, delimiter=",", header=header) title = "Information" message = "The results have been exported." PrintMessageInput([title, message, window_title_2])
def load_table(self, lineEdit, direct_load=False): title = "Error reached while loading 'acoustic pressure' table" try: if direct_load: self.path_imported_table = lineEdit.text() else: window_label = 'Choose a table to import the acoustic pressure' self.path_imported_table, _ = QFileDialog.getOpenFileName( None, window_label, self.userPath, 'Files (*.csv; *.dat; *.txt)') if self.path_imported_table == "": return None, None imported_filename = os.path.basename(self.path_imported_table) lineEdit.setText(self.path_imported_table) imported_file = np.loadtxt(self.path_imported_table, delimiter=",") if imported_file.shape[1] < 2: message = "The imported table has insufficient number of columns. The spectrum" message += " data must have only two columns to the frequencies and values." PrintMessageInput([title, message, window_title_1]) return None, None imported_values = imported_file[:, 1] if imported_file.shape[1] >= 2: self.frequencies = imported_file[:, 0] self.f_min = self.frequencies[0] self.f_max = self.frequencies[-1] self.f_step = self.frequencies[1] - self.frequencies[0] if self.project.change_project_frequency_setup( imported_filename, list(self.frequencies)): self.lineEdit_reset(self.lineEdit_load_table_path) return None, None else: self.project.set_frequencies(self.frequencies, self.f_min, self.f_max, self.f_step) return imported_values, imported_filename except Exception as log_error: message = str(log_error) PrintMessageInput([title, message, window_title_1]) lineEdit.setFocus() return None, None
def ExportResults(self): if self.lineEdit_FileName.text() != "": if self.save_path != "": self.export_path_folder = self.save_path + "/" else: title = "Empty folder input field detected" message = "Plese, choose a folder before trying export the results!" PrintMessageInput([title, message, window_title_2]) return else: title = "Empty file name input field" message = "Inform a file name before trying export the results!" PrintMessageInput([title, message, window_title_2]) return if self.check(export=True): return freq = self.frequencies self.export_path = self.export_path_folder + self.lineEdit_FileName.text( ) + ".dat" response = get_stress_spectrum_data(self.stress_data, self.elementID, self.stress_key) if self.save_Absolute: header = ( "Frequency[Hz], Real part [{}], Imaginary part [{}], Absolute [{}]" ).format(self.unit_label, self.unit_label, self.unit_label) data_to_export = np.array( [freq, np.real(response), np.imag(response), np.abs(response)]).T elif self.save_Real_Imaginary: header = ( "Frequency[Hz], Real part [{}], Imaginary part [{}]").format( self.unit_label, self.unit_label) data_to_export = np.array( [freq, np.real(response), np.imag(response)]).T np.savetxt(self.export_path, data_to_export, delimiter=",", header=header) title = "Information" message = "The results have been exported." PrintMessageInput([title, message, window_title_2])
def get_information_line(self): try: if self.lineEdit_selected_ID.text() != "": list_lines = self.get_list_typed_entries() read = GetInformationOfGroup(self.project, list_lines, "Lines") if read.lines_removed: self.load_lines_info() else: title = "UNSELECTED GROUP OF LINES" message = "Please, select a group in the list to get the information." PrintMessageInput([title, message, window_title2]) except Exception as e: title = "ERROR WHILE GETTING INFORMATION OF SELECTED GROUP" message = str(e) PrintMessageInput([title, message, window_title1])
def get_information_elem(self): try: selected_key = self.dictKey_label.format( self.lineEdit_selected_ID.text()) if "Selection-" in selected_key: values = self.dict_group_elements[selected_key] GetInformationOfGroup(self.project, values, "Elements") else: title = "UNSELECTED GROUP OF ELEMENTS" message = "Please, select a group in the list to get the information." PrintMessageInput([title, message, window_title2]) except Exception as e: title = "ERROR WHILE GETTING INFORMATION OF SELECTED GROUP" message = str(e) PrintMessageInput([title, message, window_title1])
def update_selected_id(self): if self.opv.getListPickedPoints( ) != [] and self.opv.getListPickedElements() != []: title = "Multiples node(s) and element(s) selected" message = "Dear user, the current selection includes multiples node(s) and element(s). " message += "You should to select node(s) or element(s) separately to proceed. " self.multiple_selection = True self.reset_selection() PrintMessageInput([title, message, window_title_1]) return True elif self.opv.getListPickedLines() != []: self.line_id = self.opv.getListPickedLines() self.node_id = [] self.element_id = [] elif self.opv.getListPickedPoints() != []: self.node_id = self.opv.getListPickedPoints() self.line_id = [] self.element_id = [] elif self.opv.getListPickedElements() != []: self.element_id = self.opv.getListPickedElements() self.line_id = [] self.node_id = [] else: return True self.process_tabs_after_selection() return False
def reset_all(self): if len(self.preprocessor.nodes_with_compressor_excitation) > 0: title = f"Removal of all compressor excitations" message = "Do you really want to remove all compressor excitations \napplied to the following nodes?\n\n" for node in self.preprocessor.nodes_with_compressor_excitation: message += f"{node.external_index}\n" message += "\n\nPress the Continue button to proceed with the resetting or press Cancel or " message += "\nClose buttons to abort the current operation." read = CallDoubleConfirmationInput(title, message, leftButton_label='Cancel', rightButton_label='Continue') if read._doNotRun: return if read._continue: self.dict_node_to_compressor_excitation = self.project.file.get_dict_of_compressor_excitation_from_file( ) for node_id in self.dict_node_to_compressor_excitation.keys(): self.remove_message = False self.node_ID_remove = node_id self.reset_node() self.node_ID_remove = None title = "Reset of compressor excitations" message = "All compressor excitations have been removed from the model." PrintMessageInput([title, message, window_title_2])
def check_reset(self): if len(self.preprocessor.nodes_with_radiation_impedance) > 0: title = f"Removal of all applied radiation impedances" message = "Do you really want to remove the radiation impedance(s) \napplied to the following node(s)?\n\n" for node in self.preprocessor.nodes_with_radiation_impedance: message += f"{node.external_index}\n" message += "\n\nPress the Continue button to proceed with the resetting or press Cancel or " message += "\nClose buttons to abort the current operation." read = CallDoubleConfirmationInput(title, message, leftButton_label='Cancel', rightButton_label='Continue') _nodes_with_radiation_impedance = self.preprocessor.nodes_with_radiation_impedance.copy( ) if read._continue: for node in _nodes_with_radiation_impedance: node_id = node.external_index key_strings = ["radiation impedance"] remove_bc_from_file([node_id], self.acoustic_bc_info_path, key_strings, None) self.preprocessor.set_radiation_impedance_bc_by_node( node_id, None) title = "Radiation impedance resetting process complete" message = "All radiation impedances applied to the acoustic\n" message += "model have been removed from the model." PrintMessageInput([title, message, window_title_2]) self.opv.updateRendererMesh() self.close()
def empty_project_action_message(self): title = 'EMPTY PROJECT' message = 'Please, you should create a new project or load an already existing one before start to set up the model.' message += "\n\nIt is recommended to use the 'New Project' or the 'Import Project' \nbuttons to continue." window_title = 'ERROR' PrintMessageInput([title, message, window_title], opv=self.mainWindow.getOPVWidget())
def check_constant_values(self): lineEdit_nodeID = self.lineEdit_nodeID.text() self.stop, self.nodes_typed = self.before_run.check_input_NodeID(lineEdit_nodeID) if self.stop: self.lineEdit_nodeID.setFocus() return specific_impedance = self.check_complex_entries(self.lineEdit_specific_impedance_real, self.lineEdit_specific_impedance_imag) if self.stop: return if specific_impedance is not None: self.specific_impedance = specific_impedance data = [self.specific_impedance, None] list_table_names = self.get_list_table_names_from_selected_nodes(self.nodes_typed) self.process_table_file_removal(list_table_names) self.project.set_specific_impedance_bc_by_node(self.nodes_typed, data, False) self.opv.updateRendererMesh() print(f"[Set Specific Impedance] - defined at node(s) {self.nodes_typed}") self.close() else: title = "Additional inputs required" message = "You must inform at least one specific impedance\n" message += "before confirming the input!" PrintMessageInput([title, message, window_title_1]) self.lineEdit_specific_impedance_real.setFocus()
def save_table_file(self, node_id, values, filename): try: self.project.create_folders_acoustic("acoustic_pressure_files") real_values = np.real(values) imag_values = np.imag(values) abs_values = np.abs(values) data = np.array( [self.frequencies, real_values, imag_values, abs_values]).T header = f"OpenPulse - imported table for acoustic pressure @ node {node_id}\n" header += f"\nSource filename: {filename}\n" header += "\nFrequency [Hz], real[Pa], imaginary[Pa], absolute[Pa]" basename = f"acoustic_pressure_node_{node_id}.dat" new_path_table = get_new_path( self.acoustic_pressure_tables_folder_path, basename) np.savetxt(new_path_table, data, delimiter=",", header=header) return values, basename except Exception as log_error: title = "Error reached while saving table files" message = str(log_error) PrintMessageInput([title, message, window_title_1]) return None, None
def check_table_values(self): lineEdit_nodeID = self.lineEdit_nodeID.text() self.stop, self.nodes_typed = self.before_run.check_input_NodeID(lineEdit_nodeID) if self.stop: self.lineEdit_nodeID.setFocus() return list_table_names = self.get_list_table_names_from_selected_nodes(self.nodes_typed) if self.lineEdit_load_table_path != "": for node_id in self.nodes_typed: if self.filename_specific_impedance is None: self.imported_values, self.filename_specific_impedance = self.load_table(self.lineEdit_load_table_path, direct_load=True) if self.imported_values is None: return else: self.specific_impedance, self.basename_specific_impedance = self.save_table_file( node_id, self.imported_values, self.filename_specific_impedance ) if self.basename_specific_impedance in list_table_names: list_table_names.remove(self.basename_specific_impedance) data = [self.specific_impedance, self.basename_specific_impedance] self.project.set_specific_impedance_bc_by_node([node_id], data, True) self.process_table_file_removal(list_table_names) self.opv.updateRendererMesh() print(f"[Set Specific Impedance] - defined at node(s) {self.nodes_typed}") self.close() else: title = "Additional inputs required" message = "You must inform at least one specific impedance\n" message += "table path before confirming the input!" PrintMessageInput([title, message, window_title_1]) self.lineEdit_load_table_path.setFocus()
def runAnalysis(self): # t0 = time() if self.analysis_ID is None or not self.project.setup_analysis_complete: title = "INCOMPLETE SETUP ANALYSIS" message = "Please, it is necessary to choose an analysis type and \nsetup it before trying to solve the model." PrintMessageInput([title, message, window_title_1]) return self.before_run = self.project.get_pre_solution_model_checks( opv=self.opv) if self.before_run.check_is_there_a_problem(self.analysis_ID): return # self.project.time_to_checking_entries = time()-t0 read = self.processInput(RunAnalysisInput, self.project, self.analysis_ID, self.analysis_type_label) if read.complete: if self.analysis_ID == 2: self.before_run.check_modal_analysis_imported_data() elif self.analysis_ID in [3, 5, 6]: self.before_run.check_all_acoustic_criteria() self.after_run = self.project.get_post_solution_model_checks( opv=self.opv) self.after_run.check_all_acoustic_criterias()
def __init__(self, project, opv, config, path, *args, **kwargs): super().__init__(*args, **kwargs) self.project = project self.opv = opv self.config = config self.path = path self.userPath = expanduser('~') self.complete_project_path = "" self.complete = False if self.path is None: self.complete_project_path, _type = QFileDialog.getOpenFileName( None, 'Open file', self.userPath, 'OpenPulse Project (*.ini)') else: self.complete_project_path = self.path try: if self.complete_project_path != "": t0 = time() self.project.load_project(self.complete_project_path) if self.project.preferences: self.opv.setUserInterfacePreferences( self.project.preferences) self.config.writeRecentProject(self.project.get_project_name(), self.complete_project_path) self.complete = True self.project.time_to_load_or_create_project = time() - t0 self.close() except Exception as log_error: title = "Error while loading project" message = str(log_error) window_title = "ERROR" PrintMessageInput([title, message, window_title])
def check_composition_input(self): self.str_composition_value = self.lineEdit_composition.text() if self.str_composition_value != "": title = "Invalid input value to the fluid Composition" message = "" value = None try: value = float(self.str_composition_value) except Exception as log_error: message = "Dear user, you have typed an invalid entry at the fluid Composition input. " message += "\nPlease, check the typed value to proceed with the fluid setup.\n\n" message += str(log_error) if value is not None: if value > 100 or value < 0: message = "Dear user, you have typed an invalid entry at the fluid Composition input. " message += "The value must be a positive value less or equals to 100." message += "\nPlease, check the typed value to proceed with the fluid setup." if round(value / 100, 5) > round(self.remaining_composition, 5): _remain = round(self.remaining_composition * 100, 5) message = "Dear user, you have typed an invalid entry at the Fluid Composition input. " message += f"The value must be a positive value less or equals to {_remain}%." message += "\nPlease, check the typed value to proceed with the fluid setup." if message == "": self.composition_value = value / 100 fluid_file_name, _, _ = self.list_gases[self.selected_fluid] self.fluid_to_composition[self.selected_fluid] = [ self.str_composition_value, self.composition_value, fluid_file_name ] if self.composition_value == 0: if self.selected_fluid in self.fluid_to_composition.keys(): self.fluid_to_composition.pop(self.selected_fluid) return False else: PrintMessageInput([title, message, window_title_1]) return True else: title = "Empty entry at molar fraction input field" message = "An Empty entry has been detected at molar fraction input field. " message += "You should to inform a valid positive float number less than 1 to proceed." PrintMessageInput([title, message, window_title_1]) return True
def check_reset_all(self): self.project.reset_B2PX_totation_decoupling() message = "The rotation decoupling applied \nto all dofs has been reseted." title = "Rotations dofs decoupling" window_title = "WARNING" PrintMessageInput([title, message, window_title]) self.load_decoupling_info() self.clear_texts()