21 integer(itm_i4) :: nr, nchi
22 type (type_equilibrium
) :: equilibrium
27 allocate(equilibrium%profiles_1d%psi(nr))
28 allocate(equilibrium%profiles_1d%phi(nr))
29 allocate(equilibrium%profiles_1d%pressure(nr))
30 allocate(equilibrium%profiles_1d%F_dia(nr))
31 allocate(equilibrium%profiles_1d%pprime(nr))
32 allocate(equilibrium%profiles_1d%ffprime(nr))
33 allocate(equilibrium%profiles_1d%jphi(nr))
34 allocate(equilibrium%profiles_1d%jparallel(nr))
35 allocate(equilibrium%profiles_1d%q(nr))
36 allocate(equilibrium%profiles_1d%r_inboard(nr))
37 allocate(equilibrium%profiles_1d%r_outboard(nr))
38 allocate(equilibrium%profiles_1d%rho_tor(nr))
39 allocate(equilibrium%profiles_1d%dpsidrho_tor(nr))
40 allocate(equilibrium%profiles_1d%rho_vol(nr))
41 allocate(equilibrium%profiles_1d%beta_pol(nr))
42 allocate(equilibrium%profiles_1d%li(nr))
43 allocate(equilibrium%profiles_1d%elongation(nr))
44 allocate(equilibrium%profiles_1d%tria_upper(nr))
45 allocate(equilibrium%profiles_1d%tria_lower(nr))
46 allocate(equilibrium%profiles_1d%volume(nr))
47 allocate(equilibrium%profiles_1d%vprime(nr))
48 allocate(equilibrium%profiles_1d%dvdrho(nr))
49 allocate(equilibrium%profiles_1d%area(nr))
50 allocate(equilibrium%profiles_1d%aprime(nr))
51 allocate(equilibrium%profiles_1d%surface(nr))
52 allocate(equilibrium%profiles_1d%ftrap(nr))
53 allocate(equilibrium%profiles_1d%gm1(nr))
54 allocate(equilibrium%profiles_1d%gm2(nr))
55 allocate(equilibrium%profiles_1d%gm3(nr))
56 allocate(equilibrium%profiles_1d%gm4(nr))
57 allocate(equilibrium%profiles_1d%gm5(nr))
58 allocate(equilibrium%profiles_1d%gm6(nr))
59 allocate(equilibrium%profiles_1d%gm7(nr))
60 allocate(equilibrium%profiles_1d%gm8(nr))
61 allocate(equilibrium%profiles_1d%gm9(nr))
62 allocate(equilibrium%profiles_1d%b_av(nr))
63 allocate(equilibrium%profiles_1d%b_min(nr))
64 allocate(equilibrium%profiles_1d%b_max(nr))
67 allocate(equilibrium%profiles_2d(1))
68 allocate(equilibrium%profiles_2d(1)%grid_type(4))
69 allocate(equilibrium%profiles_2d(1)%grid%dim1(nr))
70 allocate(equilibrium%profiles_2d(1)%grid%dim2(nchi))
71 allocate(equilibrium%profiles_2d(1)%r(nr, nchi))
72 allocate(equilibrium%profiles_2d(1)%z(nr, nchi))
73 allocate(equilibrium%profiles_2d(1)%psi(nr, nchi))
74 allocate(equilibrium%profiles_2d(1)%theta(nr, nchi))
75 allocate(equilibrium%profiles_2d(1)%jphi(nr, nchi))
76 allocate(equilibrium%profiles_2d(1)%jpar(nr, nchi))
77 allocate(equilibrium%profiles_2d(1)%br(nr, nchi))
78 allocate(equilibrium%profiles_2d(1)%bz(nr, nchi))
79 allocate(equilibrium%profiles_2d(1)%bphi(nr, nchi))
82 allocate(equilibrium%eqgeometry%boundary(1))
83 allocate(equilibrium%eqgeometry%boundary(1)%r(nchi))
84 allocate(equilibrium%eqgeometry%boundary(1)%z(nchi))
87 allocate(equilibrium%coord_sys%grid_type(4))
88 allocate(equilibrium%coord_sys%grid%dim1(nr))
89 allocate(equilibrium%coord_sys%grid%dim2(nchi))
90 allocate(equilibrium%coord_sys%position%r(nr, nchi))
91 allocate(equilibrium%coord_sys%position%z(nr, nchi))
92 allocate(equilibrium%coord_sys%g_11(nr, nchi))
93 allocate(equilibrium%coord_sys%g_12(nr, nchi))
94 allocate(equilibrium%coord_sys%g_13(nr, nchi))
95 allocate(equilibrium%coord_sys%g_22(nr, nchi))
96 allocate(equilibrium%coord_sys%g_23(nr, nchi))
97 allocate(equilibrium%coord_sys%g_33(nr, nchi))
98 allocate(equilibrium%coord_sys%jacobian(nr, nchi))
101 equilibrium%profiles_1d%psi = 0._r8
102 equilibrium%profiles_1d%phi = 0._r8
103 equilibrium%profiles_1d%pressure = 0._r8
104 equilibrium%profiles_1d%F_dia = 0._r8
105 equilibrium%profiles_1d%pprime = 0._r8
106 equilibrium%profiles_1d%ffprime = 0._r8
107 equilibrium%profiles_1d%jphi = 0._r8
108 equilibrium%profiles_1d%jparallel = 0._r8
109 equilibrium%profiles_1d%q = 0._r8
110 equilibrium%profiles_1d%r_inboard = 0._r8
111 equilibrium%profiles_1d%r_outboard = 0._r8
112 equilibrium%profiles_1d%rho_tor = 0._r8
113 equilibrium%profiles_1d%dpsidrho_tor = 0._r8
114 equilibrium%profiles_1d%rho_vol = 0._r8
115 equilibrium%profiles_1d%beta_pol = 0._r8
116 equilibrium%profiles_1d%li = 0._r8
117 equilibrium%profiles_1d%elongation = 0._r8
118 equilibrium%profiles_1d%tria_upper = 0._r8
119 equilibrium%profiles_1d%tria_lower = 0._r8
120 equilibrium%profiles_1d%volume = 0._r8
121 equilibrium%profiles_1d%vprime = 0._r8
122 equilibrium%profiles_1d%dvdrho = 0._r8
123 equilibrium%profiles_1d%area = 0._r8
124 equilibrium%profiles_1d%aprime = 0._r8
125 equilibrium%profiles_1d%surface = 0._r8
126 equilibrium%profiles_1d%ftrap = 0._r8
127 equilibrium%profiles_1d%gm1 = 0._r8
128 equilibrium%profiles_1d%gm2 = 0._r8
129 equilibrium%profiles_1d%gm3 = 0._r8
130 equilibrium%profiles_1d%gm4 = 0._r8
131 equilibrium%profiles_1d%gm5 = 0._r8
132 equilibrium%profiles_1d%gm6 = 0._r8
133 equilibrium%profiles_1d%gm7 = 0._r8
134 equilibrium%profiles_1d%gm8 = 0._r8
135 equilibrium%profiles_1d%gm9 = 0._r8
136 equilibrium%profiles_1d%b_av = 0._r8
137 equilibrium%profiles_1d%b_min = 0._r8
138 equilibrium%profiles_1d%b_max = 0._r8
140 equilibrium%profiles_2d(1)%grid%dim1 = 0._r8
141 equilibrium%profiles_2d(1)%grid%dim2 = 0._r8
142 equilibrium%profiles_2d(1)%r = 0._r8
143 equilibrium%profiles_2d(1)%z = 0._r8
144 equilibrium%profiles_2d(1)%psi = 0._r8
145 equilibrium%profiles_2d(1)%theta = 0._r8
146 equilibrium%profiles_2d(1)%jphi = 0._r8
147 equilibrium%profiles_2d(1)%jpar = 0._r8
148 equilibrium%profiles_2d(1)%br = 0._r8
149 equilibrium%profiles_2d(1)%bz = 0._r8
150 equilibrium%profiles_2d(1)%bphi = 0._r8
152 equilibrium%eqgeometry%boundary(1)%r = 0._r8
153 equilibrium%eqgeometry%boundary(1)%z = 0._r8
155 equilibrium%coord_sys%grid%dim1 = 0._r8
156 equilibrium%coord_sys%grid%dim2 = 0._r8
157 equilibrium%coord_sys%position%r = 0._r8
158 equilibrium%coord_sys%position%z = 0._r8
159 equilibrium%coord_sys%g_11 = 0._r8
160 equilibrium%coord_sys%g_12 = 0._r8
161 equilibrium%coord_sys%g_13 = 0._r8
162 equilibrium%coord_sys%g_22 = 0._r8
163 equilibrium%coord_sys%g_23 = 0._r8
164 equilibrium%coord_sys%g_33 = 0._r8
165 equilibrium%coord_sys%jacobian = 0._r8
175 type (type_equilibrium
) :: equilibrium
180 deallocate(equilibrium%profiles_1d%psi)
181 deallocate(equilibrium%profiles_1d%phi)
182 deallocate(equilibrium%profiles_1d%pressure)
183 deallocate(equilibrium%profiles_1d%F_dia)
184 deallocate(equilibrium%profiles_1d%pprime)
185 deallocate(equilibrium%profiles_1d%ffprime)
186 deallocate(equilibrium%profiles_1d%jphi)
187 deallocate(equilibrium%profiles_1d%jparallel)
188 deallocate(equilibrium%profiles_1d%q)
189 deallocate(equilibrium%profiles_1d%r_inboard)
190 deallocate(equilibrium%profiles_1d%r_outboard)
191 deallocate(equilibrium%profiles_1d%rho_tor)
192 deallocate(equilibrium%profiles_1d%dpsidrho_tor)
193 deallocate(equilibrium%profiles_1d%rho_vol)
194 deallocate(equilibrium%profiles_1d%beta_pol)
195 deallocate(equilibrium%profiles_1d%li)
196 deallocate(equilibrium%profiles_1d%elongation)
197 deallocate(equilibrium%profiles_1d%tria_upper)
198 deallocate(equilibrium%profiles_1d%tria_lower)
199 deallocate(equilibrium%profiles_1d%volume)
200 deallocate(equilibrium%profiles_1d%vprime)
201 deallocate(equilibrium%profiles_1d%dvdrho)
202 deallocate(equilibrium%profiles_1d%area)
203 deallocate(equilibrium%profiles_1d%aprime)
204 deallocate(equilibrium%profiles_1d%surface)
205 deallocate(equilibrium%profiles_1d%ftrap)
206 deallocate(equilibrium%profiles_1d%gm1)
207 deallocate(equilibrium%profiles_1d%gm2)
208 deallocate(equilibrium%profiles_1d%gm3)
209 deallocate(equilibrium%profiles_1d%gm4)
210 deallocate(equilibrium%profiles_1d%gm5)
211 deallocate(equilibrium%profiles_1d%gm6)
212 deallocate(equilibrium%profiles_1d%gm7)
213 deallocate(equilibrium%profiles_1d%gm8)
214 deallocate(equilibrium%profiles_1d%gm9)
215 deallocate(equilibrium%profiles_1d%b_av)
216 deallocate(equilibrium%profiles_1d%b_min)
217 deallocate(equilibrium%profiles_1d%b_max)
220 deallocate(equilibrium%profiles_2d(1)%grid_type)
221 deallocate(equilibrium%profiles_2d(1)%grid%dim1)
222 deallocate(equilibrium%profiles_2d(1)%grid%dim2)
223 deallocate(equilibrium%profiles_2d(1)%r)
224 deallocate(equilibrium%profiles_2d(1)%z)
225 deallocate(equilibrium%profiles_2d(1)%psi)
226 deallocate(equilibrium%profiles_2d(1)%theta)
227 deallocate(equilibrium%profiles_2d(1)%jphi)
228 deallocate(equilibrium%profiles_2d(1)%jpar)
229 deallocate(equilibrium%profiles_2d(1)%br)
230 deallocate(equilibrium%profiles_2d(1)%bz)
231 deallocate(equilibrium%profiles_2d(1)%bphi)
232 deallocate(equilibrium%profiles_2d)
235 deallocate(equilibrium%eqgeometry%boundary(1)%r)
236 deallocate(equilibrium%eqgeometry%boundary(1)%z)
237 deallocate(equilibrium%eqgeometry%boundary)
240 deallocate(equilibrium%coord_sys%grid_type)
241 deallocate(equilibrium%coord_sys%grid%dim1)
242 deallocate(equilibrium%coord_sys%grid%dim2)
243 deallocate(equilibrium%coord_sys%position%r)
244 deallocate(equilibrium%coord_sys%position%z)
245 deallocate(equilibrium%coord_sys%g_11)
246 deallocate(equilibrium%coord_sys%g_12)
247 deallocate(equilibrium%coord_sys%g_13)
248 deallocate(equilibrium%coord_sys%g_22)
249 deallocate(equilibrium%coord_sys%g_23)
250 deallocate(equilibrium%coord_sys%g_33)
251 deallocate(equilibrium%coord_sys%jacobian)
264 use mod_dat, only : eps, rvac, bvac, alfa, hbt, b, verbosity, p_sep, &
265 bmag, pscale, r_vessel, zgeo, cpsurfin
274 type (type_equilibrium
),
intent(inout) :: equilibrium
275 character(len = *),
intent(in) :: current_averaging
276 real(r8),
intent(in) :: a, xaxis, yaxis
278 real(r8) :: p_out(nr), rbphi_out(nr), dp_out(nr), drbphi_out(nr)
282 real(r8) :: raxis, rminor, rmag
283 real(r8) :: cpsurf_out
284 real(r8) :: toroidal_current
290 equilibrium%global_param%toroid_field%r0 = r_vessel
291 equilibrium%global_param%toroid_field%b0 = rvac * bvac / r_vessel
296 call
profiles(p_out, rbphi_out, dp_out, drbphi_out, a)
300 dp_out(i) = -0.5_r8 * a * b *
dp_dpsi(psikn(nr - i + 1))
301 drbphi_out(i) = dp_out(i) - eps * a *
dgamma_dpsi(psikn(nr - i + 1))
303 dp_out(i) = -eps * a * b *
dp_dpsi(psikn(nr - i + 1))
304 drbphi_out(i) = -eps * a *
dgamma_dpsi(psikn(nr - i + 1))
306 drbphi_out(i) = 1._r8 / (2._r8 * rbphi_out(i)) * 2._r8 * eps &
307 * drbphi_out(i) / alfa**2
309 raxis = 1._r8 + eps * xaxis
311 bm = rbphi_out(1) / raxis
318 pscale = b0**2 * eps / alfa**2
320 p_out = p_out * pscale
321 dp_out = dp_out * pscale
322 rbphi_out = rbphi_out * rbscale
323 drbphi_out = drbphi_out * rbscale
326 cpsurf_out = twopi * eps**2 * rvac**2 * bvac / alfa
328 if (verbosity > 2)
write(iu6, *)
'cpsurf_out = ', cpsurf_out
335 p_out = p_out * bmag**2 / mu0
336 dp_out = dp_out * bmag**2 / (mu0 * cpsurf_out)
337 rbphi_out = rbphi_out * rmag * bmag
338 drbphi_out = drbphi_out * rmag * bmag / cpsurf_out
341 p_out = p_out + p_sep
352 equilibrium%global_param%mag_axis%position%r = rmag
353 equilibrium%global_param%mag_axis%position%z = zgeo + yaxis * rminor
354 equilibrium%global_param%mag_axis%bphi = bmag
355 equilibrium%eqgeometry%geom_axis%r = rvac
356 equilibrium%eqgeometry%geom_axis%z = 0._r8
357 equilibrium%eqgeometry%a_minor = rminor
360 equilibrium%profiles_1d%psi(i) = cpsurf_out * psikn(nr + 1 - i)
362 equilibrium%profiles_1d%psi(1) = 0._r8
363 equilibrium%profiles_1d%pressure = p_out
364 equilibrium%profiles_1d%pprime = dp_out
365 equilibrium%profiles_1d%F_dia = rbphi_out
366 equilibrium%profiles_1d%ffprime = drbphi_out * rbphi_out
367 equilibrium%profiles_1d%jphi = j_tor_av
371 equilibrium%global_param%volume =
plasma_volume(equilibrium, &
375 equilibrium%global_param%i_plasma = i_tor(nr)
378 call
spline(npts, psivec, p_int, dpres(1) * sign(1._r8, cpsurfin), &
379 dpres(npts) * sign(1._r8, cpsurfin), 1, p_spline)
380 equilibrium%global_param%beta_pol =
beta_poloidal(a, equilibrium)
381 equilibrium%global_param%beta_tor =
beta_toroidal(a, equilibrium)
384 equilibrium%global_param%w_mhd =
w_mhd(equilibrium, rminor, eps)
386 equilibrium%global_param%beta_normal = 100._r8 * rminor &
387 * abs(equilibrium%global_param%toroid_field%b0) &
388 * equilibrium%global_param%beta_tor &
389 / abs(equilibrium%global_param%i_plasma) * 1e6_r8
392 equilibrium%profiles_1d%rho_vol = sqrt(equilibrium%profiles_1d%volume &
393 / equilibrium%profiles_1d%volume(nr))
396 write(iu6, *)
'total current inside fill_equilibrium ', i_tor(nr)
413 use mod_dat, only : alfa, ip, q95, match, verbosity
420 real(r8),
intent(in) :: a, xaxis
421 real(r8),
intent(in) :: cx, cy
422 integer(itm_i4),
intent(in) :: npts
424 real(r8) :: dummy(npts)
426 real(r8) :: q95out, q1out
428 if (trim(match) ==
"q95")
then
430 if (verbosity > 1)
then
431 write(iu6, *)
'recalculate alfa from safety factor q95 = ', q95
432 write(iu6, *)
'q1out = ', q1out
433 write(iu6, *)
'old alfa = ', alfa
435 alfa = alfa * q95 / q1out
436 if (verbosity > 1)
then
437 write(iu6, *)
'new alfa = ', alfa
441 else if (trim(match) ==
"Ip")
then
443 if (verbosity > 1)
then
444 write(iu6, *)
'recalculate alfa from plasma current Ip = ', ip
445 write(iu6, *)
'current Ip = ', ip
446 write(iu6, *)
'new current = ',
current
447 write(iu6, *)
'old alfa = ', alfa
450 if (verbosity > 1)
write(iu6, *)
'new alfa = ', alfa
subroutine, public equilibrium_constructor(equilibrium, nr, nchi)
real(r8) function, public cross_section(equilibrium, rminor, eps)
subroutine adapt_alfa(a, xaxis, cx, cy, npts)
subroutine profiles(p0, rbphi, dp0, drbphi, a)
subroutine allocate_spline_coefficients(spline, n)
subroutine, public fill_equilibrium(a, xaxis, yaxis, current_averaging, equilibrium)
real(r8) function internal_inductance(a, equilibrium)
subroutine spline(N, X, Y, ALFA, BETA, TYP, A, B, C, D)
real(r8) function dgamma_dpsi(flux)
subroutine, public si_currents
subroutine current(GEOMETRY, PROFILES, TRANSPORT, SOURCES, EVOLUTION, CONTROL, j_boun, ifail, failstring)
CURRENT TRANSPORT EQUATION.
real(r8) function, public plasma_volume(equilibrium, rminor, eps)
subroutine, public current_densities(a, xaxis, type)
subroutine deallocate_spline_coefficients(spline)
subroutine, public total_current(a, xaxis, toroidal_current)
real(r8) function, public w_mhd(equilibrium, rminor, eps)
real(r8) function beta_toroidal(a, equilibrium)
subroutine, public equilibrium_destructor(equilibrium)
real(r8) function beta_poloidal(a, equilibrium)
subroutine, public surface_area(equilibrium, rminor, eps)
subroutine, public current_calculations_destructor
real(r8) function dp_dpsi(flux)
subroutine safety_factor(xaxis, a, cx, cy, qprf, q95out, q1out)
subroutine, public current_calculations_constructor(nr, np)