ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
global_plasma_parameters.f90
Go to the documentation of this file.
2 
3  use itm_types
4  use mod_mesh, only : nr, np, ias
5  use mod_parameter
6  use euitm_schemas
7 
8  implicit none
9 
11 
12  contains
13 
14 !-----------------------------------------------------------------------------
15  function w_mhd(equilibrium, rminor, eps) result(f_w_mhd)
16 !-----------------------------------------------------------------------------
17 ! This function calculates W_MHD, i.e. the volume integral of the pressure
18 ! times 1.5 in SI units.
19 !-----------------------------------------------------------------------------
20 
22  use phys_functions, only : identity
23 
24  implicit none
25 
26  type (type_equilibrium), intent(in) :: equilibrium
27  real(r8) :: rminor, eps
28  real(r8) :: f_w_mhd
29 
30  character(len = 6), parameter :: type = 'volume'
31 
32  real(r8) :: df(np - 1), dv(np - 1), dv_flux_tube(nr)
33  real(r8) :: xaxis, factas
34  integer(itm_i4) :: i, j
35 
36  if (ias == 1) then
37  factas = 1._r8
38  else
39  factas = 2._r8
40  end if
41 
42 !-- normalized magnetic axis
43  xaxis = (equilibrium%global_param%mag_axis%position%r &
44  - equilibrium%eqgeometry%geom_axis%r) &
45  / equilibrium%eqgeometry%a_minor
46 
47 !-- initialize dV and df
48  dv = 0._r8
49  df = 0._r8
50 
51 !-- calculate volume of flux tubes
52  do i = 1, nr
53  dv_flux_tube(i) = 0._r8
54  call element_average(i, type, xaxis, 1._r8, 0._r8, identity, df, dv)
55  do j = 1, np -1
56  dv_flux_tube(i) = dv_flux_tube(i) + dv(j)
57  end do
58  end do
59  dv_flux_tube = dv_flux_tube * factas ! symmetry factor
60  dv_flux_tube = dv_flux_tube * rminor**3 / eps ! denormalize
61 
62 !-- interpolate pressure p for centers of flux tubes
63 ! p((x(i) + x(i + 1))/2) = p(x(i)) + (x(i + 1) - x(i)) / 2 &
64 ! * (0.75 * dp(x(i)) + 0.25 * dp(x(i + 1)))
65 ! dV_flux_tube(i) = volume of flux tube between flux surfaces i - 1 and i
66 ! i.e. dV_flux_tube(1) = 0 (magnetic axis)
67  f_w_mhd = 0._r8
68  do i = 2, nr
69  f_w_mhd = f_w_mhd + 1.5_r8 * dv_flux_tube(i) &
70  * (equilibrium%profiles_1d%pressure(i - 1) &
71  + 0.5_r8 * (equilibrium%profiles_1d%psi(i) &
72  - equilibrium%profiles_1d%psi(i - 1)) * (0.75_r8 &
73  * equilibrium%profiles_1d%pprime(i - 1) + 0.25_r8 &
74  * equilibrium%profiles_1d%pprime(i)))
75  end do
76 
77  end function w_mhd
78 
79 !-----------------------------------------------------------------------------
80  function plasma_volume(equilibrium, rminor, eps) &
81  result(f_plasma_volume)
82 !-----------------------------------------------------------------------------
83 ! This function calculates the volume enclosed by the flux surfaces
84 ! (-> equilibrium) and returns the plasma volume in SI units.
85 !-----------------------------------------------------------------------------
86 
88  use phys_functions, only : identity
89 
90  implicit none
91 
92  type (type_equilibrium), intent(inout) :: equilibrium
93  real(r8) :: rminor, eps
94  real(r8) :: f_plasma_volume
95 
96  character(len = 6), parameter :: type = 'volume'
97 
98  real(r8) :: df(np - 1), dv(np - 1), dv_flux_tube(nr)
99  real(r8) :: xaxis, factas
100  integer(itm_i4) :: i, j
101 
102  if (ias == 1) then
103  factas = 1._r8
104  else
105  factas = 2._r8
106  end if
107 
108 !-- xaxis = (Rmag - Rvac) / a
109  xaxis = (equilibrium%global_param%mag_axis%position%r &
110  - equilibrium%eqgeometry%geom_axis%r) &
111  / equilibrium%eqgeometry%a_minor
112 
113 !-- initialize dV and df
114  dv = 0._r8
115  df = 0._r8
116 
117 !-- calculate volume of flux tubes
118  do i = 1, nr
119  dv_flux_tube(i) = 0._r8
120  call element_average(i, type, xaxis, 1._r8, 0._r8, identity, df, dv)
121  do j = 1, np -1
122  dv_flux_tube(i) = dv_flux_tube(i) + dv(j)
123  end do
124  end do
125  dv_flux_tube = dv_flux_tube * factas ! symmetry factor
126  dv_flux_tube = dv_flux_tube * rminor**3 / eps ! denormalize
127 
128  f_plasma_volume = 0._r8
129  do i = 1, nr
130  f_plasma_volume = f_plasma_volume + dv_flux_tube(i)
131  equilibrium%profiles_1d%volume(i) = f_plasma_volume
132  end do
133 
134  end function plasma_volume
135 
136 !-----------------------------------------------------------------------------
137  function cross_section(equilibrium, rminor, eps) &
138  result(f_cross_section)
139 !-----------------------------------------------------------------------------
140 ! This function calculates the area enclosed by the flux surfaces
141 ! (-> equilibrium) and returns the total area of the plasma
142 ! cross-section in SI units.
143 !-----------------------------------------------------------------------------
144 
145  use math_functions, only : element_average
146  use phys_functions, only : identity
147 
148  implicit none
149 
150  type (type_equilibrium), intent(inout) :: equilibrium
151  real(r8) :: rminor, eps
152  real(r8) :: f_cross_section
153 
154  character(len = 6), parameter :: type = 'area '
155 
156  real(r8) :: df(np - 1), da(np - 1), da_flux_tube(nr)
157  real(r8) :: xaxis, factas
158  integer(itm_i4) :: i, j
159 
160  if (ias == 1) then
161  factas = 1._r8
162  else
163  factas = 2._r8
164  end if
165 
166 !-- xaxis = (Rmag - Rvac) / a
167  xaxis = (equilibrium%global_param%mag_axis%position%r &
168  - equilibrium%eqgeometry%geom_axis%r) &
169  / equilibrium%eqgeometry%a_minor
170 
171 !-- initialize dA and df
172  da = 0._r8
173  df = 0._r8
174 
175 !-- calculate area of flux tubes
176  do i = 1, nr
177  da_flux_tube(i) = 0._r8
178  call element_average(i, type, xaxis, 1._r8, 0._r8, identity, df, da)
179  do j = 1, np -1
180  da_flux_tube(i) = da_flux_tube(i) + da(j)
181  end do
182  end do
183  da_flux_tube = da_flux_tube * factas ! symmetry factor
184  da_flux_tube = da_flux_tube * rminor**2 ! denormalize
185 
186  f_cross_section = 0._r8
187  do i = 1, nr
188  f_cross_section = f_cross_section + da_flux_tube(i)
189  equilibrium%profiles_1d%area(i) = f_cross_section
190  end do
191 
192  end function cross_section
193 
194 !-----------------------------------------------------------------------------
195  subroutine surface_area(equilibrium, rminor, eps)
196 !-----------------------------------------------------------------------------
197 ! This subroutine calculates the surface area of all flux surfaces
198 ! (-> equilibrium) in SI units.
199 !-----------------------------------------------------------------------------
200 
201  use math_functions, only : element_average
202  use phys_functions, only : r_major
203 
204  implicit none
205 
206  type (type_equilibrium), intent(inout) :: equilibrium
207  real(r8) :: rminor, eps
208 
209  character(len = 6), parameter :: type = 'line '
210 
211  real(r8) :: df(np - 1), da(np - 1), da_flux_tube(nr)
212  real(r8) :: xaxis, factas
213  integer(itm_i4) :: i, j
214 
215  if (ias == 1) then
216  factas = 1._r8
217  else
218  factas = 2._r8
219  end if
220 
221 !-- xaxis = (Rmag - Rvac) / a
222  xaxis = (equilibrium%global_param%mag_axis%position%r &
223  - equilibrium%eqgeometry%geom_axis%r) &
224  / equilibrium%eqgeometry%a_minor
225 
226 !-- initialize dA and df
227  da = 0._r8
228  df = 0._r8
229 
230 !-- calculate surface area of flux surfaces
231  do i = 1, nr
232  da_flux_tube(i) = 0._r8
233  call element_average(i, type, xaxis, 1._r8, 0._r8, r_major, df, da)
234  do j = 1, np -1
235  da_flux_tube(i) = da_flux_tube(i) + da(j) * df(j)
236  end do
237  end do
238  da_flux_tube = da_flux_tube * factas ! symmetry factor
239  da_flux_tube = da_flux_tube * rminor &
240  * equilibrium%eqgeometry%geom_axis%r * twopi ! denormalize
241 
242  equilibrium%profiles_1d%surface = da_flux_tube
243 
244  end subroutine surface_area
245 
246 !-----------------------------------------------------------------------------
247  function beta_poloidal(a, equilibrium) &
248  result(f_beta_poloidal)
249 !-----------------------------------------------------------------------------
250 ! This function calculates the poloidal beta for all flux surfaces
251 ! (-> equilibrium) and returns the poloidal beta of the equilibrium
252 ! dependencies: profiles_1d%area
253 ! p_spline (profiles has to be called beforehand)
254 !-----------------------------------------------------------------------------
255 
256  use math_functions, only : element_average
257  use phys_functions, only : identity, p
258  use mod_parameter, only : mu0
259  use mod_dat
260 
261  implicit none
262 
263  type (type_equilibrium), intent(inout) :: equilibrium
264  real(r8) :: rminor
265  real(r8) :: f_beta_poloidal
266 
267  character(len = 6), parameter :: type = 'area '
268 
269  real(r8) :: df(np - 1), da(np - 1), dl(np - 1)
270  real(r8), intent(in) :: a
271  real(r8) :: factas, xaxis
272  real(r8) :: lp, b_a
273  integer(itm_i4) :: i, j
274 
275  if (ias == 1) then
276  factas = 1._r8
277  else
278  factas = 2._r8
279  end if
280 
281 !-- xaxis = (Rmag - Rvac) / a
282  xaxis = (equilibrium%global_param%mag_axis%position%r &
283  - equilibrium%eqgeometry%geom_axis%r) &
284  / equilibrium%eqgeometry%a_minor
285 !-- rminor = a_minor
286  rminor = equilibrium%eqgeometry%a_minor
287 
288 !-- initialize dA and df
289  da = 0._r8
290  df = 0._r8
291  dl = 0._r8
292  f_beta_poloidal = 0._r8
293 
294 !-- calculate poloidal beta
295  do i = 1, nr
296  call element_average(i, type, xaxis, a, 0._r8, p, df, da)
297  da = da * factas ! symmetry factor
298  da = da * rminor**2 ! denormalize
299  do j = 1, np -1
300  f_beta_poloidal = f_beta_poloidal + df(j) * da(j)
301  end do
302 !-- average on axis = original value on axis
303  if (i == 1) then
304  equilibrium%profiles_1d%beta_pol(i) = df(1)
305  else
306 !-- average over cross-section up to flux surface i
307  equilibrium%profiles_1d%beta_pol(i) = f_beta_poloidal &
308  / equilibrium%profiles_1d%area(i)
309  end if
310  end do
311 
312 !-- calculate B_a
313  call element_average(nr, 'line ', xaxis, 1._r8, 0._r8, identity, df, dl)
314  lp = 0._r8
315  do j = 1, np -1
316  lp = lp + dl(j)
317  end do
318  lp = lp * factas * rminor
319  b_a = mu0 * equilibrium%global_param%i_plasma / lp
320 
321  equilibrium%profiles_1d%beta_pol = equilibrium%profiles_1d%beta_pol &
322  * 2._r8 * mu0 / b_a**2
323 
324  f_beta_poloidal = equilibrium%profiles_1d%beta_pol(nr)
325 
326  end function beta_poloidal
327 
328 !-----------------------------------------------------------------------------
329  function beta_toroidal(a, equilibrium) &
330  result(f_beta_toroidal)
331 !-----------------------------------------------------------------------------
332 ! This function returns the toroidal beta for the last closed flux surface
333 ! dependencies: global_param%volume, global_param%toroid_field%b0
334 ! p_spline (profiles has to be called beforehand)
335 !-----------------------------------------------------------------------------
336 
337  use math_functions, only : element_average
338  use phys_functions, only : p
339  use mod_parameter, only : mu0
340  use mod_dat
341 
342  implicit none
343 
344  type (type_equilibrium), intent(inout) :: equilibrium
345  real(r8) :: rminor
346  real(r8) :: f_beta_toroidal
347 
348  character(len = 6), parameter :: type = 'volume'
349 
350  real(r8) :: df(np - 1), dv(np - 1)
351  real(r8), intent(in) :: a
352  real(r8) :: factas, xaxis
353  integer(itm_i4) :: i, j
354 
355  if (ias == 1) then
356  factas = 1._r8
357  else
358  factas = 2._r8
359  end if
360 
361 !-- xaxis = (Rmag - Rvac) / a
362  xaxis = (equilibrium%global_param%mag_axis%position%r &
363  - equilibrium%eqgeometry%geom_axis%r) &
364  / equilibrium%eqgeometry%a_minor
365 !-- rminor = a_minor
366  rminor = equilibrium%eqgeometry%a_minor
367 
368 !-- initialize dA and df
369  dv = 0._r8
370  df = 0._r8
371  f_beta_toroidal = 0._r8
372 
373 !-- calculate toroidal beta (no contribution from axis
374 ! since dV = 0)
375  do i = 2, nr
376  call element_average(i, type, xaxis, a, 0._r8, p, df, dv)
377  dv = dv * factas ! symmetry factor
378  dv = dv * rminor**3 / eps ! denormalize
379  do j = 1, np -1
380  f_beta_toroidal = f_beta_toroidal + df(j) * dv(j)
381  end do
382  end do
383 !-- volume average
384  f_beta_toroidal = f_beta_toroidal / equilibrium%global_param%volume
385 !-- normalization
386  f_beta_toroidal = f_beta_toroidal * 2._r8 * mu0 &
387  / equilibrium%global_param%toroid_field%b0**2
388 
389  end function beta_toroidal
390 
391 !-----------------------------------------------------------------------------
392  function internal_inductance(a, equilibrium) &
393  result(f_internal_inductance)
394 !-----------------------------------------------------------------------------
395 ! This function calculates the normalized internal inductance li for all flux
396 ! surfaces (-> equilibrium) and returns the normalized internal inductance
397 ! of the equilibrium
398 ! dependencies: profiles_1d%area
399 ! profiles_1d%jphi
400 ! profiles_1d%psi
401 !-----------------------------------------------------------------------------
402 
403  use math_functions, only : element_average
404  use phys_functions, only : bp2
405  use mod_parameter, only : mu0
406  use mod_dat
407  use mod_profiles
408  use helena_spline
409 
410  implicit none
411 
412  type (type_equilibrium), intent(inout) :: equilibrium
413  real(r8) :: f_internal_inductance
414 
415  character(len = 6), parameter :: type = 'volume'
416 
417  type(spline_coefficients) :: coeff
418  real(r8) :: abltg(3)
419  real(r8) :: df(np - 1), dv(np - 1), dl(np - 1)
420  real(r8) :: i_tor(nr)
421  real(r8), intent(in) :: a
422  real(r8) :: factas, xaxis
423  real(r8) :: rminor, r_average
424  integer(itm_i4) :: i, j
425 
426  if (ias == 1) then
427  factas = 1._r8
428  else
429  factas = 2._r8
430  end if
431 
432 !-- xaxis = (Rmag - Rvac) / a
433  xaxis = (equilibrium%global_param%mag_axis%position%r &
434  - equilibrium%eqgeometry%geom_axis%r) &
435  / equilibrium%eqgeometry%a_minor
436  rminor = equilibrium%eqgeometry%a_minor
437 
438 !-- initialize dV and df
439  dv = 0._r8
440  df = 0._r8
441  i_tor = 0._r8
442  f_internal_inductance = 0._r8
443 
444 !-- calculate internal inductance
445  do i = 2, nr
446  call element_average(i, type, xaxis, a, 0._r8, bp2, df, dv)
447  dv = dv * factas ! symmetry factor
448  dv = dv * rminor**3 / eps ! denormalize
449  do j = 1, np -1
450  f_internal_inductance = f_internal_inductance + df(j) * dv(j)
451  end do
452  i_tor(i) = i_tor(i - 1) + (equilibrium%profiles_1d%area(i) &
453  - equilibrium%profiles_1d%area(i - 1)) &
454  * equilibrium%profiles_1d%jphi(i)
455  r_average = equilibrium%profiles_1d%volume(i) / (twopi &
456  * equilibrium%profiles_1d%area(i))
457  equilibrium%profiles_1d%li(i) = f_internal_inductance / i_tor(i)**2 &
458  / (equilibrium%eqgeometry%a_minor &
459  * equilibrium%eqgeometry%geom_axis%r &
460  / (equilibrium%profiles_1d%psi(nr) &
461  - equilibrium%profiles_1d%psi(1)))**2 / mu0
462 !-- normalize internal inductance
463  equilibrium%profiles_1d%li(i) = 2._r8 * equilibrium%profiles_1d%li(i) &
464  / (mu0 * r_average)
465  end do
466 
467 !-- extrapolate internal inductance onto axis (over volume)
468  call allocate_spline_coefficients(coeff, nr - 1)
469  call spline(nr - 1, equilibrium%profiles_1d%volume(2 : nr), &
470  equilibrium%profiles_1d%li(2 : nr), 0._r8, 0._r8, 2, coeff)
471  equilibrium%profiles_1d%li(1) = spwert(nr - 1, 0._r8, coeff, &
472  equilibrium%profiles_1d%volume(2 : nr), abltg, 0)
474 
475  f_internal_inductance = equilibrium%profiles_1d%li(nr)
476 
477  end function internal_inductance
478 
479 end module global_plasma_parameters
real(r8) function, public cross_section(equilibrium, rminor, eps)
real(r8) function bp2(a, x, xr, xs, yr, ys, psi, psir, F_dia)
subroutine allocate_spline_coefficients(spline, n)
real(r8) function internal_inductance(a, equilibrium)
subroutine spline(N, X, Y, ALFA, BETA, TYP, A, B, C, D)
Definition: solution6.f90:655
REAL *8 function spwert(N, XWERT, A, B, C, D, X, ABLTG)
Definition: solution6.f90:155
real(r8) function, public plasma_volume(equilibrium, rminor, eps)
subroutine, public element_average(i, type, xaxis, a, F_dia, func, df, dl)
subroutine deallocate_spline_coefficients(spline)
real(r8) function p(a, x, xr, xs, yr, ys, psi, psir, F_dia)
real(r8) function, public w_mhd(equilibrium, rminor, eps)
real(r8) function beta_toroidal(a, equilibrium)
real(r8) function identity(a, x, xr, xs, yr, ys, psi, psir, F_dia)
real(r8) function beta_poloidal(a, equilibrium)
subroutine, public surface_area(equilibrium, rminor, eps)
real(r8) function r_major(a, x, xr, xs, yr, ys, psi, psir, F_dia)