ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
scale_current.f90
Go to the documentation of this file.
1 subroutine scale_current(a, r0, b0, rav, fcirc, kkk)
2 !----------------------------------------------------------------------
3 ! subroutine to scale the toroidal current profile to match with the
4 ! neoclassical bootstrap current at the edge
5 ! bootstrap current is calculated in subroutine neo using sauter's
6 ! formula. it is compared with the equilibrium parallel current.
7 ! the input toroidal current is scaled to match the parallel currents.
8 ! the routine can have problems, if the equilibrium parallel current is
9 ! negative. in that case, it produces flat toroidal current profile in the
10 ! range where the parallel current is negative. increasing iscalejz can
11 ! help.
12 !
13 ! input parameters (all in mod_dete) :
14 !
15 ! iscalejz - the number of scaling loops. 0 = no scaling, normal helena run.
16 ! default = 0.0
17 ! bsmultip - the amount of the neoclassical bootstrap current
18 ! used in the scaling. default = 1.0
19 ! scalemix - how much of the old j_tor is mixed with the new default = 0.0
20 !----------------------------------------------------------------------
21 
22  use itm_constants
23  use mod_parameter
24  use mod_dat
25  use mod_dete
26  use mod_gauss
27  use mod_mesh
28  use mod_nodes
29  use mod_profiles
30  use mod_helena_io, only : iu6
33  use helena_spline
34 
35  implicit none
36 
37  real(r8), intent(in) :: a, r0, b0
38  real(r8), dimension(nr), intent(in) :: rav, fcirc
39  integer(itm_i4), intent(in) :: kkk
40 
41  real(r8), parameter :: zmu0 = 4.e-7_r8 * pi
42  real(r8), parameter :: ze = itm_qe
43  integer(itm_i4), parameter :: nrbs = 2001
44 
45  real(r8), dimension(nrbs) :: psibs
46  real(r8), dimension(npts) :: oldzj, oldold, oldoldzj
47 ! real :: oldoldzjz(npts)
48  real(r8), dimension(nr) :: pskn1
49  real(r8), dimension(nr) :: p0tmp, ftmp, dptmp, dftmp
50  type(spline_coefficients) :: r_spline, c_spline, pp_spline, z_spline, &
51  s_spline, ff_spline, q_spline, f_spline
52  real(r8), dimension(nr) :: zps, zjj1, zjj2, zjj3, zjj4, zjj5, zjj6, djj5
53  real(r8), dimension(nr) :: qq, dq, zjpar
54  real(r8), dimension(nr) :: zjbt, zjsig
55  real(r8), dimension(3) :: abltg
56  real(r8) :: factas
57  real(r8) :: radius, cpsurf
58  real(r8) :: pscale, rbscale
59  real(r8) :: r, s, ws
60  real(r8) :: sumq, sumj1, sumj2, sumj3, sumj4, sumj5, sumj6, &
61  sumj5r, sumqr, sumb0, sumbop, sumor2
62  real(r8) :: x, xr, xs, xrs, xrr, xss
63  real(r8) :: y, yr, ys, yrs, yrr, yss
64  real(r8) :: ps, psr, pss, psrs, psrr, psss
65  real(r8) :: xjac, xjacr, dl, bigr, gradps2, dssdr
66  real(r8) :: zjdchi, b02
67  real(r8) :: or2av, b02av, gbar
68  real(r8) :: ex, ext, denom, dndpsico, dtdpsico, ztmp, defte, tefte
69  real(r8) :: conste, consde
70  real(r8) :: ss, pwr
71  real(r8) :: zni, dni, tte, ti, dtte, dti
72  real(r8) :: rr, fcsp, fsp, qsp
73  real(r8) :: zznue, zznui, zsigsp, zsigneo, zzjbt, zhjbt
74  real(r8) :: zj0, sigz0
75 ! real :: maxzjpar, maxzbs
76  real(r8) :: sumerr, sumerr2
77  real(r8) :: dps, fi, pp
78  real(r8) :: zj, bsz, sigz, zj2
79  real(r8) :: oldzjz, zjzcalc
80 ! real :: dummyzjz
81  real(r8) :: scalejz
82  integer(itm_i4) :: iscalest, iscalend
83  integer(itm_i4) :: i, j, ngs
84  integer(itm_i4) :: typ
85  integer(itm_i4) :: n1, n2, n3, n4
86  integer(itm_i4) :: ni, nint
87 
88 ! if (verbosity > 3) write(iu6, *) 'iscalejz = ', iscalejz
89 
90  iscalest = scalest * npts
91  iscalend = scaleend * npts
92 
93  do i = 1, nr - 1
94  pskn1(i) = psikn(nr + 1 - i)
95  end do
96  pskn1(nr) = 1
97 
98  typ = 2
99  call allocate_spline_coefficients(r_spline, nr)
100  call spline(nr, pskn1, rav, 0._r8, 0._r8, typ, r_spline)
101  call allocate_spline_coefficients(c_spline, nr)
102  call spline(nr, pskn1, fcirc, 0._r8, 0._r8, typ, c_spline)
103 
104  factas = 2._r8
105  if (ias == 1) factas = 1._r8
106 
107 ! for r0 = 1.0 and b0 =1.0
108 
109  radius = eps
110  cpsurf = radius**2 / alfa
111 
112  call profiles(p0tmp, ftmp, dptmp, dftmp, a)
113 
114  pscale = eps / alfa**2
115  rbscale = 1.0_r8
116 
117  do i = 1, nr
118  p0tmp(i) = p0tmp(i) * pscale
119  dptmp(i) = dptmp(i) * pscale
120  ftmp(i) = ftmp(i) * rbscale
121  dftmp(i) = dftmp(i) * rbscale
122  end do
123 
124  r = -1._r8
125  do i = 1, nr - 1
126  sumq = 0._r8
127  sumj1 = 0._r8
128  sumj2 = 0._r8
129  sumj3 = 0._r8
130  sumj4 = 0._r8
131  sumj5 = 0._r8
132  sumj6 = 0._r8
133  sumj5r= 0._r8
134  sumqr = 0._r8
135  sumb0 = 0._r8
136  sumbop = 0._r8
137  sumor2 = 0._r8
138  do j = 1, np - 1
139  n1 = (i - 1) * np + j
140  n2 = n1 + 1
141  n3 = n2 + np
142  n4 = n1 + np
143 !------------------------------------- 4 point gaussian int. in s -----
144  do ngs = 1, 4
145  s = xgauss(ngs)
146  ws = wgauss(ngs)
147  call interpolation(2, xx(1, n1), xx(1, n2), xx(1, n3), xx(1, n4), &
148  r, s, x, xr, xs, xrs, xrr, xss)
149  call interpolation(2, yy(1, n1), yy(1, n2), yy(1, n3), yy(1, n4), &
150  r, s, y, yr, ys, yrs, yrr, yss)
151  call interpolation(2, psi(4 * (n1 - 1) + 1), psi(4 * (n2 - 1) + 1), &
152  psi(4 * (n3 - 1) + 1), psi(4 * (n4 - 1) + 1), r, s, ps, &
153  psr, pss, psrs, psrr, psss)
154  xjac = xr * ys - xs * yr
155  xjacr = xrr * ys + xr * yrs - xrs * yr - xs * yrr
156  dl = sqrt(xs**2+ys**2)
157  bigr = 1._r8 + eps * x
158  gradps2 = psr**2 * (xs**2 + ys**2) / xjac**2
159  dssdr = abs(psr) / (2._r8 * sqrt(ps))
160 !------------------------------------------------ normalisations
161  gradps2 = gradps2 * (cpsurf / radius)**2
162  xjac = xjac * radius**2
163  bigr = bigr
164  dl = radius * dl
165  psr = cpsurf * psr
166  psrr = cpsurf * psrr
167  xjacr = xjacr * radius**2
168 !---------------------------------------------------------------
169 
170  zjdchi = bigr * xjac / abs(psr)
171 
172  sumj1 = sumj1 - ws * zjdchi / (gradps2 * bigr**2)
173  sumj2 = sumj2 - ws * zjdchi / gradps2
174  sumj3 = sumj3 - ws * zjdchi * bigr**2 / gradps2
175  sumj4 = sumj4 - ws * zjdchi / bigr**2
176  sumj5 = sumj5 - ws * zjdchi
177  sumj6 = sumj6 - ws * zjdchi * gradps2 / bigr**2
178  sumq = sumq - ws * xjac / (bigr * abs(psr))
179 
180  sumqr = sumqr + psrr * xjac / ((psr**2) * bigr) * ws
181  sumqr = sumqr - xjacr / (bigr * psr) * ws
182  sumqr = sumqr + xjac * eps * xr / ((bigr**2) * psr) * ws
183 
184  sumj5r = sumj5r + xjac * bigr * psrr / (psr**2) * ws
185  sumj5r = sumj5r - xjacr * bigr / psr * ws
186  sumj5r = sumj5r - xjac * eps *xr / psr * ws
187 
188 !----------------------------------------- d_nc from Hegna's
189 
190  b02 = (ftmp(nr - i + 1) / bigr)**2 + gradps2 / bigr**2
191 
192  sumb0 = sumb0 - ws * zjdchi * b02
193  sumbop = sumbop - ws * zjdchi * b02 / gradps2
194  sumor2 = sumor2 - ws * zjdchi / bigr**2
195 
196  end do
197  end do
198  ni = nr - i + 1
199  zps(ni) = sqrt(ps)
200  zjj1(ni) = factas * sumj1 / (2._r8 * pi)
201  zjj2(ni) = factas * sumj2 / (2._r8 * pi)
202  zjj3(ni) = factas * sumj3 / (2._r8 * pi)
203  zjj4(ni) = factas * sumj4 / (2._r8 * pi)
204  zjj5(ni) = factas * sumj5 / (2._r8 * pi)
205  zjj6(ni) = factas * sumj6 / (2._r8 * pi)
206 
207  djj5(ni) = factas * sumj5r / dssdr / (2._r8 * pi)
208 
209  qq(ni) = factas * ftmp(ni) * sumq / (2._r8*pi)
210  dq(ni) = dftmp(ni) * sumq + ftmp(ni) * sumqr / dssdr
211  dq(ni) = dq(ni) * factas / (2._r8 * pi)
212 
213  or2av = factas * sumor2 / (2._r8 * pi) / zjj5(ni)
214  b02av = factas * sumb0 / (2._r8 * pi) / zjj5(ni)
215  gbar = factas * sumbop / (2._r8 * pi)
216 
217  zjpar(ni) = (-dptmp(ni) * ftmp(ni) - dftmp(ni) * b02av) &
218  / ( 2._r8 * cpsurf * sqrt(ps))
219  zjpar(ni) = zjpar(ni) / (zmu0 * r0 / b0**2)
220 ! if (verbosity > 3) write(iu6, *) ni, qq(ni)
221  end do
222  qq(nr) = 2._r8 * qq(nr - 1) - qq(nr - 2)
223  qq(1) = 2._r8 * qq(2) - qq(3)
224 
225  radius = eps * r0
226  cpsurf = radius**2 * b0 / alfa
227 
228 ! if (verbosity > 3) write(iu6, *) r0, b0, alfa, cpsurf
229 
230  call profiles(p0tmp, ftmp, dptmp, dftmp, a)
231 
232  pscale = b0**2 * eps / (zmu0 * alfa**2)
233  rbscale = b0 * r0
234 
235  do i = 1, nr
236  p0tmp(i) = p0tmp(i) * pscale
237 !TODO: This was disabled in revision 161. scale_current has to be re-written
238 ! if (p%type == 15) then
239 ! p0tmp(i) = p0tmp(i) + p%coeff(2) * 1000._r8
240 ! end if
241  dptmp(i) = dptmp(i) * pscale
242  ftmp(i) = ftmp(i) * rbscale
243  dftmp(i) = dftmp(i) * rbscale
244  end do
245 
246  call allocate_spline_coefficients(pp_spline, nr)
247  call spline(nr, pskn1, dptmp, 0._r8, 0._r8, typ, pp_spline)
248 
249  if (te%shape > 0) then
250  call ne_te_profile(ne, ne%psi_0, defte, dndpsico, consde)
251  call ne_te_profile(te, te%psi_0, tefte, dtdpsico, conste)
252  end if
253 
254  call allocate_spline_coefficients(z_spline, nr)
255  call allocate_spline_coefficients(s_spline, nr)
256  call allocate_spline_coefficients(ff_spline, nr)
257  call allocate_spline_coefficients(q_spline, nr)
258 !------------------------------------ to be elaborated
259  if (te%shape == 0) then
260  do i = 2, nr - 1
261  ps = psi(4 * (nr - i) * np + 1)
262  ss = sqrt(ps)
263 
264  pwr = 1._r8 / (etaei + 1._r8)
265 
266  zni = zn0 * (p0tmp(i) / p0tmp(1))**pwr
267  dni = zn0 * pwr * abs((p0tmp(i) / p0tmp(1)))**(pwr - 1._r8) &
268  * dptmp(i) / p0tmp(1) / (2._r8 * ss)
269  tte = rpe * p0tmp(i) / (ze * zni * 1e19_r8)
270  ti = (1._r8 - rpe) * p0tmp(i) / (ze * zni * 1e19_r8)
271 
272  dtte = rpe / (ze * 1e19_r8) * (dptmp(i) / (2._r8 * ss * zni) &
273  - p0tmp(i) * dni / zni**2)
274  dti = (1._r8 - rpe) / (ze * 1e19_r8) * (dptmp(i) / (2._r8 &
275  * ss * zni) - p0tmp(i) * dni / zni**2)
276  dtte = dtte / cpsurf
277  dti = dti / cpsurf
278  dni = dni / cpsurf
279  rr = r0 * rav(i)
280 
281  call neo_helena(fcirc(i), tte, ti, zni, zeff, ftmp(i), qq(i), rr, &
282  eps * ss, dni, dtte, dti, zznue, zznui, zsigsp, zsigneo, &
283  zzjbt, zhjbt)
284  zjbt(i) = zzjbt
285  if (neosig) then
286  zjsig(i) = zsigneo
287  else
288  zjsig(i) = zsigsp
289  end if
290  if (i > 2) zjsig(i) = zjsig(i) / zjsig(2)
291  end do
292  stop
293  zjsig(2) = 1.0_r8
294  zjsig(1) = 2._r8 * zjsig(2) - zjsig(3)
295  zjsig(nr) = 2._r8 * zjsig(nr - 1) - zjsig(nr - 2)
296  zjbt(1) = zjbt(2)
297  zjbt(nr) = zjbt(nr - 1)
298  call spline(nr, pskn1, zjbt, 0._r8, 0._r8, typ, z_spline)
299  call spline(nr, pskn1, zjsig, 0._r8, 0._r8, typ, s_spline)
300  else
301  call spline(nr, pskn1, ftmp, 0._r8, 0._r8, typ, ff_spline)
302  call spline(nr, pskn1, qq, 0._r8, 0._r8, typ, q_spline)
303  do i = 2, nrbs - 1
304  psibs(i) = dble(i - 1) / dble(nrbs)
305  ps = psibs(i)
306  ss = sqrt(ps)
307  if (ps >= ne%psi_0) then
308  call ne_te_profile(ne, ps, zni, dni)
309  else
310  call ne_te_profile(ne, ps, zni, dni, consde, dndpsico)
311 !TODO: factor fde missing in zni (same in si_output) !!!
312  end if
313  dni = -dni
314 ! te given in ev (profiles defined in kev)
315  if (ps >= te%psi_0) then
316  call ne_te_profile(te, ps, tte, dtte)
317  else
318  call ne_te_profile(te, ps, tte, dtte, conste, dtdpsico)
319  end if
320  dtte = -dtte * 1000.0_r8
321  ti = tte
322  dti = dtte
323  dtte = dtte / cpsurf
324  dti = dti / cpsurf
325  dni = dni / cpsurf
326 
327 ! if (verbosity > 3) write(iu6, *) ps, te, zni, dte, dni, conste, consde
328  rr = r0 * spwert(nr, ps, r_spline, pskn1, abltg, 0)
329  fcsp = spwert(nr, ps, c_spline, pskn1, abltg, 0)
330  fsp = spwert(nr, ps, ff_spline, pskn1, abltg, 0)
331  qsp = spwert(nr, ps, q_spline, pskn1, abltg, 0)
332 ! if (i < 200) write(iu6, *) ps, fcsp, te, ti, zni, qsp, dni, dte, dti
333 
334  call neo_helena(fcsp, tte, ti, zni, zeff, fsp, qsp, rr, eps * ss, dni, &
335  dtte, dti, zznue, zznui, zsigsp, zsigneo, zzjbt, zhjbt)
336 ! if (i == nrbs - 3) then
337 ! if (verbosity > 3) &
338 ! write(iu6, *) i, ps, fcirc(i), te, ti, zni, qsp, dni, dte, dti, &
339 ! zzjbt, zznue, conste, dtdpsico
340 ! end if
341  zjbt(i) = zzjbt
342  if (neosig) then
343  zjsig(i) = zsigneo
344  else
345  zjsig(i) = zsigsp
346  end if
347  if (i > 2) zjsig(i) = zjsig(i) / zjsig(2)
348 ! if (i < 200) write(iu6, *) ps, te, ti, zni, dni, dte, dti, &
349 ! zsigsp, zzjbt
350  end do
351  zjsig(2) = 1.0_r8
352  zjsig(1) = 2._r8 * zjsig(2) - zjsig(3)
353  zjsig(nrbs) = 2._r8 * zjsig(nrbs - 1) - zjsig(nrbs - 2)
354 ! zjbt(1) = zjbt(2)
355  zjbt(nrbs) = 2._r8 * zjbt(nrbs - 1) - zjbt(nrbs - 2)
356  zjbt(1) = 0.0_r8
357  psibs(1) = 0.0_r8
358  psibs(nrbs) = 1.0_r8
359  call spline(nrbs, psibs, zjbt, 0._r8, 0._r8, typ, z_spline)
360  call spline(nrbs, psibs, zjsig, 0._r8, 0._r8, typ, s_spline)
361 ! do i = 1, nrbs
362 ! if (verbosity > 3) write(iu6, *) psibs(i), zjbt(i), zjsig(i)
363 ! end do
364 ! stop
365  end if
366  zjpar(1) = 2._r8 * zjpar(2) - zjpar(3)
367 ! zjpar(nr) = 2 * zjpar(nr - 1) - zjpar(nr - 2)
368  zj0 = zjpar(1)
369  sigz0 = zjsig(1)
370  call allocate_spline_coefficients(f_spline, nr)
371  call spline(nr, pskn1, zjpar, 0._r8, 0._r8, typ, f_spline)
372 ! if (verbosity > 3) write(iu6, *) 'iscalejz = ', iscalejz
373  if (iscalejz > 0) then
374  if (verbosity > 3) write(iu6, *) 'scaling current'
375  if (verbosity > 3) write(iu6, *) 'scalemix = ', scalemix
376 ! maxzjpar = 0._r8
377 ! maxzbs = 0._r8
378 ! do i = scaleend * nr, nr - 1
379 ! if (zjpar(i) > maxzjpar) then
380 ! maxzjpar = zjpar(i)
381 ! end if
382 ! if (zjbt(i) > maxzbs) then
383 ! maxzbs = zjbt(i)
384 ! end if
385 ! if (verbosity > 3) write(iu6, *) i, zjpar(i)
386 ! end do
387 ! if (verbosity > 3) write(iu6, *) 'scalejz = ', scalejz, maxzbs, maxzjpar
388 ! if (verbosity > 3) write(iu6, *) iscalest, iscalend
389  sumerr = 0.0_r8
390  sumerr2 = 0.0_r8
391  if (verbosity > 3) &
392  write(iu6, *) "flux j_tor(i)_cal j_tor(i) oldzjz ", &
393  " scalejz bsz sigz zj pp"
394  dps = 1._r8 / dble(npts - 1)
395  do i = 1, npts
396  fi = dble(i - 1) / dble(npts - 1)
397  if (i == 1) then
398  zj = zjpar(1)
399  bsz = zjbt(1)
400  sigz = zjsig(1)
401  else
402  zj = spwert(nr, fi, f_spline, pskn1, abltg, 0)
403  nint = int((npts - 1) * fi) + 1
404  zj2 = zjpar(nint) + (fi - dps * (nint - 1)) / dps &
405  * (zjpar(nint + 1) - zjpar(nint))
406 ! if (verbosity > 3) write(iu6, *) nint, fi, zj, zj2
407  if (te%shape == 0) then
408  bsz = spwert(nr, fi, z_spline, pskn1, abltg, 0)
409  sigz = spwert(nr, fi, s_spline, pskn1, abltg, 0)
410  else
411  bsz = spwert(nrbs, fi, z_spline, psibs, abltg, 0)
412  sigz = spwert(nrbs, fi, s_spline, psibs, abltg, 0)
413  end if
414  end if
415 
416  pp = -spwert(nr, fi, pp_spline, pskn1, abltg, 0)
417 ! if (fi > 0.97_r8) then
418  bsz = bsz * bsmultip
419 ! end if
420 ! end do
421 ! do i = iscalend, npts - 1
422 ! fi = dble(i - 1) / dble(npts - 1)
423 ! zj = spwert(nr, fi, f_spline, pskn1, abltg, 0)
424 ! if (te%type == 0) then
425 ! bsz = spwert(nr, fi, z_spline, pskn1, abltg, 0)
426 ! sigz = spwert(nr, fi, s_spline, pskn1, abltg, 0)
427 ! else
428 ! bsz = spwert(nrbs, fi, z_spline, psibs, abltg, 0)
429 ! sigz = spwert(nrbs, fi, s_spline, psibs, abltg, 0)
430 ! end if
431 ! bsz = bsz * bsmultip
432  oldzjz = j_tor(i)
433 ! if (i >= iscalend) then
434  scalejz = bsz / zj
435 ! sumerr = sumerr + abs(scalejz * (1._r8 - zj / zj0 * sigz &
436 ! / sigz0) - 1._r8)
437  j_tor(i) = sigz + j_tor(i) * scalejz ! *(1-zj/zj0*sigz/sigz0)
438  zjzcalc = j_tor(i)
439 ! else
440 ! j_tor(i) = sigz
441 ! end if
442 ! if (j_tor(i) < 0._r8) j_tor(i) = j_tor(i - 1)
443 ! if (kkk > 2) then
444 ! dummyzjz = ((oldzjz - oldold(i) * (sigz * zj + bsz &
445 ! - oldzj(i))) / (oldzj(i) - oldoldzj(i))) + oldzjz
446 ! end if
447 ! if (j_tor(i) < 0._r8) j_tor(i) = oldzjz * 2._r8
448 ! if ((zj - bsz) / zj0 < sigz .and. zj > bsz) then
449 ! j_tor(i) = oldzjz * sigz / (zj - bsz) * zj0
450 ! end if
451  if (zj < 0._r8) then
452  if (j_tor(i - 1) > j_tor(i) .and. j_tor(i - 1) > oldzjz) then
453  j_tor(i) = j_tor(i - 1)
454 ! if (verbosity > 3) &
455 ! write(iu6, *) 'j_tor(',i,') < 0 !!', j_tor(i), j_tor(i-1), oldzjz
456  else
457  j_tor(i) = oldzjz * 2.0_r8
458  end if
459  end if
460  zjzcalc = j_tor(i)
461 ! if ((zj - bsz) / zj0 > sigz) then
462 ! if (verbosity > 3) write(iu6, *) 'j_tor larger than sigz'
463 ! j_tor(i) = oldzjz * sigz / (zj - bsz) * zj0
464 ! endif
465  if (i > 3 * npts / 4) then
466  sumerr = sumerr + abs(oldzjz / j_tor(i) - 1.0_r8)
467  sumerr2 = sumerr2 + abs(bsz / (zj - sigz / sigz0 * zj0) &
468  - 1.0_r8)
469  end if
470  if (i > 1) then
471 ! if (((oldzjz .lt. oldold(i - 1) .and. oldzjz .lt. oldold(i &
472 ! + 1) .and. j_tor(i) .gt. oldzjz) .or. (oldzjz .gt. oldold(i &
473 ! - 1). and. oldzjz .gt. oldold(i + 1)) .and. j_tor(i) &
474 ! .lt. oldzjz) .and. i .lt. npts) then
475 ! j_tor(i) = scalemix / 2 * oldzjz + (1.0 - scalemix / 2) &
476 ! * j_tor(i) / j_tor(1)
477 ! else
478  j_tor(i) = scalemix * oldzjz + (1.0_r8 - scalemix) * j_tor(i) &
479  / j_tor(1)
480 ! endif
481  end if
482  if (i > iscalend .or. i == 1) then
483  if (verbosity > 3) &
484  write(iu6, 10) fi, zjzcalc, j_tor(i), oldzjz, scalejz, bsz, &
485  sigz, zj, pp
486  end if
487  oldold(i) = oldzjz
488  oldoldzj(i) = oldzj(i)
489  oldzj(i) = zj + sigz
490  end do
491  j_tor(1) = 1._r8
492  if (verbosity > 3) &
493  write(iu6, *) 'average error in current profile vs. ', &
494  'bootstrap current: ', sumerr2 / (npts / 4)
495 
496  if (verbosity > 3) write(iu6, *) 'average error in current iteration: ', &
497  sumerr / (npts / 4)
498 ! j_tor(npts) = 2 * j_tor(npts - 1) - j_tor(npts - 2)
499 ! do i = iscalest, iscalend - 1
500 ! oldzjz = j_tor(i)
501 ! j_tor(i) = j_tor(iscalest) + (j_tor(iscalend) - j_tor(iscalest)) &
502 ! * (i - iscalest) / (scaleend - scalest) / dble(npts)
503 ! if (verbosity > 3) write(iu6, *) i, j_tor(i), oldzjz
504 ! end do
505  end if
506 ! if ((kkk > 0.5_r8 * iscalejz) .and. (iscalejz >= 10) &
507 ! .and. (scalemix > 0.5_r8)) then
508 ! scalemix = 0.5_r8
509 ! end if
510 ! if ((kkk > 0.8_r8 * iscalejz) .and. (iscalejz >= 10) &
511 ! .and. (scalemix > 0.2_r8)) then
512 ! scalemix = 0.2_r8
513 ! end if
514 
515  call deallocate_spline_coefficients(r_spline)
516  call deallocate_spline_coefficients(c_spline)
517  call deallocate_spline_coefficients(ff_spline)
518  call deallocate_spline_coefficients(f_spline)
519  call deallocate_spline_coefficients(z_spline)
520  call deallocate_spline_coefficients(q_spline)
521  call deallocate_spline_coefficients(s_spline)
522  call deallocate_spline_coefficients(pp_spline)
523 
524  10 format(f6.4, 9es14.6)
525 
526  return
527 end subroutine scale_current
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)
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
subroutine neo_helena(fcirc, te, ti, zzne, z, f, q, r, eps, zdne, dte, dti, znue, znui, sigspitz, signeo, zjbt, hjbt)
Definition: neo_helena.f90:1
subroutine deallocate_spline_coefficients(spline)
subroutine scale_current(a, r0, b0, rav, fcirc, kkk)
subroutine ne_te_profile(dt, psi, f, df, const, df_in)