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

Replace instances of 4pi*1e-7 with scipy.constants.mu_0 #1513

Merged
merged 5 commits into from
Jan 16, 2025
Merged

Conversation

dpanici
Copy link
Collaborator

@dpanici dpanici commented Jan 9, 2025

No description provided.

@dpanici dpanici requested review from a team, rahulgaur104, f0uriest, ddudt, kianorr, sinaatalay, unalmis and YigitElma and removed request for a team January 9, 2025 03:34
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.69%. Comparing base (af31d5b) to head (5e90926).
Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
desc/integrals/singularities.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1513   +/-   ##
=======================================
  Coverage   95.69%   95.69%           
=======================================
  Files         101      101           
  Lines       25569    25569           
=======================================
  Hits        24467    24467           
  Misses       1102     1102           
Files with missing lines Coverage Δ
desc/coils.py 97.98% <100.00%> (ø)
desc/magnetic_fields/_core.py 96.40% <100.00%> (ø)
desc/nestor.py 98.49% <100.00%> (ø)
desc/integrals/singularities.py 91.28% <66.66%> (ø)

... and 2 files with indirect coverage changes

Copy link
Contributor

github-actions bot commented Jan 9, 2025

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +3.22 +/- 6.82     | +1.78e-02 +/- 3.78e-02 |  5.72e-01 +/- 3.1e-02  |  5.54e-01 +/- 2.1e-02  |
 test_equilibrium_init_medres            |     +1.14 +/- 3.05     | +5.03e-02 +/- 1.34e-01 |  4.45e+00 +/- 1.2e-01  |  4.40e+00 +/- 5.1e-02  |
 test_equilibrium_init_highres           |     +0.56 +/- 2.56     | +3.15e-02 +/- 1.45e-01 |  5.68e+00 +/- 1.2e-01  |  5.65e+00 +/- 8.7e-02  |
 test_objective_compile_dshape_current   |     +0.37 +/- 1.33     | +1.48e-02 +/- 5.36e-02 |  4.06e+00 +/- 4.2e-02  |  4.04e+00 +/- 3.3e-02  |
 test_objective_compute_dshape_current   |     +1.53 +/- 5.03     | +8.17e-05 +/- 2.69e-04 |  5.42e-03 +/- 2.1e-04  |  5.34e-03 +/- 1.7e-04  |
 test_objective_jac_dshape_current       |     +0.90 +/- 6.78     | +3.89e-04 +/- 2.93e-03 |  4.37e-02 +/- 2.3e-03  |  4.33e-02 +/- 1.8e-03  |
 test_perturb_2                          |     +1.68 +/- 1.73     | +3.40e-01 +/- 3.50e-01 |  2.06e+01 +/- 2.4e-01  |  2.03e+01 +/- 2.5e-01  |
 test_proximal_freeb_jac                 |     +0.23 +/- 1.12     | +1.71e-02 +/- 8.30e-02 |  7.45e+00 +/- 4.8e-02  |  7.43e+00 +/- 6.8e-02  |
 test_solve_fixed_iter                   |     +1.14 +/- 1.96     | +3.72e-01 +/- 6.41e-01 |  3.30e+01 +/- 3.9e-01  |  3.27e+01 +/- 5.1e-01  |
 test_LinearConstraintProjection_build   |     -0.01 +/- 2.51     | -8.17e-04 +/- 2.68e-01 |  1.07e+01 +/- 2.1e-01  |  1.07e+01 +/- 1.7e-01  |
 test_build_transform_fft_midres         |     +3.96 +/- 5.72     | +2.47e-02 +/- 3.57e-02 |  6.49e-01 +/- 3.0e-02  |  6.24e-01 +/- 1.9e-02  |
 test_build_transform_fft_highres        |     +0.76 +/- 3.29     | +7.60e-03 +/- 3.29e-02 |  1.01e+00 +/- 2.1e-02  |  1.00e+00 +/- 2.5e-02  |
 test_equilibrium_init_lowres            |     +4.34 +/- 4.30     | +1.75e-01 +/- 1.74e-01 |  4.22e+00 +/- 1.3e-01  |  4.04e+00 +/- 1.2e-01  |
 test_objective_compile_atf              |     -1.19 +/- 3.47     | -9.91e-02 +/- 2.90e-01 |  8.24e+00 +/- 2.3e-01  |  8.34e+00 +/- 1.8e-01  |
 test_objective_compute_atf              |     -0.08 +/- 5.21     | -1.47e-05 +/- 9.08e-04 |  1.74e-02 +/- 8.5e-04  |  1.74e-02 +/- 3.3e-04  |
 test_objective_jac_atf                  |     -0.27 +/- 2.91     | -5.32e-03 +/- 5.79e-02 |  1.98e+00 +/- 4.1e-02  |  1.99e+00 +/- 4.1e-02  |
 test_perturb_1                          |     -2.75 +/- 3.95     | -4.34e-01 +/- 6.22e-01 |  1.53e+01 +/- 5.1e-01  |  1.58e+01 +/- 3.5e-01  |
 test_proximal_jac_atf                   |     +0.19 +/- 1.45     | +1.59e-02 +/- 1.20e-01 |  8.31e+00 +/- 9.1e-02  |  8.29e+00 +/- 7.8e-02  |
 test_proximal_freeb_compute             |     +1.81 +/- 1.44     | +3.61e-03 +/- 2.87e-03 |  2.04e-01 +/- 2.2e-03  |  2.00e-01 +/- 1.8e-03  |
 test_solve_fixed_iter_compiled          |     -0.88 +/- 1.34     | -1.85e-01 +/- 2.82e-01 |  2.09e+01 +/- 1.9e-01  |  2.11e+01 +/- 2.1e-01  |

@YigitElma YigitElma added the skip_changelog No need to update changelog on this PR label Jan 9, 2025
rahulgaur104
rahulgaur104 previously approved these changes Jan 9, 2025
@@ -672,7 +673,7 @@ def _kernel_biot_savart(eval_data, source_data, diag=False):
r = r[:, None]
else:
r = r[:, :, None]
return 1e-7 * safediv(num, r**3)
return scipy.constants.mu_0 / 4 / jnp.pi * safediv(num, r**3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not import once at the top and use the same mu_0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I meant to remove the scipy.constants import and just use the scipy module. I'll do that now

@@ -68,7 +68,7 @@ def body(i, B):
B = B + jnp.where(den[:, None] == 0, 0, num / den[:, None])
return B

return 1e-7 * fori_loop(0, J.shape[0], body, B)
return scipy.constants.mu_0 / 4 / jnp.pi * fori_loop(0, J.shape[0], body, B)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does importing mu0 once affect jit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no, I just didn't think to change the imports for this file.

@dpanici dpanici requested review from a team and rahulgaur104 and removed request for a team January 15, 2025 20:11
@dpanici dpanici merged commit ccf72cb into master Jan 16, 2025
24 of 25 checks passed
@dpanici dpanici deleted the dp/mu0 branch January 16, 2025 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip_changelog No need to update changelog on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants