53 real** offload_array) {
55 int N_reac = offload_data->
N_reac;
58 int temp_arr_length = 6 * N_reac;
59 for(
int i_reac = 0; i_reac < N_reac; i_reac++) {
60 int N_E = offload_data->
N_E[i_reac];
61 int N_n = offload_data->
N_n[i_reac];
62 int N_T = offload_data->
N_T[i_reac];
63 int dim = (N_E > 1) + (N_n > 1) + (N_T > 1);
66 temp_arr_length += N_E * NSIZE_COMP1D;
70 temp_arr_length += N_E * N_T * NSIZE_COMP2D;
74 temp_arr_length += N_E * N_n * N_T * NSIZE_COMP3D;
79 print_err(
"Error: Unrecognized abscissa dimensionality\n");
84 real* temp_array = (
real*) malloc(temp_arr_length*
sizeof(
real));
88 real * temp_arr_pos = temp_array + 6 * N_reac;
89 real * offload_arr_pos = *offload_array + 6 * N_reac;
93 for(
int i_reac = 0; i_reac < N_reac; i_reac++) {
94 int N_E = offload_data->
N_E[i_reac];
95 int N_n = offload_data->
N_n[i_reac];
96 int N_T = offload_data->
N_T[i_reac];
97 int dim = (N_E > 1) + (N_n > 1) + (N_T > 1);
99 real E_min = (*offload_array)[0*N_reac+i_reac];
100 real E_max = (*offload_array)[1*N_reac+i_reac];
101 real n_min = (*offload_array)[2*N_reac+i_reac];
102 real n_max = (*offload_array)[3*N_reac+i_reac];
103 real T_min = (*offload_array)[4*N_reac+i_reac];
104 real T_max = (*offload_array)[5*N_reac+i_reac];
105 temp_array[ 0*N_reac+i_reac] = E_min;
106 temp_array[ 1*N_reac+i_reac] = E_max;
107 temp_array[ 2*N_reac+i_reac] = n_min;
108 temp_array[ 3*N_reac+i_reac] = n_max;
109 temp_array[ 4*N_reac+i_reac] = T_min;
110 temp_array[ 5*N_reac+i_reac] = T_max;
114 temp_arr_pos, offload_arr_pos,
118 temp_arr_pos += N_E * NSIZE_COMP1D;
119 offload_arr_pos += N_E;
124 temp_arr_pos, offload_arr_pos,
129 temp_arr_pos += N_E * N_T * NSIZE_COMP2D;
130 offload_arr_pos += N_E * N_T;
135 temp_arr_pos, offload_arr_pos,
141 temp_arr_pos += N_E * N_n * N_T * NSIZE_COMP3D;
142 offload_arr_pos += N_E * N_n * N_T;
147 print_err(
"Error: Unrecognized abscissa dimensionality\n");
153 free(*offload_array);
154 *offload_array = temp_array;
162 for(
int i_reac = 0; i_reac < N_reac; i_reac++) {
164 "Reaction number / Total number of reactions = %d / %d\n"
165 " Reactant species Z_1 / A_1, Z_2 / A_2 = %d / %d, %d / %d\n"
166 " Min/Max energy = %1.2le / %1.2le\n"
167 " Min/Max density = %1.2le / %1.2le\n"
168 " Min/Max temperature = %1.2le / %1.2le\n"
169 " Number of energy grid points = %d\n"
170 " Number of density grid points = %d\n"
171 " Number of temperature grid points = %d\n",
173 offload_data->
z_1[i_reac], offload_data->
a_1[i_reac],
174 offload_data->
z_2[i_reac], offload_data->
a_2[i_reac],
175 (*offload_array)[0 * N_reac + i_reac],
176 (*offload_array)[1 * N_reac + i_reac],
177 (*offload_array)[2 * N_reac + i_reac],
178 (*offload_array)[3 * N_reac + i_reac],
179 (*offload_array)[4 * N_reac + i_reac],
180 (*offload_array)[5 * N_reac + i_reac],
181 offload_data->
N_E[i_reac],
182 offload_data->
N_n[i_reac],
183 offload_data->
N_T[i_reac]);
198 real** offload_array) {
199 free(*offload_array);
200 *offload_array = NULL;
218 real* offload_array) {
220 int N_reac = offload_data->
N_reac;
224 real* offload_arr_pos = offload_array + 6 * N_reac;
228 for(
int i_reac = 0; i_reac < N_reac; i_reac++) {
239 int N_E = offload_data->
N_E[i_reac];
240 real E_min = offload_array[0*N_reac+i_reac];
241 real E_max = offload_array[1*N_reac+i_reac];
242 int N_n = offload_data->
N_n[i_reac];
243 real n_min = offload_array[2*N_reac+i_reac];
244 real n_max = offload_array[3*N_reac+i_reac];
245 int N_T = offload_data->
N_T[i_reac];
246 real T_min = offload_array[4*N_reac+i_reac];
247 real T_max = offload_array[5*N_reac+i_reac];
248 int dim = (N_E > 1) + (N_n > 1) + (N_T > 1);
256 offload_arr_pos += N_E *NSIZE_COMP1D;
266 offload_arr_pos += N_E * N_T * NSIZE_COMP2D;
271 &(
asigma_data->BMSsigmav[i_reac]), offload_arr_pos,
277 offload_arr_pos += N_E * N_n * N_T * NSIZE_COMP3D;
282 print_err(
"Error: Unrecognized abscissa dimensionality\n");
310 real* sigma,
int z_1,
int a_1,
int z_2,
int a_2,
real E_coll_per_amu,
316 int reac_found = -1, i_reac;
317 for(i_reac = 0; i_reac <
asigma_data->N_reac; i_reac++) {
335 if(
asigma_data->reac_type[i_reac] == sigma_ioniz ||
385 real* sigmav,
int z_1,
int a_1,
real m_1,
int z_2,
int a_2,
397 int reac_found = -1, i_reac;
398 for(i_reac = 0; i_reac <
asigma_data->N_reac; i_reac++) {
399 if(reac_type == sigmav_BMS &&
419 if(reac_type == sigmav_ioniz ||
420 reac_type == sigmav_recomb ||
421 reac_type == sigmav_CX) {
432 }
else if(reac_type == sigmav_BMS) {
478 real* ratecoeff,
int z_1,
int a_1,
real E,
real mass,
int nspec,
479 const int* znum,
const int* anum,
real T_0,
real* n_0,
int extrapolate,
487 for(
int i_spec = 0; i_spec < nspec; i_spec++) {
490 int reac_found = -1, i_reac;
491 for(i_reac = 0; i_reac <
asigma_data->N_reac; i_reac++) {
519 *ratecoeff += sigmav*n_0[i_spec];
550 real* ratecoeff,
int z_1,
int a_1,
real E,
real mass,
int nion,
551 const int* znum,
const int* anum,
real T_e,
real* n_i,
int extrapolate,
561 int reac_found = -1;
real n_e = 0; *ratecoeff = 0;
562 for(
int i_spec = 0; i_spec < nion; i_spec++) {
563 n_e += znum[i_spec] * n_i[i_spec];
564 for(
int i_reac = 0; i_reac <
asigma_data->N_reac; i_reac++) {
573 E_eV/anum[i_spec], znum[i_spec] * n_i[i_spec], T_e);
584 *ratecoeff += sigmav * ( znum[i_spec] * n_i[i_spec]);
595 if(
suzuki_sigmav(ratecoeff, E/a_1, vnorm, n_e, T_e, nion, n_i, anum,
Main header file for ASCOT5.
Header file for asigma.c.
void asigma_loc_free_offload(asigma_loc_offload_data *offload_data, real **offload_array)
Free offload array and reset parameters.
a5err asigma_loc_eval_cx(real *ratecoeff, int z_1, int a_1, real E, real mass, int nspec, const int *znum, const int *anum, real T_0, real *n_0, int extrapolate, asigma_loc_data *asigma_data)
Evaluate atomic reaction rate coefficient.
a5err asigma_loc_eval_sigma(real *sigma, int z_1, int a_1, int z_2, int a_2, real E_coll_per_amu, int reac_type, int extrapolate, asigma_loc_data *asigma_data)
Evaluate atomic reaction cross-section.
void asigma_loc_init(asigma_loc_data *asigma_data, asigma_loc_offload_data *offload_data, real *offload_array)
Initialize atomic reaction data struct on target.
a5err asigma_loc_eval_sigmav(real *sigmav, int z_1, int a_1, real m_1, int z_2, int a_2, real E, real T_e, real T_0, real n_i, int reac_type, int extrapolate, asigma_loc_data *asigma_data)
Evaluate atomic reaction rate coefficient.
int asigma_loc_init_offload(asigma_loc_offload_data *offload_data, real **offload_array)
Initialize local file atomic data and check inputs.
a5err asigma_loc_eval_bms(real *ratecoeff, int z_1, int a_1, real E, real mass, int nion, const int *znum, const int *anum, real T_e, real *n_i, int extrapolate, asigma_loc_data *asigma_data)
Evaluate beam stopping rate coefficient.
Header file for asigma_loc.c.
Header file containing physical and mathematical constants.
#define CONST_E
Elementary charge [C]
unsigned long int a5err
Simulation error flag.
static DECLARE_TARGET_SIMD a5err error_raise(error_type type, int line, error_file file)
Raise a new error.
Spline interpolation library.
DECLARE_TARGET_END a5err interp3Dcomp_eval_f(real *f, interp3D_data *str, real x, real y, real z)
Evaluate interpolated value of 3D scalar field.
int interp3Dcomp_init_coeff(real *c, real *f, int n_x, int n_y, int n_z, int bc_x, int bc_y, int bc_z, real x_min, real x_max, real y_min, real y_max, real z_min, real z_max)
Calculate tricubic spline interpolation coefficients for 3D data.
int interp1Dcomp_init_coeff(real *c, real *f, int n_x, int bc_x, real x_min, real x_max)
Calculate cubic spline interpolation coefficients for scalar 1D data.
int interp2Dcomp_init_coeff(real *c, real *f, int n_x, int n_y, int bc_x, int bc_y, real x_min, real x_max, real y_min, real y_max)
Calculate bicubic spline interpolation coefficients for scalar 2D data.
a5err interp1Dcomp_eval_f(real *f, interp1D_data *str, real x)
Evaluate interpolated value of 1D scalar field.
void interp3Dcomp_init_spline(interp3D_data *str, real *c, int n_x, int n_y, int n_z, int bc_x, int bc_y, int bc_z, real x_min, real x_max, real y_min, real y_max, real z_min, real z_max)
Initialize a tricubic spline.
void interp2Dcomp_init_spline(interp2D_data *str, real *c, int n_x, int n_y, int bc_x, int bc_y, real x_min, real x_max, real y_min, real y_max)
Initialize a bicubic spline.
void interp1Dcomp_init_spline(interp1D_data *str, real *c, int n_x, int bc_x, real x_min, real x_max)
Initialize a cubic spline.
DECLARE_TARGET_END a5err interp2Dcomp_eval_f(real *f, interp2D_data *str, real x, real y)
Evaluate interpolated value of a 2D field.
Methods to evaluate elementary physical quantities.
#define physlib_vnorm_gamma(gamma)
Evaluate velocity norm from Lorentz factor.
#define physlib_gamma_Ekin(m, ekin)
Evaluate Lorentz factor from kinetic energy [J].
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
#define print_err(...)
Print to standard error.
Atomic reaction simulation data.
Local-files atomic reaction simulation data.
Local-files atomic reaction offload data.
int reac_type[MAX_ATOMIC]
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.
Header file for suzuki.c.