In [1]:
from coilpy import *
import numpy as np
import matplotlib.pyplot as plt

Files can be found in FOCUS/examples/hsx

plot plasma.boundary

In [2]:
plas = FourSurf.read_focus_input('plasma.boundary')
plas.plot(zeta=0)
plas.plot(zeta=np.pi/4)
Out[2]:
[<matplotlib.lines.Line2D at 0x7fdcb408c790>]

check poincare plot with case_postproc=3

In [18]:
# %load ref.input
&FOCUSIN
 ISQUIET=-1         ,
 ISSYMMETRIC=2          ,
 INPUT_SURF="plasma.boundary",
 INPUT_COILS="coils.hsx",
 NTETA=64         ,
 NZETA=64         ,
 CASE_INIT=-1          ,
 NFCOIL=8          ,
 NSEG=128        ,
 ISNORMALIZE=1          ,
 ISNORMWEIGHT=1          ,
 CASE_BNORMAL=0          ,
 WEIGHT_BNORM=  1.0000000000000000     ,
 CASE_OPTIMIZE=0          ,
 CASE_POSTPROC=3          ,
 SAVE_FREQ=1          ,
 SAVE_COILS=0          ,
 SAVE_HARMONICS=0          ,
 SAVE_FILAMENTS=0          ,
 UPDATE_PLASMA=0          ,
 PP_PHI=  0.0000000000000000     ,
 PP_RAXIS=  0.0000000000000000     ,
 PP_ZAXIS=  0.0000000000000000     ,
 PP_RMAX=  1.52000000000000000     ,
 PP_ZMAX=  0.0000000000000000     ,
 PP_NS=12         ,
 PP_MAXITER=600       ,
 PP_NSTEPS=4          ,
 PP_NFP=1          ,
 PP_XTOL=  9.9999999999999995E-007,
 /
&mgrid
Rmax = 1.6
Rmin = 0.8
Zmax = 0.35
Zmin = -0.35
NR = 81
NZ = 71
NP = 72
/
In [19]:
ref = FOCUSHDF5('focus_ref.h5')
FOCUS version: v0.13.09
In [20]:
plt.figure()
plas.plot(color='k')
ref.poincare_plot()

Generate MGRID file using case_postproc=5

&FOCUSIN
...
 CASE_POSTPROC= 5
...
&mgrid
Rmax = 1.6
Rmin = 0.8
Zmax = 0.35
Zmin = -0.35
NR = 81
NZ = 71
NP = 72
/

Run free-boundary VMEC

Key parameters:

  MGRID_FILE = 'mgrid.focus_ref'
  LFREEB = T
  EXTCUR = 1.0

Then run VMEC

mpiexec xvmec2000 input.hsx
In [21]:
wout = VMECout('wout_hsx.nc')
In [22]:
plt.figure()
for i in wout.surface[::16]:
    i.plot()
ref.poincare_plot(color='k')
plt.ylim([0,0.3])
Out[22]:
(0.0, 0.3)
In [23]:
plas.plot(color='k',label='plasma boundary')
wout.surface[-1].plot(label='free-boundary VMEC')
plt.legend()
ref.poincare_plot()
plt.ylim([0,0.3])
Out[23]:
(0.0, 0.3)

Prepare and run BOOZ_XFORM

In [7]:
# prepare a BOOZ_XFORM input file
BOOZ_XFORM.from_vmec('wout_hsx.nc')

run BOOZ_XFORM via

xbooz_xform inbooz.hsx
In [10]:
booz = BOOZ_XFORM('boozmn_hsx.nc')
In [15]:
# plotting the leading 10 modes
# m, n/Nfp = 1,1 is the target mode
booz.plot(ordering=10, log=False)
plt.legend()
Out[15]:
<matplotlib.legend.Legend at 0x7fdcb6f66100>
In [24]:
booz.plot(mn=(2,1), log=False)
Out[24]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fdc7a4ef9a0>
In [16]:
booz.plot2d()
Out[16]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fdcb6dd2e80>
In [17]:
booz.plot2d(ns=49)
Out[17]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fdcb6d26be0>
In [ ]: