|
43 | 43 |
|
44 | 44 |
|
45 | 45 | 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. |
47 | 47 | The setup is simulated for a few iterations to allow the examination |
48 | 48 | of the temperature field in the pipe. |
49 | 49 |
|
50 | 50 | """ |
51 | | -# %% |
52 | | -# Import modules, download files, launch products |
53 | | -# ----------------------------------------------- |
54 | | -# Setting up this example consists of performing imports, downloading |
55 | | -# the input file, and launching the required products. |
56 | | -# |
57 | | -# Perform required imports |
58 | | -# ~~~~~~~~~~~~~~~~~~~~~~~~ |
59 | | -# Import ``ansys-systemcoupling-core``, ``ansys-fluent-core`` |
60 | | - |
61 | | -import ansys.fluent.core as pyfluent |
62 | | -import ansys.mapdl.core as pymapdl |
63 | | - |
64 | | -import ansys.systemcoupling.core as pysyc |
65 | | -from ansys.systemcoupling.core import examples |
66 | | - |
67 | | -# %% |
68 | | -# Download the mesh file |
69 | | -fluent_msh_file = examples.download_file( |
70 | | - "fluid_domain.msh", "pysystem-coupling/cht_pipe" |
71 | | -) |
72 | | - |
73 | | -mapdl = pymapdl.launch_mapdl() |
74 | | -mapdl.clear() |
75 | | -mapdl.prep7() |
76 | | - |
77 | | -# %% |
78 | | -# Define material properties |
79 | | -mapdl.mp("EX", 1, 69e9) |
80 | | -mapdl.mp("NUXY", 1, 0.33) |
81 | | -mapdl.mp("DENS", 1, 2700) |
82 | | -mapdl.mp("ALPX", 1, 23.6e-6) |
83 | | -mapdl.mp("KXX", 1, 237) |
84 | | -mapdl.mp("C", 1, 900) |
85 | | - |
86 | | -# %% |
87 | | -# Set element type to SOLID279 |
88 | | -mapdl.et(1, 279) |
89 | | -mapdl.keyopt(1, 2, 1) |
90 | | -print(mapdl) |
91 | | - |
92 | | -# %% |
93 | | -# Parameter of the pipe |
94 | | -r_in = 0.025 |
95 | | -r_out = 0.035 |
96 | | -l = 0.2 |
97 | | - |
98 | | -# %% |
99 | | -# Create hollow pipe |
100 | | -mapdl.cyl4(0, 0, rad1=r_in, rad2=r_out, depth=l) |
101 | | -mapdl.esize(0.002) |
102 | | -mapdl.vsweep(1) |
103 | | -print(mapdl.geometry.anum) |
104 | | - |
105 | | - |
106 | | -# %% |
107 | | -# Biot number prediction |
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 |
114 | | - return Bi |
115 | | - |
116 | | - |
117 | | -Bi = biot_number() |
118 | | -print("The Biot number is ", Bi) |
119 | | - |
120 | | -# %% |
121 | | -# Creating the regions from the geometry for named selections |
122 | | -# Inner wall NS |
123 | | -mapdl.asel("S", "AREA", "", 5, 6) |
124 | | -mapdl.nsla("S", 1) |
125 | | -mapdl.cm("FSIN_1", "NODE") |
126 | | -mapdl.allsel() |
127 | | - |
128 | | -# Outer wall NS |
129 | | -mapdl.asel("S", "AREA", "", 3, 4) |
130 | | -mapdl.cm("Outer_wall", "AREA") |
131 | | -mapdl.allsel() |
132 | | - |
133 | | -# Outlet NS |
134 | | -mapdl.asel("S", "AREA", "", 2) |
135 | | -mapdl.cm("Outlet", "AREA") |
136 | | -mapdl.allsel() |
137 | | - |
138 | | -# Inlet NS |
139 | | -mapdl.asel("S", "AREA", "", 1) |
140 | | -mapdl.cm("Inlet", "AREA") |
141 | | -mapdl.allsel() |
142 | | - |
143 | | -# %% |
144 | | -# Boundary conditions |
145 | | -mapdl.cmsel("S", "Outer_wall") |
146 | | -mapdl.d("Outer_wall", "TEMP", 77) |
147 | | -mapdl.allsel() |
148 | | - |
149 | | -mapdl.cmsel("S", "Inlet") |
150 | | -mapdl.sf("ALL", "HFLUX", 0) |
151 | | -mapdl.allsel() |
152 | | - |
153 | | -mapdl.cmsel("S", "Outlet") |
154 | | -mapdl.sf("ALL", "HFLUX", 0) |
155 | | -mapdl.allsel() |
156 | | - |
157 | | -mapdl.cmsel("S", "FSIN_1") |
158 | | -mapdl.sf("FSIN_1", "FSIN", 1) |
159 | | -mapdl.allsel() |
160 | | - |
161 | | -# %% |
162 | | -# Setup the rest of the analysis |
163 | | -mapdl.run("/SOLU") |
164 | | -mapdl.antype(0) |
165 | | - |
166 | | -# %% |
167 | | -# Set up the fluid analysis |
168 | | -# ~~~~~~~~~~~~~~~~~~~~~~~~~ |
169 | | - |
170 | | -# %% |
171 | | -# Read the pre-created mesh file |
172 | | - |
173 | | -fluent = pyfluent.launch_fluent(start_transcript=False) |
174 | | -fluent.file.read(file_type="mesh", file_name=fluent_msh_file) |
175 | | - |
176 | | -# %% |
177 | | -# Define the fluid solver settings |
178 | | -fluent.setup.models.energy.enabled = True |
179 | | - |
180 | | -# %% |
181 | | -# Add the material |
182 | | -fluent.setup.materials.database.copy_by_name(type="fluid", name="water-liquid") |
183 | | - |
184 | | -fluent.setup.cell_zone_conditions.fluid["fff_fluiddomain"].material = "water-liquid" |
185 | | - |
186 | | -# %% |
187 | | -# Define boundary conditions |
188 | | -fluent.setup.boundary_conditions.velocity_inlet["inlet"].momentum.velocity = 0.1 |
189 | | -fluent.setup.boundary_conditions.velocity_inlet["inlet"].thermal.temperature = 300 |
190 | | -fluent.setup.boundary_conditions.wall["inner_wall"].thermal.thermal_bc = ( |
191 | | - "via System Coupling" |
192 | | -) |
193 | | - |
194 | | -fluent.solution.run_calculation.iter_count = 20 |
195 | | - |
196 | | -# %% |
197 | | -# Set up the coupled analysis |
198 | | -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
199 | | -# System Coupling setup involves adding the structural and fluid |
200 | | -# participants, adding coupled interfaces and data transfers, |
201 | | -# and setting other coupled analysis properties. |
202 | | -syc = pysyc.launch(start_output=True) |
203 | | - |
204 | | -# %% |
205 | | -# Add participants by passing session handles to System Coupling. |
206 | | -fluid_name = syc.setup.add_participant(participant_session=fluent) |
207 | | -solid_name = syc.setup.add_participant(participant_session=mapdl) |
208 | | - |
209 | | -syc.setup.coupling_participant[fluid_name].display_name = "Fluid" |
210 | | -syc.setup.coupling_participant[solid_name].display_name = "Solid" |
211 | | - |
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"], |
219 | | -) |
220 | | - |
221 | | -# %% |
222 | | -# Set up 2-way thermal FSI coupling |
223 | | -syc.setup.add_thermal_data_transfers(interface=interface_name) |
224 | | - |
225 | | -# %% |
226 | | -# Time step size, end time, output controls |
227 | | -syc.setup.solution_control.time_step_size = "0.1 [s]" # time step is 0.1 [s] |
228 | | -syc.setup.solution_control.end_time = 10 # end time is 10.0 [s] |
229 | | - |
230 | | -syc.setup.solution_control.maximum_iterations = 100 |
231 | | - |
232 | | -# %% |
233 | | -# Solution |
234 | | -# -------- |
235 | | -syc.solution.solve() |
236 | | - |
237 | | -# %% |
238 | | -# Exit |
239 | | -# ---- |
240 | | -syc.end_output() |
241 | | -syc.exit() |
| 51 | +# # %% |
| 52 | +# # Import modules, download files, launch products |
| 53 | +# # ----------------------------------------------- |
| 54 | +# # Setting up this example consists of performing imports, downloading |
| 55 | +# # the input file, and launching the required products. |
| 56 | +# # |
| 57 | +# # Perform required imports |
| 58 | +# # ~~~~~~~~~~~~~~~~~~~~~~~~ |
| 59 | +# # Import ``ansys-systemcoupling-core``, ``ansys-fluent-core`` |
| 60 | + |
| 61 | +# import ansys.mapdl.core as pymapdl |
| 62 | +# import ansys.fluent.core as pyfluent |
| 63 | +# import ansys.systemcoupling.core as pysyc |
| 64 | +# from ansys.systemcoupling.core import examples |
| 65 | + |
| 66 | +# # %% |
| 67 | +# # Download the mesh file |
| 68 | +# fluent_msh_file = examples.download_file( |
| 69 | +# "fluid_domain.msh", "pysystem-coupling/cht_pipe" |
| 70 | +# ) |
| 71 | + |
| 72 | +# mapdl=pymapdl.launch_mapdl() |
| 73 | +# mapdl.clear() |
| 74 | +# mapdl.prep7() |
| 75 | + |
| 76 | +# # %% |
| 77 | +# # Define material properties |
| 78 | +# mapdl.mp("EX", 1, 69e9) |
| 79 | +# mapdl.mp("NUXY", 1, 0.33) |
| 80 | +# mapdl.mp("DENS", 1, 2700) |
| 81 | +# mapdl.mp("ALPX", 1, 23.6e-6) |
| 82 | +# mapdl.mp("KXX", 1, 237) |
| 83 | +# mapdl.mp("C", 1 , 900) |
| 84 | + |
| 85 | +# # %% |
| 86 | +# # Set element type to SOLID279 |
| 87 | +# mapdl.et(1, 279) |
| 88 | +# mapdl.keyopt(1, 2, 1) |
| 89 | +# print(mapdl) |
| 90 | + |
| 91 | +# # %% |
| 92 | +# # Parameter of the pipe |
| 93 | +# r_in=0.025 |
| 94 | +# r_out=0.035 |
| 95 | +# l=0.2 |
| 96 | + |
| 97 | +# # %% |
| 98 | +# # Create hollow pipe |
| 99 | +# mapdl.cyl4(0, 0, rad1=r_in, rad2=r_out, depth=l) |
| 100 | +# mapdl.esize(0.002) |
| 101 | +# mapdl.vsweep(1) |
| 102 | +# print(mapdl.geometry.anum) |
| 103 | + |
| 104 | +# # %% |
| 105 | +# # 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 |
| 120 | +# return Bi |
| 121 | +# Bi=biot_number() |
| 122 | +# print("The Biot number is ", Bi) |
| 123 | + |
| 124 | +# # %% |
| 125 | +# # 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) |
| 129 | +# mapdl.cm("FSIN_1", "NODE") |
| 130 | +# mapdl.allsel() |
| 131 | + |
| 132 | +# # Outer wall NS |
| 133 | +# mapdl.asel('S', 'AREA', '', 3, 4) |
| 134 | +# mapdl.cm("Outer_wall", "AREA") |
| 135 | +# mapdl.allsel() |
| 136 | + |
| 137 | +# # Outlet NS |
| 138 | +# mapdl.asel('S', 'AREA', '', 2) |
| 139 | +# mapdl.cm("Outlet", "AREA") |
| 140 | +# mapdl.allsel() |
| 141 | + |
| 142 | +# # Inlet NS |
| 143 | +# mapdl.asel('S', 'AREA', '', 1) |
| 144 | +# mapdl.cm("Inlet", "AREA") |
| 145 | +# mapdl.allsel() |
| 146 | + |
| 147 | +# # %% |
| 148 | +# # Boundary conditions |
| 149 | +# mapdl.cmsel('S', 'Outer_wall') |
| 150 | +# mapdl.d('Outer_wall', 'TEMP', 77) |
| 151 | +# mapdl.allsel() |
| 152 | + |
| 153 | +# mapdl.cmsel('S', 'Inlet') |
| 154 | +# mapdl.sf('ALL', 'HFLUX', 0) |
| 155 | +# mapdl.allsel() |
| 156 | + |
| 157 | +# mapdl.cmsel('S', 'Outlet') |
| 158 | +# mapdl.sf('ALL', 'HFLUX', 0) |
| 159 | +# mapdl.allsel() |
| 160 | + |
| 161 | +# mapdl.cmsel('S', 'FSIN_1') |
| 162 | +# mapdl.sf('FSIN_1', 'FSIN', 1) |
| 163 | +# mapdl.allsel() |
| 164 | + |
| 165 | +# # %% |
| 166 | +# # Setup the rest of the analysis |
| 167 | +# mapdl.run("/SOLU") |
| 168 | +# mapdl.antype(0) |
| 169 | + |
| 170 | +# # %% |
| 171 | +# # Set up the fluid analysis |
| 172 | +# # ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 173 | + |
| 174 | +# # %% |
| 175 | +# # Read the pre-created mesh file |
| 176 | + |
| 177 | +# fluent=pyfluent.launch_fluent(start_transcript=False) |
| 178 | +# fluent.file.read(file_type="mesh", file_name=fluent_msh_file) |
| 179 | + |
| 180 | +# # %% |
| 181 | +# # Define the fluid solver settings |
| 182 | +# fluent.setup.models.energy.enabled =True |
| 183 | + |
| 184 | +# # %% |
| 185 | +# # Add the material |
| 186 | +# fluent.setup.materials.database.copy_by_name(type="fluid", name="water-liquid") |
| 187 | + |
| 188 | +# fluent.setup.cell_zone_conditions.fluid["fff_fluiddomain"].material = "water-liquid" |
| 189 | + |
| 190 | +# # %% |
| 191 | +# # Define boundary conditions |
| 192 | +# fluent.setup.boundary_conditions.velocity_inlet["inlet"].momentum.velocity = 0.1 |
| 193 | +# fluent.setup.boundary_conditions.velocity_inlet["inlet"].thermal.temperature = 300 |
| 194 | +# fluent.setup.boundary_conditions.wall["inner_wall"].thermal.thermal_bc = "via System Coupling" |
| 195 | + |
| 196 | +# fluent.solution.run_calculation.iter_count = 20 |
| 197 | + |
| 198 | +# # %% |
| 199 | +# # Set up the coupled analysis |
| 200 | +# # ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 201 | +# # System Coupling setup involves adding the structural and fluid |
| 202 | +# # participants, adding coupled interfaces and data transfers, |
| 203 | +# # and setting other coupled analysis properties. |
| 204 | +# syc=pysyc.launch(start_output= True) |
| 205 | + |
| 206 | +# # %% |
| 207 | +# # 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) |
| 210 | + |
| 211 | +# syc.setup.coupling_participant[fluid_name].display_name= "Fluid" |
| 212 | +# syc.setup.coupling_participant[solid_name].display_name= "Solid" |
| 213 | + |
| 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"] |
| 219 | +# ) |
| 220 | + |
| 221 | +# # %% |
| 222 | +# # Set up 2-way thermal FSI coupling |
| 223 | +# syc.setup.add_thermal_data_transfers(interface = interface_name) |
| 224 | + |
| 225 | +# # %% |
| 226 | +# # Time step size, end time, output controls |
| 227 | +# syc.setup.solution_control.time_step_size = "0.1 [s]" # time step is 0.1 [s] |
| 228 | +# syc.setup.solution_control.end_time = 10 # end time is 10.0 [s] |
| 229 | + |
| 230 | +# syc.setup.solution_control.maximum_iterations=100 |
| 231 | + |
| 232 | +# # %% |
| 233 | +# # Solution |
| 234 | +# # -------- |
| 235 | +# syc.solution.solve() |
| 236 | + |
| 237 | +# # %% |
| 238 | +# # Exit |
| 239 | +# # ---- |
| 240 | +# syc.end_output() |
| 241 | +# syc.exit() |
| 242 | +# fluent.exit() |
| 243 | +# mapdl.exit() |
0 commit comments