1 subroutine mercier(a, dimerc, drmerc, hh, qq, dq, geonc, zjpar)
17 real(r8),
intent(in) :: a
19 real(r8),
dimension(nr),
intent(out) :: dimerc, drmerc, hh, qq, dq
20 real(r8),
dimension(nr),
intent(out) :: geonc
21 real(r8),
dimension(nr),
intent(inout) :: zjpar
23 real(r8),
dimension(nr) :: p0tmp, ftmp, dptmp, dftmp
24 real(r8),
dimension(nr) :: zps, zjj1, zjj2, zjj3, zjj4, zjj5, zjj6, djj5
25 real(r8),
dimension(nr) :: bigg
28 real(r8) :: radius, cpsurf
31 real(r8) :: sumq, sumj1, sumj2, sumj3, sumj4, sumj5, sumj6, sumj5r, &
32 sumqr, sumb0, sumbop, sumor2
33 real(r8) :: x, xr, xs, xrs, xrr, xss
34 real(r8) :: y, yr, ys, yrs, yrr, yss
35 real(r8) :: ps, psr, pss, psrs, psrr, psss
36 real(r8) :: xjac, xjacr, dl, bigr, gradps2, dssdr
37 real(r8) :: zjdchi, b02
38 real(r8) :: or2av, b02av, gbar
40 integer(itm_i4) :: i, j, ngs
41 integer(itm_i4) :: n1, n2 ,n3 ,n4
45 if (ias == 1) factas = 1._r8
50 cpsurf = radius**2 * b0 / alfa
52 call
profiles(p0tmp, ftmp, dptmp, dftmp, a)
54 pscale = b0**2 * eps / alfa**2
57 p0tmp(i) = p0tmp(i) * pscale
58 dptmp(i) = dptmp(i) * pscale
59 ftmp(i) = ftmp(i) * rbscale
60 dftmp(i) = dftmp(i) * rbscale
63 if (standard_output)
then
67 write(out_he, *)
'*i, ss, d_i, d_r, h,', &
95 call
interpolation(2, xx(1, n1), xx(1, n2), xx(1, n3), xx(1, n4), &
96 r, s, x, xr, xs, xrs, xrr, xss)
97 call
interpolation(2, yy(1, n1), yy(1, n2), yy(1, n3), yy(1, n4), &
98 r, s, y, yr, ys, yrs, yrr, yss)
99 call
interpolation(2, psi(4 * (n1 - 1) + 1), psi(4 * (n2 - 1) + 1), &
100 psi(4 * (n3 - 1) + 1), psi(4 * (n4 - 1) + 1), r, s, ps, &
101 psr, pss, psrs, psrr, psss)
103 xjac = xr * ys - xs * yr
104 xjacr = xrr * ys + xr * yrs - xrs * yr - xs * yrr
106 dl = sqrt(xs**2 + ys**2)
107 bigr = 1._r8 + eps * x
108 gradps2 = psr**2 * (xs**2 + ys**2) / xjac**2
109 dssdr = abs(psr) / (2._r8 * sqrt(ps))
111 gradps2 = gradps2 * (cpsurf / radius)**2
112 xjac = xjac * radius**2
117 xjacr = xjacr * radius**2
120 zjdchi = bigr * xjac / abs(psr)
122 sumj1 = sumj1 - ws * zjdchi / (gradps2 * bigr**2)
123 sumj2 = sumj2 - ws * zjdchi / gradps2
124 sumj3 = sumj3 - ws * zjdchi * bigr**2 / gradps2
125 sumj4 = sumj4 - ws * zjdchi / bigr**2
126 sumj5 = sumj5 - ws * zjdchi
127 sumj6 = sumj6 - ws * zjdchi * gradps2 / bigr**2
128 sumq = sumq - ws * xjac / (bigr * abs(psr))
130 sumqr = sumqr + psrr * xjac / ((psr**2) * bigr) * ws
131 sumqr = sumqr - xjacr / (bigr * psr) * ws
132 sumqr = sumqr + xjac * eps * xr / ((bigr**2) * psr) * ws
134 sumj5r = sumj5r + xjac * bigr * psrr / (psr**2) * ws
135 sumj5r = sumj5r - xjacr * bigr / psr * ws
136 sumj5r = sumj5r - xjac * eps * xr / psr * ws
140 b02 = (ftmp(nr - i + 1) / bigr)**2 + gradps2 / bigr**2
142 sumb0 = sumb0 - ws * zjdchi * b02
143 sumbop = sumbop - ws * zjdchi * b02 / gradps2
144 sumor2 = sumor2 - ws * zjdchi / bigr**2
150 zjj1(ni) = factas * sumj1 / (2._r8 * pi)
151 zjj2(ni) = factas * sumj2 / (2._r8 * pi)
152 zjj3(ni) = factas * sumj3 / (2._r8 * pi)
153 zjj4(ni) = factas * sumj4 / (2._r8 * pi)
154 zjj5(ni) = factas * sumj5 / (2._r8 * pi)
155 zjj6(ni) = factas * sumj6 / (2._r8 * pi)
157 djj5(ni) = factas * sumj5r / dssdr / (2._r8 * pi)
159 qq(ni) = factas * ftmp(ni) * sumq / (2._r8 * pi)
160 dq(ni) = dftmp(ni) * sumq + ftmp(ni) * sumqr / dssdr
161 dq(ni) = dq(ni) * factas / (2._r8 * pi)
163 or2av = factas * sumor2 / (2._r8*pi) / zjj5(ni)
164 b02av = factas * sumb0 / (2._r8*pi) / zjj5(ni)
165 gbar = factas * sumbop / (2._r8*pi)
167 geonc(ni) = gbar / b02av
169 zjpar(ni) = (-dptmp(ni) * ftmp(ni) - dftmp(ni) * b02av) &
170 / (2._r8 * cpsurf * sqrt(ps))
172 bigg(ni) = factas * sumbop / (2._r8 * pi)
174 dimerc(ni) = (dptmp(ni) * ftmp(ni) * zjj2(ni) / dq(ni) &
175 - 0.5_r8)**2 + dptmp(ni) / dq(ni)**2 * (djj5(ni) - dptmp(ni) &
176 * zjj3(ni)) * (ftmp(ni)**2 * zjj1(ni) + zjj4(ni))
178 hh(ni) = ftmp(ni) * dptmp(ni) / dq(ni) * (zjj2(ni) &
179 - zjj5(ni) * (zjj4(ni) + ftmp(ni)**2 * zjj1(ni)) &
180 / (zjj6(ni) + ftmp(ni)**2 * zjj4(ni)))
182 drmerc(ni) = dimerc(ni) - (hh(ni) - 0.5_r8)**2
184 shear = sqrt(ps) * dq(ni) / qq(ni)
186 if (standard_output) &
187 write(out_he, 3) i, sqrt(ps), -dimerc(ni), -drmerc(ni), hh(ni), &
188 qq(ni), shear, geonc(ni)
191 if (standard_output)
write(out_he, 1)
197 if (additional_output)
then
200 write(41, *)
' di, dr, h, geonc : '
202 write(41, 42) i, dimerc(i), drmerc(i), hh(i), geonc(i)
206 1
format(
' ', 67(
'*'))
207 2
format(
' * ideal and resistive mercier criterion ', 26(
' '),
'*')
208 3
format(i3, f10.5, 2es10.2, 3f8.3, es10.2, 2f8.3, es10.2)
209 42
format(i4, 12es12.4)
subroutine profiles(p0, rbphi, dp0, drbphi, a)
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 mercier(a, dimerc, drmerc, hh, qq, dq, geonc, zjpar)