import ansys.fluent as pyfluent import os path = os.getcwd() s = pyfluent.launch_fluent(meshing_mode=True) s.workflow.initialize_workflow(workflow_type='Watertight Geometry') #Import Geometry s.workflow.task_object['Import Geometry'].arguments = dict(file_name=path + '/parts/manifold.scdoc.pmdb') s.workflow.task_object['Import Geometry'].execute() #Create Surface Mesh s.workflow.task_object['Add Local Sizing'].add_child_to_task() s.workflow.task_object['Add Local Sizing'].execute() s.workflow.task_object['Generate the Surface Mesh'].arguments = {r'CFDSurfaceMeshControls': {r'MaxSize': 9.404350000000001,r'MinSize': 0.3673574,r'SizeFunctions': r'Curvature & Proximity',},} s.workflow.task_object['Generate the Surface Mesh'].execute() #Describe Geometry s.workflow.task_object['Describe Geometry'].update_child_tasks(setup_type_changed = False) s.workflow.task_object['Describe Geometry'].execute() #Enclose Fluid Regions s.workflow.task_object['Enclose Fluid Regions (Capping)'].arguments = {r'LabelSelectionList': [r'in1', r'in2', r'in3'],r'PatchName': r'inlet',} s.workflow.task_object['Enclose Fluid Regions (Capping)'].add_child_to_task() s.workflow.task_object['Enclose Fluid Regions (Capping)'].insert_compound_child_task() s.workflow.task_object['Enclose Fluid Regions (Capping)'].arguments = {} s.workflow.task_object['inlet'].execute() s.workflow.task_object['Enclose Fluid Regions (Capping)'].arguments = {r'LabelSelectionList': [r'out1'],r'PatchName': r'outlet',r'ZoneType': r'pressure-outlet',} s.workflow.task_object['Enclose Fluid Regions (Capping)'].add_child_to_task() s.workflow.task_object['Enclose Fluid Regions (Capping)'].insert_compound_child_task() s.workflow.task_object['Enclose Fluid Regions (Capping)'].arguments = {} s.workflow.task_object['outlet'].execute() #Create and Update regions s.workflow.task_object['Create Regions'].execute() s.workflow.task_object['Update Regions'].execute() #Create Volume Mesh s.workflow.task_object['Add Boundary Layers'].add_child_to_task() s.workflow.task_object['Add Boundary Layers'].insert_compound_child_task() s.workflow.task_object['smooth-transition_1'].arguments = {r'BLControlName': r'smooth-transition_1',} s.workflow.task_object['smooth-transition_1'].arguments = {} s.workflow.task_object['smooth-transition_1'].execute() s.workflow.task_object['Generate the Volume Mesh'].arguments = {r'VolumeFillControls': {r'TetPolyMaxCellLength': 9.137613,},} s.workflow.task_object['Generate the Volume Mesh'].execute() s.tui.meshing.mesh.check_mesh() #s.tui.meshing.file.write_mesh("out/manifold.msh.h5") #s.tui.solver.file.start_transcript("out/exhaust_manifold_std_py.trn") s.tui.meshing.switch_to_solution_mode("yes") s.tui.solver.define.units("length","mm") s.tui.solver.define.models.energy("yes") s.tui.solver.define.models.viscous.kw_sst("yes") s.tui.solver.define.materials.change_create("aluminum","cast-iron","yes","constant","7150","yes","constant","460","yes","constant","50","yes") #Calling settings objects s.setup_settings_objects() # Set Velocity of inlet to 10 m/s s.setup.boundary_conditions.velocity_inlet['inlet'].vmag = { 'option': 'constant or expression', 'constant': 10 } # Set Temperature to 925 K s.setup.boundary_conditions.velocity_inlet['inlet'].t = { 'option': 'constant or expression', 'constant': 925 } #get active member names s.setup.boundary_conditions.velocity_inlet['inlet'].get_active_member_names() #output: ['frame_of_reference', 't', 'turb_viscosity_ratio', 'p_sup', 'turb_intensity', 'vmag', 'ke_spec', 'velocity_spec'] #Change Turbulence Spec to Intensity and Hydraulic Diameter s.setup.boundary_conditions.velocity_inlet['inlet'].ke_spec = 'Intensity and Hydraulic Diameter' s.setup.boundary_conditions.velocity_inlet['inlet'].turb_hydraulic_diam = { 'option': 'constant or expression', 'constant': 40 }