Skip to content
1 change: 1 addition & 0 deletions doc/changelog.d/5273.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update script formatting [skip tests]
1 change: 1 addition & 0 deletions doc/changelog.d/5283.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Minor Updates - axial_fan_performance_curve_workflow.py [skip tests]
68 changes: 33 additions & 35 deletions examples/00-fluent/axial_fan_performance_curve_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# This example demonstrates an end-to-end PyFluent workflow for simulating an axial fan and performing a parametric study to generate its performance curve.
#
# The workflow includes:
#
# * Importing a CFD mesh
# * Defining input parameters for the parametric study
# * Configuring the Fluent solver and physical models
Expand All @@ -36,9 +37,8 @@
# Solution Setup
# ---------------
#
# %%
# Import required libraries and download required files
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

import os

Expand All @@ -50,14 +50,14 @@

# Download the example mesh file
import_file_name = examples.download_file(
"axial_fan.msh",
"pyfluent/axial_fan_perfrormance_curve",
"axial_fan.msh.h5",
"pyfluent/axial_fan_performance_curve",
save_path=os.getcwd(),
)

# %%
# Launch Fluent
# ^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^
# Launch Fluent in solution mode with double precision running on eight processors.

solver = pyfluent.launch_fluent(
Expand All @@ -70,15 +70,15 @@

# %%
# Read mesh file and perform mesh check
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Import the mesh and perform a mesh check.

solver.settings.file.read_mesh(file_name=import_file_name)
solver.settings.mesh.check()

# %%
# Creat input parameters
# ^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^
# Create named expressions for the pressure outlet boundary condition and for the fan rotational speed, and set them as input parameters.
# Pressure outlet value is set to 0.0 Pa (atmospheric gauge pressure) and rotational speed is set to 155.534 rad/s.

Expand All @@ -96,7 +96,7 @@

# %%
# Solver setup
# ^^^^^^^^^^^^^
# ^^^^^^^^^^^^
# Set the solver type to pressure-based, and analysis type to steady state, and activate gravity in the negative x-direction.

# General: Solver Type: Pressure-Based
Expand All @@ -110,9 +110,9 @@
solver.settings.setup.general.operating_conditions.gravity.components = [-9.81, 0, 0]

# %%
# Models: Turbulance/Viscous Model
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Set the turbulance/viscous model to SST k-omega model.
# Turbulence/Viscous model
# ^^^^^^^^^^^^^^^^^^^^^^^^
# Set the turbulence/viscous model to SST k-omega model.
# Activate curvature correction, production Kato-Launder, and production limiter options.

viscous = solver.settings.setup.models.viscous
Expand All @@ -124,9 +124,9 @@
solver.settings.setup.models.viscous.options.production_limiter.enabled = True

# %%
# Cell Zones
# ^^^^^^^^^^^
# Activate the Multiple Reference Frame (MRF) model for the <code>'rotating-fan'</code> zone,
# Cell zones
# ^^^^^^^^^^
# Activate the Multiple Reference Frame (MRF) model for the 'rotating-fan' zone,
# specify the Y-axis as axis of rotation, and set the rotational speed using the previously defined input parameter.
# Keep the default setting for the remaining cell zones.

Expand All @@ -153,9 +153,9 @@

# %%
# Boundary conditions
# ^^^^^^^^^^^^^^^^^^^^
# Set the <code>'inlet'</code> boundary as pressure-inlet boundary condition type, and assign to it a pressure value of 0.0 Pa (atmospheric gauge pressure).
# Set the <code>'pressure-outlet'</code> boundary as pressure-outlet boundary condition type, and assign to it the previously defined input parameter.
# ^^^^^^^^^^^^^^^^^^^
# Set the 'inlet' boundary as pressure-inlet boundary condition type, and assign to it a pressure value of 0.0 Pa (atmospheric gauge pressure).
# Set the 'pressure-outlet' boundary as pressure-outlet boundary condition type, and assign to it the previously defined input parameter.
# Keep the remaining boundaries as no-slip wall boundary condition type (default settings - no changes)

boundary_conditions = solver.settings.setup.boundary_conditions
Expand All @@ -180,7 +180,7 @@

# %%
# Solution methods and controls
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Set the pressure-velocity coupling scheme and spatial discretization methods. Also, set the under-relaxation factors.

# Solution methods
Expand All @@ -207,7 +207,7 @@

# %%
# Create report definitions and output parameters
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Create report definitions for computed quantities of interest including, inlet volume flow rate, total-to-static pressure difference, and torque.

# Report definition: Inlet volume flow rate
Expand Down Expand Up @@ -290,7 +290,7 @@

# %%
# Set the number of iterations for the calculation and enable convergence condition check
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Set the number of solution iterations to 2500, and enable the convergence condition check.

solver.settings.solution.run_calculation.parameters.iter_count = 2500
Expand All @@ -299,25 +299,24 @@

# %%
# Save case file
# ^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^
# Write the case with all settings in place.

solver.settings.file.write_case(file_name="axial_fan.cas.h5")

# %%
# Parametric study: Construct the fan performance curve
# ------------------------------------------------------
# Parametric Study: Construct the Fan Performance Curve
# -----------------------------------------------------
#
# %%
# Initialize parametric study
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Initialize a parametric design point study from a Fluent session.

solver.settings.parametric_studies.initialize(project_filename="project_axial_fan")

# %%
# Access and modify input parameters
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Access and modify the input parameters of the base design point.
# Set the pressure at the outlet boundary to 25 Pa, and keep the fan's rotational speed at 155.534 rad/s.

Expand All @@ -331,7 +330,7 @@

# %%
# Add new design points
# ^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^
# Create four new design points and assign outlet pressure and rotational
# speed to each one.
# The fan's rotational speed is set constant in this study.
Expand Down Expand Up @@ -378,36 +377,35 @@

# %%
# Save the current parametric project
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

solver.settings.file.parametric_project.save()

# %%
# Update all design points
# ^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^
# Update all design points by running the CFD simulation for every design point.

solver.settings.parametric_studies["axial_fan-Solve"].design_points.update_all()

# %%
# Save current parametric project
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

solver.settings.file.parametric_project.save()

# %%
# Export the design table
# ^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^
# Export the design point table to a CSV file.

# parametric_table_save_path = os.path.join(working_directory, 'design_point_table_study.csv')
solver.settings.parametric_studies.export_design_table(
filepath="../../../design_point_table_study.csv"
)

# %%
# Plotting fan performance curve
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Plot the computed total-to-static pressure rise versus the inlet volume flow rate.

# Load the design point study results data from the CSV file
Expand Down Expand Up @@ -435,9 +433,9 @@

# %%
# Close Fluent
# ^^^^^^^^^^^^^^
# ^^^^^^^^^^^^
# Close Fluent session.

solver.exit()

# sphinx_gallery_thumbnail_path = '/_static/axial_fan_performance_curve/problem_schematic.png'
# sphinx_gallery_thumbnail_path = '_static/axial_fan_performance_curve/problem_schematic.png'