def check(self): if self.currentTab == 0 or True: #Pipe if self.lineEdit_outerDiameter.text() == "": error("Insert some value (OUTER DIAMETER)!", title="INPUT CROSS-SECTION ERROR") return elif self.lineEdit_thickness.text() == "": error("Insert some value (THICKENSS)!", title="INPUT CROSS-SECTION ERROR") return offset_y = 0 offset_z = 0 try: outerDiameter = float(self.lineEdit_outerDiameter.text()) except Exception: error("Wrong input for OUTER DIAMETER!", title=">>> INPUT CROSS-SECTION ERROR <<<") return try: thickness = float(self.lineEdit_thickness.text()) except Exception: error("Wrong input for THICKENSS!", title=">>> INPUT CROSS-SECTION ERROR <<<") return if self.lineEdit_offset_y.text() != "": try: offset_y = float(self.lineEdit_offset_y.text()) except Exception: error("Wrong input for OFFSET Y!", title=">>> INPUT CROSS-SECTION ERROR <<<") return if self.lineEdit_offset_z.text() != "": try: offset_z = float(self.lineEdit_offset_z.text()) except Exception: error("Wrong input for OFFSET Z!", title=">>> INPUT CROSS-SECTION ERROR <<<") return if outerDiameter<thickness: error("The OUTER DIAMETER must be greater than THICKNESS!", title=">>> INPUT CROSS-SECTION ERROR <<<") return elif thickness == 0.0: error("The THICKNESS must be greater than zero!", title=">>> INPUT CROSS-SECTION ERROR <<<") return elif abs(offset_y) > 0.2*(outerDiameter/2): error("The OFFSET_Y must be less than 20{%} of the external radius!", title=">>> INPUT CROSS-SECTION ERROR <<<") return elif abs(offset_z) > 0.2*(outerDiameter/2): error("The OFFSET_Y must be less than 20{%} of the external radius!", title=">>> INPUT CROSS-SECTION ERROR <<<") return self.cross_section = CrossSection(outerDiameter, thickness, offset_y, offset_z) self.complete = True self.close() else: pass
def set_flange_cross_section_to_list_elements(self, list_elements): section_parameters = {} for element_id in list_elements: element = self.structural_elements[element_id] if self.flag_checkBox: cross_section = element.cross_section if cross_section is None: section_parameters = {} return True else: outer_diameter = self.outer_diameter inner_diameter = cross_section.inner_diameter thickness = (self.outer_diameter - inner_diameter) / 2 offset_y = cross_section.offset_y offset_z = cross_section.offset_z insulation_thickness = cross_section.insulation_thickness insulation_density = cross_section.insulation_density else: outer_diameter = self.outer_diameter inner_diameter = self.inner_diameter thickness = (outer_diameter - inner_diameter) / 2 offset_y = self.offset_y offset_z = self.offset_z insulation_thickness = self.insulation_thickness insulation_density = self.insulation_density if outer_diameter <= inner_diameter: section_parameters = {} title = "Invalid input to the outer/inner diameters" message = "The outer diameter input should be greater than the inner diameter. \n" message += "This condition must be satified to proceed." PrintMessageInput([title, message, window_title_1]) return True section_parameters[element_id] = { "outer_diameter": outer_diameter, "thickness": thickness, "offset_y": offset_y, "offset_z": offset_z, "insulation_thickness": insulation_thickness, "insulation_density": insulation_density } for element_id in list_elements: pipe_section_info = { "section_type_label": "Pipe section", "section_parameters": section_parameters[element_id] } self.cross_section = CrossSection( pipe_section_info=pipe_section_info) self.project.set_cross_section_by_elements([element_id], self.cross_section) return False
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 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 load_mapped_cross_section(self): label_etypes = ['pipe_1', 'pipe_2', 'shell'] indexes = [0, 1, 2] dict_etype_index = dict(zip(label_etypes,indexes)) dict_index_etype = dict(zip(indexes,label_etypes)) dict_tag_entity = self.mesh.get_dict_of_entities() map_cross_section_to_lines = defaultdict(list) map_cross_section_to_elements = defaultdict(list) for line, entity in dict_tag_entity.items(): ext_diam = entity.crossSection.external_diameter thickness = entity.crossSection.thickness offset_y = entity.crossSection.offset_y offset_z = entity.crossSection.offset_z e_type = entity.element_type if e_type is None: e_type = 'pipe_1' self.acoustic_analysis = True poisson = entity.material.poisson_ratio if poisson is None: poisson = 0 index_etype = dict_etype_index[e_type] elements = self.mesh.line_to_elements[line] map_cross_section_to_lines[str([ext_diam, thickness, offset_y, offset_z, poisson, index_etype])].append(line) map_cross_section_to_elements[str([ext_diam, thickness, offset_y, offset_z, poisson, index_etype])].append(elements) for key, elements in map_cross_section_to_elements.items(): cross_strings = key[1:-1].split(',') vals = [float(value) for value in cross_strings] el_type = dict_index_etype[vals[-1]] cross_section = CrossSection(vals[0], vals[1], vals[2], vals[3], poisson_ratio=vals[4], element_type=el_type) list_flatten = [item for sublist in elements for item in sublist] self.mesh.set_cross_section_by_element(list_flatten, cross_section, update_cross_section=True)
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 flanged = False if unflanged:
from pulse.processing.solution_acoustic import SolutionAcoustic from pulse.postprocessing.plot_structural_data import get_structural_frf, get_structural_response from pulse.postprocessing.plot_acoustic_data import get_acoustic_frf, get_acoustic_response from pulse.animation.plot_function import plot_results ''' |=============================================================================| | Please, it's necessary to copy and paste main.py script at OpenPulse file | | then type "python main.py" in the terminal to run the code ! | |=============================================================================| ''' speed_of_sound = 350.337 density = 24.85 hydrogen = Fluid('hydrogen', 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.005, offset_z=0.005) # Mesh init mesh = Mesh() run = 2 anechoic_termination = True if run == 1: mesh.generate('examples/iges_files/tube_2.iges', 0.01) mesh.set_acoustic_pressure_BC_by_node([50], 1) # Anechoic termination if anechoic_termination: mesh.set_specific_impedance_BC_by_node(1086, speed_of_sound * density) if run == 2: mesh.load_mesh('examples/validation_acoustic/coord.dat', 'examples/validation_acoustic/connect.dat') # Acoustic boundary conditions - Prescribe pressure mesh.set_acoustic_pressure_BC_by_node([1], 1)
from time import time 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.mesh import Mesh from pulse.processing.solution_structural import SolutionStructural from pulse.postprocessing.plot_data import get_frf # PREPARING MESH steel = Material('Steel', 7860, young_modulus=210e9, poisson_ratio=0.3) cross_section = CrossSection(0.05, 0.034) mesh = Mesh() mesh.load_mesh('coord.dat', 'connect.dat') mesh.set_material_by_element('all', steel) mesh.set_cross_section_by_element('all', cross_section) mesh.set_prescribed_dofs_bc_by_node([1, 1200, 1325], np.zeros(6)) mesh.set_structural_load_bc_by_node([361], np.array([1, 0, 0, 0, 0, 0])) # SOLVING THE PROBLEM BY TWO AVALIABLE METHODS frequencies = np.arange(0, 202, 2) modes = 200 solution = SolutionStructural(mesh) direct = solution.direct_method(frequencies) modal = solution.mode_superposition(frequencies, modes) # GETTING FRF node = 711 local_dof = 2
mesh = Mesh() load_file = 1 if load_file==1: mesh.generate('examples/iges_files/tube_1.iges', 0.01) mesh.set_prescribed_dofs_bc_by_node([40, 1424, 1324], np.zeros(6)) mesh.set_structural_load_bc_by_node([359], np.array([1,0,0,0,0,0])) if load_file==2: mesh.load_mesh('examples/mesh_files/Geometry_01/coord.dat', 'examples/mesh_files/Geometry_01/connect.dat') mesh.set_prescribed_dofs_bc_by_node([1, 1200, 1325], np.zeros(6)) mesh.set_structural_load_bc_by_node([361], np.array([1,0,0,0,0,0])) mesh.set_element_type_by_element('all', element_type) mesh.set_material_by_element('all', steel) offset = [0.005, 0.005] cross_section = CrossSection(0.05, 0.008, offset[0], offset[1], steel.poisson_ratio, element_type=element_type, division_number=64) mesh.set_cross_section_by_element('all', cross_section) solution = SolutionStructural(mesh) f_max = 200 df = 2 frequencies = np.arange(0, f_max+df, df) modes = 200 direct = solution.direct_method(frequencies, is_viscous_lumped=True) modal = solution.mode_superposition(frequencies, modes, fastest=True) # natural_frequencies, modal_shape = solution.modal_analysis(modes=20) dt = time()-t0 print('Total elapsed time:', dt,'[s]') ###################################################################################### ## POST-PROCESSING THE RESULTS ##
d_out = 0.05 d_in = 0.034 area = np.pi * ((d_out**2) - (d_in**2)) / 4 Iyy = np.pi * ((d_out**4) - (d_in**4)) / 64 Izz = np.pi * ((d_out**4) - (d_in**4)) / 64 Iyz = 0 section_info = ["Generic section", None] cross_section = CrossSection(d_out, 0, 0, 0, steel.poisson_ratio, element_type=element_type, area=area, Iyy=Iyy, Izz=Izz, Iyz=Iyz, additional_section_info=section_info) # offset = [0.005, 0.005] # cross_section = CrossSection(0.05, 0.008, offset[0], offset[1], steel.poisson_ratio, element_type=element_type, division_number=64) preprocessor.set_cross_section_by_element('all', cross_section) f_max = 200 df = 2 frequencies = np.arange(0, f_max + df, df)
| Please, it's necessary to copy and paste main.py script at OpenPulse file | | then type "python main.py" in the terminal to run the code ! | |=============================================================================| ''' t0 = time() # PREPARING MESH speed_of_sound = 331.2 # speed of sound at 0ºC density = 1.204 air = Fluid('air', density, speed_of_sound) steel = Material('Steel', 7860, young_modulus=210e9, poisson_ratio=0.3) offset = [0.005, 0.005] element_type = 'pipe_1' cross_section = CrossSection(0.05, 0.008, offset_y=offset[0], offset_z=offset[1], poisson_ratio=steel.poisson_ratio) cross_section.update_properties() preprocessor = Preprocessor() preprocessor.generate('examples/iges_files/tube_2.iges', 0.01) # preprocessor.set_acoustic_pressure_bc_by_node([50], 1e5 + 0j) # preprocessor.set_specific_impedance_bc_by_node(1086, speed_of_sound * density+ 0j) preprocessor.set_prescribed_dofs_bc_by_node([1136, 1236], np.zeros(6) + 0j) preprocessor.set_element_type_by_element('all', element_type) preprocessor.set_fluid_by_element('all', air) preprocessor.set_material_by_element('all', steel) preprocessor.set_cross_section_by_element('all', cross_section) preprocessor.set_structural_load_bc_by_node([50],
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)
steel = Material('Steel', 7860, young_modulus=210e9, poisson_ratio=0.3) # Tube setup section_parameters = { "outer_diameter": 0.04859, "thickness": 0.003, "offset_y": 0, "offset_z": 0, "insulation_thickness": 0, "insulation_density": 0 } pipe_section_info = { "section_type_label": "Pipe section", "section_parameters": section_parameters } cross_section1 = CrossSection(pipe_section_info=pipe_section_info) cross_section1.update_properties() section_parameters = { "outer_diameter": 0.04044, "thickness": 0.003, "offset_y": 0, "offset_z": 0, "insulation_thickness": 0, "insulation_density": 0 } pipe_section_info = { "section_type_label": "Pipe section", "section_parameters": section_parameters }
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 = 347.21 density = 1.1614 air = Fluid('air', density, speed_of_sound) air.isentropic_exponent = 1.400 air.thermal_conductivity = 0.0263 air.specific_heat_Cp = 1007 air.dynamic_viscosity = 1.846e-05 steel = Material('Steel', 7860, young_modulus=210e9, poisson_ratio=0.3) # Tube setup cross_section = CrossSection(0.273, 0.00927, offset_y=0, offset_z=0) cross_section.update_properties() cross_section_expansion = CrossSection(0.56, 0.00475, offset_y=0, offset_z=0) cross_section_expansion.update_properties() # preprocessor init preprocessor = Preprocessor() preprocessor.generate('examples/validation_perforated_plate/silencer_wpp.iges', 0.01) preprocessor.set_material_by_element('all', steel) preprocessor.set_acoustic_pressure_bc_by_node(188, 2 + 0j) preprocessor.set_radiation_impedance_bc_by_node(234, 0) element_type = 'undamped' preprocessor.set_acoustic_element_type_by_element('all', element_type,
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
def accept_pipe(self): line_diam_externo = float(self.line_diam_externo.text()) line_diam_interno = float(self.line_diam_interno.text()) self.cross = CrossSection(line_diam_externo, line_diam_interno) self.close()