Modeling External Compressible Flow#

The purpose of this tutorial is to compute the turbulent flow past a transonic wing at a nonzero angle of attack using the k-w SST turbulence model.

This example uses the guided workflow for watertight geometry meshing because it is appropriate for geometries that can have no imperfections, such as gaps and leakages.

Workflow tasks

The Modeling External Compressible Flow Using the Meshing Workflow guides you through these tasks:

  • Creation of capsule mesh using Watertight Geometry workflow.

  • Model compressible flow (using the ideal gas law for density).

  • Set boundary conditions for external aerodynamics.

  • Use the k-w SST turbulence model.

  • Calculate a solution using the pressure-based coupled solver with global time step selected for the pseudo time method.

  • Check the near-wall mesh resolution by plotting the distribution of .

Problem description

The problem considers the flow around a wing at an angle of attack a=3.06° and a free stream Mach number of 0.8395 (M=0.8395). The flow is transonic, and has a shock near the mid-chord (x/c≃0.20) on the upper (suction) side. The wing has a mean aerodynamic chord length of 0.64607 m, a span of 1.1963 m, an aspect ratio of 3.8, and a taper ratio of 0.562.

../../_images/external_compressible_flow_011.png

Example Setup#

Before you can use the meshing workflow, you must set up the example and initialize this workflow.

Perform required imports#

Perform required imports, which includes downloading and importing the geometry files.

import ansys.fluent.core as pyfluent
from ansys.fluent.core import examples

wing_spaceclaim_file, wing_intermediary_file = [
    examples.download_file(CAD_file, "pyfluent/external_compressible")
    for CAD_file in ["wing.scdoc", "wing.pmdb"]
]

Launch Fluent#

Launch Fluent as a service in meshing mode with double precision running on four processors.

meshing = pyfluent.launch_fluent(
    precision="double",
    processor_count=4,
    mode="meshing",
)

Initialize workflow#

Initialize the watertight geometry meshing workflow.

meshing.workflow.InitializeWorkflow(WorkflowType="Watertight Geometry")

Watertight geometry meshing workflow#

The fault-tolerant meshing workflow guides you through the several tasks that follow.

Import CAD and set length units#

Import the CAD geometry and set the length units to inches.

geo_import = meshing.workflow.TaskObject["Import Geometry"]
geo_import.Arguments.set_state(
    {
        "FileName": wing_intermediary_file,
    }
)

meshing.upload(wing_intermediary_file)
geo_import.Execute()
/home/ansys/actions-runner/_work/pyfluent/pyfluent/src/ansys/fluent/core/session.py:357: PyFluentUserWarning: You have directly called the upload() method of the session.         Please be advised that for the current version of Fluent, many API methods         automatically handle file uploads and downloads internally. You may not         need to explicitly call upload() in most cases.         However, there are exceptions, particularly in PMFileManagement, where complex         file interactions require explicit use of upload()  method         for relevant files.
  warnings.warn(self._file_transfer_api_warning("upload()"), PyFluentUserWarning)

Warning: PMDB file will not be saved as the same is being imported.

Importing one geom object per program-controlled and one zone per body ...
Initializing ANSYS component system ...
running Ansys.Meshing.FieldMesher.exe ...
creating FMComponent instance ...
querying IFieldMesher interface ...
AnsysFieldMesher build date: May 13 2024 15:08:00

