9 private :: integrate_over_hermite_element, integrate_along_hermite_element
32 real(r8),
dimension(n),
intent(in) :: x
33 real(r8),
dimension(n) :: g
34 integer(itm_i4),
intent(in) :: n
37 real(r8),
dimension(3) :: ablt
44 g(n + 1 - i) = g(n + 2 - i) + (
spwert(n, x(n + 2 - i), f_spline, x, &
45 ablt, 0) +
spwert(n, x(n + 1 - i), f_spline, x, ablt, 0)) &
46 * (x(n + 1 - i) - x(n + 2 - i)) / 2._r8
48 g(i) = g(i - 1) + (
spwert(n, x(i - 1), f_spline, x, ablt, 0) &
49 +
spwert(n, x(i), f_spline, x, ablt, 0)) * (x(i) - x(i - 1)) &
71 real(r8),
intent(in) :: f(:), x(:)
72 real(r8),
intent(in) :: x_low, x_high
73 logical,
intent(in) :: sum
75 integer(itm_i4),
parameter :: iu6 = 6
78 real(r8) :: f_x1, f_x2, x1, x2
79 integer(itm_i4) :: i, i_x1, i_x2
82 if (
size(f) /=
size(x))
then
83 write(iu6, *)
'Error in integrate_1d: Array sizes do not agree!'
87 if (x_low > x_high)
then
101 if (x1 >= x(i)) i_x1 = i
102 if (x2 >= x(i)) i_x2 = i
108 if (.not. x1 == x2)
then
110 if (i_x1 ==
size(x))
then
116 f_x1 = f(i_x1) + (x1 - x(i_x1)) * (f(i_x1 + 1) - f(i_x1)) &
117 / (x(i_x1 + 1) - x(i_x1))
120 if (i_x2 ==
size(x))
then
126 f_x2 = f(i_x2) + (x2 - x(i_x2)) * (f(i_x2 + 1) - f(i_x2)) &
127 / (x(i_x2 + 1) - x(i_x2))
131 if (i_x1 == i_x2)
then
140 do i = i_x1 + 1, i_x2 - 1
176 real(r8),
intent(in) :: f(:)
177 real(r8),
intent(inout) :: x(:)
178 real(r8),
intent(out) :: f_equi(:), x_equi(:)
184 if (
size(f) /=
size(x) .or.
size(f_equi) /=
size(x_equi))
then
185 stop
'Error in equidistant_profile: Array sizes do not agree!'
190 call
spline(
size(f), x, f, 0._r8, 0._r8, 2, f_spline)
192 do i = 1,
size(f_equi)
193 x_equi(i) = x(1) + dble(i - 1) / dble(
size(f_equi) - 1) &
194 * (x(
size(x)) - x(1))
195 f_equi(i) =
spwert(
size(f), x_equi(i), f_spline, x, abltg, 0)
203 function root(a, b, c, d, sgn) result(f_root)
211 real(r8) :: a, b, c, d, sgn
214 if (b * sgn >= 0.0)
then
215 f_root = -2.0_r8 * c / (b + sgn * sqrt(d))
217 f_root = (-b + sgn * sqrt(d)) / (2.0_r8 * a)
223 function integrate_over_hermite_element(i, j, a, F_dia, func, volume) &
240 integer(itm_i4),
intent(in) :: i, j
241 real(r8),
intent(in) :: a, f_dia
244 real(r8) :: f_integral
246 real(r8) :: r, wr, s, ws
247 real(r8) :: x, xr, xs, xrs, xrr, xss
248 real(r8) :: y, yr, ys, yrs, yrr, yss
249 real(r8) :: ps, psr, pss, psrs, psrr, psss
250 real(r8) :: xjac, major_radius
251 integer(itm_i4) :: ngr, ngs
252 integer(itm_i4) :: nelm
253 integer(itm_i4) :: n1, n2, n3, n4
255 real(r8),
external:: func
259 nelm = (i - 1) * (np - 1) + j
269 call
interpolation(2, xx(1, n1), xx(1, n2), xx(1, n3), xx(1, n4), &
270 r, s, x, xr, xs, xrs, xrr, xss)
271 call
interpolation(2, yy(1, n1), yy(1, n2), yy(1, n3), yy(1, n4), &
272 r, s, y, yr, ys, yrs, yrr, yss)
273 call
interpolation(2, psi(4 * (n1 - 1) + 1), psi(4 * (n2 - 1) &
274 + 1), psi(4 * (n3 - 1) + 1), psi(4 * (n4 - 1) + 1), r, s, ps, &
275 psr, pss, psrs, psrr, psss)
276 xjac = xr * ys - xs * yr
278 major_radius = 1._r8 + eps * x
279 f_integral = f_integral + wr * ws * xjac * major_radius &
280 * twopi * func(a, x, xr, xs, yr, ys, ps, psr, f_dia)
282 f_integral = f_integral + wr * ws * xjac &
283 * func(a, x, xr, xs, yr, ys, ps, psr, f_dia)
288 end function integrate_over_hermite_element
291 function integrate_along_hermite_element(i, j, a, F_dia, func, theta) &
308 integer(itm_i4),
intent(in) :: i, j
309 real(r8),
intent(in) :: a, f_dia
312 real(r8) :: f_integral
315 real(r8) :: x, xr, xs, xrs, xrr, xss
316 real(r8) :: y, yr, ys, yrs, yrr, yss
317 real(r8) :: ps, psr, pss, psrs, psrr, psss
318 real(r8) :: xjac, dl, major_radius
319 integer(itm_i4) :: ngs
320 integer(itm_i4) :: nelm
321 integer(itm_i4) :: n1, n2, n3, n4
323 real(r8),
external:: func
328 nelm = (i - 1) * (np - 1) + j
334 call
interpolation(2, xx(1, n1), xx(1, n2), xx(1, n3), xx(1, n4), &
335 r, s, x, xr, xs, xrs, xrr, xss)
336 call
interpolation(2, yy(1, n1), yy(1, n2), yy(1, n3), yy(1, n4), &
337 r, s, y, yr, ys, yrs, yrr, yss)
338 call
interpolation(2, psi(4 * (n1 - 1) + 1), psi(4 * (n2 - 1) &
339 + 1), psi(4 * (n3 - 1) + 1), psi(4 * (n4 - 1) + 1), r, s, ps, &
340 psr, pss, psrs, psrr, psss)
342 xjac = xr * ys - xs * yr
343 major_radius = 1._r8 + eps * x
345 f_integral = f_integral + ws * xjac * major_radius / abs(psr) &
346 * twopi * func(a, x, xr, xs, yr, ys, ps, psr, f_dia)
349 dl = sqrt(xs**2 + ys**2)
350 f_integral = f_integral + ws * dl &
351 * func(a, x, xr, xs, yr, ys, ps, psr, f_dia)
355 end function integrate_along_hermite_element
383 character(len = 6),
intent(in) :: type
384 real(r8),
intent(in) :: xaxis, a, f_dia
385 integer(itm_i4),
intent(in) :: i
387 real(r8) :: dl(np - 1), df(np - 1)
389 real(r8) :: one = 1._r8,
zero = 0._r8
392 real(r8),
external :: func
404 select case (trim(type))
406 dl(j) = integrate_along_hermite_element(nr + 1 - i, j, a, &
408 df(j) = integrate_along_hermite_element(nr + 1 - i, j, a, &
409 f_dia, func, theta = .false.)
411 dl(j) = -integrate_over_hermite_element(nr + 1 - i, j, a, &
413 df(j) = -integrate_over_hermite_element(nr + 1 - i, j, a, &
414 f_dia, func, volume = .false.)
416 dl(j) = -integrate_over_hermite_element(nr + 1 - i, j, a, &
418 df(j) = -integrate_over_hermite_element(nr + 1 - i, j, a, &
419 f_dia, func, volume = .true.)
421 dl(j) = integrate_along_hermite_element(nr + 1 - i, j, a, &
423 df(j) = integrate_along_hermite_element(nr + 1 - i, j, a, &
424 f_dia, func, theta = .true.)
426 write(iu6, *)
'ERROR: wrong type of averaging parameter!'
429 df(j) = df(j) / dl(j)
452 character(len = 6),
intent(in) :: type
453 real(r8),
intent(in) :: xaxis, a, f_dia
454 integer(itm_i4),
intent(in) :: i
456 real(r8) :: f_average
458 real(r8) :: dl(np - 1), df(np - 1)
462 real(r8),
external:: func
474 dl_total = dl_total + dl(j)
475 f_average = f_average + df(j) * dl(j)
483 f_average = f_average / dl_total
496 real(r8),
intent(in) :: p_m, p_mr, p_p, p_pr, tol
497 real(r8),
intent(out) :: r
498 integer(itm_i4),
intent(out) :: ifail
500 real(r8) :: a, b, c, d
503 a = 3._r8 * (p_m + p_mr - p_p + p_pr ) / 4._r8
504 b = (-p_mr + p_pr ) / 2._r8
505 c = (-3._r8 * p_m - p_mr + 3._r8 * p_p - p_pr) / 4._r8
506 d = b * b - 4._r8 * a * c
509 r =
root(a, b, c, d, 1._r8)
510 if (abs(r) > tol) r =
root(a, b, c, d, -1._r8)
subroutine zero(x1, y1, x2, y2, func, err, x, y, izero, ll)
real(r8) function, dimension(n), public integrate(f_spline, x, n, inv)
subroutine, public equidistant_profile(f, x, f_equi, x_equi)
subroutine interpolation(type_interp, xn1, xn2, xn3, xn4, r, s, x, xr, xs, xrs, xrr, xss, yn1, yn2, yn3, yn4, pn1, pn2, pn3, pn4, yr, ys, ps)
subroutine allocate_spline_coefficients(spline, n)
subroutine spline(N, X, Y, ALFA, BETA, TYP, A, B, C, D)
REAL *8 function spwert(N, XWERT, A, B, C, D, X, ABLTG)
real(r8) function, public flux_surface_average(i, xaxis, a, F_dia, type, func)
subroutine, public quad_equation(p_m, p_mr, p_p, p_pr, tol, r, ifail)
subroutine, public element_average(i, type, xaxis, a, F_dia, func, df, dl)
subroutine deallocate_spline_coefficients(spline)
real(r8) function, public root(a, b, c, d, sgn)
real(r8) function identity(a, x, xr, xs, yr, ys, psi, psir, F_dia)
subroutine set_node_number(n_node, n1, n2, n3, n4)
real(r8) function integrate_1d(f, x, x_low, x_high, sum)
subroutine integral(n, h, r, f, int)