Skip to content

Commit db942ad

Browse files
committed
Add helium-3 flow contour plotting and enhance existing contour plots with improved color mapping and titles
1 parent 9d11765 commit db942ad

2 files changed

Lines changed: 121 additions & 18 deletions

File tree

process/core/io/plot_proc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13537,11 +13537,15 @@ def main_plot(
1353713537
PlasmaFuelling().plot_deuterium_flow_contour(
1353813538
axis=ax_deuterium, mfile=m_file, scan=scan
1353913539
)
13540+
ax_helium3 = figs[10].add_subplot(233, sharey=ax_tritium)
13541+
PlasmaFuelling().plot_helium3_flow_contour(axis=ax_helium3, mfile=m_file, scan=scan)
1354013542

1354113543
PlasmaFuelling().plot_alpha_flow_contour(
1354213544
figs[10].add_subplot(223), mfile=m_file, scan=scan
1354313545
)
1354413546

13547+
figs[10].subplots_adjust(wspace=0.2, hspace=0.3)
13548+
1354513549
PlasmaFuelling().plot_fuelling_info(fig=figs[10], mfile=m_file, scan=scan)
1354613550

1354713551
plot_plasma_pressure_profiles(figs[11].add_subplot(222), m_file, scan)

process/models/physics/fuelling.py

Lines changed: 117 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,36 @@ def calculate_plasma_helium3_flow_rate(
327327

328328
@staticmethod
329329
def calculate_plasma_alphas_flow_rate(
330-
fusrat_dt_total,
331-
fusrat_plasma_dhe3,
332-
t_energy_confinement,
333-
f_t_alpha_energy_confinement,
334-
nd_plasma_alphas_vol_avg,
335-
vol_plasma,
336-
):
337-
"""Calculate the alpha particle flow rate in the plasma exhaust."""
330+
fusrat_dt_total: float,
331+
fusrat_plasma_dhe3: float,
332+
t_energy_confinement: float,
333+
f_t_alpha_energy_confinement: float,
334+
nd_plasma_alphas_vol_avg: float,
335+
vol_plasma: float,
336+
) -> float:
337+
"""Calculate the alpha particle flow rate in the plasma exhaust.
338+
339+
Parameters
340+
----------
341+
fusrat_dt_total : float
342+
Total DT fusion rate (particles/s).
343+
fusrat_plasma_dhe3 : float
344+
Deuterium consumption rate from D-He3 fusion (particles/s).
345+
t_energy_confinement : float
346+
Energy confinement time (s).
347+
f_t_alpha_energy_confinement : float
348+
Ratio of alpha particle confinement time to energy confinement time (dimensionless).
349+
nd_plasma_alphas_vol_avg : float
350+
Volume-averaged density of alpha particles in the plasma (particles/m^3).
351+
vol_plasma : float
352+
Plasma volume (m^3).
353+
354+
Returns
355+
-------
356+
float
357+
Alpha particle flow rate in the plasma exhaust (particles/s).
358+
359+
"""
338360

339361
# Alpha particle balance
340362

@@ -376,8 +398,14 @@ def plot_tritium_flow_contour(self, axis: plt.Axes, mfile: mf.MFile, scan: int):
376398
)
377399

