.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/00-postprocessing/post_processing_exhaust_manifold.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-postprocessing_post_processing_exhaust_manifold.py: .. _ref_post_processing_exhaust_manifold: Postprocessing using PyVista and Matplotlib ------------------------------------------- This example uses PyVista and Matplotlib to demonstrate PyFluent postprocessing capabilities. The 3D model in this example is an exhaust manifold that has high temperature flows passing through it. The flow through the manifold is turbulent and involves conjugate heat transfer. .. GENERATED FROM PYTHON SOURCE LINES 14-17 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports and set the configuration. .. GENERATED FROM PYTHON SOURCE LINES 17-27 .. code-block:: Python import ansys.fluent.core as pyfluent from ansys.fluent.core import examples from ansys.fluent.visualization import Graphics, Plots, set_config pyfluent.CONTAINER_MOUNT_PATH = pyfluent.EXAMPLES_PATH set_config(blocking=True, set_view_on_display="isometric") .. GENERATED FROM PYTHON SOURCE LINES 28-33 Download files and launch Fluent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Download the case and data files and launch Fluent as a service in solver mode with double precision and two processors. Read in the case and data files. .. GENERATED FROM PYTHON SOURCE LINES 33-48 .. code-block:: Python import_case = examples.download_file( file_name="exhaust_system.cas.h5", directory="pyfluent/exhaust_system" ) import_data = examples.download_file( file_name="exhaust_system.dat.h5", directory="pyfluent/exhaust_system" ) solver_session = pyfluent.launch_fluent( precision="double", processor_count=2, start_transcript=False, mode="solver" ) solver_session.file.read_case(file_name=import_case) solver_session.file.read_data(file_name=import_data) .. GENERATED FROM PYTHON SOURCE LINES 49-52 Get graphics object ~~~~~~~~~~~~~~~~~~~ Get the graphics object. .. GENERATED FROM PYTHON SOURCE LINES 52-55 .. code-block:: Python graphics = Graphics(session=solver_session) .. GENERATED FROM PYTHON SOURCE LINES 56-59 Create graphics object for mesh display ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create a graphics object for the mesh display. .. GENERATED FROM PYTHON SOURCE LINES 59-62 .. code-block:: Python mesh1 = graphics.Meshes["mesh-1"] .. GENERATED FROM PYTHON SOURCE LINES 63-66 Show edges ~~~~~~~~~~ Show edges on the mesh. .. GENERATED FROM PYTHON SOURCE LINES 66-69 .. code-block:: Python mesh1.show_edges = True .. GENERATED FROM PYTHON SOURCE LINES 70-73 Get surfaces list ~~~~~~~~~~~~~~~~~ Get the surfaces list. .. GENERATED FROM PYTHON SOURCE LINES 73-85 .. code-block:: Python mesh1.surfaces = [ "in1", "in2", "in3", "out1", "solid_up:1", "solid_up:1:830", "solid_up:1:830-shadow", ] mesh1.display("window-1") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_001.png :alt: post processing exhaust manifold :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 86-89 Hide edges and display again ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Hide the edges and display again. .. GENERATED FROM PYTHON SOURCE LINES 89-93 .. code-block:: Python mesh1.show_edges = False mesh1.display("window-2") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_002.png :alt: post processing exhaust manifold :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 94-97 Create plane-surface XY plane ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create a plane-surface XY plane. .. GENERATED FROM PYTHON SOURCE LINES 97-105 .. code-block:: Python surf_xy_plane = graphics.Surfaces["xy-plane"] surf_xy_plane.definition.type = "plane-surface" surf_xy_plane.definition.plane_surface.creation_method = "xy-plane" plane_surface_xy = surf_xy_plane.definition.plane_surface.xy_plane plane_surface_xy.z = -0.0441921 surf_xy_plane.display("window-3") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_003.png :alt: post processing exhaust manifold :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 106-109 Create plane-surface YZ plane ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create a plane-surface YZ plane. .. GENERATED FROM PYTHON SOURCE LINES 109-117 .. code-block:: Python surf_yz_plane = graphics.Surfaces["yz-plane"] surf_yz_plane.definition.type = "plane-surface" surf_yz_plane.definition.plane_surface.creation_method = "yz-plane" plane_surface_yz = surf_yz_plane.definition.plane_surface.yz_plane plane_surface_yz.x = -0.174628 surf_yz_plane.display("window-4") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_004.png :alt: post processing exhaust manifold :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 118-121 Create plane-surface ZX plane ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create a plane-surface ZX plane. .. GENERATED FROM PYTHON SOURCE LINES 121-129 .. code-block:: Python surf_zx_plane = graphics.Surfaces["zx-plane"] surf_zx_plane.definition.type = "plane-surface" surf_zx_plane.definition.plane_surface.creation_method = "zx-plane" plane_surface_zx = surf_zx_plane.definition.plane_surface.zx_plane plane_surface_zx.y = -0.0627297 surf_zx_plane.display("window-5") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_005.png :alt: post processing exhaust manifold :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 130-133 Create iso-surface on outlet plane ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create an iso-surface on the outlet plane. .. GENERATED FROM PYTHON SOURCE LINES 133-141 .. code-block:: Python surf_outlet_plane = graphics.Surfaces["outlet-plane"] surf_outlet_plane.definition.type = "iso-surface" iso_surf1 = surf_outlet_plane.definition.iso_surface iso_surf1.field = "y-coordinate" iso_surf1.iso_value = -0.125017 surf_outlet_plane.display("window-3.1") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_006.png :alt: post processing exhaust manifold :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_006.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 142-145 Create iso-surface on mid-plane ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create an iso-surface on the mid-plane. .. GENERATED FROM PYTHON SOURCE LINES 145-153 .. code-block:: Python surf_mid_plane_x = graphics.Surfaces["mid-plane-x"] surf_mid_plane_x.definition.type = "iso-surface" iso_surf2 = surf_mid_plane_x.definition.iso_surface iso_surf2.field = "x-coordinate" iso_surf2.iso_value = -0.174 surf_mid_plane_x.display("window-4.1") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_007.png :alt: post processing exhaust manifold :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_007.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 154-157 Create iso-surface using velocity magnitude ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create an iso-surface using the velocity magnitude. .. GENERATED FROM PYTHON SOURCE LINES 157-166 .. code-block:: Python surf_vel_contour = graphics.Surfaces["surf-vel-contour"] surf_vel_contour.definition.type = "iso-surface" iso_surf3 = surf_vel_contour.definition.iso_surface iso_surf3.field = "velocity-magnitude" iso_surf3.rendering = "contour" iso_surf3.iso_value = 0.0 surf_vel_contour.display("window-5.1") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_008.png :alt: post processing exhaust manifold :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_008.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 167-170 Create temperature contour on mid-plane and outlet ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create a temperature contour on the mid-plane and the outlet. .. GENERATED FROM PYTHON SOURCE LINES 170-176 .. code-block:: Python temperature_contour = graphics.Contours["contour-temperature"] temperature_contour.field = "temperature" temperature_contour.surfaces = ["mid-plane-x", "outlet-plane"] temperature_contour.display("window-6") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_009.png :alt: post processing exhaust manifold :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_009.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 177-180 Create contour plot of temperature on manifold ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create a contour plot of the temperature on the manifold. .. GENERATED FROM PYTHON SOURCE LINES 180-193 .. code-block:: Python temperature_contour_manifold = graphics.Contours["contour-temperature-manifold"] temperature_contour_manifold.field = "temperature" temperature_contour_manifold.surfaces = [ "in1", "in2", "in3", "out1", "solid_up:1", "solid_up:1:830", ] temperature_contour_manifold.display("window-7") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_010.png :alt: post processing exhaust manifold :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_010.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 194-197 Create vector ~~~~~~~~~~~~~ Create a vector on a predefined surface. .. GENERATED FROM PYTHON SOURCE LINES 197-204 .. code-block:: Python velocity_vector = graphics.Vectors["velocity-vector"] velocity_vector.field = "pressure" velocity_vector.surfaces = ["solid_up:1:830"] velocity_vector.scale = 2 velocity_vector.display("window-8") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_011.png :alt: post processing exhaust manifold :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_011.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 205-208 Create Pathlines ~~~~~~~~~~~~~~~~ Create a pathlines on a predefined surface. .. GENERATED FROM PYTHON SOURCE LINES 208-214 .. code-block:: Python pathlines = graphics.Pathlines["pathlines"] pathlines.field = "velocity-magnitude" pathlines.surfaces = ["inlet", "inlet1", "inlet2"] pathlines.display("window-9") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_012.png :alt: post processing exhaust manifold :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_012.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 215-218 Create plot object ~~~~~~~~~~~~~~~~~~ Create the plot object for the session. .. GENERATED FROM PYTHON SOURCE LINES 218-221 .. code-block:: Python plots_session_1 = Plots(solver_session) .. GENERATED FROM PYTHON SOURCE LINES 222-225 Create XY plot ~~~~~~~~~~~~~~ Create the default XY plot. .. GENERATED FROM PYTHON SOURCE LINES 225-228 .. code-block:: Python xy_plot = plots_session_1.XYPlots["xy-plot"] .. GENERATED FROM PYTHON SOURCE LINES 229-232 Set plot surface and Y-axis function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set the surface on which to generate the plot and the Y-axis function. .. GENERATED FROM PYTHON SOURCE LINES 232-236 .. code-block:: Python xy_plot.surfaces = ["outlet"] xy_plot.y_axis_function = "temperature" .. GENERATED FROM PYTHON SOURCE LINES 237-240 Display XY plot ~~~~~~~~~~~~~~~~ Display the generated XY plot. .. GENERATED FROM PYTHON SOURCE LINES 240-243 .. code-block:: Python xy_plot.plot("window-9") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_013.png :alt: XY Plot :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_013.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 244-247 Create residual plot ~~~~~~~~~~~~~~~~~~~~~~ Create and display the residual plot. .. GENERATED FROM PYTHON SOURCE LINES 247-253 .. code-block:: Python matplotlib_plots1 = Plots(solver_session) residual = matplotlib_plots1.Monitors["residual"] residual.monitor_set_name = "residual" residual.plot("window-10") .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_014.png :alt: residual :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_014.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 254-257 Solve and plot solution monitors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Solve and plot solution monitors. .. GENERATED FROM PYTHON SOURCE LINES 257-270 .. code-block:: Python solver_session.solution.initialization.hybrid_initialize() solver_session.solution.run_calculation.iterate(iter_count=50) matplotlib_plots1 = Plots(solver_session) mass_bal_rplot = matplotlib_plots1.Monitors["mass-bal-rplot"] mass_bal_rplot.monitor_set_name = "mass-bal-rplot" mass_bal_rplot.plot("window-11") matplotlib_plots1 = Plots(solver_session) point_vel_rplot = matplotlib_plots1.Monitors["point-vel-rplot"] point_vel_rplot.monitor_set_name = "point-vel-rplot" point_vel_rplot.plot("window-12") .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_015.png :alt: mass-bal-rplot :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_015.png :class: sphx-glr-multi-img * .. image-sg:: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_016.png :alt: point-vel-rplot :srcset: /examples/00-postprocessing/images/sphx_glr_post_processing_exhaust_manifold_016.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 271-274 Close Fluent ~~~~~~~~~~~~ Close Fluent. .. GENERATED FROM PYTHON SOURCE LINES 274-276 .. code-block:: Python solver_session.exit() .. rst-class:: sphx-glr-timing **Total running time of the script:** (2 minutes 18.719 seconds) .. _sphx_glr_download_examples_00-postprocessing_post_processing_exhaust_manifold.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: post_processing_exhaust_manifold.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: post_processing_exhaust_manifold.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_