def mesh_(): steel = Material('Steel', 7860, young_modulus=210e9, poisson_ratio=0.3) cross_section = CrossSection(0.05, 0.008) preprocessor = Preprocessor() preprocessor.generate('iges_files\\tube_1.iges', 0.01) preprocessor.set_prescribed_dofs_bc_by_node([40, 1424, 1324], np.zeros(6)) preprocessor.set_material_by_element('all', steel) preprocessor.set_cross_section_by_element('all', cross_section) return mesh
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 material_select(self): if self.current_item is None: return new_material = Material( self.current_item.text(0), float(self.current_item.text(3)), young_modulus=float(self.current_item.text(2)) * (10**(9)), poisson_ratio=float(self.current_item.text(4)), color=self.current_item.text(5), identifier=int(self.current_item.text(1))) self.material = new_material self.close()
def model(): steel = Material('Steel', 7860, young_modulus=210e9, poisson_ratio=0.3) cross_section = CrossSection(0.05, 0.008) preprocessor = Preprocessor() preprocessor.generate('iges_files\\tube_1.iges', 0.01) preprocessor.set_prescribed_dofs_bc_by_node([40, 1424, 1324], np.zeros(6)) preprocessor.set_material_by_element('all', steel) preprocessor.set_cross_section_by_element('all', cross_section) assembly = AssemblyStructural(preprocessor) # We need to separate it in multiple atribute or functions as soon as possible. names = ['Kadd_lump', 'Madd_lump', 'K', 'M', 'Kr', 'Mr', 'K_lump', 'M_lump', 'C_lump', 'Kr_lump', 'Mr_lump', 'Cr_lump'] answer = assembly.get_all_matrices() return dict(zip(names, answer))
def check(self): if self.clicked_item is None: error("Select a material in the list") 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)) color = self.clicked_item.text(5) new_material = Material(name, density, poisson_ratio=poisson, young_modulus=young, identifier=identifier, color=color) self.material = new_material self.close() except Exception as e: error(str(e), "Error with the material list data") return
import numpy as np import matplotlib.pyplot as plt from pulse.preprocessing.cross_section import CrossSection from pulse.preprocessing.material import Material from pulse.preprocessing.fluid import Fluid from pulse.preprocessing.preprocessor import Preprocessor from pulse.processing.assembly_acoustic import AssemblyAcoustic from pulse.processing.solution_acoustic import SolutionAcoustic from pulse.postprocessing.plot_acoustic_data import get_acoustic_frf # Fluid setup speed_of_sound = 343.21 density = 1.2041 air = Fluid('air', density, speed_of_sound) steel = Material('Steel', 7860, young_modulus=210e9, poisson_ratio=0.3) # Tube setup cross_section = CrossSection(0.05, 0.008, offset_y=0, offset_z=0) cross_section.update_properties() cross_section_expansion = CrossSection(0.288, 0.008, offset_y=0, offset_z=0) cross_section_expansion.update_properties() cross_section_branch = CrossSection(0.025, 0.004, offset_y=0, offset_z=0) cross_section_branch.update_properties() # Preprocessor init preprocessor = Preprocessor() preprocessor.generate('examples/iges_files/tube_2.iges', 0.01) preprocessor.set_material_by_element('all', steel) preprocessor.set_acoustic_pressure_bc_by_node(50, 1 + 0j) unflanged = True
from pulse.preprocessing.cross_section import CrossSection from pulse.preprocessing.material import Material from pulse.preprocessing.preprocessor import Preprocessor from pulse.processing.assembly_structural import get_global_matrices # create materials steel = Material('Steel', density=7860, young_modulus=210e9, poisson_ratio=0.3) alloy_steel = Material('AISI4140', density=7850, young_modulus=203200000000, poisson_ratio=0.27) # create cross sections large_tube = CrossSection(0.05, 0.034) thin_tube = CrossSection(0.01, 0.005) # create preprocessor preprocessor = Preprocessor() # define mesh file and element size preprocessor.generate('tube_2.iges', 0.01) # set properties to all elements preprocessor.set_material_by_element('all', steel) preprocessor.set_cross_section_by_element('all', large_tube) # set properties for specific lines preprocessor.set_cross_section_by_line([37, 38, 39], thin_tube) preprocessor.set_material_by_lines([37, 38, 39], alloy_steel)
def getDictOfEntitiesFromFile(self): material_list = configparser.ConfigParser() material_list.read(self._materialListPath) fluid_list = configparser.ConfigParser() fluid_list.read(self._fluidListPath) entityFile = configparser.ConfigParser() entityFile.read(self._entityPath) dict_material = {} dict_cross = {} dict_element_type = {} dict_fluid = {} for entity in entityFile.sections(): element_type = entityFile[entity]['Element Type'] if element_type != "": dict_element_type[int(entity)] = element_type self.element_type_is_structural = True else: dict_element_type[int(entity)] = 'pipe_1' material_id = entityFile[entity]['Material ID'] if material_id.isnumeric(): material_id = int(material_id) for material in material_list.sections(): if int(material_list[material] ['identifier']) == material_id: name = str(material_list[material]['name']) identifier = str(material_list[material]['identifier']) density = str(material_list[material]['density']) youngmodulus = str( material_list[material]['young modulus']) poisson = str(material_list[material]['poisson']) color = str(material_list[material]['color']) youngmodulus = float(youngmodulus) * (10**(9)) temp_material = Material(name, float(density), identifier=int(identifier), young_modulus=youngmodulus, poisson_ratio=float(poisson), color=color) dict_material[int(entity)] = temp_material diam_ext = entityFile[entity]['Outer Diameter'] thickness = entityFile[entity]['Thickness'] offset = entityFile[entity]['Offset [e_y, e_z]'] offset_y, offset_z = self._get_offset_from_string(offset) try: diam_ext = float(diam_ext) thickness = float(thickness) offset_y = float(offset_y) offset_z = float(offset_z) cross = CrossSection( diam_ext, thickness, offset_y, offset_z ) #, poisson_ratio=poisson, element_type=element_type) dict_cross[int(entity)] = cross except Exception: print('Error - load cross-section parameters from file!') return fluid_id = entityFile[entity]['Fluid ID'] if fluid_id.isnumeric(): fluid_id = int(fluid_id) for fluid in fluid_list.sections(): if int(fluid_list[fluid]['identifier']) == fluid_id: name = str(fluid_list[fluid]['name']) identifier = str(fluid_list[fluid]['identifier']) fluid_density = str(fluid_list[fluid]['fluid density']) speed_of_sound = str( fluid_list[fluid]['speed of sound']) # acoustic_impedance = str(fluid_list[fluid]['impedance']) color = str(fluid_list[fluid]['color']) temp_fluid = Fluid(name, float(fluid_density), float(speed_of_sound), color=color, identifier=int(identifier)) dict_fluid[int(entity)] = temp_fluid return dict_material, dict_cross, dict_element_type, dict_fluid