Skip to content

Comments

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

Open
dpanici wants to merge 26 commits intomasterfrom
dp/kinetic-normalization
Open

Fix bug in Kinetic normalization when pressure is present, add warning for this case to profile setters#2046
dpanici wants to merge 26 commits intomasterfrom
dp/kinetic-normalization

Conversation

@dpanici
Copy link
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
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                 |    5.42 %    |     3.853e+03      |     4.062e+03      |    208.67    |       40.80        |       36.25        |
  test_proximal_jac_w7x_with_eq_update   |    0.29 %    |     6.619e+03      |     6.639e+03      |    19.17     |       165.64       |       165.94       |
  test_proximal_freeb_jac                |   -0.02 %    |     1.319e+04      |     1.318e+04      |    -2.14     |       86.35        |       85.66        |
  test_proximal_freeb_jac_blocked        |    0.09 %    |     7.463e+03      |     7.469e+03      |     6.48     |       73.81        |       74.41        |
  test_proximal_freeb_jac_batched        |   -0.07 %    |     7.459e+03      |     7.454e+03      |    -5.32     |       74.01        |       75.22        |
  test_proximal_jac_ripple               |    0.37 %    |     3.479e+03      |     3.491e+03      |    12.85     |       67.92        |       68.43        |
  test_proximal_jac_ripple_bounce1d      |   -2.35 %    |     3.644e+03      |     3.558e+03      |    -85.67    |       75.43        |       77.65        |
  test_eq_solve                          |    0.94 %    |     2.006e+03      |     2.025e+03      |    18.79     |       94.19        |       95.10        |

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

@dpanici dpanici requested a review from f0uriest February 5, 2026 17:37
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.53%. Comparing base (29c7877) to head (11475ba).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2046   +/-   ##
=======================================
  Coverage   94.52%   94.53%           
=======================================
  Files         102      102           
  Lines       28785    28798   +13     
=======================================
+ Hits        27210    27224   +14     
+ Misses       1575     1574    -1     
Files with missing lines Coverage Δ
desc/equilibrium/equilibrium.py 96.12% <100.00%> (+0.03%) ⬆️
desc/objectives/normalization.py 96.55% <100.00%> (+0.39%) ⬆️

... and 1 file with indirect coverage changes

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

f0uriest
f0uriest previously approved these changes Feb 17, 2026
YigitElma
YigitElma previously approved these changes Feb 18, 2026
"S" + str(file.dimensions["dim_00100"].size),
)
),
encoding="ascii",
Copy link
Collaborator

Choose a reason for hiding this comment

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

was this related to #2085 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yea I likely had accidentally added that here

@dpanici dpanici dismissed stale reviews from f0uriest and YigitElma via 6e58ec7 February 19, 2026 15:46
YigitElma
YigitElma previously approved these changes Feb 19, 2026
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
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
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
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 on lines +67 to +74
warnif(
has_kinetic,
UserWarning,
"Equilibrium has both kinetic and pressure profiles assigned to it."
" By default, the pressure profile will be used for the normalization "
"and the computation of pressure, which may lead to unexpected "
"results when kinetic profiles are also present.",
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this warning is a little unnecessary since a similar warning will have already been thrown when the equilibrium is initialized or the profiles were assigned.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it is necessary as it may be unclear which is used for normalization, like if you are using pressure and kinetic profiles but one is inconsistent with the other. I want to make it very clear what is happening in the case of both pressure and kinetic assigned

@ddudt ddudt mentioned this pull request Feb 19, 2026
@dpanici dpanici requested a review from ddudt February 20, 2026 21:10
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