from coilpy import *
import numpy as np
import matplotlib.pyplot as plt
Files can be found in FOCUS/examples/hsx
plas = FourSurf.read_focus_input('plasma.boundary')
plas.plot(zeta=0)
plas.plot(zeta=np.pi/4)
# %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
/
ref = FOCUSHDF5('focus_ref.h5')
plt.figure()
plas.plot(color='k')
ref.poincare_plot()
&FOCUSIN
...
CASE_POSTPROC= 5
...
&mgrid
Rmax = 1.6
Rmin = 0.8
Zmax = 0.35
Zmin = -0.35
NR = 81
NZ = 71
NP = 72
/
Key parameters:
MGRID_FILE = 'mgrid.focus_ref'
LFREEB = T
EXTCUR = 1.0
Then run VMEC
mpiexec xvmec2000 input.hsx
wout = VMECout('wout_hsx.nc')
plt.figure()
for i in wout.surface[::16]:
i.plot()
ref.poincare_plot(color='k')
plt.ylim([0,0.3])
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])
# prepare a BOOZ_XFORM input file
BOOZ_XFORM.from_vmec('wout_hsx.nc')
run BOOZ_XFORM via
xbooz_xform inbooz.hsx
booz = BOOZ_XFORM('boozmn_hsx.nc')
# plotting the leading 10 modes
# m, n/Nfp = 1,1 is the target mode
booz.plot(ordering=10, log=False)
plt.legend()
booz.plot(mn=(2,1), log=False)
booz.plot2d()
booz.plot2d(ns=49)