Skip to content

Commit

Permalink
fix constant_offset_surface function
Browse files Browse the repository at this point in the history
  • Loading branch information
YigitElma committed Oct 19, 2024
1 parent 92bf3d1 commit e10b2e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions desc/equilibrium/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ def fixup(x, *args):
fixup=fixup,
tol=tol,
maxiter=maxiter,
full_output=full_output,
**kwargs,
)
)
Expand Down Expand Up @@ -479,6 +480,7 @@ def fixup(x, *args):
fixup=fixup,
tol=tol,
maxiter=maxiter,
full_output=full_output,
**kwargs,
)
)
Expand Down
15 changes: 12 additions & 3 deletions desc/geometry/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,10 +741,19 @@ def fun_jax(zeta_hat, theta, zeta):
n, r, r_offset = n_and_r_jax(nodes)
return jnp.arctan(r_offset[0, 1] / r_offset[0, 0]) - zeta

vecroot = jit(vmap(lambda x0, *p: root_scalar(fun_jax, x0, jac=None, args=p)))
zetas, (res, niter) = vecroot(
grid.nodes[:, 2], grid.nodes[:, 1], grid.nodes[:, 2]
vecroot = jit(
vmap(
lambda x0, *p: root_scalar(
fun_jax, x0, jac=None, args=p, full_output=full_output
)
)
)
if full_output:
zetas, (res, niter) = vecroot(
grid.nodes[:, 2], grid.nodes[:, 1], grid.nodes[:, 2]
)
else:
zetas = vecroot(grid.nodes[:, 2], grid.nodes[:, 1], grid.nodes[:, 2])

Check warning on line 756 in desc/geometry/surface.py

View check run for this annotation

Codecov / codecov/patch

desc/geometry/surface.py#L756

Added line #L756 was not covered by tests

zetas = np.asarray(zetas)
nodes = np.vstack((np.ones_like(grid.nodes[:, 1]), grid.nodes[:, 1], zetas)).T
Expand Down

0 comments on commit e10b2e4

Please sign in to comment.