VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
funct3d.f90
Go to the documentation of this file.
1
6
13SUBROUTINE funct3d (ier_flag)
14
15 USE vmec_main
16 USE vacmod, ONLY: bsqvac, amatsav, bvecsav, mnpd2, bsubvvac
19 USE realspace
20 USE vforces
21 USE xstuff
22 USE vparams, ONLY: twopi
23
24 use dbgout
25
26 IMPLICIT NONE
27
28 INTEGER, INTENT(inout) :: ier_flag
29
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
36
37 CHARACTER(LEN=255) :: vac_file
38 integer :: nvac, istat_vac
39
40 character(len=255) :: nestor_cmd
41
42! character(len=*), parameter :: nestor_executable = &
43! "/home/IPP-HGW/jons/work/code/educational_VMEC/build/bin/xnestor"
44
45! character(len=*), parameter :: nestor_executable = &
46! "/data2/jonathan/work/code/educational_VMEC/build/bin/xnestor"
47
48! character(len=*), parameter :: nestor_executable = &
49! "python3 /data/jonathan/work/code/NESTOR/src/main/python/NESTOR.py"
50
51 character(len=*), parameter :: nestor_executable = &
52 "python3 /data/jonathan/work/code/NESTOR/src/main/python/ooNESTOR.py"
53
54! character(len=*), parameter :: nestor_executable = &
55! "python3 /home/IPP-HGW/jons/work/code/NESTOR/src/main/python/NESTOR.py"
56
58 logical :: lexternal_nestor = .false.
59
61 logical :: ldump_vacuum_ref = .false.
62
63
64
65
66
67
68
69! funct3d_calls = funct3d_calls + 1
70
71 ! POINTER ALIASES
72 lu => czmn
73 lv => crmn
74
75 ! CONVERT ODD M TO 1/SQRT(S) INTERNAL REPRESENTATION
76 ! temprary use of gc (force) for scaled xc (position)
77 gc(:neqs) = xc(:neqs)*scalxc(:neqs)
78
79 if (open_dbg_context("totzsp_input", num_eqsolve_retries)) then
80 call add_real_5d("gc", 3, ntmax, ns, ntor1, mpol, gc(:neqs), order=(/ 3, 4, 5, 2, 1 /) )
81 call close_dbg_out()
82 end if
83
84 ! INVERSE FOURIER TRANSFORM TO S,THETA,ZETA SPACE
85 ! R, Z, AND LAMBDA ARRAYS IN FOURIER SPACE
86 ! FIRST, DO SYMMETRIC [ F(u,v) = F(-u,-v) ] PIECES
87 ! ON THE RANGE u = 0,pi and v = 0,2*pi
88 CALL totzsps (gc, r1, ru, rv, z1, zu, zv, lu, lv, rcon, zcon)
89
90 IF (lasym) THEN
91 ! ANTI-SYMMETRIC CONTRIBUTIONS TO INVERSE TRANSFORMS
92 CALL totzspa (gc, armn, brmn, extra3, &
93 azmn, bzmn, extra4, &
94 blmn, clmn, &
95 extra1, extra2 )
96
97 ! SUM SYMMETRIC, ANTISYMMETRIC PIECES APPROPRIATELY
98 ! TO GET R, Z, L, (AND RCON, ZCON) ON FULL RANGE OF u (0 to 2*pi)
99 CALL symrzl ( r1, ru, rv, z1, zu, zv, lu, lv, rcon, zcon, &
101 ENDIF
102
103 if (open_dbg_context("funct3d_geometry", num_eqsolve_retries)) then
104
105 call add_real_4d("r1", ns, 2, nzeta, ntheta3, r1, order=(/ 1, 3, 4, 2 /) ) ! in reality: ns, nzeta, ntheta3, 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 /) )
115
116 call close_dbg_out()
117 end if
118
119 ! now that we have the current real-space geometry, use the opportunity so do some analysis / statistics
120 ! --> at ns, sqrt(s)==1 --> no need to scale r1(ns or l0pi, 1) by sqrt(s) anymore
121
122 router = r1(ns,0) + r1(ns,1) ! index ns corresponds to (u=0, v=0, js=ns)
123
124 ! l0pi is the index corresponding to (u = pi, v = 0, js = ns) (?)
125 l0pi = ns*(1 + nzeta*(ntheta2 - 1))
126 rinner = r1(l0pi,0) + r1(l0pi,1)
127
128 r00 = r1(1,0) ! contrib from only even m since sqrt(s)=0 at axis
129 z00 = z1(1,0) ! contrib from only even m since sqrt(s)=0 at axis
130
131! print *, "r00 = ", r00
132
133 ! COMPUTE CONSTRAINT RCON, ZCON
134
135 ! --> see Hirshman, Schwenn & Nührenberg: summation of even-m and odd-m*sqrt(s)
136
137! #ifndef _HBANGLE
138 ! odd-m entries need to be scaled appropriately
139 rcon(:nrzt,0) = rcon(:nrzt,0) + rcon(:nrzt,1)*sqrts(:nrzt)
140 zcon(:nrzt,0) = zcon(:nrzt,0) + zcon(:nrzt,1)*sqrts(:nrzt)
141! #end /* ndef _HBANGLE */
142
143 ! Assemble dR/du and dZ/du, since they are needed for arnorm, aznorm in bcovar() and for guess_axis().
144 ! Must store them in separate arrays ru0, zu0 since separation into even-m and odd-m
145 ! must be kept for e.g jacobian and metric elements (I guess...).
146 ru0(:nrzt) = ru(:nrzt,0) + ru(:nrzt,1)*sqrts(:nrzt)
147 zu0(:nrzt) = zu(:nrzt,0) + zu(:nrzt,1)*sqrts(:nrzt)
148
149 IF (iter2.eq.iter1 .and. ivac.le.0) THEN
150
151! print *, "rcon0 <-- (rcon * s) into volume"
152 ! iter2 == iter1 is true at start of a new multi-grid iteration
153 ! ivac .le. 0 is always true for fixed-boundary,
154 ! but only true for first iteration in free-boundary (?)
155
156 ! COMPUTE RCON0, ZCON0 FOR FIXED BOUNDARY BY SCALING EDGE VALUES
157 ! SCALE BY POWER OF SQRTS, RATHER THAN USE rcon0 = rcon, etc.
158 ! THIS PREVENTS A DISCONTINUITY WHEN RESTARTING FIXED BOUNDARY WITH NEW RCON0....
159 !
160 ! NOTE: IN ORDER TO MAKE INITIAL CONSTRAINT FORCES SAME FOR FREE/FIXED
161 ! BOUNDARY, WE SET RCON0,ZCON0 THE SAME INITIALLY, BUT TURN THEM OFF
162 ! SLOWLY IN FREE-BOUNDARY VACUUM LOOP (BELOW)
163 DO l = 1, ns
164 ! value of rcon(ns) is scaled into the volume proportional to s
165 rcon0(l:nrzt:ns) = rcon(ns:nrzt:ns,0) * sqrts(l:nrzt:ns)**2.0_dp
166 zcon0(l:nrzt:ns) = zcon(ns:nrzt:ns,0) * sqrts(l:nrzt:ns)**2.0_dp
167 END DO
168 ENDIF
169! #end /* ndef _HBANGLE */
170
171 ! COMPUTE S AND THETA DERIVATIVE OF R AND Z AND JACOBIAN ON HALF-GRID
172 CALL jacobian
173 IF (first.eq.2 .and. iequi.eq.0) then
174 ! bad jacobian and not final iteration yet (would be indicated by iequi.eq.1) --> need to restart
175 ! except when computing output file --> ignore bad jacobian
176 return
177 end if
178
179
180
181 ! NOTE: up to here, only worked on geometry so far...
182
183
184
185 ! COMPUTE COVARIANT COMPONENTS OF B, MAGNETIC AND KINETIC PRESSURE,
186 ! AND METRIC ELEMENTS ON HALF-GRID
187 CALL bcovar (lu, lv)
188
189 ! NOTE: If iequi .eq. 1, nothing of the code below is actually executed anymore!
190
191 ! COMPUTE VACUUM MAGNETIC PRESSURE AT PLASMA EDGE
192 ! NOTE: FOR FREE BOUNDARY RUNS, THE VALUE OF RBTOR=R*BTOR AT THE PLASMA EDGE
193 ! SHOULD BE ADJUSTED TO APPROXIMATELY EQUAL THE VACUUM VALUE.
194 ! THIS CAN BE DONE BY CHANGING EITHER PHIEDGE OR THE INITIAL CROSS SECTION
195 ! ACCORDING TO THE SCALING LAW R*BTOR .EQ. PHIEDGE/(R1 * Z1).
196 IF (lfreeb .and. iter2.gt.1 .and. iequi.eq.0) THEN
197
198 IF ((fsqr + fsqz) .le. 1.e-3_dp) then
199 ! when R+Z force residuals are <1e-3, enable vacuum contribution
200 ! print *, "force residuals decreased sufficiently => increment ivac=",ivac
201
202 ! Initially, ivac is initialized to -1 by reset_params().
203 ! This does ivac=-1 --> ivac=0 to enable NESTOR at all.
204 ! Also, this then keeps incrementing ivac until eternity (or convergence...)
205
206 ivac = ivac+1 ! decreased from e-1 to e-3 - sph12/04
207 end if
208
209 IF (nvskip0 .eq. 0) then
210 ! only happens once at program startup?
211 nvskip0 = max(1, nvacskip)
212 end if
213
214 IF (ivac .ge. 0) THEN
215 ! IF INITIALLY ON, MUST TURN OFF rcon0, zcon0 SLOWLY
216 rcon0 = 0.9_dp*rcon0
217 zcon0 = 0.9_dp*zcon0
218
219 ivacskip = mod(iter2-iter1, nvacskip)
220 IF (ivac .le. 2) then
221 ivacskip = 0
222 ! vacuum pressure not turned on yet (?)
223 ! and do full vacuum calc on every iteration
224 end if
225
226 ! EXTEND NVACSKIP AS EQUILIBRIUM CONVERGES
227 IF (ivacskip .eq. 0) THEN
228 nvacskip = one/max(1.e-1_dp, 1.e11_dp*(fsqr+fsqz))
229 ! print *, "suggested nvacskip: ",nvacskip
230 nvacskip = max(nvacskip, nvskip0)
231 END IF
232
233 ! NOTE: gc contains correct edge values of r,z,l arrays
234 ! convert_sym, convert_asym have been applied to m=1 modes
235 CALL convert (rmnc, zmns, lmns, rmns, zmnc, lmnc, gc, ns)
236
237 ! raxis_nestor(1:nzeta) = r1(1:ns*nzeta:ns,0)
238 ! zaxis_nestor(1:nzeta) = z1(1:ns*nzeta:ns,0)
239
240 if (ldump_vacuum_ref) then
241 ! build filename for NESTOR inputs
242 write(vac_file, "(A,I6.6,A)") "vac_ref/vacin_"//trim(input_extension)//"_", &
243 vacuum_calls, ".nc"
244
245 ! write NESTOR inputs
246 call write_nestor_inputs(trim(vac_file), &
247 vacuum_calls, ier_flag, trim(mgrid_file), trim(input_extension), &
248 ivacskip, ivac, nfp, ntor, mpol, nzeta, ntheta, &
249 mnmax, xm, xn, rmnc, zmns, rmns, zmnc, &
251 r1(1:ns*nzeta:ns,0), z1(1:ns*nzeta:ns,0), wint(ns:nznt*ns:ns), nznt, &
252 amatsav, bvecsav, mnpd2, bsubvvac)
253
254 ! print *, "dumped reference NESTOR inputs to '"//trim(vac_file)//"'"
255 end if
256
257 if (lexternal_nestor) then
258 write(vac_file, "(A,I6.6,A)") "vac/vacin_"//trim(input_extension)//"_", &
259 vacuum_calls, ".nc"
260
261 ! write NESTOR inputs
262 call write_nestor_inputs(trim(vac_file), &
263 vacuum_calls, ier_flag, trim(mgrid_file), trim(input_extension), &
264 ivacskip, ivac, nfp, ntor, mpol, nzeta, ntheta, &
265 mnmax, xm, xn, rmnc, zmns, rmns, zmnc, &
267 r1(1:ns*nzeta:ns,0), z1(1:ns*nzeta:ns,0), wint(ns:nznt*ns:ns), nznt, &
268 amatsav, bvecsav, mnpd2, bsubvvac)
269
270 ! print *, "dumped NESTOR inputs to '"//trim(vac_file)//"'"
271 end if
272
273 if (.not. lexternal_nestor) then
274 if (vac_1_2 .eq. 1) then
275 ! vac1: use default NESTOR
276 CALL vacuum (rmnc, rmns, zmns, zmnc, xm, xn, &
277 ctor, rbtor, wint(ns:nznt*ns:ns), ivacskip, ivac, mnmax, ier_flag, &
278 lasym, signgs, r1(1:ns*nzeta:ns,0), z1(1:ns*nzeta:ns,0))
279 else
280! if (ntor .gt. 0) then ! Stellarator version
281! ! vac2: fully 3d case (does not work for axisymmetric case)
282! call vac2_vacuum(rmnc, rmns, zmns, zmnc, xm, xn, &
283! ctor, rbtor, ivacskip, ivac, mnmax, ntheta3)
284! else ! ntor == 0 --> Tokamak version
285! ! axisymmetric special case
286! call vac3_vacuum(rmnc, rmns, zmns, zmnc, xm, &
287! ctor, ivacskip, ivac, mnmax)
288! end if ! ntor .gt. 0
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."
291 end if ! vac_1_2
292 else ! lexternal_nestor
293 ! construct command with argument for stand-alone external NESTOR
294 write(nestor_cmd, "(A,X,A)") trim(nestor_executable), trim(vac_file)
295
296 ! do system call to external NESTOR
297 !print *, "NESTOR command: '",trim(nestor_cmd),"'"
298 call system(nestor_cmd)
299
300 !print *, "system call to NESTOR finished"
301 end if ! lexternal_nestor
302
303 if (ldump_vacuum_ref) then
304 ! construct filename for reference NESTOR output
305 write(vac_file, "(A,I6.6,A)") "vac_ref/vacout_ref_"//trim(input_extension)//"_", &
306 vacuum_calls, ".nc"
307
308 call write_nestor_outputs(vac_file, lasym, ivac, ier_flag)
309
310 ! print *, "dumped reference NESTOR outputs to '"//trim(vac_file)//"'"
311 end if
312
313 if (lexternal_nestor) then
314 ! contruct filename from which to read output of stand-alone NESTOR
315 write(vac_file, "(A,I6.6,A)") "vac/vacout_"//trim(input_extension)//"_", &
316 vacuum_calls, ".nc"
317
318 !print *, "read NESTOR output from '"//trim(vac_file)//"'"
319
320 ! read output of external NESTOR
321 call read_nestor_outputs(trim(vac_file), ier_flag, ivac)
322 !print *, "read in NESTOR output: ivac=",ivac," ier_flag=",ier_flag
323
324 end if
325
326 ! update counter for calls to NESTOR (initialized to 0 in reset_params)
328
329 IF (ier_flag .ne. 0) then
330 ! some error occured within NESTOR, so cancel the iterations
331 return
332 end if
333
334 ! RESET FIRST TIME FOR SOFT START
335 IF (ivac .eq. 1) THEN
336 first = 2
337
338 ! delt0 is never used --> ignore change to time step by restart_iter
339 ! TODO: Since delt0 is never used and also nothing else is modified in restart_iter,
340 ! why bother which value it has on entry to restart_iter?
341 delt0 = delt
342 CALL restart_iter(delt0)
343 first = 1 ! already done in restart_iter for first.eq.2
344 END IF
345
346 ! IN CASE PRESSURE IS NOT ZERO AT EXTRAPOLATED EDGE...
347 ! UNCOMMENT ALL "RPRES" COMMENTS HERE AND IN BCOVAR, FORCES ROUTINES
348 ! IF NON-VARIATIONAL FORCES ARE DESIRED
349 !
350 ! presf_ns = 1.5_dp*pres(ns) - 0.5_dp*pres(ns1)
351 ! MUST NOT BREAK TRI-DIAGONAL RADIAL COUPLING: OFFENDS PRECONDITIONER!
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)
355 end if
356
357 lk = 0
358 DO l = ns, nrzt, ns ! loop over all points on LCFS
359 lk = lk + 1
360
361 ! current extrapolation to LCFS of plasma magnetic field
362 bsqsav(lk,3) = 1.5_dp*bzmn_o(l) - 0.5_dp*bzmn_o(l-1)
363
364 ! total pressure (?) at LCFS
365 ! (gcon(l) is only used as a temporary variable here,
366 ! since it immediately gets overwritten when entering alias())
367 gcon(l) = bsqvac(lk) + presf_ns
368
369 ! edge force contribution (see forces())
370 ! --> *HERE* is where the free-boundary computation enters VMEC !
371 rbsq(lk) = gcon(l)*(r1(l,0) + r1(l,1))*ohs
372
373 ! residual magnetic field discontinuity at LCFS
374 ! --> used in last column of printout (as flux surface avg.; relative to <bsqsav>)
375 dbsq(lk) = abs(gcon(l)-bsqsav(lk,3))
376 END DO
377
378 !print *, "max bsqvac = ", maxval(bsqvac)
379
380 if (open_dbg_context("rbsq", num_eqsolve_retries)) then
381 call add_real_2d("rbsq", nzeta, ntheta3, rbsq)
382 call close_dbg_out()
383 end if
384
385 IF (ivac .eq. 1) THEN
386! print *,"bsqsav(:,1:2) are filled now"
387 bsqsav(:nznt,1) = bzmn_o(ns:nrzt:ns) ! initial magnetic field at boundary
388 bsqsav(:nznt,2) = bsqvac(:nznt) ! initial NESTOR |B|^2 at boundary
389 ENDIF
390
391 ENDIF ! ivac .ge. 0
392 ENDIF ! free-boundary contribution
393
394 IF (iequi .NE. 1) THEN
395 ! normal iterations, not final call from fileout (which sets iequi=1)
396
397! #ifndef _HBANGLE
398 ! COMPUTE CONSTRAINT FORCE
399 extra1(:nrzt,0) = (rcon(:nrzt,0) - rcon0(:nrzt))*ru0(:nrzt) &
400 + (zcon(:nrzt,0) - zcon0(:nrzt))*zu0(:nrzt)
401 ! Fourier-space filter: only retain m=1, ..., (mpol1-1)==mpol-2 in gcon
402 CALL alias (gcon, extra1(:,0), gc, gc(1+mns), gc(1+2*mns), extra1(:,1)) ! temporary re-use of extra1(:,1) for g_ss
403! #end /* ndef _HBANGLE */
404
405 if (open_dbg_context("constraint_force", num_eqsolve_retries)) then
406
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))
410
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))
414
415 call add_real_3d("extra1", ns, nzeta, ntheta3, extra1(:,0))
416 call add_real_3d("gcon", ns, nzeta, ntheta3, gcon )
417
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))
422
423 call close_dbg_out()
424 end if
425
426 ! COMPUTE MHD FORCES ON INTEGER-MESH
427 CALL forces
428
429 ! SYMMETRIZE FORCES (in u-v space): NOTE - gc IS SMALL BY FACTOR 2 IF lasym=T
430 IF (lasym) THEN
431 CALL symforce (armn, brmn, crmn, azmn, bzmn, czmn, blmn, clmn, rcon, zcon, &
432 r1, ru, rv, z1, zu, zv, extra3, extra4, extra1, extra2 )
433
434 ! NOT NECESSARY (EVEN THOUGH CORRECT) --> why?
435 !gc = 2*gc
436 END IF
437
438 ! FOURIER-TRANSFORM MHD FORCES TO (M,N)-SPACE
439 ! Note that gc is immediately zeroed on entry,
440 ! so above use of gc is only for temporary values inside alias() !
441 CALL tomnsps (gc, &
442 armn, brmn, crmn, &
443 azmn, bzmn, czmn, &
444 blmn, clmn, rcon, zcon)
446 IF (lasym) then
447 CALL tomnspa (gc, &
448 r1, ru, rv, &
449 z1, zu, zv, &
452 end if
453
454 IF (lasym) THEN
455 ! NOT NECESSARY (EVEN THOUGH CORRECT) --> why?
456 !gc = 2*gc
457 !gc_con = 2*gc_con
458 end if
459
460
461
462 ! COMPUTE FORCE RESIDUALS (RAW AND PRECONDITIONED)
463 gc = gc * scalxc !!IS THIS CORRECT: SPH010214?
465 gc_mhd = gc - gc_con
466
467 fsqrz = fsqr + fsqz
468 old_fsqz = fsqz
469
470 CALL residue (gc, gc(1+irzloff), gc(1+2*irzloff), fsqrz, old_fsqz)
471 call residue_con(gc_con, gc_con(1+irzloff), gc_con(1+2*irzloff), fsqrz, old_fsqz)
472 call residue_mhd(gc_mhd, gc_mhd(1+irzloff), gc_mhd(1+2*irzloff), fsqrz, old_fsqz)
473
474 IF (iter2.eq.1 .and. (fsqr+fsqz+fsql).gt.1.e2_dp) then
475 ! first iteration and gigantic force residuals --> what is going one here?
476 first = 4 ! fatal error
477 end if
478
479! ELSE
480 ! iequi == 1 --> skip above remainder of funct3d
481 END IF
482
483END SUBROUTINE funct3d
subroutine alias(gcons, ztemp, gcs, gsc, gcc, gss)
Fourier-space bandpass filter on constraint force for spectral condensation.
Definition alias.f90:15
subroutine bcovar(lu, lv)
Compute the covariant components of the magnetic field , .
Definition bcovar.f90:9
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),...
Definition convert.f90:17
subroutine forces
Compute the real-space MHD forces.
Definition forces.f90:7
subroutine funct3d(ier_flag)
Evaluate the three-dimensional MHD energy functional. Think of this as the "forward model" that tells...
Definition funct3d.f90:14
subroutine jacobian
Evaulate the Jacobian of the transform from flux- to cylindrical coordinates.
Definition jacobian.f90:7
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...
Definition dbgout.f90:17
Input and Output for stand-alone NESTOR.
Definition nestor_io.f90:5
integer mnmax
Definition nestor_io.f90:31
integer nzeta
Definition nestor_io.f90:26
subroutine write_nestor_outputs(vac_file, lasym, ivac, ier_flag)
real(dp), dimension(:), allocatable extcur
Definition nestor_io.f90:11
integer ntor
Definition nestor_io.f90:23
character(len=255) input_extension
Definition nestor_io.f90:9
integer mpol
Definition nestor_io.f90:24
integer ntheta
Definition nestor_io.f90:25
logical lasym
Definition nestor_io.f90:34
integer nfp
Definition nestor_io.f90:22
real(dp), dimension(:), allocatable xn
Definition nestor_io.f90:15
real(dp), dimension(:), allocatable xm
Definition nestor_io.f90:14
character(len=255) mgrid_file
Definition nestor_io.f90:10
real(rprec), dimension(:,:), allocatable rv
Definition realspace.f90:10
real(rprec), dimension(:), allocatable zu0
, even-m and odd-m added together appropriately
Definition realspace.f90:25
real(rprec), dimension(:), allocatable wint
two-dimensional array for normalizing angle integrations
Definition realspace.f90:34
real(rprec), dimension(:,:), allocatable zv
Definition realspace.f90:13
real(rprec), dimension(:,:), allocatable zcon
spectral condensation term in
Definition realspace.f90:16
real(rprec), dimension(:,:), allocatable ru
Definition realspace.f90:9
real(rprec), dimension(:), allocatable sqrts
sqrt(s), two-dimensional array on full-grid
Definition realspace.f90:32
real(rprec), dimension(:,:), allocatable, target extra3
Definition realspace.f90:38
real(rprec), dimension(:,:), allocatable, target extra4
Definition realspace.f90:39
real(rprec), dimension(:,:), allocatable, target extra1
Definition realspace.f90:36
real(rprec), dimension(:), allocatable ru0
, even-m and odd-m added together appropriately
Definition realspace.f90:24
real(rprec), dimension(:), allocatable gcon
spectral condensation force; "alias force"
Definition realspace.f90:27
real(rprec), dimension(:,:), allocatable, target z1
Definition realspace.f90:11
real(rprec), dimension(:,:), allocatable rcon
spectral condensation term in
Definition realspace.f90:15
real(rprec), dimension(:), allocatable rcon0
spectral condensation term in at start of current multi-grid iteration
Definition realspace.f90:17
real(rprec), dimension(:,:), allocatable r1
Definition realspace.f90:8
real(rprec), dimension(:,:), allocatable, target extra2
Definition realspace.f90:37
real(rprec), dimension(:), allocatable zcon0
spectral condensation term in at start of current multi-grid iteration
Definition realspace.f90:18
real(rprec), dimension(:,:), allocatable zu
Definition realspace.f90:12
real(rprec), dimension(:), allocatable bsqvac
Definition vacmod.f90:43
real(rprec), dimension(:), allocatable bvecsav
Definition vacmod.f90:34
real(rprec), dimension(:), allocatable amatsav
Definition vacmod.f90:35
real(rprec) bsubvvac
Definition vacmod.f90:16
real(rprec), dimension(:), allocatable, target clmn
Definition vforces.f90:17
real(rprec), dimension(:), allocatable, target azmn
Definition vforces.f90:12
real(rprec), dimension(:), allocatable, target brmn_con
Definition vforces.f90:39
real(rprec), dimension(:), allocatable, target brmn
Definition vforces.f90:9
real(rprec), dimension(:), allocatable, target bzmn_con
Definition vforces.f90:40
real(rprec), dimension(:), allocatable, target blmn
Definition vforces.f90:16
real(rprec), dimension(:), allocatable, target armn
Definition vforces.f90:8
real(rprec), dimension(:), pointer bzmn_o
Definition vforces.f90:29
real(rprec), dimension(:), allocatable, target crmn
Definition vforces.f90:10
real(rprec), dimension(:), allocatable, target czmn
Definition vforces.f90:14
real(rprec), dimension(:), allocatable, target bzmn
Definition vforces.f90:13
integer irzloff
offset in xc array between R,Z,L components
real(rprec) rbtor
poloidal current at LCFS
real(rprec) fsql
Definition vmec_main.f90:96
real(rprec) hs
radial mesh size increment
Definition vmec_main.f90:84
integer iter1
number of iterations at which the currently active evolution was branched off from
real(rprec) fsqr
Definition vmec_main.f90:94
real(rprec) fsqz
Definition vmec_main.f90:95
real(rprec), dimension(:), allocatable dbsq
real(rprec) ctor
toroidal current (?)
real(rprec) ohs
Definition vmec_main.f90:87
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...
real(rprec) router
real(rprec) z00
Definition vmec_main.f90:91
real(rprec) r00
Definition vmec_main.f90:89
integer ivac
counts number of free-boundary iterations
real(rprec), dimension(:,:), allocatable bsqsav
Definition vmec_main.f90:73
real(rprec), dimension(:), allocatable pres
pressure profile
Definition vmec_main.f90:55
real(rprec) rinner
integer num_eqsolve_retries
integer vacuum_calls
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
Definition xstuff.f90:37
real(rprec), dimension(:), allocatable gc_con
Definition xstuff.f90:37
real(rprec), dimension(:), allocatable gc
stacked array of R, Z, Lambda Spectral force coefficients (see above for stack order)
Definition xstuff.f90:37
real(rprec), dimension(:), allocatable, target xc
stacked array of scaled R, Z, Lambda Fourier coefficients (see above for stack order)
Definition xstuff.f90:40
real(rprec), dimension(:), allocatable scalxc
Definition xstuff.f90:50
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.
Definition residue.f90:10
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.
Definition symforce.f90:30
subroutine symrzl(r1s, rus, rvs, z1s, zus, zvs, lus, lvs, rcons, zcons, r1a, rua, rva, z1a, zua, zva, lua, lva, rcona, zcona)
Symmetrize , and .
Definition symrzl.f90:28
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.
Definition tomnsp.f90:189
subroutine tomnsps(frzl_array, armn, brmn, crmn, azmn, bzmn, czmn, blmn, clmn, arcon, azcon)
Fourier-transform symmetric forces from real space to Fourier space.
Definition tomnsp.f90:22
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.
Definition totzsp.f90:257
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.
Definition totzsp.f90:33
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.
Definition vacuum.f90:27