Skip to content

Commit 72d04c7

Browse files
formatted the code
1 parent 2f27c3f commit 72d04c7

File tree

1 file changed

+76
-77
lines changed

1 file changed

+76
-77
lines changed

examples/00-systemcoupling/cht_pipe.py

Lines changed: 76 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
4444
4545
The flow is smooth inside the pipe and the outer wall of the pipe is adiabatic. Fluid enters
46-
at an initial temperature of 300K while the outside pipe of the wall is at 400K.
46+
at an initial temperature of 300K while the outside pipe of the wall is at 400K.
4747
The setup is simulated for a few iterations to allow the examination
4848
of the temperature field in the pipe.
4949
@@ -58,8 +58,9 @@
5858
# ~~~~~~~~~~~~~~~~~~~~~~~~
5959
# Import ``ansys-systemcoupling-core``, ``ansys-fluent-core``
6060

61-
import ansys.mapdl.core as pymapdl
6261
import ansys.fluent.core as pyfluent
62+
import ansys.mapdl.core as pymapdl
63+
6364
import ansys.systemcoupling.core as pysyc
6465
from ansys.systemcoupling.core import examples
6566

@@ -69,101 +70,96 @@
6970
"fluid_domain.msh", "pysystem-coupling/cht_pipe"
7071
)
7172

72-
mapdl=pymapdl.launch_mapdl()
73+
mapdl = pymapdl.launch_mapdl()
7374
mapdl.clear()
7475
mapdl.prep7()
7576

76-
#%%
77-
#Define material properties
77+
# %%
78+
# Define material properties
7879
mapdl.mp("EX", 1, 69e9)
7980
mapdl.mp("NUXY", 1, 0.33)
8081
mapdl.mp("DENS", 1, 2700)
8182
mapdl.mp("ALPX", 1, 23.6e-6)
8283
mapdl.mp("KXX", 1, 237)
83-
mapdl.mp("C", 1 , 900)
84+
mapdl.mp("C", 1, 900)
8485

85-
#%%
86-
#Set element type to SOLID279
86+
# %%
87+
# Set element type to SOLID279
8788
mapdl.et(1, 279)
8889
mapdl.keyopt(1, 2, 1)
8990
print(mapdl)
9091

91-
#%%
92-
#Parameter of the pipe
93-
r_in=0.025
94-
r_out=0.035
95-
l=0.2
92+
# %%
93+
# Parameter of the pipe
94+
r_in = 0.025
95+
r_out = 0.035
96+
l = 0.2
9697

97-
#%%
98-
#Create hollow pipe
99-
mapdl.cyl4(0, 0, rad1=r_in, rad2=r_out, depth=l)
98+
# %%
99+
# Create hollow pipe
100+
mapdl.cyl4(0, 0, rad1=r_in, rad2=r_out, depth=l)
100101
mapdl.esize(0.002)
101102
mapdl.vsweep(1)
102103
print(mapdl.geometry.anum)
103104

105+
104106
# %%
105107
# Biot number prediction
106-
def biot_number(
107-
rho=1000,
108-
mu=1e-3,
109-
cp=4180,
110-
k_f=0.6,
111-
k_s=237,
112-
L_c=r_out-r_in,
113-
U=0.1
114-
):
115-
Re= (rho*U*L_c)/mu
116-
Pr= (mu*cp)/ k_f
117-
Nu= 0.023 * Re**0.8 * Pr**0.4
118-
h= Nu * k_f / L_c
119-
Bi= h *L_c / k_s
108+
def biot_number(rho=1000, mu=1e-3, cp=4180, k_f=0.6, k_s=237, L_c=r_out - r_in, U=0.1):
109+
Re = (rho * U * L_c) / mu
110+
Pr = (mu * cp) / k_f
111+
Nu = 0.023 * Re**0.8 * Pr**0.4
112+
h = Nu * k_f / L_c
113+
Bi = h * L_c / k_s
120114
return Bi
121-
Bi=biot_number()
115+
116+
117+
Bi = biot_number()
122118
print("The Biot number is ", Bi)
123119

124120
# %%
125121
# Creating the regions from the geometry for named selections
126-
#Inner wall NS
127-
mapdl.asel('S', 'AREA', '', 5, 6)
128-
mapdl.nsla('S', 1)
122+
# Inner wall NS
123+
mapdl.asel("S", "AREA", "", 5, 6)
124+
mapdl.nsla("S", 1)
129125
mapdl.cm("FSIN_1", "NODE")
130126
mapdl.allsel()
131127

132-
#Outer wall NS
133-
mapdl.asel('S', 'AREA', '', 3, 4)
128+
# Outer wall NS
129+
mapdl.asel("S", "AREA", "", 3, 4)
134130
mapdl.cm("Outer_wall", "AREA")
135131
mapdl.allsel()
136132

137-
#Outlet NS
138-
mapdl.asel('S', 'AREA', '', 2)
133+
# Outlet NS
134+
mapdl.asel("S", "AREA", "", 2)
139135
mapdl.cm("Outlet", "AREA")
140136
mapdl.allsel()
141137

142-
#Inlet NS
143-
mapdl.asel('S', 'AREA', '', 1)
138+
# Inlet NS
139+
mapdl.asel("S", "AREA", "", 1)
144140
mapdl.cm("Inlet", "AREA")
145141
mapdl.allsel()
146142

