Skip to content

Commit

Permalink
Merge branch 'master' into boozer_windowpane
Browse files Browse the repository at this point in the history
  • Loading branch information
ejpaul committed May 20, 2024
2 parents 2d2180a + 1049228 commit be33c0a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
20 changes: 10 additions & 10 deletions src/simsopt/field/mgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,16 @@ def write(self, filename):
var_raw_coil_cur = ds.createVariable('raw_coil_cur', 'f8', ('external_coils',))

# assign values
var_ir.assignValue(self.nr)
var_jz.assignValue(self.nz)
var_kp.assignValue(self.nphi)
var_nfp.assignValue(self.nfp)
var_nextcur.assignValue(self.n_ext_cur)

var_rmin.assignValue(self.rmin)
var_zmin.assignValue(self.zmin)
var_rmax.assignValue(self.rmax)
var_zmax.assignValue(self.zmax)
var_ir.data[()] = self.nr
var_jz.data[()] = self.nz
var_kp.data[()] = self.nphi
var_nfp.data[()] = self.nfp
var_nextcur.data[()] = self.n_ext_cur

var_rmin.data[()] = self.rmin
var_zmin.data[()] = self.zmin
var_rmax.data[()] = self.rmax
var_zmax.data[()] = self.zmax

var_mgrid_mode[:] = 'N' # R - Raw, S - scaled, N - none (old version)
var_raw_coil_cur[:] = np.ones(self.n_ext_cur)
Expand Down
10 changes: 5 additions & 5 deletions src/simsopt/mhd/virtual_casing.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,27 +300,27 @@ def save(self, filename="vcasing.nc"):
f.createDimension('xyz', 3)

src_ntheta = f.createVariable('src_ntheta', 'i', tuple())
src_ntheta.assignValue(self.src_ntheta)
src_ntheta.data[()] = self.src_ntheta
src_ntheta.description = 'Number of grid points in the poloidal angle theta for source B field and surface shape'
src_ntheta.units = 'Dimensionless'

trgt_ntheta = f.createVariable('trgt_ntheta', 'i', tuple())
trgt_ntheta.assignValue(self.trgt_ntheta)
trgt_ntheta.data[()] = self.trgt_ntheta
trgt_ntheta.description = 'Number of grid points in the poloidal angle theta for resulting B_external'
trgt_ntheta.units = 'Dimensionless'

src_nphi = f.createVariable('src_nphi', 'i', tuple())
src_nphi.assignValue(self.src_nphi)
src_nphi.data[()] = self.src_nphi
src_nphi.description = 'Number of grid points in the toroidal angle phi for source B field and surface shape'
src_nphi.units = 'Dimensionless'

trgt_nphi = f.createVariable('trgt_nphi', 'i', tuple())
trgt_nphi.assignValue(self.trgt_nphi)
trgt_nphi.data[()] = self.trgt_nphi
trgt_nphi.description = 'Number of grid points in the toroidal angle phi for resulting B_external'
trgt_nphi.units = 'Dimensionless'

nfp = f.createVariable('nfp', 'i', tuple())
nfp.assignValue(self.nfp)
nfp.data[()] = self.nfp
nfp.description = 'Periodicity in toroidal direction'
nfp.units = 'Dimensionless'

Expand Down
21 changes: 9 additions & 12 deletions src/simsopt/mhd/vmec.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ class Vmec(Optimizable):
Vmec object with different parameters; changing the parameters of
one would change the parameters of the other.
An instance of this class owns just a few optimizable degrees of
freedom, particularly ``phiedge`` and ``curtor``. The optimizable
An instance of this class owns three optimizable degrees of
freedom: ``phiedge``, ``curtor``, and ``pres_scale``. The optimizable
degrees of freedom associated with the boundary surface are owned
by that surface object.
Expand Down Expand Up @@ -373,7 +373,7 @@ def __init__(self,
# Handle a few variables that are not Parameters:
x0 = self.get_dofs()
fixed = np.full(len(x0), True)
names = ['delt', 'tcon0', 'phiedge', 'curtor', 'gamma']
names = ['phiedge', 'curtor', 'pres_scale']
super().__init__(x0=x0, fixed=fixed, names=names,
depends_on=[self._boundary],
external_dof_setter=Vmec.set_dofs)
Expand Down Expand Up @@ -444,20 +444,17 @@ def iota_profile(self, iota_profile):
def get_dofs(self):
if not self.runnable:
# Use default values from vmec_input
return np.array([1, 1, 1, 0, 0])
return np.array([1.0, 0.0, 1.0])
else:
return np.array([self.indata.delt, self.indata.tcon0,
self.indata.phiedge, self.indata.curtor,
self.indata.gamma])
return np.array([self.indata.phiedge, self.indata.curtor,
self.indata.pres_scale])

def set_dofs(self, x):
if self.runnable:
self.need_to_run_code = True
self.indata.delt = x[0]
self.indata.tcon0 = x[1]
self.indata.phiedge = x[2]
self.indata.curtor = x[3]
self.indata.gamma = x[4]
self.indata.phiedge = x[0]
self.indata.curtor = x[1]
self.indata.pres_scale = x[2]

def recompute_bell(self, parent=None):
self.need_to_run_code = True
Expand Down

0 comments on commit be33c0a

Please sign in to comment.