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

add basic coil objectives #853

Merged
merged 87 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
24fdbc6
initial commit
kianorr Feb 3, 2024
dd1c024
Merge branch 'master' into ko/coil_length
kianorr Feb 3, 2024
68301c0
add simple test
kianorr Feb 4, 2024
1b8306f
Merge branch master into ko/coil_length
kianorr Feb 4, 2024
834b6d0
add default args plus todos
kianorr Feb 4, 2024
45b7282
Merge branch 'master' into ko/coil_length
kianorr Feb 5, 2024
06bef53
add to objectives __init__
kianorr Feb 5, 2024
aea78c1
merge PR#840 into ko/coil_length
kianorr Feb 5, 2024
2d64ab5
delete comments and change grid
kianorr Feb 5, 2024
a64ce35
add docstrings and grid option
kianorr Feb 6, 2024
30e72ad
Merge branch 'master' into ko/coil_length
dpanici Feb 6, 2024
5541546
Merge branch 'origin/ko/coil_length' into ko/coil_length
kianorr Feb 7, 2024
6026cf6
merge dd/curve into ko/coil_length
kianorr Feb 7, 2024
5c8823b
Merge branch 'master' into ko/coil_length
kianorr Feb 8, 2024
2ddc10f
initial commit
kianorr Feb 3, 2024
6326552
add simple test
kianorr Feb 4, 2024
c424ec1
add default args plus todos
kianorr Feb 4, 2024
22b4b63
add to objectives __init__
kianorr Feb 5, 2024
c874e84
delete comments and change grid
kianorr Feb 5, 2024
b1e34eb
add docstrings and grid option
kianorr Feb 6, 2024
0e2315d
Merge branch 'ko/coil_length' into ko/coil_length
kianorr Feb 8, 2024
ffc857c
Revert "Merge branch 'ko/coil_length' into ko/coil_length"
kianorr Feb 8, 2024
09fe488
add logic for CoilSet
kianorr Feb 9, 2024
e612fb4
add test for CoilSet
kianorr Feb 9, 2024
c21305c
add mixed coil functionality
kianorr Feb 10, 2024
edae7b8
correct dim_f
kianorr Feb 10, 2024
bc0e23e
Merge branch 'master' into ko/coil_length
kianorr Feb 10, 2024
1ab2e75
add base class for coil objectives
kianorr Feb 11, 2024
dbfb77d
add kwargs
kianorr Feb 11, 2024
6f2cf35
Merge branch 'ko/coil_length' of https://github.com/PlasmaControl/DES…
kianorr Feb 11, 2024
39bff34
Merge branch 'master' into ko/coil_length
kianorr Feb 19, 2024
01c872b
address easy reviews
kianorr Feb 21, 2024
fc6cfd9
Merge branch 'ko/coil_length' of https://github.com/PlasmaControl/DES…
kianorr Feb 21, 2024
05bf325
Merge branch 'master' into ko/coil_length
kianorr Feb 21, 2024
b0658af
Merge branch 'master' into ko/coil_length
kianorr Feb 24, 2024
a6ef1c2
add tree_flatten for nested coilsets
kianorr Feb 24, 2024
209ea6d
fix import bug
kianorr Feb 24, 2024
9d378be
Merge branch 'master' into ko/coil_length
dpanici Mar 6, 2024
47f615f
Merge branch 'master' into ko/coil_length
kianorr Mar 7, 2024
2559aa1
add nested coil sets functionality
kianorr Mar 7, 2024
af3a424
use tree_flatten from backend and import jax
kianorr Mar 7, 2024
024f0f2
use tree_map for transforms
kianorr Mar 7, 2024
7535497
add logic for default grid
kianorr Mar 7, 2024
00c7bcd
add torsion objective and tests
kianorr Mar 7, 2024
73eafa4
update docstrings
kianorr Mar 7, 2024
dabdba1
change curvature target to bounds
kianorr Mar 7, 2024
2acba22
correct self._dim_f
kianorr Mar 7, 2024
be8fcb4
add normalization
kianorr Mar 7, 2024
bc129d0
move everything to _coils.py
kianorr Mar 7, 2024
2c36497
Merge branch 'master' into ko/coil_length
kianorr Mar 8, 2024
7beb157
import from _coils
kianorr Mar 8, 2024
337c0fd
Merge branch 'ko/coil_length' of https://github.com/PlasmaControl/DES…
kianorr Mar 8, 2024
3523178
addressed reviews
kianorr Mar 9, 2024
cdd348e
fix logic for type checking
kianorr Mar 10, 2024
fdb6cae
add actual nested coilset
kianorr Mar 11, 2024
7c06e13
change grid logic
kianorr Mar 12, 2024
7e7c1c9
refactor
kianorr Mar 12, 2024
c471948
Merge branch 'master' into ko/coil_length
kianorr Mar 12, 2024
a3ffe3b
Merge branch 'ko/coil_length' of https://github.com/PlasmaControl/DES…
kianorr Mar 12, 2024
77645c5
add comments
kianorr Mar 13, 2024
d071f8c
change if to elif statements
kianorr Mar 13, 2024
752fec9
refactor
kianorr Mar 13, 2024
86537fd
Merge branch 'master' into ko/coil_length
f0uriest Mar 14, 2024
e6712f0
add missing names
dpanici Mar 15, 2024
118b1cc
fix current setting of coils, which could fail if a size 1 dim 1 ndar…
dpanici Mar 15, 2024
cf0ddef
add missing print value fmt, units and whether coil objs are scalar
dpanici Mar 15, 2024
0de46f1
add test for objectives, though torsion test is not working
dpanici Mar 15, 2024
e6814b3
fix torsion test
dpanici Mar 15, 2024
51d2f02
remove unneeded print
dpanici Mar 15, 2024
3c59c73
make test a little faster and more compact
dpanici Mar 15, 2024
1000d9d
Merge branch 'master' into ko/coil_length
dpanici Mar 17, 2024
e8522bd
Merge branch 'master' into ko/coil_length
kianorr Mar 18, 2024
14095f6
adress reviews
kianorr Mar 18, 2024
2dc0510
Merge branch 'ko/coil_length' of https://github.com/PlasmaControl/DES…
kianorr Mar 18, 2024
5dd7ca3
merge master and resolve import conflict
kianorr Mar 18, 2024
53a2a20
add quad_weights to constants
kianorr Mar 19, 2024
24c393e
add quad_weights with spacing
kianorr Mar 19, 2024
2a4dd3b
concatenate quad_weights
kianorr Mar 19, 2024
24afec7
Merge branch 'master' into ko/coil_length
kianorr Mar 19, 2024
c630ca9
update docstrings
kianorr Mar 20, 2024
d6a498e
Merge branch 'ko/coil_length' of https://github.com/PlasmaControl/DES…
kianorr Mar 20, 2024
321851b
fix docstring
kianorr Mar 21, 2024
4ab1518
Merge branch 'master' into ko/coil_length
kianorr Mar 21, 2024
01a6bc2
delete scalar comments
kianorr Mar 27, 2024
caaae44
Merge branch 'master' into ko/coil_length
f0uriest Mar 27, 2024
442fc96
Merge branch 'master' into ko/coil_length
ddudt Mar 28, 2024
b0662cc
Merge branch 'master' into ko/coil_length
kianorr Mar 28, 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
21 changes: 20 additions & 1 deletion desc/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@
from jax.experimental.ode import odeint
from jax.scipy.linalg import block_diag, cho_factor, cho_solve, qr, solve_triangular
from jax.scipy.special import gammaln, logsumexp
from jax.tree_util import register_pytree_node, tree_flatten, tree_unflatten
from jax.tree_util import (
register_pytree_node,
tree_flatten,
tree_leaves,
tree_map,
tree_structure,
tree_unflatten,
)

def put(arr, inds, vals):
"""Functional interface for array "fancy indexing".
Expand Down Expand Up @@ -393,6 +400,18 @@ def tree_unflatten(*args, **kwargs):
"""Unflatten pytree for numpy backend."""
raise NotImplementedError

def tree_map(*args, **kwargs):
"""Map pytree for numpy backend."""
raise NotImplementedError

def tree_structure(*args, **kwargs):
"""Get structure of pytree for numpy backend."""
raise NotImplementedError

def tree_leaves(*args, **kwargs):
"""Get leaves of pytree for numpy backend."""
raise NotImplementedError

def register_pytree_node(foo, *args):
"""Dummy decorator for non-jax pytrees."""
return foo
Expand Down
4 changes: 2 additions & 2 deletions desc/coils.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class _Coil(_MagneticField, Optimizable, ABC):
_io_attrs_ = _MagneticField._io_attrs_ + ["_current"]

def __init__(self, current, *args, **kwargs):
self._current = float(current)
self._current = float(np.squeeze(current))
super().__init__(*args, **kwargs)

@optimizable_parameter
Expand All @@ -145,7 +145,7 @@ def current(self):
@current.setter
def current(self, new):
assert jnp.isscalar(new) or new.size == 1
self._current = float(new)
self._current = float(np.squeeze(new))

def compute_magnetic_field(
self, coords, params=None, basis="rpz", source_grid=None
Expand Down
1 change: 1 addition & 0 deletions desc/objectives/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Classes defining objectives for equilibrium and optimization."""

from ._bootstrap import BootstrapRedlConsistency
from ._coils import CoilCurvature, CoilLength, CoilTorsion
from ._equilibrium import (
CurrentDensity,
Energy,
Expand Down
Loading
Loading