Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 130 additions & 42 deletions process/core/io/plot_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10752,8 +10752,8 @@ def plot_blkt_pipe_bends(fig, m_file, scan: int):
"""

ax_90 = fig.add_subplot(331)
ax_180 = fig.add_subplot(334)
ax_90 = fig.add_subplot(341)
ax_180 = fig.add_subplot(342)

# Get pipe radius from m_file, fallback to 0.1 m
r = m_file.get("radius_blkt_channel", scan=scan)
Expand Down Expand Up @@ -13224,6 +13224,133 @@ def plot_inequality_constraint_equations(axis: plt.Axes, m_file: mf.MFile, scan:
axis.set_xticklabels([])


def plot_blkt_structure(
ax: plt.Axes,
fig: plt.Figure,
m_file: mf.MFile,
scan: int,
radial_build: dict[str, float],
colour_scheme: Literal[1, 2],
):
"""Plot the BLKT structure on the given axis."""

rmajor = m_file.get("rmajor", scan=scan)

plot_blanket(ax, m_file, scan, radial_build, colour_scheme)
plot_firstwall(ax, m_file, scan, radial_build, colour_scheme)
ax.set_xlabel("Radial position [m]")
ax.set_ylabel("Vertical position [m]")
ax.set_title("Blanket and First Wall Poloidal Cross-Section")
ax.minorticks_on()
ax.grid(which="minor", linestyle=":", linewidth=0.5, alpha=0.5)
# Plot major radius line (vertical dashed line at rmajor)
ax.axvline(
m_file.get("rminor", scan=scan),
color="black",
linestyle="--",
linewidth=1.5,
label="Major Radius $R_0$",
)
# Plot a horizontal line at dz_blkt_half (blanket half height)
dz_blkt_half = m_file.get("dz_blkt_half", scan=scan)
ax.axhline(
dz_blkt_half,
color="purple",
linestyle="--",
linewidth=1.5,
label="Blanket Half Height",
)
ax.axhline(
-dz_blkt_half,
color="purple",
linestyle="--",
linewidth=1.5,
label="Blanket Half Height",
)

ax.annotate(
"",
xy=(rmajor, dz_blkt_half),
xytext=(rmajor, -dz_blkt_half),
arrowprops={"arrowstyle": "<->", "color": "black"},
)

# Add a label for the internal coil width
ax.text(
rmajor,
0.0,
f"{2 * dz_blkt_half:.3f} m",
fontsize=7,
color="black",
rotation=270,
verticalalignment="center",
horizontalalignment="center",
bbox={"boxstyle": "round", "facecolor": "pink", "alpha": 1.0},
zorder=101, # Ensure label is on top of all plots
)

# Plot midplane line (horizontal dashed line at Z=0)
ax.axhline(
0.0,
color="black",
linestyle="--",
linewidth=1.5,
label="Midplane",
)

textstr_blkt_areas = (
f"$\\mathbf{{Blanket \\ Areas:}}$\n\n"
f"Inboard blanket, with holes and gaps: {m_file.get('a_blkt_inboard_surface', scan=scan):,.3f} $\\text{{m}}^2$ \n"
f"Outboard blanket, with holes and gaps: {m_file.get('a_blkt_outboard_surface', scan=scan):,.3f} $\\text{{m}}^2$ \n"
f"Total blanket, with holes and gaps: {m_file.get('a_blkt_total_surface', scan=scan):,.3f} $\\text{{m}}^2$ \n\n"
f"Inboard blanket, full coverage: {m_file.get('a_blkt_inboard_surface_full_coverage', scan=scan):,.3f} $\\text{{m}}^2$ \n"
f"Outboard blanket, full coverage: {m_file.get('a_blkt_outboard_surface_full_coverage', scan=scan):,.3f} $\\text{{m}}^2$ \n"
f"Total blanket, full coverage: {m_file.get('a_blkt_total_surface_full_coverage', scan=scan):,.3f} $\\text{{m}}^2$ "
)

ax.text(
0.05,
0.3,
textstr_blkt_areas,
fontsize=9,
verticalalignment="bottom",
horizontalalignment="left",
transform=fig.transFigure,
bbox={
"boxstyle": "round",
"facecolor": "wheat",
"alpha": 1.0,
"linewidth": 2,
},
)

textstr_blkt_volumes = (
f"$\\mathbf{{Blanket \\ Volumes:}}$\n\n"
f"Inboard blanket, with holes and gaps: {m_file.get('vol_blkt_inboard', scan=scan):,.3f} $\\text{{m}}^3$ \n"
f"Outboard blanket, with holes and gaps: {m_file.get('vol_blkt_outboard', scan=scan):,.3f} $\\text{{m}}^3$ \n"
f"Total blanket, with holes and gaps: {m_file.get('vol_blkt_total', scan=scan):,.3f} $\\text{{m}}^3$ \n\n"
f"Inboard blanket, full coverage: {m_file.get('vol_blkt_inboard_full_coverage', scan=scan):,.3f} $\\text{{m}}^3$ \n"
f"Outboard blanket, full coverage: {m_file.get('vol_blkt_outboard_full_coverage', scan=scan):,.3f} $\\text{{m}}^3$ \n"
f"Total blanket, full coverage: {m_file.get('vol_blkt_total_full_coverage', scan=scan):,.3f} $\\text{{m}}^3$ "
)

ax.text(
0.05,
0.05,
textstr_blkt_volumes,
fontsize=9,
verticalalignment="bottom",
horizontalalignment="left",
transform=fig.transFigure,
bbox={
"boxstyle": "round",
"facecolor": "wheat",
"alpha": 1.0,
"linewidth": 2,
},
)


def main_plot(
figs: list[Axes],
m_file: mf.MFile,
Expand Down Expand Up @@ -13506,46 +13633,7 @@ def main_plot(

plot_blkt_pipe_bends(figs[28], m_file, scan)
ax_blanket = figs[28].add_subplot(122, aspect="equal")
plot_blanket(ax_blanket, m_file, scan, radial_build, colour_scheme)
plot_firstwall(ax_blanket, m_file, scan, radial_build, colour_scheme)
ax_blanket.set_xlabel("Radial position [m]")
ax_blanket.set_ylabel("Vertical position [m]")
ax_blanket.set_title("Blanket and First Wall Poloidal Cross-Section")
ax_blanket.minorticks_on()
ax_blanket.grid(which="minor", linestyle=":", linewidth=0.5, alpha=0.5)
# Plot major radius line (vertical dashed line at rmajor)
ax_blanket.axvline(
m_file.get("rminor", scan=scan),
color="black",
linestyle="--",
linewidth=1.5,
label="Major Radius $R_0$",
)
# Plot a horizontal line at dz_blkt_half (blanket half height)
dz_blkt_half = m_file.get("dz_blkt_half", scan=scan)
ax_blanket.axhline(
dz_blkt_half,
color="purple",
linestyle="--",
linewidth=1.5,
label="Blanket Half Height",
)
ax_blanket.axhline(
-dz_blkt_half,
color="purple",
linestyle="--",
linewidth=1.5,
label="Blanket Half Height",
)

# Plot midplane line (horizontal dashed line at Z=0)
ax_blanket.axhline(
0.0,
color="black",
linestyle="--",
linewidth=1.5,
label="Midplane",
)
plot_blkt_structure(ax_blanket, figs[28], m_file, scan, radial_build, colour_scheme)

plot_main_power_flow(
figs[29].add_subplot(111, aspect="equal"), m_file, scan, figs[29]
Expand Down
Loading
Loading