Skip to content

Derive plasma beta explicitly from the current plasma state - #4640

Open
grmtrkngtn wants to merge 31 commits into
mainfrom
4637-replace-the-iterative-idempotence-treatment-of-plasma-beta-with-an-explicit-fixed-point-calculation
Open

grmtrkngtn wants to merge 31 commits into
mainfrom
4637-replace-the-iterative-idempotence-treatment-of-plasma-beta-with-an-explicit-fixed-point-calculation

Conversation

@grmtrkngtn

@grmtrkngtn grmtrkngtn commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This PR changes plasma beta from an independently optimised quantity to a quantity derived explicitly from the current plasma state. This has been motivated by UQ work, where we want to define solutions to PROCESS in a determined system of equations.

Previously, beta_total_vol_avg could be included as iteration variable ixc=5 and constrained using the beta consistency equation icc=1. Investigation of the non-idempotent beta behaviour showed that the current model no longer contains a meaningful beta = f(beta) feedback loop.

Instead, the remaining non-idempotence came from calculation ordering: beta_total_vol_avg could be evaluated before beta_fast_alpha had been updated for the current model evaluation.

This PR therefore:

  • calculates the fast-particle beta contributions before finalising plasma beta

  • derives thermal beta directly from the current plasma pressure and magnetic field

  • derives total beta as the sum of thermal, fast-alpha and beam contributions

  • removes beta_total_vol_avg as iteration variable ixc=5

  • removes the beta consistency constraint icc=1

Investigation

Thanks to Matti for questioning whether this was still genuinely a fixed-point problem - it appears that it is not.

To test this, I took the converged DEMO LAR point on main, held all other optimisation variables fixed, and varied only the supplied beta_total_vol_avg

supplied beta beta from plasma state thermal beta from state fast-alpha beta Te,ped [keV] density-weighted Te [keV]
0.01 0.037188485401 0.032507877472 0.004680607929 4.199 12.23058763
0.02 0.037188485401 0.032507877472 0.004680607929 4.199 12.23058763
0.04 0.037188485401 0.032507877472 0.004680607929 4.199 12.23058763
0.08 0.037188485401 0.032507877472 0.004680607929 4.199 12.23058763

Changing the supplied beta therefore does not change the upstream plasma quantities from which beta is calculated. This shows that the current model no longer contains a meaningful beta -> plasma state -> beta fixed-point loop.

New solution

There is stil some kind of non-idempotent behaviour that Jon picked up on while developing UQ.

Inspection of the model ordering showed that PlasmaBeta.run() could be called before beta_fast_alpha was recalculated for the current model evaluation.

Total beta could therefore use the fast-alpha contribution left from the previous evaluation, with a subsequent evaluation then using the updated value.

The issue is therefore calculation ordering/stale state rather than a physical beta fixed point.

New calculation

Thermal beta is now calculated directly from the current thermal plasma pressure and the total magnetic field

beta_thermal = 2 μ0 p_thermal / B²

Total beta is then:

beta_total = beta_thermal + beta_fast_alpha + beta_beam

This makes beta_total_vol_avg a derived state quantity rather than an independent optimisation variable.

Independent consistency check

Before removing icc=1, I tested both regression cases with:

ixc=5 OFF

icc=1 ON

This leaves the old consistency equation in place as an independent check while preventing the optimiser from varying beta to satisfy it.

For both cases the beta consistency residual was exactly zero:

DEMO LAR: beta consistency residual = 0.0

ST: beta consistency residual = 0.0

Adding or removing icc=1 did not otherwise change either converged solution or the number of VMCON iterations.

This confirms that once beta is derived from the current plasma state, the old consistency equation is redundant.

Regression results

DEMO LAR

The revised formulation reproduces the previous LAR solution very closely.

Quantity main revised
Iteration variables 19 18
Equality constraints 4 3
Te [keV] 10.99094746 10.99094742
ne [m^-3] 6.877961940e19 6.877961920e19
q95 3.600000000045 3.600000000007
Total beta 0.037188485401 0.037188485369
Thermal beta 0.032507877472 0.032507877450
Fast-alpha beta 0.004680607929 0.004680607919
Fusion power [MW] 1668.53036494 1668.53034847
Burn time [s] 8124.840326 8124.840368
Net electric [MW] 350.00000001 350.00000000
VMCON iterations 16 41

The physical and engineering design is virtually unchanged. The main difference is the optimisation trajectory: removing the redundant beta variable/equality increases the number of VMCON iterations for this case.

ST regression

The ST case also recovers effectively the same plasma optimum:

