Skip to content

🔌 Power plot over time#3940

Merged
timothy-nunn merged 11 commits intomainfrom
power_plot_over_time
Nov 6, 2025
Merged

🔌 Power plot over time#3940
timothy-nunn merged 11 commits intomainfrom
power_plot_over_time

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

@chris-ashe chris-ashe commented Oct 20, 2025

This pull request adds comprehensive support for tracking, calculating, and visualizing time-dependent power profiles and net electric energy output for various plant systems over a pulse. The changes include new variables to store power profiles, updated calculations and output routines, and a new plotting function to visualize these profiles, with integration into the main plotting workflow.

Power profile and energy output tracking:

  • Added new variables in power_variables.py to store net electric energy output per pulse (in MJ and kWh) and detailed power profiles for key plant subsystems (e.g., coils, pumps, tritium, cryo, fusion, gross/net electric power) over the pulse.
  • Updated init_power_variables() to initialize these new variables and profiles.

Calculation and output enhancements:

  • Modified Power.plant_electric_production() to compute all new energy outputs and power profiles over time, assigning them to the new variables.
  • Updated output routines in Power.output_plant_electric_powers() and output.py to write the new net electric energy outputs to the output file.

Visualization and plotting integration:

  • Added a new plotting function plot_system_power_profiles_over_time() in plot_proc.py to visualize the time evolution of all tracked power profiles and annotate energy production and pulse timings.
  • Integrated this plot into the main plotting workflow, including figure creation, subplot setup, PDF export, and resource cleanup.
image

Internal API and data flow updates:

  • Updated the Power class to track the output file and MFile for improved data flow.

Checklist

I confirm that I have completed the following checks:

  • My changes follow the PROCESS style guide
  • I have justified any large differences in the regression tests caused by this pull request in the comments.
  • I have added new tests where appropriate for the changes I have made.
  • If I have had to change any existing unit or integration tests, I have justified this change in the pull request comments.
  • If I have made documentation changes, I have checked they render correctly.
  • I have added documentation for my change, if appropriate.

@chris-ashe chris-ashe self-assigned this Oct 20, 2025
@chris-ashe chris-ashe added Engineering Relating to the engineering models Input/Output Files Issues related to the input and output data files labels Oct 20, 2025
@chris-ashe chris-ashe force-pushed the power_plot_over_time branch 2 times, most recently from a7d0d96 to a6ba4f9 Compare October 29, 2025 15:12
@chris-ashe chris-ashe marked this pull request as ready for review October 29, 2025 15:52
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 52.81690% with 67 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.04%. Comparing base (0fdad95) to head (ca93576).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
process/io/plot_proc.py 4.65% 41 Missing ⚠️
process/power.py 63.76% 25 Missing ⚠️
process/output.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3940      +/-   ##
==========================================
+ Coverage   46.01%   46.04%   +0.03%     
==========================================
  Files         123      123              
  Lines       28723    28865     +142     
