106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253 | def plot_system_power_profiles_over_time(axis: plt.Axes, mfile: MFile, scan: int, fig):
"""Plots the power profiles over time for various systems."""
pulse_timings = get_pulse_timings(mfile, scan)
# Create empty arrays for the power at each time step for each system
power_profiles = {
"Fusion Power": np.zeros(pulse_timings.n_pulse_points_total),
"Plant Base Load": np.zeros(pulse_timings.n_pulse_points_total),
"Cryo Plant": np.zeros(pulse_timings.n_pulse_points_total),
"Tritium Plant": np.zeros(pulse_timings.n_pulse_points_total),
"Vacuum Pumps": np.zeros(pulse_timings.n_pulse_points_total),
"TF Coil Supplies": np.zeros(pulse_timings.n_pulse_points_total),
"PF Coil Supplies": np.zeros(pulse_timings.n_pulse_points_total),
"Coolant Pump Elec Total": np.zeros(pulse_timings.n_pulse_points_total),
"HCD Electric Total": np.zeros(pulse_timings.n_pulse_points_total),
"Gross Electric Power": np.zeros(pulse_timings.n_pulse_points_total),
"Net Electric Power": np.zeros(pulse_timings.n_pulse_points_total),
}
# Fill power_profiles arrays using vectorized assignment
for label, key in [
("Fusion Power", "p_fusion_total_profile_mw"),
("Gross Electric Power", "p_plant_electric_gross_profile_mw"),
("Net Electric Power", "p_plant_electric_net_profile_mw"),
("Plant Base Load", "p_plant_electric_base_total_profile_mw"),
("Cryo Plant", "p_cryo_plant_electric_profile_mw"),
("Tritium Plant", "p_tritium_plant_electric_profile_mw"),
("Vacuum Pumps", "vachtmw_profile_mw"),
("TF Coil Supplies", "p_tf_electric_supplies_profile_mw"),
("PF Coil Supplies", "p_pf_electric_supplies_profile_mw"),
("Coolant Pump Elec Total", "p_coolant_pump_elec_total_profile_mw"),
("HCD Electric Total", "p_hcd_electric_total_profile_mw"),
]:
for time in range(pulse_timings.n_pulse_points_total):
power_profiles[label][time] = mfile.get(f"{key}{time}", scan=scan)
# Define line styles for each system
# All net drains (negative power flows) use the same line style: dashed
line_styles = {
"Fusion Power": ":",
"Plant Base Load": "--",
"Cryo Plant": "--",
"Tritium Plant": "--",
"Vacuum Pumps": "--",
"TF Coil Supplies": "--",
"PF Coil Supplies": "--",
"Coolant Pump Elec Total": "--",
"HCD Electric Total": "--",
"Gross Electric Power": "-",
"Net Electric Power": "-",
}
# Plot each system's power profile over time with different line styles
for label, powers in power_profiles.items():
style = line_styles.get(label, "-")
axis.plot(
pulse_timings.total_pulse_cumulative,
powers,
label=label,
linestyle=style,
)
# Move the x-axis to 0 on the y-axis
axis.spines["bottom"].set_position("zero")
# Annotate key points
# Create a secondary x-axis for annotations
secax = axis.secondary_xaxis("bottom")
# Label phase starts only (exclude final end-of-dwell point).
secax.set_xticks(pulse_timings.total_pulse_cumulative[:-1])
secax.set_xticklabels(
pulse_timings.POINT_LABELS,
rotation=60,
)
secax.tick_params(axis="x", which="major")
# Add axis labels
axis.set_xlabel("Time [s]", fontsize=12)
axis.xaxis.set_label_coords(1.05, 0.5)
axis.set_ylabel("Power [MW]", fontsize=12)
# Add a title
axis.set_title("System Power Over Time", fontsize=14)
# Add a legend
axis.legend()
axis.set_yscale("symlog")
axis.minorticks_on()
axis.grid(True, which="both", linestyle="--", linewidth=0.5, alpha=0.2)
# Add a grid for better readability
axis.grid(True, linestyle="--", alpha=0.6)
# Add energy produced info
textstr_energy = (
"$\\mathbf{Energy \\ Production:}$\n\nEnergy produced over whole"
f" pulse: {mfile.get('e_plant_net_electric_pulse_mj', scan=scan):,.4f}"
" MJ\nEnergy produced over whole pulse:"
f" {mfile.get('e_plant_net_electric_pulse_kwh', scan=scan):,.4f} kWh\n"
)
axis.text(
0.075,
0.2,
textstr_energy,
fontsize=9,
verticalalignment="top",
transform=fig.transFigure,
bbox=box_style("grey"),
)
# Add energy produced info
textstr_times = (
"$\\mathbf{Pulse \\ Timings:}$\n\nCoil precharge,"
" $t_{\\text{precharge}}$: "
f" {mfile.get('t_plant_pulse_coil_precharge', scan=scan):,.1f} s "
f" ({secs_to_hms(mfile.get('t_plant_pulse_coil_precharge', scan=scan))})\nCurrent" # noqa: E501
" ramp up, $t_{\\text{current ramp}}$: "
f" {mfile.get('t_plant_pulse_plasma_current_ramp_up', scan=scan):,.1f}"
f" s ({secs_to_hms(mfile.get('t_plant_pulse_plasma_current_ramp_up', scan=scan))})\nFusion" # noqa: E501
" ramp, $t_{\\text{fusion ramp}}$: "
f" {mfile.get('t_plant_pulse_fusion_ramp', scan=scan):,.1f} s "
f" ({secs_to_hms(mfile.get('t_plant_pulse_fusion_ramp', scan=scan))})\nBurn,"
" $t_{\\text{burn}}$: "
f" {mfile.get('t_plant_pulse_burn', scan=scan):,.1f} s "
f" ({secs_to_hms(mfile.get('t_plant_pulse_burn', scan=scan))})\nRamp"
" down, $t_{\\text{ramp down}}$: "
f" {mfile.get('t_plant_pulse_plasma_current_ramp_down', scan=scan):,.1f}"
f" s ({secs_to_hms(mfile.get('t_plant_pulse_plasma_current_ramp_down', scan=scan))})\nBetween" # noqa: E501
" pulse, $t_{\\text{between pulse}}$: "
f" {mfile.get('t_plant_pulse_dwell', scan=scan):,.1f} s "
f" ({secs_to_hms(mfile.get('t_plant_pulse_dwell', scan=scan))})\n\nTotal"
" pulse length, $t_{\\text{cycle}}$: "
f" {mfile.get('t_plant_pulse_total', scan=scan):,.1f} s "
f" ({secs_to_hms(mfile.get('t_plant_pulse_total', scan=scan))})\n"
)
axis.text(
0.6,
0.225,
textstr_times,
fontsize=9,
verticalalignment="top",
transform=fig.transFigure,
bbox=box_style("grey"),
)
|