ASCOT5
Loading...
Searching...
No Matches
suzuki.c
Go to the documentation of this file.
1
14#include <math.h>
15#include <stdio.h>
16#include <stdlib.h>
17#include "ascot5.h"
18#include "consts.h"
19#include "error.h"
20#include "suzuki.h"
21
22#define N_IMPURITY_DATA 7
23
33real A_highE[3][10] = {
34{12.7, 1.25, 0.452, 0.0105, 0.547, -0.102, 0.360, -0.0298, -0.0959, 4.21e-3},
35{14.1, 1.11, 0.408, 0.0105, 0.547, -0.0403, 0.345, -0.0288, -0.0971, 4.74e-3},
36{12.7, 1.26, 0.449, 0.0105, 0.547, -0.00577, 0.336, -0.0282, -0.0974, 4.87e-3}
37};
38
48real A_lowE[3][10] = {
49{-52.9, -1.36, 0.0719, 0.0137, 0.454, 0.403, -0.220, 0.0666, -0.0677, -1.48e-3},
50{-67.9, -1.22, 0.0814, 0.0139, 0.454, 0.465, -0.273, 0.0751, -0.0630, -5.08e-4},
51{-74.2, -1.18, 0.0843, 0.0139, 0.453, 0.491, -0.294, 0.0788, -0.0612, -1.85e-4}
52};
53
57integer Z_imp[] = { 2, 6, 6, 8, 7, 5, 26 };
58
62real Zeffmin_imp[] = { 1.0, 1.0, 5.0, 1.0, 1.0, 1.0, 1.0 };
63
69real Zeffmax_imp[] = { 2.1, 5.0, 6.0, 5.0, 5.0, 5.0, 5.0 };
70
80real B_highE[N_IMPURITY_DATA][12] = {
81 { 0.231, 0.343, -0.185, -0.162e-1, 0.105, -0.703e-1,
82 0.531e-1, 0.342e-2, -0.838e-2, 0.415e-2, -0.335e-2, -0.221e-3 },
83 { -0.101e1, -0.865e-2, -0.124, -0.145e-1, 0.391, 0.161e-1,
84 0.298e-1, 0.332e-2, -0.248e-1, -0.104e-2, -0.152e-2, -0.189e-3 },
85 { -0.100e1, -0.255e-1, -0.125, -0.142e-1, 0.388, 0.206e-1,
86 0.297e-1, 0.326e-2, -0.246e-1, -0.131e-2, -0.148e-2, -0.180e-3 },
87 //{ -0.613, 0.552e-1, -0.167, -0.159e-1, 0.304, 0.154e-2,
88 // 0.436e-1, 0.378e-2, -0.201e-1, -0.216e-3, -0.251e-2, -0.227e-3 },
89 { -0.102e1, -0.148e-1, -0.674e-1, -0.917e-2, 0.359, 0.143e-1,
90 0.139e-1, 0.184e-2, -0.209e-1, -0.732e-3, -0.502e-3, -0.949e-4 },
91 { -0.102e1, -0.139e-1, -0.979e-1, -0.117e-1, 0.375, 0.156e-1,
92 0.224e-1, 0.254e-2, -0.226e-1, -0.889e-3, -0.104e-2, -0.139e-3 },
93 //{ -0.441, 0.129, -0.170, -0.162e-1, 0.277, -0.156e-1,
94 // 0.466e-1, 0.379e-2, -0.193e-1, 0.753e-3, -0.286e-2, -0.239e-3 },
95 { -0.732, 0.183e-1, -0.155, -0.172e-1, 0.321, 0.946e-2,
96 0.397e-1, 0.420e-2, -0.204e-1, -0.619e-3, -0.224e-2, -0.254e-3 },
97 { -0.820, -0.636e-2, 0.542e-1, 0.395e-2, 0.202, 0.806e-3,
98 -0.200e-2, -0.178e-2, -0.610e-2, 0.651e-3, 0.175e-2, 0.146e-3 }
99};
100
111real B_lowE[N_IMPURITY_DATA][12] = {
112 { -0.792, 0.420e-1, 0.530e-1, -0.139e-1, 0.301, -0.264e-1,
113 -0.299e-1, 0.607e-2, 0.272e-3, 0.611e-2, 0.347e-2, -0.919e-3 },
114 { 0.161, 0.598e-1, -0.336e-2, -0.426e-2, -0.157, -0.396e-1,
115 0.460e-2, 0.219e-2, 0.391e-1, 0.711e-2, -0.144e-2, -0.385e-3 },
116 { 0.158, 0.554e-1, -0.431e-2, -0.335e-2, -0.155, -0.374e-1,
117 0.537e-2, 0.174e-2, 0.388e-1, 0.683e-2, -0.160e-2, -0.322e-3 },
118 //{ 0.112, 0.495e-1, 0.116e-1, -0.286e-2, -0.149, -0.331e-1,
119 // -0.426e-2, 0.980e-3, 0.447e-1, 0.652e-2, -0.356e-3, -0.203e-3 },
120 { 0.111, 0.541e-1, -0.346e-3, -0.368e-2, -0.108, -0.347e-1,
121 0.193e-2, 0.181e-2, 0.280e-1, 0.604e-2, -0.841e-3, -0.317e-3 },
122 { 0.139, 0.606e-1, -0.306e-2, -0.455e-2, -0.133, -0.394e-1,
123 0.399e-2, 0.236e-2, 0.335e-1, 0.690e-2, -0.124e-2, -0.405e-3 },
124 //{ 0.112, 0.495e-1, 0.116e-1, -0.286e-2, -0.149, -0.331e-1,
125 // -0.426e-2, 0.980e-3, 0.447e-1, 0.652e-2, -0.356e-3, -0.203e-3 },
126 { 0.122, 0.527e-1, -0.430e-3, -0.318e-2, -0.151, -0.364e-1,
127 0.343e-2, 0.151e-2, 0.420e-1, 0.692e-2, -0.141e-2, -0.290e-3 },
128 { -0.110e-1, 0.202e-1, 0.946e-3, -0.409e-2, -0.666e-2, -0.117e-1,
129 -0.236e-3, 0.202e-2, 0.408e-2, 0.185e-2, -0.648e-4, -0.313e-3 }
130};
131
148a5err suzuki_sigmav(real* sigmav, real EperAmu, real vnorm, real ne, real te,
149 integer nion, real* ni, const int* anum, const int* znum) {
150 a5err err = 0;
151 /* Convert eperamu to keV and te to eV */
152 EperAmu /= (1e3*CONST_E);
153 te /= CONST_E;
154
155 int ind_H[3]; /* Indices of possible hydrogen species H, D, and T */
156 int n_H = 0; /* Total number of hydrogen species (max 3) */
157 int ind_Z[MAX_SPECIES]; /* Indices of impurity species */
158 int n_Z = 0; /* Total number of impurity species */
159
160 /* Separate ions into hydrogen species and impurities and calculate
161 * their total densities and Zeff */
162 real dens_H = 0.0, dens_Z = 0.0;
163 real Zeff_sum1 = 0.0, Zeff_sum2 = 0.0;
164 for(int i = 0; i < nion; i++) {
165 if(znum[i] == 1) {
166 ind_H[n_H] = i;
167 dens_H += ni[i];
168 n_H++;
169 } else {
170 ind_Z[n_Z] = i;
171 dens_Z += ni[i];
172 n_Z++;
173 }
174
175 Zeff_sum1 += ni[i] * znum[i] * znum[i];
176 Zeff_sum2 += ni[i] * znum[i];
177 }
178 real Zeff = Zeff_sum1 / Zeff_sum2;
179
180 if(n_H == 0) {
181 /* No hydrogen species present */
182 err = error_raise( ERR_INPUT_EVALUATION, __LINE__, EF_SUZUKI );
183 }
184
185 /* Select low- or high-energy coefficient tables */
186 real (*A)[10];
187 real (*B)[12];
188 if(EperAmu >= 9.0 && EperAmu < 100.0) {
189 A = A_lowE;
190 B = B_lowE;
191 } else if(EperAmu < 10000.0) {
192 A = A_highE;
193 B = B_highE;
194 } else {
195 /* Outside energy range, just put some data to avoid segfaults */
196 A = A_lowE;
197 B = B_lowE;
198 err = error_raise( ERR_INPUT_EVALUATION, __LINE__, EF_SUZUKI );
199 }
200
201 real logE = log(EperAmu);
202 real N = ne * 1.0e-19;
203 real logN = log(N);
204 real U = log(te * 1.0e-3);
205
206 /* Equation 28 for sigma_H */
207 real sigma_H = 0.0;
208 for(int i = 0; i < n_H; i++) {
209 real* Aijk = A[anum[ind_H[i]]-1];
210 /* Weight with density in case we have multiple hydrogen species */
211 sigma_H += ni[ind_H[i]]
212 * ( Aijk[0] * 1.e-16 / EperAmu )
213 * ( 1.0 + Aijk[1] * logE + Aijk[2] * logE * logE )
214 * ( 1.0 + pow( 1.0 - exp( -Aijk[3] * N ), Aijk[4] )
215 * (Aijk[5] + Aijk[6] * logE + Aijk[7] * logE * logE) )
216 * ( 1.0 + Aijk[8] * U + Aijk[9] * U * U );
217 }
218 sigma_H /= dens_H;
219
220 /* Equations 26 & 27 for Sz with Rui's correction for the sum */
221 real sigma_Z = 0, numerator = 0, denominator = 0;
222 for(int i = 0; i < n_Z; i++) {
223 int ind_B = -1;
224 for(int j = 0; j < N_IMPURITY_DATA; j++) {
225 if(Z_imp[j] == znum[ind_Z[i]] && Zeff > Zeffmin_imp[j]
226 && Zeff < Zeffmax_imp[j]) {
227 ind_B = j;
228 }
229 }
230 if(ind_B < 0 && !err) {
231 /* Data for the input species not tabulated */
232 err = error_raise( ERR_INPUT_EVALUATION, __LINE__, EF_SUZUKI );
233 }
234 denominator += znum[ind_Z[i]] * (znum[ind_Z[i]] - 1) * ni[ind_Z[i]];
235 numerator += znum[ind_Z[i]] * (znum[ind_Z[i]] - 1) * ni[ind_Z[i]]
236 * (B[ind_B][0]
237 + B[ind_B][1] * U
238 + B[ind_B][2] * logN
239 + B[ind_B][3] * logN * U
240 + B[ind_B][4] * logE
241 + B[ind_B][5] * logE * U
242 + B[ind_B][6] * logE * logN
243 + B[ind_B][7] * logE * logN * U
244 + B[ind_B][8] * logE * logE
245 + B[ind_B][9] * logE * logE * U
246 + B[ind_B][10] * logE * logE * logN
247 + B[ind_B][11] * logE * logE * logN * U);
248 }
249 if(denominator > 0)
250 sigma_Z = numerator / denominator;
251
252 /* Equation 24 and convert cm^2 to m^2*/
253 *sigmav = sigma_H * (1 + (Zeff - 1) * sigma_Z) * 1e-4;
254 /* Multiply with velocity to get correct units */
255 *sigmav *= vnorm;
256
257 if(err) { *sigmav = 0.0; }
258 return err;
259}
260
261#undef N_IMPURITY_DATA
Main header file for ASCOT5.
double real
Definition ascot5.h:85
long integer
Definition ascot5.h:84
#define MAX_SPECIES
Maximum number of plasma species.
Definition ascot5.h:95
Header file containing physical and mathematical constants.
#define CONST_E
Elementary charge [C].
Definition consts.h:35
Error module for ASCOT5.
unsigned long int a5err
Simulation error flag.
Definition error.h:17
@ EF_SUZUKI
Definition error.h:53
@ ERR_INPUT_EVALUATION
Definition error.h:63
static DECLARE_TARGET_SIMD a5err error_raise(error_type type, int line, error_file file)
Raise a new error.
Definition error.h:86
Header file for math.c.
real A_lowE[3][10]
Fitting parameters for Aijk in equation 28.
Definition suzuki.c:48
real Zeffmin_imp[]
Minimum valid Zeff corresponding to the tabulated values of Bijk.
Definition suzuki.c:62
real Zeffmax_imp[]
Maximum valid Zeff corresponding to the tabulated values of Bijk.
Definition suzuki.c:69
real A_highE[3][10]
Fitting parameters for Aijk in equation 28.
Definition suzuki.c:33
integer Z_imp[]
Charge number corresponding to the tabulated values of Bijk.
Definition suzuki.c:57
real B_highE[N_IMPURITY_DATA][12]
Fitting parameters for Bijk in equation 28.
Definition suzuki.c:80
real B_lowE[N_IMPURITY_DATA][12]
Fitting parameters for Bijk in equation 28.
Definition suzuki.c:111
a5err suzuki_sigmav(real *sigmav, real EperAmu, real vnorm, real ne, real te, integer nion, real *ni, const int *anum, const int *znum)
Calculate beam-stopping cross-section according to Suzuki model.
Definition suzuki.c:148
Header file for suzuki.c.