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

Particle Tracing #734

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

Particle Tracing #734

wants to merge 38 commits into from

Conversation

f0uriest
Copy link
Member

@f0uriest f0uriest commented Nov 3, 2023

Adds functionality for tracing particles in an arbitrary MagneticField, using either guiding center or full orbit equations.

dpanici and others added 18 commits August 3, 2023 17:28
…m netCDF4 but cannot only target that module)
…f it is not benign, Cython would raise a ValueError, not a RuntimeWarning), and add kwrgs to integrate function
…diffrax's part), undo accidental ml_dtypes change, add ignore for benign equinox warning
@f0uriest f0uriest marked this pull request as draft November 3, 2023 23:43
Copy link
Contributor

github-actions bot commented Nov 4, 2023

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     -6.87 +/- 5.59     | -1.39e-03 +/- 1.13e-03 |  1.89e-02 +/- 1.3e-04  |  2.03e-02 +/- 1.1e-03  |
 test_build_transform_fft_midres         |     -0.07 +/- 1.05     | -7.41e-05 +/- 1.17e-03 |  1.11e-01 +/- 5.0e-04  |  1.11e-01 +/- 1.1e-03  |
 test_build_transform_fft_highres        |     -0.23 +/- 1.35     | -1.16e-03 +/- 6.99e-03 |  5.15e-01 +/- 3.3e-03  |  5.16e-01 +/- 6.2e-03  |
 test_equilibrium_init_lowres            |     -1.72 +/- 2.08     | -1.47e-02 +/- 1.78e-02 |  8.44e-01 +/- 1.4e-02  |  8.59e-01 +/- 1.1e-02  |
 test_equilibrium_init_medres            |     -1.55 +/- 1.40     | -1.98e-02 +/- 1.78e-02 |  1.26e+00 +/- 9.8e-03  |  1.27e+00 +/- 1.5e-02  |
 test_equilibrium_init_highres           |     -0.21 +/- 0.83     | -6.46e-03 +/- 2.50e-02 |  3.02e+00 +/- 1.8e-02  |  3.02e+00 +/- 1.7e-02  |
 test_objective_compile_dshape_current   |     -1.98 +/- 6.82     | -1.07e-01 +/- 3.68e-01 |  5.29e+00 +/- 2.9e-01  |  5.39e+00 +/- 2.2e-01  |
 test_objective_compile_atf              |     -0.95 +/- 5.84     | -1.63e-01 +/- 1.00e+00 |  1.70e+01 +/- 7.2e-01  |  1.72e+01 +/- 7.0e-01  |
 test_objective_compute_dshape_current   |     -1.08 +/- 1.06     | -3.60e-05 +/- 3.53e-05 |  3.31e-03 +/- 2.6e-05  |  3.34e-03 +/- 2.4e-05  |
 test_objective_compute_atf              |     -2.37 +/- 0.94     | -2.64e-04 +/- 1.05e-04 |  1.09e-02 +/- 4.3e-05  |  1.12e-02 +/- 9.6e-05  |
 test_objective_jac_dshape_current       |     -2.31 +/- 6.58     | -3.29e-03 +/- 9.36e-03 |  1.39e-01 +/- 5.2e-03  |  1.42e-01 +/- 7.8e-03  |
 test_objective_jac_atf                  |     -8.23 +/- 5.80     | -7.19e-01 +/- 5.06e-01 |  8.02e+00 +/- 5.0e-01  |  8.74e+00 +/- 8.0e-02  |
 test_perturb_1                          |     -1.04 +/- 12.62    | -1.14e-01 +/- 1.38e+00 |  1.08e+01 +/- 9.2e-01  |  1.09e+01 +/- 1.0e+00  |
 test_perturb_2                          |     -1.59 +/- 5.14     | -3.01e-01 +/- 9.70e-01 |  1.86e+01 +/- 6.0e-01  |  1.89e+01 +/- 7.6e-01  |

Copy link
Contributor

github-actions bot commented Dec 5, 2023

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +1.25 +/- 1.62     | +1.56e-04 +/- 2.02e-04 |  1.26e-02 +/- 1.9e-04  |  1.25e-02 +/- 8.1e-05  |
 test_build_transform_fft_midres         |     -0.01 +/- 1.23     | -1.19e-05 +/- 1.13e-03 |  9.24e-02 +/- 7.0e-04  |  9.24e-02 +/- 9.0e-04  |
 test_build_transform_fft_highres        |     +1.21 +/- 0.72     | +5.62e-03 +/- 3.32e-03 |  4.69e-01 +/- 1.9e-03  |  4.63e-01 +/- 2.7e-03  |
 test_equilibrium_init_lowres            |     +2.70 +/- 1.62     | +2.13e-02 +/- 1.28e-02 |  8.12e-01 +/- 1.1e-02  |  7.91e-01 +/- 6.3e-03  |
 test_equilibrium_init_medres            |     +1.58 +/- 1.37     | +2.23e-02 +/- 1.94e-02 |  1.43e+00 +/- 1.5e-02  |  1.41e+00 +/- 1.3e-02  |
 test_equilibrium_init_highres           |     +0.61 +/- 1.32     | +2.54e-02 +/- 5.51e-02 |  4.21e+00 +/- 4.5e-02  |  4.18e+00 +/- 3.1e-02  |
 test_objective_compile_dshape_current   |     +1.16 +/- 9.78     | +4.73e-02 +/- 3.98e-01 |  4.12e+00 +/- 3.3e-01  |  4.07e+00 +/- 2.3e-01  |
 test_objective_compile_atf              |     -3.85 +/- 5.66     | -3.63e-01 +/- 5.34e-01 |  9.07e+00 +/- 3.2e-01  |  9.43e+00 +/- 4.3e-01  |
 test_objective_compute_dshape_current   |     -0.85 +/- 1.95     | -1.84e-05 +/- 4.25e-05 |  2.16e-03 +/- 2.7e-05  |  2.18e-03 +/- 3.3e-05  |
 test_objective_compute_atf              |     +1.72 +/- 1.21     | +1.30e-04 +/- 9.13e-05 |  7.70e-03 +/- 6.1e-05  |  7.57e-03 +/- 6.8e-05  |
 test_objective_jac_dshape_current       |     -3.41 +/- 12.79    | -1.61e-03 +/- 6.03e-03 |  4.55e-02 +/- 3.8e-03  |  4.71e-02 +/- 4.7e-03  |
 test_objective_jac_atf                  |     -3.18 +/- 6.69     | -7.55e-02 +/- 1.59e-01 |  2.30e+00 +/- 7.4e-02  |  2.37e+00 +/- 1.4e-01  |
 test_perturb_1                          |     -0.78 +/- 13.58    | -6.56e-02 +/- 1.14e+00 |  8.31e+00 +/- 7.7e-01  |  8.37e+00 +/- 8.4e-01  |
 test_perturb_2                          |     -5.08 +/- 5.34     | -7.50e-01 +/- 7.88e-01 |  1.40e+01 +/- 5.5e-01  |  1.48e+01 +/- 5.7e-01  |

