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

Allow QuadraticFlux etc. to take multiple MagneticField objects #1205

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

ddudt
Copy link
Collaborator

@ddudt ddudt commented Aug 19, 2024

Resolves #1164

This allows for optimization with multiple different types of magnetic fields in combination; for example, a MixedCoilSet, a FourierCurrentPotentialField, and a VerticalMagneticField. Objectives like QuadraticFlux need to know about the total magnetic field from all of these sources, and you could combine them all in a SumMagneticField to make that work. However, that then breaks the logic of objectives that expect a particular type of magnetic field, such as the coil objectives. Rather than editing the logic of all other objectives to work with a SumMagneticField, this PR edits the logic of QuadraticFlux to take a list of fields and internally combines them into a SumMagneticField to get the total field.

TODO:

  • QuadraticFlux
  • BoundaryError
  • other objectives that need the total magnetic field?
  • tests

@ddudt ddudt added objectives Adding or improving objective functions coil stuff relating to coils and coil optimization EZ-review labels Aug 19, 2024
@ddudt ddudt self-assigned this Aug 19, 2024
Copy link

codecov bot commented Aug 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.42%. Comparing base (b1900b3) to head (aaed44a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1205   +/-   ##
=======================================
  Coverage   95.42%   95.42%           
=======================================
  Files          89       89           
  Lines       22434    22434           
=======================================
+ Hits        21407    21408    +1     
+ Misses       1027     1026    -1     
Files Coverage Δ
desc/objectives/_coils.py 99.14% <100.00%> (ø)

... and 2 files with indirect coverage changes

Copy link
Contributor

github-actions bot commented Aug 20, 2024

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     -0.81 +/- 7.27     | -4.42e-03 +/- 3.97e-02 |  5.42e-01 +/- 3.6e-02  |  5.46e-01 +/- 1.7e-02  |
 test_build_transform_fft_midres         |     -2.60 +/- 3.37     | -1.65e-02 +/- 2.14e-02 |  6.17e-01 +/- 1.3e-02  |  6.34e-01 +/- 1.7e-02  |
 test_build_transform_fft_highres        |     -2.03 +/- 2.81     | -2.10e-02 +/- 2.91e-02 |  1.01e+00 +/- 2.3e-02  |  1.03e+00 +/- 1.8e-02  |
 test_equilibrium_init_lowres            |     -0.10 +/- 4.94     | -4.02e-03 +/- 1.98e-01 |  4.00e+00 +/- 1.3e-01  |  4.00e+00 +/- 1.5e-01  |
 test_equilibrium_init_medres            |     +0.14 +/- 1.46     | +6.34e-03 +/- 6.54e-02 |  4.49e+00 +/- 5.6e-02  |  4.49e+00 +/- 3.3e-02  |
 test_equilibrium_init_highres           |     -0.36 +/- 2.57     | -2.16e-02 +/- 1.52e-01 |  5.90e+00 +/- 1.3e-01  |  5.92e+00 +/- 7.2e-02  |
 test_objective_compile_dshape_current   |     +0.31 +/- 0.82     | +1.21e-02 +/- 3.23e-02 |  3.93e+00 +/- 2.7e-02  |  3.92e+00 +/- 1.7e-02  |
 test_objective_compile_atf              |     -0.15 +/- 1.09     | -1.20e-02 +/- 8.73e-02 |  8.02e+00 +/- 7.0e-02  |  8.03e+00 +/- 5.2e-02  |
 test_objective_compute_dshape_current   |     -0.93 +/- 2.50     | -3.32e-05 +/- 8.93e-05 |  3.53e-03 +/- 5.0e-05  |  3.56e-03 +/- 7.4e-05  |
 test_objective_compute_atf              |     -0.64 +/- 2.93     | -6.79e-05 +/- 3.11e-04 |  1.05e-02 +/- 2.4e-04  |  1.06e-02 +/- 2.0e-04  |
 test_objective_jac_dshape_current       |     +0.01 +/- 8.15     | +5.94e-06 +/- 3.37e-03 |  4.14e-02 +/- 2.6e-03  |  4.14e-02 +/- 2.2e-03  |
 test_objective_jac_atf                  |     +2.28 +/- 2.48     | +4.37e-02 +/- 4.74e-02 |  1.96e+00 +/- 1.4e-02  |  1.91e+00 +/- 4.5e-02  |
 test_perturb_1                          |     -0.48 +/- 1.83     | -6.22e-02 +/- 2.38e-01 |  1.29e+01 +/- 1.6e-01  |  1.30e+01 +/- 1.8e-01  |
 test_perturb_2                          |     -0.75 +/- 0.84     | -1.37e-01 +/- 1.52e-01 |  1.81e+01 +/- 1.4e-01  |  1.82e+01 +/- 7.0e-02  |
 test_proximal_jac_atf                   |     -0.33 +/- 1.06     | -2.76e-02 +/- 8.74e-02 |  8.23e+00 +/- 3.8e-02  |  8.26e+00 +/- 7.9e-02  |
 test_proximal_freeb_compute             |     -1.24 +/- 0.90     | -2.28e-03 +/- 1.65e-03 |  1.82e-01 +/- 9.0e-04  |  1.84e-01 +/- 1.4e-03  |
 test_proximal_freeb_jac                 |     +0.21 +/- 1.43     | +1.54e-02 +/- 1.08e-01 |  7.55e+00 +/- 7.3e-02  |  7.53e+00 +/- 8.0e-02  |
 test_solve_fixed_iter                   |     -1.11 +/- 60.18    | -5.71e-02 +/- 3.09e+00 |  5.08e+00 +/- 2.2e+00  |  5.13e+00 +/- 2.2e+00  |

@unalmis unalmis added easy Short and simple to code or review and removed EZ-review labels Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coil stuff relating to coils and coil optimization easy Short and simple to code or review objectives Adding or improving objective functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add external_field argument to QuadraticFlux and other normal field objectives
4 participants