VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
vmec_main.f90
Go to the documentation of this file.
1
3
4 USE vmec_dim
5 USE vmec_input
7 USE vmec_params, ONLY: ndamp
8 USE vparams
9
10 IMPLICIT NONE
11
12 ! 1d-preconditioner-related
13 REAL(rprec), DIMENSION(:), ALLOCATABLE :: blam
14 REAL(rprec), DIMENSION(:), ALLOCATABLE :: clam
15 REAL(rprec), DIMENSION(:), ALLOCATABLE :: dlam
16 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: ard
17 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: arm
18 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: brd
19 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: brm
20 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: azd
21 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: azm
22 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: bzd
23 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: bzm
24 REAL(rprec), DIMENSION(:), ALLOCATABLE :: crd
25 REAL(rprec), DIMENSION(:), ALLOCATABLE :: sm
26 REAL(rprec), DIMENSION(:), ALLOCATABLE :: sp
27 REAL(rprec), DIMENSION(:), ALLOCATABLE :: bdamp
28 REAL(rprec), DIMENSION(:,:,:,:), ALLOCATABLE :: faclam
29 REAL(rprec), DIMENSION(:,:,:,:), ALLOCATABLE :: faclam0
30
31 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: bmin
32 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: bmax
33
34 REAL(rprec), DIMENSION(:), ALLOCATABLE :: iotaf
35 REAL(rprec), DIMENSION(:), ALLOCATABLE :: phipf
36 REAL(rprec), DIMENSION(:), ALLOCATABLE :: chipf
37 REAL(rprec), DIMENSION(:), ALLOCATABLE :: phi
38 REAL(rprec), DIMENSION(:), ALLOCATABLE :: beta_vol
39 REAL(rprec), DIMENSION(:), ALLOCATABLE :: jcuru
40 REAL(rprec), DIMENSION(:), ALLOCATABLE :: jcurv
41 REAL(rprec), DIMENSION(:), ALLOCATABLE :: jdotb
42 REAL(rprec), DIMENSION(:), ALLOCATABLE :: buco
43 REAL(rprec), DIMENSION(:), ALLOCATABLE :: bvco
44 REAL(rprec), DIMENSION(:), ALLOCATABLE :: bdotgradv
45 REAL(rprec), DIMENSION(:), ALLOCATABLE :: equif
46 REAL(rprec), DIMENSION(:), ALLOCATABLE :: specw
47 REAL(rprec), DIMENSION(:), ALLOCATABLE :: tcon
48 REAL(rprec), DIMENSION(:), ALLOCATABLE :: psi
49 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: yellip
50 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: yinden
51 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: ytrian
52 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: yshift
53 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: ygeo
54 REAL(rprec), DIMENSION(:), ALLOCATABLE :: overr
55 REAL(rprec), DIMENSION(:), ALLOCATABLE :: pres
56 REAL(rprec), DIMENSION(:), ALLOCATABLE :: vp
57 REAL(rprec), DIMENSION(:), ALLOCATABLE :: jpar2
58 REAL(rprec), DIMENSION(:), ALLOCATABLE :: jperp2
59 REAL(rprec), DIMENSION(:), ALLOCATABLE :: bdotb
60 REAL(rprec), DIMENSION(:), ALLOCATABLE :: vpphi
61 REAL(rprec), DIMENSION(:), ALLOCATABLE :: presgrad
62 REAL(rprec), DIMENSION(:), ALLOCATABLE :: bucof
63 REAL(rprec), DIMENSION(:), ALLOCATABLE :: bvcof
64 REAL(rprec), DIMENSION(:), ALLOCATABLE :: chi
65
66 REAL(rprec), DIMENSION(:), ALLOCATABLE :: presf
67 REAL(rprec), DIMENSION(:), ALLOCATABLE :: chips
68 REAL(rprec), DIMENSION(:), ALLOCATABLE :: phips
69 REAL(rprec), DIMENSION(:), ALLOCATABLE :: iotas
70 REAL(rprec), DIMENSION(:), ALLOCATABLE :: icurv
71 REAL(rprec), DIMENSION(:), ALLOCATABLE :: mass
72
73 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: bsqsav
74
75 REAL(rprec), DIMENSION(:), ALLOCATABLE :: bredge
76 REAL(rprec), DIMENSION(:), ALLOCATABLE :: bpedge
77 REAL(rprec), DIMENSION(:), ALLOCATABLE :: bzedge
78
79 REAL(rprec), ALLOCATABLE :: xcl0(:)
80
81 REAL(rprec), DIMENSION(0:mpol1d,3) :: xmpq
82 REAL(rprec), DIMENSION(0:mpol1d) :: faccon
83
84 REAL(rprec) :: hs
85 REAL(rprec) :: currv
86 REAL(rprec) :: aspect
87 REAL(rprec) :: ohs
88 REAL(rprec) :: voli
89 REAL(rprec) :: r00
90 REAL(rprec) :: r0scale
91 REAL(rprec) :: z00
92 REAL(rprec) :: fsqsum0
93 REAL(rprec) :: fnorm
94 REAL(rprec) :: fsqr = 1.0_dp
95 REAL(rprec) :: fsqz = 1.0_dp
96 REAL(rprec) :: fsql = 1.0_dp
97 REAL(rprec) :: fnorm1
98 REAL(rprec) :: fnorml
99 REAL(rprec) :: fsqr1
100 REAL(rprec) :: fsqz1
101 REAL(rprec) :: fsql1
102 REAL(rprec) :: fsq
103 REAL(rprec) :: fedge
104 REAL(rprec) :: wb
105 REAL(rprec) :: wp
106
107 ! force residuals due to constraint force alone
108 REAL(rprec) :: fsqr_con = 1.0_dp
109 REAL(rprec) :: fsqz_con = 1.0_dp
110 REAL(rprec) :: fsqr1_con
111 REAL(rprec) :: fsqz1_con
112
113 ! force residuals due to MHD force alone
114 REAL(rprec) :: fsqr_mhd = 1.0_dp
115 REAL(rprec) :: fsqz_mhd = 1.0_dp
116 REAL(rprec) :: fsqr1_mhd
117 REAL(rprec) :: fsqz1_mhd
118
119 REAL(rprec) :: router
120 REAL(rprec) :: rinner
121
122 REAL(rprec) :: ftolv
123
125 REAL(rprec) :: otav
126 REAL(rprec), DIMENSION(ndamp) :: otau
127
128 REAL(rprec), DIMENSION(:,:,:), ALLOCATABLE, TARGET :: rmn_bdy
129 REAL(rprec), DIMENSION(:,:,:), ALLOCATABLE, TARGET :: zmn_bdy
130
131 REAL(rprec), DIMENSION(:), ALLOCATABLE :: bsubu0
132 REAL(rprec), DIMENSION(:), ALLOCATABLE :: dbsq
133 REAL(rprec), DIMENSION(:), ALLOCATABLE :: rbsq
134
135 REAL(rprec) :: rbtor
136 REAL(rprec) :: rbtor0
137 REAL(rprec) :: ctor
138 REAL(rprec) :: delbsq
139 REAL(rprec) :: res0
140 REAL(rprec) :: delt0r
141
142 LOGICAL :: lthreed
143 LOGICAL :: lconm1
144
145 LOGICAL :: lflip
146
147 INTEGER, DIMENSION(:), ALLOCATABLE :: ireflect
148 INTEGER :: multi_ns_grid
149
150 integer :: niterv
151
152 integer :: first
155
156 integer :: neqs
157 integer :: irzloff
158 integer :: iequi
159 integer :: ijacob
160 integer :: iter1
161 integer :: iter2
162 integer :: ivac
163
164 integer :: vacuum_calls
165! integer :: profil3d_calls
166! integer :: funct3d_calls
168
169END MODULE vmec_main
real(rprec), dimension(:), allocatable dlam
Definition vmec_main.f90:15
real(rprec), dimension(:), allocatable bredge
Definition vmec_main.f90:75
real(rprec), dimension(:), allocatable equif
radial force balance error: grad(p) - <j x B>
Definition vmec_main.f90:45
integer irzloff
offset in xc array between R,Z,L components
real(rprec) rbtor
poloidal current at LCFS
real(rprec), dimension(:,:), allocatable ygeo
Definition vmec_main.f90:53
real(rprec), dimension(:), allocatable vp
radial derivative of enclosed volume
Definition vmec_main.f90:56
real(rprec), dimension(:), allocatable bvco
enclosed poloidal current profile
Definition vmec_main.f90:43
real(rprec), dimension(:,:,:,:), allocatable faclam0
Definition vmec_main.f90:29
real(rprec), dimension(:), allocatable buco
enclosed toroidal current profile
Definition vmec_main.f90:42
real(rprec) fsqr_con
real(rprec), dimension(:), allocatable crd
Definition vmec_main.f90:24
real(rprec), dimension(:), allocatable sp
shalf(i+1)/sfull(i)
Definition vmec_main.f90:26
real(rprec) fsqz1
real(rprec) fsql
Definition vmec_main.f90:96
real(rprec), dimension(:,:), allocatable brd
Definition vmec_main.f90:18
real(rprec) fsq
real(rprec) fsqr1_con
real(rprec), dimension(:), allocatable jcuru
poloidal current density
Definition vmec_main.f90:39
real(rprec) wp
kinetic/thermal energy (from pressure)
real(rprec) hs
radial mesh size increment
Definition vmec_main.f90:84
real(rprec), dimension(:,:), allocatable azd
Definition vmec_main.f90:20
real(rprec), dimension(:,:), allocatable ytrian
Definition vmec_main.f90:51
real(rprec), dimension(:,:,:,:), allocatable faclam
Definition vmec_main.f90:28
real(rprec) ftolv
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 bmax
Definition vmec_main.f90:32
real(rprec), dimension(:), allocatable dbsq
real(rprec), dimension(:), allocatable chips
poloidal flux (same as chip), one-dimensional array
Definition vmec_main.f90:67
real(rprec) ctor
toroidal current (?)
real(rprec), dimension(:), allocatable presf
pressure profile on full-grid, mass/phip**gamma
Definition vmec_main.f90:66
real(rprec), dimension(:,:,:), allocatable, target zmn_bdy
real(rprec) fnorm
Definition vmec_main.f90:93
real(rprec) voli
total plasma volume in m^3
Definition vmec_main.f90:88
real(rprec) ohs
Definition vmec_main.f90:87
real(rprec), dimension(:), allocatable rbsq
real(rprec), dimension(:), allocatable bdamp
radial mesh-blending factor
Definition vmec_main.f90:27
real(rprec) delbsq
real(rprec), dimension(:), allocatable phi
toroidal magnetic flux
Definition vmec_main.f90:37
integer neqs
total number of equations to evolve (size of xc)
real(rprec), dimension(:), allocatable overr
Definition vmec_main.f90:54
real(rprec) fsqz1_con
real(rprec), dimension(:), allocatable sm
shalf(i)/sfull(i)
Definition vmec_main.f90:25
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), dimension(:,:), allocatable bmin
Definition vmec_main.f90:31
real(rprec) fsqsum0
Definition vmec_main.f90:92
real(rprec) z00
Definition vmec_main.f90:91
real(rprec), dimension(:,:), allocatable brm
Definition vmec_main.f90:19
real(rprec), dimension(ndamp) otau
real(rprec), dimension(:), allocatable jdotb
Definition vmec_main.f90:41
real(rprec) aspect
Definition vmec_main.f90:86
real(rprec) fsqr1_mhd
real(rprec) fsqz_mhd
real(rprec) fsqr_mhd
real(rprec), dimension(:,:), allocatable bzd
Definition vmec_main.f90:22
real(rprec) delt0r
real(rprec), dimension(:,:), allocatable bzm
Definition vmec_main.f90:23
real(rprec), dimension(:,:), allocatable yinden
Definition vmec_main.f90:50
real(rprec) fnorml
Definition vmec_main.f90:98
real(rprec) r00
Definition vmec_main.f90:89
real(rprec), dimension(:), allocatable bdotgradv
Definition vmec_main.f90:44
integer ivac
counts number of free-boundary iterations
real(rprec), dimension(:), allocatable clam
Definition vmec_main.f90:14
real(rprec), dimension(:), allocatable specw
spectral width (diagnostic)
Definition vmec_main.f90:46
real(rprec), dimension(:), allocatable iotaf
rotational transform (full grid)
Definition vmec_main.f90:34
real(rprec) otav
time-step algorithm
real(rprec), dimension(:,:), allocatable yshift
Definition vmec_main.f90:52
logical lconm1
real(rprec) rbtor0
poloidal current at magnetic axis
real(rprec), dimension(:), allocatable psi
Definition vmec_main.f90:48
real(rprec), dimension(:,:), allocatable ard
Definition vmec_main.f90:16
real(rprec), dimension(:,:), allocatable bsqsav
Definition vmec_main.f90:73
real(rprec) fsqr1
Definition vmec_main.f90:99
real(rprec), dimension(:), allocatable pres
pressure profile
Definition vmec_main.f90:55
integer niterv
max iterations for current multi-grid iteration
real(rprec) rinner
real(rprec), dimension(:), allocatable chipf
radial derivative of poloidal magnetic flux (full grid)
Definition vmec_main.f90:36
integer ijacob
counter for number of times jacobian changes sign
real(rprec) wb
magnetic energy: volume integral over B^2/2
real(rprec), dimension(:), allocatable bpedge
Definition vmec_main.f90:76
integer multi_ns_grid
real(rprec), dimension(:,:,:), allocatable, target rmn_bdy
integer num_eqsolve_retries
real(rprec), dimension(0:mpol1d, 3) xmpq
spectral condensation weighting factors
Definition vmec_main.f90:81
real(rprec) fnorm1
Definition vmec_main.f90:97
real(rprec) fedge
real(rprec) res0
real(rprec), dimension(:), allocatable jpar2
Definition vmec_main.f90:57
real(rprec), dimension(:), allocatable presgrad
pressure gradient: dp/ds
Definition vmec_main.f90:61
integer, dimension(:), allocatable ireflect
two-dimensional array for computing 2pi-v angle
real(rprec) currv
toroidal current (?)
Definition vmec_main.f90:85
real(rprec), dimension(:,:), allocatable arm
Definition vmec_main.f90:17
real(rprec), dimension(:), allocatable bvcof
Definition vmec_main.f90:63
logical lthreed
real(rprec), dimension(:), allocatable blam
Definition vmec_main.f90:13
real(rprec), dimension(:), allocatable chi
poloidal magnetic flux
Definition vmec_main.f90:64
real(rprec) r0scale
Definition vmec_main.f90:90
real(rprec), dimension(:), allocatable phips
toroidal flux (same as phip), one-dimensional array
Definition vmec_main.f90:68
real(rprec), dimension(:), allocatable xcl0
Definition vmec_main.f90:79
real(rprec), dimension(:), allocatable bsubu0
real(rprec), dimension(:), allocatable mass
mass profile on half-grid
Definition vmec_main.f90:71
real(rprec), dimension(:), allocatable bdotb
Definition vmec_main.f90:59
real(rprec) fsql1
real(rprec) fsqz1_mhd
integer vacuum_calls
logical lflip
from init_geometry
real(rprec), dimension(:), allocatable bzedge
Definition vmec_main.f90:77
real(rprec), dimension(:), allocatable bucof
Definition vmec_main.f90:62
real(rprec), dimension(0:mpol1d) faccon
factor for spectral constraint
Definition vmec_main.f90:82
real(rprec), dimension(:), allocatable beta_vol
Definition vmec_main.f90:38
integer iter2
total number of iterations
real(rprec), dimension(:), allocatable iotas
rotational transform , on half radial mesh
Definition vmec_main.f90:69
real(rprec) fsqz_con
real(rprec), dimension(:,:), allocatable azm
Definition vmec_main.f90:21
real(rprec), dimension(:), allocatable jperp2
Definition vmec_main.f90:58
real(rprec), dimension(:), allocatable phipf
radial derivative of toroidal magnetic flux (full grid)
Definition vmec_main.f90:35
real(rprec), dimension(:), allocatable tcon
constraint-force multiplier
Definition vmec_main.f90:47
real(rprec), dimension(:,:), allocatable yellip
Definition vmec_main.f90:49
real(rprec), dimension(:), allocatable icurv
(-)toroidal current inside flux surface (vanishes like s)
Definition vmec_main.f90:70
real(rprec), dimension(:), allocatable vpphi
Definition vmec_main.f90:60
real(rprec), dimension(:), allocatable jcurv
toroidal current density
Definition vmec_main.f90:40
integer, parameter ndamp
number of iterations over which damping is averaged