argv[0] = /ansys_inc/v242/aisol/CommonFiles/linx64/ansys.meshing.fieldmesher.exe
argv[1] = -B
argv[2] = /ansys_inc/v242/commonfiles/CPython/3_10/linx64/Release/python/../Ansys/TGrid/CADReaders.py
argv[3] = -a
argv[4] = /mnt/pyfluent/FM_e6efa6a1ffbf_152/options1728488949.040747152.xml
argv[5] = -a
argv[6] = /mnt/pyfluent/FM_e6efa6a1ffbf_152/options1728488949.040747152.xml
    /ansys_inc/v242/aisol/CommonFiles/linx64/ansys.meshing.fieldmesher.exe started by root on e6efa6a1ffbf linx64 on Wed Oct  9 15:49:09 2024
    using Python 3.10.12 (main, Mar 26 2024, 02:17:48) [GCC 8.2.0]

    using Ansys.Meshing.FieldMesher build May 13 2024 15:04:53

    running ANSYS TGrid CADToTGridConverter ...
    setting up parameters ...
    setting up parameters done.
    running conversion ...
    converting 1 file(s) from Workbench to FLTG using output path '/mnt/pyfluent/FM_e6efa6a1ffbf_152/out1728488949.040747152.tgf'
    converting file 'wing.pmdb' (1 of 1) from Workbench to FLTG using output path '/mnt/pyfluent/FM_e6efa6a1ffbf_152'
    importing data ...
    importing meshing model from PartMgr from file '/mnt/pyfluent/wing.pmdb' ...
    setting enclosure and symmetry processing to False
    setting transfer named selections to True
    setting named selection prefixes to ''
    setting mixed import resolution type to 'SolidAndSurface'
    setting target application to 'FluentMeshing'
    initializing part manager from file ...
    processing assembly 'V:\v20.2\ajamwal\tutorial\onera_wing_tui_fltg\std\wing.scdoc' with ID 1 and reference key '<?xml version="1.0" encoding="utf-16"?>
    <IdTable xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Table>
        <Entry>
          <Text>&lt;SnippetV1 sctype="SpaceClaim.BasicMoniker`1[[SpaceClaim.IEvaluation, Core]], Core" refId="96eb1453-b93e-47b3-ac40-b839719e0f23:2" /&gt;</Text>
          <ExplodedBodyText>&lt;SnippetV1 sctype="SpaceClaim.BasicMoniker`1[[SpaceClaim.IEvaluation, Core]], Core" refId="3b3e1be1-19e3-426a-b9be-57a5d102de0c:359" /&gt;</ExplodedBodyText>
          <Id>10000</Id>
          <IsExploded>true</IsExploded>
        </Entry>
        <Entry>
          <Text>&lt;SnippetV1 sctype="SpaceClaim.BasicMoniker`1[[SpaceClaim.IEvaluation, Core]], Core" refId="96eb1453-b93e-47b3-ac40-b839719e0f23:2" /&gt;</Text>
          <ExplodedBodyText>&lt;SnippetV1 sctype="SpaceClaim.BasicMoniker`1[[SpaceClaim.IEvaluation, Core]], Core" refId="6913b575-3023-4a96-8ca3-797ab1ec6f00:31674" /&gt;</ExplodedBodyText>
          <Id>10001</Id>
          <IsExploded>true</IsExploded>
        </Entry>
      </Table>
    </IdTable>'
    length unit = [m]
    processing part 'wing' with ID 3
    processing part 'wing' with ID 5
    processing named selection 'fluid_symmetry'
    processing named selection 'pressure_farfield'
    processing named selection 'wing_bottom'
    processing named selection 'wing_top'
    processing named selection 'wing_edge'
    processing data ...
    removing named collections of entities ...
    removing named collections of entities stopped, no named collections selected.
    analyzing feature edges ...
    detecting feature edges, feature angle = 40 [deg] ...
        Data information
            Meshing model
                Attributes:
                    'LengthUnit': '[mm]'
                Entity summary:
                    Collection: 5
                    Component : 3
                    Body      : 2
                    Shell     : 2
                    Face      : 19
                    Loop      : 20
                    Edge      : 38
                    Vertex    : 24
                    Surface   : 19
                    Curve     : 38
                Tessellation summary:
                    Face facets  : 2691
                    Edge segments: 426
                Bounding box:
                    (-25039.427734375, -9.623148855553154e-08, -25039.421875) x (26144.078125, 25039.427734375, 25039.43223878741)
                Assembly component hierarchy:
                    'V:\v20.2\ajamwal\tutorial\onera_wing_tui_fltg\std\wing.scdoc'
                      'wing'
                      'wing'
                NamedCollections:
                    'fluid_symmetry'
                    'pressure_farfield'
                    'wing_bottom'
                    'wing_top'
                    'wing_edge'


    exporting FLTG data to file '/mnt/pyfluent/FM_e6efa6a1ffbf_152/out1728488949.040747152.tgf' ...
    writing face-based mesh file '/mnt/pyfluent/FM_e6efa6a1ffbf_152/out1728488949.040747152.tgf' ...
    ======== Exported Data ========
    Entity summary:
        Object       : 2
        Object region: 7
        Zone         : 16

    running conversion done.
    running ANSYS TGrid CADToTGridConverter done.
    ran ANSYS TGrid CADToTGridConverter in 0.123 [s]
        ======== Command Execution Log Manager ========
        Number of execution logs: 0


