Skip to content

4233 global power imbalance output#4417

Open
mkovari wants to merge 2 commits into
mainfrom
4233-global-power-imbalance-output
Open

4233 global power imbalance output#4417
mkovari wants to merge 2 commits into
mainfrom
4233-global-power-imbalance-output

Conversation

@mkovari

@mkovari mkovari commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

This implements issue #4233. I have restored the power accounting section in the output files.
Note the powers do not balance - see issue for details.
The only changes are additional outputs.
I have merged main into this branch, but's a long time since I have made a merge request - let me know if there are any problems. I have no idea how to update the outputs of the regression tests, or if I need to do this.
I will create new issues to resolve the imbalances. Those will need to be looked at by Chris and others - for the moment I suggest any of the people on the maintainer list are sufficient.

@mkovari mkovari requested a review from a team as a code owner July 7, 2026 12:51
@mkovari mkovari linked an issue Jul 7, 2026 that may be closed by this pull request
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 74 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.72%. Comparing base (a3db864) to head (c944cef).

Files with missing lines Patch % Lines
process/models/physics/physics.py 0.00% 74 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4417      +/-   ##
==========================================
- Coverage   48.84%   48.72%   -0.13%     
==========================================
  Files         151      151              
  Lines       29406    29480      +74     
==========================================
  Hits        14363    14363              
- Misses      15043    15117      +74     

☔ View full report in Codecov by Harness.
📢 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.

@timothy-nunn timothy-nunn left a comment

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.

Just some suggestions from a quick code review. Will check the calculations in another review.

if self.data.physics.i_plasma_ignited == 1:
po.ocmmnt(self.outfile, " (Injected power only used for start-up phase)")

# Global power imbalance output #4233 ########################################

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
# Global power imbalance output #4233 ########################################

@mkovari mkovari Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Row of # removed. Comment unchanged

