VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
vmec_input.f90
Go to the documentation of this file.
1
3
4 USE vparams, ONLY: rprec, dp, mpol1d, ntord, ndatafmax
5 USE vsvd0
6
7 IMPLICIT NONE
8
9 INTEGER, PARAMETER :: mpol_default = 6
10 INTEGER, PARAMETER :: ntor_default = 0
11 INTEGER, PARAMETER :: ns_default = 31
12 INTEGER, PARAMETER :: niter_default = 100
13 REAL(rprec), PARAMETER :: ftol_default = 1.e-10_dp
14 integer, parameter :: num_iter2_to_dump = 20
15
16 INTEGER :: nfp
17 INTEGER :: ncurr
18 INTEGER :: nstep
19 INTEGER :: nvacskip
20 INTEGER :: mpol
21 INTEGER :: ntor
22 INTEGER :: ntheta
23 INTEGER :: nzeta
24 INTEGER :: mfilter_fbdy
25 INTEGER :: nfilter_fbdy
26
27 INTEGER, DIMENSION(100) :: ns_array
28 INTEGER, DIMENSION(100) :: niter_array
29 REAL(rprec), DIMENSION(100) :: ftol_array
30
31 REAL(rprec), DIMENSION(-ntord:ntord,0:mpol1d) :: rbc
32 REAL(rprec), DIMENSION(-ntord:ntord,0:mpol1d) :: zbs
33 REAL(rprec), DIMENSION(-ntord:ntord,0:mpol1d) :: rbs
34 REAL(rprec), DIMENSION(-ntord:ntord,0:mpol1d) :: zbc
35 REAL(rprec) :: curtor
36 REAL(rprec) :: delt
37 REAL(rprec) :: tcon0
38 REAL(rprec) :: gamma
39 REAL(rprec) :: bloat
40 REAL(rprec) :: pres_scale
41 REAL(rprec) :: spres_ped
42 REAL(rprec) :: phiedge
43 REAL(rprec), DIMENSION(0:20) :: am
44 REAL(rprec), DIMENSION(0:20) :: ai
45 REAL(rprec), DIMENSION(0:20) :: ac
47 REAL(rprec), DIMENSION(1:20) :: aphi
48 CHARACTER(len=20) :: pcurr_type
49 CHARACTER(len=20) :: piota_type
50 CHARACTER(len=20) :: pmass_type
51 REAL(rprec), DIMENSION(ndatafmax) :: am_aux_s
52 REAL(rprec), DIMENSION(ndatafmax) :: am_aux_f
53 REAL(rprec), DIMENSION(ndatafmax) :: ai_aux_s
54 REAL(rprec), DIMENSION(ndatafmax) :: ai_aux_f
55 REAL(rprec), DIMENSION(ndatafmax) :: ac_aux_s
56 REAL(rprec), DIMENSION(ndatafmax) :: ac_aux_f
57
58 REAL(rprec), DIMENSION(0:ntord) :: raxis_cc
59 REAL(rprec), DIMENSION(0:ntord) :: raxis_cs
60 REAL(rprec), DIMENSION(0:ntord) :: zaxis_cc
61 REAL(rprec), DIMENSION(0:ntord) :: zaxis_cs
62 REAL(rprec), DIMENSION(nigroup) :: extcur
63 LOGICAL :: lfreeb
64 LOGICAL :: lasym
65
70 integer :: vac_1_2
71
72 ! RESET lbsubs DEFAULT FLAG TO FALSE TO CAPTURE CURRENT SHEETS!
73 ! LOGICAL, PARAMETER :: lbsubs = .false. ! False to use (correct) bsubs calculation (from metrics)
74 ! ! True to use (modified) bsubs calculation (from mag. diff. eq.)
75 ! lbsubs is now a namelist input variable, so user can change.
76 ! LOGICAL, PARAMETER :: lbsubs = .true. ! True to use NEW bsubs calculation (from mag. diff. eq.)
77 ! ! False to use OLD bsubs calculation (from metrics)
78 LOGICAL :: lbsubs
79
80 CHARACTER(len=200) :: mgrid_file
81 CHARACTER(len=100) :: input_extension
82
83 ! debugging output
84
86 integer, dimension(num_iter2_to_dump) :: iter2_to_dump
87
90 logical :: dump_add_fluxes = .false.
91 logical :: dump_metric = .false.
92 logical :: dump_volume = .false.
93 logical :: dump_bcontrav = .false.
94 logical :: dump_bcov = .false.
95 logical :: dump_lambda_forces = .false.
96 logical :: dump_bcov_full = .false.
97 logical :: dump_precondn = .false.
98 logical :: dump_forcenorms_tcon = .false.
99 logical :: dump_lulv_comb = .false.
100 logical :: dump_calc_fbal = .false.
101 logical :: dump_evolve = .false.
102 logical :: dump_fixaray = .false.
103 logical :: dump_spectral_constraint = .false.
104 logical :: dump_forces = .false.
105 logical :: dump_totzsp_input = .false.
106 logical :: dump_funct3d_geometry = .false.
107 logical :: dump_constraint_force = .false.
108 logical :: dump_guess_axis = .false.
109 logical :: dump_interp = .false.
110 logical :: dump_jacobian = .false.
111 logical :: dump_lamcal = .false.
112 logical :: dump_profil1d = .false.
113 logical :: dump_profil3d = .false.
114 logical :: dump_readin_boundary = .false.
115 logical :: dump_phys_gc = .false.
116 logical :: dump_fsq = .false.
117 logical :: dump_scale_m1 = .false.
118 logical :: dump_scalfor_out = .false.
119 logical :: dump_fsq1 = .false.
120 logical :: dump_scalfor_r = .false.
121 logical :: dump_scalfor_z = .false.
122 logical :: dump_symforce = .false.
123 logical :: dump_tomnsps = .false.
124 logical :: dump_tomnspa = .false.
125 logical :: dump_multigrid_result = .false.
126 logical :: dump_rbsq = .false.
127 logical :: dump_printout = .false.
128
129 ! fileout
130 logical :: dump_bcovar_fileout = .false.
131 logical :: dump_bss = .false.
132 logical :: dump_jxbforce_bsub_lowpass = .false.
133 logical :: dump_jxbout = .false.
134 logical :: dump_mercier = .false.
135 logical :: dump_threed1_firsttable = .false.
136 logical :: dump_threed1_geomag = .false.
137 logical :: dump_threed1_volquant = .false.
138 logical :: dump_threed1_axis = .false.
139 logical :: dump_threed1_beta = .false.
140 logical :: dump_threed1_shafrint = .false.
141 logical :: dump_freeb_data = .false.
142
143 ! debugging output flags for NESTOR
144 logical :: dump_vac1n_vacuum = .false.
145 logical :: dump_vac1n_precal = .false.
146 logical :: dump_vac1n_surface = .false.
147 logical :: dump_vac1n_bextern = .false.
148 logical :: dump_vac1n_analyt = .false.
149 logical :: dump_vac1n_greenf = .false.
150 logical :: dump_vac1n_fourp = .false.
151 logical :: dump_vac1n_fouri = .false.
152 logical :: dump_vac1n_solver = .false.
153 logical :: dump_vac1n_bsqvac = .false.
154
155 logical :: dump_vac2_vacuum = .false.
156 logical :: dump_vac2_precal = .false.
157 logical :: dump_vac2_surface = .false.
158 logical :: dump_vac2_bexmat = .false.
159 logical :: dump_vac2_matrix = .false.
160 logical :: dump_vac2_foumat_unreg = .false.
161 logical :: dump_vac2_analin = .false.
162 logical :: dump_vac2_analyt = .false.
163 logical :: dump_vac2_foumat = .false.
164 logical :: dump_vac2_linsys = .false.
165 logical :: dump_vac2_linslv = .false.
166 logical :: dump_vac2_bsqvac = .false.
167
168
169
170 namelist /indata/ &
171 mgrid_file, &
172 nfp, &
173 ncurr, &
174 nstep, &
175 nvacskip, &
176 delt, &
177 gamma, &
178 am, &
179 ai, &
180 ac, &
181 aphi, &
182 pcurr_type, &
183 pmass_type, &
184 piota_type, &
185 bloat, &
186 am_aux_s, &
187 am_aux_f, &
188 ai_aux_s, &
189 ai_aux_f, &
190 ac_aux_s, &
191 ac_aux_f, &
192 rbc, &
193 zbs, &
194 rbs, &
195 zbc, &
196 spres_ped, &
197 pres_scale, &
198 raxis_cc, &
199 zaxis_cs, &
200 raxis_cs, &
201 zaxis_cc, &
202 mpol, &
203 ntor, &
204 ntheta, &
205 nzeta, &
206 mfilter_fbdy, &
207 nfilter_fbdy, &
208 niter_array, &
209 ns_array, &
210 ftol_array, &
211 tcon0, &
212 curtor, &
213 extcur, &
214 phiedge, &
215 lfreeb, &
216 lasym, &
217 lbsubs, &
218 vac_1_2, &
219 iter2_to_dump , & ! dbgout
221 dump_metric , &
222 dump_volume , &
223 dump_bcontrav , &
224 dump_bcov , &
227 dump_precondn , &
231 dump_evolve , &
232 dump_fixaray , &
234 dump_forces , &
239 dump_interp , &
240 dump_jacobian , &
241 dump_lamcal , &
242 dump_profil1d , &
243 dump_profil3d , &
245 dump_phys_gc , &
246 dump_fsq , &
247 dump_scale_m1 , &
249 dump_fsq1 , &
252 dump_symforce , &
253 dump_tomnsps , &
254 dump_tomnspa , &
256 dump_rbsq , &
257 dump_printout , &
258 dump_bcovar_fileout , & ! dbgout from fileout
259 dump_bss , &
261 dump_jxbout , &
262 dump_mercier , &
270 dump_vac1n_vacuum , & ! NESTOR vac1
280 dump_vac2_vacuum , & ! NESTOR vac2
292
293
294CONTAINS
295
296SUBROUTINE read_indata_namelist (iunit, istat)
297 INTEGER, intent(in) :: iunit
298 INTEGER, intent(inout) :: istat
299
300 character(len=1000) :: line
301
302 ! INITIALIZATIONS
303 gamma = 0
304 spres_ped = 1
307 ntheta = 0
308 nzeta = 0
309
313
314 bloat = 1
315 rbc = 0
316 rbs = 0
317 zbs = 0
318 zbc = 0
319 nfp = 1
320 ncurr = 0
321 nstep = 10
322 nvacskip = 1
323 delt = 1
324
325 am = 0
326 ai = 0
327 ac = 0
328
329 aphi = 0
330 aphi(1) = 1
331
332 pres_scale = 1
333
334 raxis_cc = 0
335 zaxis_cs = 0
336 raxis_cs = 0
337 zaxis_cc = 0
338
339 mfilter_fbdy = -1
340 nfilter_fbdy = -1
341
342 tcon0 = 1
343 curtor = 0
344 extcur = 0
345 phiedge = 1
346
347 mgrid_file = 'NONE'
348
349 vac_1_2 = 1 ! vac1 NESTOR by default
350
351 lfreeb = .true.
352 lasym = .false.
353 lbsubs = .false.
354
355 pcurr_type = 'power_series'
356 piota_type = 'power_series'
357 pmass_type = 'power_series'
358
359 am_aux_s(:) = -1
360 ac_aux_s(:) = -1
361 ai_aux_s(:) = -1
362
363 ! by default, dump first two iterations
364 iter2_to_dump(:) = 0
365 iter2_to_dump(1) = 1
366 iter2_to_dump(2) = 2
367
368 READ (iunit, nml=indata, iostat=istat)
369
370 if (istat .ne. 0) then
371 ! help to debug invalid inputs:
372 ! re-read last line that lead to error and print it to screen
373 backspace(iunit)
374 read(iunit,fmt='(A)') line
375 write(*,'(A)') 'Invalid line in namelist: '//trim(line)
376 end if
377
378END SUBROUTINE read_indata_namelist
379
380
381SUBROUTINE write_indata_namelist (iunit, istat)
382 IMPLICIT NONE
383
384 INTEGER, INTENT(in) :: iunit
385 INTEGER, INTENT(inout) :: istat
386 INTEGER :: iftol,i,n,m
387 INTEGER, DIMENSION(1) :: ins
388 CHARACTER(LEN=*), PARAMETER :: outboo = "(2X,A,1X,'=',1X,L1)"
389 CHARACTER(LEN=*), PARAMETER :: outint = "(2X,A,1X,'=',1X,I0)"
390 CHARACTER(LEN=*), PARAMETER :: outint1 = "(2X,A,1X,'=',1X,I1.1)"
391 CHARACTER(LEN=*), PARAMETER :: outint2 = "(2X,A,1X,'=',1X,I2.2)"
392 CHARACTER(LEN=*), PARAMETER :: outint3 = "(2X,A,1X,'=',1X,I3.3)"
393 CHARACTER(LEN=*), PARAMETER :: outint4 = "(2X,A,1X,'=',1X,I4.4)"
394 CHARACTER(LEN=*), PARAMETER :: outint5 = "(2X,A,1X,'=',1X,I5.5)"
395 CHARACTER(LEN=*), PARAMETER :: outint6 = "(2X,A,1X,'=',1X,I6.6)"
396 CHARACTER(LEN=*), PARAMETER :: outflt="(2X,A,1X,'=',1X,ES22.12E3)"
397 CHARACTER(LEN=*), PARAMETER :: outexp="(2X,A,1X,'=',1X,ES22.12E3)"
398 IF (istat < 0) RETURN
399 WRITE(iunit,'(A)') '!----- Runtime Parameters -----'
400 WRITE(iunit,'(A)') '&INDATA'
401 WRITE(iunit,outflt) 'DELT',delt
402 WRITE(iunit,outint) 'NSTEP',nstep
403 WRITE(iunit,outflt) 'TCON0',tcon0
404 ins = maxloc(ns_array)
405 WRITE(iunit,'(a,(1p,4i14))') ' NS_ARRAY = ',(ns_array(i), i=1,ins(1))
406 iftol = 1
407 DO WHILE(ftol_array(iftol).ne.0 .and. iftol.lt.100)
408 iftol = iftol + 1
409 END DO
410 WRITE(iunit,'(a,(1p,4e14.6))')' FTOL_ARRAY = ',(ftol_array(i), i=1,iftol - 1)
411 ins = minloc(niter_array)
412 IF (ins(1) > 1) WRITE(iunit,'(a,(1p,4i14))') ' NITER_ARRAY = ',(niter_array(i), i=1,ins(1)-1)
413 WRITE(iunit,'(A)') '!----- Grid Parameters -----'
414 WRITE(iunit,outboo) 'LASYM',lasym
415 WRITE(iunit,outint4) 'NFP',nfp
416 WRITE(iunit,outint4) 'MPOL',mpol
417 WRITE(iunit,outint4) 'NTOR',ntor
418 WRITE(iunit,outflt) 'PHIEDGE',phiedge
419 WRITE(iunit,'(A)') '!----- Free Boundary Parameters -----'
420 WRITE(iunit,outboo) 'LFREEB',lfreeb
421 IF (lfreeb) THEN
422 WRITE (iunit, '(2x,3a)') "MGRID_FILE = '",trim(mgrid_file),"'"
423 WRITE(iunit,outint4) 'NZETA',nzeta
424 DO n=1,SIZE(extcur)
425 IF (extcur(n) == 0) cycle
426 WRITE(iunit,'(2X,A,I3.3,A,ES22.12E3)') 'EXTCUR(',n,') = ',extcur(n)
427 END DO
428 WRITE(iunit,outint4) 'NVACSKIP',nvacskip
429 END IF
430 WRITE(iunit,'(A)') '!----- Pressure Parameters -----'
431 WRITE(iunit,outflt) 'GAMMA',gamma
432 WRITE(iunit,outflt) 'BLOAT',bloat
433 WRITE(iunit,outflt) 'SPRES_PED',spres_ped
434 WRITE(iunit,outflt) 'PRES_SCALE',pres_scale
435 WRITE(iunit,'(2x,3a)') "PMASS_TYPE = '",trim(pmass_type),"'"
436 WRITE(iunit,'(a,(1p,4e22.14))')' AM = ', (am(i-1), i=1,SIZE(am))
437 i = minloc(am_aux_s(2:),dim=1)
438 IF (i > 4) THEN
439 WRITE (iunit,'(a,(1p,4ES22.12E3))') ' AM_AUX_S = ', (am_aux_s(n), n=1,i)
440 WRITE (iunit,'(a,(1p,4ES22.12E3))') ' AM_AUX_F = ', (am_aux_f(n), n=1,i)
441 END IF
442
443 WRITE(iunit,'(A)') '!----- Current/Iota Parameters -----'
444 WRITE(iunit,outexp) 'CURTOR',curtor
445 WRITE(iunit,outint) 'NCURR',ncurr
446 WRITE (iunit, '(2x,3a)') "PIOTA_TYPE = '",trim(piota_type),"'"
447 WRITE (iunit,'(a,(1p,4e22.14))') ' AI = ',(ai(n-1), n=1,SIZE(ai))
448 i = minloc(ai_aux_s(2:),dim=1)
449 IF (i > 4) THEN
450 WRITE (iunit,'(a,(1p,4ES22.12E3))') ' AI_AUX_S = ', (ai_aux_s(n), n=1,i)
451 WRITE (iunit,'(a,(1p,4ES22.12E3))') ' AI_AUX_F = ', (ai_aux_f(n), n=1,i)
452 END IF
453 WRITE (iunit, '(2x,3a)') "PCURR_TYPE = '",trim(pcurr_type),"'"
454 WRITE (iunit,'(a,(1p,4ES22.12E3))') ' AC = ',(ac(n-1), n=1,SIZE(ac))
455 i = minloc(ac_aux_s(2:),dim=1)
456 IF (i > 4) THEN
457 WRITE (iunit,'(a,(1p,4ES22.12E3))') ' AC_AUX_S = ', (ac_aux_s(n), n=1,i)
458 WRITE (iunit,'(a,(1p,4ES22.12E3))') ' AC_AUX_F = ', (ac_aux_f(n), n=1,i)
459 END IF
460
461 WRITE(iunit,'(A)') '!----- Axis Parameters ----- '
462 WRITE (iunit,'(a,(1p,4e22.14))') ' RAXIS_CC = ',(raxis_cc(n), n=0,ntor)
463 IF (lasym) then
464 WRITE (iunit,'(a,(1p,4ES22.12E3))') ' RAXIS_CS = ',(raxis_cs(n), n=0,ntor)
465 WRITE (iunit,'(a,(1p,4ES22.12E3))') ' ZAXIS_CC = ',(zaxis_cc(n), n=0,ntor)
466 end if
467 WRITE (iunit,'(a,(1p,4ES22.12E3))') ' ZAXIS_CS = ',(zaxis_cs(n), n=0,ntor)
468
469 WRITE(iunit,'(A)') '!----- Boundary Parameters -----'
470 DO m = 0, mpol - 1
471 DO n = -ntor, ntor
472 IF ((rbc(n,m).ne.0) .or. (zbs(n,m).ne.0)) THEN
473 WRITE(iunit,'(2(A,I4.3,A,I3.3,A,ES22.12E3))') &
474 ' RBC(',n,',',m,') = ',rbc(n,m),' ZBS(',n,',',m,') = ',zbs(n,m)
475 IF (lasym) then
476 WRITE(iunit,'(2(A,I4.3,A,I3.3,A,ES22.12E3))') &
477 ' RBS(',n,',',m,') = ',rbs(n,m),' ZBC(',n,',',m,') = ',zbc(n,m)
478 end if
479 END IF
480 END DO
481 END DO
482
483 WRITE(iunit,'(A)') '/'
484
485 RETURN
486
487END SUBROUTINE write_indata_namelist
488
489END MODULE vmec_input
logical dump_vac2_analyt
logical dump_vac2_surface
subroutine read_indata_namelist(iunit, istat)
logical dump_threed1_axis
logical dump_rbsq
logical dump_scalfor_out
real(rprec), dimension(1:20) aphi
logical dump_vac2_matrix
logical dump_printout
real(rprec), dimension(0:20) ac
array of coefficients in phi-series for the quantity d(Icurv)/ds = toroidal current density * Vprime,...
logical dump_vac1n_fourp
logical dump_scalfor_z
logical dump_add_fluxes
individual flags to control debug output loosely related to similarly-named routines (checkpoints alo...
logical dump_mercier
logical dump_guess_axis
logical dump_spectral_constraint
logical dump_fixaray
real(rprec) pres_scale
logical dump_vac2_precal
logical dump_vac2_analin
real(rprec) curtor
logical dump_precondn
logical dump_vac1n_precal
logical dump_vac1n_vacuum
logical dump_vac2_foumat
logical lfreeb
character(len=20) pcurr_type
real(rprec) delt
integer ntheta
logical dump_vac1n_bextern
logical dump_vac1n_fouri
logical dump_freeb_data
real(rprec), dimension(ndatafmax) ac_aux_f
subroutine write_indata_namelist(iunit, istat)
logical dump_fsq1
logical dump_jxbout
logical dump_lambda_forces
real(rprec), dimension(ndatafmax) ai_aux_s
logical dump_funct3d_geometry
logical dump_jacobian
logical dump_evolve
real(rprec), dimension(-ntord:ntord, 0:mpol1d) zbs
logical dump_vac2_vacuum
logical dump_readin_boundary
logical dump_vac2_bexmat
character(len=20) pmass_type
logical dump_bcov_full
real(rprec) gamma
real(rprec), dimension(ndatafmax) am_aux_s
character(len=20) piota_type
logical dump_vac2_linslv
logical dump_volume
logical dump_symforce
logical dump_fsq
logical dump_multigrid_result
logical dump_threed1_firsttable
real(rprec), dimension(ndatafmax) ai_aux_f
logical dump_bcov
integer, parameter mpol_default
Definition vmec_input.f90:9
logical dump_totzsp_input
logical dump_tomnsps
logical dump_lamcal
real(rprec), dimension(0:20) am
array of coefficients in phi-series for mass (NWT/m**2)
real(rprec), dimension(ndatafmax) am_aux_f
real(rprec), dimension(-ntord:ntord, 0:mpol1d) zbc
logical dump_tomnspa
logical dump_vac1n_surface
logical dump_forces
logical dump_calc_fbal
real(rprec), dimension(0:ntord) raxis_cs
real(rprec) bloat
real(rprec), dimension(-ntord:ntord, 0:mpol1d) rbc
logical dump_constraint_force
character(len=200) mgrid_file
integer nvacskip
real(rprec), dimension(ndatafmax) ac_aux_s
logical dump_interp
character(len=100) input_extension
logical dump_vac1n_bsqvac
logical dump_threed1_beta
logical dump_scalfor_r
real(rprec), dimension(0:ntord) raxis_cc
integer, parameter num_iter2_to_dump
logical lasym
logical dump_phys_gc
logical dump_metric
logical dump_jxbforce_bsub_lowpass
real(rprec), dimension(nigroup) extcur
logical dump_bcovar_fileout
integer, dimension(100) niter_array
logical dump_vac2_foumat_unreg
logical dump_lulv_comb
real(rprec), dimension(0:20) ai
array of coefficients in phi-series for iota (ncurr=0)
real(rprec) phiedge
value of real toroidal flux at plasma edge (s=1)
integer nfp
logical dump_vac1n_solver
real(rprec) spres_ped
value of s beyond which pressure profile is flat (pedestal)
logical dump_vac1n_analyt
logical dump_vac2_bsqvac
logical dump_vac1n_greenf
logical dump_forcenorms_tcon
logical dump_profil1d
integer, parameter ns_default
integer ntor
real(rprec) tcon0
logical dump_vac2_linsys
integer, dimension(num_iter2_to_dump) iter2_to_dump
values of iter2 for which to dump data
integer nzeta
logical dump_profil3d
integer mfilter_fbdy
real(rprec), parameter ftol_default
integer mpol
logical dump_bss
logical dump_scale_m1
real(rprec), dimension(0:ntord) zaxis_cs
real(rprec), dimension(100) ftol_array
logical lbsubs
logical dump_threed1_volquant
integer, parameter ntor_default
logical dump_bcontrav
integer nstep
real(rprec), dimension(0:ntord) zaxis_cc
integer vac_1_2
switch between implementations of NESTOR: vac1 (magnetic scalar potential, both Stellarator and Tokam...
real(rprec), dimension(-ntord:ntord, 0:mpol1d) rbs
integer, dimension(100) ns_array
integer ncurr
logical dump_threed1_shafrint
integer nfilter_fbdy
logical dump_threed1_geomag
integer, parameter niter_default
integer, parameter mpol1d
Definition vparams.f90:18
integer, parameter ndatafmax
Definition vparams.f90:15
integer, parameter ntord
maximum number of toroidal harmonics
Definition vparams.f90:14
Definition vsvd0.f90:2