DESC icon indicating copy to clipboard operation
DESC copied to clipboard

How to handle NAE O(rho) stellarator symmetry, but O(rho^2) asymmetric solutions with NAE constraints

Open dpanici opened this issue 2 years ago • 8 comments

When the NAE equilibrium is stellarator asymmetric bc of O(r^2) effects, the DESC equilibrium fit is also asymmetric. BUT, the NAE O(r) constraints are stellarator symmetric.

This leads to the first problem, which is that the constraints will be setting the stellarator asymmetric parts of the equilibrium's O(r) coefficients to roughly 0, which can cause some weirdness when solving

To allevaite the issue I thought to drop any NAE constraints whose target was below a threshold value (of like 1e-12 or so). However, this means when solving, the equilibrium's stellarator asymmetric coefficients are free to move as they wish, and this results in a completely different looking equilibrium than the NAE equilibrium (as expected I guess, since there is so much more freedom that we are not constraining).

dpanici avatar Mar 30 '23 00:03 dpanici

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Test this again @dpanici

dpanici avatar May 30 '23 16:05 dpanici

image iota is off near-axis, so the non-stell-sym O(r) constraints seem to be off somehow

dpanici avatar May 31 '23 02:05 dpanici

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     -5.15 +/- 6.60     | -6.81e-04 +/- 8.72e-04 |  1.25e-02 +/- 1.3e-04  |  1.32e-02 +/- 8.6e-04  |
 test_build_transform_fft_midres         |     -0.89 +/- 0.95     | -8.25e-04 +/- 8.84e-04 |  9.24e-02 +/- 6.3e-04  |  9.32e-02 +/- 6.2e-04  |
 test_build_transform_fft_highres        |     -0.77 +/- 0.93     | -3.60e-03 +/- 4.34e-03 |  4.63e-01 +/- 3.0e-03  |  4.66e-01 +/- 3.1e-03  |
 test_equilibrium_init_lowres            |     +0.37 +/- 4.35     | +2.98e-03 +/- 3.54e-02 |  8.17e-01 +/- 2.3e-02  |  8.14e-01 +/- 2.7e-02  |
 test_equilibrium_init_medres            |     +0.47 +/- 0.90     | +6.62e-03 +/- 1.28e-02 |  1.43e+00 +/- 8.0e-03  |  1.42e+00 +/- 1.0e-02  |
 test_equilibrium_init_highres           |     +0.29 +/- 0.74     | +1.23e-02 +/- 3.08e-02 |  4.20e+00 +/- 1.6e-02  |  4.19e+00 +/- 2.6e-02  |
 test_objective_compile_dshape_current   |     +0.50 +/- 7.72     | +2.19e-02 +/- 3.38e-01 |  4.40e+00 +/- 2.3e-01  |  4.37e+00 +/- 2.5e-01  |
 test_objective_compile_atf              |     +1.09 +/- 7.66     | +9.99e-02 +/- 7.04e-01 |  9.29e+00 +/- 5.9e-01  |  9.19e+00 +/- 3.9e-01  |
 test_objective_compute_dshape_current   |     +0.32 +/- 2.15     | +6.83e-06 +/- 4.53e-05 |  2.12e-03 +/- 2.6e-05  |  2.11e-03 +/- 3.7e-05  |
 test_objective_compute_atf              |     +2.20 +/- 0.97     | +1.63e-04 +/- 7.16e-05 |  7.56e-03 +/- 4.8e-05  |  7.39e-03 +/- 5.3e-05  |
 test_objective_jac_dshape_current       |     -0.70 +/- 14.82    | -3.28e-04 +/- 6.92e-03 |  4.63e-02 +/- 3.1e-03  |  4.67e-02 +/- 6.2e-03  |
 test_objective_jac_atf                  |     -6.02 +/- 5.26     | -1.40e-01 +/- 1.23e-01 |  2.19e+00 +/- 1.0e-01  |  2.33e+00 +/- 6.4e-02  |
 test_perturb_1                          |     -0.08 +/- 14.14    | -7.32e-03 +/- 1.22e+00 |  8.63e+00 +/- 8.7e-01  |  8.64e+00 +/- 8.5e-01  |
 test_perturb_2                          |     +4.12 +/- 4.27     | +6.03e-01 +/- 6.24e-01 |  1.52e+01 +/- 3.6e-01  |  1.46e+01 +/- 5.1e-01  |

