@@ -43,7 +43,7 @@ class RadiationInterface(SolverInterface):
43
43
44
44
"""
45
45
46
- def __init__ (self , comm , model , conv_hist = False , complex_mode = False ):
46
+ def __init__ (self , comm , model , conv_hist = False , complex_mode = False , debug = False ):
47
47
"""
48
48
The instantiation of the thermal radiation interface class will populate the model
49
49
with the aerodynamic surface mesh, body.aero_X and body.aero_nnodes.
@@ -60,6 +60,9 @@ def __init__(self, comm, model, conv_hist=False, complex_mode=False):
60
60
self .comm = comm
61
61
self .conv_hist = conv_hist
62
62
self .complex_mode = complex_mode
63
+ self .debug = debug
64
+
65
+ self .sigma_sb = 5.670374419e-8
63
66
64
67
# setup forward and adjoint tolerances
65
68
super ().__init__ ()
@@ -206,16 +209,15 @@ def iterate(self, scenario: Scenario, bodies: list[Body], step):
206
209
f .write ("{0:03d} " .format (step ))
207
210
208
211
for ibody , body in enumerate (bodies , 1 ):
209
- aero_X = body .get_aero_nodes ()
210
- aero_id = body .get_aero_node_ids ()
211
212
aero_nnodes = body .get_num_aero_nodes ()
212
213
213
214
aero_temps = body .get_aero_temps (scenario , time_index = step )
214
- print (f"aero_temps: { aero_temps } " )
215
- heat_rad = self .calc_heat_flux (aero_temps , scenario )
216
-
217
215
heat_flux = body .get_aero_heat_flux (scenario , time_index = step )
218
- heat_flux += heat_rad
216
+
217
+ if aero_temps is not None and aero_nnodes > 0 :
218
+ heat_rad = self .calc_heat_flux (aero_temps , scenario )
219
+
220
+ heat_flux += heat_rad
219
221
220
222
return 0
221
223
@@ -255,17 +257,16 @@ def iterate_adjoint(self, scenario: Scenario, bodies: list[Body], step):
255
257
256
258
nfuncs = scenario .count_adjoint_functions ()
257
259
for ibody , body in enumerate (bodies , 1 ):
258
- # Get the adjoint-Jacobian product for the heat flux
260
+ # Get the adjoint-Jacobian product for the aero temperature
259
261
aero_flux_ajp = body .get_aero_heat_flux_ajp (scenario )
260
262
aero_nnodes = body .get_num_aero_nodes ()
261
- aero_flux = body .get_aero_heat_flux (scenario , time_index = step )
262
263
aero_temps = body .get_aero_temps (scenario , time_index = step )
263
264
264
265
aero_temps_ajp = body .get_aero_temps_ajp (scenario )
265
266
266
- if aero_flux_ajp is not None and aero_nnodes > 0 :
267
- # Solve the aero heat flux computation adjoint
268
- # dR/dhA ^{T} * psi_R = - dQ/dhA^{T} * psi_Q = - aero_flux_ajp
267
+ if aero_temps_ajp is not None and aero_nnodes > 0 :
268
+ # Add contribution to aero_temps_ajp from radiation
269
+ # dR/dhR ^{T} * psi_R = dA_dhA^{T} * psi_A = - dQ/dhA^{T} * psi_Q = - aero_flux_ajp
269
270
psi_R = aero_flux_ajp
270
271
271
272
rad_heat_deriv = self .calc_heat_flux_deriv (aero_temps , scenario )
@@ -276,13 +277,11 @@ def iterate_adjoint(self, scenario: Scenario, bodies: list[Body], step):
276
277
for func in range (nfuncs ):
277
278
lam [:, func ] = psi_R [:, func ] * rad_heat_deriv [:]
278
279
279
- if not self .complex_mode :
280
- lam = lam .astype (np .double )
281
-
282
- for func in range (nfuncs ):
283
- print (f"aero_flux_ajp: { aero_flux_ajp [:, func ]} " )
284
- print (f"lam: { lam [:, func ]} " )
285
- aero_flux_ajp [:, func ] += lam [:, func ]
280
+ for ifunc in range (nfuncs ):
281
+ if self .debug and self .comm .rank == 0 :
282
+ print (f"aero_temps_ajp: { aero_temps_ajp [:, func ]} " )
283
+ print (f"lam: { lam [:, func ]} " )
284
+ aero_temps_ajp [:, ifunc ] += lam [:, ifunc ]
286
285
287
286
return
288
287
@@ -313,11 +312,10 @@ def calc_heat_flux(self, temps, scenario=None):
313
312
F_v = scenario .F_v
314
313
T_v = scenario .T_v
315
314
316
- sigma_sb = 5.670374419e-8
317
315
rad_heat = np .zeros_like (temps , dtype = TransferScheme .dtype )
318
316
319
317
for indx , temp_i in enumerate (temps ):
320
- rad_heat [indx ] = - sigma_sb * emis * F_v * (temp_i ** 4 - T_v ** 4 )
318
+ rad_heat [indx ] = - self . sigma_sb * emis * F_v * (temp_i ** 4 - T_v ** 4 )
321
319
322
320
return rad_heat
323
321
@@ -331,16 +329,13 @@ def calc_heat_flux_deriv(self, temps, scenario=None):
331
329
if scenario is None :
332
330
emis = 0.8
333
331
F_v = 1.0
334
- T_v = 0.0
335
332
else :
336
333
emis = scenario .emis
337
334
F_v = scenario .F_v
338
- T_v = scenario .T_v
339
335
340
- sigma_sb = 5.670374419e-8
341
336
rad_heat_deriv = np .zeros_like (temps , dtype = TransferScheme .dtype )
342
337
343
338
for indx , temp_i in enumerate (temps ):
344
- rad_heat_deriv [indx ] = - 4 * sigma_sb * emis * F_v * temp_i ** 3
339
+ rad_heat_deriv [indx ] = - 4 * self . sigma_sb * emis * F_v * temp_i ** 3
345
340
346
341
return rad_heat_deriv
0 commit comments