Skip to content

Commit

Permalink
JaxCurrent actually not quite working yet. Made some little fixes but…
Browse files Browse the repository at this point in the history
… need to fully fix.
  • Loading branch information
akaptano committed Sep 22, 2024
1 parent ac7df3d commit 846d400
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# filename = TEST_DIR / input_name

# Directory for output
OUT_DIR = "./dipole_array_optimization_QA/"
OUT_DIR = "./dipole_array_optimization_QA_debug/"
if os.path.exists(OUT_DIR):
shutil.rmtree(OUT_DIR)
os.makedirs(OUT_DIR, exist_ok=True)
Expand All @@ -43,7 +43,7 @@
nphi = 64
ntheta = 64
poff = 2.0
coff = 1.0
coff = 2.0
s = SurfaceRZFourier.from_vmec_input(filename, range=range_param, nphi=nphi, ntheta=ntheta)
s_inner = SurfaceRZFourier.from_vmec_input(filename, range=range_param, nphi=nphi * 4, ntheta=ntheta * 4)
s_outer = SurfaceRZFourier.from_vmec_input(filename, range=range_param, nphi=nphi * 4, ntheta=ntheta * 4)
Expand Down
4 changes: 4 additions & 0 deletions src/simsopt/field/coil.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from math import pi
import numpy as np
from jax import vjp, jacfwd, jvp
import jax.numpy as jnp

from simsopt._core.optimizable import Optimizable
from simsopt._core.derivative import Derivative
from simsopt.geo.curvexyzfourier import CurveXYZFourier
from simsopt.geo.curve import RotatedCurve
from simsopt.geo.jit import jit
import simsoptpp as sopp


Expand Down Expand Up @@ -142,6 +145,7 @@ def current(self):
self.current_jax = jit(lambda dofs: self.current_pure(dofs))
self.dcurrent_by_dcoeff_jax = jit(jacfwd(self.current_jax))
self.dcurrent_by_dcoeff_vjp_jax = jit(lambda x, v: vjp(self.current_jax, x)[1](v)[0])
self.vjp = dcurrent_by_dcoeff_vjp_jax

def set_dofs(self, dofs):
self.local_x = dofs
Expand Down

0 comments on commit 846d400

Please sign in to comment.