po.ovarre(
self.outfile,
"Plasma power imbalance (MW)",
"(p_plasma_out - p_plasma_in)",

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
"(p_plasma_out - p_plasma_in)",
"(p_plasma_out_subtract_p_plasma_in)",

I don't think this will be able to be indexed from the MFILE properly

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

All these have been replaced by new variables:
"(p_plasma_imbalance_mw)",
etc

if abs(p_plasma_out - p_plasma_in) > 0.1:
logger.error("Plasma power imbalance > 0.1 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.

Suggested change
####################################################

I know these still exist in the code but I try and keep them at a minimum

@mkovari mkovari Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed

Comment thread process/models/physics/physics.py
Comment thread process/models/physics/physics.py
po.ovarre(
self.outfile,
"Electric power imbalance (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 you assign this an output name otherwise I suspect it will cause issues in the MFILE parsing at some point

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

New variable

po.ovarre(
self.outfile,
"Power plant overall imbalance (MW)",
"(p_plant_in_mw - p_plant_out_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.

Suggested change
"(p_plant_in_mw - p_plant_out_mw)",
"(p_plant_in_mw_subtract_p_plant_out_mw)",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

New variable

@timothy-nunn timothy-nunn self-assigned this Jul 7, 2026

@timothy-nunn timothy-nunn left a comment

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.

A lot of these variables are already being output in the same routine/in other models. I don't see a reason to do this twice?

Comment on lines +2331 to +2344
po.ovarre(
self.outfile,
"Net power transported by electrons (MW)",
"(p_electron_transport_loss_mw)",
self.data.physics.p_electron_transport_loss_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Net power transported by ions (MW)",
"(p_ion_transport_loss_mw)",
self.data.physics.p_ion_transport_loss_mw,
"OP ",
)

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.

These variables are already output above

Suggested change
po.ovarre(
self.outfile,
"Net power transported by electrons (MW)",
"(p_electron_transport_loss_mw)",
self.data.physics.p_electron_transport_loss_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Net power transported by ions (MW)",
"(p_ion_transport_loss_mw)",
self.data.physics.p_ion_transport_loss_mw,
"OP ",
)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Indeed. Nevertheless, we need to check that the powers balance, and there is no easy way to check that from the existing outputs. A certain amount of redundancy is not a big deal. It may be possible to slim down the rest of the output file - I can look at that, but that would be another issue.

In theory one could hide the output if it balances, and display it only if there is a discrepancy, but I don't really see the benefit.

Comment on lines +2352 to +2358
po.ovarre(
self.outfile,
"Net loss by synchrotron radiation (MW)",
"(p_plasma_sync_mw)",
self.data.physics.p_plasma_sync_mw,
"OP ",
)

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.

Already output above

Suggested change
po.ovarre(
self.outfile,
"Net loss by synchrotron radiation (MW)",
"(p_plasma_sync_mw)",
self.data.physics.p_plasma_sync_mw,
"OP ",
)

Comment on lines +2374 to +2401
po.ovarre(
self.outfile,
"Alpha power (MW)",
"(p_alpha_total_mw)",
self.data.physics.p_alpha_total_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Power from p, 3He, T products of DD and/or D-He3 fusion (MW)",
"(p_non_alpha_charged_mw)",
self.data.physics.p_non_alpha_charged_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Injected power (MW)",
"(p_hcd_injected_total_mw)",
self.data.current_drive.p_hcd_injected_total_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Ohmic heating (MW)",
"(p_plasma_ohmic_mw)",
self.data.physics.p_plasma_ohmic_mw,
"OP ",
)

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
po.ovarre(
self.outfile,
"Alpha power (MW)",
"(p_alpha_total_mw)",
self.data.physics.p_alpha_total_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Power from p, 3He, T products of DD and/or D-He3 fusion (MW)",
"(p_non_alpha_charged_mw)",
self.data.physics.p_non_alpha_charged_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Injected power (MW)",
"(p_hcd_injected_total_mw)",
self.data.current_drive.p_hcd_injected_total_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Ohmic heating (MW)",
"(p_plasma_ohmic_mw)",
self.data.physics.p_plasma_ohmic_mw,
"OP ",
)

Already output above

Comment on lines +2437 to +2464
po.ovarre(
self.outfile,
"Fusion power (MW)",
"(p_fusion_total_mw)",
self.data.physics.p_fusion_total_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Energy multiplication in blanket and shield (MW)",
"(p_blkt_multiplication_mw)",
self.data.fwbs.p_blkt_multiplication_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Injected power (MW)",
"(p_hcd_injected_total_mw)",
self.data.current_drive.p_hcd_injected_total_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Ohmic heating (MW)",
"(p_plasma_ohmic_mw)",
self.data.physics.p_plasma_ohmic_mw,
"OP ",
)

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
po.ovarre(
self.outfile,
"Fusion power (MW)",
"(p_fusion_total_mw)",
self.data.physics.p_fusion_total_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Energy multiplication in blanket and shield (MW)",
"(p_blkt_multiplication_mw)",
self.data.fwbs.p_blkt_multiplication_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Injected power (MW)",
"(p_hcd_injected_total_mw)",
self.data.current_drive.p_hcd_injected_total_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Ohmic heating (MW)",
"(p_plasma_ohmic_mw)",
self.data.physics.p_plasma_ohmic_mw,
"OP ",
)

Already output above

Comment on lines +2465 to +2478
po.ovarre(
self.outfile,
"Power deposited by pump in coolant for FW and blanket circuit (MW)",
"(p_fw_blkt_coolant_pump_mw)",
self.data.primary_pumping.p_fw_blkt_coolant_pump_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Power deposited by pump in coolant for divertor circuit (MW)",
"(p_div_coolant_pump_mw)",
self.data.heat_transport.p_div_coolant_pump_mw,
"OP ",
)

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.

Already output in another module

Suggested change
po.ovarre(
self.outfile,
"Power deposited by pump in coolant for FW and blanket circuit (MW)",
"(p_fw_blkt_coolant_pump_mw)",
self.data.primary_pumping.p_fw_blkt_coolant_pump_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Power deposited by pump in coolant for divertor circuit (MW)",
"(p_div_coolant_pump_mw)",
self.data.heat_transport.p_div_coolant_pump_mw,
"OP ",
)

Comment on lines +2558 to +2592
po.ovarre(
self.outfile,
"Net electric (MW)",
"(p_plant_electric_net_mw)",
self.data.heat_transport.p_plant_electric_net_mw,
"OP ",
)
po.ovarre(
self.outfile,
"TF coils electric power (MW)",
"(p_tf_electric_supplies_mw)",
self.data.heat_transport.p_tf_electric_supplies_mw,
"OP ",
)
po.ovarre(
self.outfile,
"PF coils electric power (MW)",
"(p_pf_electric_supplies_mw)",
self.data.pf_coil.p_pf_electric_supplies_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Heating and current drive electric power (MW)",
"(p_hcd_electric_total_mw)",
self.data.heat_transport.p_hcd_electric_total_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Primary coolant pump electric power (MW)",
"(p_coolant_pump_elec_total_mw)",
self.data.heat_transport.p_coolant_pump_elec_total_mw,
"OP ",
)

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.

Already being output in another model

Suggested change
po.ovarre(
self.outfile,
"Net electric (MW)",
"(p_plant_electric_net_mw)",
self.data.heat_transport.p_plant_electric_net_mw,
"OP ",
)
po.ovarre(
self.outfile,
"TF coils electric power (MW)",
"(p_tf_electric_supplies_mw)",
self.data.heat_transport.p_tf_electric_supplies_mw,
"OP ",
)
po.ovarre(
self.outfile,
"PF coils electric power (MW)",
"(p_pf_electric_supplies_mw)",
self.data.pf_coil.p_pf_electric_supplies_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Heating and current drive electric power (MW)",
"(p_hcd_electric_total_mw)",
self.data.heat_transport.p_hcd_electric_total_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Primary coolant pump electric power (MW)",
"(p_coolant_pump_elec_total_mw)",
self.data.heat_transport.p_coolant_pump_elec_total_mw,
"OP ",
)

Comment on lines +2593 to +2606
po.ovarre(
self.outfile,
"Vacuum pumps electric power (MW)",
"(vachtmw)",
self.data.heat_transport.vachtmw,
"OP ",
)
po.ovarre(
self.outfile,
"Cryoplant electric power (MW)",
"(p_cryo_plant_electric_mw)",
self.data.heat_transport.p_cryo_plant_electric_mw,
"OP ",
)

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
po.ovarre(
self.outfile,
"Vacuum pumps electric power (MW)",
"(vachtmw)",
self.data.heat_transport.vachtmw,
"OP ",
)
po.ovarre(
self.outfile,
"Cryoplant electric power (MW)",
"(p_cryo_plant_electric_mw)",
self.data.heat_transport.p_cryo_plant_electric_mw,
"OP ",
)

Already being output

Comment on lines +2629 to +2635
po.ovarre(
self.outfile,
"Gross electric output (MW)",
"(p_plant_electric_gross_mw)",
self.data.heat_transport.p_plant_electric_gross_mw,
"OP ",
)

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
po.ovarre(
self.outfile,
"Gross electric output (MW)",
"(p_plant_electric_gross_mw)",
self.data.heat_transport.p_plant_electric_gross_mw,
"OP ",
)

Already being output

Comment on lines +2658 to +2671
po.ovarre(
self.outfile,
"Fusion power (MW)",
"(p_fusion_total_mw)",
self.data.physics.p_fusion_total_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Energy multiplication in blanket and shield (MW)",
"(p_blkt_multiplication_mw)",
self.data.fwbs.p_blkt_multiplication_mw,
"OP ",
)

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
po.ovarre(
self.outfile,
"Fusion power (MW)",
"(p_fusion_total_mw)",
self.data.physics.p_fusion_total_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Energy multiplication in blanket and shield (MW)",
"(p_blkt_multiplication_mw)",
self.data.fwbs.p_blkt_multiplication_mw,
"OP ",
)

Already being output

Comment on lines +2680 to +2700
po.ovarre(
self.outfile,
"Net electric (MW)",
"(p_plant_electric_net_mw)",
self.data.heat_transport.p_plant_electric_net_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Heat rejected by main power conversion circuit (MW)",
"(p_turbine_loss_mw)",
self.data.power.p_turbine_loss_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Heat rejected by other circuits (secondary heat) (MW)",
"(p_plant_secondary_heat_mw)",
self.data.heat_transport.p_plant_secondary_heat_mw,
"OP ",
)

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.

Already output in another model

Suggested change
po.ovarre(
self.outfile,
"Net electric (MW)",
"(p_plant_electric_net_mw)",
self.data.heat_transport.p_plant_electric_net_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Heat rejected by main power conversion circuit (MW)",
"(p_turbine_loss_mw)",
self.data.power.p_turbine_loss_mw,
"OP ",
)
po.ovarre(
self.outfile,
"Heat rejected by other circuits (secondary heat) (MW)",
"(p_plant_secondary_heat_mw)",
self.data.heat_transport.p_plant_secondary_heat_mw,
"OP ",
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Global power imbalance output

3 participants