32 geo_ax, mag_ax, plasma_ax, &
35 elong_up, elong_low, &
38 npsi, ndim1, ndim2, npoints)
57 TYPE (type_equilibrium
),
POINTER :: equilibrium(:)
58 TYPE (type_equilibrium
),
POINTER :: equilibrium_out(:)
64 REAL (R8) :: geo_ax(3)
65 REAL (R8) :: mag_ax(3)
66 REAL (R8) :: plasma_ax(3)
71 REAL (R8) :: elong_up, elong_low
73 REAL (R8) :: tria_up, tria_low
77 REAL (R8),
ALLOCATABLE :: rho(:)
78 REAL (R8),
ALLOCATABLE :: rho_2d(:)
81 INTEGER :: ndim1, idim1
82 INTEGER :: ndim2, idim2
83 INTEGER :: npoints, itheta
85 CHARACTER*1000 :: output_diag
90 diag%ERROR_MESSAGE =
" "
95 IF(
ASSOCIATED(equilibrium_out))
DEALLOCATE (equilibrium_out)
96 ALLOCATE (equilibrium_out(1))
99 equilibrium_out(1)%global_param%i_plasma = ip
100 equilibrium_out(1)%global_param%toroid_field%r0 = geo_ax(1)
101 equilibrium_out(1)%global_param%toroid_field%b0 = geo_ax(3)
103 equilibrium_out(1)%global_param%mag_axis%position%r = mag_ax(1)
104 equilibrium_out(1)%global_param%mag_axis%position%z = mag_ax(2)
105 equilibrium_out(1)%global_param%mag_axis%bphi = mag_ax(3)
109 CALL
calculate_rho_tor(plasma_ax, mag_ax, amin, elong_up, elong_low, tria_up, tria_low, &
111 IF (diag%IERR == -1 .OR. diag%IERR == 2 ) goto 90
114 ALLOCATE (equilibrium_out(1)%profiles_1d%rho_tor(npsi))
117 rho(ipsi) = rho_bnd/(npsi-1)*(ipsi-1)
119 equilibrium_out(1)%profiles_1d%rho_tor = rho
124 ALLOCATE (equilibrium_out(1)%profiles_1d%elongation(npsi))
125 ALLOCATE (equilibrium_out(1)%profiles_1d%tria_upper(npsi))
126 ALLOCATE (equilibrium_out(1)%profiles_1d%tria_lower(npsi))
128 ALLOCATE (equilibrium_out(1)%profiles_1d%r_inboard(npsi))
129 ALLOCATE (equilibrium_out(1)%profiles_1d%r_outboard(npsi))
131 ALLOCATE (equilibrium_out(1)%profiles_1d%r_inboard(npsi))
132 ALLOCATE (equilibrium_out(1)%profiles_1d%r_outboard(npsi))
133 ALLOCATE (equilibrium_out(1)%profiles_1d%gm1(npsi))
134 ALLOCATE (equilibrium_out(1)%profiles_1d%gm2(npsi))
135 ALLOCATE (equilibrium_out(1)%profiles_1d%gm3(npsi))
136 ALLOCATE (equilibrium_out(1)%profiles_1d%gm4(npsi))
137 ALLOCATE (equilibrium_out(1)%profiles_1d%gm5(npsi))
138 ALLOCATE (equilibrium_out(1)%profiles_1d%gm6(npsi))
139 ALLOCATE (equilibrium_out(1)%profiles_1d%gm7(npsi))
140 ALLOCATE (equilibrium_out(1)%profiles_1d%gm8(npsi))
141 ALLOCATE (equilibrium_out(1)%profiles_1d%gm9(npsi))
142 ALLOCATE (equilibrium_out(1)%profiles_1d%volume(npsi))
143 ALLOCATE (equilibrium_out(1)%profiles_1d%vprime(npsi))
144 ALLOCATE (equilibrium_out(1)%profiles_1d%area(npsi))
145 ALLOCATE (equilibrium_out(1)%profiles_1d%aprime(npsi))
146 ALLOCATE (equilibrium_out(1)%profiles_1d%F_dia(npsi))
147 ALLOCATE (equilibrium_out(1)%profiles_1d%rho_vol(npsi))
149 equilibrium_out(1)%profiles_1d%elongation(npsi) = (elong_up + elong_low) / 2._r8
150 equilibrium_out(1)%profiles_1d%tria_upper(npsi) = tria_up
151 equilibrium_out(1)%profiles_1d%tria_lower(npsi) = tria_low
153 equilibrium_out(1)%profiles_1d%r_inboard(npsi) = plasma_ax(1) - amin
154 equilibrium_out(1)%profiles_1d%r_outboard(npsi) = plasma_ax(1) + amin
155 equilibrium_out(1)%profiles_1d%gm1 = 1.e0_r8 / plasma_ax(1)**2
156 equilibrium_out(1)%profiles_1d%gm2 = 1.e0_r8 / plasma_ax(1)**2
157 equilibrium_out(1)%profiles_1d%gm3 = 1.e0_r8
158 equilibrium_out(1)%profiles_1d%gm4 = 1.e0_r8 / plasma_ax(3)**2
159 equilibrium_out(1)%profiles_1d%gm5 = plasma_ax(3)**2
160 equilibrium_out(1)%profiles_1d%gm6 = 1.e0_r8 / plasma_ax(3)**2
161 equilibrium_out(1)%profiles_1d%gm7 = 1.e0_r8
162 equilibrium_out(1)%profiles_1d%gm8 = plasma_ax(1)
163 equilibrium_out(1)%profiles_1d%gm9 = 1.e0_r8 / plasma_ax(1)
164 equilibrium_out(1)%profiles_1d%volume = 2.e0_r8 * itm_pi**2 * rho**2 * plasma_ax(1)
165 equilibrium_out(1)%profiles_1d%vprime = 4.e0_r8 * itm_pi**2 * rho * plasma_ax(1)
166 equilibrium_out(1)%profiles_1d%area = itm_pi * rho**2
167 equilibrium_out(1)%profiles_1d%aprime = 4.e0_r8 * itm_pi**2 * plasma_ax(1)
168 equilibrium_out(1)%profiles_1d%F_dia = plasma_ax(3) * plasma_ax(1)
169 equilibrium_out(1)%profiles_1d%rho_vol = sqrt(equilibrium_out(1)%profiles_1d%volume/equilibrium_out(1)%profiles_1d%volume(npsi))
173 equilibrium_out(1)%eqgeometry%geom_axis%r = plasma_ax(1)
174 equilibrium_out(1)%eqgeometry%geom_axis%z = plasma_ax(2)
176 equilibrium_out(1)%eqgeometry%a_minor = amin
177 equilibrium_out(1)%eqgeometry%elongation = (elong_up + elong_low) / 2._r8
178 equilibrium_out(1)%eqgeometry%elong_upper = elong_up
179 equilibrium_out(1)%eqgeometry%elong_lower = elong_low
180 equilibrium_out(1)%eqgeometry%tria_upper = tria_up
181 equilibrium_out(1)%eqgeometry%tria_lower = tria_low
185 ALLOCATE (equilibrium_out(1)%eqgeometry%boundary(1))
186 ALLOCATE (equilibrium_out(1)%eqgeometry%boundary(1)%r(npoints))
187 ALLOCATE (equilibrium_out(1)%eqgeometry%boundary(1)%z(npoints))
190 theta =
REAL(itheta-1,r8)/
REAL(npoints-1,r8)*2.0_r8*itm_pi
191 IF (theta.LE.itm_pi) tria = tria_up
192 IF (theta.LE.itm_pi) elong = elong_up
193 IF (theta.GT.itm_pi) tria = tria_low
194 IF (theta.GT.itm_pi) elong = elong_low
195 equilibrium_out(1)%eqgeometry%boundary(1)%r(itheta) = plasma_ax(1) + amin * (cos(theta) - tria*(sin(theta))**2)
196 equilibrium_out(1)%eqgeometry%boundary(1)%z(itheta) = plasma_ax(2) + amin * elong * sin(theta)
198 IF (abs(equilibrium_out(1)%eqgeometry%boundary(1)%z(itheta)).LE.1.e-15_r8) &
199 equilibrium_out(1)%eqgeometry%boundary(1)%z(itheta) = 0.0e0_r8
204 ALLOCATE (rho_2d(ndim1))
205 rho_loop2:
DO idim1=1,ndim1
206 rho_2d(idim1) = rho_bnd/(ndim1-1)*(idim1-1)
209 ALLOCATE(equilibrium_out(1)%coord_sys%grid_type(1))
210 ALLOCATE(equilibrium_out(1)%coord_sys%grid%dim1(ndim1))
211 ALLOCATE(equilibrium_out(1)%coord_sys%grid%dim2(ndim2))
212 ALLOCATE(equilibrium_out(1)%coord_sys%position%R(ndim1,ndim2))
213 ALLOCATE(equilibrium_out(1)%coord_sys%position%Z(ndim1,ndim2))
217 equilibrium_out(1)%coord_sys%grid_type =
'(rho,theta)'
218 equilibrium_out(1)%coord_sys%grid%dim1 = rho_2d
221 theta =
REAL(idim2-1,r8)/
REAL(ndim2-1,r8)*2.0_r8*itm_pi
222 equilibrium_out(1)%coord_sys%grid%dim2(idim2) = theta
225 IF (theta.LE.itm_pi) tria = tria_up
226 IF (theta.GT.itm_pi) tria = tria_low
227 IF (theta.LE.itm_pi) elong = elong_up
228 IF (theta.GT.itm_pi) elong = elong_low
230 equilibrium_out(1)%coord_sys%position%R(idim1,idim2) = plasma_ax(1) + amin * (cos(theta) - tria*(sin(theta))**2) * rho_2d(idim1)/rho_2d(ndim1)
231 equilibrium_out(1)%coord_sys%position%Z(idim1,idim2) = plasma_ax(2) + amin * rho_2d(idim1)/rho_2d(ndim1) * elong * sin(theta)
232 IF (abs(equilibrium_out(1)%eqgeometry%boundary(1)%z(idim2)).LE.1.e-15_r8) &
233 equilibrium_out(1)%coord_sys%position%Z(idim1,idim2) = 0.0e0_r8
241 90 output_diag =
"GEOMETRY_FROM_WF_PARAMETERS: "//trim(adjustl(diag%ERROR_MESSAGE))
242 nline = floor(len_trim(adjustl(output_diag))/132.001)+1
243 ALLOCATE (equilibrium_out(1)%codeparam%codename(1))
244 ALLOCATE (equilibrium_out(1)%codeparam%codeversion(1))
245 ALLOCATE (equilibrium_out(1)%codeparam%output_diag(nline))
247 equilibrium_out(1)%codeparam%codename =
'GEOM_FROM_WF_PARAMETERS'
248 equilibrium_out(1)%codeparam%codeversion =
'GEOM_FROM_WF_PARAMETERS_4.10b.10'
249 equilibrium_out(1)%codeparam%output_flag = diag%IERR
251 equilibrium_out(1)%codeparam%output_diag(i) = output_diag(((i-1)*132+1):(i*132))
266 ndim1, ndim2,ierr_out,error_mes)
282 USE deallocate_structures
287 TYPE (type_equilibrium
),
POINTER :: equilibrium(:)
288 TYPE (type_equilibrium
),
POINTER :: equilibrium_out(:)
298 REAL (R8) :: elong_up, elong_low
300 REAL (R8) :: tria_up, tria_low
302 REAL (R8) :: geo_ax(3)
303 REAL (R8) :: mag_ax(3)
304 REAL (R8) :: plasma_ax(3)
309 INTEGER :: npsi=200, ipsi
310 INTEGER :: npoints=300, itheta
311 INTEGER :: ndim1, idim1
312 INTEGER :: ndim2, idim2
313 INTEGER :: nline, i, iwarning
314 CHARACTER*1000 :: output_diag
315 character*255 :: error_mes
321 if (equilibrium(1)%time.eq.itm_r8_invalid)
then
323 error_mes=
'equilibrium is not present on input, you might check your basic paramters like username, shot_in, run_in, etc.'
324 allocate(equilibrium_out(1))
330 diag%ERROR_MESSAGE =
" "
335 ALLOCATE (equilibrium_out(1))
336 CALL copy_cpo(equilibrium(1), equilibrium_out(1))
341 IF (equilibrium(1)%global_param%i_plasma.NE.equilibrium(1)%global_param%i_plasma &
342 .OR. .NOT. (itm_is_valid(equilibrium(1)%global_param%i_plasma)))
THEN
343 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"PLASMA CURRENT is not present in input EQUILIBRIUM. "
349 elong_up, elong_low, tria_up, tria_low, diag)
350 IF (diag%IERR == -1 .OR. diag%IERR == 2) goto 100
353 IF (.NOT.
ASSOCIATED (equilibrium(1)%profiles_1d%rho_tor))
THEN
354 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"RHO_TOR is not present in input EQUILIBRIUM. "
355 iwarning = iwarning + 1
357 CALL
calculate_rho_tor(plasma_ax, mag_ax, amin, elong_up, elong_low, tria_up, tria_low, &
359 IF (diag%IERR == -1 .OR. diag%IERR == 2 ) goto 100
361 IF (
ASSOCIATED (equilibrium_out(1)%profiles_1d%rho_tor))
THEN
362 npsi =
SIZE(equilibrium_out(1)%profiles_1d%rho_tor)
364 ALLOCATE (equilibrium_out(1)%profiles_1d%rho_tor(npsi))
368 equilibrium_out(1)%profiles_1d%rho_tor(ipsi) = rho_bnd/(npsi-1)*(ipsi-1)
371 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"RHO_TOR was recalculated. "
380 IF (equilibrium_out(1)%global_param%toroid_field%r0.NE.equilibrium_out(1)%global_param%toroid_field%r0 &
381 .OR. .NOT. (itm_is_valid(equilibrium_out(1)%global_param%toroid_field%r0)))
THEN
382 equilibrium_out(1)%global_param%toroid_field%r0 = geo_ax(1)
384 IF (equilibrium_out(1)%global_param%toroid_field%b0.NE.equilibrium_out(1)%global_param%toroid_field%b0 &
385 .OR. .NOT. (itm_is_valid(equilibrium_out(1)%global_param%toroid_field%b0)))
THEN
386 equilibrium_out(1)%global_param%toroid_field%b0 = geo_ax(3)
388 IF (equilibrium_out(1)%global_param%mag_axis%position%r.NE.equilibrium_out(1)%global_param%mag_axis%position%r &
389 .OR. .NOT. (itm_is_valid(equilibrium_out(1)%global_param%mag_axis%position%r)))
THEN
390 equilibrium_out(1)%global_param%mag_axis%position%r = mag_ax(1)
392 IF (equilibrium_out(1)%global_param%mag_axis%position%z.NE.equilibrium_out(1)%global_param%mag_axis%position%z &
393 .OR. .NOT. (itm_is_valid(equilibrium_out(1)%global_param%mag_axis%position%z)))
THEN
394 equilibrium_out(1)%global_param%mag_axis%position%z = mag_ax(2)
396 IF (equilibrium_out(1)%global_param%mag_axis%bphi.NE.equilibrium_out(1)%global_param%mag_axis%bphi &
397 .OR. .NOT. (itm_is_valid(equilibrium_out(1)%global_param%mag_axis%bphi)))
THEN
398 equilibrium_out(1)%global_param%mag_axis%bphi = mag_ax(3)
402 IF (equilibrium_out(1)%eqgeometry%geom_axis%r.NE.equilibrium_out(1)%eqgeometry%geom_axis%r &
403 .OR. .NOT. (itm_is_valid(equilibrium_out(1)%eqgeometry%geom_axis%r)))
THEN
404 equilibrium_out(1)%eqgeometry%geom_axis%r = plasma_ax(1)
406 IF (equilibrium_out(1)%eqgeometry%geom_axis%z.NE.equilibrium_out(1)%eqgeometry%geom_axis%z &
407 .OR. .NOT. (itm_is_valid(equilibrium_out(1)%eqgeometry%geom_axis%z)))
THEN
408 equilibrium_out(1)%eqgeometry%geom_axis%z = plasma_ax(2)
410 IF (equilibrium_out(1)%eqgeometry%a_minor.NE.equilibrium_out(1)%eqgeometry%a_minor &
411 .OR. .NOT. (itm_is_valid(equilibrium_out(1)%eqgeometry%a_minor)))
THEN
412 equilibrium_out(1)%eqgeometry%a_minor = amin
414 IF (equilibrium_out(1)%eqgeometry%elongation.NE.equilibrium_out(1)%eqgeometry%elongation &
415 .OR. .NOT. (itm_is_valid(equilibrium_out(1)%eqgeometry%elongation)))
THEN
416 equilibrium_out(1)%eqgeometry%elongation = (elong_up + elong_low) / 2._r8
418 IF (equilibrium_out(1)%eqgeometry%elong_upper.NE.equilibrium_out(1)%eqgeometry%elong_upper &
419 .OR. .NOT. (itm_is_valid(equilibrium_out(1)%eqgeometry%elong_upper)))
THEN
420 equilibrium_out(1)%eqgeometry%elong_upper = elong_up
422 IF (equilibrium_out(1)%eqgeometry%elong_lower.NE.equilibrium_out(1)%eqgeometry%elong_lower &
423 .OR. .NOT. (itm_is_valid(equilibrium_out(1)%eqgeometry%elong_lower)))
THEN
424 equilibrium_out(1)%eqgeometry%elong_lower = elong_low
426 IF (equilibrium_out(1)%eqgeometry%tria_upper.NE.equilibrium_out(1)%eqgeometry%tria_upper &
427 .OR. .NOT. (itm_is_valid(equilibrium_out(1)%eqgeometry%tria_upper)))
THEN
428 equilibrium_out(1)%eqgeometry%tria_upper = tria_up
430 IF (equilibrium_out(1)%eqgeometry%tria_lower.NE.equilibrium_out(1)%eqgeometry%tria_lower &
431 .OR. .NOT. (itm_is_valid(equilibrium_out(1)%eqgeometry%tria_lower)))
THEN
432 equilibrium_out(1)%eqgeometry%tria_lower = tria_low
438 IF(.NOT.
ASSOCIATED (equilibrium_out(1)%eqgeometry%boundary)) &
439 ALLOCATE (equilibrium_out(1)%eqgeometry%boundary(1))
441 IF (.NOT.
ASSOCIATED (equilibrium_out(1)%eqgeometry%boundary(1)%r) .OR. &
442 .NOT.
ASSOCIATED (equilibrium_out(1)%eqgeometry%boundary(1)%z))
THEN
444 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"Boundary is not defined in input EQUILIBRIUM. "
445 iwarning = iwarning + 1
448 IF(
ASSOCIATED (equilibrium_out(1)%eqgeometry%boundary(1)%r))
THEN
449 npoints =
SIZE(equilibrium_out(1)%eqgeometry%boundary(1)%r)
450 IF(.NOT.
ASSOCIATED(equilibrium_out(1)%eqgeometry%boundary(1)%z)) &
451 ALLOCATE (equilibrium_out(1)%eqgeometry%boundary(1)%z(npoints))
453 ELSE IF (
ASSOCIATED(equilibrium_out(1)%eqgeometry%boundary(1)%z) )
THEN
454 npoints =
SIZE(equilibrium_out(1)%eqgeometry%boundary(1)%z)
455 ALLOCATE (equilibrium_out(1)%eqgeometry%boundary(1)%r(npoints))
458 ALLOCATE (equilibrium_out(1)%eqgeometry%boundary(1)%r(npoints))
459 ALLOCATE (equilibrium_out(1)%eqgeometry%boundary(1)%z(npoints))
464 theta =
REAL(itheta-1,r8)/
REAL(npoints-1,r8)*2.0_r8*itm_pi
465 IF (theta.LE.itm_pi) tria = tria_up
466 IF (theta.LE.itm_pi) elong = elong_up
467 IF (theta.GT.itm_pi) tria = tria_low
468 IF (theta.GT.itm_pi) elong = elong_low
469 equilibrium_out(1)%eqgeometry%boundary(1)%r(itheta) = plasma_ax(1) + amin * (cos(theta) - tria*(sin(theta))**2)
470 equilibrium_out(1)%eqgeometry%boundary(1)%z(itheta) = plasma_ax(2) + amin * elong * sin(theta)
472 IF (abs(equilibrium_out(1)%eqgeometry%boundary(1)%z(itheta)).LE.1.e-15_r8) &
473 equilibrium_out(1)%eqgeometry%boundary(1)%z(itheta) = 0.0e0_r8
481 IF (.not.
ASSOCIATED(equilibrium_out(1)%coord_sys%position%R))
THEN
482 IF(
ASSOCIATED(equilibrium_out(1)%coord_sys%grid_type)) &
483 DEALLOCATE(equilibrium_out(1)%coord_sys%grid_type)
484 IF(
ASSOCIATED(equilibrium_out(1)%coord_sys%grid%dim1)) &
485 DEALLOCATE(equilibrium_out(1)%coord_sys%grid%dim1)
486 IF(
ASSOCIATED(equilibrium_out(1)%coord_sys%grid%dim2)) &
487 DEALLOCATE(equilibrium_out(1)%coord_sys%grid%dim2)
488 IF(
ASSOCIATED(equilibrium_out(1)%coord_sys%position%R)) &
489 DEALLOCATE(equilibrium_out(1)%coord_sys%position%R)
490 IF(
ASSOCIATED(equilibrium_out(1)%coord_sys%position%Z)) &
491 DEALLOCATE(equilibrium_out(1)%coord_sys%position%Z)
493 ALLOCATE(equilibrium_out(1)%coord_sys%grid_type(1))
494 ALLOCATE(equilibrium_out(1)%coord_sys%grid%dim1(ndim1))
495 ALLOCATE(equilibrium_out(1)%coord_sys%grid%dim2(ndim2))
496 ALLOCATE(equilibrium_out(1)%coord_sys%position%R(ndim1,ndim2))
497 ALLOCATE(equilibrium_out(1)%coord_sys%position%Z(ndim1,ndim2))
499 equilibrium_out(1)%coord_sys%grid_type =
'empty'
500 equilibrium_out(1)%coord_sys%grid%dim1 = 0.0_r8
501 equilibrium_out(1)%coord_sys%grid%dim2 = 0.0_r8
502 equilibrium_out(1)%coord_sys%position%R = 0.0_r8
503 equilibrium_out(1)%coord_sys%position%Z = 0.0_r8
510 100 output_diag =
"GEOMETRY_FROM_CPO: "//trim(adjustl(diag%ERROR_MESSAGE))
511 nline = floor(len_trim(adjustl(output_diag))/132.001)+1
512 IF(
ASSOCIATED(equilibrium_out(1)%codeparam%codename)) &
513 DEALLOCATE(equilibrium_out(1)%codeparam%codename)
514 IF(
ASSOCIATED(equilibrium_out(1)%codeparam%codeversion)) &
515 DEALLOCATE(equilibrium_out(1)%codeparam%codeversion)
516 IF(
ASSOCIATED(equilibrium_out(1)%codeparam%output_diag)) &
517 DEALLOCATE(equilibrium_out(1)%codeparam%output_diag)
518 ALLOCATE (equilibrium_out(1)%codeparam%codename(1))
519 ALLOCATE (equilibrium_out(1)%codeparam%codeversion(1))
520 ALLOCATE (equilibrium_out(1)%codeparam%output_diag(nline))
522 equilibrium_out(1)%codeparam%codename =
'GEOM_FROM_CPO'
523 equilibrium_out(1)%codeparam%codeversion =
'GEOM_FROM_CPO_4.10b.10'
525 IF (diag%IERR == 0 .AND. iwarning /= 0 ) diag%IERR = iwarning
527 equilibrium_out(1)%codeparam%output_flag = diag%IERR
529 equilibrium_out(1)%codeparam%output_diag(i) = output_diag(((i-1)*132+1):(i*132))
544 elong_up, elong_low, &
571 REAL (R8) :: plasma_ax(3)
572 REAL (R8) :: mag_ax(3)
574 REAL (R8) :: elong_up
575 REAL (R8) :: elong_low
577 REAL (R8) :: tria_low
589 REAL (R8) :: yd1,yt2,yge
590 REAL (R8) :: y1,y2,y3,y4,y5,y6
597 yd = mag_ax(1) - plasma_ax(1)
599 ye = (elong_up + elong_low) / 2._r8
600 yt = (tria_up + tria_low) / 2._r8
608 IF (abs(yge) .GT. 1._r8) goto 8
613 yd1 = 1._r8+yt2*(yt2-2._r8/yge)
619 y1 = (2._r8-yt2*yge)*yd1/(1._r8+yd1)
621 y3 = sqrt(1._r8-yt2*yge+yge*yd1)
622 y4 = sqrt(1._r8-yt2*yge-yge*yd1)
625 y1 = (y1+y2)/(y3+(1._r8-yt2)*y5)-(y1-y2)/(y4+(1._r8+yt2)*y6)
626 y1 = y1/sqrt(2._r8*(1._r8-yt2*yge+y5*y6))
633 y1 = (1._r8-yt2)*y5+(1._r8+yt2)*y6
634 y1 = (1._r8-y1/sqrt(2._r8*(1._r8-yt2*yge+y5*y6)))/yt2
639 rho = 2._r8*sqrt(yr*ya*ye*y1)
648 8 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"CALCULATE_RHO_TOR >>> Illegal input: R+Delta < a. "
653 9 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"CALCULATE_RHO_TOR >>> Illegal input. "
671 geo_ax, mag_ax, plasma_ax, &
674 elong_up, elong_low, &
693 TYPE (type_equilibrium
),
POINTER :: equilibrium(:)
701 REAL (R8) :: r_0, z_0, b_0
702 REAL (R8) :: r_mag, z_mag, b_mag
703 REAL (R8) :: r_pla, z_pla, b_pla
707 REAL (R8) :: elong_up, elong_low
708 REAL (R8) :: tria_up, tria_low
711 REAL (R8) :: geo_ax(3)
712 REAL (R8) :: mag_ax(3)
713 REAL (R8) :: plasma_ax(3)
715 REAL (R8) :: amin_tmp
716 REAL (R8) :: rgeo_tmp
717 REAL (R8) :: zgeo_tmp
718 REAL (R8) :: tria_upper_tmp
719 REAL (R8) :: tria_lower_tmp
720 REAL (R8) :: tria_tmp
721 REAL (R8) :: elong_upper_tmp
722 REAL (R8) :: elong_lower_tmp
723 REAL (R8) :: elong_tmp
724 LOGICAL :: l_have_boundary
725 INTEGER :: iwarning, ierror
728 l_have_boundary = .false.
733 IF(.NOT.
ASSOCIATED (equilibrium(1)%eqgeometry%boundary)) &
734 ALLOCATE (equilibrium(1)%eqgeometry%boundary(1))
736 IF (
ASSOCIATED (equilibrium(1)%eqgeometry%boundary(1)%r) &
738 ASSOCIATED (equilibrium(1)%eqgeometry%boundary(1)%z) )
THEN
740 amin_tmp = (maxval(equilibrium(1)%eqgeometry%boundary(1)%r) - &
741 minval(equilibrium(1)%eqgeometry%boundary(1)%r)) / 2._r8
743 rgeo_tmp = (maxval(equilibrium(1)%eqgeometry%boundary(1)%r) + &
744 minval(equilibrium(1)%eqgeometry%boundary(1)%r)) / 2._r8
746 zgeo_tmp = (maxval(equilibrium(1)%eqgeometry%boundary(1)%z) + &
747 minval(equilibrium(1)%eqgeometry%boundary(1)%z)) / 2._r8
749 tria_upper_tmp = (equilibrium(1)%eqgeometry%boundary(1)%r(maxloc(equilibrium(1)%eqgeometry%boundary(1)%z,dim=1)) &
751 tria_lower_tmp = (equilibrium(1)%eqgeometry%boundary(1)%r(minloc(equilibrium(1)%eqgeometry%boundary(1)%z,dim=1)) &
753 tria_tmp =(tria_upper_tmp + tria_lower_tmp)/2.0_r8
755 elong_upper_tmp = (maxval(equilibrium(1)%eqgeometry%boundary(1)%z) - zgeo_tmp)/amin_tmp
756 elong_lower_tmp = (zgeo_tmp-minval(equilibrium(1)%eqgeometry%boundary(1)%z))/amin_tmp
757 elong_tmp = (elong_upper_tmp+elong_lower_tmp)/2.0_r8
758 l_have_boundary =.true.
764 IF (equilibrium(1)%eqgeometry%a_minor.EQ.equilibrium(1)%eqgeometry%a_minor &
765 .AND. itm_is_valid(equilibrium(1)%eqgeometry%a_minor))
THEN
766 amin = equilibrium(1)%eqgeometry%a_minor
768 IF (
ASSOCIATED (equilibrium(1)%profiles_1d%r_inboard).AND. &
769 ASSOCIATED (equilibrium(1)%profiles_1d%r_outboard))
THEN
770 amin = (equilibrium(1)%profiles_1d%r_outboard(
SIZE(equilibrium(1)%profiles_1d%r_outboard)) - &
771 equilibrium(1)%profiles_1d%r_inboard(
SIZE(equilibrium(1)%profiles_1d%r_inboard))) / 2._r8
772 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"MINOR RADIUS is approximated from other signals. "
773 iwarning = iwarning + 1
775 IF (
ASSOCIATED (equilibrium(1)%eqgeometry%boundary(1)%r))
THEN
776 amin = (maxval(equilibrium(1)%eqgeometry%boundary(1)%r) - &
777 minval(equilibrium(1)%eqgeometry%boundary(1)%r)) / 2._r8
778 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"MINOR RADIUS is approximated from boundary. "
779 iwarning = iwarning + 1
781 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"MINOR RADIUS is not present in input EQUILIBRIUM. "
789 IF (equilibrium(1)%eqgeometry%elongation.EQ.equilibrium(1)%eqgeometry%elongation &
790 .AND. itm_is_valid(equilibrium(1)%eqgeometry%elongation))
THEN
791 elong = equilibrium(1)%eqgeometry%elongation
793 IF (
ASSOCIATED (equilibrium(1)%profiles_1d%elongation))
THEN
794 elong = equilibrium(1)%profiles_1d%elongation(
SIZE(equilibrium(1)%profiles_1d%elongation))
796 IF (l_have_boundary)
THEN
798 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"ELONGATION is approximated from bounday. "
799 iwarning = iwarning + 1
801 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"ELONGATION is not present in input EQUILIBRIUM. "
809 IF (equilibrium(1)%eqgeometry%elong_upper.EQ.equilibrium(1)%eqgeometry%elong_upper &
810 .AND. itm_is_valid(equilibrium(1)%eqgeometry%elong_upper))
THEN
811 elong_up = equilibrium(1)%eqgeometry%elong_upper
813 IF (
ASSOCIATED (equilibrium(1)%profiles_1d%elongation))
THEN
814 elong_up = equilibrium(1)%profiles_1d%elongation(
SIZE(equilibrium(1)%profiles_1d%elongation))
816 IF (l_have_boundary)
THEN
817 elong_up = elong_upper_tmp
818 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"ELONG_UPPER is approximated from boundary. "
819 iwarning = iwarning + 1
821 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"ELONG_UPPER is not present in input EQUILIBRIUM. "
829 IF (equilibrium(1)%eqgeometry%elong_lower.EQ.equilibrium(1)%eqgeometry%elong_lower &
830 .AND. itm_is_valid(equilibrium(1)%eqgeometry%elong_lower) )
THEN
831 elong_low = equilibrium(1)%eqgeometry%elong_lower
833 IF (
ASSOCIATED (equilibrium(1)%profiles_1d%elongation))
THEN
834 elong_low = equilibrium(1)%profiles_1d%elongation(
SIZE(equilibrium(1)%profiles_1d%elongation))
836 IF (l_have_boundary)
THEN
837 elong_low = elong_lower_tmp
838 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"ELONG_LOWER is approximated from boundary. "
839 iwarning = iwarning +1
841 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"ELONG_LOWER is not present in input EQUILIBRIUM. "
849 IF (equilibrium(1)%eqgeometry%tria_upper.EQ.equilibrium(1)%eqgeometry%tria_upper &
850 .AND. itm_is_valid(equilibrium(1)%eqgeometry%tria_upper))
THEN
851 tria_up = equilibrium(1)%eqgeometry%tria_upper
853 IF (
ASSOCIATED (equilibrium(1)%profiles_1d%tria_upper))
THEN
854 tria_up= equilibrium(1)%profiles_1d%tria_upper(
SIZE(equilibrium(1)%profiles_1d%tria_upper))
856 IF (l_have_boundary)
THEN
857 tria_up = tria_upper_tmp
858 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"TRIANG_UPPER is approximated from bounday. "
859 iwarning = iwarning + 1
861 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"TRIANG_UPPER is not present in input EQUILIBRIUM. "
869 IF (equilibrium(1)%eqgeometry%tria_lower.EQ.equilibrium(1)%eqgeometry%tria_lower &
870 .AND. itm_is_valid(equilibrium(1)%eqgeometry%tria_lower))
THEN
871 tria_low = equilibrium(1)%eqgeometry%tria_lower
873 IF (
ASSOCIATED (equilibrium(1)%profiles_1d%tria_lower))
THEN
874 tria_low= equilibrium(1)%profiles_1d%tria_lower(
SIZE(equilibrium(1)%profiles_1d%tria_lower))
876 IF (l_have_boundary)
THEN
877 tria_low = tria_lower_tmp
878 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"TRIANG_LOWER is approximated from boundary. "
879 iwarning = iwarning + 1
881 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"TRIANG_LOWER is not present in input EQUILIBRIUM. "
891 IF (equilibrium(1)%global_param%toroid_field%r0.EQ.equilibrium(1)%global_param%toroid_field%r0 &
892 .AND. itm_is_valid(equilibrium(1)%global_param%toroid_field%r0))
THEN
893 r_0 = equilibrium(1)%global_param%toroid_field%r0
895 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"R_0 is not present in input EQUILIBRIUM. "
896 iwarning = iwarning + 1
897 IF (
ASSOCIATED (equilibrium(1)%profiles_1d%r_inboard).AND. &
898 ASSOCIATED (equilibrium(1)%profiles_1d%r_outboard))
THEN
899 r_0 = (equilibrium(1)%profiles_1d%r_inboard(
SIZE(equilibrium(1)%profiles_1d%r_inboard)) + &
900 equilibrium(1)%profiles_1d%r_outboard(
SIZE(equilibrium(1)%profiles_1d%r_outboard))) / 2._r8
901 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"R_0 is calculated from other sources. "
902 iwarning = iwarning + 1
904 IF (
ASSOCIATED (equilibrium(1)%eqgeometry%boundary(1)%r))
THEN
905 r_0 = (maxval(equilibrium(1)%eqgeometry%boundary(1)%r) + &
906 minval(equilibrium(1)%eqgeometry%boundary(1)%r)) / 2._r8
907 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"R_0 is calculated from other sources. "
908 iwarning = iwarning + 1
910 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"R_0 can not be defined from other signals. "
917 IF (equilibrium(1)%global_param%toroid_field%b0.EQ.equilibrium(1)%global_param%toroid_field%b0 &
918 .AND. itm_is_valid(equilibrium(1)%global_param%toroid_field%b0))
THEN
919 b_0 = equilibrium(1)%global_param%toroid_field%b0
921 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"B_0 is not present in input EQUILIBRIUM. "
928 IF (equilibrium(1)%eqgeometry%geom_axis%r.EQ.equilibrium(1)%eqgeometry%geom_axis%r &
929 .AND. itm_is_valid(equilibrium(1)%eqgeometry%geom_axis%r))
THEN
930 r_pla = equilibrium(1)%eqgeometry%geom_axis%r
934 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"R_plasma is approximated by Rgeo. "
935 iwarning = iwarning + 1
938 IF (equilibrium(1)%eqgeometry%geom_axis%z.EQ.equilibrium(1)%eqgeometry%geom_axis%z &
939 .AND. itm_is_valid(equilibrium(1)%eqgeometry%geom_axis%z))
THEN
940 z_pla = equilibrium(1)%eqgeometry%geom_axis%z
944 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"Z_plasma is set to Zgeo "
945 iwarning = iwarning + 1
948 b_pla = b_0 * r_0 / r_pla
951 IF (equilibrium(1)%global_param%mag_axis%position%r.EQ.equilibrium(1)%global_param%mag_axis%position%r &
952 .AND. itm_is_valid(equilibrium(1)%global_param%mag_axis%position%r))
THEN
953 r_mag = equilibrium(1)%global_param%mag_axis%position%r
956 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"R_mag is set to R_plasma. "
957 iwarning = iwarning + 1
960 IF (equilibrium(1)%global_param%mag_axis%position%z.EQ.equilibrium(1)%global_param%mag_axis%position%z &
961 .AND. itm_is_valid(equilibrium(1)%global_param%mag_axis%position%z))
THEN
962 z_mag = equilibrium(1)%global_param%mag_axis%position%z
965 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"Z_mag is set to Z_plasma. "
966 iwarning = iwarning + 1
969 IF (equilibrium(1)%global_param%mag_axis%bphi.EQ.equilibrium(1)%global_param%mag_axis%bphi &
970 .AND. itm_is_valid(equilibrium(1)%global_param%mag_axis%bphi))
THEN
971 b_mag = equilibrium(1)%global_param%mag_axis%bphi
973 b_mag = b_pla * r_pla / r_mag
974 diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//
"B_mag is recalculated from B_plasma* R_plasma/R_magM. "
975 iwarning = iwarning + 1
990 IF (iwarning == 0 .and. ierror == 0 )
THEN
993 IF (iwarning > 0 ) diag%IERR = 1
994 IF (ierror > 0 ) diag%IERR = 2
The module declares types of variables used in ETS (transport code)