github-actions[bot] avatar Dec 23 '23 04:12 github-actions[bot]

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +0.80 +/- 1.63     | +9.86e-05 +/- 2.01e-04 |  1.24e-02 +/- 1.5e-04  |  1.23e-02 +/- 1.3e-04  |
 test_build_transform_fft_midres         |     +0.36 +/- 1.33     | +3.29e-04 +/- 1.21e-03 |  9.14e-02 +/- 7.9e-04  |  9.11e-02 +/- 9.2e-04  |
 test_build_transform_fft_highres        |     -0.12 +/- 0.98     | -5.45e-04 +/- 4.47e-03 |  4.57e-01 +/- 3.8e-03  |  4.57e-01 +/- 2.3e-03  |
 test_equilibrium_init_lowres            |     -1.03 +/- 2.05     | -8.26e-03 +/- 1.65e-02 |  7.95e-01 +/- 8.7e-03  |  8.03e-01 +/- 1.4e-02  |
 test_equilibrium_init_medres            |     -2.28 +/- 1.49     | -3.29e-02 +/- 2.14e-02 |  1.41e+00 +/- 1.2e-02  |  1.44e+00 +/- 1.8e-02  |
 test_equilibrium_init_highres           |     -0.62 +/- 0.95     | -2.61e-02 +/- 3.98e-02 |  4.17e+00 +/- 2.1e-02  |  4.20e+00 +/- 3.4e-02  |
 test_objective_compile_dshape_current   |     -2.36 +/- 7.55     | -1.04e-01 +/- 3.33e-01 |  4.31e+00 +/- 2.3e-01  |  4.41e+00 +/- 2.4e-01  |
 test_objective_compile_atf              |     -0.62 +/- 6.88     | -5.71e-02 +/- 6.35e-01 |  9.18e+00 +/- 5.4e-01  |  9.23e+00 +/- 3.4e-01  |
 test_objective_compute_dshape_current   |     -4.13 +/- 3.81     | -9.13e-05 +/- 8.42e-05 |  2.12e-03 +/- 4.9e-05  |  2.21e-03 +/- 6.9e-05  |
 test_objective_compute_atf              |     -1.36 +/- 2.03     | -1.04e-04 +/- 1.55e-04 |  7.53e-03 +/- 6.0e-05  |  7.64e-03 +/- 1.4e-04  |
 test_objective_jac_dshape_current       |     -2.94 +/- 11.80    | -1.42e-03 +/- 5.71e-03 |  4.70e-02 +/- 2.4e-03  |  4.84e-02 +/- 5.2e-03  |
 test_objective_jac_atf                  |     -6.41 +/- 7.36     | -1.46e-01 +/- 1.68e-01 |  2.13e+00 +/- 1.4e-01  |  2.28e+00 +/- 9.6e-02  |
 test_perturb_1                          |     -0.16 +/- 13.36    | -1.37e-02 +/- 1.16e+00 |  8.67e+00 +/- 8.2e-01  |  8.68e+00 +/- 8.2e-01  |
 test_perturb_2                          |     +2.13 +/- 4.57     | +3.16e-01 +/- 6.77e-01 |  1.51e+01 +/- 6.3e-01  |  1.48e+01 +/- 2.6e-01  |

github-actions[bot] avatar Dec 23 '23 07:12 github-actions[bot]

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     -0.16 +/- 1.22     | -1.93e-05 +/- 1.53e-04 |  1.25e-02 +/- 1.0e-04  |  1.25e-02 +/- 1.1e-04  |
 test_build_transform_fft_midres         |     +0.11 +/- 0.95     | +9.94e-05 +/- 8.68e-04 |  9.11e-02 +/- 7.0e-04  |  9.10e-02 +/- 5.1e-04  |
 test_build_transform_fft_highres        |     +1.23 +/- 1.11     | +5.60e-03 +/- 5.07e-03 |  4.63e-01 +/- 3.3e-03  |  4.57e-01 +/- 3.8e-03  |
 test_equilibrium_init_lowres            |     +1.96 +/- 1.80     | +1.53e-02 +/- 1.41e-02 |  7.99e-01 +/- 1.4e-02  |  7.83e-01 +/- 3.3e-03  |
 test_equilibrium_init_medres            |     +0.56 +/- 1.63     | +7.96e-03 +/- 2.30e-02 |  1.42e+00 +/- 2.1e-02  |  1.41e+00 +/- 9.8e-03  |
 test_equilibrium_init_highres           |     +0.88 +/- 0.79     | +3.66e-02 +/- 3.27e-02 |  4.19e+00 +/- 2.5e-02  |  4.15e+00 +/- 2.1e-02  |
 test_objective_compile_dshape_current   |     +1.05 +/- 7.68     | +4.48e-02 +/- 3.29e-01 |  4.33e+00 +/- 2.5e-01  |  4.29e+00 +/- 2.2e-01  |
 test_objective_compile_atf              |     +0.63 +/- 8.38     | +5.69e-02 +/- 7.59e-01 |  9.11e+00 +/- 6.1e-01  |  9.05e+00 +/- 4.5e-01  |
 test_objective_compute_dshape_current   |     -0.84 +/- 2.01     | -1.77e-05 +/- 4.24e-05 |  2.10e-03 +/- 3.0e-05  |  2.11e-03 +/- 3.0e-05  |
 test_objective_compute_atf              |     -3.27 +/- 1.26     | -2.51e-04 +/- 9.66e-05 |  7.43e-03 +/- 7.7e-05  |  7.68e-03 +/- 5.9e-05  |
 test_objective_jac_dshape_current       |     -1.86 +/- 10.56    | -8.75e-04 +/- 4.97e-03 |  4.62e-02 +/- 3.1e-03  |  4.71e-02 +/- 3.9e-03  |
 test_objective_jac_atf                  |     +0.11 +/- 5.80     | +2.39e-03 +/- 1.30e-01 |  2.24e+00 +/- 5.9e-02  |  2.24e+00 +/- 1.2e-01  |
 test_perturb_1                          |     +0.04 +/- 14.25    | +3.50e-03 +/- 1.21e+00 |  8.52e+00 +/- 9.1e-01  |  8.52e+00 +/- 8.0e-01  |
 test_perturb_2                          |     +0.46 +/- 4.92     | +6.62e-02 +/- 7.11e-01 |  1.45e+01 +/- 5.8e-01  |  1.44e+01 +/- 4.2e-01  |

