.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/00-fluent/frozen_rotor_workflow.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_00-fluent_frozen_rotor_workflow.py: .. _frozen_rotor_simulation: Impeller-Volute simulation using the Frozen Rotor Approach ---------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 30-49 Objective ============================================================================================================== This example demonstrates how to set up a CFD simulation of an impeller and volute using the frozen rotor approach. The frozen rotor approach is a technique used in computational fluid dynamics (CFD) to simulate the flow around rotating machinery, such as pumps, turbines, and compressors. In this approach, the rotor is treated as a stationary component, while the surrounding fluid is allowed to move. This allows for a more efficient simulation of the flow field, as the rotor's motion does not need to be explicitly modeled. The frozen rotor approach is particularly useful for simulating steady-state flows, where the rotor's motion is constant. By using this approach, engineers can obtain accurate predictions of the flow field and performance characteristics of rotating machinery without the need for complex and computationally expensive simulations. .. image:: ../../_static/pump-volute-geom.png :align: center :alt: Pump Volute Geometry View .. GENERATED FROM PYTHON SOURCE LINES 51-53 Outline ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 53-74 .. code-block:: Python # The example demonstrates the following: # *Overview & Problem description # *Launching Fluent in solver mode. # *Downloading a mesh files from the examples repository. # *Initial setup # *Mesh configuration # *Model selection & Material definition # *Defining cell zone conditions & boundary conditions # *Turbomachinery configuration # *Solver settings # *Report definitions # *Initialization # *Running the simulation # *Post-processing the results # *Visualizing the results # *Saving the case file # *Closing the solver .. GENERATED FROM PYTHON SOURCE LINES 75-77 Import required libraries/modules ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 77-83 .. code-block:: Python import math import os import ansys.fluent.core as pyfluent from ansys.fluent.core import examples .. GENERATED FROM PYTHON SOURCE LINES 84-86 Download the mesh file ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 86-101 .. code-block:: Python # Download the mesh file from the examples repository # Impeller and volute mesh files impeller_mesh = examples.download_file( "impeller.msh.h5", "pyfluent/examples/pump-volute", save_path=os.getcwd(), ) volute_mesh = examples.download_file( "volute.msh.h5", "pyfluent/examples/pump-volute", save_path=os.getcwd(), ) .. GENERATED FROM PYTHON SOURCE LINES 102-104 Define Constants ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 104-113 .. code-block:: Python density_water = 998.2 # kg/m^3 viscosity_water = 0.001002 # kg/(m.s) g = 9.81 # m/s^2 # Impeller speed impeller_speed = 1450 # rpm # Convert to rad/s impeller_speed_rad = impeller_speed * 2 * math.pi / 60 # rad/s .. GENERATED FROM PYTHON SOURCE LINES 114-116 Launch Fluent with solver mode and print Fluent version ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 116-125 .. code-block:: Python solver_session = pyfluent.launch_fluent( mode="solver", processor_count=4, cleanup_on_exit=True, ) print(solver_session.get_fluent_version()) .. GENERATED FROM PYTHON SOURCE LINES 126-128 Read, append the mesh files ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 128-134 .. code-block:: Python # Read Impeller mesh file solver_session.settings.file.read_mesh(file_name=impeller_mesh) # Append Volute mesh file solver_session.settings.mesh.modify_zones.append_mesh(file_name=volute_mesh) .. GENERATED FROM PYTHON SOURCE LINES 135-137 Display the mesh ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 137-170 .. code-block:: Python # Access the graphics object graphics = solver_session.settings.results.graphics # Create a mesh object and configure its settings mesh_object = solver_session.settings.results.graphics.mesh.create(name="mesh-1") mesh_object.surfaces_list = [ "inlet", "mass-flow-inlet-11", "interface-impeller-outlet", "interface-volute-inlet", "blade", "impeller-hub", "impeller-shroud", "inblock-hub", "inblock-shroud", "volute-inlet-wall", "volute-wall", ] mesh_object.options.edges = True # Set the hardcopy format for saving the image graphics.picture.driver_options.hardcopy_format = "png" graphics.views.restore_view(view_name="front") mesh_object.display() graphics.views.auto_scale() graphics.picture.save_picture( file_name="pump-volute-mesh.png", ) .. GENERATED FROM PYTHON SOURCE LINES 171-176 .. image:: ../../_static/pump-volute-mesh.png :align: center :width: 650px :height: 400px :alt: Pump Volute Mesh .. GENERATED FROM PYTHON SOURCE LINES 178-180 Set the unit for angular velocity, rad/s to rev/min ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 180-185 .. code-block:: Python solver_session.settings.setup.general.units.set_units( quantity="angular-velocity", units_name="rev/min" ) .. GENERATED FROM PYTHON SOURCE LINES 186-188 Define the Viscous Model ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 188-195 .. code-block:: Python # Models setting viscous = solver_session.settings.setup.models.viscous viscous = solver_session.settings.setup.models.viscous viscous.model = "k-omega" viscous.k_omega_model = "sst" .. GENERATED FROM PYTHON SOURCE LINES 196-198 Define Materials ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 198-202 .. code-block:: Python solver_session.settings.setup.materials.database.copy_by_name( type="fluid", name="water-liquid" ) .. GENERATED FROM PYTHON SOURCE LINES 203-205 Define Cell Zone Conditions ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 205-242 .. code-block:: Python impeller_cell_zone = solver_session.settings.setup.cell_zone_conditions.fluid[ "impeller" ] impeller_cell_zone.general.material = "water-liquid" impeller_cell_zone.reference_frame.reference_frame_axis_origin = [0, 0, 0] impeller_cell_zone.reference_frame.reference_frame_axis_direction = [0, 0, 1] impeller_cell_zone.reference_frame.frame_motion = True # impeller rotation impeller_cell_zone.reference_frame.mrf_omega.value = impeller_speed_rad # Volute Cell Zone Conditions volute_cell_zone = solver_session.settings.setup.cell_zone_conditions.fluid["volute"] volute_cell_zone.general.material = "water-liquid" # Boundary Conditions # impeller hub impeller_hub = solver_session.settings.setup.boundary_conditions.wall[ "impeller-hub" ].momentum impeller_hub.wall_motion = "Moving Wall" impeller_hub.relative = True impeller_hub.velocity_spec = "Rotational" # inblock-shroud inblock_shroud = solver_session.settings.setup.boundary_conditions.wall[ "inblock-shroud" ].momentum inblock_shroud.wall_motion = "Moving Wall" inblock_shroud.relative = False inblock_shroud.velocity_spec = "Rotational" .. GENERATED FROM PYTHON SOURCE LINES 243-245 Define Boundary Conditions ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 245-279 .. code-block:: Python # Inlet Boundary Condition pressure_inlet = solver_session.settings.setup.boundary_conditions.pressure_inlet[ "inlet" ] pressure_inlet.momentum.supersonic_or_initial_gauge_pressure.value = -100 # It seems, need to change the boundary condition to mass flow outlet solver_session.settings.setup.boundary_conditions.set_zone_type( zone_list=["mass-flow-inlet-11"], new_type="mass-flow-outlet" ) # Outlet Boundary Condition mass_flow_outlet = solver_session.settings.setup.boundary_conditions.mass_flow_outlet[ "mass-flow-inlet-11" ] mass_flow_outlet.momentum.mass_flow_rate.value = 90 # kg/s # Create a turbo interfaces # enable the turbo models solver_session.settings.setup.turbo_models.enabled = True impeller_volute_interface = ( solver_session.settings.setup.mesh_interfaces.turbo_create.create( adjacent_cell_zone_1="impeller", adjacent_cell_zone_2="volute", mesh_interface_name="imp-volute-interface", turbo_choice="No-Pitch-Scale", zone1="interface-impeller-outlet", zone2="interface-volute-inlet", ) ) .. GENERATED FROM PYTHON SOURCE LINES 280-282 Define Solver Settings ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 282-286 .. code-block:: Python methods = solver_session.settings.solution.methods methods.spatial_discretization.gradient_scheme = "green-gauss-node-based" methods.high_order_term_relaxation.enable = True .. GENERATED FROM PYTHON SOURCE LINES 287-289 Define Named Expressions ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 289-295 .. code-block:: Python pump_head = solver_session.settings.setup.named_expressions.create("head") pump_head.definition = "(({p-out} - {p-in}) / (998.2 [kg/m^3] * 9.81[m/s^2]))" pump_head.output_parameter = True .. GENERATED FROM PYTHON SOURCE LINES 296-298 Define Report Definitions ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 298-360 .. code-block:: Python # Create a report definition # p-out outlet_pressure_report_def = ( solver_session.settings.solution.report_definitions.surface.create("p-out") ) outlet_pressure_report_def.report_type = "surface-massavg" outlet_pressure_report_def.surface_names = ["mass-flow-inlet-11"] outlet_pressure_report_def.field = "total-pressure" outlet_pressure_report_def.per_surface = False outlet_pressure_report_plot = ( solver_session.settings.solution.monitor.report_plots.create("p-out-rplot") ) outlet_pressure_report_plot.report_defs = "p-out" outlet_pressure_report_file = ( solver_session.settings.solution.monitor.report_files.create("p-out-rfile") ) outlet_pressure_report_file.report_defs = "p-out" # p-in inlet_pressure_report_def = ( solver_session.settings.solution.report_definitions.surface.create("p-in") ) inlet_pressure_report_def.report_type = "surface-massavg" inlet_pressure_report_def.surface_names = ["inlet"] inlet_pressure_report_def.field = "total-pressure" inlet_pressure_report_def.per_surface = False # Pump Head pump_head_report_def = ( solver_session.settings.solution.report_definitions.single_valued_expression.create( "pump-head" ) ) pump_head_report_def.definition = "head" # report plot pump_head_report_plot = solver_session.settings.solution.monitor.report_plots.create( "pump-head-rplot" ) pump_head_report_plot.report_defs = "pump-head" # report file pump_head_report_file = solver_session.settings.solution.monitor.report_files.create( "pump-head-rfile" ) pump_head_report_file.report_defs = "pump-head" # p-blade blade_pressure_report_def = ( solver_session.settings.solution.report_definitions.surface.create("p-blade") ) blade_pressure_report_def.report_type = "surface-massavg" blade_pressure_report_def.surface_names = ["blade"] blade_pressure_report_def.field = "pressure" blade_pressure_report_def.per_surface = False .. GENERATED FROM PYTHON SOURCE LINES 361-363 Initialization and run solver ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 363-382 .. code-block:: Python initialization = solver_session.settings.solution.initialization initialization.reference_frame = "absolute" initialization.hybrid_init_options.general_settings.initialization_options.initial_pressure = ( True ) initialization.hybrid_initialize() # Run calculation settings run_calculation = solver_session.settings.solution.run_calculation run_calculation.pseudo_time_settings.time_step_method.time_step_size_scale_factor = 10 run_calculation.iter_count = 200 # Write the case file solver_session.settings.file.write( file_type="case", file_name="pump_voulte_setup.cas.h5" ) # Run the calculation run_calculation.calculate() .. GENERATED FROM PYTHON SOURCE LINES 383-385 Post-Processing Workflow ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 385-409 .. code-block:: Python # Create a mid-plane surface at z = -0.015 m z_mid_plane = solver_session.settings.results.surfaces.plane_surface.create( name="z_mid_plane" ) z_mid_plane.method = "xy-plane" z_mid_plane.z = -0.015 z_mid_plane.display() # Define the contour for static pressure pressure_contour = solver_session.settings.results.graphics.contour.create( name="static-pressure-contour" ) pressure_contour.field = "pressure" pressure_contour.surfaces_list = ["z_mid_plane"] # Display the contour and save the image graphics.views.restore_view(view_name="front") pressure_contour.display() graphics.views.auto_scale() graphics.picture.save_picture(file_name="static-pressure-contour.png") .. GENERATED FROM PYTHON SOURCE LINES 410-413 .. image:: ../../_static/static-pressure-contour.png :align: center :alt: Static Pressure Contour .. GENERATED FROM PYTHON SOURCE LINES 415-417 Save the case file ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 417-421 .. code-block:: Python solver_session.settings.file.write( file_type="case-data", file_name="pump_volute_setup_solved.cas.h5" ) .. GENERATED FROM PYTHON SOURCE LINES 422-424 Close the session ============================================================================================================== .. GENERATED FROM PYTHON SOURCE LINES 424-426 .. code-block:: Python solver_session.exit() .. GENERATED FROM PYTHON SOURCE LINES 427-431 References ============================================================================================================== [1] Ansys Fluent User's Guide, Release 2025R1 .. _sphx_glr_download_examples_00-fluent_frozen_rotor_workflow.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: frozen_rotor_workflow.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: frozen_rotor_workflow.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: frozen_rotor_workflow.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_