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

Fix definition of b0 in vmec output #1012

Merged
merged 1 commit into from
May 8, 2024
Merged

Fix definition of b0 in vmec output #1012

merged 1 commit into from
May 8, 2024

Conversation

f0uriest
Copy link
Member

@f0uriest f0uriest commented May 7, 2024

The quantity b0 output by VMEC is defined as $\langle R B \rangle / \langle R \rangle$ where $\langle ... \rangle$ is a flux surface average. We currently compute it as

DESC/desc/vmec.py

Lines 488 to 491 in 90d1ecb

b0 = file.createVariable("b0", np.float64)
b0.long_name = "average B_tor on axis"
b0.units = "T"
b0[:] = data_axis["G"][0] / data_axis["R"][0]

This is fine in axisymmetry, but for stellarators we're using the major radius at phi=0 rather than the average.

This PR changes it to use the equivalent definition, b0 = data_axis['<|B|>'] which avoids needing to deal with zero jacobians in the surface averages in the VMECIO part of things

Copy link

codecov bot commented May 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.94%. Comparing base (90d1ecb) to head (1675e12).
Report is 1542 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1012   +/-   ##
=======================================
  Coverage   94.94%   94.94%           
=======================================
  Files          87       87           
  Lines       21884    21884           
=======================================
  Hits        20777    20777           
  Misses       1107     1107           
Files with missing lines Coverage Δ
desc/vmec.py 92.21% <100.00%> (ø)

Copy link
Contributor

github-actions bot commented May 7, 2024

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +1.23 +/- 4.17     | +6.44e-03 +/- 2.18e-02 |  5.28e-01 +/- 2.0e-02  |  5.22e-01 +/- 8.4e-03  |
 test_build_transform_fft_midres         |     +0.56 +/- 1.93     | +3.35e-03 +/- 1.15e-02 |  5.99e-01 +/- 8.8e-03  |  5.96e-01 +/- 7.4e-03  |
 test_build_transform_fft_highres        |     -0.01 +/- 2.28     | -9.92e-05 +/- 2.26e-02 |  9.91e-01 +/- 1.8e-02  |  9.91e-01 +/- 1.4e-02  |
 test_equilibrium_init_lowres            |     +1.25 +/- 4.00     | +5.09e-02 +/- 1.63e-01 |  4.12e+00 +/- 1.3e-01  |  4.07e+00 +/- 1.0e-01  |
 test_equilibrium_init_medres            |     -0.40 +/- 2.69     | -1.84e-02 +/- 1.24e-01 |  4.61e+00 +/- 6.4e-02  |  4.63e+00 +/- 1.1e-01  |
 test_equilibrium_init_highres           |     +0.99 +/- 3.00     | +6.28e-02 +/- 1.89e-01 |  6.38e+00 +/- 1.7e-01  |  6.32e+00 +/- 8.3e-02  |
 test_objective_compile_dshape_current   |     -1.55 +/- 2.86     | -5.73e-02 +/- 1.05e-01 |  3.63e+00 +/- 7.7e-02  |  3.69e+00 +/- 7.2e-02  |
 test_objective_compile_atf              |     -1.21 +/- 4.22     | -8.65e-02 +/- 3.03e-01 |  7.08e+00 +/- 1.7e-01  |  7.17e+00 +/- 2.5e-01  |
 test_objective_compute_dshape_current   |     -0.26 +/- 2.72     | -1.01e-05 +/- 1.06e-04 |  3.90e-03 +/- 5.8e-05  |  3.91e-03 +/- 8.9e-05  |
 test_objective_compute_atf              |     -2.72 +/- 3.01     | -4.84e-04 +/- 5.35e-04 |  1.73e-02 +/- 3.8e-04  |  1.78e-02 +/- 3.8e-04  |
 test_objective_jac_dshape_current       |     -4.61 +/- 7.91     | -1.96e-03 +/- 3.36e-03 |  4.05e-02 +/- 2.0e-03  |  4.24e-02 +/- 2.7e-03  |
 test_objective_jac_atf                  |     -0.05 +/- 2.94     | -1.01e-03 +/- 5.57e-02 |  1.89e+00 +/- 4.7e-02  |  1.89e+00 +/- 3.0e-02  |
 test_perturb_1                          |     -2.60 +/- 3.44     | -3.07e-01 +/- 4.05e-01 |  1.15e+01 +/- 3.6e-01  |  1.18e+01 +/- 1.8e-01  |
 test_perturb_2                          |     +0.37 +/- 2.75     | +6.12e-02 +/- 4.51e-01 |  1.64e+01 +/- 4.2e-01  |  1.64e+01 +/- 1.7e-01  |
 test_proximal_jac_atf                   |     +1.81 +/- 1.40     | +1.27e-01 +/- 9.82e-02 |  7.15e+00 +/- 5.9e-02  |  7.02e+00 +/- 7.9e-02  |
 test_proximal_freeb_compute             |     +0.27 +/- 0.81     | +3.54e-04 +/- 1.04e-03 |  1.29e-01 +/- 6.0e-04  |  1.29e-01 +/- 8.5e-04  |
 test_proximal_freeb_jac                 |     -0.52 +/- 1.63     | -3.79e-02 +/- 1.19e-01 |  7.24e+00 +/- 9.4e-02  |  7.28e+00 +/- 7.3e-02  |

@dpanici dpanici merged commit 267d533 into master May 8, 2024
20 checks passed
@dpanici dpanici deleted the rc/b0 branch May 8, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants