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

Umbilic fourier bounce #1349

Draft
wants to merge 655 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
655 commits
Select commit Hold shift + click to select a range
5d93b3c
Merge branch 'master' into ku/fourier_bounce
unalmis Sep 18, 2024
e4f68b7
Update desc_from_clebsch function
unalmis Sep 18, 2024
fe60029
Merge branch 'master' into ku/fourier_bounce
unalmis Sep 18, 2024
454bf3b
Merge branch 'master' into ripple
unalmis Sep 18, 2024
9498ad4
Merge branch 'ripple' into Gamma_c
unalmis Sep 18, 2024
41f3727
Increase test_compute_everything tolerance
unalmis Sep 18, 2024
a1fad7e
Merge branch 'ku/stop_angle_mod' into ku/fourier_bounce
unalmis Sep 19, 2024
7113d3f
Debugging cusp
unalmis Sep 19, 2024
0b14c20
document something that should be testd more
unalmis Sep 19, 2024
6c14202
Note that more poloidal resolution is needed
unalmis Sep 19, 2024
6e3b0e7
Merge branch 'master' into ripple
unalmis Sep 19, 2024
be0aa6b
Merge branch 'master' into ku/fourier_bounce
unalmis Sep 19, 2024
e2b58c7
Removing period argument
unalmis Sep 19, 2024
7894b41
Merge branch 'ripple' into Gamma_c
unalmis Sep 19, 2024
c348378
fix test
unalmis Sep 19, 2024
258dad0
-----
unalmis Sep 19, 2024
9acc900
Use infinite period for alpha
unalmis Sep 19, 2024
22df224
Document solution to discontinuity
unalmis Sep 19, 2024
2781681
Fix comment
unalmis Sep 19, 2024
44ef80f
adding another objective to make umbilic curve field aligned
rahulgaur104 Sep 20, 2024
41d440a
Remove unnecessary interpolation:
unalmis Sep 21, 2024
e31b602
Use better quadrature for part of integral in Nemov Gamma_c
unalmis Sep 21, 2024
a574827
Add quad2 kwargs for weak singular integrals
unalmis Sep 21, 2024
a5c87a4
Doing stuff marked todo
unalmis Sep 21, 2024
4eb6db2
testing
unalmis Sep 21, 2024
87dc90d
Improving API to avoid redundant computation
unalmis Sep 22, 2024
df0590b
Merge branch 'ku/fourier_bounce_part1' into ripple
unalmis Sep 22, 2024
4756c38
Merge branch 'ku/fourier_bounce_part1' into ripple
unalmis Sep 22, 2024
2073547
Avoid redundant computation of bounce points
unalmis Sep 22, 2024
142c13c
Merge branch 'ku/fourier_bounce_part1' into ku/fourier_bounce
unalmis Sep 22, 2024
cff5494
Merge branch 'ripple' into Gamma_c
unalmis Sep 22, 2024
503f0d6
Avoid redundant computation of bounce points
unalmis Sep 22, 2024
e5d150c
Merge branch 'ku/fourier_bounce_part1' into ripple
unalmis Sep 22, 2024
1edd349
Complete @f0uriest 's request to compare against Neo
unalmis Sep 22, 2024
850001a
Add neo out file to desc repository
unalmis Sep 22, 2024
0ae5c9a
Do remaining review suggestion
unalmis Sep 22, 2024
362f198
Merge branch 'ripple' into Gamma_c
unalmis Sep 22, 2024
1d5a84d
Merge branch 'ku/fourier_bounce_part1' into ku/fourier_bounce
unalmis Sep 22, 2024
8cb2a28
Fix linear interpolation for bad neo values
unalmis Sep 22, 2024
48d92fb
Merge branch 'ripple' into Gamma_c
unalmis Sep 22, 2024
21235b4
Fix neo script
unalmis Sep 22, 2024
3714827
Merge branch 'ripple' into Gamma_c
unalmis Sep 22, 2024
7977695
Document choice for quadrature
unalmis Sep 22, 2024
fe3d7b4
Merge branch 'ku/fourier_bounce_part1' into ku/fourier_bounce
unalmis Sep 22, 2024
098db02
Merge branch 'ku/fourier_bounce_part1' into ripple
unalmis Sep 22, 2024
1739b3e
Merge branch 'ripple' into Gamma_c
unalmis Sep 22, 2024
53ca834
More documentation
unalmis Sep 22, 2024
9dac89e
Document that Velasco's expression converges to zero
unalmis Sep 24, 2024
679697f
Document multivaluedness bug and how to fix. likely will be done in n…
unalmis Sep 24, 2024
dfb3eee
Merge branch 'ku/fourier_bounce_part1' into ku/fourier_bounce
unalmis Sep 24, 2024
eb3370b
Merge branch 'ku/fourier_bounce_part1' into ripple
unalmis Sep 24, 2024
56a88a8
Update _write_neo
unalmis Sep 24, 2024
5a8e861
Merge branch 'ripple' into Gamma_c
unalmis Sep 24, 2024
7268ad8
Update after merging
unalmis Sep 24, 2024
9e88270
Merge branch 'master' into ripple
unalmis Sep 24, 2024
8840c9c
Review suggestions
unalmis Sep 24, 2024
b270de8
Merge branch 'master' into ku/fourier_bounce
unalmis Sep 24, 2024
38e71e9
Marking test xfail
unalmis Sep 25, 2024
05cb195
Adding more tests and documentation
unalmis Sep 25, 2024
2dffde2
Add epsilon 3/2 and effective ripple as distinct
unalmis Sep 25, 2024
b58a1bd
Merge branch 'ripple' into Gamma_c
unalmis Sep 25, 2024
73a6b48
Increase entropy of test compute everything to pass test
unalmis Sep 26, 2024
5b668ee
Merge branch 'ripple' into Gamma_c
unalmis Sep 26, 2024
6c1cd12
Fix DESC docs variable name
unalmis Sep 26, 2024
5b4456d
Merge branch 'master' into ripple
unalmis Sep 26, 2024
eef81f6
Merge branch 'ripple' into Gamma_c
unalmis Sep 26, 2024
7d88eac
Simplify latex label
unalmis Sep 26, 2024
c819e32
Merge branch 'master' into ripple
unalmis Sep 26, 2024
157e57b
Add chunk size option
unalmis Sep 26, 2024
507a30c
Merge branch 'ripple' into Gamma_c
unalmis Sep 26, 2024
021b28a
Add chunk_size option
unalmis Sep 26, 2024
ff2d204
Merge branch 'master' into ku/fourier_bounce
unalmis Sep 26, 2024
134d826
short-circuit convergence of poloidal Fourier series
unalmis Sep 26, 2024
455353f
Remove resolved comment
unalmis Sep 26, 2024
f63f3b3
Stitch theta as well for robustness
unalmis Sep 26, 2024
883b34d
Merge branch 'master' into ripple
unalmis Sep 27, 2024
1a62674
Merge branch 'ripple' into Gamma_c
unalmis Sep 27, 2024
19e6bd1
Merge branch 'master' into ku/fourier_bounce
unalmis Sep 27, 2024
1b3b6f2
Fix name in test
unalmis Sep 27, 2024
3f465d6
Merge branch 'ripple' into Gamma_c
unalmis Sep 27, 2024
b1de0d6
Solved the convergence issue
unalmis Sep 27, 2024
e028106
support vector valued to simplify multivalued function reconstruction
unalmis Sep 27, 2024
a2a3d71
Merge branch 'master' into ripple
rahulgaur104 Sep 27, 2024
2ce57ee
Fix comment
unalmis Sep 27, 2024
384670d
manually merging ripple into rg/NFP_fac
rahulgaur104 Sep 28, 2024
32fcdb2
Merge branch 'master' into ku/fourier_bounce
unalmis Sep 29, 2024
7b1267a
Add explanation of math in c
unalmis Sep 29, 2024
47988d1
small but important typo in comment
unalmis Sep 29, 2024
3e4c0ab
Review requests and refactor to avoid explicit broadcast
unalmis Sep 29, 2024
157359d
Merge branch 'ripple' into Gamma_c
unalmis Sep 29, 2024
998c830
Clean up
unalmis Sep 29, 2024
53ea40b
Merge branch 'ripple' into Gamma_c
unalmis Sep 29, 2024
779f57c
Make sure API is compatible for Gamma_d etc.
unalmis Sep 29, 2024
954b9ec
address my review comment
unalmis Sep 29, 2024
bc5f6d3
Resolve todo comment out smoothness
unalmis Sep 29, 2024
499a6c7
Move changes from downstream branch here
unalmis Sep 30, 2024
5b8ccb7
Merge branch 'ripple' into Gamma_c
unalmis Sep 30, 2024
71b42bd
Merge branch 'master' into ripple
unalmis Sep 30, 2024
f6aee2c
Merge branch 'ripple' into Gamma_c
unalmis Sep 30, 2024
e5127e0
Merge remote-tracking branch 'refs/remotes/origin/Gamma_c' into Gamma_c
unalmis Sep 30, 2024
f78d7bd
Merge branch 'master' into ku/fourier_bounce
unalmis Sep 30, 2024
ea227a1
Genealize to NFP!=1
unalmis Oct 2, 2024
18af538
Merge branch 'master' into ku/fourier_bounce
unalmis Oct 2, 2024
89762c7
Add NFP to get_rtz_grid
unalmis Oct 2, 2024
c3e465b
More NFP fixes
unalmis Oct 2, 2024
3871353
Got things working now
unalmis Oct 3, 2024
a5cf4bc
Merge branch 'master' into ku/fourier_bounce
unalmis Oct 3, 2024
21c2e6b
fix method name in gammaC compute call
dpanici Oct 3, 2024
60fc00f
Change NFP mismatch error back to warning
unalmis Oct 3, 2024
c5d6a99
Merge branch 'Gamma_c' into ku/fourier_bounce_neo
unalmis Oct 3, 2024
b1a5c81
write eps_eff compute function with bounce2d
unalmis Oct 3, 2024
e5bfd38
Merge branch 'master' into ripple
rahulgaur104 Oct 4, 2024
08b54af
Merge branch 'master' into ku/fourier_bounce
unalmis Oct 6, 2024
56dcbb2
Split compute quantities into periodic and secular terms
unalmis Oct 6, 2024
a81014d
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 6, 2024
30d511e
Add ability to compute length along field line with fft
unalmis Oct 6, 2024
29d24f5
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 6, 2024
6870bcd
Make sure returned shape doesn't have extra dimension
unalmis Oct 6, 2024
eb448e9
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 6, 2024
15875d9
Debugging JAX issues
unalmis Oct 6, 2024
5e72593
PUlling changes from downstream branch
unalmis Oct 6, 2024
5eb11eb
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 6, 2024
ce64c53
Add missing key to stability fun test
unalmis Oct 6, 2024
7c88211
Document algorithm choices
unalmis Oct 6, 2024
22500b2
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 6, 2024
1376e90
Update incorrect comment
unalmis Oct 6, 2024
70a3a9e
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 7, 2024
d54a809
document better root finding method for later
unalmis Oct 7, 2024
8cef6d3
update ballooning notebook by explicitly comping gbdrift
unalmis Oct 7, 2024
0e07215
resolving jit error
unalmis Oct 7, 2024
dc82cfa
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 7, 2024
d20ee87
Merge commit '70a3a9e' into ku/fourier_bounce_neo
unalmis Oct 7, 2024
47962de
Merge branch 'master' into ku/fourier_bounce
YigitElma Oct 12, 2024
4d3e49e
Document that almost-equispaced Kosloff/Tal-Ezer arcsin map gives wor…
unalmis Oct 14, 2024
1466bfb
manually merging ripple into rg/NFP_fac
rahulgaur104 Oct 16, 2024
3495a0d
Adding 2D plots, more quadrature tests, checking 2D PEST convergence
unalmis Oct 17, 2024
dcb7c17
Merge branch 'master' into ku/fourier_bounce
unalmis Oct 17, 2024
9ca889d
Doing review suggestions
unalmis Oct 17, 2024
aedb90f
Fix failing axis limit test
unalmis Oct 17, 2024
ae939e9
Merge branch 'master' into ripple
unalmis Oct 17, 2024
e13bdaf
Merge branch 'ripple' into Gamma_c
unalmis Oct 17, 2024
d5f4473
Update comment about convergence to zero with warning to use adaptive…
unalmis Oct 17, 2024
fd723a6
Merge branch 'Gamma_c' into ku/fourier_bounce_neo
unalmis Oct 17, 2024
8b5cdb8
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 17, 2024
1e1089d
Merge branch 'ripple' into rg/NFP_fac
rahulgaur104 Oct 17, 2024
569dcdc
Merge branch 'master' into ripple
unalmis Oct 17, 2024
59235b0
Update baseline image now that plot_fsa computes on symmetric grid
unalmis Oct 17, 2024
1797fcc
Merge branch 'ripple' into Gamma_c
unalmis Oct 17, 2024
8fd8e21
Clarify documentation
unalmis Oct 17, 2024
7b440de
Merge branch 'master' into ku/fourier_bounce
unalmis Oct 17, 2024
78fa50d
Merge branch 'master' into ripple
dpanici Oct 17, 2024
c2971d1
adding ripple notebook with rev-mode optimization example
rahulgaur104 Oct 18, 2024
466e478
Merge branch 'master' into rg/NFP_fac
rahulgaur104 Oct 18, 2024
a251d3e
Algorithm improvements, last major refactor
unalmis Oct 18, 2024
7e12015
Remove Bounce2D PEST ; will add back 2D plotting functions in later PR
unalmis Oct 18, 2024
263fb56
Add interp_fft_to_argmin for Gamma c Nemov
unalmis Oct 18, 2024
276f6af
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 18, 2024
372aae8
Resolves test of bounce average with secular term
unalmis Oct 19, 2024
38da125
Improve interpolate to argmin test
unalmis Oct 19, 2024
b83fed8
Merge branch 'ripple' into Gamma_c
unalmis Oct 19, 2024
7bf01e5
Update master compute data
unalmis Oct 19, 2024
4d89326
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 19, 2024
d3d239e
Add missing unit test marker to nangrad ballooning
unalmis Oct 19, 2024
2e74569
Merge branch 'ripple' into Gamma_c
unalmis Oct 19, 2024
d6d9407
Merge branch 'Gamma_c' into ku/fourier_bounce_neo
unalmis Oct 19, 2024
55ee0c3
Fix comment
unalmis Oct 19, 2024
4ed1701
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 19, 2024
916dad5
reducing compile time
unalmis Oct 19, 2024
ed7833f
adding back use of vecdot
unalmis Oct 19, 2024
2f3a03a
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 19, 2024
0dd088b
Add riple tutorial to docs to avoid failing test
unalmis Oct 19, 2024
5a58582
Writing new compute funs with Bounce2D
unalmis Oct 20, 2024
927ab54
Merging changes from downstream branch #1290
unalmis Oct 20, 2024
5ea5c02
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 20, 2024
9ffb527
Merge branch 'ripple' into Gamma_c
unalmis Oct 20, 2024
3227c8f
Merge branch 'Gamma_c' into ku/fourier_bounce_neo
unalmis Oct 20, 2024
8a8e8f2
Updating epsilon and gamma objectives with Bounce2D
unalmis Oct 20, 2024
b229726
Pulling updates from downstream branch #1290
unalmis Oct 20, 2024
bd5ff90
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 20, 2024
47744c2
Change variable name <L|r,a> to fieldline length
unalmis Oct 20, 2024
f2c3ac1
Update docstrings for neoclassical objectives to use new docstring fo…
unalmis Oct 20, 2024
b9e867e
Increase codecoverage
unalmis Oct 20, 2024
8733ab7
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 20, 2024
89e63f7
Add jitable flag to create meshgrid
unalmis Oct 20, 2024
332c053
Increasing coverage
unalmis Oct 20, 2024
ed7aa75
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 21, 2024
7c8902a
Remove redundant parameter to Bounce2D. Last edit unless reviewers re…
unalmis Oct 21, 2024
36512d1
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 21, 2024
635cf3d
making reviewer suggested changes
unalmis Oct 21, 2024
4ebe882
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 21, 2024
695ebac
Removing redundant parameter when constructing bounce2d
unalmis Oct 21, 2024
45f33c0
Merge branch 'master' into ku/fourier_bounce
unalmis Oct 21, 2024
0c88f3c
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 21, 2024
6da03ab
Rename files as requested by reviewers
unalmis Oct 21, 2024
c22b495
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 21, 2024
365b55d
Making changes that arise from Rory's suggested naming changes
unalmis Oct 21, 2024
583dc3f
Apply suggestions from code review
unalmis Oct 21, 2024
9abb6a9
review comments
unalmis Oct 21, 2024
0e6fa9f
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 21, 2024
f7220a0
Review inspired changes
unalmis Oct 21, 2024
6ff8bce
More review inspired changes
unalmis Oct 22, 2024
968afed
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 22, 2024
7b58acf
Improving documentation and fixing bug in objective where Y_B not set…
unalmis Oct 22, 2024
5e0bd0d
Mark Gamma_c as not implemented axis limit
unalmis Oct 22, 2024
15f9278
Add Gamma_c axis limit
unalmis Oct 22, 2024
62fa063
Creating new option to reduce memory usage
unalmis Oct 23, 2024
03a0af5
Adding abs around B^zeta missing from last commit. Now, I'm done.
unalmis Oct 23, 2024
f53e668
Merge branch 'master' into ku/fourier_bounce
dpanici Oct 23, 2024
8fbd2f1
Merge branch 'grid_resolution_fix' into ku/fourier_bounce_neo
unalmis Oct 24, 2024
19afc1e
Increasing FFT resolution in tests
unalmis Oct 24, 2024
abfa7f4
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
rahulgaur104 Oct 25, 2024
f82bf2d
Avoid redundant interpolation to speed things
unalmis Oct 27, 2024
1f26a33
Add psuedo spectral version of velasco gamma_c
unalmis Oct 27, 2024
54c7369
Speed up by ffting at once
unalmis Oct 27, 2024
7bef6a4
Merge branch 'master' into ku/fourier_bounce
unalmis Oct 29, 2024
2b36f5a
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 29, 2024
e10c571
Cosmetic changes requested by @dpanici
unalmis Oct 29, 2024
d88227e
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 29, 2024
c94fec2
Merge branch 'master' into ripple
unalmis Oct 29, 2024
371b7b9
Merge branch 'master' into rg/NFP_fac
rahulgaur104 Oct 30, 2024
2250ce0
changing _get_rtz_grid to get_rtz_grid
rahulgaur104 Oct 30, 2024
f019d32
trying to pass more tests
rahulgaur104 Oct 30, 2024
69f9e4c
fixing more tests
rahulgaur104 Oct 30, 2024
c9de31d
Merge branch 'master' into ripple
unalmis Oct 30, 2024
edc8fc2
Merge branch 'master' into ku/fourier_bounce
unalmis Oct 30, 2024
aa9513f
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 30, 2024
dc04fa5
Merge branch 'master' into ripple
unalmis Oct 31, 2024
4558b37
Updating NeoIO due to changes on master
unalmis Oct 31, 2024
4527892
Merge commit 'c9de31d' into ripple
unalmis Oct 31, 2024
3956822
Merge branch 'master' into ku/fourier_bounce
unalmis Oct 31, 2024
51cceeb
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 31, 2024
02aff96
Update dev requirement
unalmis Oct 31, 2024
6ef152c
removing NFP_umbilic_factor from FourierRZCurve
rahulgaur104 Oct 31, 2024
7eb5a9d
removing NFP_umbilic_factor from the axis FourierRZCurve object
rahulgaur104 Oct 31, 2024
3e55f00
Merge branch 'master' into rg/NFP_fac
rahulgaur104 Oct 31, 2024
99bd03d
removing NFP_umbilic_factor from desc/coils.py FourierRZCoil
rahulgaur104 Oct 31, 2024
ea03565
Merge branch 'rg/NFP_fac' of https://github.com/PlasmaControl/DESC in…
rahulgaur104 Oct 31, 2024
d556f1c
fixing from input file and removing erroneous NFP_umbilic_factor. Now…
rahulgaur104 Oct 31, 2024
fc893e4
undoing a change from the past to fix more tests
rahulgaur104 Oct 31, 2024
bc88b80
doing @dpanici review requests
unalmis Oct 31, 2024
b421baf
Merge branch 'master' into ku/fourier_bounce
unalmis Oct 31, 2024
e019670
Fixing comment from previous commit
unalmis Oct 31, 2024
808c5e2
Merge branch 'ku/fourier_bounce' into ku/fourier_bounce_neo
unalmis Oct 31, 2024
2097156
merging ripple again to measure progress
rahulgaur104 Nov 1, 2024
f02894f
trying to fix more tests; fixed test_compute_everything.py
rahulgaur104 Nov 9, 2024
96b2149
reverting to the master files
rahulgaur104 Nov 9, 2024
6e44ff3
reverting to the master files 2
rahulgaur104 Nov 9, 2024
faffd41
merging ku/fourier_bounce into rg/NFP_fac
rahulgaur104 Nov 9, 2024
e72b01e
merging ku/fourier_bounce_neo into this branch
rahulgaur104 Nov 9, 2024
e2c67b0
fixing minor bug
rahulgaur104 Nov 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions desc/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
from jax.lax import cond, fori_loop, scan, switch, while_loop
from jax.nn import softmax as softargmax
from jax.numpy import bincount, flatnonzero, repeat, take
from jax.numpy.fft import irfft, rfft, rfft2
from jax.numpy.fft import ifft, irfft, irfft2, rfft, rfft2
from jax.scipy.fft import dct, idct
from jax.scipy.linalg import block_diag, cho_factor, cho_solve, qr, solve_triangular
from jax.scipy.special import gammaln, logsumexp
Expand Down Expand Up @@ -434,7 +434,7 @@ def tangent_solve(g, y):
jit = lambda func, *args, **kwargs: func
execute_on_cpu = lambda func: func
import scipy.optimize
from numpy.fft import irfft, rfft, rfft2 # noqa: F401
from numpy.fft import ifft, irfft, irfft2, rfft, rfft2 # noqa: F401
from scipy.fft import dct, idct # noqa: F401
from scipy.integrate import odeint # noqa: F401
from scipy.linalg import ( # noqa: F401
Expand Down
83 changes: 68 additions & 15 deletions desc/basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class _Basis(IOAble, ABC):
"_M",
"_N",
"_NFP",
# --no-verify "_NFP_umbilic_factor",
"_modes",
"_sym",
"_spectral_indexing",
Expand Down Expand Up @@ -186,6 +187,11 @@ def NFP(self):
"""int: Number of field periods."""
return self.__dict__.setdefault("_NFP", 1)

@property
def NFP_umbilic_factor(self):
"""int: Umbilic factor field periods."""
return self.__dict__.setdefault("_NFP_umbilic_factor", 1)

@property
def sym(self):
"""str: Type of symmetry."""
Expand Down Expand Up @@ -213,8 +219,14 @@ def __repr__(self):
type(self).__name__
+ " at "
+ str(hex(id(self)))
+ " (L={}, M={}, N={}, NFP={}, sym={}, spectral_indexing={})".format(
self.L, self.M, self.N, self.NFP, self.sym, self.spectral_indexing
+ " (L={}, M={}, N={}, NFP={}, sym={},\
spectral_indexing={})".format(
self.L,
self.M,
self.N,
self.NFP,
self.sym,
self.spectral_indexing,
)
)

Expand All @@ -239,6 +251,7 @@ def __init__(self, L, sym="even"):
self._M = 0
self._N = 0
self._NFP = 1
self._sym = sym
self._sym = bool(sym) if not sym else str(sym)
self._spectral_indexing = "linear"

Expand Down Expand Up @@ -340,18 +353,24 @@ class FourierSeries(_Basis):
Maximum toroidal resolution.
NFP : int
number of field periods
NFP_umbilic_factor : int
Prefactor of the form 1/NFP_umbilic_fac.
This is needed for the umbilic torus design.
sym : {``'cos'``, ``'sin'``, False}
* ``'cos'`` for cos(m*t-n*z) symmetry
* ``'sin'`` for sin(m*t-n*z) symmetry
* ``False`` for no symmetry (Default)

"""

def __init__(self, N, NFP=1, sym=False):
def __init__(self, N, NFP=1, NFP_umbilic_factor=1, sym=False):
self._L = 0
self._M = 0
self._N = check_nonnegint(N, "N", False)
self._NFP = check_posint(NFP, "NFP", False)
self._NFP_umbilic_factor = check_posint(
NFP_umbilic_factor, "NFP_umbilic_factor", False
)
self._sym = bool(sym) if not sym else str(sym)
self._spectral_indexing = "linear"

Expand Down Expand Up @@ -422,13 +441,20 @@ def evaluate(
z = z[zidx]
n = n[nidx]

toroidal = fourier(z[:, np.newaxis], n, self.NFP, derivatives[2])
toroidal = fourier(
z[:, np.newaxis],
n,
self.NFP,
self.NFP_umbilic_factor,
derivatives[2],
)

if unique:
toroidal = toroidal[zoutidx][:, noutidx]

return toroidal

def change_resolution(self, N, NFP=None, sym=None):
def change_resolution(self, N, NFP=None, NFP_umbilic_factor=None, sym=None):
"""Change resolution of the basis to the given resolutions.

Parameters
Expand All @@ -437,12 +463,20 @@ def change_resolution(self, N, NFP=None, sym=None):
Maximum toroidal resolution.
NFP : int
Number of field periods.
NFP_umbilic_factor : float
Prefactor of the form 1/NFP_umbilic_factor.
This is needed for the umbilic torus design.
sym : bool
Whether to enforce stellarator symmetry.

"""
NFP = check_posint(NFP, "NFP")
self._NFP = NFP if NFP is not None else self.NFP
self._NFP_umbilic_factor = (
NFP_umbilic_factor
if NFP_umbilic_factor is not None
else self.NFP_umbilic_factor
)
if N != self.N:
self._N = check_nonnegint(N, "N", False)
self._sym = sym if sym is not None else self.sym
Expand Down Expand Up @@ -561,8 +595,16 @@ def evaluate(
m = m[midx]
n = n[nidx]

poloidal = fourier(t[:, np.newaxis], m, 1, derivatives[1])
toroidal = fourier(z[:, np.newaxis], n, self.NFP, derivatives[2])
poloidal = fourier(
t[:, np.newaxis], m, NFP=1, NFP_umbilic_factor=1, dt=derivatives[1]
)
toroidal = fourier(
z[:, np.newaxis],
n,
NFP=self.NFP,
NFP_umbilic_factor=1,
dt=derivatives[2],
)
if unique:
poloidal = poloidal[toutidx][:, moutidx]
toroidal = toroidal[zoutidx][:, noutidx]
Expand Down Expand Up @@ -770,7 +812,7 @@ def evaluate(
m = m[midx]

radial = zernike_radial(r[:, np.newaxis], lm[:, 0], lm[:, 1], dr=derivatives[0])
poloidal = fourier(t[:, np.newaxis], m, 1, derivatives[1])
poloidal = fourier(t[:, np.newaxis], m, 1, 1, derivatives[1])

if unique:
radial = radial[routidx][:, lmoutidx]
Expand Down Expand Up @@ -902,8 +944,8 @@ def evaluate(
l, m, n = modes.T

radial = chebyshev(r[:, np.newaxis], l, dr=derivatives[0])
poloidal = fourier(t[:, np.newaxis], m, 1, derivatives[1])
toroidal = fourier(z[:, np.newaxis], n, self.NFP, derivatives[2])
poloidal = fourier(t[:, np.newaxis], m, 1, 1, derivatives[1])
toroidal = fourier(z[:, np.newaxis], n, self.NFP, 1, derivatives[2])

return radial * poloidal * toroidal

Expand Down Expand Up @@ -1132,8 +1174,14 @@ def evaluate(
n = n[nidx]

radial = zernike_radial(r[:, np.newaxis], lm[:, 0], lm[:, 1], dr=derivatives[0])
poloidal = fourier(t[:, np.newaxis], m, dt=derivatives[1])
toroidal = fourier(z[:, np.newaxis], n, NFP=self.NFP, dt=derivatives[2])
poloidal = fourier(t[:, np.newaxis], m, 1, 1, dt=derivatives[1])
toroidal = fourier(
z[:, np.newaxis],
n,
NFP=self.NFP,
NFP_umbilic_factor=1,
dt=derivatives[2],
)
if unique:
radial = radial[routidx][:, lmoutidx]
poloidal = poloidal[toutidx][:, moutidx]
Expand Down Expand Up @@ -1652,7 +1700,7 @@ def chebyshev(r, l, dr=0):


@jit
def fourier(theta, m, NFP=1, dt=0):
def fourier(theta, m, NFP=1, NFP_umbilic_factor=1, dt=0):
"""Fourier series.

Parameters
Expand All @@ -1663,6 +1711,9 @@ def fourier(theta, m, NFP=1, dt=0):
poloidal/toroidal mode number(s)
NFP : int
number of field periods (Default = 1)
NFP_umbilic_factor : int
NFP prefactor of the form 1/NFP_umbilic_factor.
This is needed for the umbilic torus design.
dt : int
order of derivative (Default = 0)

Expand All @@ -1672,9 +1723,11 @@ def fourier(theta, m, NFP=1, dt=0):
basis function(s) evaluated at specified points

"""
theta, m, NFP, dt = map(jnp.asarray, (theta, m, NFP, dt))
theta, m, NFP, NFP_umbilic_factor, dt = map(
jnp.asarray, (theta, m, NFP, NFP_umbilic_factor, dt)
)
m_pos = (m >= 0).astype(int)
m_abs = jnp.abs(m) * NFP
m_abs = jnp.abs(m) * NFP / NFP_umbilic_factor
shift = m_pos * jnp.pi / 2 + dt * jnp.pi / 2
return m_abs**dt * jnp.sin(m_abs * theta + shift)

Expand Down
39 changes: 34 additions & 5 deletions desc/coils.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ def _compute_position(self, params=None, grid=None, dx1=False, **kwargs):
basis = kwargs.get("basis", "xyz")
if basis.lower() == "rpz":
x = x.at[:, :, 1].set(jnp.mod(x[:, :, 1], 2 * jnp.pi))

# --no-verify x = x.at[:, :, 1].set(x[:, :, 1])

if dx1:
return x, x_s
return x
Expand Down Expand Up @@ -533,7 +536,7 @@ def to_SplineXYZ(self, knots=None, grid=None, method="cubic", name="", **kwargs)
self.current, coords, knots=knots, method=method, name=name, basis="xyz"
)

def to_FourierRZ(self, N=10, grid=None, NFP=None, sym=False, name="", **kwargs):
def to_FourierRZ(self, N=10, grid=None, NFP=None, sym=False, name=""):
"""Convert Coil to FourierRZCoil representation.

Note that some types of coils may not be representable in this basis.
Expand Down Expand Up @@ -564,7 +567,13 @@ def to_FourierRZ(self, N=10, grid=None, NFP=None, sym=False, name="", **kwargs):
grid = LinearGrid(N=2 * N + 1)
coords = self.compute("x", grid=grid, basis="xyz")["x"]
return FourierRZCoil.from_values(
self.current, coords, N=N, NFP=NFP, basis="xyz", sym=sym, name=name
self.current,
coords,
N=N,
NFP=NFP,
basis="xyz",
sym=sym,
name=name,
)

def to_FourierPlanar(self, N=10, grid=None, basis="xyz", name="", **kwargs):
Expand Down Expand Up @@ -669,7 +678,16 @@ def __init__(
super().__init__(current, R_n, Z_n, modes_R, modes_Z, NFP, sym, name)

@classmethod
def from_values(cls, current, coords, N=10, NFP=1, basis="rpz", sym=False, name=""):
def from_values(
cls,
current,
coords,
N=10,
NFP=1,
basis="rpz",
name="",
sym=False,
):
"""Fit coordinates to FourierRZCoil representation.

Parameters
Expand Down Expand Up @@ -699,7 +717,12 @@ def from_values(cls, current, coords, N=10, NFP=1, basis="rpz", sym=False, name=

"""
curve = super().from_values(
coords=coords, N=N, NFP=NFP, basis=basis, sym=sym, name=name
coords,
N=N,
NFP=NFP,
basis=basis,
sym=sym,
name=name,
)
return FourierRZCoil(
current=current,
Expand Down Expand Up @@ -2036,7 +2059,13 @@ def to_FourierPlanar(
)

def to_FourierRZ(
self, N=10, grid=None, NFP=None, sym=False, name="", check_intersection=True
self,
N=10,
grid=None,
NFP=None,
sym=False,
name="",
check_intersection=True,
):
"""Convert all coils to FourierRZCoil representaion.

Expand Down
14 changes: 12 additions & 2 deletions desc/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,12 @@ def rescale(
eq = eq.copy()

# size scaling
grid_L = QuadratureGrid(L=eq.L_grid, M=eq.M_grid, N=eq.N_grid, NFP=eq.NFP)
grid_L = QuadratureGrid(
L=eq.L_grid,
M=eq.M_grid,
N=eq.N_grid,
NFP=eq.NFP,
)
data_L = eq.compute(L_keys, grid=grid_L)
L_old = data_L[L_key]
L_new = L_new or L_old
Expand All @@ -227,7 +232,12 @@ def rescale(
data_B = eq.compute("<|B|>_vol", grid=grid_B)
B_old = data_B["<|B|>_vol"]
elif B_key == "B_max":
grid_B = LinearGrid(M=eq.M_grid, N=eq.N_grid, NFP=eq.NFP, rho=1)
grid_B = LinearGrid(
M=eq.M_grid,
N=eq.N_grid,
NFP=eq.NFP,
rho=1,
)
data_B = eq.compute("|B|", grid=grid_B)
B_old = np.max(data_B["|B|"])
B_new = B_new or B_old
Expand Down
3 changes: 3 additions & 0 deletions desc/compute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@
_field,
_geometry,
_metric,
_neoclassical,
_neoclassical_1D,
_omnigenity,
_profiles,
_stability,
_surface,
_umbiliccurve,
)
from .data_index import all_kwargs, allowed_kwargs, data_index
from .geom_utils import rpz2xyz, rpz2xyz_vec, xyz2rpz, xyz2rpz_vec
Expand Down
Loading
Loading