147-
#%%
148-
#Boundary conditions
149-
mapdl.cmsel('S', 'Outer_wall')
150-
mapdl.d('Outer_wall', 'TEMP', 77)
143+
# %%
144+
# Boundary conditions
145+
mapdl.cmsel("S", "Outer_wall")
146+
mapdl.d("Outer_wall", "TEMP", 77)
151147
mapdl.allsel()
152148

153-
mapdl.cmsel('S', 'Inlet')
154-
mapdl.sf('ALL', 'HFLUX', 0)
149+
mapdl.cmsel("S", "Inlet")
150+
mapdl.sf("ALL", "HFLUX", 0)
155151
mapdl.allsel()
156152

157-
mapdl.cmsel('S', 'Outlet')
158-
mapdl.sf('ALL', 'HFLUX', 0)
153+
mapdl.cmsel("S", "Outlet")
154+
mapdl.sf("ALL", "HFLUX", 0)
159155
mapdl.allsel()
160156

161-
mapdl.cmsel('S', 'FSIN_1')
162-
mapdl.sf('FSIN_1', 'FSIN', 1)
157+
mapdl.cmsel("S", "FSIN_1")
158+
mapdl.sf("FSIN_1", "FSIN", 1)
163159
mapdl.allsel()
164160

165-
#%%
166-
#Setup the rest of the analysis
161+
# %%
162+
# Setup the rest of the analysis
167163
mapdl.run("/SOLU")
168164
mapdl.antype(0)
169165

@@ -174,24 +170,26 @@ def biot_number(
174170
# %%
175171
# Read the pre-created mesh file
176172

177-
fluent=pyfluent.launch_fluent(start_transcript=False)
173+
fluent = pyfluent.launch_fluent(start_transcript=False)
178174
fluent.file.read(file_type="mesh", file_name=fluent_msh_file)
179175

180-
#%%
181-
#Define the fluid solver settings
182-
fluent.setup.models.energy.enabled =True
176+
# %%
177+
# Define the fluid solver settings
178+
fluent.setup.models.energy.enabled = True
183179

184-
#%%
185-
#Add the material
180+
# %%
181+
# Add the material
186182
fluent.setup.materials.database.copy_by_name(type="fluid", name="water-liquid")
187183

188184
fluent.setup.cell_zone_conditions.fluid["fff_fluiddomain"].material = "water-liquid"
189185

190-
#%%
191-
#Define boundary conditions
186+
# %%
187+
# Define boundary conditions
192188
fluent.setup.boundary_conditions.velocity_inlet["inlet"].momentum.velocity = 0.1
193189
fluent.setup.boundary_conditions.velocity_inlet["inlet"].thermal.temperature = 300
194-
fluent.setup.boundary_conditions.wall["inner_wall"].thermal.thermal_bc = "via System Coupling"
190+
fluent.setup.boundary_conditions.wall["inner_wall"].thermal.thermal_bc = (
191+
"via System Coupling"
192+
)
195193

196194
fluent.solution.run_calculation.iter_count = 20
197195

@@ -201,33 +199,35 @@ def biot_number(
201199
# System Coupling setup involves adding the structural and fluid
202200
# participants, adding coupled interfaces and data transfers,
203201
# and setting other coupled analysis properties.
204-
syc=pysyc.launch(start_output= True)
202+
syc = pysyc.launch(start_output=True)
205203

206-
#%%
204+
# %%
207205
# Add participants by passing session handles to System Coupling.
208-
fluid_name=syc.setup.add_participant(participant_session= fluent)
209-
solid_name=syc.setup.add_participant(participant_session= mapdl)
206+
fluid_name = syc.setup.add_participant(participant_session=fluent)
207+
solid_name = syc.setup.add_participant(participant_session=mapdl)
210208

211-
syc.setup.coupling_participant[fluid_name].display_name= "Fluid"
212-
syc.setup.coupling_participant[solid_name].display_name= "Solid"
209+
syc.setup.coupling_participant[fluid_name].display_name = "Fluid"
210+
syc.setup.coupling_participant[solid_name].display_name = "Solid"
213211

214-
#%%
215-
#Add coupling face and data transfers
216-
interface_name=syc.setup.add_interface(
217-
side_one_participant= fluid_name, side_one_regions= ["inner_wall"],
218-
side_two_participant= solid_name, side_two_regions= ["FSIN_1"]
212+
# %%
213+
# Add coupling face and data transfers
214+
interface_name = syc.setup.add_interface(
215+
side_one_participant=fluid_name,
216+
side_one_regions=["inner_wall"],
217+
side_two_participant=solid_name,
218+
side_two_regions=["FSIN_1"],
219219
)
220220

221-
#%%
222-
#Set up 2-way thermal FSI coupling
223-
syc.setup.add_thermal_data_transfers(interface = interface_name)
221+
# %%
222+
# Set up 2-way thermal FSI coupling
223+
syc.setup.add_thermal_data_transfers(interface=interface_name)
224224

225225
# %%
226226
# Time step size, end time, output controls
227227
syc.setup.solution_control.time_step_size = "0.1 [s]" # time step is 0.1 [s]
228228
syc.setup.solution_control.end_time = 10 # end time is 10.0 [s]
229229

230-
syc.setup.solution_control.maximum_iterations=100
230+
syc.setup.solution_control.maximum_iterations = 100
231231

232232
# %%
233233
# Solution
@@ -239,4 +239,3 @@ def biot_number(
239239
# ----
240240
syc.end_output()
241241
syc.exit()
242-

0 commit comments

Comments
 (0)