.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/00-Different-analysis-types/05-fluid-simulation.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-Different-analysis-types_05-fluid-simulation.py: .. _ref_fluid_example: Fluid Simulation ================ This example shows how to load a fluid simulation, explore the model and its available zones, species, and phases, as well as how to extract a result. .. note:: This example requires DPF 7.0 (2024.1.pre0) or above. For more information, see :ref:`compatibility`. .. GENERATED FROM PYTHON SOURCE LINES 15-17 Perform required imports ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 17-20 .. code-block:: Python from ansys.dpf import post from ansys.dpf.post import examples .. GENERATED FROM PYTHON SOURCE LINES 21-23 Load the fluid analysis result ------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 23-31 .. code-block:: Python fluid_example_files = examples.download_fluent_axial_comp() simulation = post.FluidSimulation( cas=fluid_example_files["cas"], dat=fluid_example_files["dat"] ) # Printing the simulation will show most of the available metadata print(simulation) .. rst-class:: sphx-glr-script-out .. code-block:: none Fluid Simulation. Data Sources ------------------------------ DPF DataSources: Result files: result key: cas and path: /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/ansys/dpf/core/examples/result_files/fluent-axial_comp/axial_comp-1-01438.cas.h5 result key: cas and path: /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/ansys/dpf/core/examples/result_files/fluent-axial_comp/axial_comp-1-01439.cas.h5 result key: cas and path: /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/ansys/dpf/core/examples/result_files/fluent-axial_comp/axial_comp-1-01440.cas.h5 Secondary files: path: /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/ansys/dpf/core/examples/result_files/fluent-axial_comp/axial_comp-1-01438.dat.h5 path: /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/ansys/dpf/core/examples/result_files/fluent-axial_comp/axial_comp-1-01439.dat.h5 path: /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/ansys/dpf/core/examples/result_files/fluent-axial_comp/axial_comp-1-01440.dat.h5 DPF Model ------------------------------ Static analysis Unit system: SI: m, kg, N, s, V, A, K Physics Type: Fluid Available results: - enthalpy: Elemental Enthalpy - mass_flow_rate: Faces Mass Flow Rate - static_pressure: ElementalAndFaces Static Pressure - mean_static_pressure: Elemental Mean Static Pressure - rms_static_pressure: Elemental Rms Static Pressure - surface_heat_rate: Faces Surface Heat Rate - density: ElementalAndFaces Density - wall_shear_stress: Faces Wall Shear Stress - temperature: ElementalAndFaces Temperature - mean_temperature: ElementalAndFaces Mean Temperature - rms_temperature: Elemental Rms Temperature - velocity: ElementalAndFaces Velocity - mean_velocity: Elemental Mean Velocity - rms_velocity: Elemental Rms Velocity Available qualifier labels: - phase: phase-1 (1) - zone: default-interior:0 (2), rotor-hub (3), rotor-shroud (4), rotor-inlet (5), rotor-interface (6), rotor-blade-1 (7), rotor-blade-2 (8), rotor-per-1-shadow (9), rotor-per-1 (10), rotor-per-2-shadow (11), rotor-per-2 (12), fluid-rotor (13), default-interior (15), stator-hub (16), stator-shroud (17), stator-interface (18), stator-outlet (19), stator-blade-1 (20), stator-blade-2 (21), stator-blade-3 (22), stator-blade-4 (23), stator-per-2 (24), stator-per-2-shadow (25), stator-per-1 (26), stator-per-1-shadow (27), fluid-stator (28) ------------------------------ DPF Meshed Region: 16660 nodes 13856 elements 44242 faces Unit: m With solid (3D) elements ------------------------------ DPF Time/Freq Support: Number of sets: 1 Cumulative Frequency () LoadStep Substep 1 0.000000 1 1 .. GENERATED FROM PYTHON SOURCE LINES 32-35 Explore the available metadata ------------------------------ Check the available cell and face zones .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: Python print(simulation.cell_zones) print(simulation.face_zones) .. rst-class:: sphx-glr-script-out .. code-block:: none {13: 'fluid-rotor', 28: 'fluid-stator'} {2: 'default-interior:0', 3: 'rotor-hub', 4: 'rotor-shroud', 5: 'rotor-inlet', 6: 'rotor-interface', 7: 'rotor-blade-1', 8: 'rotor-blade-2', 9: 'rotor-per-1-shadow', 10: 'rotor-per-1', 11: 'rotor-per-2-shadow', 12: 'rotor-per-2', 15: 'default-interior', 16: 'stator-hub', 17: 'stator-shroud', 18: 'stator-interface', 19: 'stator-outlet', 20: 'stator-blade-1', 21: 'stator-blade-2', 22: 'stator-blade-3', 23: 'stator-blade-4', 24: 'stator-per-2', 25: 'stator-per-2-shadow', 26: 'stator-per-1', 27: 'stator-per-1-shadow'} .. GENERATED FROM PYTHON SOURCE LINES 39-42 The mesh metadata is available separately from the mesh as accessing the mesh means loading it. Use the mesh_info property to explore the mesh structure to define queries .. GENERATED FROM PYTHON SOURCE LINES 42-44 .. code-block:: Python print(simulation.mesh_info) .. rst-class:: sphx-glr-script-out .. code-block:: none Fluid mesh metadata ------------------- Number of nodes: 16660 Number of faces: 45391 Number of cells: 13856 Cell zones: {13: 'fluid-rotor', 28: 'fluid-stator'} Face zones: {2: 'default-interior:0', 3: 'rotor-hub', 4: 'rotor-shroud', 5: 'rotor-inlet', 6: 'rotor-interface', 7: 'rotor-blade-1', 8: 'rotor-blade-2', 9: 'rotor-per-1-shadow', 10: 'rotor-per-1', 11: 'rotor-per-2-shadow', 12: 'rotor-per-2', 15: 'default-interior', 16: 'stator-hub', 17: 'stator-shroud', 18: 'stator-interface', 19: 'stator-outlet', 20: 'stator-blade-1', 21: 'stator-blade-2', 22: 'stator-blade-3', 23: 'stator-blade-4', 24: 'stator-per-2', 25: 'stator-per-2-shadow', 26: 'stator-per-1', 27: 'stator-per-1-shadow'} Cell to face zones: {13: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 28: [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]} .. GENERATED FROM PYTHON SOURCE LINES 45-46 Check the available species .. GENERATED FROM PYTHON SOURCE LINES 46-48 .. code-block:: Python print(simulation.species) .. rst-class:: sphx-glr-script-out .. code-block:: none 0 species available {} .. GENERATED FROM PYTHON SOURCE LINES 49-50 Check the available phases .. GENERATED FROM PYTHON SOURCE LINES 50-53 .. code-block:: Python print(simulation.phases) .. rst-class:: sphx-glr-script-out .. code-block:: none 1 phases available {Phase, } .. GENERATED FROM PYTHON SOURCE LINES 54-58 Extract a result ---------------- ############################################################################## Check the metadata on available results .. GENERATED FROM PYTHON SOURCE LINES 58-60 .. code-block:: Python print(simulation.result_info) .. rst-class:: sphx-glr-script-out .. code-block:: none Static analysis Unit system: SI: m, kg, N, s, V, A, K Physics Type: Fluid Available results: - enthalpy: Elemental Enthalpy - mass_flow_rate: Faces Mass Flow Rate - static_pressure: ElementalAndFaces Static Pressure - mean_static_pressure: Elemental Mean Static Pressure - rms_static_pressure: Elemental Rms Static Pressure - surface_heat_rate: Faces Surface Heat Rate - density: ElementalAndFaces Density - wall_shear_stress: Faces Wall Shear Stress - temperature: ElementalAndFaces Temperature - mean_temperature: ElementalAndFaces Mean Temperature - rms_temperature: Elemental Rms Temperature - velocity: ElementalAndFaces Velocity - mean_velocity: Elemental Mean Velocity - rms_velocity: Elemental Rms Velocity Available qualifier labels: - phase: phase-1 (1) - zone: default-interior:0 (2), rotor-hub (3), rotor-shroud (4), rotor-inlet (5), rotor-interface (6), rotor-blade-1 (7), rotor-blade-2 (8), rotor-per-1-shadow (9), rotor-per-1 (10), rotor-per-2-shadow (11), rotor-per-2 (12), fluid-rotor (13), default-interior (15), stator-hub (16), stator-shroud (17), stator-interface (18), stator-outlet (19), stator-blade-1 (20), stator-blade-2 (21), stator-blade-3 (22), stator-blade-4 (23), stator-per-2 (24), stator-per-2-shadow (25), stator-per-1 (26), stator-per-1-shadow (27), fluid-stator (28) .. GENERATED FROM PYTHON SOURCE LINES 61-62 Print a specific one to get more information on available qualifiers (zones, phases and so on) .. GENERATED FROM PYTHON SOURCE LINES 62-66 .. code-block:: Python print(simulation.result_info["enthalpy"]) # Or use an index # print(simulation.result_info[0]) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF Result ---------- enthalpy Operator name: "H_S" Number of components: 1 Dimensionality: scalar Homogeneity: specific_energy Units: J/kg Location: Elemental Available qualifier labels: - zone: fluid-rotor (13), fluid-stator (28) - phase: phase-1 (1) Available qualifier combinations: {'zone': 13, 'phase': 1} {'zone': 28, 'phase': 1} .. GENERATED FROM PYTHON SOURCE LINES 67-68 Extract this available result as a Dataframe .. GENERATED FROM PYTHON SOURCE LINES 68-72 .. code-block:: Python enthalpy = simulation.enthalpy() print(enthalpy) # Not specifying any qualifier returns a unique column of data .. rst-class:: sphx-glr-script-out .. code-block:: none results H_S (J/kg) set_ids 1 cell_ids 1 2.7790e+05 2 2.7781e+05 3 2.7795e+05 4 2.7712e+05 5 2.7720e+05 6 2.7769e+05 ... ... .. GENERATED FROM PYTHON SOURCE LINES 73-74 Plot the Dataframe .. GENERATED FROM PYTHON SOURCE LINES 74-76 .. code-block:: Python enthalpy.plot() .. image-sg:: /examples/00-Different-analysis-types/images/sphx_glr_05-fluid-simulation_001.png :alt: 05 fluid simulation :srcset: /examples/00-Different-analysis-types/images/sphx_glr_05-fluid-simulation_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 77-80 Available qualifiers for this result can be used in the extraction request to filter/separate data. Here we want a different column for each available zone for this result .. GENERATED FROM PYTHON SOURCE LINES 80-86 .. code-block:: Python print(simulation.enthalpy(zone_ids=[13, 28])) # Here only the data for the fluid-stator zone is extracted print(simulation.enthalpy(zone_ids=[28])) # The same logic can be applied to any available qualifier found in the ``AvailableResult`` # description under 'Available qualifier labels'. .. rst-class:: sphx-glr-script-out .. code-block:: none results H_S (J/kg) set_ids 1 zone fluid-rotor (13) fluid-stator (28) cell_ids 1 2.7790e+05 2 2.7781e+05 3 2.7795e+05 4 2.7712e+05 5 2.7720e+05 6 2.7769e+05 ... ... ... results H_S (J/kg) set_ids 1 zone fluid-stator (28) cell_ids 6081 3.0593e+05 6082 3.0567e+05 6083 3.0510e+05 6084 3.0407e+05 6085 3.0543e+05 6086 3.0252e+05 ... ... .. GENERATED FROM PYTHON SOURCE LINES 87-90 The result extraction request can also contain selection arguments The enthalpy result being defined on cells, you can request data for specific cells using their IDs: .. GENERATED FROM PYTHON SOURCE LINES 90-92 .. code-block:: Python print(simulation.enthalpy(cell_ids=[1, 2])) .. rst-class:: sphx-glr-script-out .. code-block:: none results H_S (J/kg) set_ids 1 cell_ids 1 2.7790e+05 2 2.7781e+05 .. GENERATED FROM PYTHON SOURCE LINES 93-95 For selection and manipulation of the Dataframe, please refer to example "Create and manipulate a DPF Dataframe" .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 6.439 seconds) .. _sphx_glr_download_examples_00-Different-analysis-types_05-fluid-simulation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 05-fluid-simulation.ipynb <05-fluid-simulation.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 05-fluid-simulation.py <05-fluid-simulation.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_