18 type (type_equilibrium
),
pointer :: equil_in(:), equil_out(:)
20 character*131 :: helena_par
21 integer :: nr_grid, np_grid, n_psi_out, n_tht_out, n_bnd, n_prof_in, iopt_p, iopt_f, i, j, nchi, node
22 real (r8) :: quad_u_in, quad_l_in, bgeo_in
23 real (r8),
allocatable :: fraction_circ(:), surface_powers(:,:), surface_integrals(:,:)
24 real (r8),
allocatable :: volume_powers(:,:), volume_integrals(:,:), moments(:,:), vprime(:), dpsi_drho(:)
25 integer :: n_var_surfaces, n_int_surfaces, n_var_volumes, n_int_volumes, n_moments
26 real (r8),
allocatable :: rrflux(:,:),zzflux(:,:),psflux(:,:)
27 real (r8) :: amin_out, rgeo_out, zgeo_out, area_out, volume_out, betap_out, xip_out, xli_out, betat_out
28 real (r8) :: r_axis_out, z_axis_out, b_axis_out, psi_axis_out, psi_bnd_out, pi
29 integer :: ileft, iright
31 write(*,*)
'**********************************************'
32 write(*,*)
'* HELENA_ITM (ALFA) *'
33 write(*,*)
'**********************************************'
35 pi = 2.e0_r8 * asin(1.e0_r8)
37 if (.not.
associated(equil_in))
then
38 write(*,*) equil_in%eqgeometry%a_minor
39 write(*,*)
' equil_in not defined'
43 nr_grid = nint(
size(equil_in(1)%profiles_1d%psi)/2.0)
48 n_psi_out =
size(equil_in(1)%profiles_1d%psi)
49 n_tht_out =
size(equil_in(1)%eqgeometry%boundary(1)%r)
58 n_bnd =
size(equil_in(1)%eqgeometry%boundary(1)%r,1)
59 write(*,*)
' n_bnd : ',n_bnd
63 allocate(surface_powers(n_var_surfaces,n_int_surfaces), surface_integrals(n_psi_out,n_int_surfaces))
64 allocate(vprime(n_psi_out),dpsi_drho(n_psi_out))
66 surface_powers(1:3,1) = (/ -2, 0, 0 /)
67 surface_powers(1:3,2) = (/ -2, 0, 2 /)
68 surface_powers(1:3,3) = (/ 0, 0, 2 /)
69 surface_powers(1:3,4) = (/ 0,-1, 0 /)
70 surface_powers(1:3,5) = (/ 0, 1, 0 /)
71 surface_powers(1:3,6) = (/ 0,-1, 2 /)
72 surface_powers(1:3,7) = (/ 0, 0, 1 /)
73 surface_powers(1:3,8) = (/ 0, 0, 0 /)
78 allocate(volume_powers(n_var_volumes,n_int_volumes), volume_integrals(n_psi_out,n_int_volumes))
80 volume_powers(1:2,1) = (/ 0, 0 /)
81 volume_powers(1:2,2) = (/ -1, 1 /)
82 volume_powers(1:2,3) = (/ -1, 0 /)
84 allocate(rrflux(4,n_psi_out*n_tht_out),zzflux(4,n_psi_out*n_tht_out),psflux(4,n_psi_out*n_tht_out))
85 allocate(moments(n_moments,n_psi_out),fraction_circ(n_psi_out))
87 if (
associated(equil_in(1)%profiles_1d%pressure))
then
88 n_prof_in =
size(equil_in(1)%profiles_1d%pressure,1)
89 if (.not.
associated(equil_in(1)%profiles_1d%pprime))
allocate(equil_in(1)%profiles_1d%pprime(n_prof_in))
90 elseif (
associated(equil_in(1)%profiles_1d%pprime))
then
91 n_prof_in =
size(equil_in(1)%profiles_1d%pprime,1)
96 if (.not.
associated(equil_in(1)%profiles_1d%jphi))
then
97 write(*,*)
' jphi not associated '
98 allocate(equil_in(1)%profiles_1d%jphi(n_prof_in))
99 equil_in(1)%profiles_1d%jphi = 0.e0_r8
102 if (.not.
associated(equil_in(1)%profiles_1d%ffprime))
allocate(equil_in(1)%profiles_1d%ffprime(n_prof_in))
104 if (.not.
associated(equil_out))
allocate(equil_out(1))
106 allocate(equil_out(1)%profiles_1d%psi(n_psi_out))
107 allocate(equil_out(1)%profiles_1d%pressure(n_psi_out))
108 allocate(equil_out(1)%profiles_1d%pprime(n_psi_out))
109 allocate(equil_out(1)%profiles_1d%f_dia(n_psi_out))
110 allocate(equil_out(1)%profiles_1d%ffprime(n_psi_out))
111 allocate(equil_out(1)%profiles_1d%q(n_psi_out))
112 allocate(equil_out(1)%profiles_1d%jphi(n_psi_out))
113 allocate(equil_out(1)%profiles_1d%vprime(n_psi_out))
115 bgeo_in = equil_in(1)%eqconstraint%bvac_r%measured / equil_in(1)%eqgeometry%geom_axis%r
116 write(*,*)
'Bgeo_in ',bgeo_in
121 call
helena21(equil_in(1)%eqgeometry%boundary(1)%r(1:n_bnd),equil_in(1)%eqgeometry%boundary(1)%z(1:n_bnd),n_bnd, &
122 equil_in(1)%eqgeometry%geom_axis%r, equil_in(1)%eqgeometry%geom_axis%z, equil_in(1)%eqgeometry%a_minor, &
123 equil_in(1)%eqgeometry%elongation,equil_in(1)%eqgeometry%tria_upper, equil_in(1)%eqgeometry%tria_lower, &
124 quad_u_in, quad_l_in, &
126 equil_in(1)%profiles_1d%psi, equil_in(1)%profiles_1d%pprime, equil_in(1)%profiles_1d%ffprime, &
127 equil_in(1)%profiles_1d%pressure, equil_in(1)%profiles_1d%f_dia, equil_in(1)%profiles_1d%jphi, &
128 n_prof_in, iopt_p, iopt_f, &
130 equil_out(1)%profiles_1d%psi, equil_out(1)%profiles_1d%pprime, equil_out(1)%profiles_1d%ffprime, &
131 equil_out(1)%profiles_1d%pressure, equil_out(1)%profiles_1d%f_dia, equil_out(1)%profiles_1d%jphi, &
132 equil_out(1)%profiles_1d%q, equil_out(1)%profiles_1d%vprime, &
133 fraction_circ, moments, n_moments, &
134 surface_powers, surface_integrals, n_var_surfaces, n_int_surfaces, &
135 volume_powers, volume_integrals, n_var_volumes, n_int_volumes, n_psi_out, n_tht_out, &
136 amin_out, rgeo_out, zgeo_out, &
137 area_out, volume_out, betap_out, xip_out, xli_out, betat_out, &
138 r_axis_out, z_axis_out, b_axis_out, psi_axis_out, psi_bnd_out, &
139 rrflux,zzflux,psflux)
141 write(*,*)
' helena21 done'
143 write(*,*) n_psi_out, n_tht_out
144 write(*,*)
' magnetic axis : ',r_axis_out,z_axis_out
146 allocate(equil_out(1)%datainfo%dataprovider(1))
147 equil_out(1)%datainfo%dataprovider(1) =
' HELENA2 '
148 equil_out(1)%time = equil_in(1)%time
150 equil_out(1)%global_param%area = area_out
151 equil_out(1)%global_param%volume = volume_out
153 equil_out(1)%global_param%psi_ax = psi_axis_out
154 equil_out(1)%global_param%psi_bound = psi_bnd_out
155 equil_out(1)%global_param%beta_pol = betap_out
156 equil_out(1)%global_param%I_plasma = xip_out
157 equil_out(1)%global_param%li = xli_out
158 equil_out(1)%global_param%beta_tor = betat_out
159 equil_out(1)%global_param%beta_normal = 1.256637061*betat_out / xip_out
162 equil_out(1)%global_param%mag_axis%position%r = r_axis_out
163 equil_out(1)%global_param%mag_axis%position%z = z_axis_out
164 equil_out(1)%global_param%mag_axis%bphi = b_axis_out
168 equil_out(1)%eqgeometry%a_minor = amin_out
169 equil_out(1)%eqgeometry%geom_axis%r = rgeo_out
170 equil_out(1)%eqgeometry%geom_axis%z = zgeo_out
174 allocate(equil_out(1)%eqgeometry%boundary(1),equil_out(1)%eqgeometry%boundary(1)%r(nchi),equil_out(1)%eqgeometry%boundary(1)%z(nchi))
177 node = nchi*(n_psi_out-1) + j
178 equil_out(1)%eqgeometry%boundary(1)%r(j) = rrflux(1,node)
179 equil_out(1)%eqgeometry%boundary(1)%z(j) = zzflux(1,node)
182 allocate(equil_out(1)%profiles_1d%volume(n_psi_out))
183 allocate(equil_out(1)%profiles_1d%rho_vol(n_psi_out))
184 allocate(equil_out(1)%profiles_1d%area(n_psi_out))
185 allocate(equil_out(1)%profiles_1d%phi(n_psi_out))
186 allocate(equil_out(1)%profiles_1d%gm1(n_psi_out))
187 allocate(equil_out(1)%profiles_1d%gm2(n_psi_out))
188 allocate(equil_out(1)%profiles_1d%gm3(n_psi_out))
189 allocate(equil_out(1)%profiles_1d%gm4(n_psi_out))
190 allocate(equil_out(1)%profiles_1d%gm5(n_psi_out))
191 allocate(equil_out(1)%profiles_1d%gm6(n_psi_out))
192 allocate(equil_out(1)%profiles_1d%gm7(n_psi_out))
195 equil_out(1)%profiles_1d%volume(1:n_psi_out) = volume_integrals(1:n_psi_out,1)
196 equil_out(1)%profiles_1d%area(1:n_psi_out) = volume_integrals(1:n_psi_out,3)
197 equil_out(1)%profiles_1d%phi(1:n_psi_out) = volume_integrals(1:n_psi_out,2) / &
201 equil_out(1)%profiles_1d%rho_vol=sqrt(abs(equil_out(1)%profiles_1d%volume/equil_out(1)%profiles_1d%volume(n_psi_out)))
204 dpsi_drho = 2.e0_r8 * sqrt(equil_out(1)%profiles_1d%phi/(pi * bgeo_in)) / &
205 equil_out(1)%profiles_1d%q / abs(psi_axis_out - psi_bnd_out)
206 dpsi_drho = 2.e0_r8 * sqrt(equil_out(1)%profiles_1d%phi/(pi * bgeo_in)) / equil_out(1)%profiles_1d%q
209 equil_out(1)%profiles_1d%vprime = equil_out(1)%profiles_1d%vprime * dpsi_drho
213 equil_out(1)%profiles_1d%gm1 = surface_integrals(1:n_psi_out,1)
214 equil_out(1)%profiles_1d%gm2 = surface_integrals(1:n_psi_out,2) / dpsi_drho**2
215 equil_out(1)%profiles_1d%gm3 = surface_integrals(1:n_psi_out,3) / dpsi_drho**2
216 equil_out(1)%profiles_1d%gm4 = surface_integrals(1:n_psi_out,4)
217 equil_out(1)%profiles_1d%gm5 = surface_integrals(1:n_psi_out,5)
218 equil_out(1)%profiles_1d%gm6 = surface_integrals(1:n_psi_out,6) / dpsi_drho**2
219 equil_out(1)%profiles_1d%gm7 = surface_integrals(1:n_psi_out,7) / dpsi_drho
300 allocate(equil_out(1)%profiles_1d%r_inboard(n_psi_out))
301 allocate(equil_out(1)%profiles_1d%r_outboard(n_psi_out))
303 ileft = (i-1)*n_tht_out + n_tht_out /2.e0_r8 + 1
304 iright = (i-1)*n_tht_out + 1
305 equil_out(1)%profiles_1d%r_inboard(i) = rrflux(1,ileft)
306 equil_out(1)%profiles_1d%r_outboard(i) = rrflux(1,iright)
309 allocate(equil_out(1)%profiles_1d%ftrap(n_psi_out))
310 equil_out(1)%profiles_1d%ftrap = 1.e0_r8 - fraction_circ
313 WRITE(*,*)
' COORD_SYS : ',n_psi_out,nchi
318 allocate(equil_out(1)%coord_sys%position%R(n_psi_out,nchi))
319 allocate(equil_out(1)%coord_sys%position%Z(n_psi_out,nchi))
332 node = (i-1)*nchi + j
334 equil_out(1)%coord_sys%position%R(i,j) = rrflux(1,node)
335 equil_out(1)%coord_sys%position%Z(i,j) = zzflux(1,node)
350 equil_out(1)%profiles_1d%psi=-2.0_r8*itm_pi*equil_out(1)%profiles_1d%psi
351 equil_out(1)%profiles_1d%psi=equil_out(1)%profiles_1d%psi-equil_out(1)%profiles_1d%psi(1)
subroutine helena21itm(equil_in, equil_out)
subroutine cos_zconversion(e, nbrho)
subroutine helena21(R_bnd_in, Z_bnd_in, n_bnd_in, Rgeo_in, Zgeo_in, amin_in, ellip_in, tria_u_in, tria_l_in, quad_u_in, quad_l_in, Bgeo_in, psi_in, pprime_in, ffprime_in, pressure_in, fdia_in, current_in, n_prof_in, iopt_p, iopt_f, nr_grid, np_grid, psi_out, pprime_out, ffprime_out, pressure_out, fdia_out, current_out, qprof_out, vprime, fraction_circ, moments, n_moments, surface_powers, surface_integrals, n_var_surfaces, n_int_surfaces, volume_powers, volume_integrals, n_var_volumes, n_int_volumes, n_psi_out, n_tht_out, amin_out, Rgeo_out, Zgeo_out, area_out, volume_out, betap_out, xip_out, xli_out, beta_out, R_axis_out, Z_axis_out, B_axis_out, psi_axis_out, psi_bnd_out, RRflux, ZZflux, PSflux)