ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
manipulator_tools.f90
Go to the documentation of this file.
2 !--------------------------------------------------------
3 !-------------------------------------------------------!
4 ! This module defines types of internal !
5 ! variables used by IMPURITY_MANIPULATOR !
6 !-------------------------------------------------------!
7 ! Developers: D.Kalupin !
8 ! Contacts: Denis.Kalupin@euro-fusion.org !
9 ! !
10 ! Comments: created for the ETS !
11 ! !
12 !-------------------------------------------------------!
13 !--------------------------------------------------------
14 
15 CONTAINS
16 !--------------------------------------------------------
17 !--------------------------------------------------------
18  SUBROUTINE output_compositions (PARAM, COREPROF, COREIMPUR, DIAG)
19 
21  USE ets_plasma
22  USE euitm_schemas
23  USE itm_types
25 
26  IMPLICIT NONE
27  TYPE (type_coreprof), POINTER :: coreprof(:)
28  TYPE (type_coreimpur), POINTER :: coreimpur(:)
29  TYPE (type_compositionc),POINTER :: compositionc(:)
30  TYPE (manipulator_param) :: param
31  TYPE (diagnostic) :: diag
32 
33  REAL (R8), ALLOCATABLE :: amn(:)
34  REAL (R8), ALLOCATABLE :: zn(:)
35  INTEGER, ALLOCATABLE :: nucindex(:)
36  INTEGER, ALLOCATABLE :: nzimp(:)
37  INTEGER, ALLOCATABLE :: ncomp(:)
38  INTEGER, ALLOCATABLE :: ntype(:)
39 
40  INTEGER :: nrho
41  INTEGER :: nnucl
42  INTEGER :: inucl
43  INTEGER :: iimp, izimp
44 
45  ALLOCATE (amn(param%NIMP))
46  ALLOCATE (zn(param%NIMP))
47  ALLOCATE (nucindex(param%NIMP))
48  ALLOCATE (nzimp(param%NIMP))
49 
50  nnucl = 0
51  DO iimp = 1,param%NIMP
52  IF (param%AMN_IMP(iimp).GT.0._r8.AND.param%ZN_IMP(iimp).GT.0._r8) THEN
53  IF (nnucl.GE.1) THEN
54  DO inucl = 1, nnucl
55  IF (abs(amn(inucl)-param%AMN_IMP(iimp)) .LE. 0.25 .AND. &
56  abs(zn(inucl)-param%ZN_IMP(iimp)) .LE. 0.25) THEN
57  nucindex(iimp) = inucl
58  goto 12
59  END IF
60  ENDDO
61  ENDIF
62  nnucl = nnucl + 1
63  amn(nnucl) = param%AMN_IMP(iimp)
64  zn(nnucl) = param%ZN_IMP(iimp)
65  nucindex(iimp) = nnucl
66  12 CONTINUE
67  END IF
68  IF (trim(adjustl(param%ISTATE(iimp))).EQ."all") THEN
69  nzimp(iimp) = maxval(param%Z_IMP(iimp,:))
70  ELSE
71  nzimp(iimp) = 1
72  END IF
73  END DO
74 
75  nrho = SIZE(coreprof(1)%rho_tor)
76 
77  CALL allocate_coreimpur_cpo(1, nrho, nnucl, 0, param%NIMP, nzimp, 0, ntype, ncomp, coreimpur)
78 
79 ! +++ Nuclei:
80  DO inucl = 1, nnucl
81  coreimpur(1)%compositions%NUCLEI(inucl)%zn = zn(inucl)
82  coreimpur(1)%compositions%NUCLEI(inucl)%amn = amn(inucl)
83  coreimpur(1)%compositions%NUCLEI(inucl)%label = " "
84  END DO
85 
86 
87 ! +++ Impurities:
88  DO iimp = 1, param%NIMP
89  coreimpur(1)%compositions%IMPURITIES(iimp)%nucindex = nucindex(iimp)
90  coreimpur(1)%compositions%IMPURITIES(iimp)%nzimp = nzimp(iimp)
91  IF (trim(adjustl(param%ISTATE(iimp))).EQ."all") THEN
92  DO izimp = 1, nzimp(iimp)
93  coreimpur(1)%compositions%IMPURITIES(iimp)%zmin(izimp) = izimp
94  coreimpur(1)%compositions%IMPURITIES(iimp)%zmax(izimp) = izimp
95  coreimpur(1)%IMPURITY(iimp)%z(:,izimp) = izimp
96  coreimpur(1)%IMPURITY(iimp)%zsq(:,izimp) = izimp**2
97  coreimpur(1)%compositions%IMPURITIES(iimp)%label(izimp) = " "
98  END DO
99  ELSE
100  coreimpur(1)%compositions%IMPURITIES(iimp)%zmin(:) = maxval(param%Z_IMP(iimp,:))
101  coreimpur(1)%compositions%IMPURITIES(iimp)%zmax(:) = maxval(param%Z_IMP(iimp,:))
102  coreimpur(1)%IMPURITY(iimp)%z(:,:) = maxval(param%Z_IMP(iimp,:))
103  coreimpur(1)%IMPURITY(iimp)%zsq(:,:) = maxval(param%Z_IMP(iimp,:))**2
104  coreimpur(1)%compositions%IMPURITIES(iimp)%label(:) = " "
105  END IF
106 
107  END DO
108 
109 ! +++ grid:
110  coreimpur(1)%rho_tor = coreprof(1)%rho_tor
111  coreimpur(1)%rho_tor_norm = coreprof(1)%rho_tor_norm
112 
113  RETURN
114 
115  END SUBROUTINE output_compositions
116 !--------------------------------------------------------
117 !--------------------------------------------------------
118 
119 
120 
121 !--------------------------------------------------------
122 !--------------------------------------------------------
123  SUBROUTINE constant_profiles (IIMP, PARAM, COREIMPUR, DIAG)
124 
125  USE ets_plasma
126  USE euitm_schemas
127  USE itm_types
128  USE manipulator_type
129 
130  IMPLICIT NONE
131  TYPE (type_coreimpur), POINTER :: coreimpur(:)
132  TYPE (manipulator_param) :: param
133  TYPE (diagnostic) :: diag
134 
135  INTEGER :: iimp, izimp
136 
137  DO izimp = 1, SIZE(coreimpur(1)%IMPURITY(iimp)%nz, dim=2)
138  coreimpur(1)%IMPURITY(iimp)%nz(:,izimp) = param%DENS(iimp,izimp)
139 
140  coreimpur(1)%IMPURITY(iimp)%boundary%type(izimp) = 0
141 
142  coreimpur(1)%IMPURITY(iimp)%boundary%value(1,izimp) = param%DENS(iimp,izimp)
143  coreimpur(1)%IMPURITY(iimp)%boundary%value(2,izimp) = 0.0_r8
144  coreimpur(1)%IMPURITY(iimp)%boundary%value(3,izimp) = 0.0_r8
145 
146  IF (param%DENS(iimp,izimp).LE.0.0_r8.OR.param%DENS(iimp,izimp).GT.1.e30_r8) THEN
147  diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//" your settings for density might be wrong."
148  diag%IERR = diag%IERR+1
149  END IF
150  END DO
151 
152  RETURN
153 
154  END SUBROUTINE constant_profiles
155 !--------------------------------------------------------
156 !--------------------------------------------------------
157 
158 
159 
160 !--------------------------------------------------------
161 !--------------------------------------------------------
162  SUBROUTINE derive_profiles (IIMP, PARAM, COREPROF, COREIMPUR, DIAG)
163 
164  USE ets_plasma
165  USE euitm_schemas
166  USE itm_types
167  USE manipulator_type
168 
169  IMPLICIT NONE
170  TYPE (type_coreprof), POINTER :: coreprof(:)
171  TYPE (type_coreimpur), POINTER :: coreimpur(:)
172  TYPE (manipulator_param) :: param
173  TYPE (diagnostic) :: diag
174 
175  INTEGER :: iimp, izimp, iion, inucl
176 
177  REAL (R8), ALLOCATABLE :: prof(:)
178 
179  ALLOCATE (prof(SIZE(coreprof(1)%rho_tor)))
180  prof = 0.0_r8
181 
182 
183  IF (param%PROF_SOURCE(iimp).EQ."electrons") THEN
184  prof = coreprof(1)%ne%value
185 
186  ELSE IF (param%PROF_SOURCE(iimp).EQ."selected_ion") THEN
187  DO iion = 1,SIZE(coreprof(1)%ni%value, dim=2)
188  inucl= coreprof(1)%COMPOSITIONS%IONS(iion)%nucindex
189  IF (inucl.LE.0 .OR. inucl.GT.SIZE(coreprof(1)%COMPOSITIONS%NUCLEI)) goto 5
190 
191  IF &
192  (abs(coreprof(1)%COMPOSITIONS%NUCLEI(inucl)%amn - param%AMN_ION(iimp)) .LE. 0.25_r8 .AND. &
193  abs(coreprof(1)%COMPOSITIONS%NUCLEI(inucl)%zn - param%ZN_ION(iimp) ) .LE. 0.25_r8 .AND. &
194  abs(coreprof(1)%COMPOSITIONS%IONS(iion)%zion - param%Z_ION(iimp)) .LE. 0.25_r8) THEN
195  prof(:) = coreprof(1)%ni%value(:,iion)
196  EXIT
197  END IF
198 5 CONTINUE
199  END DO
200 
201  ELSE IF (param%PROF_SOURCE(iimp).EQ."ions_total") THEN
202  DO iion = 1,SIZE(coreprof(1)%ni%value, dim=2)
203  prof(:) = prof(:)+coreprof(1)%ni%value(:,iion)
204  END DO
205  END IF
206 
207  DO izimp = 1, SIZE(coreimpur(1)%IMPURITY(iimp)%nz, dim=2)
208  coreimpur(1)%IMPURITY(iimp)%nz(:,izimp) = prof(:)*param%FRA(iimp,izimp)
209 
210  coreimpur(1)%IMPURITY(iimp)%boundary%type(izimp) = 0
211 
212  coreimpur(1)%IMPURITY(iimp)%boundary%value(1,izimp) = prof(SIZE(prof))*param%FRA(iimp,izimp)
213  coreimpur(1)%IMPURITY(iimp)%boundary%value(2,izimp) = 0.0_r8
214  coreimpur(1)%IMPURITY(iimp)%boundary%value(3,izimp) = 0.0_r8
215 
216  IF (param%FRA(iimp,izimp).LE.0.0_r8.OR.param%FRA(iimp,izimp).GT.1000_r8) THEN
217  diag%ERROR_MESSAGE = trim(adjustl(diag%ERROR_MESSAGE))//" your settings for fractions might be wrong."
218  diag%IERR = diag%IERR+1
219  END IF
220  END DO
221 
222 
223  RETURN
224 
225  END SUBROUTINE derive_profiles
226 !--------------------------------------------------------
227 !--------------------------------------------------------
228 
229 
230 
231 !--------------------------------------------------------
232 !--------------------------------------------------------
233  SUBROUTINE coronal_profiles (IIMP, PARAM, COREPROF, COREIMPUR, DIAG)
234 
235  USE coronal
236  USE ets_plasma
237  USE euitm_schemas
238  USE itm_types
239  USE manipulator_type
240 
241  IMPLICIT NONE
242  TYPE (type_coreprof), POINTER :: coreprof(:)
243  TYPE (type_coreimpur), POINTER :: coreimpur(:)
244  TYPE (manipulator_param) :: param
245  TYPE (diagnostic) :: diag
246 
247  INTEGER :: iimp, izimp, nzimp, irho, nrho
248  REAL (R8), ALLOCATABLE :: ne(:), te(:), n_impurity(:,:)
249 
250  nrho = SIZE(coreimpur(1)%rho_tor)
251  nzimp= int(param%ZN_IMP(iimp))
252  ALLOCATE (ne(nrho))
253  ALLOCATE (te(nrho))
254  ALLOCATE (n_impurity(nrho,nzimp))
255 
256  ne = coreprof(1)%ne%value
257  te = coreprof(1)%te%value
258 
259  CALL coronal_distribution(nrho, ne, te, param%AMN_IMP(iimp), param%ZN_IMP(iimp), nzimp, n_impurity)
260 
261  DO irho = 1,nrho
262  DO izimp = 1,nzimp
263  IF (n_impurity(nrho,izimp).LE.1.0d-200) n_impurity(nrho,izimp) = 0._r8
264  ENDDO
265  ENDDO
266 
267  DO izimp = 1,nzimp
268  coreimpur(1)%IMPURITY(iimp)%nz(:,izimp) = n_impurity(:,izimp)*param%DENS(iimp,1)
269 
270  coreimpur(1)%IMPURITY(iimp)%boundary%type(izimp) = 0
271 
272  coreimpur(1)%IMPURITY(iimp)%boundary%value(1,izimp) = n_impurity(nrho,izimp)*param%DENS(iimp,1)
273  coreimpur(1)%IMPURITY(iimp)%boundary%value(2,izimp) = 0.0_r8
274  coreimpur(1)%IMPURITY(iimp)%boundary%value(3,izimp) = 0.0_r8
275  END DO
276 
277 
278  DEALLOCATE (ne)
279  DEALLOCATE (te)
280  DEALLOCATE (n_impurity)
281 
282 
283  RETURN
284 
285  END SUBROUTINE coronal_profiles
286 !--------------------------------------------------------
287 !--------------------------------------------------------
288 
289 
290 
291 
292 
293 END MODULE manipulator_tools
294 !--------------------------------------------------------
295 !--------------------------------------------------------
subroutine allocate_coreimpur_cpo(NSLICE, NRHO, NNUCL, NION, NIMP, NZIMP, NNEUT, NTYPE, NCOMP, COREIMPUR)
This routine allocates COREIMPUR CPO.
subroutine coronal_distribution(NRHO, NE, TE, AMN, ZN, NZIMP1, N_IMPURITY)
Definition: coronal.f90:202
subroutine coronal_profiles(IIMP, PARAM, COREPROF, COREIMPUR, DIAG)
This module contains routines for allocation/deallocation if CPOs used in ETS.
subroutine constant_profiles(IIMP, PARAM, COREIMPUR, DIAG)
subroutine derive_profiles(IIMP, PARAM, COREPROF, COREIMPUR, DIAG)
subroutine output_compositions(PARAM, COREPROF, COREIMPUR, DIAG)
The module declares types of variables used in ETS (transport code)
Definition: ets_plasma.f90:8