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

Dommaschk potentials implemented in JAX #483

Merged
merged 77 commits into from
Mar 14, 2024
Merged

Dommaschk potentials implemented in JAX #483

merged 77 commits into from
Mar 14, 2024

Conversation

dpanici
Copy link
Collaborator

@dpanici dpanici commented Apr 8, 2023

Following Dommaschk 1986 paper, implementing general Dommaschk potentials in JAX so can automatically differentiate to find the field

TODO:

  • Add tests for each function added
  • Add new MagneticField subclass DommaschkMagneticField which uses autodiff to grad(dommaschk_potential) to find the B field
  • replace CD_mk and CN_mk with the expressions in eqns 31 and 32 of the paper, so they are applicable for any m,k
  • Possibly verify against simsopt implementation - I don't think this is needed, I also verified thru field tracing that we reproduce Fig. 2 in the 1986 dommaschk paper.
  • jaxify for loops in dommaschk potential functions
  • other ways to speed up evaluation or fitting?
  • implement stellarator symmetry option for fitting ( makes $a_{ml}=d_{ml}=0$ for even $l$ and $b_{m,l}=c_{m,l}=0$ for odd $l$, so effectively reduced number of modes by 2, useful for fitting)
  • put magnetic_fields in its own directory and break out dommaschk utility functions?

Pushing off improving the fit logic to #928 , this PR has been good to go for a while now, might as well get it in.

@codecov
Copy link

codecov bot commented Apr 8, 2023

Codecov Report

Attention: Patch coverage is 99.71182% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 94.71%. Comparing base (ba62bb2) to head (5830208).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #483      +/-   ##
==========================================
- Coverage   94.96%   94.71%   -0.25%     
==========================================
  Files          83       86       +3     
  Lines       21012    21198     +186     
==========================================
+ Hits        19954    20078     +124     
- Misses       1058     1120      +62     
Files Coverage Δ
desc/compute/_surface.py 94.49% <ø> (ø)
desc/compute/data_index.py 95.55% <ø> (ø)
desc/magnetic_fields/__init__.py 100.00% <100.00%> (ø)
desc/magnetic_fields/_core.py 84.32% <100.00%> (ø)
desc/magnetic_fields/_dommaschk.py 100.00% <100.00%> (ø)
desc/objectives/_free_boundary.py 96.80% <ø> (ø)
desc/magnetic_fields/_current_potential.py 99.39% <99.39%> (ø)

dpanici and others added 26 commits April 9, 2023 14:05
…sure summations are only being used where they are valid
… This does make the fitting much slower though
f0uriest
f0uriest previously approved these changes Mar 7, 2024
f0uriest
f0uriest previously approved these changes Mar 11, 2024
@dpanici dpanici requested review from kianorr, YigitElma and rahulgaur104 and removed request for rahulgaur104, ddudt, kianorr and YigitElma March 12, 2024 14:30
ddudt
ddudt previously approved these changes Mar 12, 2024
Copy link
Collaborator

@ddudt ddudt left a comment

Choose a reason for hiding this comment

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

Approving, but check docstring formatting

desc/magnetic_fields/_dommaschk.py Outdated Show resolved Hide resolved
@dpanici dpanici dismissed stale reviews from ddudt and f0uriest via acfbebe March 12, 2024 19:51
@dpanici dpanici requested review from f0uriest and ddudt March 13, 2024 13:32
ddudt
ddudt previously approved these changes Mar 13, 2024
@f0uriest f0uriest merged commit a232c02 into master Mar 14, 2024
17 checks passed
@dpanici dpanici deleted the dp/dommaschk branch March 14, 2024 03:35
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