Reading "/mnt/pyfluent/FM_e6efa6a1ffbf_152/out1728488949.040747152.tgf"...

nodes: 1603
edges: 267
faces: 2649
cells: 0
generating pointers...done.
extracting boundary entities...
 1603 boundary nodes.
 2649 boundary faces.
 6 boundary face zones.
done.
analyzing boundary connectivity...done.


---------------- Import of wing, consisting of 2 parts/objects, complete.

Add local sizing#

Add local sizing controls to the faceted geometry.

local_sizing = meshing.workflow.TaskObject["Add Local Sizing"]
local_sizing.Arguments.set_state(
    {
        "AddChild": "yes",
        "BOIControlName": "wing-facesize",
        "BOIFaceLabelList": ["wing_bottom", "wing_top"],
        "BOISize": 10,
    }
)

local_sizing.AddChildAndUpdate()

local_sizing.Arguments.set_state(
    {
        "AddChild": "yes",
        "BOIControlName": "wing-ege-facesize",
        "BOIFaceLabelList": ["wing_edge"],
        "BOISize": 2,
    }
)

local_sizing.AddChildAndUpdate()

local_sizing.Arguments.set_state(
    {
        "AddChild": "yes",
        "BOIControlName": "boi_1",
        "BOIExecution": "Body Of Influence",
        "BOIFaceLabelList": ["wing-boi"],
        "BOISize": 5,
    }
)

local_sizing.AddChildAndUpdate()
---------------- A local size of 10 was added to wing-facesize

---------------- The Global Min size was adjusted to 2

---------------- A local size of 2 was added to wing-ege-facesize

---------------- A Body of Influence with a target size of 5 was added to: wing-boi

Generate surface mesh#

Generate the surface mash.

surface_mesh_gen = meshing.workflow.TaskObject["Generate the Surface Mesh"]
surface_mesh_gen.Arguments.set_state(
    {"CFDSurfaceMeshControls": {"MaxSize": 1000, "MinSize": 2}}
)

surface_mesh_gen.Execute()
Writing "/mnt/pyfluent/FM_e6efa6a1ffbf_152/TaskObject3.msh.h5" ...
writing 1 node zones
writing 10 edge zones
writing 6 face zones
writing node curvature data...
done.    processing size functions/scoped sizing to create Size Field...

Writing "/mnt/pyfluent/FM_e6efa6a1ffbf_152/wing.sf"...

Done.


Importing one mesh object per program-controlled and one zone per body ...
Initializing ANSYS component system ...
running Ansys.Meshing.FieldMesher.exe ...
creating FMComponent instance ...
querying IFieldMesher interface ...
AnsysFieldMesher build date: May 13 2024 15:08:00

