5858import ansys .fluent .core as pyfluent
5959import ansys .systemcoupling .core as pysyc
6060
61+ #===
62+
6163# launch Fluent session and read in mesh file
6264pipe_fluid_session = pyfluent .launch_fluent (start_transcript = False )
6365pipe_fluid_mesh_file = "pipe_fluid.msh.h5"
6466pipe_fluid_session .file .read (file_type = "mesh" , file_name = pipe_fluid_mesh_file )
6567
66- # %%
67- # Setup
68- # -----
69- # The setup consists of setting up the fluids analysis and the coupled analysis.
70-
7168# turn on energy model
7269pipe_fluid_session .setup .models .energy .enabled = True
7370
113110pipe_solid_session .setup .boundary_conditions .wall ["insulated2" ].thermal .q .value = 0
114111
115112# set up solver settings - 1 fluent iteration per 1 coupling iteration
116- pipe_solid_session .solution .run_calculation .iter_count = 1
113+ pipe_solid_session .solution .run_calculation .iter_count = 1
114+
115+ import numpy as np
116+
117+
118+ rho_water = 998.2
119+ mu_water = 1.002e-3
120+ k_water = 0.6
121+ Pr_water = 7.0
122+
123+ rho_al = 2700
124+ k_al = 237
125+ cp_al = 900
126+
127+
128+ # Flow and Geometry
129+
130+ u = 0.5 # velocity [m/s]
131+ L = 0.5 # pipe length [m]
132+ D = 0.1 # inner diameter [m] → characteristic length for fluid
133+ t_wall = 0.12 # wall thickness [m] → characteristic length for solid conduction
134+
135+
136+ # Functions
137+
138+ def getReynoldsNumber (rho , u , D , mu ):
139+ return rho * u * D / mu
140+
141+ def getPrandtlNumber (mu , cp , k ):
142+ return mu * cp / k
143+
144+ def getNusseltNumber (Re , Pr , L_over_D ):
145+
146+ if Re < 2300 :
147+ Nu = 3.66 # laminar, fully developed
148+ elif Re < 10000 :
149+ Nu = 0.023 * Re ** 0.8 * Pr ** 0.4 # transitional approximation
150+ else :
151+ Nu = 0.023 * Re ** 0.8 * Pr ** 0.4 # fully turbulent
152+ return Nu
153+
154+ def getConvectionCoefficient (Nu , k_fluid , D ):
155+ return Nu * k_fluid / D
156+
157+ def getBiotNumber (h , k_solid , t_wall ):
158+ return h * t_wall / k_solid
159+
160+
161+ Re = getReynoldsNumber (rho_water , u , D , mu_water )
162+ Pr = Pr_water # directly used
163+ L_over_D = L / D
164+
165+ Nu = getNusseltNumber (Re , Pr , L_over_D )
166+ h = getConvectionCoefficient (Nu , k_water , D )
167+ Bi = getBiotNumber (h , k_al , t_wall )
168+
169+
170+ print (f"{ 'Parameter' :<25} { 'Value' :<15} { 'Unit' } " )
171+ print ("-" * 50 )
172+ print (f"{ 'Reynolds Number (Re)' :<25} { Re :<15.2f} " )
173+ print (f"{ 'Prandtl Number (Pr)' :<25} { Pr :<15.1f} " )
174+ print (f"{ 'Nusselt Number (Nu)' :<25} { Nu :<15.2f} " )
175+ print (f"{ 'Convection coeff (h)' :<25} { h :<15.1f} W/m²·K" )
176+ print (f"{ 'Biot Number (Bi)' :<25} { Bi :<15.6f} " )
177+ print ("-" * 50 )
178+ print (f"The Biot number is { Bi :.6f} " )
179+
180+
181+ if Bi < 0.1 :
182+ print ("→ Bi < 0.1 → Lumped capacitance valid (uniform wall temperature)" )
183+ elif Bi > 10 :
184+ print ("→ Bi > 10 → Significant temperature gradient in wall" )
185+ else :
186+ print ("→ 0.1 < Bi < 10 → Moderate internal resistance" )
187+ #===
188+
189+ # launch System Coupling session
190+ syc = pysyc .launch ()
191+ syc .start_output ()
192+
193+ # add two Fluent sessions above as participants
194+ fluid_name = syc .setup .add_participant (participant_session = pipe_fluid_session )
195+ solid_name = syc .setup .add_participant (participant_session = pipe_solid_session )
196+ syc .setup .coupling_participant [fluid_name ].display_name = "Fluid"
197+ syc .setup .coupling_participant [solid_name ].display_name = "Solid"
198+
199+ # add a coupling interface
200+ interface = syc .setup .add_interface (
201+ side_one_participant = fluid_name , side_one_regions = ["wall" ],
202+ side_two_participant = solid_name , side_two_regions = ["inner_wall" ])
203+
204+ # set up 2-way coupling - add temperature and heat flow data transfers
205+ syc .setup .add_thermal_data_transfers (interface = interface )
206+
207+ # set up coupled analysis settings
208+ # it should take about 80 iterations to converge
209+ syc .setup .solution_control .maximum_iterations = 100
210+
211+ #===
212+
213+ # solve the coupled analysis
214+ syc .solution .solve ()
215+
216+ #===
217+
218+ # clean up at the end
219+ syc .end_output ()
220+ pipe_fluid_session .exit ()
221+ pipe_solid_session .exit ()
222+ syc .exit ()
0 commit comments