Skip to content

Commit

Permalink
fixed winding surface issue
Browse files Browse the repository at this point in the history
  • Loading branch information
abaillod committed Jan 19, 2024
1 parent 6e59496 commit 1375fe7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/simsopt/geo/curveobjectives.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,15 @@ def ws_distance_pure(gammac, lc, gammas, ns, maximum_distance):
This function is used in a Python+Jax implementation of the curve-surface distance
formula.
"""
nss = gammas.size
ncc = gammac.size
dists = jnp.sqrt(jnp.sum(
(gammac[:, None, :] - gammas[None, :, :])**2, axis=2))
integralweight = jnp.linalg.norm(lc, axis=1)[:, None] \
* jnp.linalg.norm(ns, axis=1)[None, :]
return jnp.mean(integralweight * jnp.maximum(dists-maximum_distance, 0)**2)
return jnp.mean(
integralweight * jnp.maximum(dists**2-maximum_distance**2, 0)**2
) / (nss*ncc)**2

class WindingSurface(Optimizable):
r"""Used to constrain coils to remain on a surface
Expand Down

0 comments on commit 1375fe7

Please sign in to comment.