10 coreprof_out, equilibrium_out)
42 TYPE (type_coreprof
),
POINTER :: coreprof_in(:)
43 TYPE (type_coreprof
),
POINTER :: coreprof_out(:)
44 TYPE (type_equilibrium
),
POINTER :: equilibrium_in(:)
45 TYPE (type_equilibrium
),
POINTER :: equilibrium_out(:)
54 REAL (R8),
ALLOCATABLE :: rho(:)
55 REAL (R8),
ALLOCATABLE :: rhomod(:)
57 REAL (R8),
ALLOCATABLE :: psi(:)
58 REAL (R8),
ALLOCATABLE :: qsf(:)
59 REAL (R8),
ALLOCATABLE :: jpar(:)
60 REAL (R8),
ALLOCATABLE :: pr(:)
62 REAL (R8),
ALLOCATABLE :: ne(:)
63 REAL (R8),
ALLOCATABLE :: te(:)
64 REAL (R8),
ALLOCATABLE :: ni(:,:)
65 REAL (R8),
ALLOCATABLE :: ti(:,:)
67 REAL (R8),
ALLOCATABLE ::
fun(:)
68 REAL (R8),
ALLOCATABLE :: intjpar(:)
69 REAL (R8),
ALLOCATABLE :: intfun(:)
71 REAL (R8),
ALLOCATABLE ::
fdia(:)
72 REAL (R8),
ALLOCATABLE :: gm2(:)
73 REAL (R8),
ALLOCATABLE :: vprime(:)
75 REAL (R8) :: curr, curr_total
76 REAL (R8) :: jpar0, jparb
81 REAL (R8) :: bnd_value(3)
87 REAL (R8) :: s_ip, s_bt, s_q, s_psi, s_jpar
91 ALLOCATE (coreprof_out(1))
92 ALLOCATE (equilibrium_out(1))
97 CALL copy_cpo(coreprof_in(1), coreprof_out(1))
98 CALL copy_cpo(equilibrium_in(1), equilibrium_out(1))
103 nrho =
SIZE (coreprof_in(1)%rho_tor, dim=1)
104 nion =
SIZE (coreprof_in(1)%ni%value, dim=2)
105 npsi =
SIZE (equilibrium_in(1)%profiles_1d%psi, dim=1)
107 s_ip = sign(1.0_r8, coreprof_in(1)%globalparam%current_tot)
108 s_bt = sign(1.0_r8, coreprof_in(1)%toroid_field%b0)
109 s_q = sign(1.0_r8, coreprof_in(1)%profiles1d%q%value(1))
110 s_psi = sign(1.0_r8, coreprof_in(1)%psi%value(nrho)-coreprof_in(1)%psi%value(1))
111 s_jpar = sign(1.0_r8, coreprof_in(1)%profiles1d%jtot%value(1))
113 WRITE(*,*)
's_ip, s_bt, s_q, s_psi, s_jpar = ', s_ip, s_bt, s_q, s_psi, s_jpar
116 ALLOCATE (rho(nrho) )
117 ALLOCATE (rhomod(nrho) )
119 ALLOCATE (psi(nrho) )
120 ALLOCATE (qsf(nrho) )
121 ALLOCATE (jpar(nrho) )
126 ALLOCATE (ni(nrho,nion) )
127 ALLOCATE (ti(nrho,nion) )
129 ALLOCATE (
fun(nrho) )
130 ALLOCATE (intjpar(nrho) )
131 ALLOCATE (intfun(nrho))
133 ALLOCATE (
fdia(nrho) )
134 ALLOCATE (gm2(nrho) )
135 ALLOCATE (vprime(nrho) )
140 rho = coreprof_in(1)%rho_tor
141 curr_total = coreprof_in(1)%globalparam%current_tot
143 r0 = coreprof_in(1)%toroid_field%r0
144 b0 = coreprof_in(1)%toroid_field%b0
146 CALL
l3deriv(equilibrium_in(1)%profiles_1d%volume, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
148 CALL
l3interp(equilibrium_in(1)%profiles_1d%F_dia, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
150 CALL
l3interp(equilibrium_in(1)%profiles_1d%gm2, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
152 rhomod = (1.e0_r8-rho**2 / rho(nrho)**2)
154 ne = coreprof_in(1)%ne%value
155 te = coreprof_in(1)%te%value
156 ni = coreprof_in(1)%ni%value
157 ti = coreprof_in(1)%ti%value
162 jpar0 = 1.e6_r8 * s_jpar
168 7 jpar = (jpar0-jparb) * rhomod + jparb
172 jpar = (jpar0-jparb) * rhomod + jparb
176 fun = jpar * itm_mu0 * vprime /
fdia**2 / rho
179 qsf = - vprime * gm2 /
fdia * rho / intfun
184 fun = 2.e0_r8 * itm_pi * b0 / qsf
191 fun = vprime * jpar / 2.0e0_r8 / itm_pi * b0 /
fdia**2
193 curr = intjpar(nrho) *
fdia(nrho)
195 IF (dabs(1.0_r8 - curr/curr_total) .GE. 1.0e-5_r8)
THEN
197 jpar0 = jpar0 * curr_total / curr
203 WRITE (*,*)
'Parabolic current set to', curr
207 pr = (ne * te + sum(ni * ti, dim=2)) * itm_ev
212 pr = (pr(1)-pr(nrho)) * rhomod + pr(nrho)
217 coreprof_out(1)%psi%value = psi
218 coreprof_out(1)%profiles1d%q%value = qsf
219 coreprof_out(1)%profiles1d%jtot%value = jpar
220 coreprof_out(1)%profiles1d%pr_th%value = pr
221 coreprof_out(1)%profiles1d%pr_perp%value = pr
222 coreprof_out(1)%profiles1d%pr_parallel%value = pr
262 (prof_flag, q0_flag, coreprof_in, equilibrium_in, coreprof_out)
295 TYPE (type_equilibrium
),
POINTER :: equilibrium_in(:)
296 TYPE (type_coreprof
),
POINTER :: coreprof_in(:)
297 TYPE (type_coreprof
),
POINTER :: coreprof_out(:)
301 INTEGER :: nrho, irho
303 INTEGER :: prof_flag, flag
311 REAL (R8),
ALLOCATABLE :: rho(:)
312 REAL (R8),
ALLOCATABLE :: rhomod(:)
313 REAL (R8),
ALLOCATABLE :: psi(:)
314 REAL (R8),
ALLOCATABLE :: dpsi(:)
315 REAL (R8),
ALLOCATABLE :: qsf(:)
316 REAL (R8),
ALLOCATABLE :: jpar(:)
318 REAL (R8),
ALLOCATABLE ::
fun(:)
319 REAL (R8),
ALLOCATABLE :: dfun(:)
320 REAL (R8),
ALLOCATABLE :: intfun(:)
322 REAL (R8),
ALLOCATABLE ::
fdia(:)
323 REAL (R8),
ALLOCATABLE :: gm2(:)
324 REAL (R8),
ALLOCATABLE :: vprime(:)
326 REAL (R8) :: curr_total
327 REAL (R8) :: psi0, psib
328 REAL (R8) :: qsf0, qsfb
329 REAL (R8) :: jpar0, jparb
330 REAL (R8) :: pr0, prb
333 REAL (R8) :: rho_min, qsf_min
335 REAL (R8) :: s_ip, s_bt, s_q, s_psi, s_jpar
339 nrho =
SIZE (coreprof_in(1)%rho_tor, dim=1)
340 npsi =
SIZE (equilibrium_in(1)%profiles_1d%psi, dim=1)
343 s_ip = sign(1.0_r8, coreprof_in(1)%globalparam%current_tot)
344 s_bt = sign(1.0_r8, coreprof_in(1)%toroid_field%b0)
345 s_q = sign(1.0_r8, coreprof_in(1)%profiles1d%q%value(1))
346 s_psi = sign(1.0_r8, coreprof_in(1)%psi%value(nrho)-coreprof_in(1)%psi%value(1))
347 s_jpar = sign(1.0_r8, coreprof_in(1)%profiles1d%jtot%value(1))
349 WRITE(*,*)
's_ip, s_bt, s_q, s_psi, s_jpar = ', s_ip, s_bt, s_q, s_psi, s_jpar
353 ALLOCATE (rhomod(nrho))
356 ALLOCATE (dpsi(nrho))
358 ALLOCATE (jpar(nrho))
361 ALLOCATE (dfun(nrho))
362 ALLOCATE (intfun(nrho))
364 ALLOCATE (
fdia(nrho))
366 ALLOCATE (vprime(nrho))
368 ALLOCATE (coreprof_out(1))
373 rho = coreprof_in(1)%rho_tor
374 psi = coreprof_in(1)%psi%value
375 qsf = coreprof_in(1)%profiles1d%q%value
376 jpar = coreprof_in(1)%profiles1d%jtot%value
378 r0 = coreprof_in(1)%toroid_field%r0
379 b0 = coreprof_in(1)%toroid_field%b0
381 CALL
l3deriv(equilibrium_in(1)%profiles_1d%volume, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
383 CALL
l3interp(equilibrium_in(1)%profiles_1d%F_dia, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
385 CALL
l3interp(equilibrium_in(1)%profiles_1d%gm2, equilibrium_in(1)%profiles_1d%rho_tor, npsi, &
393 CALL
derivn(nrho, rho, psi, dpsi)
394 qsf = 2.e0_r8 * itm_pi * b0 * rho / dpsi
400 fun = dpsi * r0 * b0 * vprime * gm2 /
fdia
402 jpar = - dfun / itm_mu0 / r0 / 2.e0_r8 / itm_pi / vprime / b0**2 *
fdia**2
406 IF (qsf(1)*s_q.GT.minval(qsf*s_q).AND.q0_flag.GT.0.0d0)
THEN
410 IF (qsf(irho)*s_q.LT.qsf_min*s_q)
THEN
416 IF (rho(irho).LT.rho_min)
THEN
420 fun = vprime * gm2 /
fdia * rho / qsf
422 jpar = dfun / itm_mu0 / vprime *
fdia**2
428 ELSE IF(flag.EQ.2)
THEN
430 fun = 2.e0_r8 * itm_pi * b0 / qsf
435 fun = vprime * gm2 /
fdia * rho / qsf
437 jpar = dfun / itm_mu0 / vprime *
fdia**2
442 ELSE IF(flag.EQ.3)
THEN
444 fun = jpar * itm_mu0 * vprime /
fdia**2 / rho
447 qsf = - vprime * gm2 /
fdia * rho / intfun
451 fun = 2.e0_r8 * itm_pi * b0 / qsf
462 CALL copy_cpo(coreprof_in(1), coreprof_out(1))
467 coreprof_out(1)%psi%value = psi
468 coreprof_out(1)%profiles1d%q%value = qsf
469 coreprof_out(1)%profiles1d%jtot%value = jpar
536 TYPE (type_coreprof
),
POINTER :: coreprof_in(:)
537 TYPE (type_coreprof
),
POINTER :: coreprof_out(:)
538 TYPE (type_equilibrium
),
POINTER :: equilibrium(:)
543 INTEGER :: nrho, irho
544 INTEGER :: npsi, ipsi
550 REAL (R8),
ALLOCATABLE :: rho(:)
551 REAL (R8),
ALLOCATABLE :: psi(:)
552 REAL (R8),
ALLOCATABLE :: qsf(:)
553 REAL (R8),
ALLOCATABLE :: jpar(:)
554 REAL (R8),
ALLOCATABLE :: intjpar(:)
556 REAL (R8),
ALLOCATABLE ::
fun(:)
557 REAL (R8),
ALLOCATABLE :: intfun(:)
559 REAL (R8),
ALLOCATABLE :: vprime(:)
560 REAL (R8),
ALLOCATABLE ::
fdia(:)
561 REAL (R8),
ALLOCATABLE :: gm2(:)
563 REAL (R8) :: curr_total, curr
566 REAL (R8),
ALLOCATABLE :: jpar_bg(:)
567 REAL (R8) :: curr_bg, bg
569 REAL (R8) :: s_ip, s_bt, s_q, s_psi, s_jpar
572 nrho =
SIZE (coreprof_in(1)%rho_tor, dim=1)
573 npsi =
SIZE (equilibrium(1)%profiles_1d%psi, dim=1)
575 s_ip = sign(1.0_r8, coreprof_in(1)%globalparam%current_tot)
576 s_bt = sign(1.0_r8, coreprof_in(1)%toroid_field%b0)
577 s_q = sign(1.0_r8, coreprof_in(1)%profiles1d%q%value(1))
578 s_psi = sign(1.0_r8, coreprof_in(1)%psi%value(nrho)-coreprof_in(1)%psi%value(1))
579 s_jpar = sign(1.0_r8, coreprof_in(1)%profiles1d%jtot%value(1))
588 ALLOCATE (jpar(nrho))
589 ALLOCATE (intjpar(nrho))
592 ALLOCATE (intfun(nrho))
594 ALLOCATE (vprime(nrho))
595 ALLOCATE (
fdia(nrho))
598 ALLOCATE (jpar_bg(nrho))
600 ALLOCATE (coreprof_out(1))
605 rho = coreprof_in(1)%rho_tor
606 psi = coreprof_in(1)%psi%value
607 qsf = coreprof_in(1)%profiles1d%q%value
608 jpar = coreprof_in(1)%profiles1d%jtot%value
610 curr_total = coreprof_in(1)%globalparam%current_tot
611 r0 = coreprof_in(1)%toroid_field%r0
612 b0 = coreprof_in(1)%toroid_field%b0
614 CALL
l3deriv(equilibrium(1)%profiles_1d%volume, equilibrium(1)%profiles_1d%rho_tor, npsi, &
616 CALL
l3interp(equilibrium(1)%profiles_1d%F_dia, equilibrium(1)%profiles_1d%rho_tor, npsi, &
618 CALL
l3interp(equilibrium(1)%profiles_1d%gm2, equilibrium(1)%profiles_1d%rho_tor, npsi, &
623 IF (j0_flag.GT.0)
THEN
625 IF (jpar(irho)*s_jpar.LE.0.0e0_r8) jpar(irho) = 1.0e-6_r8*s_jpar
631 fun = vprime * jpar / 2.0e0_r8 / itm_pi * b0 /
fdia**2
633 curr = intjpar(nrho) *
fdia(nrho)
637 curr_bg = curr_total - curr
639 IF (curr_bg*s_ip.LE.0.0_r8)
THEN
641 IF (intjpar(irho) *
fdia(irho)*s_ip.GE.curr_total*s_ip) jpar(irho) = 1.0e-6_r8*s_jpar
644 ELSE IF (curr_bg*s_ip.GT.0.0_r8)
THEN
646 jpar_bg = bg * (1.0_r8 - 0.5_r8/(1.0_r8+((rho(nrho)-rho)/(rho(nrho)*0.05_r8))**3))
647 7
fun = vprime * max(jpar*s_jpar,jpar_bg*s_jpar)*s_jpar / 2.0e0_r8 / itm_pi * b0 /
fdia**2
649 curr = intjpar(nrho) *
fdia(nrho)
651 IF (abs(1.0_r8-curr/curr_total).GE.1.e-4_r8)
THEN
652 bg = bg * curr_total / curr
653 jpar_bg = jpar_bg * curr_total / curr
658 IF (jpar_bg(irho)*s_jpar.GT.jpar(irho)*s_jpar)
THEN
659 jpar(irho:nrho) = jpar_bg(irho:nrho)
674 10
fun = jpar * itm_mu0 * vprime /
fdia**2 / rho
677 qsf = - vprime * gm2 /
fdia * rho / intfun
682 fun = 2.e0_r8 * itm_pi * b0 / qsf
690 CALL copy_cpo(coreprof_in(1), coreprof_out(1))
695 coreprof_out(1)%psi%value = psi
696 coreprof_out(1)%profiles1d%q%value = qsf
697 coreprof_out(1)%profiles1d%jtot%value = jpar
766 TYPE (type_coreprof
),
POINTER :: coreprof_in(:)
767 TYPE (type_coreprof
),
POINTER :: coreprof_out(:)
768 TYPE (type_equilibrium
),
POINTER :: equilibrium(:)
773 INTEGER :: nrho, irho
781 REAL (R8),
ALLOCATABLE :: rho(:)
782 REAL (R8),
ALLOCATABLE :: psi(:)
783 REAL (R8),
ALLOCATABLE :: qsf(:)
784 REAL (R8),
ALLOCATABLE :: jpar(:)
785 REAL (R8),
ALLOCATABLE :: intjpar(:)
787 REAL (R8),
ALLOCATABLE ::
fun(:)
788 REAL (R8),
ALLOCATABLE :: intfun(:)
790 REAL (R8),
ALLOCATABLE :: vprime(:)
791 REAL (R8),
ALLOCATABLE ::
fdia(:)
792 REAL (R8),
ALLOCATABLE :: gm2(:)
794 REAL (R8) :: curr_total, curr
797 REAL (R8) :: s_ip, s_bt, s_q, s_psi, s_jpar
802 nrho =
SIZE (coreprof_in(1)%rho_tor, dim=1)
803 npsi =
SIZE (equilibrium(1)%profiles_1d%psi, dim=1)
805 s_ip = sign(1.0_r8, coreprof_in(1)%globalparam%current_tot)
806 s_bt = sign(1.0_r8, coreprof_in(1)%toroid_field%b0)
807 s_q = sign(1.0_r8, coreprof_in(1)%profiles1d%q%value(1))
808 s_psi = sign(1.0_r8, coreprof_in(1)%psi%value(nrho)-coreprof_in(1)%psi%value(1))
809 s_jpar = sign(1.0_r8, coreprof_in(1)%profiles1d%jtot%value(1))
811 WRITE(*,*)
's_ip, s_bt, s_q, s_psi, s_jpar = ', s_ip, s_bt, s_q, s_psi, s_jpar
818 ALLOCATE (jpar(nrho))
819 ALLOCATE (intjpar(nrho))
822 ALLOCATE (intfun(nrho))
824 ALLOCATE (vprime(nrho))
825 ALLOCATE (
fdia(nrho))
829 ALLOCATE (coreprof_out(1))
834 rho = coreprof_in(1)%rho_tor
835 psi = coreprof_in(1)%psi%value
836 qsf = coreprof_in(1)%profiles1d%q%value
837 jpar = coreprof_in(1)%profiles1d%jtot%value
838 curr_total = coreprof_in(1)%globalparam%current_tot
840 r0 = coreprof_in(1)%toroid_field%r0
841 b0 = coreprof_in(1)%toroid_field%b0
844 CALL
l3deriv(equilibrium(1)%profiles_1d%volume, equilibrium(1)%profiles_1d%rho_tor, npsi, &
846 CALL
l3interp(equilibrium(1)%profiles_1d%F_dia, equilibrium(1)%profiles_1d%rho_tor, npsi, &
848 CALL
l3interp(equilibrium(1)%profiles_1d%gm2, equilibrium(1)%profiles_1d%rho_tor, npsi, &
854 IF (jpar(irho)*s_jpar.LE.0.0e0_r8) jpar(irho) = 1.0e-6_r8*s_jpar
859 fun = vprime * jpar / 2.0e0_r8 / itm_pi * b0 /
fdia**2
861 curr = intjpar(nrho) *
fdia(nrho)
864 IF (intjpar(irho) *
fdia(irho)*s_jpar.GT.curr_total*s_jpar) jpar(irho) = 1.0e-6_r8*s_jpar
869 CALL copy_cpo(coreprof_in(1), coreprof_out(1))
874 IF (j0_flag.GT.0) coreprof_out(1)%profiles1d%jtot%value = jpar
931 inty(1)=y(1)*x(1)**2/2.e0_r8
933 inty(i)=inty(i-1)+(y(i-1)*x(i-1)+y(i)*x(i))*(x(i)-x(i-1))/2.e0_r8
960 inty(1)=y(1)*x(1)/2.0_r8
962 inty(i)=inty(i-1)+(y(i)+y(i-1))*(x(i)-x(i-1))/2.0_r8
997 REAL (R8) :: h(n),dy2(n)
1004 dy1(i)=((y(i+1)-y(i))*h(i-1)/h(i)+(y(i)-y(i-1))*h(i)/h(i-1)) &
1006 dy2(i)=2.e0_r8*((y(i-1)-y(i))/h(i-1)+(y(i+1)-y(i))/h(i)) &
1010 dy1(1)=dy1(2)-dy2(2)*h(1)
1011 dy1(n)=dy1(n-1)+dy2(n-1)*h(n-1)
subroutine l3deriv(y_in, x_in, nr_in, dydx_out, x_out, nr_out)
subroutine derivn(N, X, Y, DY1)
These subroutines calculate first and second derivatives, DY1 and DY2, of function Y respect to argum...
subroutine l3interp(y_in, x_in, nr_in, y_out, x_out, nr_out)
subroutine parabolic_prof(COREPROF_IN, EQUILIBRIUM_IN, COREPROF_OUT, EQUILIBRIUM_OUT)
real(r8) function fdia(psi_n)
subroutine negative_current(J0_FLAG, COREPROF_IN, EQUILIBRIUM, COREPROF_OUT)
subroutine readjust_profiles(PROF_FLAG, Q0_FLAG, COREPROF_IN, EQUILIBRIUM_IN, COREPROF_OUT)
subroutine integral(n, h, r, f, int)
subroutine correct_current_prof(J0_FLAG, COREPROF_IN, EQUILIBRIUM, COREPROF_OUT)