Skip to content

Fix bug in Kinetic normalization when pressure is present, add warning for this case to profile setters#2046

Merged
YigitElma merged 31 commits intomasterfrom
dp/kinetic-normalization
Mar 2, 2026
Merged

Fix bug in Kinetic normalization when pressure is present, add warning for this case to profile setters#2046
YigitElma merged 31 commits intomasterfrom
dp/kinetic-normalization

Conversation

@dpanici
Copy link
Copy Markdown
Collaborator

@dpanici dpanici commented Dec 22, 2025

Resolved #1995

@dpanici dpanici requested review from a team, YigitElma, ddudt, f0uriest, rahulgaur104 and unalmis and removed request for a team December 22, 2025 21:05
@dpanici dpanici added the easy Short and simple to code or review label Dec 22, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 22, 2025

Memory benchmark result

|               Test Name                |      %Δ      |    Master (MB)     |      PR (MB)       |    Δ (MB)    |    Time PR (s)     |  Time Master (s)   |
| -------------------------------------- | ------------ | ------------------ | ------------------ | ------------ | ------------------ | ------------------ |
  test_objective_jac_w7x                 |    6.97 %    |     3.800e+03      |     4.065e+03      |    265.00    |       44.57        |       36.73        |
  test_proximal_jac_w7x_with_eq_update   |   -1.02 %    |     6.581e+03      |     6.514e+03      |    -67.02    |       164.83       |       160.88       |
  test_proximal_freeb_jac                |   -0.29 %    |     1.326e+04      |     1.322e+04      |    -37.93    |       88.74        |       84.40        |
  test_proximal_freeb_jac_blocked        |   -0.12 %    |     7.528e+03      |     7.519e+03      |    -9.16     |       78.10        |       72.35        |
  test_proximal_freeb_jac_batched        |    0.30 %    |     7.502e+03      |     7.525e+03      |    22.64     |       80.13        |       74.88        |
  test_proximal_jac_ripple               |   -1.15 %    |     3.567e+03      |     3.526e+03      |    -40.95    |       70.10        |       66.37        |
  test_proximal_jac_ripple_bounce1d      |   -1.24 %    |     3.628e+03      |     3.583e+03      |    -45.04    |       78.33        |       77.10        |
  test_eq_solve                          |   -0.54 %    |     1.993e+03      |     1.982e+03      |    -10.78    |       94.60        |       95.41        |

For the memory plots, go to the summary of Memory Benchmarks workflow and download the artifact.

Comment thread desc/equilibrium/equilibrium.py Outdated
Comment thread desc/equilibrium/equilibrium.py Outdated
Comment thread desc/objectives/normalization.py Outdated
Comment thread tests/test_equilibrium.py Outdated
@dpanici dpanici requested a review from f0uriest February 5, 2026 17:37
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.52%. Comparing base (b725c98) to head (2743ac2).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2046      +/-   ##
==========================================
+ Coverage   94.35%   94.52%   +0.17%     
==========================================
  Files         102      102              
  Lines       28676    28689      +13     
==========================================
+ Hits        27056    27119      +63     
+ Misses       1620     1570      -50     
Files with missing lines Coverage Δ
desc/equilibrium/equilibrium.py 96.12% <100.00%> (+0.28%) ⬆️
desc/objectives/normalization.py 96.55% <100.00%> (+0.39%) ⬆️

... and 9 files with indirect coverage changes

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

YigitElma
YigitElma previously approved these changes Feb 19, 2026
Comment thread desc/objectives/normalization.py Outdated
Comment on lines +49 to +55
has_kinetic = False
if (
thing.electron_density is not None
and thing.electron_temperature is not None
and thing.atomic_number is not None
and thing.ion_temperature is not None
):
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.

We should split this up like:

  • if thing has either temperature profile, add the temperature scaling
  • if thing has a density profile, add the density scaling
  • if thing has a pressure profile, add the pressure scaling

And have them all be independent of each other. It might not matter now, but in #2090 some but not all of the kinetic profiles can be None which would break this check.

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.

Have we decided that #2090 is the way we will be doing this? I mean right now, the profile behavior is not well-defined when there is a subset. It makes little sense for these to be independent. Even in that PR change, I think that there should still be some sort of warning, or you can make the warning specifically consider the case you mention (which I think is that ion density profile may exist but no Zeff or vice versa?)

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 think this is the most I can split up without making the logic more complex, let me know what you think

Comment thread desc/objectives/normalization.py
Comment thread desc/vmec_utils.py
Comment thread tests/test_bootstrap.py
Comment thread tests/test_objective_funs.py
@ddudt ddudt mentioned this pull request Feb 19, 2026
Comment thread desc/vmec_utils.py Outdated
@dpanici dpanici requested a review from ddudt February 20, 2026 21:10
@dpanici dpanici requested review from ddudt and removed request for ddudt February 24, 2026 18:11
YigitElma
YigitElma previously approved these changes Feb 24, 2026
@dpanici dpanici requested review from ddudt and removed request for ddudt March 2, 2026 19:06
ddudt
ddudt previously approved these changes Mar 2, 2026
@YigitElma YigitElma dismissed stale reviews from ddudt and themself via 2743ac2 March 2, 2026 20:45
@YigitElma YigitElma requested a review from ddudt March 2, 2026 20:45
@YigitElma
Copy link
Copy Markdown
Collaborator

@ddudt allowed me to use his previous approval for merge (which was staled due to CHANGELOG merge conflict)

@YigitElma YigitElma merged commit 32a8b23 into master Mar 2, 2026
26 of 27 checks passed
@YigitElma YigitElma deleted the dp/kinetic-normalization branch March 2, 2026 23:20
daniel-dudt added a commit that referenced this pull request Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

easy Short and simple to code or review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting kinetic profiles does not remove pressure profile, and this leads to errors

4 participants