==========================================
+ Hits        13217    13292      +75     
- Misses      15506    15573      +67     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chris-ashe chris-ashe force-pushed the power_plot_over_time branch from e4d9d4d to 379a00b Compare November 3, 2025 14:51
Comment thread process/power.py Outdated
Comment on lines +2428 to +2498
for i in range(len(power_variables.p_plant_electric_base_total_profile_mw)):
po.ovarre(
self.mfile,
f"Plant total electric base load at time point {i}",
f"p_plant_electric_base_total_profile_mw{i}",
power_variables.p_plant_electric_base_total_profile_mw[i],
)
for i in range(len(power_variables.p_plant_electric_gross_profile_mw)):
po.ovarre(
self.mfile,
f"Plant total electric gross at time point {i}",
f"p_plant_electric_gross_profile_mw{i}",
power_variables.p_plant_electric_gross_profile_mw[i],
)
for i in range(len(power_variables.p_plant_electric_net_profile_mw)):
po.ovarre(
self.mfile,
f"Plant total electric net at time point {i}",
f"p_plant_electric_net_profile_mw{i}",
power_variables.p_plant_electric_net_profile_mw[i],
)
for i in range(len(power_variables.p_hcd_electric_total_profile_mw)):
po.ovarre(
self.mfile,
f"Plant total electric HCD at time point {i}",
f"p_hcd_electric_total_profile_mw{i}",
power_variables.p_hcd_electric_total_profile_mw[i],
)
for i in range(len(power_variables.p_coolant_pump_elec_total_profile_mw)):
po.ovarre(
self.mfile,
f"Plant total electric coolant pump at time point {i}",
f"p_coolant_pump_elec_total_profile_mw{i}",
power_variables.p_coolant_pump_elec_total_profile_mw[i],
)
for i in range(len(power_variables.p_tf_electric_supplies_profile_mw)):
po.ovarre(
self.mfile,
f"Plant total electric TF supplies at time point {i}",
f"p_tf_electric_supplies_profile_mw{i}",
power_variables.p_tf_electric_supplies_profile_mw[i],
)
for i in range(len(power_variables.p_pf_electric_supplies_profile_mw)):
po.ovarre(
self.mfile,
f"Plant total electric PF supplies at time point {i}",
f"p_pf_electric_supplies_profile_mw{i}",
power_variables.p_pf_electric_supplies_profile_mw[i],
)
for i in range(len(power_variables.vachtmw_profile_mw)):
po.ovarre(
self.mfile,
f"Plant total electric vacuum pump power at time point {i}",
f"vachtmw_profile_mw{i}",
power_variables.vachtmw_profile_mw[i],
)
for i in range(len(power_variables.p_tritium_plant_electric_profile_mw)):
po.ovarre(
self.mfile,
f"Plant total electric tritium plant power at time point {i}",
f"p_tritium_plant_electric_profile_mw{i}",
power_variables.p_tritium_plant_electric_profile_mw[i],
)
for i in range(len(power_variables.p_cryo_plant_electric_profile_mw)):
po.ovarre(
self.mfile,
f"Plant total electric cryo plant power at time point {i}",
f"p_cryo_plant_electric_profile_mw{i}",
power_variables.p_cryo_plant_electric_profile_mw[i],
)
for i in range(len(power_variables.p_fusion_total_profile_mw)):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these loops be re-written with enumerate.

E.g.

for index, profile_value in enumerate(power_variables.p_plant_electric_base_total_profile_mw):