Quantity main revised
Iteration variables 14 13
Equality constraints 3 2
Q 16.5856075932 16.5856075936
Total beta 0.112828620935 0.112828620934
Fusion power [MW] 1983.58397383 1983.58397386
VMCON iterations 11 13

The plasma temperature, density, current and q95 are effectively equal..

The ST optimiser does settle on a different feasible engineering layout, including a change in net-electric output from approximately 106 MW to 170 MW.

This does not result from a change in the plasma optimum: the optimisation objective is Q.

This is not caused by a change in the plasma optimum: the optimisation objective is Q, which is effectively identical between the two runs. Removing the redundant beta optimisation degree of freedom changes the optimisation path and leads to a different feasible engineering point with the same plasma optimum.

OUT.DATs for inspection

beta_fix_low_aspect_ratio_DEMO.OUT.DAT.txt
icc1_beta_fix_low_aspect_ratio_DEMO.OUT.DAT.txt
beta_fix_st_regression.OUT.DAT.txt
icc1_beta_fix_st_regression.OUT.DAT.txt

@grmtrkngtn
grmtrkngtn requested a review from a team as a code owner October 1, 2026 15:30
@grmtrkngtn grmtrkngtn added the Convergence Solver or convergence-related problems label Oct 1, 2026
@codecov-commenter

codecov-commenter commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.98%. Comparing base (4885172) to head (8e6cb33).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
process/models/physics/physics.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4640      +/-   ##
==========================================
+ Coverage   49.92%   49.98%   +0.06%     
==========================================
  Files         151      151              
  Lines       30236    30451     +215     
==========================================
+ Hits        15094    15220     +126     
- Misses      15142    15231      +89     

☔ 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.

@CoronelBuendia

Copy link
Copy Markdown
Contributor

Hmm.. this only happens when beta is used to calculate things that relate to how beta is calculated.

As far as I am aware, this was only happening in the Saamuli pedestal temperature scaling $\beta = f(T_{e,ped} = g(\beta))$ that was used for EU-DEMO, hence the constraint/Picard iteration. But this pedestal model no longer exists in open-source PROCESS.

Where is the fixed point problem now for the open-source PROCESS LAR point? I just think it's really important to identify what these "circular loops" are.

More importantly, are you sure this is a complete closure of the plasma calculation chain, or are there other fixed point issues?

@timothy-nunn timothy-nunn self-assigned this Oct 2, 2026
@timothy-nunn
timothy-nunn requested a review from a team October 5, 2026 07:52
@timothy-nunn

Copy link
Copy Markdown
Collaborator

Going to invite comments from as many @ukaea/process-model-review on this one, thanks @CoronelBuendia for already commenting. @grmtrkngtn I will do a code review once modeller questions/concerns have been answered/addressed.

@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.

Does this PR not remove the need for the beta consistency equation? Why does this need to wait for another PR?

@grmtrkngtn

Copy link
Copy Markdown
Collaborator Author

Does this PR not remove the need for the beta consistency equation?

Yes, that is the primary motivation.

Why does this need to wait for another PR?

I'm not sure what you mean, it doesn't need another PR - it's independent of anything else.

@timothy-nunn

Copy link
Copy Markdown
Collaborator

I'm not sure what you mean, it doesn't need another PR - it's independent of anything else.

As in, why does this PR not remove the beta consistency equation from the code and input files?

2: IterationVariable("b_plasma_toroidal_on_axis", "physics", 0.010, 30.00),
3: IterationVariable("rmajor", "physics", 0.1, 50.00),
4: IterationVariable("temp_plasma_electron_vol_avg_kev", "physics", 5.0, 150.0),
5: IterationVariable("beta_total_vol_avg", "physics", 0.001, 1.0),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are we removing it as an iteration variable in this case? How would a user constraint the beta value then. We can still have this as an iteration but now without the constraint

@grmtrkngtn grmtrkngtn Oct 6, 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.

Now that beta is calculated directly from the plasma state, I don't think it makes sense for it to remain an iteration variable.

If a user wants to restrict beta, that should be done by applying a constraint to the derived beta rather than allowing the optimiser to vary beta independently of the plasma state. We already have beta upper and lower-limit constraints for this purpose.

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 would agree. Now that beta_total_vol_avg is calculated in the code (here) having it as an iteration variable would be incorrect at best and dangerous at worse.

The solver would set beta_total_vol_avg = x and then the code would update it to beta_total_vol_avg. = y and all of the gradients would be calculated wrt y but the solver would think they related to x, which would cause the solver to move in incorrect ways.

constraint_registration,
)


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.

