-
Notifications
You must be signed in to change notification settings - Fork 26
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
LinkingCurrent
objective
#1222
LinkingCurrent
objective
#1222
Conversation
| benchmark_name | dt(%) | dt(s) | t_new(s) | t_old(s) |
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
test_build_transform_fft_lowres | +4.34 +/- 5.58 | +2.39e-02 +/- 3.07e-02 | 5.75e-01 +/- 2.3e-02 | 5.51e-01 +/- 2.0e-02 |
test_equilibrium_init_medres | -1.56 +/- 6.66 | -7.21e-02 +/- 3.07e-01 | 4.54e+00 +/- 1.5e-01 | 4.61e+00 +/- 2.7e-01 |
test_equilibrium_init_highres | +0.53 +/- 2.86 | +3.13e-02 +/- 1.68e-01 | 5.92e+00 +/- 1.2e-01 | 5.89e+00 +/- 1.2e-01 |
test_objective_compile_dshape_current | +0.01 +/- 2.44 | +2.90e-04 +/- 1.01e-01 | 4.13e+00 +/- 9.0e-02 | 4.13e+00 +/- 4.6e-02 |
test_objective_compute_dshape_current | +2.30 +/- 6.92 | +1.24e-04 +/- 3.73e-04 | 5.51e-03 +/- 3.5e-04 | 5.38e-03 +/- 1.2e-04 |
test_objective_jac_dshape_current | +0.72 +/- 7.17 | +3.22e-04 +/- 3.20e-03 | 4.49e-02 +/- 2.0e-03 | 4.46e-02 +/- 2.5e-03 |
test_perturb_2 | -2.85 +/- 2.58 | -6.05e-01 +/- 5.47e-01 | 2.06e+01 +/- 4.7e-01 | 2.12e+01 +/- 2.8e-01 |
test_proximal_freeb_jac | -0.95 +/- 2.34 | -7.29e-02 +/- 1.79e-01 | 7.57e+00 +/- 1.1e-01 | 7.64e+00 +/- 1.4e-01 |
test_solve_fixed_iter | -2.25 +/- 2.46 | -7.96e-01 +/- 8.71e-01 | 3.46e+01 +/- 7.0e-01 | 3.54e+01 +/- 5.2e-01 |
test_LinearConstraintProjection_build | -1.22 +/- 3.60 | -1.35e-01 +/- 4.00e-01 | 1.10e+01 +/- 3.5e-01 | 1.11e+01 +/- 1.9e-01 |
test_build_transform_fft_midres | -2.52 +/- 4.89 | -1.66e-02 +/- 3.22e-02 | 6.42e-01 +/- 2.0e-02 | 6.58e-01 +/- 2.5e-02 |
test_build_transform_fft_highres | -2.57 +/- 2.63 | -2.66e-02 +/- 2.72e-02 | 1.01e+00 +/- 1.7e-02 | 1.03e+00 +/- 2.1e-02 |
test_equilibrium_init_lowres | -1.45 +/- 3.02 | -6.21e-02 +/- 1.29e-01 | 4.22e+00 +/- 9.2e-02 | 4.28e+00 +/- 9.0e-02 |
test_objective_compile_atf | -3.45 +/- 4.64 | -2.97e-01 +/- 4.00e-01 | 8.31e+00 +/- 3.0e-01 | 8.61e+00 +/- 2.6e-01 |
test_objective_compute_atf | -4.15 +/- 5.51 | -7.36e-04 +/- 9.78e-04 | 1.70e-02 +/- 9.0e-04 | 1.77e-02 +/- 3.9e-04 |
test_objective_jac_atf | -1.42 +/- 2.70 | -2.89e-02 +/- 5.49e-02 | 2.01e+00 +/- 3.9e-02 | 2.04e+00 +/- 3.8e-02 |
test_perturb_1 | -3.70 +/- 1.61 | -5.97e-01 +/- 2.60e-01 | 1.55e+01 +/- 1.6e-01 | 1.61e+01 +/- 2.0e-01 |
test_proximal_jac_atf | -0.78 +/- 1.06 | -6.57e-02 +/- 8.93e-02 | 8.34e+00 +/- 4.2e-02 | 8.40e+00 +/- 7.9e-02 |
test_proximal_freeb_compute | -2.01 +/- 1.42 | -4.15e-03 +/- 2.93e-03 | 2.02e-01 +/- 2.1e-03 | 2.07e-01 +/- 2.1e-03 |
test_solve_fixed_iter_compiled | -0.56 +/- 2.46 | -1.28e-01 +/- 5.62e-01 | 2.27e+01 +/- 3.8e-01 | 2.28e+01 +/- 4.2e-01 | |
do #1231 |
Any progress on this @daniel-dudt ? |
Use Linking number calc for linear objective for sum coil currents as well, to use as weights for sum |
I think an equivalent sort of objective to ensure that the coils are creating the necessary current, without needing the linking number calculation (though I'd still like that in sometime), is to directly calculate $\int_{o}^{2\pi/NFP} \mathbf{B}{coil} \cdot \mathbf{e}{\zeta} d\zeta - \int_{o}^{2\pi/NFP} \mathbf{B}{DESC} \cdot \mathbf{e}{\zeta} d\zeta$ which is the relation that Ampere's law tells us (the second term here is This being zero means the coils are consistent with Ampere's law and avoids needing to worry about the linking currents (though this is a bit more expensive, as it relies on biot-savart integration over the coils to get |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1222 +/- ##
==========================================
+ Coverage 95.60% 95.62% +0.02%
==========================================
Files 98 98
Lines 25300 25374 +74
==========================================
+ Hits 24188 24264 +76
+ Misses 1112 1110 -2
|
…to dd/linking_current
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't officially approve, but it looks good.
# linking number for coils with axis | ||
link = np.round(dummy_coilset._compute_linking_number())[0, 1:] | ||
|
||
self._constants = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be 1 line instead of 4
Returns | ||
------- | ||
f : array of floats | ||
Linking current error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
techincally just a single float but not a big deal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the name could be changed to LinkingCurrentConsistency
or something, or the docstring should make it clearer that target should be zero, and NOT the targeted linking current G
verbose=2, | ||
copy=True, | ||
) | ||
with warnings.catch_warnings(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we understand why this constraint is being flagged as "incompatible"? This is like the simplest possible linear constraint, so I'm worried if this doesn't work without warnings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error is like 1e-9 which is about what we'd expect given the currents are ~MA
Co-authored-by: Dario Panici <[email protected]>
This is a nonlinear form of the existing linear objective
FixSumCoilCurrent
. It ensures the total current through the coils matches the poloidal current of the equilibrium. This is necessary for single-stage optimization where the equilibrium and coils are changing simultaneously.