Skip to content

Add parameter to shift the max B theta to Omnigenity objective#2167

Draft
dpanici wants to merge 1 commit into
masterfrom
dp/omni-shift
Draft

Add parameter to shift the max B theta to Omnigenity objective#2167
dpanici wants to merge 1 commit into
masterfrom
dp/omni-shift

Conversation

@dpanici
Copy link
Copy Markdown
Collaborator

@dpanici dpanici commented Apr 16, 2026

Resolves #1143

@dpanici dpanici requested review from daniel-dudt and ddudt April 16, 2026 20:01
@github-actions
Copy link
Copy Markdown
Contributor

Memory benchmark result

|               Test Name                |      %Δ      |    Master (MB)     |      PR (MB)       |    Δ (MB)    |    Time PR (s)     |  Time Master (s)   |
| -------------------------------------- | ------------ | ------------------ | ------------------ | ------------ | ------------------ | ------------------ |
  test_objective_jac_w7x                 |   -1.14 %    |     4.052e+03      |     4.005e+03      |    -46.19    |       41.47        |       38.07        |
  test_proximal_jac_w7x_with_eq_update   |    0.94 %    |     6.517e+03      |     6.578e+03      |    61.13     |       158.10       |       159.47       |
  test_proximal_freeb_jac                |    0.61 %    |     1.337e+04      |     1.345e+04      |    81.61     |       88.15        |       86.25        |
  test_proximal_freeb_jac_blocked        |    0.61 %    |     7.720e+03      |     7.767e+03      |    47.04     |       76.61        |       76.10        |
  test_proximal_freeb_jac_batched        |    0.21 %    |     7.777e+03      |     7.793e+03      |    16.59     |       75.61        |       74.99        |
  test_proximal_jac_ripple               |   -0.91 %    |     3.614e+03      |     3.581e+03      |    -32.83    |       61.28        |       59.86        |
  test_proximal_jac_ripple_bounce1d      |    2.19 %    |     3.790e+03      |     3.873e+03      |    82.95     |       75.75        |       72.73        |
  test_eq_solve                          |   -0.65 %    |     2.228e+03      |     2.213e+03      |    -14.57    |       98.87        |       97.78        |

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.45%. Comparing base (03637dd) to head (0dca8a4).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2167   +/-   ##
=======================================
  Coverage   94.45%   94.45%           
=======================================
  Files         101      101           
  Lines       28604    28606    +2     
=======================================
+ Hits        27018    27020    +2     
  Misses       1586     1586           
Files with missing lines Coverage Δ
desc/objectives/_omnigenity.py 97.08% <100.00%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@ddudt ddudt left a comment

Choose a reason for hiding this comment

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

My preferred solution is to create equivalents of flip_theta and rotate_zeta for pyQSC & pyQIC. That would solve #1143 for @dpanici's use case and improve the functionality of those codes.

If we do use this solution, we need to also add a new parameter for shifting zeta_B in case B_max is not aligned with zeta_B=0 for OP equilibria.

computation time during optimization and only ``eq`` is allowed to change.
If False, the field is allowed to change during the optimization and its
associated data are re-computed at every iteration (Default).
B_max_theta_location : float, optional
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 don't like this name. Technically it isn't even the theta angle of B_max, since that will change as a function of the toroidal angle. I suggest B_max_theta_offset or something similar. Also you would need to add a similar option for the zeta offset.

(
jnp.zeros_like(theta_B),
theta_B,
theta_B + B_max_theta_location,
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 will only work for toroidal and helical omnigenity. There is also the similar issue for poloidal omnigenity (aka QI) where you want to shift the toroidal angle zeta_B

@dpanici
Copy link
Copy Markdown
Collaborator Author

dpanici commented Apr 17, 2026

Thanks for catching, I'll add a toroidal shift as well. Adding these here is easier than modifying both pyQSC and pyQIC, imo.

@YigitElma YigitElma marked this pull request as draft May 5, 2026 04:56
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.

Misaligned target and eq fields in omnigenity objective

2 participants