Removing this breaks every previous PROCESS IN.DAT. If we want to progress with this change, could we have a grace period where both methods of determining beta are valid.

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.

I'm indifferent to this. Happy to allow both approaches although I'd argue it's better to rip the band-aid off in on go.

It is straight forward to modify any IN.DAT by removing icc = 1, ixc = 5 and reducing n_equality_constraints by 1.

@grmtrkngtn grmtrkngtn changed the title Implementation of beta fixed point solve, based on Jon M work. Derive plasma beta explicitly from the current plasma state Oct 6, 2026
@grmtrkngtn

grmtrkngtn commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator Author

Prompted by Matti's comment - I've made a significant change to the proposed solution in this PR although it achieves the same effect. Updated description.

@grmtrkngtn
grmtrkngtn requested a review from chris-ashe October 6, 2026 13:18

"""
# Thermal beta is derived directly from the current plasma state.
self.data.physics.beta_thermal_vol_avg = self.calculate_plasma_beta(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just wondering if we could do this all tidy and just put this in the run method of the beta class?

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.

Yes, I've tidied this up in the latest commits

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I cant see the thermal calc inside the beat run method its still showing as a random calc for me

@grmtrkngtn

Copy link
Copy Markdown
Collaborator Author

As in, why does this PR not remove the beta consistency equation from the code and input files?

I've added this into the latest version (as in removed beta consistency from code and inputs). Some may prefer a grace period although I think it's better to just remove it if it's not needed any more.

@CoronelBuendia

Copy link
Copy Markdown
Contributor

So at present, @grmtrkngtn, none of the regression tests actually have a fixed point issue in beta, meaning it is not possible to verify that removing beta as an iteration variable is successfully addressed by fixed point iteration (a.k.a. idempotence loop in PROCESS).

I don't actually doubt that this is the case. Just that in future (as we have had in the past e.g. for EU-DEMO with the Saamuli T_e_ped scaling) we may need beta as a variable in the calculation chain of beta; i.e. beta = f(beta). Note that this will (or already does happen with other variables). For example the Giacomin pedestal density is f(P_sol), so if this is calculated before P_sol, we would have P_sol = g(P_sol).

Again, this should be treated by the existing Picard iteration (idempotence loop), but if these variables ever grow in number (and I think it's fair to say it is not known how many exist at present, see e.g. #4638), it's possible Picard iteration will not cut it.

@grmtrkngtn

Copy link
Copy Markdown
Collaborator Author

After some discussion we have agreed to leave in icc = 1 tool for checking potential fpp issues which may arise in future. IXC = 5 will be removed.

...
```
The beta and plasma power balance equality constraints are recommended to ensure model consistency, and the `temp_plasma_electron_vol_avg_kev` and `nd_plasma_electrons_vol_avg` iteration variables used to solve them.
The plasma power balance equality constraint is recommended to ensure model consistency, and the `temp_plasma_electron_vol_avg_kev` and `nd_plasma_electrons_vol_avg` may be used as iteration variables used to solve them.

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.

Now that there is only one consistency equation enabled only one active iteration variable could be used

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.

Yes - I've changed this to tell the user to select one of these to solve. This should be a temporary change while we add the fuel-ion equilibrium into code to solve with temperature and density.

Comment thread process/data_structure/physics_variables.py Outdated

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.

This file needs an iteration variable removing since it now only has one consistency constraint

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.

I've removed density. This should be a temporary change pending #4639 which will give us two equations for which we can solve with te and ne.

)

# Total beta is derived from the thermal and fast-particle components.
self.data.physics.beta_total_vol_avg = (

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.

Now that beta_total_vol_avg is calculated we should also remove it as an input

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.

Yes, done - also removed from regression input files accordingly.

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.

Again will need an iteration variable removed because it now only has 2 consistency constraints

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.

I've removed density. This should be a temporary change pending #4639 which will give us two equations for which we can solve with te and ne.

Comment thread documentation/source/physics-models/plasma_beta/plasma_beta.md Outdated

"""
# Thermal beta is derived directly from the current plasma state.
self.data.physics.beta_thermal_vol_avg = self.calculate_plasma_beta(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I cant see the thermal calc inside the beat run method its still showing as a random calc for me

grmtrkngtn and others added 2 commits October 8, 2026 15:40
@grmtrkngtn
grmtrkngtn force-pushed the 4637-replace-the-iterative-idempotence-treatment-of-plasma-beta-with-an-explicit-fixed-point-calculation branch from ab551cb to 4508b31 Compare October 9, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Convergence Solver or convergence-related problems

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace the iterative idempotence treatment of plasma beta with an explicit fixed-point calculation

6 participants