Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Effective ripple ε #1003

Open
wants to merge 213 commits into
base: master
Choose a base branch
from
Open

Effective ripple ε #1003

wants to merge 213 commits into from

Conversation

unalmis
Copy link
Collaborator

@unalmis unalmis commented Apr 21, 2024

Resolves #519 . Automatically differentiable

Copy link
Contributor

github-actions bot commented Apr 21, 2024

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_midres         |     -5.49 +/- 6.44     | -3.52e-02 +/- 4.13e-02 |  6.06e-01 +/- 3.6e-02  |  6.41e-01 +/- 2.1e-02  |
 test_build_transform_fft_highres        |     -1.56 +/- 3.08     | -1.60e-02 +/- 3.17e-02 |  1.02e+00 +/- 2.8e-02  |  1.03e+00 +/- 1.6e-02  |
 test_equilibrium_init_lowres            |     +7.36 +/- 3.24     | +2.80e-01 +/- 1.23e-01 |  4.09e+00 +/- 7.3e-02  |  3.81e+00 +/- 1.0e-01  |
 test_objective_compile_atf              |     +1.99 +/- 4.44     | +1.55e-01 +/- 3.46e-01 |  7.94e+00 +/- 2.9e-01  |  7.78e+00 +/- 1.8e-01  |
 test_objective_compute_atf              |     +3.03 +/- 3.54     | +3.16e-04 +/- 3.69e-04 |  1.08e-02 +/- 3.2e-04  |  1.04e-02 +/- 1.8e-04  |
 test_objective_jac_atf                  |     +0.24 +/- 3.53     | +4.54e-03 +/- 6.58e-02 |  1.87e+00 +/- 5.5e-02  |  1.86e+00 +/- 3.6e-02  |
-test_perturb_1                          |    +10.48 +/- 2.86     | +1.30e+00 +/- 3.56e-01 |  1.37e+01 +/- 3.0e-01  |  1.24e+01 +/- 2.0e-01  |
 test_proximal_jac_atf                   |     +0.96 +/- 1.39     | +7.82e-02 +/- 1.13e-01 |  8.21e+00 +/- 9.9e-02  |  8.13e+00 +/- 5.4e-02  |
 test_proximal_freeb_compute             |     +1.16 +/- 0.94     | +2.12e-03 +/- 1.72e-03 |  1.85e-01 +/- 8.3e-04  |  1.83e-01 +/- 1.5e-03  |
 test_build_transform_fft_lowres         |     +2.29 +/- 9.88     | +1.31e-02 +/- 5.64e-02 |  5.84e-01 +/- 5.6e-02  |  5.71e-01 +/- 8.3e-03  |
 test_equilibrium_init_medres            |     +0.68 +/- 5.16     | +2.92e-02 +/- 2.22e-01 |  4.33e+00 +/- 1.8e-01  |  4.30e+00 +/- 1.3e-01  |
 test_equilibrium_init_highres           |     +0.51 +/- 1.23     | +2.85e-02 +/- 6.85e-02 |  5.61e+00 +/- 5.6e-02  |  5.58e+00 +/- 4.0e-02  |
 test_objective_compile_dshape_current   |     +0.02 +/- 1.32     | +6.62e-04 +/- 5.09e-02 |  3.86e+00 +/- 2.9e-02  |  3.86e+00 +/- 4.1e-02  |
 test_objective_compute_dshape_current   |     +0.84 +/- 2.58     | +3.05e-05 +/- 9.33e-05 |  3.65e-03 +/- 6.0e-05  |  3.62e-03 +/- 7.2e-05  |
 test_objective_jac_dshape_current       |     -2.52 +/- 4.21     | -1.04e-03 +/- 1.73e-03 |  4.01e-02 +/- 1.2e-03  |  4.11e-02 +/- 1.2e-03  |
 test_perturb_2                          |     -0.61 +/- 3.67     | -1.10e-01 +/- 6.59e-01 |  1.78e+01 +/- 4.5e-01  |  1.80e+01 +/- 4.9e-01  |
 test_proximal_freeb_jac                 |     -0.76 +/- 1.38     | -5.64e-02 +/- 1.03e-01 |  7.40e+00 +/- 7.0e-02  |  7.46e+00 +/- 7.6e-02  |
 test_solve_fixed_iter                   |     +0.73 +/- 58.64    | +3.65e-02 +/- 2.95e+00 |  5.06e+00 +/- 2.1e+00  |  5.03e+00 +/- 2.1e+00  |

@unalmis unalmis changed the base branch from master to bounce April 21, 2024 17:06
@unalmis unalmis requested a review from dpanici April 24, 2024 01:43
desc/compute/utils.py Outdated Show resolved Hide resolved
desc/compute/_neoclassical.py Outdated Show resolved Hide resolved
desc/equilibrium/equilibrium.py Outdated Show resolved Hide resolved
desc/objectives/_neoclassical.py Show resolved Hide resolved
desc/objectives/_neoclassical.py Show resolved Hide resolved
desc/compute/_neoclassical.py Outdated Show resolved Hide resolved