argv[0] = /ansys_inc/v242/aisol/CommonFiles/linx64/ansys.meshing.fieldmesher.exe
argv[1] = -B
argv[2] = /ansys_inc/v242/commonfiles/CPython/3_10/linx64/Release/python/../Ansys/TGrid/CADReaders.py
argv[3] = -a
argv[4] = /mnt/pyfluent/FM_e6efa6a1ffbf_152/options1728488955.702896152.xml
argv[5] = -a
argv[6] = /mnt/pyfluent/FM_e6efa6a1ffbf_152/options1728488955.702896152.xml
    /ansys_inc/v242/aisol/CommonFiles/linx64/ansys.meshing.fieldmesher.exe started by root on e6efa6a1ffbf linx64 on Wed Oct  9 15:49:16 2024
    using Python 3.10.12 (main, Mar 26 2024, 02:17:48) [GCC 8.2.0]

    using Ansys.Meshing.FieldMesher build May 13 2024 15:04:53

    running ANSYS TGrid CADToTGridConverter ...
    setting up parameters ...
    setting up parameters done.
    running conversion ...
    converting 1 file(s) from Workbench to FLTG using output path '/mnt/pyfluent/FM_e6efa6a1ffbf_152/out1728488955.702896152.tgf'
    converting file 'wing.pmdb' (1 of 1) from Workbench to FLTG using output path '/mnt/pyfluent/FM_e6efa6a1ffbf_152'
    importing data ...
    importing meshing model from PartMgr from file '/mnt/pyfluent/wing.pmdb' ...
    setting enclosure and symmetry processing to False
    setting transfer named selections to True
    setting named selection prefixes to ''
    setting mixed import resolution type to 'SolidAndSurface'
    setting target application to 'FluentMeshing'
    initializing part manager from file ...
    processing assembly 'V:\v20.2\ajamwal\tutorial\onera_wing_tui_fltg\std\wing.scdoc' with ID 1 and reference key '<?xml version="1.0" encoding="utf-16"?>
    <IdTable xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Table>
        <Entry>
          <Text>&lt;SnippetV1 sctype="SpaceClaim.BasicMoniker`1[[SpaceClaim.IEvaluation, Core]], Core" refId="96eb1453-b93e-47b3-ac40-b839719e0f23:2" /&gt;</Text>
          <ExplodedBodyText>&lt;SnippetV1 sctype="SpaceClaim.BasicMoniker`1[[SpaceClaim.IEvaluation, Core]], Core" refId="3b3e1be1-19e3-426a-b9be-57a5d102de0c:359" /&gt;</ExplodedBodyText>
          <Id>10000</Id>
          <IsExploded>true</IsExploded>
        </Entry>
        <Entry>
          <Text>&lt;SnippetV1 sctype="SpaceClaim.BasicMoniker`1[[SpaceClaim.IEvaluation, Core]], Core" refId="96eb1453-b93e-47b3-ac40-b839719e0f23:2" /&gt;</Text>
          <ExplodedBodyText>&lt;SnippetV1 sctype="SpaceClaim.BasicMoniker`1[[SpaceClaim.IEvaluation, Core]], Core" refId="6913b575-3023-4a96-8ca3-797ab1ec6f00:31674" /&gt;</ExplodedBodyText>
          <Id>10001</Id>
          <IsExploded>true</IsExploded>
        </Entry>
      </Table>
    </IdTable>'
    length unit = [m]
    processing part 'wing' with ID 3
    processing part 'wing' with ID 5
    processing named selection 'fluid_symmetry'
    processing named selection 'pressure_farfield'
    processing named selection 'wing_bottom'
    processing named selection 'wing_top'
    processing named selection 'wing_edge'
    processing data ...
    loading size function background grid from file '/mnt/pyfluent/FM_e6efa6a1ffbf_152//wing.sf' ...
    reading size function background grid file '/mnt/pyfluent/FM_e6efa6a1ffbf_152//wing.sf' ...
     Read 379882 vertices
    initializing size function background grid done in 0.22 [s]
    tessellating 19 faces done in 22.48 [s]
    removing named collections of entities ...
    removing named collections of entities stopped, no named collections selected.
    analyzing feature edges ...
    detecting feature edges, feature angle = 40 [deg] ...
        Data information
            Meshing model
                Attributes:
                    'LengthUnit': '[mm]'
                Entity summary:
                    Collection: 5
                    Component : 3
                    Body      : 2
                    Shell     : 2
                    Face      : 19
                    Loop      : 20
                    Edge      : 38
                    Vertex    : 24
                    Surface   : 19
                    Curve     : 38
                Tessellation summary:
                    Face facets  : 146550
                    Edge segments: 4352
                Bounding box:
                    (-25035.203125, -9.623148855553154e-08, -25039.421875) x (26144.078125, 25039.42578125, 25039.431640625)
                Assembly component hierarchy:
                    'V:\v20.2\ajamwal\tutorial\onera_wing_tui_fltg\std\wing.scdoc'
                      'wing'
                      'wing'
                NamedCollections:
                    'fluid_symmetry'
                    'pressure_farfield'
                    'wing_bottom'
                    'wing_top'
                    'wing_edge'


    exporting FLTG data to file '/mnt/pyfluent/FM_e6efa6a1ffbf_152/out1728488955.702896152.tgf' ...
    writing face-based mesh file '/mnt/pyfluent/FM_e6efa6a1ffbf_152/out1728488955.702896152.tgf' ...
    ======== Exported Data ========
    Entity summary:
        Object       : 2
        Object region: 7
        Zone         : 16

    running conversion done.
    running ANSYS TGrid CADToTGridConverter done.
    ran ANSYS TGrid CADToTGridConverter in 23.191 [s]
        ======== Command Execution Log Manager ========
        Number of execution logs: 0


Reading "/mnt/pyfluent/FM_e6efa6a1ffbf_152/out1728488955.702896152.tgf"...

