Skip to content

files for reproduction#2026

Merged
unalmis merged 4 commits intoku/dynamicfrom
ku/bounce_paper
Apr 1, 2026
Merged

files for reproduction#2026
unalmis merged 4 commits intoku/dynamicfrom
ku/bounce_paper

Conversation

@unalmis
Copy link
Copy Markdown
Collaborator

@unalmis unalmis commented Nov 25, 2025

Adds files to reproduce the results in the article.

@unalmis unalmis requested a review from rahulgaur104 November 25, 2025 15:30
@unalmis unalmis requested review from a team, YigitElma, ddudt, dpanici and f0uriest and removed request for a team November 26, 2025 00:37
@unalmis unalmis force-pushed the ku/bounce_paper branch 2 times, most recently from c2fb6c8 to ca29113 Compare November 28, 2025 10:26
Copy link
Copy Markdown
Collaborator

@dpanici dpanici left a comment

Choose a reason for hiding this comment

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

Files all seem fine, but could you add a README.md to the subfolder that has some info on how to run/setup, even just adding one line saying something like the specific either DESC version, tag, or commit hash which was used to make the figs would be good.

@unalmis
Copy link
Copy Markdown
Collaborator Author

unalmis commented Dec 11, 2025

Files all seem fine, but could you add a README.md to the subfolder that has some info on how to run/setup, even just adding one line saying something like the specific either DESC version, tag, or commit hash which was used to make the figs would be good.

I can't do any of that until #1919 is merged to master. The commit hash will be the commit on master associated with the merge of #1919.

@YigitElma
Copy link
Copy Markdown
Collaborator

Files all seem fine, but could you add a README.md to the subfolder that has some info on how to run/setup, even just adding one line saying something like the specific either DESC version, tag, or commit hash which was used to make the figs would be good.

I can't do any of that until #1919 is merged to master. The commit hash will be the commit on master associated with the merge of #1919.

You can still create a tag for the commit you used for plots, and that tag will last forever (even if squashed). You should be able to do this

git tag -a unalmis2025 <commit-id> -m "DESC version that is used to produce results in Unalmis 2025 Paper"
git push --tags

unalmis2025 part is tag name, you can choose a name you like. The last part is a description, again change it as you like.

