28 INTEGER,
INTENT(inout) :: ier_flag
30 INTEGER :: l0pi, l, lk, ivacskip, js, ku, m, n
31 INTEGER :: nvskip0 = 0
32 REAL(dp),
DIMENSION(mnmax) :: rmnc, zmns, lmns, rmns, zmnc, lmnc
33 REAL(dp),
DIMENSION(:),
POINTER :: lu, lv
34 REAL(dp) :: presf_ns, delt0, fsqrz, old_fsqz, diff
35 REAL(dp),
EXTERNAL :: pmass
37 CHARACTER(LEN=255) :: vac_file
38 integer :: nvac, istat_vac
40 character(len=255) :: nestor_cmd
51 character(len=*),
parameter :: nestor_executable = &
52 "python3 /data/jonathan/work/code/NESTOR/src/main/python/ooNESTOR.py"
58 logical :: lexternal_nestor = .false.
61 logical :: ldump_vacuum_ref = .false.
80 call add_real_5d(
"gc", 3,
ntmax, ns, ntor1,
mpol,
gc(:
neqs), order=(/ 3, 4, 5, 2, 1 /) )
88 CALL totzsps (
gc,
r1,
ru,
rv,
z1,
zu,
zv, lu, lv,
rcon,
zcon)
99 CALL symrzl (
r1,
ru,
rv,
z1,
zu,
zv, lu, lv,
rcon,
zcon, &
105 call add_real_4d(
"r1", ns, 2,
nzeta, ntheta3,
r1, order=(/ 1, 3, 4, 2 /) )
106 call add_real_4d(
"ru", ns, 2,
nzeta, ntheta3,
ru, order=(/ 1, 3, 4, 2 /) )
107 call add_real_4d(
"rv", ns, 2,
nzeta, ntheta3,
rv, order=(/ 1, 3, 4, 2 /) )
108 call add_real_4d(
"z1", ns, 2,
nzeta, ntheta3,
z1, order=(/ 1, 3, 4, 2 /) )
109 call add_real_4d(
"zu", ns, 2,
nzeta, ntheta3,
zu, order=(/ 1, 3, 4, 2 /) )
110 call add_real_4d(
"zv", ns, 2,
nzeta, ntheta3,
zv, order=(/ 1, 3, 4, 2 /) )
111 call add_real_4d(
"lu", ns, 2,
nzeta, ntheta3, lu, order=(/ 1, 3, 4, 2 /) )
112 call add_real_4d(
"lv", ns, 2,
nzeta, ntheta3, lv, order=(/ 1, 3, 4, 2 /) )
113 call add_real_4d(
"rcon", ns, 2,
nzeta, ntheta3,
rcon, order=(/ 1, 3, 4, 2 /) )
114 call add_real_4d(
"zcon", ns, 2,
nzeta, ntheta3,
zcon, order=(/ 1, 3, 4, 2 /) )
125 l0pi = ns*(1 +
nzeta*(ntheta2 - 1))
196 IF (lfreeb .and.
iter2.gt.1 .and.
iequi.eq.0)
THEN
198 IF ((
fsqr +
fsqz) .le. 1.e-3_dp)
then
209 IF (nvskip0 .eq. 0)
then
211 nvskip0 = max(1, nvacskip)
214 IF (
ivac .ge. 0)
THEN
220 IF (
ivac .le. 2)
then
227 IF (ivacskip .eq. 0)
THEN
228 nvacskip = one/max(1.e-1_dp, 1.e11_dp*(
fsqr+
fsqz))
230 nvacskip = max(nvacskip, nvskip0)
235 CALL convert (rmnc, zmns, lmns, rmns, zmnc, lmnc,
gc, ns)
240 if (ldump_vacuum_ref)
then
242 write(vac_file,
"(A,I6.6,A)")
"vac_ref/vacin_"//trim(
input_extension)//
"_", &
257 if (lexternal_nestor)
then
258 write(vac_file,
"(A,I6.6,A)")
"vac/vacin_"//trim(
input_extension)//
"_", &
273 if (.not. lexternal_nestor)
then
274 if (vac_1_2 .eq. 1)
then
276 CALL vacuum (rmnc, rmns, zmns, zmnc,
xm,
xn, &
289 stop
"vac_1_2 not available. Un-comment vac2 and vac3 folder inclusion in main CMakeLists.txt"// &
290 " and comment in call to vac2_vacuum and vac3_vacuum in src/funct3d.f90 to enable it."
294 write(nestor_cmd,
"(A,X,A)") trim(nestor_executable), trim(vac_file)
298 call system(nestor_cmd)
303 if (ldump_vacuum_ref)
then
305 write(vac_file,
"(A,I6.6,A)")
"vac_ref/vacout_ref_"//trim(
input_extension)//
"_", &
313 if (lexternal_nestor)
then
315 write(vac_file,
"(A,I6.6,A)")
"vac/vacout_"//trim(
input_extension)//
"_", &
329 IF (ier_flag .ne. 0)
then
335 IF (
ivac .eq. 1)
THEN
352 presf_ns = pmass(
hs*(ns-1.5_dp))
353 IF (presf_ns .ne. zero)
then
354 presf_ns = (pmass(1._dp)/presf_ns) *
pres(ns)
381 call add_real_2d(
"rbsq",
nzeta, ntheta3,
rbsq)
385 IF (
ivac .eq. 1)
THEN
394 IF (
iequi .NE. 1)
THEN
407 call add_real_3d(
"rcon", ns,
nzeta, ntheta3,
rcon(:nrzt,0))
408 call add_real_3d(
"rcon0", ns,
nzeta, ntheta3,
rcon0(:nrzt))
409 call add_real_3d(
"ru0", ns,
nzeta, ntheta3,
ru0(:nrzt))
411 call add_real_3d(
"zcon", ns,
nzeta, ntheta3,
zcon(:nrzt,0))
412 call add_real_3d(
"zcon0", ns,
nzeta, ntheta3,
zcon0(:nrzt))
413 call add_real_3d(
"zu0", ns,
nzeta, ntheta3,
zu0(:nrzt))
415 call add_real_3d(
"extra1", ns,
nzeta, ntheta3,
extra1(:,0))
416 call add_real_3d(
"gcon", ns,
nzeta, ntheta3,
gcon )
418 call add_real_3d(
"gcs", ns, ntor1,
mpol,
gc(0*mns+1:1*mns))
419 call add_real_3d(
"gsc", ns, ntor1,
mpol,
gc(1*mns+1:2*mns))
420 call add_real_3d(
"gcc", ns, ntor1,
mpol,
gc(2*mns+1:3*mns))
421 call add_real_3d(
"gss", ns, ntor1,
mpol,
extra1(:,1))
431 CALL symforce (
armn,
brmn,
crmn,
azmn,
bzmn,
czmn,
blmn,
clmn,
rcon,
zcon, &
subroutine alias(gcons, ztemp, gcs, gsc, gcc, gss)
Fourier-space bandpass filter on constraint force for spectral condensation.
subroutine bcovar(lu, lv)
Compute the covariant components of the magnetic field , .
subroutine convert(rmnc, zmns, lmns, rmns, zmnc, lmnc, rzl_array, js)
Convert internal mode representation to standard form for output (coefficients of cos(mu-nv),...
subroutine forces
Compute the real-space MHD forces.
subroutine funct3d(ier_flag)
Evaluate the three-dimensional MHD energy functional. Think of this as the "forward model" that tells...
subroutine jacobian
Evaulate the Jacobian of the transform from flux- to cylindrical coordinates.
logical function open_dbg_context(context_name, repetition, id)
check if any output is desired for the current iteration check if the given context should be openend...
Input and Output for stand-alone NESTOR.
subroutine write_nestor_outputs(vac_file, lasym, ivac, ier_flag)
real(dp), dimension(:), allocatable extcur
character(len=255) input_extension
real(dp), dimension(:), allocatable xn
real(dp), dimension(:), allocatable xm
character(len=255) mgrid_file
real(rprec), dimension(:,:), allocatable rv
real(rprec), dimension(:), allocatable zu0
, even-m and odd-m added together appropriately
real(rprec), dimension(:), allocatable wint
two-dimensional array for normalizing angle integrations
real(rprec), dimension(:,:), allocatable zv
real(rprec), dimension(:,:), allocatable zcon
spectral condensation term in
real(rprec), dimension(:,:), allocatable ru
real(rprec), dimension(:), allocatable sqrts
sqrt(s), two-dimensional array on full-grid
real(rprec), dimension(:,:), allocatable, target extra3
real(rprec), dimension(:,:), allocatable, target extra4
real(rprec), dimension(:,:), allocatable, target extra1
real(rprec), dimension(:), allocatable ru0
, even-m and odd-m added together appropriately
real(rprec), dimension(:), allocatable gcon
spectral condensation force; "alias force"
real(rprec), dimension(:,:), allocatable, target z1
real(rprec), dimension(:,:), allocatable rcon
spectral condensation term in
real(rprec), dimension(:), allocatable rcon0
spectral condensation term in at start of current multi-grid iteration
real(rprec), dimension(:,:), allocatable r1
real(rprec), dimension(:,:), allocatable, target extra2
real(rprec), dimension(:), allocatable zcon0
spectral condensation term in at start of current multi-grid iteration
real(rprec), dimension(:,:), allocatable zu
real(rprec), dimension(:), allocatable bsqvac
real(rprec), dimension(:), allocatable bvecsav
real(rprec), dimension(:), allocatable amatsav
real(rprec), dimension(:), allocatable, target clmn
real(rprec), dimension(:), allocatable, target azmn
real(rprec), dimension(:), allocatable, target brmn_con
real(rprec), dimension(:), allocatable, target brmn
real(rprec), dimension(:), allocatable, target bzmn_con
real(rprec), dimension(:), allocatable, target blmn
real(rprec), dimension(:), allocatable, target armn
real(rprec), dimension(:), pointer bzmn_o
real(rprec), dimension(:), allocatable, target crmn
real(rprec), dimension(:), allocatable, target czmn
real(rprec), dimension(:), allocatable, target bzmn
integer irzloff
offset in xc array between R,Z,L components
real(rprec) rbtor
poloidal current at LCFS
real(rprec) hs
radial mesh size increment
integer iter1
number of iterations at which the currently active evolution was branched off from
real(rprec), dimension(:), allocatable dbsq
real(rprec) ctor
toroidal current (?)
real(rprec), dimension(:), allocatable rbsq
integer neqs
total number of equations to evolve (size of xc)
integer iequi
counter used to call -EQFOR- at end of run
integer first
"counter" monitoring sign of jacobian; resets R, Z, and Lambda when jacobian changes sign and decreas...
integer ivac
counts number of free-boundary iterations
real(rprec), dimension(:,:), allocatable bsqsav
real(rprec), dimension(:), allocatable pres
pressure profile
integer num_eqsolve_retries
integer iter2
total number of iterations
integer, parameter bad_jacobian_flag
real(rprec) signgs
sign of Jacobian : must be =1 (right-handed) or =-1 (left-handed)
integer ntmax
number of contributing Fourier basis function (can be 1, 2 or 4); assigned in read_indata()
real(rprec), dimension(:), allocatable gc_mhd
real(rprec), dimension(:), allocatable gc_con
real(rprec), dimension(:), allocatable gc
stacked array of R, Z, Lambda Spectral force coefficients (see above for stack order)
real(rprec), dimension(:), allocatable, target xc
stacked array of scaled R, Z, Lambda Fourier coefficients (see above for stack order)
real(rprec), dimension(:), allocatable scalxc
subroutine read_nestor_outputs(vac_file, ier_flag, ivac)
subroutine write_nestor_inputs(vac_file, vacuum_calls, ier_flag, mgrid_file, input_extension, ivacskip, ivac, nfp, ntor, mpol, nzeta, ntheta, mnmax, xm, xn, rmnc, zmns, rmns, zmnc, rbtor, ctor, lasym, signgs, extcur_nestor, raxis_nestor, zaxis_nestor, wint, nznt, amatsav, bvecsav, mnpd2, bsubvvac)
subroutine residue(gcr, gcz, gcl, fsqrz, old_fsqz)
Compute invariant residuals.
subroutine residue_con(gcr, gcz, gcl, fsqrz, old_fsqz)
Compute invariant residuals.
subroutine residue_mhd(gcr, gcz, gcl, fsqrz, old_fsqz)
Compute invariant residuals.
subroutine restart_iter(time_step)
Save current or restore previous good state vector and reduce time step.
subroutine symforce(ars, brs, crs, azs, bzs, czs, bls, cls, rcs, zcs, ara, bra, cra, aza, bza, cza, bla, cla, rca, zca)
Symmetrize forces on restricted interval so cos, sin integrals can be performed.
subroutine symrzl(r1s, rus, rvs, z1s, zus, zvs, lus, lvs, rcons, zcons, r1a, rua, rva, z1a, zua, zva, lua, lva, rcona, zcona)
Symmetrize , and .
subroutine tomnspa(frzl_array, armn, brmn, crmn, azmn, bzmn, czmn, blmn, clmn, arcon, azcon)
Fourier-transform anti-symmetric forces from real space to Fourier space.
subroutine tomnsps(frzl_array, armn, brmn, crmn, azmn, bzmn, czmn, blmn, clmn, arcon, azcon)
Fourier-transform symmetric forces from real space to Fourier space.
subroutine tomnspa_con(frzl_array, brmn_con, bzmn_con, arcon, azcon)
Fourier-transform anti-symmetric forces from real space to Fourier space.
subroutine tomnsps_con(frzl_array, brmn_con, bzmn_con, arcon, azcon)
Fourier-transform symmetric forces from real space to Fourier space.
subroutine totzspa(rzl_array, r11, ru1, rv1, z11, zu1, zv1, lu1, lv1, rcn1, zcn1)
Inverse-Fourier-transform anti-symmetric part of geometry from Fourier space to real space.
subroutine totzsps(rzl_array, r11, ru1, rv1, z11, zu1, zv1, lu1, lv1, rcn1, zcn1)
Inverse-Fourier-transform symmetric part of geometry from Fourier space to real space.
subroutine vacuum(rmnc, rmns, zmns, zmnc, xm, xn, plascur, rbtor, wint, ivac_skip, ivac, mnmax, ier_flag, lasym, signgs, raxis, zaxis)
Compute the vacuum contribution to the free-boundary energy functional.