378400
contour = axis.contourf(
379-
fuelling_range, recycling_range, tritium_flow, levels=15, cmap="RdBu_r"
401+
fuelling_range,
402+
recycling_range,
403+
tritium_flow,
404+
levels=15,
405+
cmap="seismic",
406+
norm=plt.matplotlib.colors.CenteredNorm(vcenter=0),
380407
)
408+
381409
axis.contour(
382410
fuelling_range,
383411
recycling_range,
@@ -402,11 +430,12 @@ def plot_tritium_flow_contour(self, axis: plt.Axes, mfile: mf.MFile, scan: int):
402430

403431
axis.set_xlabel("Fuelling Rate Efficiency ($\\eta_{\\text{fuelling}}$)")
404432
axis.set_ylabel("Recycling Fraction [$R$]")
405-
axis.set_title("Plasma Tritium Flow Rate (particles/s)")
433+
axis.set_title("Plasma Tritium Flow Rate (particles/s)", pad=20)
406434
axis.minorticks_on()
407435
axis.grid(True, which="major", linestyle="-", alpha=0.7)
408436
axis.grid(True, which="minor", linestyle=":", alpha=0.4)
409-
plt.colorbar(contour, ax=axis, label="Tritium Flow Rate")
437+
cbar = plt.colorbar(contour, ax=axis, label="Tritium Flow Rate")
438+
cbar.ax.axhline(y=0, color="black", linewidth=2)
410439

411440
def plot_deuterium_flow_contour(self, axis: plt.Axes, mfile: mf.MFile, scan: int):
412441
"""Plot contour of deuterium flow rate vs recycling and fuelling rate."""
@@ -442,7 +471,12 @@ def plot_deuterium_flow_contour(self, axis: plt.Axes, mfile: mf.MFile, scan: int
442471
)
443472

444473
contour = axis.contourf(
445-
fuelling_range, recycling_range, deuterium_flow, levels=15, cmap="RdBu_r"
474+
fuelling_range,
475+
recycling_range,
476+
deuterium_flow,
477+
levels=15,
478+
cmap="seismic",
479+
norm=plt.matplotlib.colors.CenteredNorm(vcenter=0),
446480
)
447481
axis.contour(
448482
fuelling_range,
@@ -467,12 +501,12 @@ def plot_deuterium_flow_contour(self, axis: plt.Axes, mfile: mf.MFile, scan: int
467501
)
468502

469503
axis.set_xlabel("Fuelling Rate Efficiency ($\\eta_{\\text{fuelling}}$)")
470-
axis.set_ylabel("Recycling Fraction [$R$]")
471-
axis.set_title("Plasma Deuterium Flow Rate (particles/s)")
504+
axis.set_title("Plasma Deuterium Flow Rate (particles/s)", pad=20)
472505
axis.minorticks_on()
473506
axis.grid(True, which="major", linestyle="-", alpha=0.7)
474507
axis.grid(True, which="minor", linestyle=":", alpha=0.4)
475-
plt.colorbar(contour, ax=axis, label="Deuterium Flow Rate")
508+
cbar = plt.colorbar(contour, ax=axis, label="Deuterium Flow Rate")
509+
cbar.ax.axhline(y=0, color="black", linewidth=2)
476510

477511
def plot_alpha_flow_contour(self, axis: plt.Axes, mfile: mf.MFile, scan: int):
478512
"""Plot contour of alpha particle flow rate vs recycling and fuelling rate."""
@@ -504,7 +538,8 @@ def plot_alpha_flow_contour(self, axis: plt.Axes, mfile: mf.MFile, scan: int):
504538
fusion_dt_range,
505539
alpha_flow,
506540
levels=15,
507-
cmap="RdBu_r",
541+
cmap="seismic",
542+
norm=plt.matplotlib.colors.CenteredNorm(vcenter=0),
508543
)
509544
axis.contour(
510545
f_t_alpha_energy_confinement_range,
@@ -532,11 +567,75 @@ def plot_alpha_flow_contour(self, axis: plt.Axes, mfile: mf.MFile, scan: int):
532567
"Alpha to Energy Confinement Time Ratio ($f_{\\alpha, \\text{energy confinement}}$)"
533568
)
534569
axis.set_ylabel("Fusion DT Rate [$\\text{particles/s}$]")
535-
axis.set_title("Plasma Alpha Particle Flow Rate (particles/s)")
570+
axis.set_title("Plasma Alpha Particle Flow Rate (particles/s)", pad=20)
571+
axis.minorticks_on()
572+
axis.grid(True, which="major", linestyle="-", alpha=0.7)
573+
axis.grid(True, which="minor", linestyle=":", alpha=0.4)
574+
cbar = plt.colorbar(contour, ax=axis, label="Alpha Particle Flow Rate")
575+
cbar.ax.axhline(y=0, color="black", linewidth=2)
576+
577+
def plot_helium3_flow_contour(self, axis: plt.Axes, mfile: mf.MFile, scan: int):
578+
"""Plot contour of helium-3 flow rate vs recycling and fuelling rate."""
579+
580+
recycling_range = np.linspace(0.01, 0.99, 20)
581+
fuelling_range = np.linspace(0.01, 1.0, 20)
582+
helium3_flow = np.zeros((len(recycling_range), len(fuelling_range)))
583+
584+
for i, recycling in enumerate(recycling_range):
585+
for j, fuelling in enumerate(fuelling_range):
586+
helium3_flow[i, j] = self.calculate_plasma_helium3_flow_rate(
587+
f_molflow_plasma_fuelling_helium3=mfile.get(
588+
"f_molflow_plasma_fuelling_helium3", scan=scan
589+
),
590+
eta_plasma_fuelling=fuelling,
591+
molflow_plasma_fuelling_vv_injected=mfile.get(
592+
"molflow_plasma_fuelling_vv_injected", scan=scan
593+
),
594+
fusrat_plasma_dhe3=mfile.get("fusrat_plasma_dhe3", scan=scan),
595+
t_energy_confinement=mfile.get("t_energy_confinement", scan=scan),
596+
f_plasma_particles_lcfs_recycled=recycling,
597+
nd_plasma_fuel_ions_vol_avg=mfile.get(
598+
"nd_plasma_fuel_ions_vol_avg", scan=scan
599+
),
600+
vol_plasma=mfile.get("vol_plasma", scan=scan),
601+
f_plasma_fuel_helium3=mfile.get("f_plasma_fuel_helium3", scan=scan),
602+
)
603+
604+
contour = axis.contourf(
605+
fuelling_range,
606+
recycling_range,
607+
helium3_flow,
608+
levels=15,
609+
cmap="seismic",
610+
norm=plt.matplotlib.colors.CenteredNorm(vcenter=0),
611+
)
612+
axis.contour(
613+
fuelling_range,
614+
recycling_range,
615+
helium3_flow,
616+
levels=[0],
617+
colors="black",
618+
linewidths=2,
619+
)
620+
621+
# Plot star for mfile values
622+
recycling_mfile = mfile.get("f_plasma_particles_lcfs_recycled", scan=scan)
623+
fuelling_mfile = mfile.get("eta_plasma_fuelling", scan=scan)
624+
axis.plot(
625+
fuelling_mfile,
626+
recycling_mfile,
627+
marker="*",
628+
markersize=15,
629+
color="yellow",
630+
markeredgecolor="black",
631+
)
632+
axis.set_xlabel("Fuelling Rate Efficiency ($\\eta_{\\text{fuelling}}$)")
633+
cbar = plt.colorbar(contour, ax=axis, label="Helium-3 Flow Rate")
634+
cbar.ax.axhline(y=0, color="black", linewidth=2)
635+
axis.set_title("Plasma Helium-3 Flow Rate (particles/s)", pad=20)
536636
axis.minorticks_on()
537637
axis.grid(True, which="major", linestyle="-", alpha=0.7)
538638
axis.grid(True, which="minor", linestyle=":", alpha=0.4)
539-
plt.colorbar(contour, ax=axis, label="Alpha Particle Flow Rate")
540639

541640
def plot_fuelling_info(self, fig: plt.Figure, mfile: mf.MFile, scan: int):
542641
"""Plot fuelling information."""

0 commit comments

Comments
 (0)