@unalmis unalmis changed the base branch from ku/bounce to ku/points December 16, 2025 23:03
Base automatically changed from ku/points to ku/bounce December 18, 2025 11:23
@unalmis unalmis changed the base branch from ku/bounce to ku/bounce_autodiff February 1, 2026 00:43
@unalmis unalmis closed this Feb 1, 2026
@unalmis unalmis reopened this Feb 1, 2026
Base automatically changed from ku/bounce_autodiff to ku/bounce February 4, 2026 04:45
@unalmis unalmis force-pushed the ku/bounce_paper branch 2 times, most recently from d2eebf4 to 8ef9e14 Compare February 16, 2026 19:05
@unalmis unalmis changed the base branch from ku/bounce to ku/dynamic March 31, 2026 06:53
@unalmis unalmis removed the request for review from YigitElma April 1, 2026 02:33
@unalmis unalmis merged commit 4576f02 into ku/dynamic Apr 1, 2026
4 of 5 checks passed
@unalmis unalmis deleted the ku/bounce_paper branch April 1, 2026 06:35
unalmis added a commit that referenced this pull request Apr 8, 2026
![PR
Age](https://img.shields.io/github/issues/detail/age/PlasmaControl/DESC/1919?label=Ready%20for%20merge)

## Inverse stream maps
- [x] Significantly improves convergence of inverse stream maps.
Resolves #1922 to my satisfaction.
- [x] Truncation rule to remove aliasing error at the shortest
wavelengths where the signal to noise ratio is lowest.
- [x] Resolves #1928 and increases default objective resolution for
`Y_B`.
- [x] Method to plot frequency spectrum of inverse stream map.

## Improvements
- [x] Check-pointing to increase speed and reduce memory consumption of
reverse mode differentiation #1347.
- [x] Adds ``low_ram`` mode which is same speed and less memory for
`objective.compute`, but slower for `objective.grad` since JAX is poor
at iterative algorithms.
- [x] Fully resolves #1864 by avoiding materialization of a large tensor
in memory. Previously, we had closed the issue by adding nuffts as a
workaround. The improvement here actually solves the JAX regression.
- [x] Reuses some computations in identifying bounce points to make more
efficient.
- [x] Increase cache hits, fusing, and reduce floating point error in
computing bounce points (very important for accurate integrals).
- [x] Transforms an improper field line integral to one on a compact
domain where the integrand is periodic to achieve faster convergence.
- [x] Improves performance complexity of `interp_to_argmin` for
`Bounce2D` from fourth order to spectral as required for Alpert
quadrature.
- [x] Resolves #1389.

## Usability
- [x] Updates plotting utilities to accept `kwargs` as was needed for my
article.
- [x] Method to compute integrals over plasma volume and velocity space
in batches is now added to the public API. People kept asking how to use
this private function and also used it for their work, so better to make
it public.
- [x] Method to make adding new bounce integral objectives simpler.
Private for developers only.
- [x] Unifies default parameter setup to resolve #1898 for bounce
integrals.
- [x] Resolves #1388.

## Bugs
- [x] Fixes bug in ``test_compute_everything``.
- [x] Fixes inverse stream map convergence.


## Benchmarks
Just go to #2026 and run `effective_ripple_profile.py`. You will see the
large performance improvement from `master`. The CI benchmarks do not
reveal this because those benchmarks are essentially just noise. Note
that, using the same parameter inputs, the resolution of this branch is
also higher than `master` due to the faster convergence.

- If you set `use_bounce1d=True` on that script, you will run out of
memory as expected since it is an inferior approach (as expected, you
get the OOM in the jacobian before you compute a single bounce
integral).
- If you set ``nufft_eps=0``, you need 175 GB to run that script on
`master` (you'll get an OOM and JAX will tell you it needs 175GB), but
only 34 GB on this branch.
- Using nuffts, the script requires only 6.5 GB on this branch. 

# Examples

## HELIOTRON

### `Master` branch
<img width="480" height="360" alt="test_theta_chebyshev_HELIOTRON"
src="https://github.com/user-attachments/assets/9ae1e6c5-983f-48a2-a805-b28fb1aec1e1"
/>

### This branch
<img width="480" height="360"
alt="test_delta_fourier_chebyshev_HELIOTRON"
src="https://github.com/user-attachments/assets/3773b5bb-6230-4362-8136-dd91543ac217"
/>

## W7-X

### `Master` branch
<img width="480" height="360" alt="test_theta_chebyshev_W7-X"
src="https://github.com/user-attachments/assets/f2ba109c-0c72-4efc-b432-ed2993ac0795"
/>

### This branch
<img width="480" height="360" alt="test_delta_fourier_chebyshev_W7-X"
src="https://github.com/user-attachments/assets/ef9a642a-7bbc-41b8-a615-7bde6849856d"
/>

### NCSX

### `Master` branch
<img width="480" height="360" alt="test_theta_chebyshev_NCSX"
src="https://github.com/user-attachments/assets/b3d4371d-0539-4c4b-a7a8-0e882258f2f7"
/>

### This branch
<img width="480" height="360" alt="test_delta_fourier_chebyshev_NCSX"
src="https://github.com/user-attachments/assets/5c92c2c2-22de-47d9-bfd7-f3fbed40bb43"
/>

## Removal of spectral aliasing

<img width="480" height="360" alt="Figure_1"
src="https://github.com/user-attachments/assets/c4e78659-b03d-41cb-8e0f-809066b67989"
/>

# Dynamic shapes

- [x] resolves #1303 .
- [x] Activates newton step to find bounce points.
- It can be shown there exists O(sqrt(epsilon)) error for bounce
integrals with 1/v_ll where epsilon is error of bounce point. For v_||
integrals error is conveniently O(epsilon times sqrt(epsilon)). Hence,
the `spline` method would require thousands of knots per transit for
just a couple digits of accuracy, and it would stop convergence at
epsilon<=1e-5 (so sqrt(epsilon) <=3 digits) error due to condition
number. Of course, the `spline=False` method has always computed the
points with spectral accuracy and has very fast convergence after #1919
; that method converges to epsilon = machine precision without the
newton step. With the newton step, fast convergence is achieved with the
spline method as well.
  - I suspect fast ion confinement optimization will be easier now.

## Benchmarks
Here is a timing benchmark on my CPU with `nufft_eps=1e-6`. Prior to
this PR, every adjoint call to nufft1 took `>= 1 second` and the full
computation was `34 seconds`. Now every adjoint call to nufft1 is `250
milliseconds`, and the full computation is `14 seconds`. These
`improvements become larger` as the `sparsity` grows and error tolerance
parameter for the nuffts epsilon tends to 0. Likewise, the _improvement_
grows linearly with the `problem size`. As this is called within an
optimization loop where time and memory are tight, the improvement is
significant.

### Before
<img width="510" height="135" alt="Screenshot From 2026-03-29 15-22-56"
src="https://github.com/user-attachments/assets/0baf9a88-b775-4a9c-bb39-db568099aae7"
/>
<img width="510" height="135" alt="Screenshot From 2026-03-29 15-22-36"
src="https://github.com/user-attachments/assets/2bc1f730-56af-43ad-9c5e-45e9991c0bd1"
/>

### After
<img width="510" height="135" alt="Screenshot From 2026-03-29 15-12-35"
src="https://github.com/user-attachments/assets/306a6c34-32a3-46e3-8b8c-c4f259a32169"
/>
<img width="510" height="135" alt="Screenshot From 2026-03-29 15-15-59"
src="https://github.com/user-attachments/assets/db12ecb3-210a-4732-a5fc-666ba47475d8"
/>
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.

4 participants