From 5dd1558cbe48209c33d5d046449cd9016c208a9b Mon Sep 17 00:00:00 2001 From: Jonathan Matthews Date: Thu, 13 Aug 2026 11:17:08 +0100 Subject: [PATCH 1/5] updated outputting of PF coil numbering to replace PF 0 with PF 1 and any CS coils labelled as PF 6 as CS in both MFILE.DAT and OUT.DAT --- process/models/pfcoil.py | 114 ++++++++++++++++++++++++--------------- 1 file changed, 71 insertions(+), 43 deletions(-) diff --git a/process/models/pfcoil.py b/process/models/pfcoil.py index 2343d3fde3..c84caf6b08 100644 --- a/process/models/pfcoil.py +++ b/process/models/pfcoil.py @@ -1994,7 +1994,7 @@ def induct(self, output): for ig in range(pf_d.nef): op.write( self.outfile, - f"{ig}\t{pf_d.ind_pf_cs_plasma_mutual[:n_pf_cs, ig]}", + f"{ig + 1}\t{pf_d.ind_pf_cs_plasma_mutual[:n_pf_cs, ig]}", ) if self.data.build.iohcl != 0: @@ -2403,7 +2403,7 @@ def outpf(self): # PF coils pf_coil_geometry_rows = [ [ - f"PF {k}", + f"PF {k + 1}", f"{pf_d.r_pf_coil_middle[k]:.2e}", f"{pf_d.z_pf_coil_middle[k]:.2e}", f"{pf_d.r_pf_coil_outer[k] - pf_d.r_pf_coil_inner[k]:.2e}", @@ -2446,44 +2446,44 @@ def outpf(self): for k in range(pf_d.nef): op.ovarre( self.mfile, - f"PF coil {k} radius (m)", - f"(r_pf_coil_middle[{k}])", + f"PF coil {k + 1} radius (m)", + f"(r_pf_coil_middle[{k + 1}])", pf_d.r_pf_coil_middle[k], ) op.ovarre( self.mfile, - f"PF coil {k} vertical position (m)", - f"(z_pf_coil_middle[{k}])", + f"PF coil {k + 1} vertical position (m)", + f"(z_pf_coil_middle[{k + 1}])", pf_d.z_pf_coil_middle[k], ) op.ovarre( self.mfile, - f"PF coil {k} radial thickness (m)", - f"(pfdr({k}))", + f"PF coil {k + 1} radial thickness (m)", + f"(pfdr({k + 1}))", pf_d.r_pf_coil_outer[k] - pf_d.r_pf_coil_inner[k], ) op.ovarre( self.mfile, - f"PF coil {k} vertical thickness (m)", - f"(pfdz({k}))", + f"PF coil {k + 1} vertical thickness (m)", + f"(pfdz({k + 1}))", pf_d.z_pf_coil_upper[k] - pf_d.z_pf_coil_lower[k], ) op.ovarre( self.mfile, - f"PF coil {k} turns", - f"(n_pf_coil_turns[{k}])", + f"PF coil {k + 1} turns", + f"(n_pf_coil_turns[{k + 1}])", pf_d.n_pf_coil_turns[k], ) op.ovarre( self.mfile, - f"PF coil {k} current (MA)", - f"(c_pf_cs_coils_peak_ma[{k}])", + f"PF coil {k + 1} current (MA)", + f"(c_pf_cs_coils_peak_ma[{k + 1}])", pf_d.c_pf_cs_coils_peak_ma[k], ) op.ovarre( self.mfile, - f"PF coil {k} field (T)", - f"(b_pf_coil_peak[{k}])", + f"PF coil {k + 1} field (T)", + f"(b_pf_coil_peak[{k + 1}])", pf_d.b_pf_coil_peak[k], ) for time in range(6): @@ -2565,7 +2565,7 @@ def outpf(self): for k in range(pf_d.nef): if pf_d.i_pf_conductor == PFConductorModel.SUPERCONDUCTING: rows.append([ - f"PF {k}", + f"PF {k + 1}", f"{pf_d.c_pf_cs_coils_peak_ma[k]:.3e}", f"{pf_d.j_pf_wp_critical[k]:.3e}", f"{pf_d.j_pf_coil_wp_peak[k]:.3e}", @@ -2576,7 +2576,7 @@ def outpf(self): ]) else: rows.append([ - f"PF {k}", + f"PF {k + 1}", f"{pf_d.c_pf_cs_coils_peak_ma[k]:.3e}", "-1.0e0", f"{pf_d.j_pf_coil_wp_peak[k]:.3e}", @@ -2703,14 +2703,14 @@ def outvolt(self): for k in range(pf.nef): op.write( self.outfile, - f"\t{k}\t\t\t{pf.vsdum[k, 0]:.3f}" + f"\t{k + 1}\t\t\t{pf.vsdum[k, 0]:.3f}" f"\t\t\t{pf.vsdum[k, 1]:.3f}\t\t{pf.vsdum[k, 2]:.3f}", ) n_cs = pf.n_cs_pf_coils - 1 op.write( self.outfile, - f"\tCS coil\t\t\t{pf.vsdum[n_cs, 0]:.3f}" + f"\tCS\t\t\t{pf.vsdum[n_cs, 0]:.3f}" f"\t\t\t{pf.vsdum[n_cs, 1]:.3f}\t\t{pf.vsdum[n_cs, 2]:.3f}", ) @@ -2750,7 +2750,10 @@ def outvolt(self): inv_st_pulse = 1.0e0 / pf_d.f_j_cs_start_pulse_end_flat_top for k in range(self.data.pf_coil.n_pf_cs_plasma_circuits - 1): - line = f"\t{k}\t\t" + if k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2: + line = "\tCS\t\t" + else: + line = f"\t{k + 1}\t\t" for jj in range(6): line += f"\t{cpft[k, jj] * self.data.pf_coil.n_pf_coil_turns[k]:.3e}" op.write(self.outfile, line) @@ -2765,31 +2768,56 @@ def outvolt(self): op.ocmmnt(self.outfile, "This consists of: CS coil field balancing:") for k in range(pf_d.n_pf_cs_plasma_circuits - 1): - op.write( - self.outfile, - ( - f"{k}\t\t\t{cpft[k, 0] * pf_d.n_pf_coil_turns[k]:.3e}\t" - f"{cpft[k, 1] * nturn[k]:.3e}\t" - f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}\t" - f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}\t" - f"{-cpft[k, 1] * nturn[k] * inv_st_pulse:.3e}\t" - f"{cpft[k, 5] * nturn[k]:.3e}" - ), - ) + if k == pf_d.n_pf_cs_plasma_circuits - 2: + op.write( + self.outfile, + ( + f"CS\t\t\t{cpft[k, 0] * pf_d.n_pf_coil_turns[k]:.3e}\t" + f"{cpft[k, 1] * nturn[k]:.3e}\t" + f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}\t" + f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}\t" + f"{-cpft[k, 1] * nturn[k] * inv_st_pulse:.3e}\t" + f"{cpft[k, 5] * nturn[k]:.3e}" + ), + ) + else: + op.write( + self.outfile, + ( + f"{k + 1}\t\t\t{cpft[k, 0] * pf_d.n_pf_coil_turns[k]:.3e}\t" + f"{cpft[k, 1] * nturn[k]:.3e}\t" + f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}\t" + f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}\t" + f"{-cpft[k, 1] * nturn[k] * inv_st_pulse:.3e}\t" + f"{cpft[k, 5] * nturn[k]:.3e}" + ), + ) op.oblnkl(self.outfile) op.ocmmnt(self.outfile, "And: equilibrium field:") for k in range(pf_d.n_pf_cs_plasma_circuits - 1): - op.write( - self.outfile, - ( - f"{k}\t\t\t{0.0:.3e}\t{0.0:.3e}\t" - f"{(cpft[k, 2] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}\t" - f"{(cpft[k, 3] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}\t" - f"{(cpft[k, 4] + cpft[k, 1] * inv_st_pulse) * nturn[k]:.3e}\t" - "0.0e0" - ), - ) + if k == pf_d.n_pf_cs_plasma_circuits - 2: + op.write( + self.outfile, + ( + f"CS\t\t\t{0.0:.3e}\t{0.0:.3e}\t" + f"{(cpft[k, 2] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}\t" + f"{(cpft[k, 3] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}\t" + f"{(cpft[k, 4] + cpft[k, 1] * inv_st_pulse) * nturn[k]:.3e}\t" + "0.0e0" + ), + ) + else: + op.write( + self.outfile, + ( + f"{k + 1}\t\t\t{0.0:.3e}\t{0.0:.3e}\t" + f"{(cpft[k, 2] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}\t" + f"{(cpft[k, 3] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}\t" + f"{(cpft[k, 4] + cpft[k, 1] * inv_st_pulse) * nturn[k]:.3e}\t" + "0.0e0" + ), + ) op.oblnkl(self.outfile) op.ovarre( @@ -2823,7 +2851,7 @@ def outvolt(self): circuit_name = f"CS Circuit Time point {jjj} (A)" circuit_var_name = f"(cs t{jjj})" else: - circuit_name = f"PF Circuit {k} Time point {jjj} (A)" + circuit_name = f"PF Circuit {k + 1} Time point {jjj} (A)" circuit_var_name = f"(pfc{k}t{jjj})" op.ovarre( From 131ccc6536e7cee8b6b9cb2b7cddb382f55d46bb Mon Sep 17 00:00:00 2001 From: Jonathan Matthews Date: Thu, 13 Aug 2026 14:42:00 +0100 Subject: [PATCH 2/5] added coil + 1 fix to plot_summary following change to MFILE coil numbering --- process/core/io/plot/summary.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/process/core/io/plot/summary.py b/process/core/io/plot/summary.py index eb95b14759..56af1afdaf 100644 --- a/process/core/io/plot/summary.py +++ b/process/core/io/plot/summary.py @@ -8060,10 +8060,10 @@ def plot_pf_coils( noc = number_of_coils - 1 if iohcl == 1 else number_of_coils for coil in range(noc): - coils_r.append(mfile.get(f"r_pf_coil_middle[{coil:01}]", scan=scan)) - coils_z.append(mfile.get(f"z_pf_coil_middle[{coil:01}]", scan=scan)) - coils_dr.append(mfile.get(f"pfdr({coil:01})", scan=scan)) - coils_dz.append(mfile.get(f"pfdz({coil:01})", scan=scan)) + coils_r.append(mfile.get(f"r_pf_coil_middle[{coil + 1:01}]", scan=scan)) + coils_z.append(mfile.get(f"z_pf_coil_middle[{coil + 1:01}]", scan=scan)) + coils_dr.append(mfile.get(f"pfdr({coil + 1:01})", scan=scan)) + coils_dz.append(mfile.get(f"pfdz({coil + 1:01})", scan=scan)) coil_text.append(str(coil + 1)) r_points, z_points, central_coil = pfcoil_geometry( @@ -16059,10 +16059,10 @@ def plot_pf_dimensions( radial_thicknesses = [] vertical_thicknesses = [] for coil in range(int(mfile.get("n_pf_cs_plasma_circuits", scan=scan) - 2)): - r_pf_coil_middle.append(mfile.get(f"r_pf_coil_middle[{coil}]", scan=scan)) - z_pf_coil_middle.append(mfile.get(f"z_pf_coil_middle[{coil}]", scan=scan)) - radial_thicknesses.append(mfile.get(f"pfdr({coil})", scan=scan)) - vertical_thicknesses.append(mfile.get(f"pfdz({coil})", scan=scan)) + r_pf_coil_middle.append(mfile.get(f"r_pf_coil_middle[{coil + 1}]", scan=scan)) + z_pf_coil_middle.append(mfile.get(f"z_pf_coil_middle[{coil + 1}]", scan=scan)) + radial_thicknesses.append(mfile.get(f"pfdr({coil + 1})", scan=scan)) + vertical_thicknesses.append(mfile.get(f"pfdz({coil + 1})", scan=scan)) plot_pf_coils(axis=axis, mfile=mfile, scan=scan, colour_scheme=colour_scheme) From 0f79e2c8f69ac9955f6f360861e2a762078c3802 Mon Sep 17 00:00:00 2001 From: Jonathan Matthews Date: Wed, 19 Aug 2026 09:10:43 +0100 Subject: [PATCH 3/5] added statement to check for CS coil in waveform and circuit outputing --- process/models/pfcoil.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/process/models/pfcoil.py b/process/models/pfcoil.py index c84caf6b08..a10df82ac2 100644 --- a/process/models/pfcoil.py +++ b/process/models/pfcoil.py @@ -2750,7 +2750,8 @@ def outvolt(self): inv_st_pulse = 1.0e0 / pf_d.f_j_cs_start_pulse_end_flat_top for k in range(self.data.pf_coil.n_pf_cs_plasma_circuits - 1): - if k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2: + if (self.data.build.iohcl != 0) and (k == + self.data.pf_coil.n_pf_cs_plasma_circuits - 2): line = "\tCS\t\t" else: line = f"\t{k + 1}\t\t" @@ -2768,7 +2769,8 @@ def outvolt(self): op.ocmmnt(self.outfile, "This consists of: CS coil field balancing:") for k in range(pf_d.n_pf_cs_plasma_circuits - 1): - if k == pf_d.n_pf_cs_plasma_circuits - 2: + if (self.data.build.iohcl != 0) and (k == + self.data.pf_coil.n_pf_cs_plasma_circuits - 2): op.write( self.outfile, ( @@ -2796,7 +2798,8 @@ def outvolt(self): op.oblnkl(self.outfile) op.ocmmnt(self.outfile, "And: equilibrium field:") for k in range(pf_d.n_pf_cs_plasma_circuits - 1): - if k == pf_d.n_pf_cs_plasma_circuits - 2: + if (self.data.build.iohcl != 0) and (k == + self.data.pf_coil.n_pf_cs_plasma_circuits - 2): op.write( self.outfile, ( @@ -2847,7 +2850,8 @@ def outvolt(self): if k == self.data.pf_coil.n_pf_cs_plasma_circuits - 1: circuit_name = f"Plasma Time point {jjj} (A)" circuit_var_name = f"(plasmat{jjj})" - elif k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2: + elif (self.data.build.iohcl != 0) and (k == + self.data.pf_coil.n_pf_cs_plasma_circuits - 2): circuit_name = f"CS Circuit Time point {jjj} (A)" circuit_var_name = f"(cs t{jjj})" else: From 130708c2b022316691eea33f89cde70ddad374dc Mon Sep 17 00:00:00 2001 From: Jonathan Matthews Date: Wed, 2 Sep 2026 10:34:41 +0100 Subject: [PATCH 4/5] tabulated some outputs --- process/models/pfcoil.py | 232 ++++++++++++++++++++++++--------------- 1 file changed, 146 insertions(+), 86 deletions(-) diff --git a/process/models/pfcoil.py b/process/models/pfcoil.py index a10df82ac2..995f028a37 100644 --- a/process/models/pfcoil.py +++ b/process/models/pfcoil.py @@ -2660,26 +2660,36 @@ def outvolt(self): op.oheadr(self.outfile, "Volt Second Consumption") pf = self.data.pf_coil - op.write(self.outfile, "\t" * 6 + "volt-sec\t\t\tvolt-sec\t\tvolt-sec") - op.write(self.outfile, "\t" * 6 + "start-up\t\t\tburn\t\t\t\ttotal") - op.write( - self.outfile, - f"PF coils:\t\t{pf.vs_pf_coils_total_ramp:.2f}" - f"\t\t\t\t{pf.vs_pf_coils_total_burn:.2f}\t\t\t{pf.vs_pf_coils_total_pulse:.2f}", - ) - op.write( - self.outfile, - f"CS coil:\t\t{pf.vs_cs_ramp:.2f}" - f"\t\t\t\t{pf.vs_cs_burn:.2f}\t\t\t{pf.vs_cs_total_pulse:.2f}", - ) - op.write( - self.outfile, "\t" * 6 + "-" * 7 + "\t" * 4 + "-" * 7 + "\t" * 3 + "-" * 7 - ) - op.write( - self.outfile, - f"Total:\t\t\t{pf.vs_cs_pf_total_ramp:.2f}\t\t\t\t{pf.vs_cs_pf_total_burn:.2f}\t\t\t{pf.vs_cs_pf_total_pulse:.2f}", - ) + headers = [ + "", + "Start-up (Vs)", + "Burn (Vs)", + "Total (Vs)" + ] + rows = [] + rows.extend(( + ["PF coils", + f"{pf.vs_pf_coils_total_ramp:.2f}", + f"{pf.vs_pf_coils_total_burn:.2f}", + f"{pf.vs_pf_coils_total_pulse:.2f}"], + ["CS coil", + f"{pf.vs_cs_ramp:.2f}", + f"{pf.vs_cs_burn:.2f}", + f"{pf.vs_cs_total_pulse:.2f}"], + ["Total", + f"{pf.vs_cs_pf_total_ramp:.2f}", + f"{pf.vs_cs_pf_total_burn:.2f}", + f"{pf.vs_cs_pf_total_pulse:.2f}"] + )) + op.oblnkl(self.outfile) + for line in tabulate( + rows, + headers=headers, + tablefmt="plain", + disable_numparse=True, + ).splitlines(): + op.write(self.outfile, line) op.oblnkl(self.outfile) op.ovarre( self.outfile, @@ -2699,27 +2709,45 @@ def outvolt(self): op.osubhd(self.outfile, "Summary of volt-second consumption by circuit (Wb):") op.write(self.outfile, "Circuit\t\t\tBOP\t\t\tBOF\t\tEOF") op.oblnkl(self.outfile) - + headers = [ + "Circuit", + "BOP", + "BOF", + "EOF" + ] + rows = [] for k in range(pf.nef): - op.write( - self.outfile, - f"\t{k + 1}\t\t\t{pf.vsdum[k, 0]:.3f}" - f"\t\t\t{pf.vsdum[k, 1]:.3f}\t\t{pf.vsdum[k, 2]:.3f}", - ) + rows.append([ + f"PF {k + 1}", + f"{pf.vsdum[k, 0]:.3f}", + f"{pf.vsdum[k, 1]:.3f}", + f"{pf.vsdum[k, 2]:.3f}" + ]) n_cs = pf.n_cs_pf_coils - 1 - op.write( - self.outfile, - f"\tCS\t\t\t{pf.vsdum[n_cs, 0]:.3f}" - f"\t\t\t{pf.vsdum[n_cs, 1]:.3f}\t\t{pf.vsdum[n_cs, 2]:.3f}", - ) + rows.append([ + "CS coil", + f"{pf.vsdum[n_cs, 0]:.3f}", + f"{pf.vsdum[n_cs, 1]:.3f}", + f"{pf.vsdum[n_cs, 2]:.3f}" + ]) + op.oblnkl(self.outfile) + for line in tabulate( + rows, + headers=headers, + tablefmt="plain", + disable_numparse=True, + ).splitlines(): + op.write(self.outfile, line) + op.oblnkl(self.outfile) op.oshead(self.outfile, "Waveforms") op.ocmmnt(self.outfile, "Currents (Amps/coil) as a function of time:") op.oblnkl(self.outfile) - op.write(self.outfile, "\t" * 8 + "time (sec)") - line = "\t\t" + op.write(self.outfile, "Times (s)") + + headers = ["Coil"] pulse_timings = PulseTimings( t_plant_pulse_coil_precharge=self.data.times.t_plant_pulse_coil_precharge, t_plant_pulse_plasma_current_ramp_up=self.data.times.t_plant_pulse_plasma_current_ramp_up, @@ -2728,17 +2756,26 @@ def outvolt(self): t_plant_pulse_plasma_current_ramp_down=self.data.times.t_plant_pulse_plasma_current_ramp_down, t_plant_pulse_dwell=self.data.times.t_plant_pulse_dwell, ) - for k in range(pulse_timings.n_pf_active_points_total): - line += f"\t\t{pulse_timings.pf_active_cumulative[k]:.2f}" - op.write(self.outfile, line) - - line = "\t\t" for k in range(pulse_timings.n_pf_active_points_total): label = pulse_timings.POINT_ABBREVIATIONS[k] - line += f"\t\t{label}" - op.write(self.outfile, line) + headers.append(label) + line = [] + for k in range(pulse_timings.n_pf_active_points_total): + line += [f"{pulse_timings.pf_active_cumulative[k]:.2f}"] + rows = [line] + for line in tabulate( + rows, + headers=headers[1:], + tablefmt="plain", + disable_numparse=True, + ).splitlines(): + op.write(self.outfile, line) - op.ocmmnt(self.outfile, "circuit") + op.oblnkl(self.outfile) + op.write(self.outfile, "Currents (A)") + op.ocmmnt(self.outfile, "Circuit:") + + rows = [] pf_d = self.data.pf_coil cpft = self.data.pf_coil.c_pf_coil_turn @@ -2752,75 +2789,98 @@ def outvolt(self): for k in range(self.data.pf_coil.n_pf_cs_plasma_circuits - 1): if (self.data.build.iohcl != 0) and (k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2): - line = "\tCS\t\t" + line = ["CS"] else: - line = f"\t{k + 1}\t\t" + line = [f"PF {k + 1}"] for jj in range(6): - line += f"\t{cpft[k, jj] * self.data.pf_coil.n_pf_coil_turns[k]:.3e}" - op.write(self.outfile, line) + line += [f"{cpft[k, jj] * self.data.pf_coil.n_pf_coil_turns[k]:.3e}"] + rows.append(line) - line = "Plasma (A)\t\t" + line = ["Plasma"] for jj in range(6): - line += f"\t{cpft[self.data.pf_coil.n_pf_cs_plasma_circuits - 1, jj]:.3e}" + line += [f"{cpft[self.data.pf_coil.n_pf_cs_plasma_circuits - 1, jj]:.3e}"] + rows.append(line) - op.write(self.outfile, line) + # op.write(self.outfile, line) + op.oblnkl(self.outfile) + for line in tabulate( + rows, + headers=headers, + tablefmt="plain", + disable_numparse=True, + ).splitlines(): + op.write(self.outfile, line) op.oblnkl(self.outfile) - op.ocmmnt(self.outfile, "This consists of: CS coil field balancing:") + op.ocmmnt(self.outfile, "This consists of: CS coil field balancing:") + rows = [] for k in range(pf_d.n_pf_cs_plasma_circuits - 1): if (self.data.build.iohcl != 0) and (k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2): - op.write( - self.outfile, - ( - f"CS\t\t\t{cpft[k, 0] * pf_d.n_pf_coil_turns[k]:.3e}\t" - f"{cpft[k, 1] * nturn[k]:.3e}\t" - f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}\t" - f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}\t" - f"{-cpft[k, 1] * nturn[k] * inv_st_pulse:.3e}\t" + rows.append([ + "CS", + f"{cpft[k, 0] * pf_d.n_pf_coil_turns[k]:.3e}", + f"{cpft[k, 1] * nturn[k]:.3e}", + f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}", + f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}", + f"{-cpft[k, 1] * nturn[k] * inv_st_pulse:.3e}", f"{cpft[k, 5] * nturn[k]:.3e}" - ), - ) + ]) else: - op.write( - self.outfile, - ( - f"{k + 1}\t\t\t{cpft[k, 0] * pf_d.n_pf_coil_turns[k]:.3e}\t" - f"{cpft[k, 1] * nturn[k]:.3e}\t" - f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}\t" - f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}\t" - f"{-cpft[k, 1] * nturn[k] * inv_st_pulse:.3e}\t" + rows.append([ + f"PF {k + 1}", + f"{cpft[k, 0] * pf_d.n_pf_coil_turns[k]:.3e}", + f"{cpft[k, 1] * nturn[k]:.3e}", + f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}", + f"{-cpft[k, 1] * nturn[k] * se_ft_eft:.3e}", + f"{-cpft[k, 1] * nturn[k] * inv_st_pulse:.3e}", f"{cpft[k, 5] * nturn[k]:.3e}" - ), - ) + ]) + + op.oblnkl(self.outfile) + for line in tabulate( + rows, + headers=headers, + tablefmt="plain", + disable_numparse=True, + ).splitlines(): + op.write(self.outfile, line) op.oblnkl(self.outfile) op.ocmmnt(self.outfile, "And: equilibrium field:") + rows = [] for k in range(pf_d.n_pf_cs_plasma_circuits - 1): if (self.data.build.iohcl != 0) and (k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2): - op.write( - self.outfile, - ( - f"CS\t\t\t{0.0:.3e}\t{0.0:.3e}\t" - f"{(cpft[k, 2] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}\t" - f"{(cpft[k, 3] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}\t" - f"{(cpft[k, 4] + cpft[k, 1] * inv_st_pulse) * nturn[k]:.3e}\t" + rows.append([ + "CS", + f"{0.0:.3e}", + f"{0.0:.3e}", + f"{(cpft[k, 2] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}", + f"{(cpft[k, 3] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}", + f"{(cpft[k, 4] + cpft[k, 1] * inv_st_pulse) * nturn[k]:.3e}", "0.0e0" - ), - ) + ]) else: - op.write( - self.outfile, - ( - f"{k + 1}\t\t\t{0.0:.3e}\t{0.0:.3e}\t" - f"{(cpft[k, 2] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}\t" - f"{(cpft[k, 3] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}\t" - f"{(cpft[k, 4] + cpft[k, 1] * inv_st_pulse) * nturn[k]:.3e}\t" + rows.append([ + f"PF {k + 1}", + f"{0.0:.3e}", + f"{0.0:.3e}", + f"{(cpft[k, 2] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}", + f"{(cpft[k, 3] + cpft[k, 1] * se_ft_eft) * nturn[k]:.3e}", + f"{(cpft[k, 4] + cpft[k, 1] * inv_st_pulse) * nturn[k]:.3e}", "0.0e0" - ), - ) + ]) + + op.oblnkl(self.outfile) + for line in tabulate( + rows, + headers=headers, + tablefmt="plain", + disable_numparse=True, + ).splitlines(): + op.write(self.outfile, line) op.oblnkl(self.outfile) op.ovarre( From 534fe42cdd2766b3b5544840ce7858868c4f7629 Mon Sep 17 00:00:00 2001 From: Jonathan Matthews Date: Wed, 2 Sep 2026 10:35:19 +0100 Subject: [PATCH 5/5] removed duplicated waveform outputs --- process/models/pfcoil.py | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/process/models/pfcoil.py b/process/models/pfcoil.py index 995f028a37..0f58ebad36 100644 --- a/process/models/pfcoil.py +++ b/process/models/pfcoil.py @@ -2898,34 +2898,6 @@ def outvolt(self): "OP ", ) - op.oshead(self.outfile, "PF Circuit Waveform Data") - op.ovarre( - self.outfile, - "Number of PF circuits including CS and plasma", - "(n_pf_cs_plasma_circuits)", - self.data.pf_coil.n_pf_cs_plasma_circuits, - ) - for k in range(self.data.pf_coil.n_pf_cs_plasma_circuits): - for jjj in range(6): - if k == self.data.pf_coil.n_pf_cs_plasma_circuits - 1: - circuit_name = f"Plasma Time point {jjj} (A)" - circuit_var_name = f"(plasmat{jjj})" - elif (self.data.build.iohcl != 0) and (k == - self.data.pf_coil.n_pf_cs_plasma_circuits - 2): - circuit_name = f"CS Circuit Time point {jjj} (A)" - circuit_var_name = f"(cs t{jjj})" - else: - circuit_name = f"PF Circuit {k + 1} Time point {jjj} (A)" - circuit_var_name = f"(pfc{k}t{jjj})" - - op.ovarre( - self.outfile, - circuit_name, - circuit_var_name, - self.data.pf_coil.c_pf_coil_turn[k, jjj] - * self.data.pf_coil.n_pf_coil_turns[k], - ) - @staticmethod def selfinductance(a, b, c, n): """Calculates the selfinductance using Bunet's formula.