From 1074a1097540158d60b51374c2b745d36f1603c7 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 24 Oct 2025 09:52:35 +0100 Subject: [PATCH 1/3] Enhance TF cable packing logic and improve text formatting in plot function --- process/io/plot_proc.py | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index dd242c2bab..109b9d1669 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -6557,19 +6557,27 @@ def _pack_strands_rectangular_with_obstacles( turn_height - 2 * (insulation_thickness + steel_thickness), ] + # Cable strand packing parameters + strand_diameter = mfile_data.data["dia_tf_turn_superconducting_cable"].get_scan( + scan + ) + void_fraction = mfile_data.data["f_a_tf_turn_cable_space_extra_void"].get_scan( + scan + ) + # Pack strands if significant void fraction if void_fraction > 0.001: _, _ = _pack_strands_rectangular_with_obstacles( - cable_bounds, - ( + cable_space_bounds=cable_bounds, + pipe_center=( turn_width / 2, turn_height / 2, ), - he_pipe_diameter / 2, - strand_diameter, - void_fraction, - axis, - radius_tf_turn_cable_space_corners, + pipe_radius=he_pipe_diameter / 2, + strand_diameter=strand_diameter, + void_fraction=void_fraction, + axis=axis, + corner_radius=radius_tf_turn_cable_space_corners, n_strands=mfile_data.data["n_tf_turn_superconducting_cables"].get_scan( scan ), @@ -6641,15 +6649,13 @@ def _pack_strands_rectangular_with_obstacles( ) elif i_tf_turns_integer == 1: textstr_turn_cable_space = ( - ( - f"$\\mathbf{{Cable \\ Space:}}$\n\n" - f"Cable space: \n{cable_space_width_radial:.3e} m radial width \n" - f"{cable_space_width_toroidal:.3e} m toroidal width \n" - f"Corner radius, $r$: {radius_tf_turn_cable_space_corners:.3e} m\n" - f"Cable area with no cooling channel or gaps: {a_tf_turn_cable_space_no_void:.3e} m$^2$\n" - f"Extra cable space area void fraction: {f_a_tf_turn_cable_space_extra_void}\n" - f"True cable space area: {a_tf_turn_cable_space_effective:.3e} m$^2$" - ), + f"$\\mathbf{{Cable \\ Space:}}$\n\n" + f"Cable space: \n{cable_space_width_radial:.3e} m radial width \n" + f"{cable_space_width_toroidal:.3e} m toroidal width \n" + f"Corner radius, $r$: {radius_tf_turn_cable_space_corners:.3e} m\n" + f"Cable area with no cooling channel or gaps: {a_tf_turn_cable_space_no_void:.3e} m$^2$\n" + f"Extra cable space area void fraction: {f_a_tf_turn_cable_space_extra_void}\n" + f"True cable space area: {a_tf_turn_cable_space_effective:.3e} m$^2$" ) axis.text( From 9d0d01876130efe142aadcea08fd6a1883234e93 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 24 Oct 2025 10:08:43 +0100 Subject: [PATCH 2/3] Fix TF cable plot dimensions and update axis labels for clarity --- process/io/plot_proc.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 109b9d1669..cc1bc7a69f 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -6532,7 +6532,7 @@ def _pack_strands_rectangular_with_obstacles( insulation_thickness + steel_thickness, ], (turn_width - 2 * (insulation_thickness + steel_thickness)), - (turn_width - 2 * (insulation_thickness + steel_thickness)), + (turn_height - 2 * (insulation_thickness + steel_thickness)), facecolor="none", edgecolor="black", linestyle="--", @@ -6591,8 +6591,9 @@ def _pack_strands_rectangular_with_obstacles( axis.minorticks_on() axis.set_title("WP Turn Structure") - axis.set_xlabel("X [m]") - axis.set_ylabel("Y [m]") + axis.set_xlabel("r [m]") + axis.set_ylabel("x [m]") + axis.grid(True, which="both", linestyle="--", linewidth=0.5, alpha=0.5) # Add info about the steel casing surrounding the WP textstr_turn_insulation = ( @@ -6659,7 +6660,7 @@ def _pack_strands_rectangular_with_obstacles( ) axis.text( - 0.5, + 0.40, 0.7, textstr_turn_cable_space, fontsize=9, From e22e8affbe6b579e1d5d4a2a4fdbc208b5cd1748 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 24 Oct 2025 10:20:57 +0100 Subject: [PATCH 3/3] Refactor TF cable turn text formatting and add conditional display for turn dimensions --- process/io/plot_proc.py | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index cc1bc7a69f..d9499c0685 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -6593,7 +6593,6 @@ def _pack_strands_rectangular_with_obstacles( axis.set_title("WP Turn Structure") axis.set_xlabel("r [m]") axis.set_ylabel("x [m]") - axis.grid(True, which="both", linestyle="--", linewidth=0.5, alpha=0.5) # Add info about the steel casing surrounding the WP textstr_turn_insulation = ( @@ -6623,7 +6622,7 @@ def _pack_strands_rectangular_with_obstacles( ) axis.text( - 0.55, + 0.65, 0.9, textstr_turn_steel, fontsize=9, @@ -6651,8 +6650,8 @@ def _pack_strands_rectangular_with_obstacles( elif i_tf_turns_integer == 1: textstr_turn_cable_space = ( f"$\\mathbf{{Cable \\ Space:}}$\n\n" - f"Cable space: \n{cable_space_width_radial:.3e} m radial width \n" - f"{cable_space_width_toroidal:.3e} m toroidal width \n" + f"Cable space: \n$\\Delta r$: {cable_space_width_radial:.3e} m \n" + f"$\\Delta x$: {cable_space_width_toroidal:.3e} m \n" f"Corner radius, $r$: {radius_tf_turn_cable_space_corners:.3e} m\n" f"Cable area with no cooling channel or gaps: {a_tf_turn_cable_space_no_void:.3e} m$^2$\n" f"Extra cable space area void fraction: {f_a_tf_turn_cable_space_extra_void}\n" @@ -6675,6 +6674,36 @@ def _pack_strands_rectangular_with_obstacles( }, ) + if i_tf_turns_integer == 0: + textstr_turn = ( + f"$\\mathbf{{Turn:}}$\n\n" + f"$\\Delta r$: {turn_width:.3e} m\n" + f"$\\Delta x$: {turn_width:.3e} m" + ) + + if i_tf_turns_integer == 1: + textstr_turn = ( + f"$\\mathbf{{Turn:}}$\n\n" + f"$\\Delta r$: {turn_width:.3e} m\n" + f"$\\Delta x$: {turn_height:.3e} m" + ) + + axis.text( + 0.525, + 0.9, + textstr_turn, + fontsize=9, + verticalalignment="top", + horizontalalignment="left", + transform=fig.transFigure, + bbox={ + "boxstyle": "round", + "facecolor": "wheat", + "alpha": 1.0, + "linewidth": 2, + }, + ) + # Add info about the steel casing surrounding the WP textstr_turn_cooling = ( f"$\\mathbf{{Cooling:}}$\n\n"