ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
flxint2.f90
Go to the documentation of this file.
1 subroutine flxint2(xaxis, a, cx, cy, sumdq)
2 !----------------------------------------------------------------------
3 ! subroutine to evaluate new fdf profile
4 !----------------------------------------------------------------------
5 
6  use itm_types
7  use mod_parameter
8  use mod_dat
9  use mod_gauss
10  use mod_mesh
11  use mod_profiles
13  use helena_spline
14 
15  implicit none
16 
17  real(r8), intent(in) :: xaxis, a, cx, cy
18 
19  real(r8), intent(out) :: sumdq
20 
21  type(spline_coefficients) :: dd_spline
22 
23  real(r8), dimension(nr) :: qplin, deltaq, df2old
24  real(r8), dimension(nr) :: qplot, xplot, df2tmp
25  real(r8), dimension(nr) :: zps
26  real(r8), dimension(3) :: abltg
27  real(r8) :: factas
28  real(r8) :: r, s, ws
29  real(r8) :: sumq, sumqr
30  real(r8) :: x, xr, xs, xrs, xrr, xss
31  real(r8) :: y, yr, ys, yrs, yrr, yss
32  real(r8) :: ps, psr, pss, psrs, psrr, psss
33  real(r8) :: xjac, bigr, er
34  real(r8) :: qtmp, qtmp0
35  real(r8) :: ss, dummy, df21
36  integer(itm_i4) :: i, j, ngs
37  integer(itm_i4) :: n1, n2, n3, n4
38 
39  real(r8) :: q_profile, dgamma_dpsi
40 
41  factas = 2._r8
42  if (ias == 1) factas = 1._r8
43 
44  call allocate_spline_coefficients(dd_spline, nr)
45  call profiles(dd_spline%sp1, dd_spline%sp2, dd_spline%sp3, &
46  dd_spline%sp4, a)
47 !------------------------------------- nelm elements ------------------
48  r = -1._r8
49  do i = 1, nr - 1
50  sumq = 0._r8
51  sumqr = 0._r8
52  do j = 1, np - 1
53  n1 = (i - 1) * np + j
54  n2 = n1 + 1
55  n3 = n2 + np
56  n4 = n1 + np
57 !------------------------------------- 4 point gaussian int. in s -----
58  do ngs = 1, 4
59  s = xgauss(ngs)
60  ws = wgauss(ngs)
61  call interpolation(2, xx(1, n1), xx(1, n2), xx(1, n3), xx(1, n4), &
62  r, s, x, xr, xs, xrs, xrr, xss)
63  call interpolation(2, yy(1, n1), yy(1, n2), yy(1, n3), yy(1, n4), &
64  r, s, y, yr, ys, yrs, yrr, yss)
65  call interpolation(2, psi(4 * (n1 - 1) + 1), psi(4 * (n2 - 1) + 1), &
66  psi(4 * (n3 - 1) + 1), psi(4 * (n4 - 1) + 1), r, s, ps, &
67  psr, pss, psrs, psrr, psss)
68  xjac = xr * ys - xs * yr
69  bigr = 1._r8 + eps * x
70  sumq = sumq - ws * xjac / ( bigr * abs(psr))
71  er = xrr * ys + xr * yrs - xrs * yr - xs * yrr
72  sumqr = sumqr + psrr * xjac / ((psr**2) * bigr) * ws
73  sumqr = sumqr - er / (bigr * psr) * ws
74  sumqr = sumqr + xjac * eps * xr / ((bigr**2) * psr) * ws
75  end do
76  end do
77  zps(nr - i + 1) = ps
78  qtmp = 0.5_r8 * factas * (sumq * alfa / pi) * dd_spline%sp2(nr - i + 1)
79  qplin(nr - i + 1) = q_profile(ps)
80  deltaq(nr - i + 1) = qplin(nr - i + 1) - qtmp
81  df2old(nr - i + 1) = dgamma_dpsi(ps)
82  qplot(nr - i + 1) = qtmp
83  xplot(nr - i + 1) = sqrt(ps)
84  end do
85  qtmp0 = dd_spline%sp2(1) * (alfa / (2._r8 * sqrt(cx * cy) * (1._r8 &
86  + eps * xaxis)))
87  qplot(1) = qtmp0
88  xplot(1) = 0._r8
89  zps(1) = 0._r8
90  qplin(1) = q_profile(0._r8)
91  deltaq(1) = qplin(1) - qtmp0
92  df2old(1) = 1._r8
93 
94  sumdq = 0._r8
95  df2tmp(1) = df2old(1) + 0.25_r8 * ampl * (deltaq(1) - deltaq(2))
96  zps(1) = 0._r8
97  df2tmp(nr) = df2old(nr)
98  do i = 2, nr - 1
99  df2tmp(nr - i + 1) = df2old(nr - i + 1) + ampl * (deltaq(nr - i) &
100  - deltaq(nr - i + 2)) + ampl * deltaq(nr - i + 1) / 4._r8
101  df2tmp(nr - i + 1) = df2tmp(nr - i + 1) / df2tmp(1)
102 ! write(20, 41) xplot(nr - i + 1), qplot(nr - i + 1), deltaq(nr
103 ! > - i + 1), deltaq(nr - i) - deltaq(nr - i + 2), df2tmp(nr - i
104 ! > + 1), df2old(nr - i + 1)
105  sumdq = sumdq + abs(deltaq(nr - i + 1))
106  end do
107  df2tmp(1) = 1._r8
108  df2tmp(nr - 1) = df2old(nr - 1) + 0.25_r8 * ampl * (deltaq(nr - 2) &
109  - deltaq(nr - 1))
110 
111  sumdq = sumdq / dble(nr - 2)
112 
113 ! write(20, 41) zps(1), qtmp0, q_profile(0.), df2tmp(1),
114 ! > dgamma_dpsi(0.)
115 
116 !-------------------------------------- still freedom to scale q-profile
117 ! alfa = alfa * qplin(1) / qplot(1)
118 ! write(20, *) alfa, qplin(1), qplot(1)
119 !------------------------------------- calc equidistant gamma profile
120  call spline(nr, xplot, df2tmp, 0._r8, 0._r8, 2, dd_spline)
121  do i = 1, npts
122  ps = dble(i - 1) / dble(npts - 1)
123  ss = sqrt(ps)
124  dummy = spwert(nr, ss, dd_spline, xplot, abltg, 0)
125  fdf(i) = dummy
126 ! write(20, 41) ps, ss, fdf(i), df2tmp(i)
127  end do
128  df21 = fdf(1)
129  do i = 1, npts
130  fdf(i) = fdf(i) / df21
131  end do
132 
133  call deallocate_spline_coefficients(dd_spline)
134 
135 ! 41 format(12e12.4)
136 
137  return
138 end subroutine flxint2
subroutine profiles(p0, rbphi, dp0, drbphi, a)
Definition: profiles.f90:1
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)
real(r8) function q_profile(flux)
Definition: q_profile.f90:1
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 dgamma_dpsi(flux)
Definition: dgamma_dpsi.f90:1
subroutine deallocate_spline_coefficients(spline)
subroutine flxint2(xaxis, a, cx, cy, sumdq)
Definition: flxint2.f90:1