DESC icon indicating copy to clipboard operation
DESC copied to clipboard

Update Toroidal Flux Objective for Finite Beta Equilibria

Open dpanici opened this issue 1 year ago • 8 comments

Removes the warnings when a finite beta equilibrium is passed into ToroidalFlux objective, and accounts for the plasma currents as well.

In relation to comment in #1158

With finite beta stage 2 optimization, no objective on toroidal flux or coil curents is needed for the coils to make the correct toroidal flux and field magnitude, assuming that normal field error is zero. With finite normal field error, the coils may not create the necessary fluxes or have the requisite net poloidal linking current for the given equilbrium.

dpanici avatar Aug 01 '24 01:08 dpanici

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +0.60 +/- 6.24     | +3.04e-03 +/- 3.18e-02 |  5.13e-01 +/- 3.1e-02  |  5.10e-01 +/- 8.1e-03  |
 test_build_transform_fft_midres         |     +0.47 +/- 0.95     | +2.78e-03 +/- 5.60e-03 |  5.93e-01 +/- 3.7e-03  |  5.90e-01 +/- 4.2e-03  |
 test_build_transform_fft_highres        |     +0.13 +/- 1.46     | +1.23e-03 +/- 1.43e-02 |  9.81e-01 +/- 1.3e-02  |  9.80e-01 +/- 6.0e-03  |
 test_equilibrium_init_lowres            |     +0.09 +/- 0.23     | +3.33e-03 +/- 8.62e-03 |  3.72e+00 +/- 7.1e-03  |  3.71e+00 +/- 4.9e-03  |
 test_equilibrium_init_medres            |     +0.16 +/- 0.47     | +6.31e-03 +/- 1.88e-02 |  4.03e+00 +/- 1.5e-02  |  4.02e+00 +/- 1.1e-02  |
 test_equilibrium_init_highres           |     +0.23 +/- 0.57     | +1.23e-02 +/- 3.07e-02 |  5.37e+00 +/- 2.3e-02  |  5.36e+00 +/- 2.1e-02  |
 test_objective_compile_dshape_current   |     +0.16 +/- 1.36     | +6.05e-03 +/- 5.15e-02 |  3.78e+00 +/- 4.4e-02  |  3.78e+00 +/- 2.7e-02  |
 test_objective_compile_atf              |     -0.13 +/- 2.07     | -9.86e-03 +/- 1.61e-01 |  7.77e+00 +/- 8.6e-02  |  7.78e+00 +/- 1.4e-01  |
 test_objective_compute_dshape_current   |     +0.31 +/- 1.86     | +1.06e-05 +/- 6.39e-05 |  3.45e-03 +/- 2.5e-05  |  3.44e-03 +/- 5.9e-05  |
 test_objective_compute_atf              |     -0.93 +/- 1.86     | -9.49e-05 +/- 1.90e-04 |  1.01e-02 +/- 8.9e-05  |  1.02e-02 +/- 1.7e-04  |
 test_objective_jac_dshape_current       |     -3.24 +/- 6.90     | -1.30e-03 +/- 2.78e-03 |  3.90e-02 +/- 2.7e-03  |  4.03e-02 +/- 7.9e-04  |
 test_objective_jac_atf                  |     -1.21 +/- 3.18     | -2.34e-02 +/- 6.14e-02 |  1.91e+00 +/- 4.2e-02  |  1.93e+00 +/- 4.5e-02  |
 test_perturb_1                          |     +0.11 +/- 0.74     | +1.27e-02 +/- 8.96e-02 |  1.21e+01 +/- 5.8e-02  |  1.21e+01 +/- 6.9e-02  |
 test_perturb_2                          |     +0.33 +/- 1.08     | +5.59e-02 +/- 1.83e-01 |  1.70e+01 +/- 1.7e-01  |  1.70e+01 +/- 6.6e-02  |
 test_proximal_jac_atf                   |     -0.25 +/- 0.81     | -2.05e-02 +/- 6.62e-02 |  8.16e+00 +/- 4.1e-02  |  8.18e+00 +/- 5.2e-02  |
 test_proximal_freeb_compute             |     +0.95 +/- 0.58     | +1.72e-03 +/- 1.06e-03 |  1.83e-01 +/- 7.9e-04  |  1.81e-01 +/- 7.0e-04  |
 test_proximal_freeb_jac                 |     -0.19 +/- 1.09     | -1.46e-02 +/- 8.17e-02 |  7.48e+00 +/- 5.6e-02  |  7.50e+00 +/- 5.9e-02  |
 test_solve_fixed_iter                   |     +0.11 +/- 61.10    | +5.57e-03 +/- 3.07e+00 |  5.03e+00 +/- 2.2e+00  |  5.03e+00 +/- 2.1e+00  |

github-actions[bot] avatar Aug 01 '24 02:08 github-actions[bot]

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 95.33%. Comparing base (301a894) to head (5adb036). :warning: Report is 4378 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1159      +/-   ##
==========================================
- Coverage   95.33%   95.33%   -0.01%     
==========================================
  Files          90       90              
  Lines       22700    22696       -4     
==========================================
- Hits        21641    21637       -4     
  Misses       1059     1059              
Files with missing lines Coverage Δ
desc/objectives/_coils.py 99.13% <ø> (-0.01%) :arrow_down:

... and 2 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Aug 01 '24 08:08 codecov[bot]

Actually, at finite plasma current I think we need to change the compute function to account for the contribution to the flux from the plasma field?

Ah I think you are right, I can add that.

dpanici avatar Aug 01 '24 17:08 dpanici

actually im now doubting myself. Can plasma current produce toroidal flux? i thought that wasn't possible (or maybe it just cant produce "enough" flux?)

f0uriest avatar Aug 01 '24 17:08 f0uriest

actually im now doubting myself. Can plasma current produce toroidal flux? i thought that wasn't possible (or maybe it just cant produce "enough" flux?)

Any poloidally circulating current in the plasma would produce a toroidal flux right? so I think you're right in that for finite beta this is something that should be taken into account for this objective.

I am imagining simplest case of a theta-pinch, the currents flow in the theta direction and the toroidal (Z-directed at least) flux enclosed by the bdry certainly has a contribution from those poloidal currents

dpanici avatar Aug 01 '24 18:08 dpanici

Actually the poloidal currents wouuld be the diamagnetic currents right? so if anything they would reduce the toroidal flux... this is something I have not thought about the subtleties of, nor have I seen it in any papers on finite beta coil stuff

dpanici avatar Aug 01 '24 18:08 dpanici

~~This is actually a a bit trickier to include this contribution since the singular integration stuff assumes you want quantities on the surface over theta and zeta, but in this objective we only need B at a single zeta plane...~~ I was wrong here, but A is still better to use IMO so I will implement that way

I think we should use the A computation instead from the eq as then at least we only do the wasteful calc once at the surface and then we can do the loop integral.

Not completely sure how to implement, need to think if A_fixed_bdry/2 needs to be added at the surface like with the B calc in virtual casing, and if so how to get the A equivalent of the fixed bdry B is not obvious to me

dpanici avatar Aug 01 '24 18:08 dpanici

@dpanici check Helander 2014 for this

dpanici avatar Aug 14 '24 19:08 dpanici