neo_rho, neo_eps_32 = NeoIO.read("tests/inputs/neo_out.w7x")
np.testing.assert_allclose(
eps_32, np.interp(rho, neo_rho, neo_eps_32), rtol=0.16, atol=1e-5
Copy link
Member

Choose a reason for hiding this comment

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

do we expect 16% error? Does increasing resolution help much?

Copy link
Collaborator Author

@unalmis unalmis Sep 27, 2024

Choose a reason for hiding this comment

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

I've run some parameter scans and the difference persists; essentially like this

image

  1. I improved the bounce quadrature to have less clustering near edges after generating this plots, and at low resolution that has slightly increased the match near rho =1/2 (can see by plotting the neo stuff in this test).
  2. I haven't increased the Boozer resolution to generate the Neo plot. I've increased num_pitch for Neo, but my runs a few months ago would segfault on the cluster for some reason when I changed the other parameters for Neo

Copy link
Collaborator Author

@unalmis unalmis Sep 27, 2024

Choose a reason for hiding this comment

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

One thing I don't like about the quadrature is that we don't reuse all the samples of the integrand we get from doing quadratures with the smaller pitch_inv values. Ideally every bounce integral would be the sum of the bounce integrals of all the smaller wells inside it, recursively + the edges of the larger well. This is compatible with our c.o.v stuff for the more accurate quadratures, but would take some logic to figure out.

Copy link
Member

Choose a reason for hiding this comment

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

how well converged is DESC and NEO for this case? (does neo look the same if you decrease resolution?) Does desc chance if you increase any/all of the resolution parameters?

Copy link
Collaborator Author

@unalmis unalmis Sep 30, 2024

Choose a reason for hiding this comment

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

There's minor variation but DESC converges to that plot above. If I decrease DESC resolution then things differ more. I've been working on things related to #1119 instead hoping to shortcut the memory consumption of transforms rather than playing with neo or comparing to cases from Daniel's omnigenity paper.

Copy link
Member

Choose a reason for hiding this comment

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

ok, I think we should look at this a bit more before merging. It could be due to the boozer resolution being too low? or idk if NEO artifiically truncates the boozer spectrum, I know a lot of codes ignore B_mn < 1e-5 or something, so that might also be giving small differences (and might explain why NEO looks smoother).
Would also be good to test against WISTELL, we'll see what they say or we can find them at APS

Copy link
Collaborator Author

@unalmis unalmis Oct 7, 2024

Choose a reason for hiding this comment

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

@PlasmaControl/desc-dev
There's still some comments marked with todo that I haven't finished that will improve efficiency of #1119 , and I need to do other things right now, so pardon the poor plot. However, here are the results of computing effective ripple with the 2D pseduospectral methods. I have not yet run convergence scan, but this is the resolution that would achieve convergence with the 1d methods.

test2

Copy link
Member

Choose a reason for hiding this comment

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

that seems like a pretty significant improvement! is it just because bounce2d requires less memory so you can use higher resolution?

Copy link
Member

Choose a reason for hiding this comment

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

also, is the vmec eq used for neo made from vmec, or exported from desc? if its originally from vmec that might explain the difference near the axis

Copy link
Collaborator

Choose a reason for hiding this comment

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

it was desc-solved W7X converted to wout

tests/test_neoclassical.py Outdated Show resolved Hide resolved

def write(self):
"""Write neo input file."""
self.eq.solved = True # must set this for NEO to run correctly
Copy link
Member

Choose a reason for hiding this comment

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

i dont think this is needed anymore, we always say vmec succeeded

tests/test_objective_funs.py Outdated Show resolved Hide resolved
@dpanici
Copy link
Collaborator

dpanici commented Oct 2, 2024

Check against WISTELL

@dpanici
Copy link
Collaborator

dpanici commented Oct 2, 2024

https://github.com/landreman/vmec_equilibria/tree/master/W7-X/HighMirror
one more data pt, matt has a DKES run of epsilon effective apparently along with this vacuum W7X, I re-ran in DESC and ran eps eff, our min values match at least, this is not so useful without a DKES res scan as well though, just putting as I saw the data:
image
(also, the x coordinate from the dkes data is "r/a" acc. to the text file? not sure if that means rho but I assume it does?)

@unalmis
Copy link
Collaborator Author

unalmis commented Oct 2, 2024

Thank for this. How do these DESC plots change as the DESC equilibrium resolution varies? I'd expect accuracy in effective ripple etc. via a field line integration requires higher DESC equilibrium resolution than a typical objective. After all the integrals are over ripples, which will not appear if higher fourier harmonics are suppressed.

It i interesting that DESC converges with few toroidal transits

@f0uriest
Copy link
Member

f0uriest commented Oct 2, 2024

Note that DKES is generally not great for eps_eff. Since eps_eff is computed as a limit as collisionality goes to zero, and DKES has problems converging for low collisionality. It also usually comes with error bars?

@unalmis unalmis changed the title Effective ripple ε¹ᐧ⁵ Effective ripple ε Oct 3, 2024
@unalmis unalmis added the stable only merges and reviewer requested changes label Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stable only merges and reviewer requested changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add effective ripple
6 participants