Comment thread process/power.py
Comment on lines +2409 to +2423
return (
energy_made_kwh,
energy_made_mj,
power_profiles["p_plant_electric_base_total_mw"],
power_profiles["p_plant_electric_gross_mw"],
power_profiles["p_plant_electric_net_mw"],
power_profiles["p_hcd_electric_total_mw"],
power_profiles["p_coolant_pump_elec_total_mw"],
power_profiles["p_tf_electric_supplies_mw"],
power_profiles["p_pf_electric_supplies_mw"],
power_profiles["vachtmw"],
power_profiles["p_tritium_plant_electric_mw"],
power_profiles["p_cryo_plant_electric_mw"],
power_profiles["p_fusion_total_mw"],
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand why we are making a dictionary above just to pass out all of its elements

Comment thread process/power.py
Comment on lines +1427 to +1441
(
power_variables.e_plant_net_electric_pulse_kwh,
power_variables.e_plant_net_electric_pulse_mj,
power_variables.p_plant_electric_base_total_profile_mw,
power_variables.p_plant_electric_gross_profile_mw,
power_variables.p_plant_electric_net_profile_mw,
power_variables.p_hcd_electric_total_profile_mw,
power_variables.p_coolant_pump_elec_total_profile_mw,
power_variables.p_tf_electric_supplies_profile_mw,
power_variables.p_pf_electric_supplies_profile_mw,
power_variables.vachtmw_profile_mw,
power_variables.p_tritium_plant_electric_profile_mw,
power_variables.p_cryo_plant_electric_profile_mw,
power_variables.p_fusion_total_profile_mw,
) = self.power_profiles_over_time(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need to store these as variables globally, or can these calculations be done locally and immediately output (would change during PROCESS output format refactor)

Comment thread process/io/plot_proc.py Outdated
Comment on lines +3399 to +3402
def secs_to_hms(s):
"""Convert seconds to 'Hh Mm Ss' string."""
s = float(s)
return f"{int(s // 3600)}h {int((s % 3600) // 60)}m {int(s % 60)}s"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this function be made not local?

@chris-ashe chris-ashe force-pushed the power_plot_over_time branch from 0d6a960 to fd225e6 Compare November 5, 2025 13:38
@timothy-nunn timothy-nunn self-requested a review November 5, 2025 14:55
Comment thread process/power.py Outdated
po.ovarre(
self.mfile,
f"Plant total electric base load at time point {i}",
f"p_plant_electric_base_total_profile_mw{i}",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"p_plant_electric_base_total_profile_mw{i}",
f"(p_plant_electric_base_total_profile_mw{i})",

Comment thread process/power.py Outdated
po.ovarre(
self.mfile,
f"Plant total electric gross at time point {i}",
f"p_plant_electric_gross_profile_mw{i}",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"p_plant_electric_gross_profile_mw{i}",
f"(p_plant_electric_gross_profile_mw{i})",

Comment thread process/power.py Outdated
po.ovarre(
self.mfile,
f"Plant total electric net at time point {i}",
f"p_plant_electric_net_profile_mw{i}",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"p_plant_electric_net_profile_mw{i}",
f"(p_plant_electric_net_profile_mw{i})",

Comment thread process/power.py Outdated
po.ovarre(
self.mfile,
f"Plant total electric HCD at time point {i}",
f"p_hcd_electric_total_profile_mw{i}",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"p_hcd_electric_total_profile_mw{i}",
f"(p_hcd_electric_total_profile_mw{i})",

Comment thread process/power.py Outdated
po.ovarre(
self.mfile,
f"Plant total electric coolant pump at time point {i}",
f"p_coolant_pump_elec_total_profile_mw{i}",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"p_coolant_pump_elec_total_profile_mw{i}",
f"(p_coolant_pump_elec_total_profile_mw{i})",

Comment thread process/power.py Outdated
po.ovarre(
self.mfile,
f"Plant total electric PF supplies at time point {i}",
f"p_pf_electric_supplies_profile_mw{i}",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"p_pf_electric_supplies_profile_mw{i}",
f"(p_pf_electric_supplies_profile_mw{i})",

Comment thread process/power.py Outdated
po.ovarre(
self.mfile,
f"Plant total electric vacuum pump power at time point {i}",
f"vachtmw_profile_mw{i}",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"vachtmw_profile_mw{i}",
f"(vachtmw_profile_mw{i})",

Comment thread process/power.py Outdated
po.ovarre(
self.mfile,
f"Plant total electric tritium plant power at time point {i}",
f"p_tritium_plant_electric_profile_mw{i}",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"p_tritium_plant_electric_profile_mw{i}",
f"(p_tritium_plant_electric_profile_mw{i})",

Comment thread process/power.py Outdated
po.ovarre(
self.mfile,
f"Plant total electric cryo plant power at time point {i}",
f"p_cryo_plant_electric_profile_mw{i}",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"p_cryo_plant_electric_profile_mw{i}",
f"(p_cryo_plant_electric_profile_mw{i})",

Comment thread process/power.py Outdated
po.ovarre(
self.mfile,
f"Plant total electric fusion plant power at time point {i}",
f"p_fusion_total_profile_mw{i}",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"p_fusion_total_profile_mw{i}",
f"(p_fusion_total_profile_mw{i})",

@chris-ashe chris-ashe force-pushed the power_plot_over_time branch from fd225e6 to ca93576 Compare November 5, 2025 16:16
@timothy-nunn timothy-nunn merged commit a9a5e81 into main Nov 6, 2025
12 of 18 checks passed
@timothy-nunn timothy-nunn deleted the power_plot_over_time branch November 6, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Engineering Relating to the engineering models Input/Output Files Issues related to the input and output data files New Variables

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants