1+ # Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates.
2+ # SPDX-License-Identifier: MIT
3+ #
4+ #
5+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6+ # of this software and associated documentation files (the "Software"), to deal
7+ # in the Software without restriction, including without limitation the rights
8+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+ # copies of the Software, and to permit persons to whom the Software is
10+ # furnished to do so, subject to the following conditions:
11+ #
12+ # The above copyright notice and this permission notice shall be included in all
13+ # copies or substantial portions of the Software.
14+ #
15+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+ # SOFTWARE.
22+
23+ """.. _ref_CHT_pipe_example:
24+
25+ Conjugate Heat transfer- Pipe flow
26+ -----------------------------------
27+
28+ This example illustrates a two way conjugate heat transfer case for *flow in a pipe* that is used as
29+ a tutorial for System Coupling. This Fluid-Structure interaction (FSI) is based on a steady case fluid flow
30+ in a pipe with surface data transfers.
31+
32+ - Ansys Mechanical APDL (MAPDL) is used to perform a structural analysis.
33+ - Ansys Fluent is used to perform a steady fluid-flow analysis.
34+ - System Coupling coordinates the coupled sloution involving the above prodcuts to
35+ solve the multiphysics problem via co-simulation.
36+
37+ **Problem description**
38+
39+ A fluid at a certain temperature flows into a pipe of known diameter and length. As it flows, the heated wall
40+ of the pipe conducts heat to the inner wall, which in turns heats the fluid and cools down the walls of the pipe.
41+ #image
42+
43+ The flow is smooth inside the pipe and the outer wall of the pipe is adiabatic. Fluid enters at an initial
44+ temperature of 300K while the outside pipe of the wall is at some higher temperature. The setup is simulated for
45+ a few iterations to allow the examination of the temperature field in the pipe.
46+
47+ """
48+ # %%
49+ # Import modules, download files, launch products
50+ # -----------------------------------------------
51+ # Setting up this example consists of performing imports, downloading
52+ # the input file, and launching the required products.
53+ #
54+ # Perform required imports
55+ # ~~~~~~~~~~~~~~~~~~~~~~~~
56+ # Import ``ansys-systemcoupling-core``, ``ansys-fluent-core``
57+
58+ import ansys .fluent .core as pyfluent
59+ import ansys .systemcoupling .core as pysyc
60+
61+ # launch Fluent session and read in mesh file
62+ pipe_fluid_session = pyfluent .launch_fluent (start_transcript = False )
63+ pipe_fluid_mesh_file = "pipe_fluid.msh.h5"
64+ pipe_fluid_session .file .read (file_type = "mesh" , file_name = pipe_fluid_mesh_file )
65+
66+ # %%
67+ # Setup
68+ # -----
69+ # The setup consists of setting up the fluids analysis and the coupled analysis.
70+
71+ # turn on energy model
72+ pipe_fluid_session .setup .models .energy .enabled = True
73+
74+ # add water material
75+ pipe_fluid_session .setup .materials .database .copy_by_name (type = "fluid" , name = "water-liquid" )
76+
77+ # set up cell zone conditions
78+ pipe_fluid_session .setup .cell_zone_conditions .fluid ["fluid" ].material = "water-liquid"
79+
80+ # set up boundary conditions
81+ pipe_fluid_session .setup .boundary_conditions .velocity_inlet ["inlet" ].momentum .velocity = 0.1
82+ pipe_fluid_session .setup .boundary_conditions .wall ["wall" ].thermal .thermal_bc = "via System Coupling"
83+
84+ # set up solver settings - 1 fluent iteration per 1 coupling iteration
85+ pipe_fluid_session .solution .run_calculation .iter_count = 1
86+
87+ #===
88+
89+ # launch another Fluent session and read in mesh file
90+ pipe_solid_session = pyfluent .launch_fluent (start_transcript = False )
91+ pipe_solid_mesh_file = "pipe_solid.msh.h5"
92+ pipe_solid_session .file .read (file_type = "mesh" , file_name = pipe_solid_mesh_file )
93+
94+ # turn on energy model
95+ pipe_solid_session .setup .models .energy .enabled = True
96+
97+ # add copper material
98+ pipe_solid_session .setup .materials .database .copy_by_name (type = "solid" , name = "copper" )
99+
100+ # set up cell zone conditions
101+ pipe_solid_session .setup .cell_zone_conditions .solid ["solid" ].material = "copper"
102+
103+ # set up boundary conditions
104+ pipe_solid_session .setup .boundary_conditions .wall ["outer_wall" ].thermal .thermal_bc = "Temperature"
105+ pipe_solid_session .setup .boundary_conditions .wall ["outer_wall" ].thermal .t .value = 350
106+
107+ pipe_solid_session .setup .boundary_conditions .wall ["inner_wall" ].thermal .thermal_bc = "via System Coupling"
108+
109+ pipe_solid_session .setup .boundary_conditions .wall ["insulated1" ].thermal .thermal_bc = "Heat Flux"
110+ pipe_solid_session .setup .boundary_conditions .wall ["insulated1" ].thermal .q .value = 0
111+
112+ pipe_solid_session .setup .boundary_conditions .wall ["insulated2" ].thermal .thermal_bc = "Heat Flux"
113+ pipe_solid_session .setup .boundary_conditions .wall ["insulated2" ].thermal .q .value = 0
114+
115+ # set up solver settings - 1 fluent iteration per 1 coupling iteration
116+ pipe_solid_session .solution .run_calculation .iter_count = 1
0 commit comments