github-actions[bot] avatar Jan 02 '24 18:01 github-actions[bot]

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     -1.80 +/- 1.01     | -2.30e-04 +/- 1.29e-04 |  1.26e-02 +/- 7.5e-05  |  1.28e-02 +/- 1.1e-04  |
 test_build_transform_fft_midres         |     -0.63 +/- 1.62     | -5.86e-04 +/- 1.50e-03 |  9.20e-02 +/- 7.0e-04  |  9.26e-02 +/- 1.3e-03  |
+test_build_transform_fft_highres        |     -7.76 +/- 1.77     | -3.90e-02 +/- 8.87e-03 |  4.64e-01 +/- 3.0e-03  |  5.03e-01 +/- 8.4e-03  |
 test_equilibrium_init_lowres            |     -0.61 +/- 1.44     | -2.53e-03 +/- 6.00e-03 |  4.16e-01 +/- 3.3e-03  |  4.18e-01 +/- 5.0e-03  |
 test_equilibrium_init_medres            |     -0.25 +/- 2.13     | -1.91e-03 +/- 1.64e-02 |  7.65e-01 +/- 8.4e-03  |  7.67e-01 +/- 1.4e-02  |
 test_equilibrium_init_highres           |     -0.62 +/- 1.54     | -1.46e-02 +/- 3.62e-02 |  2.33e+00 +/- 1.8e-02  |  2.35e+00 +/- 3.1e-02  |
 test_objective_compile_dshape_current   |     +0.82 +/- 1.95     | +3.79e-02 +/- 8.99e-02 |  4.64e+00 +/- 2.9e-02  |  4.60e+00 +/- 8.5e-02  |
 test_objective_compile_atf              |     +0.63 +/- 2.95     | +5.78e-02 +/- 2.72e-01 |  9.29e+00 +/- 1.7e-01  |  9.24e+00 +/- 2.1e-01  |
 test_objective_compute_dshape_current   |     +0.06 +/- 1.64     | +3.93e-06 +/- 1.14e-04 |  6.94e-03 +/- 7.8e-05  |  6.94e-03 +/- 8.3e-05  |
 test_objective_compute_atf              |     -1.11 +/- 2.47     | -1.53e-04 +/- 3.41e-04 |  1.36e-02 +/- 2.4e-04  |  1.38e-02 +/- 2.4e-04  |
 test_objective_jac_dshape_current       |     +1.79 +/- 5.67     | +8.41e-04 +/- 2.67e-03 |  4.80e-02 +/- 1.6e-03  |  4.71e-02 +/- 2.2e-03  |
 test_objective_jac_atf                  |     -1.62 +/- 3.12     | -3.32e-02 +/- 6.38e-02 |  2.01e+00 +/- 4.4e-02  |  2.05e+00 +/- 4.6e-02  |
 test_perturb_1                          |     -2.05 +/- 4.65     | -2.83e-01 +/- 6.40e-01 |  1.35e+01 +/- 1.2e-01  |  1.38e+01 +/- 6.3e-01  |
+test_perturb_2                          |     -3.66 +/- 1.21     | -7.35e-01 +/- 2.42e-01 |  1.94e+01 +/- 2.2e-01  |  2.01e+01 +/- 1.1e-01  |
 test_proximal_jac_atf                   |     -0.46 +/- 1.72     | -3.17e-02 +/- 1.18e-01 |  6.85e+00 +/- 7.7e-02  |  6.89e+00 +/- 9.0e-02  |
 test_proximal_freeb_compute             |     -2.30 +/- 0.91     | -2.86e-03 +/- 1.14e-03 |  1.21e-01 +/- 7.2e-04  |  1.24e-01 +/- 8.8e-04  |
 test_proximal_freeb_jac                 |     +0.82 +/- 1.46     | +6.66e-02 +/- 1.18e-01 |  8.20e+00 +/- 1.0e-01  |  8.14e+00 +/- 6.3e-02  |

github-actions[bot] avatar Feb 22 '24 20:02 github-actions[bot]