Skip to content

Conversation

@dpanici
Copy link
Collaborator

@dpanici dpanici commented Dec 8, 2024

  • Adds objective for B measurements at points (outside the plasma, though this is not something I check for explicitly, it just does not make sense if plasma currents are present as the virtual casing principle will get the plasma contribution incorrect).

  • Currently not added in the public objective API, as we may want to think of having an overrarching "MagneticDiagnostic" objective that tries to minimize the re-computation of the magnetic field (think, concatenate all of the eval coords for both point B measurements for B probes, as well as the points along the curves for flux/mirnov and partial/full rogowski loops, to better take advantage of vectorization. I will think of a possible API for this

  • change print value to be more intuitive for this objective (show error in matching targets, not just the compute value)

@dpanici dpanici mentioned this pull request Dec 8, 2024
3 tasks
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2024

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_midres         |     +4.34 +/- 6.23     | +3.55e-02 +/- 5.09e-02 |  8.53e-01 +/- 2.8e-02  |  8.17e-01 +/- 4.3e-02  |
 test_build_transform_fft_highres        |     -0.76 +/- 2.65     | -8.22e-03 +/- 2.88e-02 |  1.08e+00 +/- 1.7e-02  |  1.09e+00 +/- 2.3e-02  |
 test_equilibrium_init_lowres            |     +0.84 +/- 3.24     | +4.86e-02 +/- 1.87e-01 |  5.83e+00 +/- 1.2e-01  |  5.78e+00 +/- 1.4e-01  |
 test_objective_compile_atf              |     -1.64 +/- 3.89     | -1.27e-01 +/- 3.00e-01 |  7.58e+00 +/- 2.4e-01  |  7.71e+00 +/- 1.8e-01  |
 test_objective_compute_atf              |     -3.39 +/- 12.79    | -7.79e-05 +/- 2.94e-04 |  2.22e-03 +/- 2.2e-04  |  2.30e-03 +/- 1.9e-04  |
 test_objective_jac_atf                  |     -0.49 +/- 3.16     | -8.76e-03 +/- 5.67e-02 |  1.79e+00 +/- 4.4e-02  |  1.79e+00 +/- 3.6e-02  |
 test_perturb_1                          |     +0.75 +/- 6.69     | +1.16e-01 +/- 1.03e+00 |  1.55e+01 +/- 7.8e-01  |  1.54e+01 +/- 6.8e-01  |
 test_proximal_jac_atf                   |     +0.04 +/- 1.52     | +2.21e-03 +/- 8.29e-02 |  5.47e+00 +/- 7.7e-02  |  5.47e+00 +/- 3.1e-02  |
 test_proximal_freeb_compute             |     -2.18 +/- 3.37     | -3.58e-03 +/- 5.53e-03 |  1.61e-01 +/- 3.5e-03  |  1.64e-01 +/- 4.3e-03  |
 test_solve_fixed_iter                   |     -5.71 +/- 3.70     | -1.70e+00 +/- 1.10e+00 |  2.81e+01 +/- 6.1e-01  |  2.98e+01 +/- 9.2e-01  |
 test_objective_compute_ripple           |     +1.30 +/- 3.69     | +2.70e-03 +/- 7.68e-03 |  2.11e-01 +/- 7.4e-03  |  2.08e-01 +/- 2.1e-03  |
 test_objective_grad_ripple              |     +1.90 +/- 4.04     | +1.71e-02 +/- 3.64e-02 |  9.18e-01 +/- 2.2e-02  |  9.01e-01 +/- 2.9e-02  |
 test_build_transform_fft_lowres         |     +4.04 +/- 3.06     | +2.96e-02 +/- 2.24e-02 |  7.62e-01 +/- 2.0e-02  |  7.32e-01 +/- 1.0e-02  |
 test_equilibrium_init_medres            |     +1.83 +/- 1.00     | +1.11e-01 +/- 6.08e-02 |  6.17e+00 +/- 5.0e-02  |  6.06e+00 +/- 3.5e-02  |
 test_equilibrium_init_highres           |     +3.40 +/- 3.21     | +2.32e-01 +/- 2.19e-01 |  7.05e+00 +/- 2.1e-01  |  6.82e+00 +/- 4.2e-02  |
 test_objective_compile_dshape_current   |     +7.18 +/- 8.80     | +2.88e-01 +/- 3.53e-01 |  4.29e+00 +/- 2.8e-01  |  4.01e+00 +/- 2.1e-01  |
 test_objective_compute_dshape_current   |     +1.11 +/- 14.92    | +7.98e-06 +/- 1.07e-04 |  7.24e-04 +/- 5.7e-05  |  7.16e-04 +/- 9.0e-05  |
 test_objective_jac_dshape_current       |     -0.41 +/- 15.32    | -1.08e-04 +/- 4.02e-03 |  2.61e-02 +/- 3.2e-03  |  2.62e-02 +/- 2.4e-03  |
 test_perturb_2                          |     +2.38 +/- 2.38     | +4.29e-01 +/- 4.29e-01 |  1.85e+01 +/- 3.9e-01  |  1.80e+01 +/- 1.8e-01  |
 test_proximal_jac_atf_with_eq_update    |     +0.35 +/- 1.04     | +4.65e-02 +/- 1.38e-01 |  1.33e+01 +/- 1.0e-01  |  1.32e+01 +/- 9.2e-02  |
 test_proximal_freeb_jac                 |     -0.30 +/- 2.88     | -1.48e-02 +/- 1.40e-01 |  4.86e+00 +/- 4.2e-02  |  4.87e+00 +/- 1.3e-01  |
 test_solve_fixed_iter_compiled          |     +1.12 +/- 1.29     | +8.78e-02 +/- 1.01e-01 |  7.95e+00 +/- 8.6e-02  |  7.86e+00 +/- 5.3e-02  |
 test_LinearConstraintProjection_build   |     -0.24 +/- 3.32     | -2.03e-02 +/- 2.77e-01 |  8.34e+00 +/- 2.4e-01  |  8.36e+00 +/- 1.4e-01  |
 test_objective_compute_ripple_bounce1d  |     -0.71 +/- 2.50     | -2.09e-03 +/- 7.37e-03 |  2.92e-01 +/- 4.8e-03  |  2.95e-01 +/- 5.6e-03  |
 test_objective_grad_ripple_bounce1d     |     -0.98 +/- 1.65     | -9.48e-03 +/- 1.59e-02 |  9.56e-01 +/- 1.2e-02  |  9.66e-01 +/- 1.1e-02  |

Github CI performance can be noisy. When evaluating the benchmarks, developers should take this into account.

@codecov
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

❌ Patch coverage is 99.05660% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.76%. Comparing base (1e844e4) to head (8482421).

Files with missing lines Patch % Lines
desc/objectives/_reconstruction.py 98.95% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1436      +/-   ##
==========================================
+ Coverage   95.75%   95.76%   +0.01%     
==========================================
  Files         102      103       +1     
  Lines       28344    28446     +102     
==========================================
+ Hits        27140    27241     +101     
- Misses       1204     1205       +1     
Files with missing lines Coverage Δ
desc/magnetic_fields/_current_potential.py 99.60% <100.00%> (+<0.01%) ⬆️
desc/objectives/__init__.py 100.00% <100.00%> (ø)
desc/objectives/objective_funs.py 94.83% <100.00%> (+0.02%) ⬆️
desc/objectives/_reconstruction.py 98.95% <98.95%> (ø)

... and 2 files with indirect coverage changes

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

@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2025

Memory benchmark result

|               Test Name                |      %Δ      |    Master (MB)     |      PR (MB)       |    Δ (MB)    |    Time PR (s)     |  Time Master (s)   |
| -------------------------------------- | ------------ | ------------------ | ------------------ | ------------ | ------------------ | ------------------ |
  test_objective_jac_w7x                 |    4.91 %    |     3.886e+03      |     4.076e+03      |    190.82    |       39.27        |       37.96        |
  test_proximal_jac_w7x_with_eq_update   |    0.68 %    |     6.490e+03      |     6.535e+03      |    44.25     |       165.45       |       165.53       |
  test_proximal_freeb_jac                |   -0.07 %    |     1.323e+04      |     1.322e+04      |    -9.64     |       85.06        |       84.66        |
  test_proximal_freeb_jac_blocked        |    0.09 %    |     7.542e+03      |     7.549e+03      |     6.82     |       74.42        |       74.12        |
  test_proximal_freeb_jac_batched        |    0.21 %    |     7.446e+03      |     7.462e+03      |    15.39     |       74.93        |       74.62        |
  test_proximal_jac_ripple               |    1.04 %    |     3.434e+03      |     3.469e+03      |    35.64     |       66.91        |       67.21        |
  test_proximal_jac_ripple_bounce1d      |   -0.98 %    |     3.539e+03      |     3.504e+03      |    -34.75    |       79.17        |       80.57        |
  test_eq_solve                          |    1.42 %    |     2.000e+03      |     2.029e+03      |    28.36     |       94.89        |       95.70        |

For the memory plots, go to the summary of Memory Benchmarks workflow and download the artifact.

@dpanici dpanici marked this pull request as ready for review May 30, 2025 14:09
@dpanici dpanici requested review from a team and YigitElma May 30, 2025 14:09
@dpanici dpanici added run_benchmarks Run timing benchmarks on this PR against current master branch skip_changelog No need to update changelog on this PR labels Jun 17, 2025
@dpanici dpanici requested review from a team and YigitElma June 17, 2025 22:09
@dpanici dpanici marked this pull request as draft June 18, 2025 20:29
@dpanici
Copy link
Collaborator Author

dpanici commented Jun 18, 2025

Draft until #1783 is thought through

@dpanici dpanici mentioned this pull request Sep 16, 2025
5 tasks
Copy link
Collaborator

@YigitElma YigitElma left a comment

Choose a reason for hiding this comment

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

Need to add the objective to docs

plasma currents. Must have endpoint=False and sym=False and be linearly
spaced in theta and zeta, with nodes only at rho=1.0
basis : {"rpz","xyz"}
the basis used for ``measurement_coords``, ``directions`` and ``target``,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
the basis used for ``measurement_coords``, ``directions`` and ``target``,
The basis used for ``measurement_coords``, ``directions`` and ``target``,

spaced in theta and zeta, with nodes only at rho=1.0
basis : {"rpz","xyz"}
the basis used for ``measurement_coords``, ``directions`` and ``target``,
assumed to be "rpz" by default. if "xyz", will convert the input arrays
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
assumed to be "rpz" by default. if "xyz", will convert the input arrays
assumed to be "rpz" by default. If "xyz", will convert the input arrays


"""

__doc__ = __doc__.rstrip() + collect_docs()
Copy link
Collaborator

Choose a reason for hiding this comment

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

You probably need to override the target

self._vacuum = vacuum
self._sheet_current = hasattr(eq.surface, "Phi_mn")
things = [eq]
self._field_fixed = field_fixed
Copy link
Collaborator

Choose a reason for hiding this comment

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

field_fixed and vacuum result in a trivial thing, right? Maybe throw a warning since objective value will never change for that combination

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can vacuum equilibrium have sheet current? I feel like if vacuum=True then eq don't need to be in the things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run_benchmarks Run timing benchmarks on this PR against current master branch skip_changelog No need to update changelog on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants