23
23
# TODO: ADJUST TO HANDLE ANY STRAIGHT W 6MM SIMU
24
24
mb = 64
25
25
26
-
27
26
# tritium fraction = T/D
28
27
PULSE_TYPE_TO_TRITIUM_FRACTION = {
29
28
"FP" : 0.5 ,
@@ -192,14 +191,50 @@ def make_mb_model(nb_mb, scenario_file):
192
191
pulse_type_to_DINA_data = {
193
192
"FP" : np .loadtxt ("Binned_Flux_Data.dat" , skiprows = 1 ),
194
193
"ICWC" : np .loadtxt ("ICWC_data.dat" , skiprows = 1 ),
195
- "RISP" : np .loadtxt ("Binned_Flux_Data.dat" , skiprows = 1 ),
196
194
"GDC" : np .loadtxt ("GDC_data.dat" , skiprows = 1 ),
197
- "BAKE" : np .loadtxt ("Binned_Flux_Data.dat" , skiprows = 1 ),
198
195
}
199
196
197
+ def RISP_data (monob , time ):
198
+ """Returns the correct RISP data file for indicated monoblock
199
+
200
+ Args:
201
+ monob (int): mb number
202
+ t (int): time as an integer
203
+
204
+ Returns:
205
+ data (np.array): data from correct file as a numpy array
206
+ """
207
+ inner_swept_bins = list (range (46 ,65 ))
208
+ outer_swept_bins = list (range (19 ,34 ))
209
+
210
+ if monob in inner_swept_bins :
211
+ label = "RISP"
212
+ div = True
213
+ offset_mb = 46
214
+ elif monob in outer_swept_bins :
215
+ label = "ROSP"
216
+ div = True
217
+ offset_mb = 19
218
+ else :
219
+ div = False
220
+ offset_mb = 0
221
+
222
+ t = int (time )
223
+
224
+ if div :
225
+ if t in list (range (1 ,10 )): data = np .loadtxt (label + "_data/time0.dat" , skiprows = 1 )
226
+ elif t in list (range (11 ,99 )): data = np .loadtxt (label + "_data/time10.dat" , skiprows = 1 )
227
+ elif t in list (range (100 ,261 )): data = np .loadtxt (label + "_data/time" + str (t )+ ".dat" , skiprows = 1 )
228
+ elif t in list (range (261 ,270 )): data = np .loadtxt (label + "_data/time270.dat" , skiprows = 1 )
229
+ else : data = np .loadtxt ("RISP_Wall_data.dat" , skiprows = 1 )
230
+ else :
231
+ data = np .loadtxt ("RISP_Wall_data.dat" , skiprows = 1 )
232
+
233
+ return data [monob - offset_mb ,:]
234
+
200
235
############# Temperature Parameters (K) #############
201
236
202
- def heat (pulse_type : str ) -> float :
237
+ def heat (pulse_type : str , t : float ) -> float :
203
238
"""Returns the surface heat flux for a given pulse type
204
239
205
240
Args:
@@ -213,12 +248,17 @@ def heat(pulse_type: str) -> float:
213
248
"""
214
249
if pulse_type not in ["FP" , "ICWC" , "RISP" , "GDC" , "BAKE" ]:
215
250
raise ValueError (f"Invalid pulse type { pulse_type } " )
216
- data = pulse_type_to_DINA_data [pulse_type ]
217
- return (
218
- data [:, - 2 ][nb_mb - 1 ]
219
- if pulse_type == "FP"
220
- else data [:, - 1 ][nb_mb - 1 ]
221
- )
251
+
252
+ if pulse_type == "RISP" :
253
+ data = RISP_data (nb_mb , time = t )
254
+ else :
255
+ data = pulse_type_to_DINA_data [pulse_type ]
256
+
257
+ if pulse_type == "FP" : heat_val = data [:, - 2 ][nb_mb - 1 ]
258
+ elif pulse_type == "RISP" : heat_val = data [- 1 ]
259
+ else : heat_val = data [:, - 1 ][nb_mb - 1 ]
260
+
261
+ return heat_val
222
262
223
263
def T_surface (t : dolfinx .fem .Constant ) -> float :
224
264
"""Monoblock surface temperature
@@ -230,7 +270,7 @@ def T_surface(t: dolfinx.fem.Constant) -> float:
230
270
monoblock surface temperature in K
231
271
"""
232
272
pulse_type = my_scenario .get_pulse_type (float (t ))
233
- return 1.1e-4 * heat (pulse_type ) + COOLANT_TEMP
273
+ return 1.1e-4 * heat (pulse_type , t = t ) + COOLANT_TEMP
234
274
235
275
def T_rear (t : dolfinx .fem .Constant ):
236
276
"""Monoblock surface temperature
@@ -242,7 +282,7 @@ def T_rear(t: dolfinx.fem.Constant):
242
282
monoblock surface temperature in K
243
283
"""
244
284
pulse_type = my_scenario .get_pulse_type (float (t ))
245
- return 2.2e-5 * heat (pulse_type ) + COOLANT_TEMP
285
+ return 2.2e-5 * heat (pulse_type , t = t ) + COOLANT_TEMP
246
286
247
287
def T_function (x , t : Constant ):
248
288
"""Monoblock temperature function
@@ -254,21 +294,28 @@ def T_function(x, t: Constant):
254
294
Returns:
255
295
pulsed monoblock temperature in K
256
296
"""
257
- a = (T_rear (t ) - T_surface (t )) / L
258
- b = T_surface (t )
259
- flat_top_value = a * x [0 ] + b
260
297
resting_value = np .full_like (x [0 ], COOLANT_TEMP )
261
298
pulse_row = my_scenario .get_row (float (t ))
299
+ pulse_type = my_scenario .get_pulse_type (float (t ))
300
+
301
+ if pulse_type == "BAKE" :
302
+ flat_top_value = 483.15
303
+ else :
304
+ a = (T_rear (t ) - T_surface (t )) / L
305
+ b = T_surface (t )
306
+ flat_top_value = a * x [0 ] + b
307
+
262
308
total_time_on = my_scenario .get_pulse_duration_no_waiting (pulse_row )
263
309
total_time_pulse = my_scenario .get_pulse_duration (pulse_row )
264
310
time_elapsed = my_scenario .get_time_till_row (pulse_row )
311
+
265
312
return (
266
313
flat_top_value
267
314
if (float (t )- time_elapsed ) % total_time_pulse < total_time_on and (float (t )- time_elapsed ) % total_time_pulse != 0.0
268
315
else resting_value
269
316
)
270
317
271
- times = np .linspace (0 , my_scenario .get_maximum_time (), num = 100 )
318
+ # times = np.linspace(0, my_scenario.get_maximum_time(), num=100)
272
319
273
320
# x = [0]
274
321
# Ts = [T_function(x, t) for t in times]
@@ -280,19 +327,38 @@ def T_function(x, t: Constant):
280
327
281
328
############# Flux Parameters #############
282
329
283
- def deuterium_ion_flux (t : float ):
284
- pulse_type = my_scenario .get_pulse_type (float (t ))
330
+ def get_flux (pulse_type , monob , t : float , ion = True ):
331
+ FP_index = 2
332
+ other_index = 0
333
+ if not ion :
334
+ FP_index += FP_index + 1
335
+ other_index += other_index + 1
336
+
285
337
if pulse_type == "FP" :
286
- ion_flux = pulse_type_to_DINA_data [pulse_type ][:, 2 ][nb_mb - 1 ]
338
+ flux = pulse_type_to_DINA_data [pulse_type ][:, FP_index ][monob - 1 ]
339
+ elif pulse_type == "RISP" :
340
+ t_value = int (t .value ) if isinstance (t , Constant ) else int (t )
341
+ flux = RISP_data (monob = nb_mb , time = t_value )[other_index ]
342
+ elif pulse_type == "BAKE" :
343
+ flux = 0.0
287
344
else :
288
- ion_flux = pulse_type_to_DINA_data [pulse_type ][:, 0 ][nb_mb - 1 ]
289
- tritium_fraction = PULSE_TYPE_TO_TRITIUM_FRACTION [pulse_type ]
290
- flat_top_value = ion_flux * (1 - tritium_fraction )
291
- resting_value = 0
345
+ flux = pulse_type_to_DINA_data [pulse_type ][:, other_index ][monob - 1 ]
346
+
347
+ return flux
348
+
349
+ def deuterium_ion_flux (t : float ):
350
+ pulse_type = my_scenario .get_pulse_type (float (t ))
351
+
292
352
pulse_row = my_scenario .get_row (float (t ))
293
353
total_time_on = my_scenario .get_pulse_duration_no_waiting (pulse_row )
294
354
total_time_pulse = my_scenario .get_pulse_duration (pulse_row )
295
355
time_elapsed = my_scenario .get_time_till_row (pulse_row )
356
+
357
+ ion_flux = get_flux (pulse_type = pulse_type , monob = nb_mb , t = t - time_elapsed )
358
+ tritium_fraction = PULSE_TYPE_TO_TRITIUM_FRACTION [pulse_type ]
359
+ flat_top_value = ion_flux * (1 - tritium_fraction )
360
+ resting_value = 0
361
+
296
362
return (
297
363
flat_top_value
298
364
if (float (t )- time_elapsed ) % total_time_pulse < total_time_on and (float (t )- time_elapsed ) % total_time_pulse != 0.0
@@ -305,17 +371,17 @@ def deuterium_ion_flux(t: float):
305
371
306
372
def tritium_ion_flux (t : float ):
307
373
pulse_type = my_scenario .get_pulse_type (float (t ))
308
- if pulse_type == "FP" :
309
- ion_flux = pulse_type_to_DINA_data [pulse_type ][:, 2 ][nb_mb - 1 ]
310
- else :
311
- ion_flux = pulse_type_to_DINA_data [pulse_type ][:, 0 ][nb_mb - 1 ]
312
- tritium_fraction = PULSE_TYPE_TO_TRITIUM_FRACTION [pulse_type ]
313
- flat_top_value = ion_flux * tritium_fraction
314
- resting_value = 0
374
+
315
375
pulse_row = my_scenario .get_row (float (t ))
316
376
total_time_on = my_scenario .get_pulse_duration_no_waiting (pulse_row )
317
377
total_time_pulse = my_scenario .get_pulse_duration (pulse_row )
318
378
time_elapsed = my_scenario .get_time_till_row (pulse_row )
379
+
380
+ ion_flux = get_flux (pulse_type = pulse_type , monob = nb_mb , t = t - time_elapsed )
381
+
382
+ tritium_fraction = PULSE_TYPE_TO_TRITIUM_FRACTION [pulse_type ]
383
+ flat_top_value = ion_flux * tritium_fraction
384
+ resting_value = 0
319
385
return (
320
386
flat_top_value
321
387
if (float (t )- time_elapsed ) % total_time_pulse < total_time_on and (float (t )- time_elapsed ) % total_time_pulse != 0.0
@@ -324,17 +390,17 @@ def tritium_ion_flux(t: float):
324
390
325
391
def deuterium_atom_flux (t : float ):
326
392
pulse_type = my_scenario .get_pulse_type (float (t ))
327
- if pulse_type == "FP" :
328
- atom_flux = pulse_type_to_DINA_data [pulse_type ][:, 3 ][nb_mb - 1 ]
329
- else :
330
- atom_flux = pulse_type_to_DINA_data [pulse_type ][:, 1 ][nb_mb - 1 ]
331
- tritium_fraction = PULSE_TYPE_TO_TRITIUM_FRACTION [pulse_type ]
332
- flat_top_value = atom_flux * (1 - tritium_fraction )
333
- resting_value = 0
393
+
334
394
pulse_row = my_scenario .get_row (float (t ))
335
395
total_time_on = my_scenario .get_pulse_duration_no_waiting (pulse_row )
336
396
total_time_pulse = my_scenario .get_pulse_duration (pulse_row )
337
397
time_elapsed = my_scenario .get_time_till_row (pulse_row )
398
+
399
+ atom_flux = get_flux (pulse_type = pulse_type , monob = nb_mb , t = t - time_elapsed , ion = False )
400
+
401
+ tritium_fraction = PULSE_TYPE_TO_TRITIUM_FRACTION [pulse_type ]
402
+ flat_top_value = atom_flux * (1 - tritium_fraction )
403
+ resting_value = 0
338
404
return (
339
405
flat_top_value
340
406
if (float (t )- time_elapsed ) % total_time_pulse < total_time_on and (float (t )- time_elapsed ) % total_time_pulse != 0.0
@@ -343,17 +409,16 @@ def deuterium_atom_flux(t: float):
343
409
344
410
def tritium_atom_flux (t : float ):
345
411
pulse_type = my_scenario .get_pulse_type (float (t ))
346
- if pulse_type == "FP" :
347
- atom_flux = pulse_type_to_DINA_data [pulse_type ][:, 3 ][nb_mb - 1 ]
348
- else :
349
- atom_flux = pulse_type_to_DINA_data [pulse_type ][:, 1 ][nb_mb - 1 ]
350
- tritium_fraction = PULSE_TYPE_TO_TRITIUM_FRACTION [pulse_type ]
351
- flat_top_value = atom_flux * tritium_fraction
352
- resting_value = 0
412
+
353
413
pulse_row = my_scenario .get_row (float (t ))
354
414
total_time_on = my_scenario .get_pulse_duration_no_waiting (pulse_row )
355
415
total_time_pulse = my_scenario .get_pulse_duration (pulse_row )
356
416
time_elapsed = my_scenario .get_time_till_row (pulse_row )
417
+
418
+ atom_flux = get_flux (pulse_type = pulse_type , monob = nb_mb , t = t - time_elapsed , ion = False )
419
+ tritium_fraction = PULSE_TYPE_TO_TRITIUM_FRACTION [pulse_type ]
420
+ flat_top_value = atom_flux * tritium_fraction
421
+ resting_value = 0
357
422
return (
358
423
flat_top_value
359
424
if (float (t )- time_elapsed ) % total_time_pulse < total_time_on and (float (t )- time_elapsed ) % total_time_pulse != 0.0
@@ -453,7 +518,7 @@ def tritium_atom_flux(t: float):
453
518
final_time = my_scenario .get_maximum_time ()
454
519
)
455
520
456
- my_model .settings .stepsize = F .Stepsize (initial_value = 20 )
521
+ my_model .settings .stepsize = F .Stepsize (initial_value = 1 )
457
522
458
523
return my_model , quantities
459
524
0 commit comments