232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621 | def plot_main_plasma_information(
axis: plt.Axes,
mfile: MFile,
scan: int,
colour_scheme: Literal[1, 2],
fig: plt.Figure,
):
"""Plots the main plasma information including plasma shape, geometry, currents,
heating, confinement, and other relevant plasma parameters.
Parameters
----------
axis : plt.Axes
The matplotlib axis object to plot on.
mfile : MFile
The MFILE data object containing plasma parameters.
scan : int
The scan number to use for extracting data.
colour_scheme : int
The colour scheme to use for plots.
fig : plt.Figure
The matplotlib figure object for additional annotations.
"""
def value(name: str):
return mfile.get(name, scan=scan)
def add_panel(
x: float,
top: float,
width: float,
height: float,
text: str,
style: dict,
text_x_offset: float = 0.004,
):
"""Add one fixed-size box and its unchanged original text."""
box_expansion = 0.002
left = x - box_expansion
bottom = top - height - box_expansion
expanded_width = width + 2 * box_expansion
expanded_height = height + 2 * box_expansion
patch = FancyBboxPatch(
(left, bottom),
expanded_width,
expanded_height,
boxstyle="round,pad=0,rounding_size=0.003",
transform=fig.transFigure,
facecolor=style.get("facecolor", "white"),
edgecolor=style.get("edgecolor", "black"),
linewidth=style.get("linewidth", 1.0),
alpha=style.get("alpha", 1.0),
clip_on=False,
zorder=20,
)
axis.add_patch(patch)
return axis.text(
x + text_x_offset,
top - 0.004,
text,
fontsize=9,
color="black",
verticalalignment="top",
horizontalalignment="left",
transform=fig.transFigure,
clip_on=False,
zorder=21,
)
def add_symbol(panel_name: str, x: float, top: float):
"""Add a large symbol at its original figure-relative position."""
return axis.text(
x,
top,
panel_name,
fontsize=23,
color="black",
verticalalignment="top",
transform=fig.transFigure,
clip_on=False,
zorder=22,
)
triang = value("triang")
kappa = value("kappa")
rmajor = value("rmajor")
rminor = value("rminor")
radius_plasma_core_norm = value("radius_plasma_core_norm")
axis.axis("off")
plot_plasma(axis, mfile, scan, colour_scheme)
plasma_main_page(
axis,
fig,
rmajor,
rminor,
triang,
radius_plasma_core_norm,
kappa,
value("i_single_null"),
value("plasma_square"),
value("big_q_plasma"),
value("p_fw_alpha_mw"),
value("f_p_alpha_plasma_deposited"),
value("p_neutron_total_mw"),
value("pflux_plasma_surface_neutron_avg_mw"),
)
geom_type = PlasmaGeometryModelType(value("i_plasma_geometry"))
textstr_plasma = (
"$\\mathbf{Shaping:}$\n\n"
f"$\\kappa_{{95}}$: {value('kappa95'):.2f} "
f"({geom_type.kappa95_model.description}) | "
f"$\\delta_{{95}}$: {value('triang95'):.2f} "
f"({geom_type.triang95_model.description}) | "
f"$\\zeta$: {value('plasma_square'):.2f}\n"
f"$\\kappa$: {kappa:.2f} ({geom_type.kappa_model.description}) | "
f"$\\delta$: {triang:.2f} ({geom_type.triang_model.description}) | "
f"A: {value('aspect'):.2f}\n"
f"$V_{{\\text{{p}}}}$: {value('vol_plasma'):,.2f} $\\mathrm{{m}}^3$ | "
"$A_{\\text{p,surface}}$: "
f"{value('a_plasma_surface'):,.2f} $\\mathrm{{m}}^2$ | "
"$A_{\\text{p,poloidal}}$: "
f"{value('a_plasma_poloidal'):,.3f} $\\mathrm{{m}}^2$\n"
"$L_{\\text{p,poloidal}}$: "
f"{value('len_plasma_poloidal'):,.3f} $\\mathrm{{m}}$"
)
add_panel(0.365, 0.975, 0.340, 0.110, textstr_plasma, box_style("lightyellow"))
i_hcd_primary = value("i_hcd_primary")
i_hcd_secondary = value("i_hcd_secondary")
cd_1 = CurrentDriveModel(i_hcd_primary)
cd_2 = CurrentDriveModel(i_hcd_secondary)
textstr_hcd = (
"$\\mathbf{Heating\\ &\\ current\\ drive:}$\n\n"
f"Total injected heat: {value('p_hcd_injected_total_mw'):.3f} MW\n"
f"Ohmic heating power: {value('p_plasma_ohmic_mw'):.3f} MW\n\n"
f"$\\mathbf{{Primary\\ system: {cd_1.abbreviation}}}$\n"
f"Current driving power: {value('p_hcd_primary_injected_mw'):.4f} MW\n"
f"Extra heat power: {value('p_hcd_primary_extra_heat_mw'):.4f} MW\n"
f"$\\eta_{{\\text{{CD,prim}}}}$: {value('eta_cd_hcd_primary'):.4f} A/W | "
f"$\\langle\\zeta_{{\\text{{CD,prim}}}}\\rangle$: "
f"{value('eta_cd_dimensionless_hcd_primary'):.4f}\n"
f"$\\gamma_{{\\text{{CD,prim}}}}$: {value('eta_cd_norm_hcd_primary'):.4f} "
"$\\times 10^{20}\\ \\mathrm{A}/\\mathrm{Wm}^2$\n"
f"Current driven by primary: {value('c_hcd_primary_driven') / 1e6:.3f} MA\n\n"
f"$\\mathbf{{Secondary\\ system: {cd_2.abbreviation}}}$\n"
f"Current driving power: {value('p_hcd_secondary_injected_mw'):.4f} MW\n"
f"Extra heat power: {value('p_hcd_secondary_extra_heat_mw'):.4f} MW\n"
f"$\\eta_{{\\text{{CD,sec}}}}$: {value('eta_cd_hcd_secondary'):.4f} A/W | "
f"$\\langle\\zeta_{{\\text{{CD,sec}}}}\\rangle$: "
f"{value('eta_cd_dimensionless_hcd_secondary'):.4f}\n"
f"$\\gamma_{{\\text{{CD,sec}}}}$: {value('eta_cd_norm_hcd_secondary'):.4f} "
"$\\times 10^{20}\\ \\mathrm{A}/\\mathrm{Wm}^2$\n"
f"Current driven by secondary: {value('c_hcd_secondary_driven') / 1e6:.3f} MA"
)
add_panel(
0.730,
0.675,
0.245,
0.300,
textstr_hcd,
box_style("paleturquoise") | {"edgecolor": "black"},
)
add_symbol("$P_{\\text{inj}}$", 0.92, 0.625)
beta_component = BetaComponentLimits(value("i_beta_component")).full_name
beta_norm_model = BetaNormMaxModel(value("i_beta_norm_max")).full_name
textstr_beta = (
"$\\mathbf{Beta\\ Information:}$\n\n"
f"Total beta, $\\langle\\beta\\rangle$: {value('beta_total_vol_avg'):.4f}\n"
f"Thermal beta, $\\langle\\beta_{{\\text{{thermal}}}}\\rangle$: "
f"{value('beta_thermal_vol_avg'):.4f}\n"
f"Toroidal beta, $\\langle\\beta_{{\\text{{t}}}}\\rangle$: "
f"{value('beta_toroidal_vol_avg'):.4f}\n"
f"Poloidal beta, $\\langle\\beta_{{\\text{{p}}}}\\rangle$: "
f"{value('beta_poloidal_vol_avg'):.4f}\n"
f"Fast-alpha beta, $\\langle\\beta_{{\\alpha}}\\rangle$: "
f"{value('beta_fast_alpha'):.4f}\n"
f"Upper limit on {beta_component}, $\\langle\\beta\\rangle$: "
f"{value('beta_vol_avg_max'):.4f}\n"
f"Normalised total beta, $\\beta_{{\\text{{N}}}}$: "
f"{value('beta_norm_total'):.4f}\n"
f"Normalised thermal beta, $\\beta_{{\\text{{N,thermal}}}}$: "
f"{value('beta_norm_thermal'):.4f}\n"
f"Maximum normalised beta ({beta_norm_model}), $\\beta_{{\\text{{N,max}}}}$: "
f"{value('beta_norm_max'):.4f}"
)
add_panel(0.025, 0.975, 0.325, 0.180, textstr_beta, box_style("lightblue"))
add_symbol("$\\beta$", 0.27, 0.94)
inductance_model = IndInternalNormModel(
value("i_ind_plasma_internal_norm")
).full_name
textstr_volt_second = (
"$\\mathbf{Volt-second\\ requirements:}$\n\n"
f"Total volt-second consumption: {value('vs_plasma_total_required'):.4f} Vs\n"
f" - Internal volt-seconds: {value('vs_plasma_internal'):.4f} Vs\n"
f" - Volt-seconds needed for burn: {value('vs_plasma_burn_required'):.4f} Vs\n"
f" - Volt-seconds needed for ramp: {value('vs_plasma_ramp_required'):.4f} Vs | "
f"$C_{{\\text{{ejima}}}}$: {value('ejima_coeff'):.4f}\n"
f"$V_{{\\text{{loop}}}}$: {value('v_plasma_loop_burn'):.4f} V\n"
f"$\\Omega_{{\\text{{p}}}}$: {value('res_plasma'):.4e} $\\Omega$\n"
f"Plasma resistive diffusion time: {value('t_plasma_res_diffusion'):,.4f} s\n"
f"Plasma inductance: {value('ind_plasma'):.4e} H | "
f"ITER $l_i(3)$: {value('ind_plasma_internal_norm_iter_3'):.4f}\n"
"Plasma stored magnetic energy: "
f"{value('e_plasma_magnetic_stored') / 1e9:.4f} GJ\n"
f"Plasma normalised internal inductance, $l_i$ ({inductance_model}): "
f"{value('ind_plasma_internal_norm'):.3f}"
)
add_panel(0.025, 0.780, 0.335, 0.195, textstr_volt_second, box_style("lightgreen"))
add_symbol("Vs", 0.30, 0.77)
textstr_div = (
f"$P_{{\\text{{sep}}}}$: {value('p_plasma_separatrix_mw'):.2f} MW\n"
f"$\\frac{{P_{{\\text{{sep}}}}}}{{R}}$: "
f"{value('p_plasma_separatrix_rmajor_mw'):.2f} MW/m\n"
f"$\\frac{{P_{{\\text{{sep}}}}B_T}}{{q_{{95}} A R}}$: "
f"{value('p_div_bt_q_aspect_rmajor_mw'):.2f} MW T/m"
)
add_panel(0.350, 0.120, 0.165, 0.095, textstr_div, box_style("orange"))
add_symbol("$P_{\\text{div}}$", 0.45, 0.10)
textstr_confinement = (
"$\\mathbf{Confinement:}$\n\n"
f"Confinement scaling law: {value('tauelaw')}\n"
f"Confinement $H$ factor: {value('hfact'):.4f}\n"
f"Energy confinement time from scaling: {value('t_energy_confinement'):.4f} s\n"
f"Fusion double product: {value('ntau'):.4e} s/m³\n"
f"Lawson Triple product: {value('nttau'):.4e} keV·s/m³\n"
"Transport loss power assumed in scaling law: "
f"{value('p_plasma_loss_mw'):.4f} MW\n"
f"Plasma thermal energy (inc. $\\alpha$), $W$: "
f"{value('e_plasma_beta') / 1e9:.4f} GJ\n"
f"Alpha particle confinement time: {value('t_alpha_confinement'):.4f} s | "
f"$\\tau_{{\\alpha}}/\\tau_{{e}}$: {value('f_t_alpha_energy_confinement'):.4f}"
)
add_panel(
0.025,
0.570,
0.325,
0.155,
textstr_confinement,
box_style("gainsboro") | {"edgecolor": "black"},
)
add_symbol("$\\tau_{\\text{e}}$", 0.30, 0.55)
textstr_reactions = (
"$\\mathbf{Fusion\\ Reactions:}$\n\n"
"Fuel mixture:\n"
f"| D: {value('f_plasma_fuel_deuterium'):.2f} | "
f"T: {value('f_plasma_fuel_tritium'):.2f} | "
f"3He: {value('f_plasma_fuel_helium3'):.2f} |\n\n"
f"Fusion Power, $P_{{\\text{{fus}}}}$: {value('p_fusion_total_mw'):,.2f} MW\n"
f"D-T Power, $P_{{\\text{{fus,DT}}}}$: {value('p_dt_total_mw'):,.2f} MW\n"
f"D-D Power, $P_{{\\text{{fus,DD}}}}$: {value('p_dd_total_mw'):,.2f} MW\n"
f"D-3He Power, $P_{{\\text{{fus,D3He}}}}$: {value('p_dhe3_total_mw'):,.2f} MW\n"
f"Alpha Power, $P_{{\\alpha}}$: {value('p_alpha_total_mw'):,.2f} MW"
)
add_panel(
0.025,
0.400,
0.185,
0.165,
textstr_reactions,
{"boxstyle": "round", "facecolor": "red", "alpha": 0.6, "linewidth": 2},
)
textstr_fuelling = (
"$\\mathbf{Fuelling:}$\n\n"
f"Plasma mass: {value('m_plasma') * 1000:.4f} g\n"
f" - Average mass of all plasma ions: {value('m_ions_total_amu'):.3f} amu\n"
f"Fuel mass: {value('m_plasma_fuel_ions') * 1000:.4f} g\n"
f" - Average mass of all fuel ions: {value('m_fuel_amu'):.3f} amu\n\n"
"Fueling rate: "
f"{value('molflow_plasma_fuelling_required'):.3e} nucleus-pairs/s\n"
f"Fuel burn-up rate: {value('rndfuel'):.3e} reactions/s\n"
f"Burn-up fraction: {value('burnup'):.4f}"
)
add_panel(
0.025,
0.220,
0.255,
0.175,
textstr_fuelling,
box_style("khaki") | {"edgecolor": "black"},
)
impurity_data = ImpurityRadiationData()
textstr_ions = (
"$\\mathbf{Ion\\ to\\ electron}$\n"
"$\\mathbf{relative\\ number}$\n"
"$\\mathbf{densities:}$\n\n"
f"Effective charge: {value('n_charge_plasma_effective_vol_avg'):.3f}\n\n"
+ "\n".join(
f"{label.replace('_', '') + ':':<6}"
f"{value(f'f_nd_impurity_electrons({index:02d})'):.4e}"
for index, label in enumerate(impurity_data.imp_label[:14], start=1)
)
)
add_panel(
0.805,
0.335,
0.170,
0.310,
textstr_ions,
{"boxstyle": "round", "facecolor": "olivedrab", "alpha": 0.7, "linewidth": 2},
text_x_offset=0.045,
)
add_symbol("$Z$", 0.815, 0.29)
current_model = PlasmaCurrentModel(value("i_plasma_current")).full_name
bootstrap_model = BootstrapCurrentFractionModel(
value("i_bootstrap_current")
).full_name
diamagnetic_model = PlasmaDiamagneticCurrentModel(
value("i_diamagnetic_current")
).full_name
textstr_currents = (
"$\\mathbf{Plasma\\ currents:}$\n\n"
f"Plasma current ({current_model}): {value('plasma_current_ma'):.4f} MA\n"
f" - Bootstrap fraction ({bootstrap_model}): "
f"{value('f_c_plasma_bootstrap'):.4f}\n"
f" - Diamagnetic fraction ({diamagnetic_model}): "
f"{value('f_c_plasma_diamagnetic'):.4f}\n"
f" - Pfirsch-Schlüter fraction: {value('f_c_plasma_pfirsch_schluter'):.4f}\n"
f" - Auxiliary fraction: {value('f_c_plasma_auxiliary'):.4f}\n"
f" - Inductive fraction: {value('f_c_plasma_inductive'):.4f}"
)
add_panel(0.720, 0.975, 0.255, 0.130, textstr_currents, box_style("#C8A2C8"))
add_symbol("$I_{\\text{p}}$", 0.93, 0.90)
textstr_fields = (
"$\\mathbf{Magnetic\\ fields:}$\n\n"
f"Toroidal field at $R_0$, $B_T$: {value('b_plasma_toroidal_on_axis'):.4f} T\n"
f" Ripple at outboard, $\\delta$: {value('ripple_b_tf_plasma_edge'):.2f}%\n"
f"Surface average poloidal field, $\\langle B_p(a)\\rangle$: "
f"{value('b_plasma_surface_poloidal_average'):.4f} T\n"
f"Total field, $B_{{\\text{{tot}}}}$: {value('b_plasma_total'):.4f} T\n"
f"Vertical field, $B_{{\\text{{vert}}}}$: "
f"{value('b_plasma_vertical_required'):.4f} T"
)
add_panel(0.5325, 0.140, 0.2575, 0.115, textstr_fields, box_style("royalblue"))
add_symbol("$B$", 0.75, 0.12)
textstr_radiation = (
"$\\mathbf{Radiation:}$\n"
f"Total radiation power: {value('p_plasma_rad_mw'):.4f} MW\n"
f"Separatrix radiation fraction: {value('f_p_plasma_separatrix_rad'):.4f}\n"
f"Reduced Core radiation power: {value('p_plasma_core_rad_reduced_mw'):.4f} MW\n"
f" - $f_{{\\text{{core,reduce}}}}$: "
f"{value('f_p_plasma_core_rad_reduction'):.4f}\n"
f"Core radiation power: {value('p_plasma_core_rad_mw'):.4f} MW\n"
f"Edge radiation power: {value('p_plasma_edge_rad_mw'):.4f} MW\n"
f"Synchrotron radiation power: {value('p_plasma_sync_mw'):.4f} MW\n"
f"Synchrotron wall reflectivity: {value('f_sync_reflect'):.4f}"
)
add_panel(
0.720,
0.830,
0.255,
0.145,
textstr_radiation,
box_style("lavender") | {"edgecolor": "black"},
text_x_offset=0.032,
)
add_symbol("$\\gamma$", 0.725, 0.78)
model_name = PlasmaConfinementTransitionModel(value("i_l_h_threshold")).full_name
if len(model_name) > 20:
model_name = "\n".join(textwrap.wrap(model_name, width=20))
textstr_lh = (
"$\\mathbf{L-H\\ threshold:}$\n"
f"{model_name}\n\n"
f"$P_{{\\text{{L-H}}}}$: {value('p_l_h_threshold_mw'):.4f} MW"
)
add_panel(0.220, 0.400, 0.110, 0.080, textstr_lh, box_style("peachpuff"))
density_model = DensityLimitModel(value("i_density_limit")).full_name
textstr_density_limit = (
"$\\mathbf{Density\\ limit:}$\n"
f"({density_model})\n"
f"$n_{{\\text{{e,limit}}}}$: {value('nd_plasma_electrons_max'):.3e} "
"$\\mathrm{m}^{-3}$\n"
f"$f_{{\\text{{GW}}}}$: {value('f_nd_plasma_greenwald'):.4f}"
)
add_panel(0.220, 0.310, 0.130, 0.075, textstr_density_limit, box_style("pink"))
|