nodes: 77268
edges: 3995
faces: 146550
cells: 0
appending mesh...
done.
generating pointers...done.
extracting boundary entities...
 78871 boundary nodes.
 149199 boundary faces.
 12 boundary face zones.
done.

Reading "/mnt/pyfluent/FM_e6efa6a1ffbf_152//wing.sf"...

 Read 379882 vertices
Warning: Deleting empty objects (wing-boi)

removed 54012 faces.
0 faces marked.

    computing regions...done
Deleting import_curvature_0
Deleting import_proximity_0
    processing size functions/scoped sizing to create Size Field...

Writing "/mnt/pyfluent/FM_e6efa6a1ffbf_152/wing.sf"...

Done.


remeshing...


------------------------- --------------------- -------------------- ---------------- ----------
                     name skewed-cells (> 0.80)    averaged-skewness maximum-skewness face count
------------------------- --------------------- -------------------- ---------------- ----------

                    fluid                     0          0.027823784       0.65385375      79840
------------------------- --------------------- -------------------- ---------------- ----------
                     name skewed-cells (> 0.80)    averaged-skewness maximum-skewness face count
------------------------- --------------------- -------------------- ---------------- ----------

               wing-fluid                     0          0.027823784       0.65385375      79840

---------------- After Surface mesh, the model consists of 1 fluid/solid regions and 0 voids.

---------------- Surface Meshing of wing complete in  0.53 minutes, with a maximum skewness of  0.65.

Describe geometry#

Describe geometry and define the fluid region.

describe_geo = meshing.workflow.TaskObject["Describe Geometry"]
describe_geo.UpdateChildTasks(SetupTypeChanged=False)

describe_geo.Arguments.set_state(
    {"SetupType": "The geometry consists of only fluid regions with no voids"}
)

describe_geo.UpdateChildTasks(SetupTypeChanged=True)

describe_geo.Execute()
---------------- Symmetry zone type was automatically assigned to zones containing the string '*symmetry*'.

---------------- Pressure-far-field zone type was automatically assigned to zones containing the string '*far*field*'.

---------------- Describe Geometry task complete in  0.00 minutes.

Update boundaries#

Update the boundaries.

meshing.workflow.TaskObject["Update Boundaries"].Execute()
---------------- Boundary Conditions Updated

Update regions#

Update the regions.

meshing.workflow.TaskObject["Update Regions"].Execute()
---------------- Regions Updated

Add boundary layers#

Add boundary layers, which consist of setting properties for the boundary layer mesh.

add_boundary_layer = meshing.workflow.TaskObject["Add Boundary Layers"]
add_boundary_layer.Arguments.set_state({"NumberOfLayers": 12})

add_boundary_layer.AddChildAndUpdate()
Created Scoped Prism: smooth-transition_1

---------------- Inflation control added to wing-fluid

Generate volume mesh#

Generate the volume mesh, which consists of setting properties for the volume mesh.

volume_mesh_gen = meshing.workflow.TaskObject["Generate the Volume Mesh"]
volume_mesh_gen.Arguments.set_state(
    {
        "VolumeFill": "poly-hexcore",
        "VolumeFillControls": {"HexMaxCellLength": 512},
        "VolumeMeshPreferences": {
            "CheckSelfProximity": "yes",
            "ShowVolumeMeshPreferences": True,
        },
    }
)

volume_mesh_gen.Execute()
Writing "/mnt/pyfluent/FM_e6efa6a1ffbf_152/TaskObject11.msh.h5" ...
writing 3 node zones
writing 20 edge zones
writing 11 face zones
writing node curvature data...
done.    processing size functions/scoped sizing to create Size Field...

Writing "/mnt/pyfluent/FM_e6efa6a1ffbf_152/wing.sf"...

Done.


    updating regions...
    done.
checking object "wing-fluid"...
    skipping validating regions of mesh object "wing-fluid"...done.
auto meshing object wing-fluid...

processing scoped prisms...
    starting orientation...
done.
    setting prism growth...done.
done.
Identifying Topology...

The octree hexcore cells will be refined using the computed Size Field.
Generating Prisms...

Generating initial mesh...

Refining mesh...

Create polyhedra ...

delete virtual and dead zones.

Merging zones...

Cleaning up dead entities...


Merging Domains...
done.

                     name       id cells (quality < 0.05)  minimum quality cell count