Copy link

codecov bot commented Dec 5, 2023

Codecov Report

Attention: Patch coverage is 25.66372% with 84 lines in your changes missing coverage. Please review.

Project coverage is 95.11%. Comparing base (acc8e5a) to head (b2156d5).

Files with missing lines Patch % Lines
desc/magnetic_fields/_core.py 25.66% 84 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #734      +/-   ##
==========================================
- Coverage   95.44%   95.11%   -0.33%     
==========================================
  Files          95       95              
  Lines       23402    23503     +101     
==========================================
+ Hits        22336    22356      +20     
- Misses       1066     1147      +81     
Files with missing lines Coverage Δ
desc/magnetic_fields/_core.py 87.78% <25.66%> (-8.79%) ⬇️

... and 2 files with indirect coverage changes

Copy link
Contributor

github-actions bot commented Apr 16, 2024

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +0.00 +/- 3.04     | +2.27e-05 +/- 1.58e-02 |  5.19e-01 +/- 1.2e-02  |  5.19e-01 +/- 9.7e-03  |
 test_equilibrium_init_medres            |     +1.08 +/- 0.95     | +4.41e-02 +/- 3.87e-02 |  4.11e+00 +/- 2.7e-02  |  4.06e+00 +/- 2.7e-02  |
 test_equilibrium_init_highres           |     +0.67 +/- 0.84     | +3.65e-02 +/- 4.55e-02 |  5.45e+00 +/- 3.0e-02  |  5.42e+00 +/- 3.4e-02  |
 test_objective_compile_dshape_current   |     +0.62 +/- 1.14     | +2.36e-02 +/- 4.34e-02 |  3.84e+00 +/- 3.2e-02  |  3.81e+00 +/- 3.0e-02  |
 test_objective_compute_dshape_current   |     +0.35 +/- 1.93     | +1.21e-05 +/- 6.64e-05 |  3.46e-03 +/- 4.5e-05  |  3.45e-03 +/- 4.9e-05  |
 test_objective_jac_dshape_current       |     +1.39 +/- 4.45     | +5.64e-04 +/- 1.80e-03 |  4.10e-02 +/- 1.0e-03  |  4.04e-02 +/- 1.5e-03  |
 test_perturb_2                          |     +0.09 +/- 0.70     | +1.62e-02 +/- 1.20e-01 |  1.72e+01 +/- 7.0e-02  |  1.72e+01 +/- 9.8e-02  |
 test_proximal_freeb_jac                 |     -0.51 +/- 1.50     | -3.82e-02 +/- 1.13e-01 |  7.47e+00 +/- 9.4e-02  |  7.51e+00 +/- 6.3e-02  |
 test_solve_fixed_iter                   |     -1.37 +/- 59.79    | -7.04e-02 +/- 3.07e+00 |  5.06e+00 +/- 2.2e+00  |  5.13e+00 +/- 2.1e+00  |

@ddudt ddudt changed the title Rc/coil tracing Particle Tracing Apr 17, 2024
@YigitElma
Copy link
Collaborator

If you want to get rid of some PRs, I can take this one. It looks interesting and I am bored:D

@f0uriest
Copy link
Member Author

If you want to get rid of some PRs, I can take this one. It looks interesting and I am bored:D

Sure, main thing it needs is some tests, so probably just need to come up with some simple magnetic fields for which we know the trajectory analytically and make sure they agree. Some ideas:

  • Uniform B (using VerticalField) to test basic motion (guiding center should move in straight line, full orbit should be a helix)
  • B with gradient (MagneticFieldFromUser with B = B0*x or something, to test grad B drift
  • Purely toroidal field to test gradB and curvature drift

@rahulgaur104
Copy link
Collaborator

Do you have a symplectic orbit solver to compare with? I have one that I can add to the test.
It calculates the the exact particle position instead of just guiding center. We only have to run it once, gyroaverage and save the data.

@YigitElma YigitElma self-assigned this Sep 12, 2024
@f0uriest
Copy link
Member Author

Do you have a symplectic orbit solver to compare with? I have one that I can add to the test. It calculates the the exact particle position instead of just guiding center. We only have to run it once, gyroaverage and save the data.

Yeah I benchmarked against SIMPLE with rogerio, I'll try to dig up the data

@YigitElma YigitElma removed their assignment Nov 19, 2024
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.

5 participants