------------------------- -------- ---------------------- ---------------- ----------
                    fluid      660                      0      0.060917203    1010403

                     name       id cells (quality < 0.05)  minimum quality cell count
------------------------- -------- ---------------------- ---------------- ----------
          Overall Summary     none                      0      0.060917203    1010403

Total Number of Cell Zones : 1

[Quality Measure : Orthogonal Quality]

---------------- Volume mesh creation completed in :  0.71 minutes

---------------- 1010403 cells were created in :  0.74 minutes

---------------- The mesh has a minimum Orthogonal Quality of:  0.06

---------------- The volume meshing of wing-fluid is complete.

Check mesh in meshing mode#

Check the mesh in meshing mode.

meshing.tui.mesh.check_mesh()
Domain extents.
  x-coordinate: min = -2.503520e+04, max = 2.614408e+04.
  y-coordinate: min = -9.623149e-08, max = 2.503895e+04.
  z-coordinate: min = -2.503942e+04, max = 2.503943e+04.
Volume statistics.
  minimum volume: 6.586764e-04.
  maximum volume: 4.131039e+08.
    total volume: 4.214428e+13.
Face area statistics.
   minimum face area: 3.599234e-03.
   maximum face area: 1.203898e+06.
   average face area: 6.202794e+04.
Checking number of nodes per edge.
Checking number of nodes per face.
Checking number of nodes per cell.
Checking number of faces/neighbors per cell.
Checking cell faces/neighbors.
Checking isolated cells.
Checking face handedness.
Checking periodic face pairs.
Checking face children.
Checking face zone boundary conditions.
Checking for invalid node coordinates.
Checking poly cells.
Checking zones.
Checking neighborhood.
Checking modified centroid.
Checking non-positive or too small area.
Checking face zones thread type.

Save mesh file#

Save the mesh file (wing.msh.h5).

meshing.meshing.File.WriteMesh(FileName="wing.msh.h5")
Done.Writing "wing.msh.h5" ...
writing 3 node zones
writing 10 edge zones
writing 6 face zones
writing 1 cell zones
writing boundary layer flags
writing node curvature data...
done.Copying the required intermediate mesh files into wing_workflow_files
Done.

Solve and postprocess#

Once you have completed the watertight geometry meshing workflow, you can solve and postprcess the results.

Switch to solution mode#

Switch to solution mode. Now that a high-quality mesh has been generated using Fluent in meshing mode, you can switch to solver mode to complete the setup of the simulation.

solver = meshing.switch_to_solver()
Preparing...

Check mesh in solver mode#

Check the mesh in solver mode. The mesh check lists the minimum and maximum x, y, and z values from the mesh in the default SI units of meters. It also reports a number of other mesh features that are checked. Any errors in the mesh are reported.

solver.mesh.check()
unused zone boundary-node-20 removed

Transferring mesh
        creating threads... done
        transferring nodes... done
        transferring cells... done
        transferring faces... done
        post mesh transfer operations... done
done

Building...
     mesh
        auto partitioning mesh by Metis (fast),
        distributing mesh
                parts....,
                faces....,
                nodes....,
                cells....,
        bandwidth reduction using Reverse Cuthill-McKee: 254558/11371 = 22.3866
     materials,
     interface,
     domains,
     zones,
        interior--fluid
        fluid_symmetry
        pressure_farfield
        wing_edge
        wing_bottom
        wing_top
        fluid
     surfaces,
     parallel,
Done.
Mesh is now scaled to meters.
Warning: Pressure far-field boundary condition can only be used with ideal gas law.
  Please change either the boundary condition type or enable ideal gas law.
  Solver cannot proceed until this is fixed.
        Warning: Pressure far-field boundary condition can only be used with ideal gas law.
  Please change either the boundary condition type or enable ideal gas law.
  Solver cannot proceed until this is fixed.

 Domain Extents:
   x-coordinate: min (m) = -2.502407e+01, max (m) = 2.614408e+01
   y-coordinate: min (m) = -9.623149e-11, max (m) = 2.503569e+01
   z-coordinate: min (m) = -2.503942e+01, max (m) = 2.503943e+01
 Volume statistics:
   minimum volume (m3): 6.586764e-13
   maximum volume (m3): 4.131039e-01
     total volume (m3): 4.214428e+04
 Face area statistics:
   minimum face area (m2): 3.599234e-09
   maximum face area (m2): 1.203898e+00
 Checking mesh.....................................
Done.

Note: Settings to improve the robustness of pathline and
      particle tracking have been automatically enabled.

Define model#

Set the k-w sst turbulence model.

# model : k-omega
# k-omega model : sst

viscous = solver.setup.models.viscous

viscous.model = "k-omega"
viscous.k_omega_model = "sst"

Define materials#

Modify the default material air to account for compressibility and variations of the thermophysical properties with temperature.

# density : ideal-gas
# viscosity : sutherland
# viscosity method : three-coefficient-method
# reference viscosity : 1.716e-05 [kg/(m s)]
# reference temperature : 273.11 [K]
# effective temperature : 110.56 [K]

air = solver.setup.materials.fluid["air"]

air.density.option = "ideal-gas"

air.viscosity.option = "sutherland"

air.viscosity.sutherland.option = "three-coefficient-method"

air.viscosity.sutherland.reference_viscosity = 1.716e-05

air.viscosity.sutherland.reference_temperature = 273.11

air.viscosity.sutherland.effective_temperature = 110.56
Note: Enabling energy equation as required by material density method.

Boundary Conditions#

Set the boundary conditions for pressure_farfield.

# gauge pressure : 0 [Pa]
# mach number : 0.8395
# temperature : 255.56 [K]
# x-component of flow direction : 0.998574
# z-component of flow direction : 0.053382
# turbulent intensity : 5 [%]
# turbulent viscosity ratio : 10

pressure_farfield = solver.setup.boundary_conditions.pressure_far_field[
    "pressure_farfield"
]

pressure_farfield.momentum.gauge_pressure = 0

pressure_farfield.momentum.mach_number = 0.8395

pressure_farfield.thermal.temperature = 255.56

pressure_farfield.momentum.flow_direction[0] = 0.998574

pressure_farfield.momentum.flow_direction[2] = 0.053382

pressure_farfield.turbulence.turbulent_intensity = 0.05

pressure_farfield.turbulence.turbulent_viscosity_ratio = 10

Operating Conditions#

Set the operating conditions.

# operating pressure : 80600 [Pa]

solver.setup.general.operating_conditions.operating_pressure = 80600

Initialize flow field#

Initialize the flow field using hybrid initialization.

solver.solution.initialization.hybrid_initialize()
Initialize using the hybrid initialization method.

Checking case topology...
-This case has a single farfield bc
-Case will be initialized with constant pressure

        iter            scalar-0

        1               1.000000e+00
        2               4.433467e-04
        3               9.199689e-05
        4               1.500116e-05
        5               3.983735e-06
        6               6.922224e-07
        7               1.628843e-07
        8               2.762818e-08
        9               6.616204e-09
        10              1.414052e-09

Hybrid initialization is done.

Save case file#

Save the case file external_compressible1.cas.h5.

solver.file.write(file_name="external_compressible.cas.h5", file_type="case")
Fast-loading "/ansys_inc/v242/fluent/fluent24.2.0/addons/afd/lib/hdfio.bin"
Done.

Writing to e6efa6a1ffbf:"/mnt/pyfluent/external_compressible.cas.h5" in NODE0 mode and compression level 1 ...
Grouping cells for Laplace smoothing ...
     1010403 cells,     1 zone  ...
     3952199 faces,     6 zones ...
     2018208 nodes,     1 zone  ...
  Done.

  Writing boundary layer flags ...
  Done.
Done.

Solve for 25 iterations#

Solve for 25 iterations (100 iterations is recommended, however for this example 25 is sufficient).

solver.solution.run_calculation.iterate(iter_count=25)
iter  continuity  x-velocity  y-velocity  z-velocity      energy           k       omega     time/iter
   1  1.0000e+00  3.9881e-07  3.7960e-07  8.0695e-07  9.2198e-07  9.9599e-01  4.9891e-01  0:03:58   24
   2  1.0000e+00  3.6050e-07  3.4643e-07  6.0292e-07  8.6895e-07  9.9339e-01  4.9823e-01  0:03:44   23
   3  1.0000e+00  3.3924e-07  3.6989e-07  5.3014e-07  8.0775e-07  9.8814e-01  4.9710e-01  0:03:29   22
   4  1.0000e+00  3.1999e-07  3.9791e-07  5.0728e-07  7.3524e-07  9.7272e-01  4.9522e-01  0:03:15   21
   5  1.0000e+00  3.0000e-07  4.1918e-07  5.0119e-07  6.6902e-07  9.3890e-01  4.9198e-01  0:02:59   20
   6  1.0344e+00  2.8263e-07  4.2705e-07  4.9595e-07  6.0770e-07  8.4099e-01  4.8625e-01  0:02:45   19
   7  1.0446e+00  2.6757e-07  4.2317e-07  4.8896e-07  5.5606e-07  5.5886e-01  4.7576e-01  0:02:32   18
   8  1.0332e+00  2.5742e-07  4.0998e-07  4.7665e-07  5.1545e-07  2.7783e-01  4.5612e-01  0:02:22   17
   9  1.0133e+00  2.5326e-07  3.9011e-07  4.6033e-07  4.8806e-07  1.3178e-01  4.1958e-01  0:02:12   16
  10  9.9203e-01  2.5191e-07  3.6668e-07  4.4215e-07  4.6922e-07  6.3681e-02  3.5648e-01  0:02:03   15
  11  9.6230e-01  2.5078e-07  3.4195e-07  4.2189e-07  4.5708e-07  3.2872e-02  2.6504e-01  0:01:53   14

iter  continuity  x-velocity  y-velocity  z-velocity      energy           k       omega     time/iter
  12  9.2893e-01  2.4992e-07  3.1642e-07  3.9973e-07  4.4596e-07  1.8927e-02  1.6508e-01  0:01:45   13
  13  8.9369e-01  2.4907e-07  2.8977e-07  3.7459e-07  4.3206e-07  1.2729e-02  8.6925e-02  0:01:37   12
  14  8.5485e-01  2.4841e-07  2.6173e-07  3.4653e-07  4.1726e-07  9.5712e-03  4.1018e-02  0:01:29   11
  15  8.1897e-01  2.5034e-07  2.3272e-07  3.1765e-07  4.0414e-07  7.5092e-03  1.8473e-02  0:01:21   10
  16  7.9422e-01  2.5416e-07  2.0463e-07  2.9139e-07  3.9441e-07  6.0726e-03  8.3204e-03  0:01:13    9
  17  7.7353e-01  2.5533e-07  1.8032e-07  2.6870e-07  3.9183e-07  5.0630e-03  3.8719e-03  0:01:05    8
  18  7.6246e-01  2.5714e-07  1.6365e-07  2.5228e-07  3.9510e-07  4.3283e-03  1.9102e-03  0:00:57    7
  19  7.5012e-01  2.5693e-07  1.5338e-07  2.4140e-07  3.9246e-07  3.7566e-03  1.0174e-03  0:00:48    6
  20  7.3439e-01  2.4704e-07  1.4348e-07  2.2684e-07  3.7844e-07  3.3013e-03  5.8934e-04  0:00:40    5
  21  7.0619e-01  2.3444e-07  1.3280e-07  2.0899e-07  3.5983e-07  2.9263e-03  3.6995e-04  0:00:32    4
  22  6.6852e-01  2.2045e-07  1.2219e-07  1.9088e-07  3.4148e-07  2.6107e-03  2.4877e-04  0:00:24    3

iter  continuity  x-velocity  y-velocity  z-velocity      energy           k       omega     time/iter
  23  6.2377e-01  2.0719e-07  1.1342e-07  1.7319e-07  3.2884e-07  2.3293e-03  1.7679e-04  0:00:16    2
  24  5.7480e-01  2.0173e-07  1.0477e-07  1.5496e-07  3.1791e-07  2.0729e-03  1.3122e-04  0:00:08    1
  25  5.3764e-01  1.9155e-07  9.9063e-08  1.4235e-07  3.0146e-07  1.8089e-03  1.0081e-04  0:00:00    0

Write final case file and data#

Write the final case file and the data.

solver.file.write(file_name="external_compressible1.cas.h5", file_type="case")
Writing to e6efa6a1ffbf:"/mnt/pyfluent/external_compressible1.cas.h5" in NODE0 mode and compression level 1 ...
Grouping cells for Laplace smoothing ...
     1010403 cells,     1 zone  ...
     3952199 faces,     6 zones ...
     2018208 nodes,     1 zone  ...
  Done.

  Writing boundary layer flags ...
  Done.
Done.

Close Fluent#

Close Fluent.

solver.exit()

Total running time of the script: (6 minutes 9.178 seconds)

Gallery generated by Sphinx-Gallery